JHotDraw 7.0.6

org.jhotdraw.draw
Class LineConnectionFigure

java.lang.Object
  extended by org.jhotdraw.draw.AbstractFigure
      extended by org.jhotdraw.draw.AttributedFigure
          extended by org.jhotdraw.draw.BezierFigure
              extended by org.jhotdraw.draw.LineFigure
                  extended by org.jhotdraw.draw.LineConnectionFigure
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, ConnectionFigure, Figure, DOMStorable
Direct Known Subclasses:
DependencyFigure, LabeledLineConnectionFigure

public class LineConnectionFigure
extends LineFigure
implements ConnectionFigure

A LineConnection is a standard implementation of the ConnectionFigure interface. The interface is implemented with BezierFigure.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.jhotdraw.draw.BezierFigure
CLOSED, path
 
Fields inherited from class org.jhotdraw.draw.AbstractFigure
changingDepth, decorator, listenerList
 
Constructor Summary
LineConnectionFigure()
          Creates a new instance.
 
Method Summary
 void addNotify(Drawing drawing)
          Informs a figure, that it has been added to the specified drawing.
protected  void basicSetEndConnector(Connector newEnd)
           
 void basicSetNode(int index, BezierPath.Node p)
          Sets a control point.
 void basicSetStartConnector(Connector newStart)
           
 void basicTransform(java.awt.geom.AffineTransform tx)
          Ensures that a connection is updated if the connection was moved.
 boolean canConnect()
          Tests whether a figure can be a connection target.
 boolean canConnect(Figure start)
          Checks if this ConnectionFigure can be attached to the provided start figure.
 boolean canConnect(Figure start, Figure end)
          Checks if two figures can be connected using this ConnectionFigure.
 LineConnectionFigure clone()
          Returns a clone of the figure.
 boolean connectsSame(ConnectionFigure other)
          Checks if the ConnectionFigure connects the same figures.
 java.util.Collection<Handle> createHandles(int detailLevel)
          Gets the handles of the figure.
 BezierPath getBezierPath()
          FIXME - Liner must work with API of LineConnection!
 Connector getEndConnector()
          Gets the end Connector.
 Figure getEndFigure()
          Gets the end figure of the connection.
 Liner getLiner()
          Get a Liner object which encapsulated a lineout algorithm for this figure.
 Connector getStartConnector()
          Gets the start Connector.
 Figure getStartFigure()
          Gets the start figure of the connection.
protected  void handleConnect(Figure start, Figure end)
          Handles the connection of a connection.
protected  void handleDisconnect(Figure start, Figure end)
          Handles the disconnection of a connection.
 boolean handleMouseClick(java.awt.geom.Point2D.Double p, java.awt.event.MouseEvent evt, DrawingView view)
          Handles a mouse click.
 void lineout()
          A lineout algorithm is used to define how the child components should be laid out in relation to each other.
 void read(DOMInput in)
           
protected  void readLiner(DOMInput in)
           
protected  void readPoints(DOMInput in)
           
 void remap(java.util.Map oldToNew)
          After cloning a collection of figures, the ConnectionFigures contained in this collection still connect to the original figures instead of to the clones.
 void removeNotify(Drawing drawing)
          Informs a figure, that it has been removed from the specified drawing.
 void reverseConnection()
           
 void setEndConnector(Connector newEnd)
          Note: this method is only final for testing purposes.
 void setEndPoint(java.awt.geom.Point2D.Double p)
          Sets the end point.
 void setLiner(Liner newValue)
          Set a Liner object which encapsulated a lineout algorithm for this figure.
 void setPoint(int index, java.awt.geom.Point2D.Double p)
          Sets the specified point.
 void setStartConnector(Connector newStart)
          Note: this method is only final for testing purposes.
 void setStartPoint(java.awt.geom.Point2D.Double p)
          Sets the start point.
 void updateConnection()
          Updates the connection.
 void validate()
           
 void write(DOMOutput out)
           
