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_PROPERTY
path
changingDepth, listenerList
propertySupport
LAYOUT_INSETS
CONNECTABLE_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, writePoints
addNode, 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, splitSegment
applyAttributesTo, drawText, get, getAttributeKey, getAttributes, getAttributesRestoreData, getStroke, getStrokeMiterLimitFactor, hasAttribute, isAttributeEnabled, readAttributes, removeAttribute, restoreAttributesTo, setAttributeEnabled, setAttributes, writeAttributes
addFigureListener, 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, willChange
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addFigureListener, 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, willChange
getEndPoint, getNode, getNodeCount, getPoint, getStartPoint
public LabeledLineConnectionFigure()
public void draw(java.awt.Graphics2D g)
draw
in interface Figure
draw
in class AbstractAttributedFigure
g
- The Graphics2D to draw to.public void transform(java.awt.geom.AffineTransform tx)
transform
in interface Figure
transform
in class LineConnectionFigure
tx
- 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 Figure
getDrawingArea
in class BezierFigure
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 BezierFigure
public <T> void set(AttributeKey<T> key, T newValue)
set
in interface Figure
set
in class BezierFigure
AttributeKey.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 Figure
findFigureInside
in class AbstractFigure
p
- A location on the drawing.public void updateConnection()
ConnectionFigure
updateConnection
in interface ConnectionFigure
updateConnection
in class LineConnectionFigure
public java.util.List<Figure> getChildren()
CompositeFigure
getChildren
in interface CompositeFigure
public int getChildCount()
CompositeFigure
This is a convenience method for calling
getChildren().size();
.
getChildCount
in interface CompositeFigure
public Figure getChild(int index)
CompositeFigure
This is a convenience method for calling
getChildren().get(index);
.
getChild
in interface CompositeFigure
public 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
CompositeFigureListener
s.
add
in interface CompositeFigure
true
if this CompositeFigure changed as a result of the
callpublic void add(int index, Figure figure)
CompositeFigure
This method calls figureAdded
on all registered
CompositeFigureListener
s.
add
in interface CompositeFigure
public 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 CompositeFigure
public 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 CompositeFigure
public 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 CompositeFigure
public Figure removeChild(int index)
CompositeFigure
Calls figureRemoved
on all registered
CompositeFigureListener
's.
removeChild
in interface CompositeFigure
public int basicRemove(Figure figure)
CompositeFigure
This 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 CompositeFigure
public Figure basicRemoveChild(int index)
CompositeFigure
This 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 CompositeFigure
public void removeAllChildren()
CompositeFigure
This is a convenience method for
while(getChildCount() > 0) removeChild(0);
removeAllChildren
in interface CompositeFigure
public void basicRemoveAllChildren()
CompositeFigure
This 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 CompositeFigure
public Layouter getLayouter()
getLayouter
in interface CompositeFigure
public void setLayouter(Layouter newLayouter)
CompositeFigure
setLayouter
in interface CompositeFigure
newLayouter
- encapsulation of a layout algorithm.public void layout()
layout
in interface CompositeFigure
layout
in class BezierFigure
public void invalidate()
AbstractFigure
invalidate
in class BezierFigure
public void validate()
validate
in class LineConnectionFigure
public void addNotify(Drawing drawing)
LineConnectionFigure
addNotify
in interface Figure
addNotify
in class LineConnectionFigure
LineConnectionFigure.handleConnect(org.jhotdraw.draw.connector.Connector, org.jhotdraw.draw.connector.Connector)
public void removeNotify(Drawing drawing)
LineConnectionFigure
removeNotify
in interface Figure
removeNotify
in class LineConnectionFigure
LineConnectionFigure.handleDisconnect(org.jhotdraw.draw.connector.Connector, org.jhotdraw.draw.connector.Connector)
public void removeCompositeFigureListener(CompositeFigureListener listener)
CompositeFigure
removeCompositeFigureListener
in interface CompositeFigure
public void addCompositeFigureListener(CompositeFigureListener listener)
CompositeFigure
addCompositeFigureListener
in interface CompositeFigure
protected void fireFigureAdded(Figure f, int zIndex)
protected void fireFigureRemoved(Figure f, int zIndex)
public LabeledLineConnectionFigure clone()
Figure
clone
in interface Figure
clone
in class LineConnectionFigure
public void remap(java.util.Map<Figure,Figure> oldToNew, boolean disconnectIfNotInMap)
Figure
remap
in interface Figure
remap
in class LineConnectionFigure
public boolean contains(Figure f)
CompositeFigure
This is a convenience method for calling
getChildren().contains(f);
.
contains
in interface CompositeFigure
public int indexOf(Figure child)
CompositeFigure
This is a convenience method for calling
getChildren().indexOf(index);
.
indexOf
in interface CompositeFigure