com.rolemodelsoft.drawlet
Interface Figure

All Known Subinterfaces:
LineFigure, PolygonFigure
All Known Implementing Classes:
AbstractFigure

public interface Figure
extends Paintable, Duplicatable, java.io.Serializable

This interface defines a generic Figure that can be drawn on and potentially manipulated on a DrawingCanvas (or elsewhere).


Field Summary
static java.lang.String FILL_COLOR_PROPERTY
          The fill color property selector.
static java.lang.String LINE_COLOR_PROPERTY
          The line color property selector.
static java.lang.String LOCATION_PROPERTY
          The location property selector.
static java.lang.String RELATION_PROPERTY
          The relation property selector.
static java.lang.String SHAPE_PROPERTY
          The shape property selector.
static java.lang.String SIZE_PROPERTY
          The size property selector.
static java.lang.String STRING_PROPERTY
          The string property selector.
static java.lang.String STYLE_PROPERTY
          The style property selector.
static java.lang.String TEXT_COLOR_PROPERTY
          The text color property selector.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Add a PropertyChangeListener to the listener list.
 void addRelatedLocationListener(RelatedLocationListener listener)
          Add a RelatedLocationListener to the listener list.
 boolean contains(Figure figure)
          Checks whether a specified Figure is completely "inside" this Figure, where the figures share the same coordinate system.
 boolean contains(int x, int y)
          Checks whether a specified x,y location is "inside" this Figure, where x and y are defined to be relative to the coordinate system of this figure.
 boolean contains(java.awt.Rectangle box)
          Checks whether a specified Rectangle is "inside" this Figure, where the Rectangle and this Figure are in the same coordinate system
 void disconnect()
          Clean up as appropriate if the figure is no longer connected to others.
 Handle editTool(int x, int y)
          Answers a Handle that will provide editing capabilities on the receiver, or null.
 Handle[] getHandles()
          Answer the handles associated with the receiver.
 Locator getLocator()
          Returns the current locator of this figure.
 DrawingStyle getStyle()
          Answer the style which defines how to paint the figure.
 boolean intersects(Figure anotherFigure)
          Answers whether the receiver intersects another figure.
 boolean intersects(java.awt.Rectangle box)
          Answers whether the receiver intersects a Rectangular area.
 boolean isObsolete()
          Answers whether the receiver is obsolete.
 boolean isWithin(Figure anotherFigure)
          Answers whether the receiver is fully within another Figure.
 boolean isWithin(java.awt.Rectangle box)
          Answers whether the receiver is fully within a Rectangular area.
 Locator locatorAt(int x, int y)
          Answers a locator corresponding to a significant point on the receiver.
 void move(int x, int y)
          Moves the Figure to a new location.
 void move(Locator locator)
          Moves the Figure to a new location.
 java.util.Enumeration relatedLocationListeners()
          Answer with an Enumeration over the RelatedLocationListeners.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Remove a PropertyChangeListener from the listener list.
 void removeRelatedLocationListener(RelatedLocationListener listener)
          Remove a RelatedLocationListener from the listener list.
 Locator requestConnection(Figure requestor, int x, int y)
          Answers a Locator corresponding to a significant point on the receiver that will serve as a connection to the other Figure.
 void setBounds(int x, int y, int width, int height)
          Reshapes the Figure to the specified bounding box.
 void setSize(java.awt.Dimension d)
          Resizes the Figure to the specified dimension.
 void setSize(int width, int height)
          Resizes the Figure to the specified width and height.
 void setStyle(DrawingStyle style)
          Set the style defining how to paint the Figure.
 void translate(int x, int y)
          Moves the Figure in the x and y direction.
 
Methods inherited from interface com.rolemodelsoft.drawlet.Paintable
getBottom, getBounds, getHeight, getLeft, getRight, getSize, getTop, getWidth, paint
 
Methods inherited from interface com.rolemodelsoft.drawlet.util.Duplicatable
duplicate, duplicateIn, postDuplicate
 

Field Detail

SHAPE_PROPERTY

public static final java.lang.String SHAPE_PROPERTY
The shape property selector.

SIZE_PROPERTY

public static final java.lang.String SIZE_PROPERTY
The size property selector.

LOCATION_PROPERTY

public static final java.lang.String LOCATION_PROPERTY
The location property selector.

STYLE_PROPERTY

public static final java.lang.String STYLE_PROPERTY
The style property selector.

FILL_COLOR_PROPERTY

public static final java.lang.String FILL_COLOR_PROPERTY
The fill color property selector.

LINE_COLOR_PROPERTY

public static final java.lang.String LINE_COLOR_PROPERTY
The line color property selector.

TEXT_COLOR_PROPERTY

public static final java.lang.String TEXT_COLOR_PROPERTY
The text color property selector.

STRING_PROPERTY

public static final java.lang.String STRING_PROPERTY
The string property selector.

RELATION_PROPERTY

public static final java.lang.String RELATION_PROPERTY
The relation property selector.
Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list.
Parameters:
listener - The PropertyChangeListener to be added

addRelatedLocationListener

public void addRelatedLocationListener(RelatedLocationListener listener)
Add a RelatedLocationListener to the listener list.
Parameters:
listener - The RelatedLocationListener to be added

contains

public boolean contains(int x,
                        int y)
Checks whether a specified x,y location is "inside" this Figure, where x and y are defined to be relative to the coordinate system of this figure.
Parameters:
x - the x coordinate
y - the y coordinate
Returns:
boolean value of true if x and y are "inside" this Figure; false otherwise.

contains

