edu.neu.ccs.gui
Class ComponentFactory

java.lang.Object
  |
  +--edu.neu.ccs.gui.ComponentFactory

public class ComponentFactory
extends Object

Provides two static methods that take a given object and either (a) construct an appropriate Component or (b) construct an appropriate Icon.

Since:
2.0

Constructor Summary
ComponentFactory()
           
 
Method Summary
static Component makeComponent(Object o)
          Returns a Component suitable for display of the the given object in a GUI.
static Icon makeIcon(Object o)
          Returns an Icon associated with the given object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentFactory

public ComponentFactory()
Method Detail

makeComponent

public static Component makeComponent(Object o)

Returns a Component suitable for display of the the given object in a GUI.

If the parameter is already a Component then that Component is returned unchanged.

If the parameter is a String, Icon, Paint, Image, Shape, Paintable, or Action then the parameter will be suitably wrapped to form a Component and that Component will be returned. Otherwise, null will be returned.

The following table shows the display wrapper type for each given object type.

Component The same Component
String Annotation
Icon Annotation
Paint PaintSwatch
Image PaintableComponent
Shape PaintableComponent
Paintable PaintableComponent
Action JButton
otherwise null

Parameters:
o - the object to display in a GUI

makeIcon

public static Icon makeIcon(Object o)

Returns an Icon associated with the given object.

If the parameter is already an Icon then that Icon is returned unchanged.

If the parameter is a Paint, Image, Shape, String, or Paintable, then the parameter will be suitably wrapped to form an Icon and that Icon will be returned. Otherwise, null will be returned.

The following table shows the display wrapper type for each given object type.

Icon The same Icon
Paint PaintSwatch
Image PaintableComponent
Shape PaintableComponent
String PaintableComponent
Paintable PaintableComponent
otherwise null

Parameters:
o - the object to display in a GUI