public class LabeledLineConnectionFigure extends LineConnectionFigure implements CompositeFigure
Usage:
LineConnectionFigure lcf = new LineConnectionFigure();
lcf.setLayouter(new LocatorLayouter());
TextFigure label = new TextFigure();
label.setText("Hello");
LocatorLayouter.LAYOUT_LOCATOR.set(label, new BezierLabelLocator(0, -Math.PI / 4, 8));
lcf.add(label);
LINER_PROPERTYpathchangingDepth, listenerListpropertySupportLAYOUT_INSETSCONNECTABLE_PROPERTY, REMOVABLE_PROPERTY, SELECTABLE_PROPERTY, TRANSFORMABLE_PROPERTY| Constructor and Description |
|---|
LabeledLineConnectionFigure()
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
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 |
addCompositeFigureListener(CompositeFigureListener listener)
Adds a listener for this composite figure.
|
void |
addNotify(Drawing drawing)
This method is invoked, when the Figure is being removed from 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.
|
int |
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.
|
LabeledLineConnectionFigure |
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.
|
void |
draw(java.awt.Graphics2D g)
Draw the figure.
|
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.
|
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.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.
|
int |
indexOf(Figure child)
Returns the index of the specified child.
|
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 |
remap(java.util.Map<Figure,Figure> oldToNew,
boolean disconnectIfNotInMap)
After cloning a collection of figures, the ConnectionFigures contained
in this collection still connect to the original figures instead of
to the clones.
|
boolean |
remove(Figure figure)
Removes the specified child.
|
void |
removeAllChildren()
Removes all children from the composite figure.
|
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)
This method is invoked, when the Figure is being removed from a Drawing.
|
<T> void |
set(AttributeKey<T> key,
T newValue)
Sets an attribute 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.
|
void |
updateConnection()
Updates the start and end point of the figure and fires figureChanged
events.
|
void |
validate() |
canConnect, canConnect, createHandles, getBezierPath, getEndConnector, getEndFigure, getLiner, getStartConnector, getStartFigure, handleConnect, handleDisconnect, handleMouseClick, lineout, read, readLiner, readPoints, reverseConnection, setConnectable, setEndConnector, setEndPoint, setLiner, setNode, setPoint, setStartConnector, setStartPoint, write, writeLiner, writePointsaddNode, addNode, chop, drawCaps, drawFill, drawStroke, findCompatibleConnector, findConnector, findNode, findSegment, getBounds, getCappedPath, getCenter, getEndPoint, getNode, getNodeCount, getOutermostPoint, getPoint, getPoint, getPointOnPath, getStartPoint, getTransformRestoreData, isClosed, joinSegments, joinSegments, removeAllNodes, removeNode, restoreTransformTo, setBezierPath, setBounds, setClosed, setPoint, splitSegment, splitSegmentapplyAttributesTo, drawText, get, getAttributeKey, getAttributes, getAttributesRestoreData, getStroke, getStrokeMiterLimitFactor, hasAttribute, isAttributeEnabled, readAttributes, removeAttribute, restoreAttributesTo, setAttributeEnabled, setAttributes, writeAttributesaddFigureListener, changed, fireAreaInvalidated, fireAreaInvalidated, fireAreaInvalidated, fireAttributeChanged, fireFigureAdded, fireFigureChanged, fireFigureChanged, fireFigureChanged, fireFigureHandlesChanged, fireFigureRemoved, fireFigureRequestRemove, fireUndoableEditHappened, getActions, getChangingDepth, getConnectors, getCursor, getDecomposition, getDrawing, getFontRenderContext, getLayer, getLock, getPreferredSize, getTool, getToolTipText, handleDrop, includes, isChanging, isConnectable, isRemovable, isSelectable, isTransformable, isVisible, removeFigureListener, requestRemove, setBounds, setRemovable, setSelectable, setTransformable, setVisible, toString, willChangeaddPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListenerequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddFigureListener, addPropertyChangeListener, changed, createHandles, findCompatibleConnector, findConnector, get, getActions, getAttributes, getAttributesRestoreData, getBounds, getConnectors, getCursor, getDecomposition, getEndPoint, getLayer, getPreferredSize, getStartPoint, getTool, getToolTipText, getTransformRestoreData, handleDrop, handleMouseClick, includes, isConnectable, isRemovable, isSelectable, isTransformable, isVisible, removeFigureListener, removePropertyChangeListener, requestRemove, restoreAttributesTo, restoreTransformTo, setBounds, willChangegetEndPoint, getNode, getNodeCount, getPoint, getStartPointpublic LabeledLineConnectionFigure()
public void draw(java.awt.Graphics2D g)
draw in interface Figuredraw in class AbstractAttributedFigureg - The Graphics2D to draw to.public void transform(java.awt.geom.AffineTransform tx)
transform in interface Figuretransform in class LineConnectionFiguretx - The transformation.Figure.getTransformRestoreData(),
Figure.restoreTransformTo(java.lang.Object)public 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 FiguregetDrawingArea in class BezierFigurepublic boolean contains(java.awt.geom.Point2D.Double p)
FigureThis is used for hit testing by Tool's.
contains in interface Figurecontains in class BezierFigurepublic <T> void set(AttributeKey<T> key, T newValue)
set in interface Figureset in class BezierFigureAttributeKey.set(org.jhotdraw.draw.Figure, T)public 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 void updateConnection()
ConnectionFigureupdateConnection in interface ConnectionFigureupdateConnection in class LineConnectionFigurepublic java.util.List<Figure> getChildren()
CompositeFiguregetChildren 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 java.util.List<Figure> getChildrenFrontToBack()
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
callpublic void add(int index,
Figure figure)
CompositeFigure
This method calls figureAdded on all registered
CompositeFigureListeners.
add in interface CompositeFigurepublic 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 CompositeFigurepublic 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 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 int basicRemove(Figure figure)
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 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 void removeAllChildren()
CompositeFigure
This is a convenience method for
while(getChildCount() > 0) removeChild(0);
removeAllChildren in interface CompositeFigurepublic void basicRemoveAllChildren()
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
while(getChildCount() > 0) basicRemoveChild(0);
basicRemoveAllChildren in interface CompositeFigurepublic Layouter getLayouter()
getLayouter in interface CompositeFigurepublic void setLayouter(Layouter newLayouter)
CompositeFiguresetLayouter in interface CompositeFigurenewLayouter - encapsulation of a layout algorithm.public void layout()
layout in interface CompositeFigurelayout in class BezierFigurepublic void invalidate()
AbstractFigureinvalidate in class BezierFigurepublic void validate()
validate in class LineConnectionFigurepublic void addNotify(Drawing drawing)
LineConnectionFigureaddNotify in interface FigureaddNotify in class LineConnectionFigureLineConnectionFigure.handleConnect(org.jhotdraw.draw.connector.Connector, org.jhotdraw.draw.connector.Connector)public void removeNotify(Drawing drawing)
LineConnectionFigureremoveNotify in interface FigureremoveNotify in class LineConnectionFigureLineConnectionFigure.handleDisconnect(org.jhotdraw.draw.connector.Connector, org.jhotdraw.draw.connector.Connector)public void removeCompositeFigureListener(CompositeFigureListener listener)
CompositeFigureremoveCompositeFigureListener in interface CompositeFigurepublic void addCompositeFigureListener(CompositeFigureListener listener)
CompositeFigureaddCompositeFigureListener in interface CompositeFigureprotected void fireFigureAdded(Figure f, int zIndex)
protected void fireFigureRemoved(Figure f, int zIndex)
public LabeledLineConnectionFigure clone()
Figureclone in interface Figureclone in class LineConnectionFigurepublic void remap(java.util.Map<Figure,Figure> oldToNew, boolean disconnectIfNotInMap)
Figureremap in interface Figureremap in class LineConnectionFigurepublic boolean contains(Figure f)
CompositeFigure
This is a convenience method for calling
getChildren().contains(f);.
contains in interface CompositeFigurepublic int indexOf(Figure child)
CompositeFigure
This is a convenience method for calling
getChildren().indexOf(index);.
indexOf in interface CompositeFigure