public boolean contains(Figure figure)
Checks whether a specified Figure is completely "inside" this Figure, where the figures share the same coordinate system. It is intended that objects that are smart enough to use something besides bounds will implement this intelligently, and isWithin will turn the parameter and receiver around to invoke this.
Parameters:
figure - the Figure to test for inclusion
Returns:
boolean value of true if the specified Figure is completely "inside" this Figure false otherwise.

contains

public boolean contains(java.awt.Rectangle box)
Checks whether a specified Rectangle is "inside" this Figure, where the Rectangle and this Figure are in the same coordinate system
Parameters:
box - the rectangle to test for inclusion
Returns:
boolean value of true if the specified Rectangle is "inside" this Figure; false otherwise.

disconnect

public void disconnect()
Clean up as appropriate if the figure is no longer connected to others.

editTool

public Handle editTool(int x,
                       int y)
Answers a Handle that will provide editing capabilities on the receiver, or null.
Parameters:
x - the x coordinate to potentially begin editing
y - the y coordinate to potentially begin editing
Returns:
a Handle that will provide editing capabilities on the receiver, or null

getHandles

public Handle[] getHandles()
Answer the handles associated with the receiver.
Returns:
an array of the Handles associated with the receiver

getLocator

public Locator getLocator()
Returns the current locator of this figure. This may or may not represent the top left of the receiver's area.
Returns:
the current Locator of this figure

getStyle

public DrawingStyle getStyle()
Answer the style which defines how to paint the figure. NOTE: It may be valid to return null if the figure just doesn't care
Returns:
the DrawingStyle which defines how to paint the figure

intersects

public boolean intersects(Figure anotherFigure)
Answers whether the receiver intersects another figure.
Parameters:
anotherFigure - the figure the receiver is potentially intersecting.
Returns:
boolean value of true if the receiver intersects another figure; false otherwise.

intersects

public boolean intersects(java.awt.Rectangle box)
Answers whether the receiver intersects a Rectangular area.
Parameters:
box - the Rectangular area
Returns:
boolean value of true if the receiver intersects the Rectangular area; false otherwise.

isObsolete

public boolean isObsolete()
Answers whether the receiver is obsolete. True if some event has happened that makes this a meaningless object.
Returns:
boolean value of true if some event has happened that makes this a meaningless object; false otherwise.

isWithin

public boolean isWithin(Figure anotherFigure)
Answers whether the receiver is fully within another Figure.
Parameters:
anotherFigure - the figure the receiver is potentially inside.
Returns:
boolean value of true if the receiver is fully within another Figure; false otherwise.

isWithin

public boolean isWithin(java.awt.Rectangle box)
Answers whether the receiver is fully within a Rectangular area.
Parameters:
box - the Rectangular area
Returns:
boolean value of true if the receiver is fully within a Rectangular area; false otherwise.

locatorAt

public Locator locatorAt(int x,
                         int y)
Answers a locator corresponding to a significant point on the receiver. It is up to the receiver whether to answer an absolute or relative locator or even whether to give a non-null answer or ignore the x, y coordinates.
Parameters:
x - the x coordinate of the requested locator
y - the y coordinate of the requested locator
Returns:
a Locator corresponding to a significant point on the receiver

move

public void move(int x,
                 int y)
Moves the Figure to a new location. The x and y coordinates are in the parent's coordinate space.
Parameters:
x - the x coordinate
y - the y coordinate
See Also:
#location, #reshape

move

public void move(Locator locator)
Moves the Figure to a new location. Note: Subclasses may wish to update dependencies based on this new location
Parameters:
locator - the Locator which identifies the desired x, y coordinates.
See Also:
#location

relatedLocationListeners

public java.util.Enumeration relatedLocationListeners()
Answer with an Enumeration over the RelatedLocationListeners.
Returns:
an Enumeration over the RelatedLocationListeners

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list.
Parameters:
listener - The PropertyChangeListener to be removed

removeRelatedLocationListener

public void removeRelatedLocationListener(RelatedLocationListener listener)
Remove a RelatedLocationListener from the listener list.
Parameters:
listener - The RelatedLocationListener to be removed

requestConnection

public Locator requestConnection(Figure requestor,
                                 int x,
                                 int y)
Answers a Locator corresponding to a significant point on the receiver that will serve as a connection to the other Figure. It is up to the receiver whether to answer a relative locator or even whether to give a non-null answer or ignore the x, y coordinates.
Parameters:
requestor - the Figure requesting a connection
x - the x coordinate of the requested locator
y - the y coordinate of the requested locator
Returns:
a Locator corresponding to a significant point on the receiver that will serve as a connection to the other Figure

setBounds

public void setBounds(int x,
                      int y,
                      int width,
                      int height)
Reshapes the Figure to the specified bounding box. Observable objects may wish to notify dependents
Parameters:
x - the x coordinate
y - the y coordinate
width - the width of the figure
height - the height of the figure
See Also:
#bounds, move(int, int), #resize

setSize

public void setSize(int width,
                    int height)
Resizes the Figure to the specified width and height.
Parameters:
width - the width of the figure
height - the height of the figure
See Also:
#size, #reshape

setSize

public void setSize(java.awt.Dimension d)
Resizes the Figure to the specified dimension.
Parameters:
d - the figure dimension
See Also:
#size, #reshape

setStyle

public void setStyle(DrawingStyle style)
Set the style defining how to paint the Figure.
Parameters:
style - the specified DrawingStyle

translate

public void translate(int x,
                      int y)
Moves the Figure in the x and y direction. Observable objects may wish to notify dependents
Parameters:
x - amount to move in the x direction
y - amount to move in the y direction
See Also:
#location, #reshape