Class AbstractCompositeFigure
- java.lang.Object
-
- org.jhotdraw.beans.AbstractBean
-
- org.jhotdraw.draw.AbstractFigure
-
- org.jhotdraw.draw.AbstractCompositeFigure
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, CompositeFigure, Figure, DOMStorable
- Direct Known Subclasses:
- AbstractAttributedCompositeFigure, GraphicalCompositeFigure, GroupFigure, QuadTreeCompositeFigure
public abstract class AbstractCompositeFigure extends AbstractFigure implements CompositeFigure, DOMStorable
This abstract class can be extended to implement aCompositeFigure. AbstractCompositeFigure.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.jhotdraw.draw.CompositeFigure
LAYOUT_INSETS
-
Fields inherited from interface org.jhotdraw.draw.Figure
CONNECTABLE_PROPERTY, REMOVABLE_PROPERTY, SELECTABLE_PROPERTY, TRANSFORMABLE_PROPERTY
-
-
Constructor Summary
Constructors Constructor and Description AbstractCompositeFigure()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleanadd(Figure figure)Adds a child to the figure.voidadd(int index, Figure figure)Adds a child to the figure at the specified index.voidaddAll(java.util.Collection<? extends Figure> figures)voidaddAll(int index, java.util.Collection<? extends Figure> figures)voidaddCompositeFigureListener(CompositeFigureListener listener)Adds a listener for this composite figure.voidaddNotify(Drawing drawing)Informs a figure, that it has been added to a drawing.voidbasicAdd(Figure figure)Adds a child to the figure without firing events.voidbasicAdd(int index, Figure figure)Adds a child to the figure at the specified index without firing events.voidbasicAddAll(int index, java.util.Collection<? extends Figure> newFigures)intbasicRemove(Figure child)Removes the specified child without firing events.voidbasicRemoveAll(java.util.Collection<? extends Figure> figures)Removes all children.voidbasicRemoveAllChildren()Removes all children.FigurebasicRemoveChild(int index)Removes the child at the specified index without firing events.voidbringToFront(Figure figure)Brings a figure to the front of the drawing.voidchanged()Informs that a figure changed the area of its display box.AbstractCompositeFigureclone()Returns a clone of the figure, with clones of all aggregated figures, such as children and decorators.booleancontains(Figure f)Returns true if this composite figure contains the specified figure.booleancontains(java.awt.geom.Point2D.Double p)Checks if a point is contained by the figure.java.util.Collection<Handle>createHandles(int detailLevel)Creates handles used to manipulate the figure.voiddraw(java.awt.Graphics2D g)Draws the figure.FigurefindChild(java.awt.geom.Point2D.Double p)intfindChildIndex(java.awt.geom.Point2D.Double p)FigurefindFigureInside(java.awt.geom.Point2D.Double p)Finds the innermost figure at the specified location.<T> Tget(AttributeKey<T> name)Gets an attribute from the Figure.java.util.Map<AttributeKey,java.lang.Object>getAttributes()Returns a view to all attributes of this figure.java.lang.ObjectgetAttributesRestoreData()Gets data which can be used to restore the attributes of the figure after a set has been applied to it.java.awt.geom.Rectangle2D.DoublegetBounds()Returns the untransformed logical bounds of the figure as a Rectangle.FiguregetChild(int index)Returns the child figure at the specified index.intgetChildCount()Returns the number of children.java.util.List<Figure>getChildren()Returns an unchangeable list view on the children.java.util.List<Figure>getChildrenFrontToBack()Returns an iterator to iterate in Z-order front to back over the children.java.util.Collection<Figure>getDecomposition()Returns a decompositon of a figure into its parts.java.awt.geom.Rectangle2D.DoublegetDrawingArea()Returns the drawing area of the figure as a Rectangle.LayoutergetLayouter()Get a Layouter object which encapsulated a layout algorithm for this figure.Dimension2DDoublegetPreferredSize()The preferred size is used by Layouter to determine the preferred size of a Figure.java.lang.ObjectgetTransformRestoreData()Gets data which can be used to restore the transformation of the figure without loss of precision, after a transform has been applied to it.intindexOf(Figure child)Returns the index of the specified child.voidlayout()A layout algorithm is used to define how the child components should be laid out in relation to each other.voidread(DOMInput in)booleanremove(Figure figure)Removes the specified child.voidremoveAll(java.util.Collection<? extends Figure> figures)Removes all specified children.voidremoveAllChildren()Removes all children.FigureremoveChild(int index)Removes the child at the specified index.voidremoveCompositeFigureListener(CompositeFigureListener listener)Removes a listener from this composite figure.voidremoveNotify(Drawing drawing)Informs a figure, that it has been removed from a drawing.voidrestoreAttributesTo(java.lang.Object newData)Restores the attributes of the figure to a previously stored state.voidrestoreTransformTo(java.lang.Object geometry)Restores the transform of the figure to a previously stored state.voidsendToBack(Figure figure)Sends a figure to the back of the composite figure.<T> voidset(AttributeKey<T> key, T value)Sets an attribute on the figure and callsattributeChangedon all registeredFigureListeners if the attribute value has changed.voidsetBounds(java.awt.geom.Point2D.Double anchor, java.awt.geom.Point2D.Double lead)Sets the logical and untransformed bounds of the figure.voidsetLayouter(Layouter newLayouter)Set a Layouter object which encapsulated a layout algorithm for this figure.voidtransform(java.awt.geom.AffineTransform tx)Transforms the figure.voidwillChange()Informs that a figure is about to change something that affects the contents of its display box.voidwrite(DOMOutput out)-
Methods inherited from class org.jhotdraw.draw.AbstractFigure
addFigureListener, findCompatibleConnector, findConnector, fireAreaInvalidated, fireFigureChanged, getActions, getConnectors, getCursor, getEndPoint, getLayer, getStartPoint, getTool, getToolTipText, handleDrop, handleMouseClick, includes, isConnectable, isRemovable, isSelectable, isTransformable, isVisible, remap, removeFigureListener, requestRemove, setBounds, setConnectable, setRemovable, setSelectable, setTransformable, setVisible, toString
-
Methods inherited from class org.jhotdraw.beans.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jhotdraw.draw.Figure
addFigureListener, addPropertyChangeListener, findCompatibleConnector, findConnector, getActions, getConnectors, getCursor, getEndPoint, getLayer, getStartPoint, getTool, getToolTipText, handleDrop, handleMouseClick, includes, isConnectable, isRemovable, isSelectable, isTransformable, isVisible, remap, removeFigureListener, removePropertyChangeListener, requestRemove
-
-
-
-
Method Detail
-
createHandles
public java.util.Collection<Handle> createHandles(int detailLevel)
Description copied from interface:FigureCreates handles used to manipulate the figure.- Specified by:
createHandlesin interfaceFigure- Overrides:
createHandlesin classAbstractFigure- Parameters:
detailLevel- The detail level of the handles. Usually this is 0 for bounding box handles and 1 for point handles. The value -1 is used by the SelectAreaTracker and the HandleTracker to highlight figures, over which the mouse pointer is hovering.- Returns:
- a Collection of handles
- See Also:
Handle
-
add
public boolean add(Figure figure)
Description copied from interface:CompositeFigureAdds a child to the figure.This is a convenience method for
add(getChildCount(), child);This method calls
figureAddedon all registeredCompositeFigureListeners.- Specified by:
addin interfaceCompositeFigure- Returns:
trueif this CompositeFigure changed as a result of the call
-
add
public void add(int index, Figure figure)Description copied from interface:CompositeFigureAdds a child to the figure at the specified index.This method calls
figureAddedon all registeredCompositeFigureListeners.- Specified by:
addin interfaceCompositeFigure
-
addAll
public void addAll(java.util.Collection<? extends Figure> figures)
-
addAll
public final void addAll(int index, java.util.Collection<? extends Figure> figures)
-
basicAdd
public void basicAdd(Figure figure)
Description copied from interface:CompositeFigureAdds a child to the figure without firing events.This method can be used to reinsert a child figure which has been temporarily removed from this CompositeFigure (for example to reorder the sequence of the children) and to efficiently build a drawing from an
InputFormat. This is a convenience method for callingbasicAdd(getChildCount(), child);.- Specified by:
basicAddin interfaceCompositeFigure
-
basicAddAll
public void basicAddAll(int index, java.util.Collection<? extends Figure> newFigures)
-
addNotify
public void addNotify(Drawing drawing)
Description copied from interface:FigureInforms a figure, that it has been added to a drawing. The figure must inform all FigureListeners that it has been added.- Specified by:
addNotifyin interfaceFigure- Overrides:
addNotifyin classAbstractFigure
-
removeNotify
public void removeNotify(Drawing drawing)
Description copied from interface:FigureInforms a figure, that it has been removed from a drawing. The figure must inform all FigureListeners that it has been removed.- Specified by:
removeNotifyin interfaceFigure- Overrides:
removeNotifyin classAbstractFigure
-
remove
public boolean remove(Figure figure)
Description copied from interface:CompositeFigureRemoves the specified child. Returns true, if the Figure contained the removed child.This is a convenience method for calling
removeChild(getChildren().indexOf(child));This method calls
figureRemovedon all registeredCompositeFigureListener's.- Specified by:
removein interfaceCompositeFigure
-
removeChild
public Figure removeChild(int index)
Description copied from interface:CompositeFigureRemoves the child at the specified index. Returns the removed child figure.Calls
figureRemovedon all registeredCompositeFigureListener's.- Specified by:
removeChildin interfaceCompositeFigure
-
removeAll
public void removeAll(java.util.Collection<? extends Figure> figures)
Removes all specified children.- See Also:
add(org.jhotdraw.draw.Figure)
-
removeAllChildren
public void removeAllChildren()
Removes all children.- Specified by:
removeAllChildrenin interfaceCompositeFigure- See Also:
add(org.jhotdraw.draw.Figure)
-
basicRemoveAllChildren
public void basicRemoveAllChildren()
Removes all children.- Specified by:
basicRemoveAllChildrenin interfaceCompositeFigure- See Also:
add(org.jhotdraw.draw.Figure)
-
basicRemoveAll
public void basicRemoveAll(java.util.Collection<? extends Figure> figures)
Removes all children.- See Also:
add(org.jhotdraw.draw.Figure)
-
sendToBack
public void sendToBack(Figure figure)
Sends a figure to the back of the composite figure.- Parameters:
figure- that is part of this composite figure
-
bringToFront
public void bringToFront(Figure figure)
Brings a figure to the front of the drawing.- Parameters:
figure- that is part of the drawing
-
transform
public void transform(java.awt.geom.AffineTransform tx)
Transforms the figure.- Specified by:
transformin interfaceFigure- Parameters:
tx- The transformation.- See Also:
Figure.getTransformRestoreData(),Figure.restoreTransformTo(java.lang.Object)
-
setBounds
public void setBounds(java.awt.geom.Point2D.Double anchor, java.awt.geom.Point2D.Double lead)Description copied from interface:FigureSets the logical and untransformed bounds of the figure.This is used by Tool's which create a new Figure and by Tool's which connect a Figure to another Figure.
This is a basic operation which does not fire events. Use the following code sequence, if you need event firing:
figure.willChange(); figure.setBounds(...); figure.changed();
- Specified by:
setBoundsin interfaceFigure- Overrides:
setBoundsin classAbstractFigure- Parameters:
anchor- the start point of the boundslead- the end point of the bounds- See Also:
Figure.getBounds()
-
getChildrenFrontToBack
public java.util.List<Figure> getChildrenFrontToBack()
Returns an iterator to iterate in Z-order front to back over the children.
-
set
public <T> void set(AttributeKey<T> key, T value)
Description copied from interface:FigureSets an attribute on the figure and callsattributeChangedon all registeredFigureListeners if the attribute value has changed.For efficiency reasons, the drawing is not automatically repainted. If you want the drawing to be repainted when the attribute is changed, you can either use
key.set(figure, value);orfigure.willChange(); figure.set(...); figure.changed();
- Specified by:
setin interfaceFigure- See Also:
AttributeKey.set(org.jhotdraw.draw.Figure, T)
-
get
public <T> T get(AttributeKey<T> name)
Description copied from interface:FigureGets an attribute from the Figure.- Specified by:
getin interfaceFigure- Returns:
- Returns the attribute value. If the Figure does not have an attribute with the specified key, returns key.getDefaultValue().
- See Also:
AttributeKey.get(org.jhotdraw.draw.Figure)
-
getAttributes
public java.util.Map<AttributeKey,java.lang.Object> getAttributes()
Description copied from interface:FigureReturns a view to all attributes of this figure. By convention, an unmodifiable map is returned.- Specified by:
getAttributesin interfaceFigure
-
getAttributesRestoreData
public java.lang.Object getAttributesRestoreData()
Description copied from interface:FigureGets data which can be used to restore the attributes of the figure after a set has been applied to it.- Specified by:
getAttributesRestoreDatain interfaceFigure
-
restoreAttributesTo
public void restoreAttributesTo(java.lang.Object newData)
Description copied from interface:FigureRestores the attributes of the figure to a previously stored state.- Specified by:
restoreAttributesToin interfaceFigure
-
contains
public boolean contains(Figure f)
Description copied from interface:CompositeFigureReturns true if this composite figure contains the specified figure.This is a convenience method for calling
getChildren().contains(f);.- Specified by:
containsin interfaceCompositeFigure
-
contains
public boolean contains(java.awt.geom.Point2D.Double p)
Description copied from interface:FigureChecks if a point is contained by the figure.This is used for hit testing by Tool's.
-
findFigureInside
@Nullable public Figure findFigureInside(java.awt.geom.Point2D.Double p)
Description copied from interface:FigureFinds the innermost figure at the specified location.In case of a
CompositeFigure, this method descends into its children and into its children's children until the innermost figure is found.This functionality is implemented using the Chain of Responsibility design pattern. A figure which is not composed of other figures returns itself if the point is contained by the figure. Composed figures pass the method call down to their children.
- Specified by:
findFigureInsidein interfaceFigure- Overrides:
findFigureInsidein classAbstractFigure- Parameters:
p- A location on the drawing.- Returns:
- Returns the innermost figure at the location, or null if the location is not contained in a figure.
-
findChildIndex
public int findChildIndex(java.awt.geom.Point2D.Double p)
-
getLayouter
public Layouter getLayouter()
Get a Layouter object which encapsulated a layout algorithm for this figure. Typically, a Layouter accesses the child components of this figure and arranges their graphical presentation.- Specified by:
getLayouterin interfaceCompositeFigure- Returns:
- layout strategy used by this figure
-
layout
public void layout()
A layout algorithm is used to define how the child components should be laid out in relation to each other. The task for layouting the child components for presentation is delegated to a Layouter which can be plugged in at runtime.- Specified by:
layoutin interfaceCompositeFigure
-
setLayouter
public void setLayouter(Layouter newLayouter)
Set a Layouter object which encapsulated a layout algorithm for this figure. Typically, a Layouter accesses the child components of this figure and arranges their graphical presentation. It is a good idea to set the Layouter in the protected initialize() method so it can be recreated if a GraphicalCompositeFigure is read and restored from a StorableInput stream.- Specified by:
setLayouterin interfaceCompositeFigure- Parameters:
newLayouter- encapsulation of a layout algorithm.
-
getPreferredSize
public Dimension2DDouble getPreferredSize()
Description copied from interface:FigureThe preferred size is used by Layouter to determine the preferred size of a Figure. For most Figure's this is the same as the dimensions returned by getBounds.- Specified by:
getPreferredSizein interfaceFigure- Overrides:
getPreferredSizein classAbstractFigure
-
draw
public void draw(java.awt.Graphics2D g)
Description copied from interface:FigureDraws the figure.
-
getDecomposition
public java.util.Collection<Figure> getDecomposition()
Description copied from interface:FigureReturns a decompositon of a figure into its parts. A figure is considered as a part of itself.- Specified by:
getDecompositionin interfaceFigure- Overrides:
getDecompositionin classAbstractFigure
-
read
public void read(DOMInput in) throws java.io.IOException
- Specified by:
readin interfaceDOMStorable- Throws:
java.io.IOException
-
write
public void write(DOMOutput out) throws java.io.IOException
- Specified by:
writein interfaceDOMStorable- Throws:
java.io.IOException
-
restoreTransformTo
public void restoreTransformTo(java.lang.Object geometry)
Description copied from interface:FigureRestores the transform of the figure to a previously stored state.- Specified by:
restoreTransformToin interfaceFigure
-
getTransformRestoreData
public java.lang.Object getTransformRestoreData()
Description copied from interface:FigureGets data which can be used to restore the transformation of the figure without loss of precision, after a transform has been applied to it.- Specified by:
getTransformRestoreDatain interfaceFigure- See Also:
Figure.transform(AffineTransform)
-
basicAdd
public void basicAdd(int index, Figure figure)Description copied from interface:CompositeFigureAdds a child to the figure at the specified index without firing events.This method can be used to reinsert a child figure which has been temporarily removed from this CompositeFigure (for example to reorder the sequence of the children) and to efficiently build a drawing from an
InputFormat.- Specified by:
basicAddin interfaceCompositeFigure
-
basicRemoveChild
public Figure basicRemoveChild(int index)
Description copied from interface:CompositeFigureRemoves the child at the specified index without firing events.This method can be used to temporarily remove a child from this CompositeFigure (for example to reorder the sequence of the children).
Returns the removed child figure.
- Specified by:
basicRemoveChildin interfaceCompositeFigure
-
getChildren
public java.util.List<Figure> getChildren()
Description copied from interface:CompositeFigureReturns an unchangeable list view on the children.- Specified by:
getChildrenin interfaceCompositeFigure
-
getChildCount
public int getChildCount()
Description copied from interface:CompositeFigureReturns the number of children.This is a convenience method for calling
getChildren().size();.- Specified by:
getChildCountin interfaceCompositeFigure
-
getChild
public Figure getChild(int index)
Description copied from interface:CompositeFigureReturns the child figure at the specified index.This is a convenience method for calling
getChildren().get(index);.- Specified by:
getChildin interfaceCompositeFigure
-
clone
public AbstractCompositeFigure clone()
Description copied from interface:FigureReturns a clone of the figure, with clones of all aggregated figures, such as children and decorators. The cloned figure does not clone the list of FigureListeners from its original.- Specified by:
clonein interfaceFigure- Overrides:
clonein classAbstractFigure
-
willChange
public void willChange()
Description copied from class:AbstractFigureInforms that a figure is about to change something that affects the contents of its display box.- Specified by:
willChangein interfaceFigure- Overrides:
willChangein classAbstractFigure- See Also:
Figure.changed()
-
changed
public void changed()
Description copied from class:AbstractFigureInforms that a figure changed the area of its display box.- Specified by:
changedin interfaceFigure- Overrides:
changedin classAbstractFigure- See Also:
Figure.willChange()
-
basicRemove
public int basicRemove(Figure child)
Description copied from interface:CompositeFigureRemoves the specified child without firing events.This method can be used to temporarily remove a child from this CompositeFigure (for example to reorder the sequence of the children).
This is a convenience method for calling
basicRemove(indexOf(child));.Returns the index of the removed figure. Returns -1 if the figure was not a child of this CompositeFigure.
- Specified by:
basicRemovein interfaceCompositeFigure
-
indexOf
public int indexOf(Figure child)
Description copied from interface:CompositeFigureReturns the index of the specified child.This is a convenience method for calling
getChildren().indexOf(index);.- Specified by:
indexOfin interfaceCompositeFigure- Returns:
- The index of the child, or -1 if the specified figure is not a child of this CompositeFigure.
-
getDrawingArea
public java.awt.geom.Rectangle2D.Double getDrawingArea()
Description copied from interface:FigureReturns the drawing area of the figure as a Rectangle.The drawing area is used to inform
DrawingViewabout the area that is needed to draw this figure.The drawing area needs to be large enough, to take line width, line caps and other decorations into account that exceed the bounds of the Figure.
- Specified by:
getDrawingAreain interfaceFigure
-
getBounds
public java.awt.geom.Rectangle2D.Double getBounds()
Description copied from interface:FigureReturns the untransformed logical bounds of the figure as a Rectangle.The bounds are used by Handle objects for adjusting the figure and for aligning the figure on a grid.
-
removeCompositeFigureListener
public void removeCompositeFigureListener(CompositeFigureListener listener)
Description copied from interface:CompositeFigureRemoves a listener from this composite figure.- Specified by:
removeCompositeFigureListenerin interfaceCompositeFigure
-
addCompositeFigureListener
public void addCompositeFigureListener(CompositeFigureListener listener)
Description copied from interface:CompositeFigureAdds a listener for this composite figure.- Specified by:
addCompositeFigureListenerin interfaceCompositeFigure
-
-
DataMelt 3.0 © DataMelt by jWork.ORG