JHotDraw 7.0.6

org.jhotdraw.draw
Class GraphicalCompositeFigure

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

public class GraphicalCompositeFigure
extends AbstractCompositeFigure

The GraphicalCompositeFigure fills in the gap between a AbstractCompositeFigure and other figures which mainly have a presentation purpose. The GraphicalCompositeFigure can be configured with any Figure which takes over the task for rendering the graphical presentation for a AbstractCompositeFigure. Therefore, the GraphicalCompositeFigure manages contained figures like the AbstractCompositeFigure does, but delegates its graphical presentation to another (graphical) figure which purpose it is to draw the container for all contained figures. The GraphicalCompositeFigure adds to the AbstractCompositeFigure by containing a presentation figure by default which can not be removed. Normally, the AbstractCompositeFigure can not be seen without containing a figure because it has no mechanism to draw itself. It instead relies on its contained figures to draw themselves thereby giving the AbstractCompositeFigure its appearance. However, the GraphicalCompositeFigure's presentation figure can draw itself even when the GraphicalCompositeFigure contains no other figures. The GraphicalCompositeFigure also uses a Layouter or layout its contained figures.

See Also:
Serialized Form

Field Summary
protected  java.util.HashMap<AttributeKey,java.lang.Object> attributes
           
 
Fields inherited from class org.jhotdraw.draw.AbstractFigure
changingDepth, decorator, listenerList
 
Fields inherited from interface org.jhotdraw.draw.CompositeFigure
LAYOUT_INSETS
 
Constructor Summary
GraphicalCompositeFigure()
          Default constructor which uses nothing as presentation figure.
GraphicalCompositeFigure(Figure newPresentationFigure)
          Constructor which creates a GraphicalCompositeFigure with a given graphical figure for presenting it.
 
Method Summary
 void addNotify(Drawing drawing)
          Informs a figure, that it has been added to the specified drawing.
protected  void applyAttributesTo(Figure that)
          Applies all attributes of this figure to that figure.
 void basicSetAttribute(AttributeKey key, java.lang.Object newValue)
          Sets an attribute of the figure.
 void basicSetBounds(java.awt.geom.Point2D.Double anchor, java.awt.geom.Point2D.Double lead)
          Moves the figure.
protected  void basicSetPresentationFigureBounds(java.awt.geom.Point2D.Double anchor, java.awt.geom.Point2D.Double lead)
           
 void basicTransform(java.awt.geom.AffineTransform tx)
          Standard presentation method which is delegated to the encapsulated presentation figure.
 java.awt.geom.Point2D.Double chop(java.awt.geom.Point2D.Double from)
          This is a default implementation that chops the point at the rectangle returned by getBounds() of the figure.
 GraphicalCompositeFigure 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)
          Return default handles from the presentation figure.
 void drawFigure(java.awt.Graphics2D g)
          Draw the figure.
protected  void drawPresentationFigure(java.awt.Graphics2D g)
           
 java.lang.Object getAttribute(AttributeKey key)
          Gets an attribute from the figure.
protected  AttributeKey getAttributeKey(java.lang.String name)
           
 java.util.Map<AttributeKey,java.lang.Object> getAttributes()
          Returns a view to all attributes of this figure.
 java.awt.geom.Rectangle2D.Double getBounds()
          Return the logcal display area.
 java.awt.geom.Rectangle2D.Double getFigureDrawBounds()
          Return the draw area.
 Figure getPresentationFigure()
          Get a figure which renders this AbstractCompositeFigure.
protected  void readAttributes(DOMInput in)
           
 void remap(java.util.HashMap<Figure,Figure> oldToNew)
           
 void removeNotify(Drawing drawing)
          Informs a figure, that it has been removed from the specified drawing.
 void setAttribute(AttributeKey key, java.lang.Object newValue)
          Sets an attribute of the figure.
 void setAttributeEnabled(AttributeKey key, boolean b)
           
 void setPresentationFigure(Figure newPresentationFigure)
          Set a figure which renders this AbstractCompositeFigure.
protected  void superBasicSetBounds(java.awt.geom.Point2D.Double anchor, java.awt.geom.Point2D.Double lead)
           
protected  void writeAttributes(DOMOutput out)
           
 
Methods inherited from class org.jhotdraw.draw.AbstractCompositeFigure
add, add, addAll, basicAdd, basicAdd, basicAddAll, basicRemove, basicRemoveAllChildren, basicRemoveChild, changed, drawConnectors, findChild, findChildIndex, findFigureInside, getChild, getChildCount, getChildren, getChildrenFrontToBack, getDecomposition, getLayouter, getPreferredSize, getRestoreData, hasAttribute, invalidate, invalidateBounds, layout, read, remove, removeAllChildren, removeAttribute, removeChild, restoreTo, sendToBack, sendToFront, setLayouter, undoableEditHappened, validate, willChange, write
 
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, 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
 

