CH.ifa.draw.standard
Class AbstractFigure
- java.lang.Object
-
- CH.ifa.draw.standard.AbstractFigure
-
- Direct Known Subclasses:
- AttributeFigure, CompositeFigure, DecoratorFigure, PolyLineFigure
public abstract class AbstractFigure extends java.lang.Object implements Figure
AbstractFigure provides default implementations for the Figure interface.
Design Patterns
Template Method
Template Methods implement default and invariant behavior for figure subclasses.- See Also:
Figure,Handle, Serialized Form
-
-
Field Summary
-
Fields inherited from interface CH.ifa.draw.framework.Figure
POPUP_MENU
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method and Description voidaddFigureChangeListener(FigureChangeListener l)Adds a listener for this figure.voidaddToContainer(FigureChangeListener c)Sets the Figure's container and registers the container as a figure change listener.abstract voidbasicDisplayBox(java.awt.Point origin, java.awt.Point corner)Sets the display box of a figure.booleancanConnect()Checks if this figure can be connected.java.awt.Pointcenter()Gets the center of a figure.voidchanged()Informs that a figure changed the area of its display box.java.lang.Objectclone()Clones a figure.LocatorconnectedTextLocator(Figure text)Returns the locator used to located connected text.java.awt.InsetsconnectionInsets()Returns the connection inset.ConnectorconnectorAt(int x, int y)Returns the Figures connector for the specified location.voidconnectorVisibility(boolean isVisible)Sets whether the connectors should be visible.booleancontainsPoint(int x, int y)Checks if a point is inside the figure.FigureEnumerationdecompose()Decomposes a figure into its parts.abstract java.awt.RectangledisplayBox()Gets the display box of a figure.voiddisplayBox(java.awt.Point origin, java.awt.Point corner)Changes the display box of a figure.voiddisplayBox(java.awt.Rectangle r)Changes the display box of a figure.FigureEnumerationfigures()Returns an Enumeration of the figures contained in this figure.FigurefindFigureInside(int x, int y)Returns the figure that contains the given point.java.lang.ObjectgetAttribute(java.lang.String name)Returns the named attribute or null if a a figure doesn't have an attribute.abstract java.util.Vectorhandles()Returns the handles of a Figure that can be used to manipulate some of its attributes.booleanincludes(Figure figure)Checks whether the given figure is contained in this figure.voidinvalidate()Invalidates the figure.booleanisEmpty()Checks if the figure is empty.FigureChangeListenerlistener()Gets the figure's listners.voidmoveBy(int dx, int dy)Moves the figure by the given offset.voidread(StorableInput dr)Reads the Figure from a StorableInput.voidrelease()A figure is released from the drawing.voidremoveFigureChangeListener(FigureChangeListener l)Removes a listener for this figure.voidremoveFromContainer(FigureChangeListener c)Removes a figure from the given container and unregisters it as a change listener.voidsetAttribute(java.lang.String name, java.lang.Object value)Sets the named attribute to the new value.java.awt.Dimensionsize()Gets the size of the figure.voidwillChange()Informes that a figure is about to change something that affects the contents of its display box.voidwrite(StorableOutput dw)Stores the Figure to a StorableOutput.
-
-
-
Method Detail
-
moveBy
public void moveBy(int dx, int dy)Moves the figure by the given offset.
-
displayBox
public void displayBox(java.awt.Point origin, java.awt.Point corner)Changes the display box of a figure. Clients usually call this method. It changes the display box and announces the corresponding change.- Specified by:
displayBoxin interfaceFigure- Parameters:
origin- the new origincorner- the new corner- See Also:
displayBox(java.awt.Point, java.awt.Point)
-
basicDisplayBox
public abstract void basicDisplayBox(java.awt.Point origin, java.awt.Point corner)Sets the display box of a figure. This is the method that subclassers override. Clients usually call displayBox.- Specified by:
basicDisplayBoxin interfaceFigure- Parameters:
origin- the new origincorner- the new corner- See Also:
displayBox(java.awt.Point, java.awt.Point)
-
displayBox
public abstract java.awt.Rectangle displayBox()
Gets the display box of a figure.- Specified by:
displayBoxin interfaceFigure- See Also:
Figure.basicDisplayBox(java.awt.Point, java.awt.Point)
-
handles
public abstract java.util.Vector handles()
Returns the handles of a Figure that can be used to manipulate some of its attributes.
-
figures
public FigureEnumeration figures()
Returns an Enumeration of the figures contained in this figure.- Specified by:
figuresin interfaceFigure- See Also:
CompositeFigure
-
size
public java.awt.Dimension size()
Gets the size of the figure. A convenience method.
-
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- Specified by:
isEmptyin interfaceFigure- See Also:
Figure.isEmpty()
-
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.- Specified by:
findFigureInsidein interfaceFigure- See Also:
containsPoint(int, int)
-
containsPoint
public boolean containsPoint(int x, int y)Checks if a point is inside the figure.- Specified by:
containsPointin interfaceFigure
-
displayBox
public void displayBox(java.awt.Rectangle r)
Changes the display box of a figure. This is a convenience method. Implementors should only have to override basicDisplayBox- Specified by:
displayBoxin interfaceFigure- See Also:
displayBox(java.awt.Point, java.awt.Point)
-
includes
public boolean includes(Figure figure)
Checks whether the given figure is contained in this figure.
-
decompose
public FigureEnumeration decompose()
Decomposes a figure into its parts. It returns a Vector that contains itself.
-
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.- Specified by:
addToContainerin interfaceFigure
-
removeFromContainer
public void removeFromContainer(FigureChangeListener c)
Removes a figure from the given container and unregisters it as a change listener.- Specified by:
removeFromContainerin interfaceFigure
-
addFigureChangeListener
public void addFigureChangeListener(FigureChangeListener l)
Adds a listener for this figure.- Specified by:
addFigureChangeListenerin interfaceFigure
-
removeFigureChangeListener
public void removeFigureChangeListener(FigureChangeListener l)
Removes a listener for this figure.- Specified by:
removeFigureChangeListenerin interfaceFigure
-
listener
public FigureChangeListener listener()
Gets the figure's listners.
-
release
public void release()
A figure is released from the drawing. You never call this method directly. Release notifies its listeners.- Specified by:
releasein interfaceFigure- See Also:
Figure.release()
-
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.- Specified by:
invalidatein interfaceFigure
-
willChange
public void willChange()
Informes that a figure is about to change something that affects the contents of its display box.- Specified by:
willChangein interfaceFigure- See Also:
Figure.willChange()
-
changed
public void changed()
Informs that a figure changed the area of its display box.- Specified by:
changedin interfaceFigure- See Also:
FigureChangeEvent,Figure.changed()
-
center
public java.awt.Point center()
Gets the center of a figure. A convenice method that is rarely overridden.
-
canConnect
public boolean canConnect()
Checks if this figure can be connected. By default AbstractFigures can be connected.- Specified by:
canConnectin interfaceFigure
-
connectionInsets
public java.awt.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.- Specified by:
connectionInsetsin interfaceFigure
-
connectorAt
public Connector connectorAt(int x, int y)
Returns the Figures connector for the specified location. By default a ChopBoxConnector is returned.- Specified by:
connectorAtin interfaceFigure- See Also:
ChopBoxConnector
-
connectorVisibility
public void connectorVisibility(boolean isVisible)
Sets whether the connectors should be visible. By default they are not visible and- Specified by:
connectorVisibilityin interfaceFigure
-
connectedTextLocator
public Locator connectedTextLocator(Figure text)
Returns the locator used to located connected text.- Specified by:
connectedTextLocatorin interfaceFigure
-
getAttribute
public java.lang.Object getAttribute(java.lang.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.- Specified by:
getAttributein interfaceFigure
-
setAttribute
public void setAttribute(java.lang.String name, java.lang.Object value)Sets the named attribute to the new value. By default figures don't have any attributes and the request is ignored.- Specified by:
setAttributein interfaceFigure
-
clone
public java.lang.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.- Specified by:
clonein interfaceFigure- Overrides:
clonein classjava.lang.Object- See Also:
Figure.clone()
-
write
public void write(StorableOutput dw)
Stores the Figure to a StorableOutput.
-
read
public void read(StorableInput dr) throws java.io.IOException
Reads the Figure from a StorableInput.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG