Class LabeledLineConnectionFigure
- java.lang.Object
-
- org.jhotdraw.beans.AbstractBean
-
- org.jhotdraw.draw.AbstractFigure
-
- org.jhotdraw.draw.AbstractAttributedFigure
-
- org.jhotdraw.draw.BezierFigure
-
- org.jhotdraw.draw.LineFigure
-
- org.jhotdraw.draw.LineConnectionFigure
-
- org.jhotdraw.draw.LabeledLineConnectionFigure
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, CompositeFigure, ConnectionFigure, Figure, DOMStorable
public class LabeledLineConnectionFigure extends LineConnectionFigure implements CompositeFigure
A LineConnection with labels.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);- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.jhotdraw.draw.LineConnectionFigure
LINER_PROPERTY
-
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 LabeledLineConnectionFigure()Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleanadd(Figure figure)Adds a child to the figure.voidadd(int index, Figure figure)Adds a child to the figure at the specified index.voidaddCompositeFigureListener(CompositeFigureListener listener)Adds a listener for this composite figure.voidaddNotify(Drawing drawing)This method is invoked, when the Figure is being removed from a Drawing.voidbasicAdd(Figure figure)Adds a child to the figure without firing events.voidbasicAdd(int index, Figure figure)Adds a child to the figure at the specified index without firing events.intbasicRemove(Figure figure)Removes the specified child without firing events.voidbasicRemoveAllChildren()Removes all children from the composite figure without firing events.FigurebasicRemoveChild(int index)Removes the child at the specified index without firing events.LabeledLineConnectionFigureclone()Returns a clone of the figure, with clones of all aggregated figures, such as children and decorators.booleancontains(Figure f)Returns true if this composite figure contains the specified figure.booleancontains(java.awt.geom.Point2D.Double p)Checks if a point is contained by the figure.voiddraw(java.awt.Graphics2D g)Draw the figure.FigurefindFigureInside(java.awt.geom.Point2D.Double p)Finds the innermost figure at the specified location.FiguregetChild(int index)Returns the child figure at the specified index.intgetChildCount()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.DoublegetDrawingArea()Returns the drawing area of the figure as a Rectangle.LayoutergetLayouter()Get a Layouter object which encapsulated a layout algorithm for this figure.intindexOf(Figure child)Returns the index of the specified child.voidinvalidate()Invalidates cached data of the Figure.voidlayout()A layout algorithm is used to define how the child components should be laid out in relation to each other.voidremap(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.booleanremove(Figure figure)Removes the specified child.voidremoveAllChildren()Removes all children from the composite figure.FigureremoveChild(int index)Removes the child at the specified index.voidremoveCompositeFigureListener(CompositeFigureListener listener)Removes a listener from this composite figure.voidremoveNotify(Drawing drawing)This method is invoked, when the Figure is being removed from a Drawing.<T> voidset(AttributeKey<T> key, T newValue)Sets an attribute of the figure.voidsetLayouter(Layouter newLayouter)Set a Layouter object which encapsulated a layout algorithm for this figure.voidtransform(java.awt.geom.AffineTransform tx)Transforms the figure.voidupdateConnection()Updates the start and end point of the figure and fires figureChanged events.voidvalidate()-
Methods inherited from class org.jhotdraw.draw.LineConnectionFigure
canConnect, canConnect, createHandles, getBezierPath, getEndConnector, getEndFigure, getLiner, getStartConnector, getStartFigure, handleMouseClick, lineout, read, reverseConnection, setConnectable, setEndConnector, setEndPoint, setLiner, setNode, setPoint, setStartConnector, setStartPoint, write
-
Methods inherited from class org.jhotdraw.draw.BezierFigure
addNode, addNode, chop, findCompatibleConnector, findConnector, findNode, findSegment, getBounds, getCenter, getEndPoint, getNode, getNodeCount, getOutermostPoint, getPoint, getPoint, getPointOnPath, getStartPoint, getTransformRestoreData, isClosed, joinSegments, joinSegments, removeNode, restoreTransformTo, setBezierPath, setBounds, setClosed, setPoint, splitSegment, splitSegment
-
Methods inherited from class org.jhotdraw.draw.AbstractAttributedFigure
get, getAttributes, getAttributesRestoreData, getStroke, getStrokeMiterLimitFactor, hasAttribute, isAttributeEnabled, removeAttribute, restoreAttributesTo, setAttributeEnabled, setAttributes
-
Methods inherited from class org.jhotdraw.draw.AbstractFigure
addFigureListener, changed, fireAreaInvalidated, fireFigureChanged, getActions, getConnectors, getCursor, getDecomposition, getLayer, getPreferredSize, getTool, getToolTipText, handleDrop, includes, isConnectable, isRemovable, isSelectable, isTransformable, isVisible, removeFigureListener, requestRemove, setBounds, setRemovable, setSelectable, setTransformable, setVisible, toString, willChange
-
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, 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
-
Methods inherited from interface org.jhotdraw.draw.ConnectionFigure
getEndPoint, getNode, getNodeCount, getPoint, getStartPoint
-
-
-
-
Constructor Detail
-
LabeledLineConnectionFigure
public LabeledLineConnectionFigure()
Creates a new instance.
-
-
Method Detail
-
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 classAbstractAttributedFigure- Parameters:
g- The Graphics2D to draw to.
-
transform
public void transform(java.awt.geom.AffineTransform tx)
Transforms the figure.- Specified by:
transformin interfaceFigure- Overrides:
transformin classLineConnectionFigure- Parameters:
tx- The transformation.- See Also:
Figure.getTransformRestoreData(),Figure.restoreTransformTo(java.lang.Object)
-
getDrawingArea
public java.awt.geom.Rectangle2D.Double getDrawingArea()
Description copied from interface:FigureReturns the drawing area of the figure as a Rectangle.The drawing area is used to inform
DrawingViewabout 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.
- Specified by:
getDrawingAreain interfaceFigure- Overrides:
getDrawingAreain classBezierFigure
-
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 classBezierFigure
-
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 classBezierFigure- See Also:
AttributeKey.set(org.jhotdraw.draw.Figure, T)
-
findFigureInside
public Figure findFigureInside(java.awt.geom.Point2D.Double p)
Description copied from interface:FigureFinds the innermost figure at the specified location.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.
- Specified by:
findFigureInsidein interfaceFigure- Overrides:
findFigureInsidein classAbstractFigure- Parameters:
p- A location on the drawing.- Returns:
- Returns the innermost figure at the location, or null if the location is not contained in a figure.
-
updateConnection
public void updateConnection()
Description copied from interface:ConnectionFigureUpdates the start and end point of the figure and fires figureChanged events.- Specified by:
updateConnectionin interfaceConnectionFigure- Overrides:
updateConnectionin classLineConnectionFigure
-
getChildren
public java.util.List<Figure> getChildren()
Description copied from interface:CompositeFigureReturns an unchangeable list view on the children.- Specified by:
getChildrenin interfaceCompositeFigure
-
getChildCount
public int getChildCount()
Description copied from interface:CompositeFigureReturns the number of children.This is a convenience method for calling
getChildren().size();.- Specified by:
getChildCountin interfaceCompositeFigure
-
getChild
public Figure getChild(int index)
Description copied from interface:CompositeFigureReturns the child figure at the specified index.This is a convenience method for calling
getChildren().get(index);.- Specified by:
getChildin interfaceCompositeFigure
-
getChildrenFrontToBack
public java.util.List<Figure> getChildrenFrontToBack()
Returns an iterator to iterate in Z-order front to back over the children.
-
add
public boolean add(Figure figure)
Description copied from interface:CompositeFigureAdds a child to the figure.This is a convenience method for
add(getChildCount(), child);This method calls
figureAddedon all registeredCompositeFigureListeners.- Specified by:
addin interfaceCompositeFigure- Returns:
trueif this CompositeFigure changed as a result of the call
-
add
public void add(int index, Figure figure)Description copied from interface:CompositeFigureAdds a child to the figure at the specified index.This method calls
figureAddedon all registeredCompositeFigureListeners.- Specified by:
addin interfaceCompositeFigure
-
basicAdd
public void basicAdd(Figure figure)
Description copied from interface:CompositeFigureAdds a child to the figure without firing events.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 callingbasicAdd(getChildCount(), child);.- Specified by:
basicAddin interfaceCompositeFigure
-
basicAdd
public void basicAdd(int index, Figure figure)Description copied from interface:CompositeFigureAdds a child to the figure at the specified index without firing events.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.- Specified by:
basicAddin interfaceCompositeFigure
-
remove
public boolean remove(Figure figure)
Description copied from interface:CompositeFigureRemoves the specified child. Returns true, if the Figure contained the removed child.This is a convenience method for calling
removeChild(getChildren().indexOf(child));This method calls
figureRemovedon all registeredCompositeFigureListener's.- Specified by:
removein interfaceCompositeFigure
-
removeChild
public Figure removeChild(int index)
Description copied from interface:CompositeFigureRemoves the child at the specified index. Returns the removed child figure.Calls
figureRemovedon all registeredCompositeFigureListener's.- Specified by:
removeChildin interfaceCompositeFigure
-
basicRemove
public int basicRemove(Figure figure)
Description copied from interface:CompositeFigureRemoves the specified child without firing events.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.
- Specified by:
basicRemovein interfaceCompositeFigure
-
basicRemoveChild
public Figure basicRemoveChild(int index)
Description copied from interface:CompositeFigureRemoves the child at the specified index without firing events.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.
- Specified by:
basicRemoveChildin interfaceCompositeFigure
-
removeAllChildren
public void removeAllChildren()
Description copied from interface:CompositeFigureRemoves all children from the composite figure.This is a convenience method for
while(getChildCount() > 0) removeChild(0);- Specified by:
removeAllChildrenin interfaceCompositeFigure
-
basicRemoveAllChildren
public void basicRemoveAllChildren()
Description copied from interface:CompositeFigureRemoves all children from the composite figure without firing events.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);- Specified by:
basicRemoveAllChildrenin interfaceCompositeFigure
-
getLayouter
public Layouter getLayouter()
Get a Layouter object which encapsulated a layout algorithm for this figure. Typically, a Layouter accesses the child components of this figure and arranges their graphical presentation.- Specified by:
getLayouterin interfaceCompositeFigure- Returns:
- layout strategy used by this figure
-
setLayouter
public void setLayouter(Layouter newLayouter)
Description copied from interface:CompositeFigureSet a Layouter object which encapsulated a layout algorithm for this figure. Typically, a Layouter accesses the child components of this figure and arranges their graphical presentation. It is a good idea to put the Layouter in the protected initialize() method so it can be recreated if a GraphicalCompositeFigure is read and restored from a StorableInput stream.- Specified by:
setLayouterin interfaceCompositeFigure- Parameters:
newLayouter- encapsulation of a layout algorithm.
-
layout
public void layout()
A layout algorithm is used to define how the child components should be laid out in relation to each other. The task for layouting the child components for presentation is delegated to a Layouter which can be plugged in at runtime.- Specified by:
layoutin interfaceCompositeFigure- Overrides:
layoutin classBezierFigure
-
invalidate
public void invalidate()
Description copied from class:AbstractFigureInvalidates cached data of the Figure. This method must execute fast, because it can be called very often.- Overrides:
invalidatein classBezierFigure
-
validate
public void validate()
- Overrides:
validatein classLineConnectionFigure
-
addNotify
public void addNotify(Drawing drawing)
Description copied from class:LineConnectionFigureThis method is invoked, when the Figure is being removed from a Drawing. This method invokes handleConnect, if the Figure is connected.- Specified by:
addNotifyin interfaceFigure- Overrides:
addNotifyin classLineConnectionFigure- See Also:
LineConnectionFigure.handleConnect(org.jhotdraw.draw.connector.Connector, org.jhotdraw.draw.connector.Connector)
-
removeNotify
public void removeNotify(Drawing drawing)
Description copied from class:LineConnectionFigureThis method is invoked, when the Figure is being removed from a Drawing. This method invokes handleDisconnect, if the Figure is connected.- Specified by:
removeNotifyin interfaceFigure- Overrides:
removeNotifyin classLineConnectionFigure- See Also:
LineConnectionFigure.handleDisconnect(org.jhotdraw.draw.connector.Connector, org.jhotdraw.draw.connector.Connector)
-
removeCompositeFigureListener
public void removeCompositeFigureListener(CompositeFigureListener listener)
Description copied from interface:CompositeFigureRemoves a listener from this composite figure.- Specified by:
removeCompositeFigureListenerin interfaceCompositeFigure
-
addCompositeFigureListener
public void addCompositeFigureListener(CompositeFigureListener listener)
Description copied from interface:CompositeFigureAdds a listener for this composite figure.- Specified by:
addCompositeFigureListenerin interfaceCompositeFigure
-
clone
public LabeledLineConnectionFigure 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 classLineConnectionFigure
-
remap
public void remap(java.util.Map<Figure,Figure> oldToNew, boolean disconnectIfNotInMap)
Description copied from interface:FigureAfter cloning a collection of figures, the ConnectionFigures contained in this collection still connect to the original figures instead of to the clones. Using This operation and providing a map, which maps from the original collection of figures to the new collection, connections can be remapped to the new figures.- Specified by:
remapin interfaceFigure- Overrides:
remapin classLineConnectionFigure
-
contains
public boolean contains(Figure f)
Description copied from interface:CompositeFigureReturns true if this composite figure contains the specified figure.This is a convenience method for calling
getChildren().contains(f);.- Specified by:
containsin interfaceCompositeFigure
-
indexOf
public int indexOf(Figure child)
Description copied from interface:CompositeFigureReturns the index of the specified child.This is a convenience method for calling
getChildren().indexOf(index);.- Specified by:
indexOfin interfaceCompositeFigure- Returns:
- The index of the child, or -1 if the specified figure is not a child of this CompositeFigure.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG