com.rolemodelsoft.drawlet.shapes
Class AbstractShape

java.lang.Object
  |
  +--com.rolemodelsoft.drawlet.basics.AbstractPaintable
        |
        +--com.rolemodelsoft.drawlet.basics.AbstractFigure
              |
              +--com.rolemodelsoft.drawlet.shapes.AbstractShape
Direct Known Subclasses:
Arrow, FilledShape, LinearShape

public abstract class AbstractShape
extends AbstractFigure

This provides basic default functionality for Figures that are assumed to be movable and reshapable with observers that want to know when their locations or shapes change. It provides most of its functionality based on its bounds(), and forces concrete subclasses to define, at a minimum: paint(Graphics); getBounds(); basicTranslate(int,int); basicReshape(int,int,int,int);

See Also:
Serialized Form

Fields inherited from class com.rolemodelsoft.drawlet.basics.AbstractFigure
listeners, locationListeners
 
Constructor Summary
AbstractShape()
           
 
Method Summary
protected abstract  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.
 Handle[] getHandles()
          Answer the handles associated with the receiver.
protected  void resetBoundsCache()
          Flush caches with respect to determining bounds.
protected  void resetSizeCache()
          Flush caches with respect to determining size.
static java.awt.Polygon reshapedPolygon(java.awt.Polygon polygon, int x, int y, int width, int height)
          Answer a new version of the given polygon reshaped to the specified bounding box.
static java.awt.Polygon reshapedPolygon(java.awt.Polygon polygon, java.awt.Rectangle bounds)
          Answer a new version of the given polygon reshaped to the specified bounding box.
 void setBounds(int x, int y, int width, int height)
          Reshapes the receiver to the specified bounding box.
 void setSize(int width, int height)
          Resizes the receiver to the specified width and height.
 
Methods inherited from class com.rolemodelsoft.drawlet.basics.AbstractFigure
addPropertyChangeListener, addRelatedLocationListener, basicMove, basicTranslate, changedLocation, changedShape, changedSize, contains, contains, contains, deleteLocationListeners, disconnect, duplicate, duplicateIn, editTool, estimatedDuplicateSize, figureFromLocator, fireLocationChange, firePropertyChange, firePropertyChange, fireRelationChange, fireShapeChange, fireSizeChange, getBounds, getLocation, getLocator, getStyle, intersects, intersects, isObsolete, isWithin, isWithin, locatorAt, move, move, paint, postDuplicate, relatedLocationListeners, removePropertyChangeListener, removeRelatedLocationListener, requestConnection, resetLocationCache, setSize, setStyle, translate
 
Methods inherited from class com.rolemodelsoft.drawlet.basics.AbstractPaintable
getBottom, getHeight, getLeft, getRight, getSize, getTop, getWidth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractShape

public AbstractShape()
Method Detail

basicReshape

protected abstract void basicReshape(int x,
                                     int y,
                                     int width,
                                     int height)
Reshapes the receiver to the specified bounding box. Subclasses should probably provide synchronized versions if they're modifying attributes of the receiver.
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.
Parameters:
width - the new width.
height - the new height.
See Also:
basicReshape(int, int, int, int)

getHandles

public Handle[] getHandles()
Answer the handles associated with the receiver. A better way to do this would be with a Strategy... maybe next release.
Overrides:
getHandles in class AbstractFigure
Returns:
an array containing the Handles associated with the receiver

resetBoundsCache

protected void resetBoundsCache()
Flush caches with respect to determining bounds. This is a hook method. Subclasses may wish to override.

resetSizeCache

protected void resetSizeCache()
Flush caches with respect to determining size. This is a hook method. Subclasses may wish to override.

reshapedPolygon

public static java.awt.Polygon reshapedPolygon(java.awt.Polygon polygon,
                                               int x,
                                               int y,
                                               int width,
                                               int height)
Answer a new version of the given polygon reshaped to the specified bounding box. This is a useful utility.
Parameters:
polygon - the polygon
x - the x coordinate
y - the y coordinate
width - the width of the figure
height - the height of the figure
Returns:
a Polygon which is a new version of the given polygon reshaped to the specified bounding box

reshapedPolygon

public static java.awt.Polygon reshapedPolygon(java.awt.Polygon polygon,
                                               java.awt.Rectangle bounds)
Answer a new version of the given polygon reshaped to the specified bounding box. This is a useful utility.
Parameters:
polygon - the polygon
bounds - its new bounding box
Returns:
a Polygon which is a new version of the given polygon reshaped to the specified bounding box

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Reshapes the receiver to the specified bounding box. Let observers know what changed. This is a TemplateMethod with hooks: resetBoundsCache(), basicReshape(), changedShape()
Overrides:
setBounds in class AbstractFigure
Parameters:
x - the x coordinate
y - the y coordinate
width - the width of the figure
height - the height of the figure

setSize

public void setSize(int width,
                    int height)
Resizes the receiver to the specified width and height. Let observers know what changed. This is a TemplateMethod with hooks: resetSizeCache(), basicResize(), changedSize()
Overrides:
setSize in class AbstractFigure
Parameters:
width - the width of the figure
height - the height of the figure