edu.neu.ccs.gui
Class ComponentFactory

java.lang.Object
  extended byedu.neu.ccs.gui.ComponentFactory

public class ComponentFactory
extends Object

ComponentFactory has 3 static methods that create gui or graphical objects from more general objects.

The first two methods both make certain specific attempts to convert a general Object into the desired type. If these attempts fail then the methods use the makePaintable method to try to convert the Object into a Paintable. If that attempt succeeds then the Paintable is placed into a PaintableComponent. On the other hand, if this final attempt fails then null is returned.

As of 2.6.0, makePaintable returns a MultiLineTextPaintable if it is given a String.

Since:
2.0
Version:
2.6.0

Constructor Summary
ComponentFactory()
           
 
Method Summary
static Component makeComponent(Object o)
          Returns a Component associated with the given object.
static Icon makeIcon(Object o)
          Returns an Icon associated with the given object.
static Paintable makePaintable(Object o)
          Returns a Paintable 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 associated with the given object.

The table below shows more about how makeComponent works.

Argument Return
Component The same Component
String Annotation
Icon Annotation
Action JButton
Paint PaintSwatch
converts to
Paintable
PaintableComponent
otherwise null

Parameters:
o - the object to make into a Component

makeIcon

public static Icon makeIcon(Object o)

Returns an Icon associated with the given object.

The table below shows more about how makeIcon works.

Argument Return
Icon The same Icon
Paint PaintSwatch
converts to
Paintable
PaintableComponent
otherwise null

Parameters:
o - the object to make into an Icon

makePaintable

public static Paintable makePaintable(Object o)

Returns a Paintable associated with the given object.

The table below shows more about how makePaintable works.

Argument Return
Paintable The same Paintable
Shape ShapePaintable
PathList ShapePaintable
Image ImagePaintable
ImageIcon ImagePaintable
String MultiLineTextPaintable
Point2D PointPaintable
Object[] PaintableSequence
otherwise null

Parameters:
o - the object to make into a Paintable