com.rolemodelsoft.drawlet.shapes
Class AbstractRectangleShape

java.lang.Object
  |
  +--com.rolemodelsoft.drawlet.basics.AbstractPaintable
        |
        +--com.rolemodelsoft.drawlet.basics.AbstractFigure
              |
              +--com.rolemodelsoft.drawlet.shapes.AbstractShape
                    |
                    +--com.rolemodelsoft.drawlet.shapes.FilledShape
                          |
                          +--com.rolemodelsoft.drawlet.shapes.AbstractRectangleShape
Direct Known Subclasses:
Ellipse, RectangleShape, RoundedRectangleShape

public abstract class AbstractRectangleShape
extends FilledShape

This provides a basic abstract implementation of rectangular bounded Figures. Although this is an abstract class, it is acknowledged that there are other implementations (e.g. ones that uses Locators) which are more flexible. Therefore, one may wish to consider subclassing the superclass instead. This provides most of its functionality based on a simple x, y, width, height attributes, and forces concrete subclasses to define, at a minimum: paintStrokes(Graphics); paintFilled(Graphics);

See Also:
Serialized Form

Field Summary
protected  int height
          The height of the shape
protected  int width
          The width of the shape
protected  int x
          The x coordinate for the shape
protected  int y
          The y coordinate for the shape
 
Fields inherited from class com.rolemodelsoft.drawlet.shapes.FilledShape
fillColor, lineColor
 
Fields inherited from class com.rolemodelsoft.drawlet.basics.AbstractFigure
listeners, locationListeners
 
Constructor Summary
AbstractRectangleShape()
          Creates a new, default AbstractRectangleShape.
AbstractRectangleShape(int x, int y, int width, int height)
          Creates a new AbstractRectangeShape initialized with the given values for x, y, width and height.
AbstractRectangleShape(java.awt.Rectangle rectangle)
          Creates a new AbstractRectangeShape initialized with the given Rectangle.
 
Method Summary
protected  void basicMove(int x, int y)
          Moves the receiver to a new location.
protected  void basicReshape(int x, int y, int width, int height)
          Reshapes the receiver to the specified bounding box.
protected  void basicResize(int width, int height)
          Resizes the receiver to the specified width and height.
protected  void basicTranslate(int x, int y)
          Moves the receiver in the x and y direction.
protected  void changedShape(java.awt.Rectangle oldBounds)
          Denote that the receiver has changed.
protected  int defaultHeight()
          Answer the default/initial value for height.
protected  int defaultWidth()
          Answer the default/initial value for width.
protected  int defaultX()
          Answer the default/initial value for x.
protected  int defaultY()
          Answer the default/initial value for y.
 java.awt.Rectangle getBounds()
          Returns the current bounds of the receiver.
 java.awt.Dimension getSize()
          Returns the current size of the receiver.
 
Methods inherited from class com.rolemodelsoft.drawlet.shapes.FilledShape
defaultFillColor, defaultLineColor, getFillColor, getLineColor, getStyle, isOpaque, isStroked, paint, paintFilled, paintStrokes, setFillColor, setLineColor, setStyle
 
Methods inherited from class com.rolemodelsoft.drawlet.shapes.AbstractShape
getHandles, resetBoundsCache, resetSizeCache, reshapedPolygon, reshapedPolygon, setBounds, setSize
 
Methods inherited from class com.rolemodelsoft.drawlet.basics.AbstractFigure
addPropertyChangeListener, addRelatedLocationListener, changedLocation, changedSize, contains, contains, contains, deleteLocationListeners, disconnect, duplicate, duplicateIn, editTool, estimatedDuplicateSize, figureFromLocator, fireLocationChange, firePropertyChange, firePropertyChange, fireRelationChange, fireShapeChange, fireSizeChange, getLocation, getLocator, intersects, intersects, isObsolete, isWithin, isWithin, locatorAt, move, move, postDuplicate, relatedLocationListeners, removePropertyChangeListener, removeRelatedLocationListener, requestConnection, resetLocationCache, setSize, translate
 
Methods inherited from class com.rolemodelsoft.drawlet.basics.AbstractPaintable
getBottom, getHeight, getLeft, getRight, getTop, getWidth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

x

protected int x
The x coordinate for the shape

y

protected int y
The y coordinate for the shape

width

protected int width
The width of the shape

height

protected int height
The height of the shape
Constructor Detail

AbstractRectangleShape

public AbstractRectangleShape()
Creates a new, default AbstractRectangleShape.

AbstractRectangleShape

public AbstractRectangleShape(int x,
                              int y,
                              int width,
                              int height)
Creates a new AbstractRectangeShape initialized with the given values for x, y, width and height.
Parameters:
x - an integer representing the x for this AbstractRectangeShape.
y - an integer representing the y for this AbstractRectangeShape.
width - an integer representing the width for this AbstractRectangeShape.
height - an integer representing the height for this AbstractRectangeShape.

AbstractRectangleShape

public AbstractRectangleShape(java.awt.Rectangle rectangle)
Creates a new AbstractRectangeShape initialized with the given Rectangle.
Parameters:
rectangle - a Rectangle representing the bounds to be used for initialization.
Method Detail

basicMove

protected void basicMove(int x,
                         int y)
Moves the receiver to a new location. The x and y coordinates are in the parent's coordinate space.
Overrides:
basicMove in class AbstractFigure
Parameters:
x - the x coordinate
y - the y coordinate

basicReshape

protected void basicReshape(int x,
                            int y,
                            int width,
                            int height)
Reshapes the receiver to the specified bounding box.
Overrides:
basicReshape in class FilledShape
Parameters:
x - the x coordinate
y - the y coordinate
width - the width of the figure
height - the height of the figure

basicResize

protected void basicResize(int width,
                           int height)
Resizes the receiver to the specified width and height.
Overrides:
basicResize in class AbstractShape
Parameters:
width - the width of the figure
height - the height of the figure

basicTranslate

protected void basicTranslate(int x,
                              int y)
Moves the receiver in the x and y direction.
Overrides:
basicTranslate in class FilledShape
Parameters:
x - amount to move in the x direction
y - amount to move in the y direction

changedShape

protected void changedShape(java.awt.Rectangle oldBounds)
Denote that the receiver has changed. Assume that the shape has changed even if the bounds haven't.
Overrides:
changedShape in class AbstractFigure
Parameters:
oldBounds - the old bounds.

defaultHeight

protected int defaultHeight()
Answer the default/initial value for height.
Returns:
an integer representing the default/initial value for height.

defaultWidth

protected int defaultWidth()
Answer the default/initial value for width.
Returns:
an integer representing the default/initial value for width.

defaultX

protected int defaultX()
Answer the default/initial value for x.
Returns:
an integer representing the default/initial value for x.

defaultY

protected int defaultY()
Answer the default/initial value for y.
Returns:
an integer representing the default/initial value for y.

getBounds

public java.awt.Rectangle getBounds()
Returns the current bounds of the receiver.
Overrides:
getBounds in class FilledShape
Returns:
a Rectangle representing the current bounds of the receiver.

getSize

public java.awt.Dimension getSize()
Returns the current size of the receiver.
Overrides:
getSize in class AbstractPaintable
Returns:
a Dimension representing the current size of the receiver.