protected  void writeLiner(DOMOutput out)
           
protected  void writePoints(DOMOutput out)
           
 
Methods inherited from class org.jhotdraw.draw.BezierFigure
addNode, addNode, basicAddNode, basicAddNode, basicJoinSegments, basicJoinSegments, basicRemoveAllNodes, basicRemoveNode, basicSetAttribute, basicSetBezierPath, basicSetBounds, basicSetEndPoint, basicSetPoint, basicSetPoint, basicSetStartPoint, basicSplitSegment, basicSplitSegment, chop, contains, drawCaps, drawFill, drawStroke, findCompatibleConnector, findConnector, findNode, findSegment, getBounds, getCappedPath, getCenter, getEndPoint, getFigureDrawBounds, getNode, getNodeCount, getOutermostPoint, getPoint, getPoint, getPointCount, getPointOnPath, getRestoreData, getStartPoint, invalidate, invalidateCappedPath, isClosed, layout, removeAllNodes, removeNode, restoreTo, setClosed, setNode, setPoint
 
Methods inherited from class org.jhotdraw.draw.AttributedFigure
applyAttributesTo, drawConnectors, drawFigure, drawText, getAttribute, getAttributeKey, getAttributes, getStroke, getStrokeMiterLimitFactor, hasAttribute, isAttributeEnabled, readAttributes, removeAttribute, setAttribute, setAttributeEnabled, setAttributes, writeAttributes
 
Methods inherited from class org.jhotdraw.draw.AbstractFigure
addFigureListener, addUndoableEditListener, basicClone, changed, draw, drawDecorator, findFigureInside, fireAreaInvalidated, fireAreaInvalidated, fireAttributeChanged, fireFigureAdded, fireFigureChanged, fireFigureChanged, fireFigureChanged, fireFigureRemoved, fireFigureRequestRemove, fireUndoableEditHappened, getActions, getChangingDepth, getCourtingConnection, getCursor, getDecomposition, getDecorator, getDrawBounds, getDrawing, getFontRenderContext, getLayer, getLock, getPreferredSize, getTool, getTooltip, handleDrop, includes, isChanging, isConnectorsVisible, isDrawDecoratorFirst, isInteractive, isVisible, remap, removeFigureListener, removeUndoableEditListener, requestRemove, setBounds, setBounds, setConnectorsVisible, setDecorator, setDrawDecoratorFirst, setInteractive, setVisible, toString, transform, updateDecoratorBounds, willChange
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jhotdraw.draw.ConnectionFigure
getEndPoint, getPoint, getPointCount, getStartPoint
 
Methods inherited from interface org.jhotdraw.draw.Figure
addFigureListener, addUndoableEditListener, basicSetAttribute, basicSetBounds, changed, contains, draw, findCompatibleConnector, findConnector, findFigureInside, getActions, getAttribute, getAttributes, getBounds, getCursor, getDecomposition, getDecorator, getDrawBounds, getLayer, getPreferredSize, getRestoreData, getTool, getTooltip, handleDrop, includes, invalidate, isConnectorsVisible, isInteractive, isVisible, removeFigureListener, removeUndoableEditListener, requestRemove, restoreTo, setAttribute, setConnectorsVisible, setDecorator, setVisible, willChange
 

Constructor Detail

LineConnectionFigure

public LineConnectionFigure()
Creates a new instance.

Method Detail

basicTransform

public void basicTransform(java.awt.geom.AffineTransform tx)
Ensures that a connection is updated if the connection was moved.

Specified by:
basicTransform in interface Figure
Overrides:
basicTransform in class BezierFigure
Parameters:
tx - The transformation.

createHandles

public java.util.Collection<Handle> createHandles(int detailLevel)
Gets the handles of the figure. It returns the normal PolylineHandles but adds ChangeConnectionHandles at the start and end.

