|
||||||||||
| 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
edu.neu.ccs.gui.TileBox
The class TileBox will wrap an object by converting it
to a Paintable if it is not one already.
This class extends Tile to add two features:
contains method to return
true if a point is within the bounding box not just within the
paintable that is being wrapped.
Because of the second feature, it is much easier to drag a TileBox using the mouse than to drag a corresponding Tile since less accuracy is required of the user.
As of 2.6.0c, fixed a bug in the code that tests if a point is
contained in the paintable represented by the tile as a whole. It was
our intention that a point would be contained in the tile if it was in
the bounding box of the tile after mutation. To achieve this,
it is necessary to override contains. This was not done
in prior versions of this class. Moreover, it was also our intention
that originalContains test if the point was in the
original bounding box before mutation. This was not done
correctly in prior versions of this class. The bounding box
before mutation is the rectangle returned by the method
getOriginalBounds2D. This method first checks to see if
a default original bounds has been set and if so returns it. Only if
no such default has been set is the method getActualBounds2D
called.
The method getActualBounds2D is the correct method to
apply a border setting. This method expands the bounding box of the
internal paintable by the border as long as the internal paintable is
not null. Otherwise, this method returns
null.
A consequence of these relationships is that if the caller has set a default original bounds then the border value is ignored.
| Field Summary | |
protected int |
border
The border size. |
static String |
SET_BORDER_SIZE
Bound property name for set border size. |
| Fields inherited from class edu.neu.ccs.gui.Tile |
col, paintable, 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 | |
TileBox()
The constructor that leaves the paintable unspecified; the background paint is set to null;
the border is set to 0. |
|
TileBox(Object o)
The constructor to specify the object to be wrapped; the background paint is set to null;
the border is set to 0. |
|
TileBox(Object o,
AffineTransform m)
The constructor to specify the object to be wrapped and the initial mutator; the background paint is set to null;
the border is set to 0. |
|
TileBox(Object o,
AffineTransform m,
int border)
The constructor to specify the object to be wrapped and the initial mutator; the background paint is set to null;
the border is set to the given border. |
|
TileBox(Object o,
int border)
The constructor to specify the object to be wrapped; the background paint is set to null;
the border is set to the given border. |
|
TileBox(Object o,
Paint background)
The constructor to specify the object to be wrapped and the background paint; the border is set to 0. |
|
TileBox(Object o,
Paint background,
AffineTransform m)
The constructor to specify the object to be wrapped, the background paint, and the initial mutator; the border is set to 0. |
|
TileBox(Object o,
Paint background,
AffineTransform m,
int border)
The constructor to specify the object to be wrapped, the background paint, and the initial mutator; the border is set to the given border. |
|
TileBox(Object o,
Paint background,
int border)
The constructor to specify the object to be wrapped and the background paint; the border is set to the given border. |
|
| Method Summary | |
boolean |
contains(double x,
double y)
Tests if a point specified by coordinates is inside the bounding box of the tile box after mutation. |
XRect |
getActualBounds2D()
Returns the actual bounds of this tile box with border added or null if the tile box is effectively empty
because there is no internal paintable installed. |
int |
getBorderSize()
Gets the border for the tile box, that is, the extra amount to add to the bounding box on all sides. |
void |
initializeTileBox(Object o,
Paint background,
AffineTransform m,
int border)
The common initialization method. |
boolean |
originalContains(double x,
double y)
Tests if a point specified by coordinates is inside the bounding box of the tile box before mutation. |
void |
setBorderSize(int border)
Sets the border for the tile box, that is, the extra amount to add to the bounding box on all sides. |
| Methods inherited from class edu.neu.ccs.gui.Tile |
getCol, getPaintable, getRow, initializeTile, makePaintable, originalPaint, setCol, setPaintable, setRow, setRowCol |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String SET_BORDER_SIZE
protected int border
| Constructor Detail |
public TileBox()
null;
the border is set to 0.
public TileBox(Object o)
null;
the border is set to 0.
o - the object to convert to a paintable to wrap in this tile
public TileBox(Object o,
Paint background)
o - the object to convert to a paintable to wrap in this tilebackground - the background paint for the tile
public TileBox(Object o,
AffineTransform m)
null;
the border is set to 0.
o - the object to convert to a paintable to wrap in this tilem - the initial mutator
public TileBox(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
public TileBox(Object o,
int border)
null;
the border is set to the given border.
o - the object to convert to a paintable to wrap in this tileborder - the border size for the tile box
public TileBox(Object o,
Paint background,
int border)
o - the object to convert to a paintable to wrap in this tilebackground - the background paint for the tileborder - the border size for the tile box
public TileBox(Object o,
AffineTransform m,
int border)
null;
the border is set to the given border.
o - the object to convert to a paintable to wrap in this tilem - the initial mutatorborder - the border size for the tile box
public TileBox(Object o,
Paint background,
AffineTransform m,
int border)
o - the object to convert to a paintable to wrap in this tilebackground - the background paint for the tilem - the initial mutatorborder - the border size for the tile box| Method Detail |
public void initializeTileBox(Object o,
Paint background,
AffineTransform m,
int border)
o - the object to convert to a paintable to wrap in this tile boxbackground - the background paint for the tile boxm - the initial mutatorborder - the border size for the tile boxpublic XRect getActualBounds2D()
Returns the actual bounds of this tile box with border added
or null if the tile box is effectively empty
because there is no internal paintable installed.
If the internal paintable is non-null, then
returns a copy of the 2-dimensional bounds of the internal
paintable expanded by the border but prior to any mutation
of this tile 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.
This method is bypassed if a default original bounds has been set.
getActualBounds2D in interface PaintablegetActualBounds2D in class Tile
public boolean contains(double x,
double y)
Tests if a point specified by coordinates is inside the
bounding box of the tile box after mutation. Calls the
method getBounds2D() to do the test.
contains in interface Paintablecontains in class AbstractPaintablex - the x-coordinate of the pointy - the y-coordinate of the point
public boolean originalContains(double x,
double y)
Tests if a point specified by coordinates is inside the
bounding box of the tile box before mutation. Calls the
method getOriginalBounds2D() to do the test.
originalContains in interface PaintableoriginalContains in class Tilex - the x-coordinate of the pointy - the y-coordinate of the point
public void setBorderSize(int border)
Sets the border for the tile box, that is, the extra amount to add to the bounding box on all sides.
Forces the border to be >= 0.
Fires property change: SET_BORDER_SIZE.
border - the border size for the tile boxpublic int getBorderSize()
Gets the border for the tile box, that is, the extra amount to add to the bounding box on all sides.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||