public class GraphicalCompositeFigure extends AbstractCompositeFigure
CompositeFigure
by containing a presentation figure by default which can not be removed. Normally,
the CompositeFigure
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 CompositeFigure
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
to lay out its child figures.AbstractCompositeFigure.EventHandler
Modifier and Type | Field and Description |
---|---|
protected java.util.HashMap<AttributeKey,java.lang.Object> |
attributes |
cachedBounds, cachedDrawingArea, children, eventHandler, layouter
changingDepth, listenerList
propertySupport
LAYOUT_INSETS
CONNECTABLE_PROPERTY, REMOVABLE_PROPERTY, SELECTABLE_PROPERTY, TRANSFORMABLE_PROPERTY
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.
|
Modifier and Type | Method and Description |
---|---|
void |
addNotify(Drawing drawing)
Informs a figure, that it has been added to a drawing.
|
protected void |
applyAttributesTo(Figure that)
Applies all attributes of this figure to that figure.
|
protected void |
basicSetPresentationFigureBounds(java.awt.geom.Point2D.Double anchor,
java.awt.geom.Point2D.Double lead) |
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, with clones of all aggregated figures,
such as children and decorators.
|
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 |
draw(java.awt.Graphics2D g)
Draw the figure.
|
protected void |
drawPresentationFigure(java.awt.Graphics2D g) |
<T> T |
get(AttributeKey<T> 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 |
getDrawingArea()
Return the draw area.
|
Figure |
getPresentationFigure()
Get a figure which renders this BasicCompositeFigure.
|
void |
read(DOMInput in) |
protected void |
readAttributes(DOMInput in) |
void |
remap(java.util.HashMap<Figure,Figure> oldToNew,
boolean disconnectIfNotInMap) |
void |
removeNotify(Drawing drawing)
Informs a figure, that it has been removed from a drawing.
|
<T> void |
set(AttributeKey<T> key,
T newValue)
Sets an attribute of the figure.
|
void |
setAttributeEnabled(AttributeKey key,
boolean b) |
void |
setBounds(java.awt.geom.Point2D.Double anchor,
java.awt.geom.Point2D.Double lead)
Moves the figure.
|
void |
setPresentationFigure(Figure newPresentationFigure)
Set a figure which renders this BasicCompositeFigure.
|
protected void |
superBasicSetBounds(java.awt.geom.Point2D.Double anchor,
java.awt.geom.Point2D.Double lead) |
void |
transform(java.awt.geom.AffineTransform tx)
Standard presentation method which is delegated to the encapsulated presentation figure.
|
void |
write(DOMOutput out) |
protected void |
writeAttributes(DOMOutput out) |
add, add, addAll, addAll, addCompositeFigureListener, basicAdd, basicAdd, basicAddAll, basicRemove, basicRemoveAll, basicRemoveAllChildren, basicRemoveChild, bringToFront, changed, contains, createEventHandler, findChild, findChildIndex, findFigureInside, fireFigureAdded, fireFigureRemoved, getAttributesRestoreData, getChild, getChildCount, getChildren, getChildrenFrontToBack, getDecomposition, getLayouter, getPreferredSize, getTransformRestoreData, indexOf, invalidate, layout, remove, removeAll, removeAllChildren, removeChild, removeCompositeFigureListener, restoreAttributesTo, restoreTransformTo, sendToBack, setLayouter, validate, willChange
addFigureListener, findCompatibleConnector, findConnector, fireAreaInvalidated, fireAreaInvalidated, fireAreaInvalidated, fireAttributeChanged, fireFigureAdded, fireFigureChanged, fireFigureChanged, fireFigureChanged, fireFigureHandlesChanged, fireFigureRemoved, fireFigureRequestRemove, fireUndoableEditHappened, getActions, getChangingDepth, getConnectors, getCursor, getDrawing, getEndPoint, getFontRenderContext, getLayer, getLock, getStartPoint, getTool, getToolTipText, handleDrop, handleMouseClick, includes, isChanging, isConnectable, isRemovable, isSelectable, isTransformable, isVisible, remap, removeFigureListener, requestRemove, setBounds, setConnectable, setRemovable, setSelectable, setTransformable, setVisible, toString
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addFigureListener, addPropertyChangeListener, findCompatibleConnector, findConnector, getActions, getConnectors, getCursor, getEndPoint, getLayer, getStartPoint, getTool, getToolTipText, handleDrop, handleMouseClick, includes, isConnectable, isRemovable, isSelectable, isTransformable, isVisible, remap, removeFigureListener, removePropertyChangeListener, requestRemove
protected java.util.HashMap<AttributeKey,java.lang.Object> attributes
public GraphicalCompositeFigure()
public GraphicalCompositeFigure(Figure newPresentationFigure)
newPresentationFigure
- figure which renders the containerpublic java.awt.geom.Rectangle2D.Double getBounds()
getBounds
in interface Figure
getBounds
in class AbstractCompositeFigure
public boolean contains(java.awt.geom.Point2D.Double p)
Figure
This is used for hit testing by Tool's.
contains
in interface Figure
contains
in class AbstractCompositeFigure
public void addNotify(Drawing drawing)
Figure
addNotify
in interface Figure
addNotify
in class AbstractCompositeFigure
public void removeNotify(Drawing drawing)
Figure
removeNotify
in interface Figure
removeNotify
in class AbstractCompositeFigure
public java.awt.geom.Rectangle2D.Double getDrawingArea()
getDrawingArea
in interface Figure
getDrawingArea
in class AbstractCompositeFigure
public void setBounds(java.awt.geom.Point2D.Double anchor, java.awt.geom.Point2D.Double lead)
setBounds
in interface Figure
setBounds
in class AbstractCompositeFigure
anchor
- the start point of the boundslead
- the end point of the boundsFigure.getBounds()
protected void superBasicSetBounds(java.awt.geom.Point2D.Double anchor, java.awt.geom.Point2D.Double lead)
protected void basicSetPresentationFigureBounds(java.awt.geom.Point2D.Double anchor, java.awt.geom.Point2D.Double lead)
public void transform(java.awt.geom.AffineTransform tx)
transform
in interface Figure
transform
in class AbstractCompositeFigure
tx
- The transformation.Figure.getTransformRestoreData()
,
Figure.restoreTransformTo(java.lang.Object)
public void draw(java.awt.Graphics2D g)
draw
in interface Figure
draw
in class AbstractCompositeFigure
g
- The Graphics2D to draw to.protected void drawPresentationFigure(java.awt.Graphics2D g)
public java.util.Collection<Handle> createHandles(int detailLevel)
createHandles
in interface Figure
createHandles
in class AbstractCompositeFigure
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.Handle
public void setPresentationFigure(Figure newPresentationFigure)
newPresentationFigure
- figure takes over the presentation taskspublic Figure getPresentationFigure()
public GraphicalCompositeFigure clone()
Figure
clone
in interface Figure
clone
in class AbstractCompositeFigure
public <T> void set(AttributeKey<T> key, T newValue)
set
in interface Figure
set
in class AbstractCompositeFigure
AttributeKey.set(org.jhotdraw.draw.Figure, T)
public void setAttributeEnabled(AttributeKey key, boolean b)
public <T> T get(AttributeKey<T> key)
get
in interface Figure
get
in class AbstractCompositeFigure
AttributeKey.get(org.jhotdraw.draw.Figure)
protected void applyAttributesTo(Figure that)
protected void writeAttributes(DOMOutput out) throws java.io.IOException
java.io.IOException
protected void readAttributes(DOMInput in) throws java.io.IOException
java.io.IOException
public void read(DOMInput in) throws java.io.IOException
read
in interface DOMStorable
read
in class AbstractCompositeFigure
java.io.IOException
public void write(DOMOutput out) throws java.io.IOException
write
in interface DOMStorable
write
in class AbstractCompositeFigure
java.io.IOException
protected AttributeKey getAttributeKey(java.lang.String name)
public java.util.Map<AttributeKey,java.lang.Object> getAttributes()
Figure
getAttributes
in interface Figure
getAttributes
in class AbstractCompositeFigure
public java.awt.geom.Point2D.Double chop(java.awt.geom.Point2D.Double from)
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.