All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class CH.ifa.draw.standard.AbstractFigure

java.lang.Object
   |
   +----CH.ifa.draw.standard.AbstractFigure

public abstract class AbstractFigure
extends Object
implements Figure
AbstractFigure provides default implementations for the Figure interface.
Design Patterns

 o Template Method
Template Methods implement default and invariant behavior for figure subclasses.


See Also:
Figure, Handle

Constructor Index

 o AbstractFigure()

Method Index

 o addFigureChangeListener(FigureChangeListener)
Adds a listener for this figure.
 o addToContainer(FigureChangeListener)
Sets the Figure's container and registers the container as a figure change listener.
 o basicDisplayBox(Point, Point)
Sets the display box of a figure.
 o basicMoveBy(int, int)
Moves the figure.
 o canConnect()
Checks if this figure can be connected.
 o center()
Gets the center of a figure.
 o changed()
Informs that a figure changed the area of its display box.
 o clone()
Clones a figure.
 o connectedTextLocator(Figure)
Returns the locator used to located connected text.
 o connectionInsets()
Returns the connection inset.
 o connectorAt(int, int)
Returns the Figures connector for the specified location.
 o connectorVisibility(boolean)
Sets whether the connectors should be visible.
 o containsPoint(int, int)
Checks if a point is inside the figure.
 o decompose()
Decomposes a figure into its parts.
 o displayBox()
Gets the display box of a figure.
 o displayBox(Point, Point)
Changes the display box of a figure.
 o displayBox(Rectangle)
Changes the display box of a figure.
 o draw(Graphics)
Draws the figure.
 o figures()
Returns an Enumeration of the figures contained in this figure.
 o findFigureInside(int, int)
Returns the figure that contains the given point.
 o getAttribute(String)
Returns the named attribute or null if a a figure doesn't have an attribute.
 o handles()
Returns the handles of a Figure that can be used to manipulate some of its attributes.
 o includes(Figure)
Checks whether the given figure is contained in this figure.
 o invalidate()
Invalidates the figure.
 o isEmpty()
Checks if the figure is empty.
 o listener()
Gets the figure's listners.
 o moveBy(int, int)
Moves the figure by the given offset.
 o read(StorableInput)
Reads the Figure from a StorableInput.
 o release()
A figure is released from the drawing.
 o removeFigureChangeListener(FigureChangeListener)
Removes a listener for this figure.
 o removeFromContainer(FigureChangeListener)
Removes a figure from the given container and unregisters it as a change listener.
 o setAttribute(String, Object)
Sets the named attribute to the new value.
 o size()
Gets the size of the figure.
 o willChange()
Informes that a figure is about to change something that affects the contents of its display box.
 o write(StorableOutput)
Stores the Figure to a StorableOutput.

Constructors

 o AbstractFigure
 protected AbstractFigure()

Methods

 o moveBy
 public void moveBy(int dx,
                    int dy)
Moves the figure by the given offset.

 o basicMoveBy
 protected abstract void basicMoveBy(int dx,
                                     int dy)
Moves the figure. This is the method that subclassers override. Clients usually call displayBox.

See Also:
moveBy
 o displayBox
 public void displayBox(Point origin,
                        Point corner)
Changes the display box of a figure. Clients usually call this method. It changes the display box and announces the corresponding change.

Parameters:
origin - the new origin
corner - the new corner
See Also:
displayBox
 o basicDisplayBox
 public abstract void basicDisplayBox(Point origin,
                                      Point corner)
Sets the display box of a figure. This is the method that subclassers override. Clients usually call displayBox.

See Also:
displayBox
 o displayBox
 public abstract Rectangle displayBox()
Gets the display box of a figure.

 o handles
 public abstract Vector handles()
Returns the handles of a Figure that can be used to manipulate some of its attributes.

Returns:
a Vector of handles
See Also:
Handle
 o figures
 public FigureEnumeration figures()
