org.jhotdraw.draw
Class GraphicalCompositeFigure
- java.lang.Object
-
- org.jhotdraw.beans.AbstractBean
-
- org.jhotdraw.draw.AbstractFigure
-
- org.jhotdraw.draw.AbstractCompositeFigure
-
- 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 CompositeFigure 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 CompositeFigure. Therefore, the GraphicalCompositeFigure manages contained figures like a CompositeFigure 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 theCompositeFigureby containing a presentation figure by default which can not be removed. Normally, theCompositeFigurecan 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 theCompositeFigureits appearance. However, the GraphicalCompositeFigure's presentation figure can draw itself even when the GraphicalCompositeFigure contains no other figures. The GraphicalCompositeFigure also uses aLayouterto lay out its child figures.- 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 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
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddNotify(Drawing drawing)Informs a figure, that it has been added to a drawing.java.awt.geom.Point2D.Doublechop(java.awt.geom.Point2D.Double from)This is a default implementation that chops the point at the rectangle returned by getBounds() of the figure.GraphicalCompositeFigureclone()Returns a clone of the figure, with clones of all aggregated figures, such as children and decorators.booleancontains(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.voiddraw(java.awt.Graphics2D g)Draw the figure.<T> Tget(AttributeKey<T> key)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.DoublegetBounds()Return the logcal display area.java.awt.geom.Rectangle2D.DoublegetDrawingArea()Return the draw area.FiguregetPresentationFigure()Get a figure which renders this BasicCompositeFigure.voidread(DOMInput in)voidremap(java.util.HashMap<Figure,Figure> oldToNew, boolean disconnectIfNotInMap)voidremoveNotify(Drawing drawing)Informs a figure, that it has been removed from a drawing.<T> voidset(AttributeKey<T> key, T newValue)Sets an attribute of the figure.voidsetAttributeEnabled(AttributeKey key, boolean b)voidsetBounds(java.awt.geom.Point2D.Double anchor, java.awt.geom.Point2D.Double lead)Moves the figure.voidsetPresentationFigure(Figure newPresentationFigure)Set a figure which renders this BasicCompositeFigure.voidtransform(java.awt.geom.AffineTransform tx)Standard presentation method which is delegated to the encapsulated presentation figure.voidwrite(DOMOutput out)-
Methods inherited from class org.jhotdraw.draw.AbstractCompositeFigure
add, add, addAll, addAll, addCompositeFigureListener, basicAdd, basicAdd, basicAddAll, basicRemove, basicRemoveAll, basicRemoveAllChildren, basicRemoveChild, bringToFront, changed, contains, findChild, findChildIndex, findFigureInside, getAttributesRestoreData, getChild, getChildCount, getChildren, getChildrenFrontToBack, getDecomposition, getLayouter, getPreferredSize, getTransformRestoreData, indexOf, layout, remove, removeAll, removeAllChildren, removeChild, removeCompositeFigureListener, restoreAttributesTo, restoreTransformTo, sendToBack, setLayouter, willChange
-
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
-
-
-
-
Constructor Detail
-
GraphicalCompositeFigure
public GraphicalCompositeFigure()
Default constructor which uses nothing as presentation figure. This constructor is needed by the Storable mechanism.
-
-
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:
getBoundsin interfaceFigure- Overrides:
getBoundsin classAbstractCompositeFigure
-
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.
- Specified by:
containsin interfaceFigure- Overrides:
containsin classAbstractCompositeFigure
-
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 classAbstractCompositeFigure
-
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 classAbstractCompositeFigure
-
getDrawingArea
public java.awt.geom.Rectangle2D.Double getDrawingArea()
Return the draw area. This method is delegated to the encapsulated presentation figure.- Specified by:
getDrawingAreain interfaceFigure- Overrides:
getDrawingAreain classAbstractCompositeFigure
-
setBounds
public void setBounds(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:
setBoundsin interfaceFigure- Overrides:
setBoundsin classAbstractCompositeFigure- Parameters:
anchor- the start point of the boundslead- the end point of the bounds- See Also:
Figure.getBounds()
-
transform
public void transform(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:
transformin interfaceFigure- Overrides:
transformin classAbstractCompositeFigure- Parameters:
tx- The transformation.- See Also:
Figure.getTransformRestoreData(),Figure.restoreTransformTo(java.lang.Object)
-
draw
public void draw(java.awt.Graphics2D g)
Draw the figure. This method is delegated to the encapsulated presentation figure.- Specified by:
drawin interfaceFigure- Overrides:
drawin classAbstractCompositeFigure- Parameters:
g- The Graphics2D to draw to.
-
createHandles
public java.util.Collection<Handle> createHandles(int detailLevel)
Return default handles from the presentation figure.- Specified by:
createHandlesin interfaceFigure- Overrides:
createHandlesin classAbstractCompositeFigure- 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
-
setPresentationFigure
public void setPresentationFigure(@Nullable Figure newPresentationFigure)
Set a figure which renders this BasicCompositeFigure. The presentation tasks for the BasicCompositeFigure are delegated to this presentation figure.- Parameters:
newPresentationFigure- figure takes over the presentation tasks
-
getPresentationFigure
public Figure getPresentationFigure()
Get a figure which renders this BasicCompositeFigure. The presentation tasks for the BasicCompositeFigure are delegated to this presentation figure.- Returns:
- figure takes over the presentation tasks
-
clone
public GraphicalCompositeFigure 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 classAbstractCompositeFigure
-
set
public <T> void set(AttributeKey<T> key, T newValue)
Sets an attribute of the figure. AttributeKey name and semantics are defined by the class implementing the figure interface.- Specified by:
setin interfaceFigure- Overrides:
setin classAbstractCompositeFigure- See Also:
AttributeKey.set(org.jhotdraw.draw.Figure, T)
-
setAttributeEnabled
public void setAttributeEnabled(AttributeKey key, boolean b)
-
get
public <T> T get(AttributeKey<T> key)
Gets an attribute from the figure.- Specified by:
getin interfaceFigure- Overrides:
getin classAbstractCompositeFigure- 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)
-
read
public void read(DOMInput in) throws java.io.IOException
- Specified by:
readin interfaceDOMStorable- Overrides:
readin classAbstractCompositeFigure- Throws:
java.io.IOException
-
write
public void write(DOMOutput out) throws java.io.IOException
- Specified by:
writein interfaceDOMStorable- Overrides:
writein classAbstractCompositeFigure- Throws:
java.io.IOException
-
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- Overrides:
getAttributesin classAbstractCompositeFigure
-
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.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG