|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.neu.ccs.gui.AbstractPaintable
edu.neu.ccs.gui.Tile
The class Tile will wrap a Paintable object
to obtain to a copy that may be subject to mutation that does not affect
the data in the encapsulated paintable.
As of 2.4.0, the class will actually accept an arbitrary object and
use the method makePaintable if needed to create the
Paintable to be wrapped. This generality turns out to be
convenient at times.
The original purpose of this class is to permit multiple copies of one source paintable to exist at once and be mutated independently.
The following principles should be observed:
Tile objects based on that paintable.Tile object will affect
only that Tile object and not the original paintable.Normally, the least confusing way to work with Tile objects
is to mutate only the Tile objects and leave the paintable
alone.
This class is a generalization of the class MutatableWrapper
which has been removed from JPT.
In 2.4.0, this class was also updated to be consistent with
refinements to the Paintable interface.
In 2.5.0, this class added fields row and
col that permit the user to tag a tile with
a row,col position in a user-defined structure. Usage of
this facility is entirely optional.
In 2.6.0, the notion of a background paint was refactored
into required “set” and “get” methods in the
Paintable interface and implemented in the base class
AbstractPaintable.
In 2.7.0, fixed some documentation.
| Field Summary | |
protected int |
col
The optional col. |
protected Paintable |
paintable
The wrapped paintable. |
protected int |
row
The optional row. |
| Fields inherited from class edu.neu.ccs.gui.AbstractPaintable |
SET_BACKGROUND_PAINT, SET_BACKGROUND_TILE |
| Fields inherited from interface edu.neu.ccs.gui.Paintable |
REMOVE_PAINTABLE, SET_CLIPPING_SHAPE, SET_DEFAULT_BOUNDS2D, SET_DEFAULT_CENTER, SET_DEFAULT_ORIGINAL_BOUNDS2D, SET_DEFAULT_ORIGINAL_CENTER, SET_MUTATOR, SET_OPACITY, SET_PAINTABLE, SET_VISIBLE, SHIFT_PAINTABLE |
| Fields inherited from interface edu.neu.ccs.util.JPTConstants |
ABOVE, ALIGNMENT, BELOW, BOTTOM_LEFT, BOTTOM_RIGHT, DEFAULT, FONT, INPUT_PROPERTIES, MANDATORY, OPTIONAL, ORIENTATION, TOP_LEFT, TOP_RIGHT, VALUE |
| Fields inherited from interface javax.swing.SwingConstants |
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
| Constructor Summary | |
Tile()
The constructor that leaves the paintable unspecified; the background paint is set to null. |
|
Tile(Object o)
The constructor to specify the object to be wrapped; the background paint is set to null. |
|
Tile(Object o,
AffineTransform m)
The constructor to specify the object to be wrapped and the initial mutator; the background paint is set to null. |
|
Tile(Object o,
Paint background)
The constructor to specify the object to be wrapped and the background paint. |
|
Tile(Object o,
Paint background,
AffineTransform m)
The constructor to specify the object to be wrapped, the background paint, and the initial mutator. |
|
| Method Summary | |
XRect |
getActualBounds2D()
Returns the actual bounds of this tile or null if the tile is effectively empty. |
int |
getCol()
Returns the optional col tag for this tile. |
Paintable |
getPaintable()
Returns the wrapped paintable. |
int |
getRow()
Returns the optional row tag for this tile. |
void |
initializeTile(Object o,
Paint background,
AffineTransform m)
The common initialization method. |
Paintable |
makePaintable(Object o)
Returns a Paintable constructed from the given
Object. |
boolean |
originalContains(double x,
double y)
Tests if a point specified by coordinates is inside the original paintable without mutation. |
void |
originalPaint(Graphics g)
Paints onto a Graphics context using the wrapped
paintable object but without the use of the mutator transform. |
void |
setCol(int col)
Sets the optional col tag for this tile. |
void |
setPaintable(Object o)
Sets the object to be wrapped. |
void |
setRow(int row)
Sets the optional row tag for this tile. |
void |
setRowCol(int row,
int col)
Sets the optional row and col tags for this tile. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected Paintable paintable
protected int row
protected int col
| Constructor Detail |
public Tile()
null.
public Tile(Object o)
null.
o - the object to convert to a paintable to wrap in this tile
public Tile(Object o,
Paint background)
o - the object to convert to a paintable to wrap in this tilebackground - the background paint for the tile
public Tile(Object o,
AffineTransform m)
null.
o - the object to convert to a paintable to wrap in this tilem - the initial mutator
public Tile(Object o,
Paint background,
AffineTransform m)
o - the object to convert to a paintable to wrap in this tilebackground - the background paint for the tilem - the initial mutator| Method Detail |
public void initializeTile(Object o,
Paint background,
AffineTransform m)
The common initialization method.
Because this method is public, the caller can reset the key properties of a tile after construction.
o - the object to convert to a paintable to wrap in this tilebackground - the background paint for the tilem - the initial mutatorpublic void originalPaint(Graphics g)
Paints onto a Graphics context using the wrapped
paintable object but without the use of the mutator transform.
originalPaint in interface PaintableoriginalPaint in class AbstractPaintableg - the graphics context on which to paintpublic XRect getActualBounds2D()
Returns the actual bounds of this tile or
null if the tile is effectively empty.
If the internal paintable is non-null, then
returns a copy of the 2-dimensional bounds of the internal
paintable prior to any mutation of this object.
Since the internal paintable may have a mutation or defaults
this method calls getBounds2D on the internal
paintable. Hence any mutation or defaults set for the internal
paintable are respected.
getActualBounds2D in interface PaintablegetActualBounds2D in class AbstractPaintable
public boolean originalContains(double x,
double y)
Tests if a point specified by coordinates is inside the original paintable without mutation.
originalContains in interface PaintableoriginalContains in class AbstractPaintablex - the x-coordinate of the pointy - the y-coordinate of the point
public Paintable makePaintable(Object o)
Returns a Paintable constructed from the given
Object.
By default, uses ComponentFactory.makePaintable.
May be overridden in a derived class if the designer has a more
sophisticated way to construct a Paintable.
Any override should respect the convention that if the object
is already a Paintable then it is returned as is.
o - the object to make into a Paintablepublic void setPaintable(Object o)
Sets the object to be wrapped. If the object is a paintable, then
it is wrapped as is. Otherwise the makePaintable method is
called to create the paintable that will be wrapped in this tile.
The given object may be set to null to eliminate the
paintable. The method originalPaint will then paint
nothing. However, if the caller has set some form of default bounds
and if a background paint or background tile has also been set, then
these will be painted by the paint method.
Fires property change: SET_PAINTABLE.
o - the object to convert to a paintable to wrap in this tilepublic Paintable getPaintable()
public void setRowCol(int row,
int col)
row - the row tag for this tilecol - the col tag for this tilepublic void setRow(int row)
row - the row tag for this tilepublic void setCol(int col)
col - the col tag for this tilepublic int getRow()
public int getCol()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||