|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.neu.ccs.gui.PaintableTools
The class PaintableTools collects static methods that
construct objects of other types from Paintable objects.
Class PaintableTools cannot be instantiated.
In 2.3.5, the class was refactored to be consistent with
the new Paintable interface and
the new AbstractPaintable class.
In 2.6.0c, adjusted makeBufferedImage to ensure that
the constructed image is at least 1-by-1 (unless the given paintable
is null in which case the method continues to return
null).
| Constructor Summary | |
private |
PaintableTools()
Private constructor to prevent instantiation. |
| Method Summary | |
static BufferedImage |
makeBufferedImage(Paintable paintable)
Constructs a BufferedImage object that is
the same size as the bounding box of the given paintable and
then paints the given paintable onto the buffered image with
a suitable translation back to the origin. |
static JButton |
makeButton(Paintable paintable)
Returns a JButton using
the given Paintable to construct the button icon,
no specified action for the button behavior,
the Java default background color,
and insets of 2, 2, 2, 2. |
static JButton |
makeButton(Paintable paintable,
Action action)
Returns a JButton using
the given Paintable to construct the button icon,
the given Action for the button behavior,
the Java default background color,
and insets of 2, 2, 2, 2. |
static JButton |
makeButton(Paintable paintable,
Action action,
Color color)
Returns a JButton using
the given Paintable to construct the button icon,
the given Action for the button behavior,
the given background color,
and insets of 2, 2, 2, 2. |
static JButton |
makeButton(Paintable paintable,
Action action,
Color color,
Insets insets)
Returns a JButton using
the given Paintable to construct the button icon,
the given Action for the button behavior,
the given background color,
and the given insets. |
static JPTComponent |
makeComponent(Paintable paintable)
Returns a JPTComponent using the given
Paintable to define its location and paint
behavior. |
static JPTComponent |
makeComponent(Paintable paintable,
Color color)
Returns a JPTComponent using the given
Paintable to define its location and paint
behavior
and the optional background color. |
static JPTComponent |
makeComponent(Paintable paintable,
Color color,
boolean opaque)
Returns a JPTComponent using the given
Paintable to define its location and paint
behavior,
the optional background color,
and the opacity setting. |
static JPTComponent |
makeComponent(Paintable paintable,
Color color,
boolean opaque,
Border border)
Returns a JPTComponent using the given
Paintable to define its location and paint
behavior,
the optional background color,
the opacity setting,
and the component border. |
static Icon |
makeIcon(Paintable paintable)
Returns an Icon constructed using the paint operation
and bounds of the given Paintable object. |
static TexturePaint |
makeTexturePaint(Paintable paintable)
Returns a TexturePaint whose BufferedImage
is constructed using the method makeBufferedImage and
whose anchor rectangle is the bounds rectangle of the given paintable. |
static Paintable |
wrapPaintable(Paintable object)
Returns a Paintable that wraps the given object
in a Tile object if needed. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
private PaintableTools()
| Method Detail |
public static Paintable wrapPaintable(Paintable object)
Returns a Paintable that wraps the given object
in a Tile object if needed.
If the given object is non-null, then it is
returned as is.
If the given object is null, it is wrapped in a
Tile.
Since 2.3.5, the code is basically trivial but it does avoid breaking certain existing code.
object - the object to wrap as a paintable
public static Icon makeIcon(Paintable paintable)
Returns an Icon constructed using the paint operation
and bounds of the given Paintable object.
If the given paintable is null, then returns
null.
As of 2.3.2, this method returns a PaintableComponent,
viewed as an Icon, or null.
paintable - the paintable used in the construction
Icon constructed from the paintablemakeButton(Paintable, Action),
makeButton(Paintable, Action, Color)public static BufferedImage makeBufferedImage(Paintable paintable)
Constructs a BufferedImage object that is
the same size as the bounding box of the given paintable and
then paints the given paintable onto the buffered image with
a suitable translation back to the origin.
This method creates a snapshot of the current visual state of the given paintable.
The BufferedImage returned will have size at
least 1-by-1 even if the given paintable has 0 width or height.
If the given paintable is null, then returns
null.
paintable - the paintable used in the construction
BufferedImage constructed from the paintablemakeTexturePaint(Paintable)public static TexturePaint makeTexturePaint(Paintable paintable)
Returns a TexturePaint whose BufferedImage
is constructed using the method makeBufferedImage and
whose anchor rectangle is the bounds rectangle of the given paintable.
If the given paintable is null, then returns
null.
paintable - the paintable used in the construction
TexturePaint constructed from the paintablemakeBufferedImage(Paintable)public static JButton makeButton(Paintable paintable)
Returns a JButton using
the given Paintable to construct the button icon,
no specified action for the button behavior,
the Java default background color,
and insets of 2, 2, 2, 2.
If the given paintable is null, then returns
null.
As of 2.3.2, this method returns a PaintableButton
or null.
paintable - the paintable that defines the button
makeIcon(Paintable),
makeButton(Paintable, Action),
makeButton(Paintable, Action, Color),
makeButton(Paintable, Action, Color, Insets)
public static JButton makeButton(Paintable paintable,
Action action)
Returns a JButton using
the given Paintable to construct the button icon,
the given Action for the button behavior,
the Java default background color,
and insets of 2, 2, 2, 2.
The action is used only to supply behavior not to set the button icon or text.
If the given paintable is null, then returns
null.
As of 2.3.2, this method returns a PaintableButton
or null.
paintable - the paintable that defines the buttonaction - the action to define the button behavior
makeIcon(Paintable),
makeButton(Paintable),
makeButton(Paintable, Action, Color),
makeButton(Paintable, Action, Color, Insets)
public static JButton makeButton(Paintable paintable,
Action action,
Color color)
Returns a JButton using
the given Paintable to construct the button icon,
the given Action for the button behavior,
the given background color,
and insets of 2, 2, 2, 2.
The action is used only to supply behavior not to set the button icon or text.
If the given paintable is null, then returns
null.
As of 2.3.2, this method returns a PaintableButton
or null.
paintable - the paintable that defines the buttonaction - the action to define the button behaviorcolor - the button background color
makeIcon(Paintable),
makeButton(Paintable),
makeButton(Paintable, Action),
makeButton(Paintable, Action, Color, Insets)
public static JButton makeButton(Paintable paintable,
Action action,
Color color,
Insets insets)
Returns a JButton using
the given Paintable to construct the button icon,
the given Action for the button behavior,
the given background color,
and the given insets.
The action is used only to supply behavior not to set the button icon or text.
If the given insets is null, then the insets
are set to 2, 2, 2, 2.
If the given paintable is null, then returns
null.
As of 2.3.2, this method returns a PaintableButton
or null.
paintable - the paintable that defines the buttonaction - the action to define the button behaviorcolor - the button background colorinsets - the button insets
makeIcon(Paintable),
makeButton(Paintable),
makeButton(Paintable, Action),
makeButton(Paintable, Action, Color)public static JPTComponent makeComponent(Paintable paintable)
Returns a JPTComponent using the given
Paintable to define its location and paint
behavior.
If the given paintable is null, then returns
null.
As of 2.3.2, this method returns a PaintableComponent
or null.
paintable - the paintable to encapsulate
makeComponent(Paintable, Color),
makeComponent(Paintable, Color, boolean),
makeComponent(Paintable, Color, boolean, Border)
public static JPTComponent makeComponent(Paintable paintable,
Color color)
Returns a JPTComponent using the given
Paintable to define its location and paint
behavior
and the optional background color.
If the given paintable is null, then returns
null.
As of 2.3.2, this method returns a PaintableComponent
or null.
paintable - the paintable to encapsulatecolor - the optional background color
makeComponent(Paintable),
makeComponent(Paintable, Color, boolean),
makeComponent(Paintable, Color, boolean, Border)
public static JPTComponent makeComponent(Paintable paintable,
Color color,
boolean opaque)
Returns a JPTComponent using the given
Paintable to define its location and paint
behavior,
the optional background color,
and the opacity setting.
If the given paintable is null, then returns
null.
As of 2.3.2, this method returns a PaintableComponent
or null.
paintable - the paintable to encapsulatecolor - the optional background coloropaque - whether or not to paint the component background
makeComponent(Paintable),
makeComponent(Paintable, Color),
makeComponent(Paintable, Color, boolean, Border)
public static JPTComponent makeComponent(Paintable paintable,
Color color,
boolean opaque,
Border border)
Returns a JPTComponent using the given
Paintable to define its location and paint
behavior,
the optional background color,
the opacity setting,
and the component border.
If the given paintable is null, then returns
null.
As of 2.3.2, this method returns a PaintableComponent
or null.
paintable - the paintable to encapsulatecolor - the optional background coloropaque - whether or not to paint the component backgroundborder - the border for the component
makeComponent(Paintable),
makeComponent(Paintable, Color),
makeComponent(Paintable, Color, boolean)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||