|
JHotDraw 7.5.1 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.jhotdraw.beans.AbstractBean
org.jhotdraw.draw.AbstractFigure
org.jhotdraw.draw.AbstractCompositeFigure
public abstract class AbstractCompositeFigure
This abstract class can be extended to implement a CompositeFigure.
AbstractCompositeFigure.
| Nested Class Summary | |
|---|---|
protected class |
AbstractCompositeFigure.EventHandler
|
| Field Summary | |
|---|---|
protected java.awt.geom.Rectangle2D.Double |
cachedBounds
Caches the bounds to improve the performance of method getBounds(). |
protected java.awt.geom.Rectangle2D.Double |
cachedDrawingArea
Caches the drawing area to improve the performance of method getDrawingArea(). |
protected java.util.ArrayList<Figure> |
children
The children that this figure is composed of |
protected AbstractCompositeFigure.EventHandler |
eventHandler
Handles figure changes in the children. |
protected Layouter |
layouter
A Layouter determines how the children of the CompositeFigure are laid out graphically. |
| Fields inherited from class org.jhotdraw.draw.AbstractFigure |
|---|
changingDepth, listenerList |
| Fields inherited from class org.jhotdraw.beans.AbstractBean |
|---|
propertySupport |
| 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 | |
|---|---|
AbstractCompositeFigure()
|
|
| Method Summary | ||
|---|---|---|
boolean |
add(Figure figure)
Adds a child to the figure. |
|
void |
add(int index,
Figure figure)
Adds a child to the figure at the specified index. |
|
void |
addAll(java.util.Collection<? extends Figure> figures)
|
|
void |
addAll(int index,
java.util.Collection<? extends Figure> figures)
|
|
void |
addCompositeFigureListener(CompositeFigureListener listener)
Adds a listener for this composite figure. |
|
void |
addNotify(Drawing drawing)
Informs a figure, that it has been added to a drawing. |
|
void |
basicAdd(Figure figure)
Adds a child to the figure without firing events. |
|
void |
basicAdd(int index,
Figure figure)
Adds a child to the figure at the specified index without firing events. |
|
void |
basicAddAll(int index,
java.util.Collection<? extends Figure> newFigures)
|
|
int |
basicRemove(Figure child)
Removes the specified child without firing events. |
|
void |
basicRemoveAll(java.util.Collection<? extends Figure> figures)
Removes all children. |
|
void |
basicRemoveAllChildren()
Removes all children. |
|
Figure |
basicRemoveChild(int index)
Removes the child at the specified index without firing events. |
|
void |
bringToFront(Figure figure)
Brings a figure to the front of the drawing. |
|
void |
changed()
Informs that a figure changed the area of its display box. |
|
AbstractCompositeFigure |
clone()
Returns a clone of the figure, with clones of all aggregated figures, such as children and decorators. |
|
boolean |
contains(Figure f)
Returns true if this composite figure contains the specified figure. |
|
boolean |
contains(java.awt.geom.Point2D.Double p)
Checks if a point is contained by the figure. |
|
protected AbstractCompositeFigure.EventHandler |
createEventHandler()
|
|
java.util.Collection<Handle> |
createHandles(int detailLevel)
Creates handles used to manipulate the figure. |
|
void |
draw(java.awt.Graphics2D g)
Draws the figure. |
|
Figure |
findChild(java.awt.geom.Point2D.Double p)
|
|
int |
findChildIndex(java.awt.geom.Point2D.Double p)
|
|
Figure |
findFigureInside(java.awt.geom.Point2D.Double p)
Finds the innermost figure at the specified location. |
|
protected void |
fireFigureAdded(Figure f,
int zIndex)
Notify all listenerList that have registered interest for notification on this event type. |
|
protected void |
fireFigureRemoved(Figure f,
int zIndex)
Notify all listenerList that have registered interest for notification on this event type. |
|
|
get(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.Object |
getAttributesRestoreData()
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.Double |
getBounds()
Returns the untransformed logical bounds of the figure as a Rectangle. |
|
Figure |
getChild(int index)
Returns the child figure at the specified index. |
|
int |
getChildCount()
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.Double |
getDrawingArea()
Returns the drawing area of the figure as a Rectangle. |
|
Layouter |
getLayouter()
Get a Layouter object which encapsulated a layout algorithm for this figure. |
|
Dimension2DDouble |
getPreferredSize()
The preferred size is used by Layouter to determine the preferred size of a Figure. |
|
java.lang.Object |
getTransformRestoreData()
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. |
|
int |
indexOf(Figure child)
Returns the index of the specified child. |
|
protected void |
invalidate()
Invalidates cached data of the Figure. |
|
void |
layout()
A layout algorithm is used to define how the child components should be laid out in relation to each other. |
|
void |
read(DOMInput in)
|
|
boolean |
remove(Figure figure)
Removes the specified child. |
|
void |
removeAll(java.util.Collection<? extends Figure> figures)
Removes all specified children. |
|
void |
removeAllChildren()
Removes all children. |
|
Figure |
removeChild(int index)
Removes the child at the specified index. |
|
void |
removeCompositeFigureListener(CompositeFigureListener listener)
Removes a listener from this composite figure. |
|
void |
removeNotify(Drawing drawing)
Informs a figure, that it has been removed from a drawing. |
|
void |
restoreAttributesTo(java.lang.Object newData)
Restores the attributes of the figure to a previously stored state. |
|
void |
restoreTransformTo(java.lang.Object geometry)
Restores the transform of the figure to a previously stored state. |
|
void |
sendToBack(Figure figure)
Sends a figure to the back of the composite figure. |
|
|
set(AttributeKey<T> key,
T value)
Sets an attribute on the figure and calls attributeChanged
on all registered FigureListeners if the attribute value
has changed. |
|
void |
setBounds(java.awt.geom.Point2D.Double anchor,
java.awt.geom.Point2D.Double lead)
Sets the logical and untransformed bounds of the figure. |
|
void |
setLayouter(Layouter newLayouter)
Set a Layouter object which encapsulated a layout algorithm for this figure. |
|
void |
transform(java.awt.geom.AffineTransform tx)
Transforms the figure. |
|
protected void |
validate()
|
|
void |
willChange()
Informs that a figure is about to change something that affects the contents of its display box. |
|
void |
write(DOMOutput out)
|
|
| Methods inherited from class org.jhotdraw.beans.AbstractBean |
|---|
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, 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 |
| Field Detail |
|---|
protected Layouter layouter
protected java.util.ArrayList<Figure> children
add(org.jhotdraw.draw.Figure),
removeChild(int)protected transient java.awt.geom.Rectangle2D.Double cachedDrawingArea
getDrawingArea().
protected transient java.awt.geom.Rectangle2D.Double cachedBounds
getBounds().
protected AbstractCompositeFigure.EventHandler eventHandler
| Constructor Detail |
|---|
public AbstractCompositeFigure()
| Method Detail |
|---|
public java.util.Collection<Handle> createHandles(int detailLevel)
Figure
createHandles in interface FigurecreateHandles in class AbstractFiguredetailLevel - 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.
Handleprotected AbstractCompositeFigure.EventHandler createEventHandler()
public boolean add(Figure figure)
CompositeFigure
This is a convenience method for add(getChildCount(), child);
This method calls figureAdded on all registered
CompositeFigureListeners.
add in interface CompositeFiguretrue if this CompositeFigure changed as a result of the
call
public void add(int index,
Figure figure)
CompositeFigure
This method calls figureAdded on all registered
CompositeFigureListeners.
add in interface CompositeFigurepublic void addAll(java.util.Collection<? extends Figure> figures)
public final void addAll(int index,
java.util.Collection<? extends Figure> figures)
public void basicAdd(Figure figure)
CompositeFigure
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 calling
basicAdd(getChildCount(), child);.
basicAdd in interface CompositeFigure
public void basicAddAll(int index,
java.util.Collection<? extends Figure> newFigures)
public void addNotify(Drawing drawing)
Figure
addNotify in interface FigureaddNotify in class AbstractFigurepublic void removeNotify(Drawing drawing)
Figure
removeNotify in interface FigureremoveNotify in class AbstractFigurepublic boolean remove(Figure figure)
CompositeFigure
This is a convenience method for calling
removeChild(getChildren().indexOf(child));
This method calls figureRemoved on all registered
CompositeFigureListener's.
remove in interface CompositeFigurepublic Figure removeChild(int index)
CompositeFigure
Calls figureRemoved on all registered
CompositeFigureListener's.
removeChild in interface CompositeFigurepublic void removeAll(java.util.Collection<? extends Figure> figures)
add(org.jhotdraw.draw.Figure)public void removeAllChildren()
removeAllChildren in interface CompositeFigureadd(org.jhotdraw.draw.Figure)public void basicRemoveAllChildren()
basicRemoveAllChildren in interface CompositeFigureadd(org.jhotdraw.draw.Figure)public void basicRemoveAll(java.util.Collection<? extends Figure> figures)
add(org.jhotdraw.draw.Figure)public void sendToBack(Figure figure)
figure - that is part of this composite figurepublic void bringToFront(Figure figure)
figure - that is part of the drawingpublic void transform(java.awt.geom.AffineTransform tx)
transform in interface Figuretx - The transformation.Figure.getTransformRestoreData(),
Figure.restoreTransformTo(java.lang.Object)
public void setBounds(java.awt.geom.Point2D.Double anchor,
java.awt.geom.Point2D.Double lead)
FigureThis 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();
setBounds in interface FiguresetBounds in class AbstractFigureanchor - the start point of the boundslead - the end point of the boundsFigure.getBounds()public java.util.List<Figure> getChildrenFrontToBack()
public <T> void set(AttributeKey<T> key,
T value)
FigureattributeChanged
on all registered FigureListeners 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); or
figure.willChange(); figure.set(...); figure.changed();
set in interface FigureAttributeKey.set(org.jhotdraw.draw.Figure, T)public <T> T get(AttributeKey<T> name)
Figure
get in interface FigureAttributeKey.get(org.jhotdraw.draw.Figure)public java.util.Map<AttributeKey,java.lang.Object> getAttributes()
Figure
getAttributes in interface Figurepublic java.lang.Object getAttributesRestoreData()
Figure
getAttributesRestoreData in interface Figurepublic void restoreAttributesTo(java.lang.Object newData)
Figure
restoreAttributesTo in interface Figurepublic boolean contains(Figure f)
CompositeFigure
This is a convenience method for calling
getChildren().contains(f);.
contains in interface CompositeFigurepublic boolean contains(java.awt.geom.Point2D.Double p)
FigureThis is used for hit testing by Tool's.
contains in interface Figurepublic Figure findFigureInside(java.awt.geom.Point2D.Double p)
Figure
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.
findFigureInside in interface FigurefindFigureInside in class AbstractFigurep - A location on the drawing.
public Figure findChild(java.awt.geom.Point2D.Double p)
public int findChildIndex(java.awt.geom.Point2D.Double p)
public Layouter getLayouter()
getLayouter in interface CompositeFigurepublic void layout()
layout in interface CompositeFigurepublic void setLayouter(Layouter newLayouter)
setLayouter in interface CompositeFigurenewLayouter - encapsulation of a layout algorithm.public Dimension2DDouble getPreferredSize()
Figure
getPreferredSize in interface FiguregetPreferredSize in class AbstractFigurepublic void draw(java.awt.Graphics2D g)
Figure
draw in interface Figureg - The Graphics2D to draw to.public java.util.Collection<Figure> getDecomposition()
Figure
getDecomposition in interface FiguregetDecomposition in class AbstractFigure
public void read(DOMInput in)
throws java.io.IOException
read in interface DOMStorablejava.io.IOException
public void write(DOMOutput out)
throws java.io.IOException
write in interface DOMStorablejava.io.IOExceptionpublic void restoreTransformTo(java.lang.Object geometry)
Figure
restoreTransformTo in interface Figurepublic java.lang.Object getTransformRestoreData()
Figure
getTransformRestoreData in interface FigureFigure.transform(AffineTransform)
public void basicAdd(int index,
Figure figure)
CompositeFigure
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.
basicAdd in interface CompositeFigurepublic Figure basicRemoveChild(int index)
CompositeFigureThis 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.
basicRemoveChild in interface CompositeFigurepublic java.util.List<Figure> getChildren()
CompositeFigure
getChildren in interface CompositeFigurepublic int getChildCount()
CompositeFigure
This is a convenience method for calling
getChildren().size();.
getChildCount in interface CompositeFigurepublic Figure getChild(int index)
CompositeFigure
This is a convenience method for calling
getChildren().get(index);.
getChild in interface CompositeFigurepublic AbstractCompositeFigure clone()
Figure
clone in interface Figureclone in class AbstractFigureprotected void validate()
validate in class AbstractFigureprotected void invalidate()
AbstractFigure
invalidate in class AbstractFigurepublic void willChange()
AbstractFigure
willChange in interface FigurewillChange in class AbstractFigureFigure.changed()public void changed()
AbstractFigure
changed in interface Figurechanged in class AbstractFigureFigure.willChange()public int basicRemove(Figure child)
CompositeFigureThis 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.
basicRemove in interface CompositeFigurepublic int indexOf(Figure child)
CompositeFigure
This is a convenience method for calling
getChildren().indexOf(index);.
indexOf in interface CompositeFigurepublic java.awt.geom.Rectangle2D.Double getDrawingArea()
Figure
The drawing area is used to inform DrawingView about 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.
getDrawingArea in interface Figurepublic java.awt.geom.Rectangle2D.Double getBounds()
FigureThe bounds are used by Handle objects for adjusting the figure and for aligning the figure on a grid.
getBounds in interface Figure
protected void fireFigureAdded(Figure f,
int zIndex)
protected void fireFigureRemoved(Figure f,
int zIndex)
public void removeCompositeFigureListener(CompositeFigureListener listener)
CompositeFigure
removeCompositeFigureListener in interface CompositeFigurepublic void addCompositeFigureListener(CompositeFigureListener listener)
CompositeFigure
addCompositeFigureListener in interface CompositeFigure
|
Copyright 1996-2010 (c) by the authors and contributors of the JHotDraw project. Some rights reserved. |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||