Specified by:
createHandles in interface Figure
Overrides:
createHandles in class LineFigure
Parameters:
detailLevel - The detail level of the handles. Usually this is 0 for bounding box handles and 1 for point handles.
Returns:
a Collection of handles
See Also:
Handle

canConnect

public boolean canConnect()
Tests whether a figure can be a connection target. ConnectionFigures cannot be connected and return false.

Specified by:
canConnect in interface Figure
Overrides:
canConnect in class LineFigure

updateConnection

public void updateConnection()
Description copied from interface: ConnectionFigure
Updates the connection. FIXME - What das this do?

Specified by:
updateConnection in interface ConnectionFigure

validate

public void validate()
Overrides:
validate in class BezierFigure

canConnect

public boolean canConnect(Figure start,
                          Figure end)
Description copied from interface: ConnectionFigure
Checks if two figures can be connected using this ConnectionFigure. Implement this method to constrain the allowed connections between figures.

Specified by:
canConnect in interface ConnectionFigure

connectsSame

public boolean connectsSame(ConnectionFigure other)
Description copied from interface: ConnectionFigure
Checks if the ConnectionFigure connects the same figures. FIXME - What do we need this for?

Specified by:
connectsSame in interface ConnectionFigure

getEndConnector

public Connector getEndConnector()
Description copied from interface: ConnectionFigure
Gets the end Connector. Returns null, if there is no end connection.

Specified by:
getEndConnector in interface ConnectionFigure

getEndFigure

public Figure getEndFigure()
Description copied from interface: ConnectionFigure
Gets the end figure of the connection. This is a convenience method for doing getEndConnector().getOwner() and handling null cases.

Specified by:
getEndFigure in interface ConnectionFigure

getStartConnector

public Connector getStartConnector()
Description copied from interface: ConnectionFigure
Gets the start Connector. Returns null, if there is no start connection.

Specified by:
getStartConnector in interface ConnectionFigure

getStartFigure

public Figure getStartFigure()
Description copied from interface: ConnectionFigure
Gets the start figure of the connection. This is a convenience method for doing getStartConnector().getOwner() and handling null cases.

Specified by:
getStartFigure in interface ConnectionFigure

setEndConnector

public final void setEndConnector(Connector newEnd)
Note: this method is only final for testing purposes. You can remove the final keywoard at any time.

Specified by:
setEndConnector in interface ConnectionFigure
Parameters:
newEnd - the end figure of the connection

basicSetEndConnector

protected void basicSetEndConnector(Connector newEnd)

setStartConnector

public final void setStartConnector(Connector newStart)
Note: this method is only final for testing purposes. You can remove the final keywoard at any time.

Specified by:
setStartConnector in interface ConnectionFigure
Parameters:
newStart - the start figure of the connection

basicSetStartConnector

public void basicSetStartConnector(Connector newStart)

addNotify

public void addNotify(Drawing drawing)
Description copied from interface: Figure
Informs a figure, that it has been added to the specified drawing. The figure must inform all FigureListeners that it has been added.

Specified by:
addNotify in interface Figure
Overrides:
addNotify in class AbstractFigure

removeNotify

public void removeNotify(Drawing drawing)
Description copied from interface: Figure
Informs a figure, that it has been removed from the specified drawing. The figure must inform all FigureListeners that it has been removed.

Specified by:
removeNotify in interface Figure
Overrides:
removeNotify in class AbstractFigure

handleDisconnect

protected void handleDisconnect(Figure start,
                                Figure end)
Handles the disconnection of a connection. Override this method to handle this event.


handleConnect

protected void handleConnect(Figure start,
                             Figure end)
Handles the connection of a connection. Override this method to handle this event.


clone

public LineConnectionFigure clone()
Description copied from interface: Figure
Returns a clone of the figure.

Specified by:
clone in interface Figure
Overrides:
clone in class BezierFigure

remap

public void remap(java.util.Map oldToNew)
Description copied from interface: Figure
After 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:
remap in interface Figure
Overrides:
remap in class AbstractFigure

