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:
JPTConstants, Paintable, SupportsPropertyChange, SwingConstants

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 the following feature. The contains method will return true if the point is in the bounding box of the tile. This has two consequences:

These features mean that one may interact with a TileBox much more easily than with a Tile and that one may even use a mouse click to add or remove the internal paintable.

To provide user feedback, it is generally a good idea to set some non-transparent background color on a tile box.

Prior to 2.7.0, a TileBox also had a concept of border. This turned out to be a poor design since the border only appeared under certain conditions. Therefore, the concept of a border has been removed from this class.

Since:
2.4.0
Version:
2.7.0

Field Summary
 
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 and the background paint is set to null.
TileBox(Object o)
          The constructor to specify the object to be wrapped; and the background paint is set to null.
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.
TileBox(Object o, Paint background)
          The constructor to specify the object to be wrapped and the background paint.
TileBox(Object o, Paint background, AffineTransform m)
          The constructor to specify the object to be wrapped, the background paint, and the initial mutator.
 
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.
 boolean originalContains(double x, double y)
          Tests if a point specified by coordinates is inside the bounding box of the tile box before mutation.
 
Methods inherited from class edu.neu.ccs.gui.Tile
getActualBounds2D, getCol, getPaintable, getRow, initializeTile, makePaintable, originalPaint, setCol, setPaintable, setRow, setRowCol
 
Methods inherited from class edu.neu.ccs.gui.AbstractPaintable
addForwardingListener, addPostMutation, addPostMutation, addPreMutation, addPreMutation, addPropertyChangeListener, addPropertyChangeListener, addPropertyChangeListeners, addPropertyChangeListeners, affinetransform, applyOpacity, clearBackgroundPaint, clearBackgroundTile, clearBothBackgrounds, contains, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackgroundPaint, getBackgroundTile, getBounds2D, getCenter, getCorner, getDefaultBounds2D, getDefaultCenter, getDefaultOriginalBounds2D, getDefaultOriginalCenter, getForwardingListener, getMutator, getMutatorInverse, getOpacity, getOriginalBounds2D, getOriginalCenter, getPreparedGraphics2D, getPropertyChangeListeners, getPropertyChangeListeners, glide, glidereflect, hasListeners, hreflect, isVisible, lineartransform, makeSnapshot, move, move, moveCenterTo, moveCenterTo, moveCornerTo, moveCornerTo, mutate, mutate, originalContains, paint, paintAsTiles, paintAsTiles, paintAsTiles, paintAt, paintAt, paintAt, paintAt, possiblyContains, reflect, removeAndAddForwardingListener, removeForwardingListener, removePropertyChangeListener, removePropertyChangeListener, rotate, scale, scale, setBackgroundPaint, setBackgroundTile, 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
 

Constructor Detail

TileBox

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


TileBox

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

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.

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.

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.

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
Method Detail

contains

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.

This method does not test whether or not the tile box has an internal paintable.

Specified by:
contains in interface Paintable
Overrides:
contains in class AbstractPaintable
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 after mutation

originalContains

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.

This method does not test whether or not the tile box has an internal paintable.

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 before mutation