JHotDraw 7.0.6

org.jhotdraw.draw
Class AbstractCompositeFigure

java.lang.Object
  extended by org.jhotdraw.draw.AbstractFigure
      extended by org.jhotdraw.draw.AbstractCompositeFigure
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, CompositeFigure, Figure, DOMStorable
Direct Known Subclasses:
AbstractAttributedCompositeFigure, GraphicalCompositeFigure, GroupFigure

public abstract class AbstractCompositeFigure
extends AbstractFigure
implements CompositeFigure

A Figure that is composed of several children. A AbstractCompositeFigure doesn't define any layout behavior. It is up to subclassers to arrange the contained children.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jhotdraw.draw.AbstractFigure
changingDepth, decorator, listenerList
 
Fields inherited from interface org.jhotdraw.draw.CompositeFigure
LAYOUT_INSETS
 
Constructor Summary
AbstractCompositeFigure()
          Creates a new instance.
 
Method Summary
 void 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<Figure> newFigures)
           
 void addNotify(Drawing drawing)
          Informs a figure, that it has been added to the specified 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(java.util.Collection<Figure> newFigures)
           
 boolean basicRemove(Figure figure)
          Removes the specified child without firing events.
 void basicRemoveAllChildren()
          Removes all children from the composite figure without firing events.
 Figure basicRemoveChild(int index)
          Removes the child at the specified index without firing events.
 void basicSetAttribute(AttributeKey name, java.lang.Object value)
          Sets an attribute of the figure without firing events.
 void basicSetBounds(java.awt.geom.Point2D.Double anchor, java.awt.geom.Point2D.Double lead)
          Sets the logical bounds of the figure and of its decorator figure.
 void basicTransform(java.awt.geom.AffineTransform tx)
          Transforms the figure.
 void changed()
          Informs that a figure changed the area of its display box.
 AbstractCompositeFigure clone()
          Returns a clone of the figure.
 boolean contains(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.
protected  void drawConnectors(java.awt.Graphics2D g)
           
 void drawFigure(java.awt.Graphics2D g)
           
 Figure findChild(java.awt.geom.Point2D.Double p)
           
 int findChildIndex(java.awt.geom.Point2D.Double p)
           
 Figure findFigureInside(java.awt.geom.Point2D.Double p)
          Returns the figure that contains the given point.
 java.lang.Object getAttribute(AttributeKey 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.awt.geom.Rectangle2D.Double getBounds()
          Returns the 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 getFigureDrawBounds()
           
 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 getRestoreData()
          Gets data which can be used to restore the shape of the figure after a basicTransform has been applied to it.
 boolean hasAttribute(AttributeKey key)
           
 void invalidate()
          Informs that a figure needs to be redrawn.
protected  void invalidateBounds()
           
 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 removeAllChildren()
          Removes all children.
 void removeAttribute(AttributeKey key)
           
 Figure removeChild(int index)
          Removes the child at the specified index.
 void removeNotify(Drawing drawing)
          Informs a figure, that it has been removed from the specified drawing.
 void restoreTo(java.lang.Object geometry)
          Restores the shape of the figure to a previously stored state.
 void sendToBack(Figure figure)
          Sends a figure to the back of the composite figure.
 void sendToFront(Figure figure)
          Sends a figure to the front of the drawing.
 void setAttribute(AttributeKey name, java.lang.Object value)
          Sets an attribute of the figure.
 void setLayouter(Layouter newLayouter)
          Set a Layouter object which encapsulated a layout algorithm for this figure.
 void undoableEditHappened(javax.swing.event.UndoableEditEvent e)
           
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.draw.AbstractFigure
addFigureListener, addUndoableEditListener, basicClone, canConnect, draw, drawDecorator, findCompatibleConnector, findConnector, fireAreaInvalidated, fireAreaInvalidated, fireAttributeChanged, fireFigureAdded, fireFigureChanged, fireFigureChanged, fireFigureChanged, fireFigureRemoved, fireFigureRequestRemove, fireUndoableEditHappened, getActions, getChangingDepth, getCourtingConnection, getCursor, getDecorator, getDrawBounds, getDrawing, getEndPoint, getFontRenderContext, getLayer, getLock, getStartPoint, getTool, getTooltip, handleDrop, handleMouseClick, includes, isChanging, isConnectorsVisible, isDrawDecoratorFirst, isInteractive, isVisible, remap, remap, removeFigureListener, removeUndoableEditListener, requestRemove, setBounds, setBounds, setConnectorsVisible, setDecorator, setDrawDecoratorFirst, setInteractive, setVisible, toString, transform, updateDecoratorBounds
 
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, addUndoableEditListener, canConnect, draw, findCompatibleConnector, findConnector, getActions, getCursor, getDecorator, getDrawBounds, getEndPoint, getLayer, getStartPoint, getTool, getTooltip, handleDrop, handleMouseClick, includes, isConnectorsVisible, isInteractive, isVisible, remap, removeFigureListener, removeUndoableEditListener, requestRemove, setConnectorsVisible, setDecorator, setVisible
 

Constructor Detail

AbstractCompositeFigure

public AbstractCompositeFigure()
Creates a new instance.

Method Detail

createHandles

public java.util.Collection<Handle> createHandles(int detailLevel)
Description copied from interface: Figure
Creates handles used to manipulate the figure.

Specified by:
createHandles in interface Figure
Overrides:
createHandles in class AbstractFigure
Parameters:
detailLevel - The detail level of the handles. Usually this is 0 for bounding box handles and 1 for point handles.
Returns:
a Collection of handles
See Also:
Handle

add

public void add(Figure figure)
Description copied from interface: CompositeFigure
Adds a child to the figure. This is a convenience method for add(getChildCount(), child);

Specified by:
add in interface CompositeFigure

add

public void add(int index,
                Figure figure)
Description copied from interface: CompositeFigure
Adds a child to the figure at the specified index.

Specified by:
add in interface CompositeFigure

addAll

public void addAll(java.util.Collection<Figure> newFigures)

basicAdd

public void basicAdd(Figure figure)
Description copied from interface: CompositeFigure
Adds a child to the figure without firing events. This is a convenience method for basicAdd(getChildCount(), child);

Specified by:
basicAdd in interface CompositeFigure

basicAdd

public void basicAdd(int index,
                     Figure figure)
Description copied from interface: CompositeFigure
Adds a child to the figure at the specified index without firing events.

Specified by:
basicAdd in interface CompositeFigure

basicAddAll

public void basicAddAll(java.util.Collection<Figure> newFigures)

addNotify

public void addNotify(Drawing drawing)
Description copied from interface: Figure
Informs a figure, that it has been added to the specified drawing. The figure must inform all FigureListeners that it has been added.

Specified by:
addNotify in interface Figure
Overrides:
addNotify in class AbstractFigure

removeNotify

public void removeNotify(Drawing drawing)
Description copied from interface: Figure
Informs a figure, that it has been removed from the specified drawing. The figure must inform all FigureListeners that it has been removed.

Specified by:
removeNotify in interface Figure
Overrides:
removeNotify in class AbstractFigure

remove

public boolean remove(Figure figure)
Description copied from interface: CompositeFigure
Removes the specified child. Returns true, if the Figure contained the removed child.

Specified by:
remove in interface CompositeFigure

removeChild

public Figure removeChild(int index)
Description copied from interface: CompositeFigure
Removes the child at the specified index. Returns the removed child figure.

Specified by:
removeChild in interface CompositeFigure

basicRemove

public boolean basicRemove(Figure figure)
Description copied from interface: CompositeFigure
Removes the specified child without firing events. Returns true, if the Figure contained the removed child.

Specified by:
basicRemove in interface CompositeFigure

basicRemoveChild

public Figure basicRemoveChild(int index)
Description copied from interface: CompositeFigure
Removes the child at the specified index without firing events. Returns the removed child figure.

Specified by:
basicRemoveChild in interface CompositeFigure

removeAllChildren

public void removeAllChildren()
Removes all children.

Specified by:
removeAllChildren in interface CompositeFigure
See Also:
add(org.jhotdraw.draw.Figure)

basicRemoveAllChildren

public void basicRemoveAllChildren()
Description copied from interface: CompositeFigure
Removes all children from the composite figure without firing events.

Specified by:
basicRemoveAllChildren in interface CompositeFigure

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

sendToFront

public void sendToFront(Figure figure)
Sends a figure to the front of the drawing.

Parameters:
figure - that is part of the drawing

basicTransform

public void basicTransform(java.awt.geom.AffineTransform tx)
Transforms the figure.

Specified by:
basicTransform in interface Figure
Specified by:
basicTransform in class AbstractFigure
Parameters:
tx - The transformation.

basicSetBounds

public void basicSetBounds(java.awt.geom.Point2D.Double anchor,
                           java.awt.geom.Point2D.Double lead)
Description copied from interface: Figure
Sets the logical bounds of the figure and of its decorator 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.

Specified by:
basicSetBounds in interface Figure
Parameters:
anchor - the start point of the bounds
lead - the end point of the bounds
See Also:
Figure.getBounds()

undoableEditHappened

public void undoableEditHappened(javax.swing.event.UndoableEditEvent e)

getChildren

public java.util.List<Figure> getChildren()
Description copied from interface: CompositeFigure
Returns an unchangeable list view on the children.

Specified by:
getChildren in interface CompositeFigure

getChildCount

public int getChildCount()
Description copied from interface: CompositeFigure
Returns the number of children.

Specified by:
getChildCount in interface CompositeFigure

getChild

public Figure getChild(int index)
Description copied from interface: CompositeFigure
Returns the child figure at the specified index.

Specified by:
getChild in interface CompositeFigure

getChildrenFrontToBack

public java.util.List<Figure> getChildrenFrontToBack()
Returns an iterator to iterate in Z-order front to back over the children.


setAttribute

public void setAttribute(AttributeKey name,
                         java.lang.Object value)
Description copied from interface: Figure
Sets an attribute of the figure. AttributeKey name and semantics are defined by the class implementing the Figure interface.

On an attribute change, the Figure fires FigureListener.figureAttributeChanged, UndoableEditListener.undoableEditHappened. If the shape is affected by an attribute change, FigureListener.figureChanged is fired too.

Specified by:
setAttribute in interface Figure

basicSetAttribute

public void basicSetAttribute(AttributeKey name,
                              java.lang.Object value)
Description copied from interface: Figure
Sets an attribute of the figure without firing events. AttributeKey name and semantics are defined by the class implementing the Figure interface.

Use AttributeKey.set() for typesafe access to this method.

Specified by:
basicSetAttribute in interface Figure
See Also:
AttributeKey.set(org.jhotdraw.draw.Figure, T)

getAttribute

public java.lang.Object getAttribute(AttributeKey name)
Description copied from interface: Figure
Gets an attribute from the Figure.

Use AttributeKey.get() for typesafe access to this method.

Specified by:
getAttribute in interface Figure
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)

contains

public boolean contains(java.awt.geom.Point2D.Double p)
Description copied from interface: Figure
Checks if a point is contained by the figure.

This is used for hit testing by Tool's.

Specified by:
contains in interface Figure

findFigureInside

public Figure findFigureInside(java.awt.geom.Point2D.Double p)
Description copied from interface: Figure
Returns the figure that contains the given point.

Specified by:
findFigureInside in interface Figure
Overrides:
findFigureInside in class AbstractFigure

findChild

public Figure findChild(java.awt.geom.Point2D.Double p)

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:
getLayouter in interface CompositeFigure
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:
layout in interface CompositeFigure

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:
setLayouter in interface CompositeFigure
Parameters:
newLayouter - encapsulation of a layout algorithm.

getPreferredSize

public Dimension2DDouble getPreferredSize()
Description copied from interface: Figure
The 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:
getPreferredSize in interface Figure
Overrides:
getPreferredSize in class AbstractFigure

getFigureDrawBounds

public java.awt.geom.Rectangle2D.Double getFigureDrawBounds()
Specified by:
getFigureDrawBounds in class AbstractFigure

getBounds

public java.awt.geom.Rectangle2D.Double getBounds()
Description copied from interface: Figure
Returns the logical bounds of the figure as a Rectangle. The logical bounds are used by some Handle objects for adjusting the figure.

Specified by:
getBounds in interface Figure

drawFigure

public void drawFigure(java.awt.Graphics2D g)
Specified by:
drawFigure in class AbstractFigure

drawConnectors

protected void drawConnectors(java.awt.Graphics2D g)

clone

public AbstractCompositeFigure clone()
Description copied from interface: Figure
Returns a clone of the figure.

Specified by:
clone in interface Figure
Overrides:
clone in class AbstractFigure

invalidateBounds

protected void invalidateBounds()

getDecomposition

public java.util.Collection<Figure> getDecomposition()
Description copied from interface: Figure
Returns a decompositon of a figure into its parts. A figure is considered as a part of itself.

Specified by:
getDecomposition in interface Figure
Overrides:
getDecomposition in class AbstractFigure

read

public void read(DOMInput in)
          throws java.io.IOException
Specified by:
read in interface DOMStorable
Throws:
java.io.IOException

write

public void write(DOMOutput out)
           throws java.io.IOException
Specified by:
write in interface DOMStorable
Throws:
java.io.IOException

getAttributes

public java.util.Map<AttributeKey,java.lang.Object> getAttributes()
Description copied from interface: Figure
Returns a view to all attributes of this figure. By convention, an unmodifiable map is returned.

Specified by:
getAttributes in interface Figure

restoreTo

public void restoreTo(java.lang.Object geometry)
Description copied from interface: Figure
Restores the shape of the figure to a previously stored state.

Specified by:
restoreTo in interface Figure

getRestoreData

public java.lang.Object getRestoreData()
Description copied from interface: Figure
Gets data which can be used to restore the shape of the figure after a basicTransform has been applied to it.

Specified by:
getRestoreData in interface Figure
See Also:
Figure.basicTransform(AffineTransform)

willChange

public void willChange()
Description copied from class: AbstractFigure
Informs that a figure is about to change something that affects the contents of its display box.

Specified by:
willChange in interface Figure
Overrides:
willChange in class AbstractFigure

changed

public void changed()
Description copied from class: AbstractFigure
Informs that a figure changed the area of its display box.

Specified by:
changed in interface Figure
Overrides:
changed in class AbstractFigure
See Also:
Figure.willChange()

invalidate

public void invalidate()
Description copied from class: AbstractFigure
Informs that a figure needs to be redrawn.

Specified by:
invalidate in interface Figure
Overrides:
invalidate in class AbstractFigure

validate

protected void validate()
Overrides:
validate in class AbstractFigure

removeAttribute

public void removeAttribute(AttributeKey key)

hasAttribute

public boolean hasAttribute(AttributeKey key)

Copyright 1996-2006 © JHotDraw.org