canConnect

public boolean canConnect(Figure start)
Description copied from interface: ConnectionFigure
Checks if this ConnectionFigure can be attached to the provided start figure. This is used to provide an early feedback to the user, when he/she creates a new connection.

Specified by:
canConnect in interface ConnectionFigure

handleMouseClick

public boolean handleMouseClick(java.awt.geom.Point2D.Double p,
                                java.awt.event.MouseEvent evt,
                                DrawingView view)
Handles a mouse click.

Specified by:
handleMouseClick in interface Figure
Overrides:
handleMouseClick in class LineFigure
Parameters:
p - The location of the mouse event.
evt - The mouse event.
view - The drawing view which is the source of the mouse event.
Returns:
Returns true, if the figure consumed the mouse click.

readPoints

protected void readPoints(DOMInput in)
                   throws java.io.IOException
Overrides:
readPoints in class BezierFigure
Throws:
java.io.IOException

read

public void read(DOMInput in)
          throws java.io.IOException
Specified by:
read in interface DOMStorable
Overrides:
read in class BezierFigure
Throws:
java.io.IOException

readLiner

protected void readLiner(DOMInput in)
                  throws java.io.IOException
Throws:
java.io.IOException

write

public void write(DOMOutput out)
           throws java.io.IOException
Specified by:
write in interface DOMStorable
Overrides:
write in class BezierFigure
Throws:
java.io.IOException

writeLiner

protected void writeLiner(DOMOutput out)
                   throws java.io.IOException
Throws:
java.io.IOException

writePoints

protected void writePoints(DOMOutput out)
                    throws java.io.IOException
Overrides:
writePoints in class BezierFigure
Throws:
java.io.IOException

setLiner

public void setLiner(Liner newValue)
Description copied from interface: ConnectionFigure
Set a Liner object which encapsulated a lineout algorithm for this figure. Typically, a Liner accesses the child components of this figure and arranges their graphical presentation. It is a good idea to set the Liner in the protected initialize() method so it can be recreated if a GraphicalCompositeFigure is read and restored from a StorableInput stream.

Specified by:
setLiner in interface ConnectionFigure
Parameters:
newValue - encapsulation of a lineout algorithm.

basicSetNode

public void basicSetNode(int index,
                         BezierPath.Node p)
Description copied from class: BezierFigure
Sets a control point.

Overrides:
basicSetNode in class BezierFigure

lineout

public void lineout()
Description copied from interface: ConnectionFigure
A lineout algorithm is used to define how the child components should be laid out in relation to each other. The task for lineouting the child components for presentation is delegated to a Liner which can be plugged in at runtime.

Specified by:
lineout in interface ConnectionFigure

getBezierPath

public BezierPath getBezierPath()
FIXME - Liner must work with API of LineConnection!

Overrides:
getBezierPath in class BezierFigure

getLiner

public Liner getLiner()
Description copied from interface: ConnectionFigure
Get a Liner object which encapsulated a lineout algorithm for this figure. Typically, a Liner accesses the child components of this figure and arranges their graphical presentation.

Specified by:
getLiner in interface ConnectionFigure
Returns:
lineout strategy used by this figure

setStartPoint

public void setStartPoint(java.awt.geom.Point2D.Double p)
Description copied from interface: ConnectionFigure
Sets the start point.

Specified by:
setStartPoint in interface ConnectionFigure

setPoint

public void setPoint(int index,
                     java.awt.geom.Point2D.Double p)
Description copied from interface: ConnectionFigure
Sets the specified point.

Specified by:
setPoint in interface ConnectionFigure

setEndPoint

public void setEndPoint(java.awt.geom.Point2D.Double p)
Description copied from interface: ConnectionFigure
Sets the end point.

Specified by:
setEndPoint in interface ConnectionFigure

reverseConnection

public void reverseConnection()

Copyright 1996-2006 © JHotDraw.org