edu.neu.ccs.gui
Class TileBox

java.lang.Object
  extended byedu.neu.ccs.gui.AbstractPaintable
      extended byedu.neu.ccs.gui.Tile
          extended byedu.neu.ccs.gui.TileBox
All Implemented Interfaces:
Paintable, SupportsPropertyChange

public class TileBox
extends Tile

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:

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.

Since:
2.4.0

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
background, col, paintable, row, SET_BACKGROUND_PAINT
 
Fields inherited from class edu.neu.ccs.gui.AbstractPaintable
 
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
 
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
 XRect getActualBounds2D()
          Returns the actual bounds of this tile box with border added or null if the tile box is effectively empty.
 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 without 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
getBackgroundPaint, getCol, getPaintable, getRow, initializeTile, makePaintable, originalPaint, setBackgroundPaint, setCol, setPaintable, setRow, setRowCol
 
Methods inherited from class edu.neu.ccs.gui.AbstractPaintable
addForwardingListener, addPostMutation, addPostMutation, addPreMutation, addPreMutation, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListeners, addPropertyChangeListeners, affinetransform, applyOpacity, contains, contains, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBounds2D, getCenter, getCorner, getDefaultBounds2D, getDefaultCenter, getDefaultOriginalBounds2D, getDefaultOriginalCenter, getForwardingListener, getMutator, getMutatorInverse, getOpacity, getOriginalBounds2D, getOriginalCenter, getPreparedGraphics2D, getPropertyChangeListeners, getPropertyChangeListeners, glide, glidereflect, hasListeners, hreflect, isVisible, lineartransform, move, move, moveCenterTo, moveCenterTo, moveCornerTo, moveCornerTo, mutate, mutate, originalContains, paint, paintAt, paintAt, paintAt, paintAt, possiblyContains, reflect, removeAndAddForwardingListener, removeForwardingListener, removePropertyChangeListener, removePropertyChangeListener, rotate, scale, scale, setDefaultBounds2D, setDefaultCenter, setDefaultOriginalBounds2D, setDefaultOriginalCenter, setMutator, setMutator, setOpacity, setVisible, shear, vreflect
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SET_BORDER_SIZE

public static final String SET_BORDER_SIZE
Bound property name for set border size.

See Also:
Constant Field Values

border

protected int border
The border size.

Constructor Detail

TileBox

public TileBox()
The constructor that leaves the paintable unspecified; the background paint is set to null; the border is set to 0.


TileBox

public 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.

Parameters:
o - the object to convert to a paintable to wrap in this tile

TileBox

public TileBox(Object o,
               Paint background)
The constructor to specify the object to be wrapped and the background paint; the border is set to 0.

Parameters:
o - the object to convert to a paintable to wrap in this tile
background - the background paint for the tile

TileBox

public 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.

Parameters:
o - the object to convert to a paintable to wrap in this tile
m - the initial mutator

TileBox

public 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.

Parameters:
o - the object to convert to a paintable to wrap in this tile
background - the background paint for the tile
m - the initial mutator

TileBox

public 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.

Parameters:
o - the object to convert to a paintable to wrap in this tile
border - the border size for the tile box

TileBox

public 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.

Parameters:
o - the object to convert to a paintable to wrap in this tile
background - the background paint for the tile
border - the border size for the tile box

TileBox

public 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.

Parameters:
o - the object to convert to a paintable to wrap in this tile
m - the initial mutator
border - the border size for the tile box

TileBox

public 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.

Parameters:
o - the object to convert to a paintable to wrap in this tile
background - the background paint for the tile
m - the initial mutator
border - the border size for the tile box
Method Detail

initializeTileBox

public void initializeTileBox(Object o,
                              Paint background,
                              AffineTransform m,
                              int border)
The common initialization method.

Parameters:
o - the object to convert to a paintable to wrap in this tile box
background - the background paint for the tile box
m - the initial mutator
border - the border size for the tile box

getActualBounds2D

public XRect getActualBounds2D()

Returns the actual bounds of this tile box with border added or null if the tile box is effectively empty.

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 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.

Specified by:
getActualBounds2D in interface Paintable
Overrides:
getActualBounds2D in class Tile
Returns:
a copy of the 2-dimensional bounds of the original paintable

originalContains

public boolean originalContains(double x,
                                double y)

Tests if a point specified by coordinates is inside the bounding box of the tile box without mutation.

Specified by:
originalContains in interface Paintable
Overrides:
originalContains in class Tile
Parameters:
x - the x-coordinate of the point
y - the y-coordinate of the point
Returns:
whether or not a specified point is inside the bounding box

setBorderSize

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.

Parameters:
border - the border size for the tile box

getBorderSize

public int getBorderSize()

Gets the border for the tile box, that is, the extra amount to add to the bounding box on all sides.