Returns an Enumeration of the figures contained in this figure.

See Also:
CompositeFigure
 o size
 public Dimension size()
Gets the size of the figure. A convenience method.

 o isEmpty
 public boolean isEmpty()
Checks if the figure is empty. The default implementation returns true if the width or height of its display box is < 3

See Also:
isEmpty
 o findFigureInside
 public Figure findFigureInside(int x,
                                int y)
Returns the figure that contains the given point. In contrast to containsPoint it returns its innermost figure that contains the point.

See Also:
containsPoint
 o containsPoint
 public boolean containsPoint(int x,
                              int y)
Checks if a point is inside the figure.

 o displayBox
 public void displayBox(Rectangle r)
Changes the display box of a figure. This is a convenience method. Implementors should only have to override basicDisplayBox

See Also:
displayBox
 o includes
 public boolean includes(Figure figure)
Checks whether the given figure is contained in this figure.

 o decompose
 public FigureEnumeration decompose()
Decomposes a figure into its parts. It returns a Vector that contains itself.

Returns:
an Enumeration for a Vector with itself as the only element.
 o addToContainer
 public void addToContainer(FigureChangeListener c)
Sets the Figure's container and registers the container as a figure change listener. A figure's container can be any kind of FigureChangeListener. A figure is not restricted to have a single container.

 o removeFromContainer
 public void removeFromContainer(FigureChangeListener c)
Removes a figure from the given container and unregisters it as a change listener.

 o addFigureChangeListener
 public void addFigureChangeListener(FigureChangeListener l)
Adds a listener for this figure.

 o removeFigureChangeListener
 public void removeFigureChangeListener(FigureChangeListener l)
Removes a listener for this figure.

 o listener
 public FigureChangeListener listener()
Gets the figure's listners.

 o release
 public void release()
A figure is released from the drawing. You never call this method directly. Release notifies its listeners.

See Also:
release
 o invalidate
 public void invalidate()
Invalidates the figure. This method informs the listeners that the figure's current display box is invalid and should be refreshed.

 o willChange
 public void willChange()
Informes that a figure is about to change something that affects the contents of its display box.

See Also:
willChange
 o changed
 public void changed()
Informs that a figure changed the area of its display box.

See Also:
FigureChangeEvent, changed
 o center
 public Point center()
Gets the center of a figure. A convenice method that is rarely overridden.

 o canConnect
 public boolean canConnect()
Checks if this figure can be connected. By default AbstractFigures can be connected.

 o connectionInsets
 public Insets connectionInsets()
Returns the connection inset. The connection inset defines the area where the display box of a figure can't be connected. By default the entire display box can be connected.

 o connectorAt
 public Connector connectorAt(int x,
                              int y)
Returns the Figures connector for the specified location. By default a ChopBoxConnector is returned.

See Also:
ChopBoxConnector
 o connectorVisibility
 public void connectorVisibility(boolean isVisible)
Sets whether the connectors should be visible. By default they are not visible and

 o connectedTextLocator
 public Locator connectedTextLocator(Figure text)
Returns the locator used to located connected text.

 o getAttribute
 public Object getAttribute(String name)
Returns the named attribute or null if a a figure doesn't have an attribute. By default figures don't have any attributes getAttribute returns null.

 o setAttribute
 public void setAttribute(String name,
                          Object value)
Sets the named attribute to the new value. By default figures don't have any attributes and the request is ignored.

 o clone
 public Object clone()
Clones a figure. Creates a clone by using the storable mechanism to flatten the Figure to stream followed by resurrecting it from the same stream.

Overrides:
clone in class Object
See Also:
clone
 o write
 public void write(StorableOutput dw)
Stores the Figure to a StorableOutput.

 o read
 public void read(StorableInput dr) throws IOException
Reads the Figure from a StorableInput.


All Packages  Class Hierarchy  This Package  Previous  Next  Index