Field Detail

attributes

protected java.util.HashMap<AttributeKey,java.lang.Object> attributes
Constructor Detail

GraphicalCompositeFigure

public GraphicalCompositeFigure()
Default constructor which uses nothing as presentation figure. This constructor is needed by the Storable mechanism.


GraphicalCompositeFigure

public GraphicalCompositeFigure(Figure newPresentationFigure)
Constructor which creates a GraphicalCompositeFigure with a given graphical figure for presenting it.

Parameters:
newPresentationFigure - figure which renders the container
Method Detail

getBounds

public java.awt.geom.Rectangle2D.Double getBounds()
Return the logcal display area. This method is delegated to the encapsulated presentation figure.

Specified by:
getBounds in interface Figure
Overrides:
getBounds in class AbstractCompositeFigure

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
Overrides:
contains in class AbstractCompositeFigure

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 AbstractCompositeFigure

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 AbstractCompositeFigure

getFigureDrawBounds

public java.awt.geom.Rectangle2D.Double getFigureDrawBounds()
Return the draw area. This method is delegated to the encapsulated presentation figure.

Overrides:
getFigureDrawBounds in class AbstractCompositeFigure

basicSetBounds

public void basicSetBounds(java.awt.geom.Point2D.Double anchor,
                           java.awt.geom.Point2D.Double lead)
Moves the figure. This is the method that subclassers override. Clients usually call displayBox.

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

superBasicSetBounds

protected void superBasicSetBounds(java.awt.geom.Point2D.Double anchor,
                                   java.awt.geom.Point2D.Double lead)

basicSetPresentationFigureBounds

protected void basicSetPresentationFigureBounds(java.awt.geom.Point2D.Double anchor,
                                                java.awt.geom.Point2D.Double lead)

basicTransform

public void basicTransform(java.awt.geom.AffineTransform tx)
Standard presentation method which is delegated to the encapsulated presentation figure. The presentation figure is moved as well as all contained figures.

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

drawFigure

public void drawFigure(java.awt.Graphics2D g)
Draw the figure. This method is delegated to the encapsulated presentation figure.

Overrides:
drawFigure in class AbstractCompositeFigure

drawPresentationFigure

protected void drawPresentationFigure(java.awt.Graphics2D g)

createHandles

public java.util.Collection<Handle> createHandles(int detailLevel)
Return default handles from the presentation figure.

Specified by:
createHandles in interface Figure
Overrides:
createHandles in class AbstractCompositeFigure
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

setPresentationFigure

public void setPresentationFigure(Figure newPresentationFigure)
Set a figure which renders this AbstractCompositeFigure. The presentation tasks for the AbstractCompositeFigure are delegated to this presentation figure.

Parameters:
newPresentationFigure - figure takes over the presentation tasks

getPresentationFigure

public Figure getPresentationFigure()
Get a figure which renders this AbstractCompositeFigure. The presentation tasks for the AbstractCompositeFigure are delegated to this presentation figure.

Returns:
figure takes over the presentation tasks

clone

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

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

remap

public void remap(java.util.HashMap<Figure,Figure> oldToNew)
Overrides:
remap in class AbstractFigure

setAttribute

public void setAttribute(AttributeKey key,
                         java.lang.Object newValue)
Sets an attribute of the figure. AttributeKey name and semantics are defined by the class implementing the figure interface.

Specified by:
setAttribute in interface Figure
Overrides:
setAttribute in class AbstractCompositeFigure

basicSetAttribute

public void basicSetAttribute(AttributeKey key,
                              java.lang.Object newValue)
Sets an attribute of the figure. AttributeKey name and semantics are defined by the class implementing the figure interface.

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

setAttributeEnabled

public void setAttributeEnabled(AttributeKey key,
                                boolean b)

getAttribute

public java.lang.Object getAttribute(AttributeKey key)
Gets an attribute from the figure.

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

applyAttributesTo

protected void applyAttributesTo(Figure that)
Applies all attributes of this figure to that figure.


writeAttributes

protected void writeAttributes(DOMOutput out)
                        throws java.io.IOException
Throws:
java.io.IOException

readAttributes

protected void readAttributes(DOMInput in)
                       throws java.io.IOException
Throws:
java.io.IOException

getAttributeKey

protected AttributeKey getAttributeKey(java.lang.String name)

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
Overrides:
getAttributes in class AbstractCompositeFigure

chop

public java.awt.geom.Point2D.Double chop(java.awt.geom.Point2D.Double from)
This is a default implementation that chops the point at the rectangle returned by getBounds() of the figure.

Figures which have a non-rectangular shape need to override this method.

This method takes the following attributes into account: AttributeKeys.STROKE_COLOR, AttributeKeys.STROKE_PLACEMENT, and AttributeKeys.StrokeTotalWidth.


Copyright 1996-2006 © JHotDraw.org