JHotDraw 6.0b1

org.jhotdraw.figures
Class LineConnection

java.lang.Object
  extended by org.jhotdraw.standard.AbstractFigure
      extended by org.jhotdraw.figures.PolyLineFigure
          extended by org.jhotdraw.figures.LineConnection
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.EventListener, ConnectionFigure, Figure, FigureChangeListener, Storable
Direct Known Subclasses:
ElbowConnection, PertDependency

public class LineConnection
extends PolyLineFigure
implements ConnectionFigure

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

See Also:
ConnectionFigure, Serialized Form

Field Summary
protected  Connector myEndConnector
           
protected  Connector myStartConnector
           
 
Fields inherited from class org.jhotdraw.figures.PolyLineFigure
ARROW_TIP_BOTH, ARROW_TIP_END, ARROW_TIP_NONE, ARROW_TIP_START, fEndDecoration, fFrameColor, fPoints, fStartDecoration
 
Constructor Summary
LineConnection()
          Constructs a LineConnection.
 
Method Summary
protected  void basicMoveBy(int dx, int dy)
          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, Figure end)
          Tests whether two figures can be connected.
 void connectEnd(Connector newEndConnector)
          Sets the end figure of the connection.
 boolean connectsSame(ConnectionFigure other)
          Tests whether a connection connects the same figures as another ConnectionFigure.
 void connectStart(Connector newStartConnector)
          Sets the start figure of the connection.
 void disconnectEnd()
          Disconnects the end figure.
 void disconnectStart()
          Disconnects the start figure.
 Figure endFigure()
          Gets the end figure of the connection.
 java.awt.Point endPoint()
          Gets the end point.
 void endPoint(int x, int y)
          Sets the end point.
 void figureChanged(FigureChangeEvent e)
          Sent when a figure changed
 void figureInvalidated(FigureChangeEvent e)
          Sent when an area is invalid
 void figureRemoved(FigureChangeEvent e)
          Sent when a figure was removed
 void figureRequestRemove(FigureChangeEvent e)
          Sent when requesting to remove a figure.
 void figureRequestUpdate(FigureChangeEvent e)
          Sent when an update should happen.
 Connector getEndConnector()
          Gets the end figure of the connection.
 Connector getStartConnector()
          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.
 HandleEnumeration handles()
          Gets the handles of the figure.
 void insertPointAt(java.awt.Point p, int i)
          Inserts the point and updates the connection.
 void layoutConnection()
          Lays out the connection.
 void read(StorableInput dr)
          Reads the Figure from a StorableInput.
 void release()
          A figure is released from the drawing.
 void removeFromContainer(FigureChangeListener c)
          Removes a figure from the given container and unregisters it as a change listener.
 void removePointAt(int i)
          Removes the point and updates the connection.
protected  void setEndConnector(Connector newEndConnector)
           
 void setPointAt(java.awt.Point p, int i)
          Sets the point and updates the connection.
protected  void setStartConnector(Connector newStartConnector)
           
 Figure startFigure()
          Gets the start figure of the connection.
 java.awt.Point startPoint()
          Gets the start point.
 void startPoint(int x, int y)
          Sets the start point.
 void updateConnection()
          Updates the connection.
 void visit(FigureVisitor visitor)
           
 void write(StorableOutput dw)
          Stores the Figure to a StorableOutput.
 
Methods inherited from class org.jhotdraw.figures.PolyLineFigure
addPoint, basicDisplayBox, connectorAt, containsPoint, displayBox, draw, drawLine, findSegment, getAttribute, getAttribute, getEndDecoration, getFrameColor, getStartDecoration, invalidateRectangle, isEmpty, joinSegments, locator, pointAt, pointCount, points, setAttribute, setAttribute, setEndDecoration, setFrameColor, setStartDecoration, splitSegment
 
Methods inherited from class org.jhotdraw.standard.AbstractFigure
addDependendFigure, addFigureChangeListener, addToContainer, center, changed, clone, connectedTextLocator, connectionInsets, connectorVisibility, decompose, displayBox, displayBox, figures, findFigureInside, getDecoratedFigure, getDependendFigures, getTextHolder, getZValue, includes, invalidate, listener, moveBy, removeDependendFigure, removeFigureChangeListener, setZValue, size, willChange
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jhotdraw.framework.ConnectionFigure
joinSegments, pointAt, pointCount, splitSegment
 
Methods inherited from interface org.jhotdraw.framework.Figure
addDependendFigure, addFigureChangeListener, addToContainer, basicDisplayBox, center, changed, clone, connectedTextLocator, connectionInsets, connectorAt, connectorVisibility, containsPoint, decompose, displayBox, displayBox, displayBox, draw, figures, findFigureInside, getAttribute, getAttribute, getDecoratedFigure, getDependendFigures, getTextHolder, getZValue, includes, invalidate, isEmpty, listener, moveBy, removeDependendFigure, removeFigureChangeListener, setAttribute, setAttribute, setZValue, size, willChange
 

Field Detail

myStartConnector

protected Connector myStartConnector

myEndConnector

protected Connector myEndConnector
Constructor Detail

LineConnection

public LineConnection()
Constructs a LineConnection. A connection figure has an arrow decoration at the start and end.

Method Detail

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 AbstractFigure

basicMoveBy

protected void basicMoveBy(int dx,
                           int dy)
Ensures that a connection is updated if the connection was moved.

Overrides:
basicMoveBy in class PolyLineFigure
See Also:
AbstractFigure.moveBy(int, int)

connectStart

public void connectStart(Connector newStartConnector)
Sets the start figure of the connection.

Specified by:
connectStart in interface ConnectionFigure
Parameters:
newStartConnector - the start connector of the connection

connectEnd

public void connectEnd(Connector newEndConnector)
Sets the end figure of the connection.

Specified by:
connectEnd in interface ConnectionFigure
Parameters:
newEndConnector - the end connector of the connection

disconnectStart

public void disconnectStart()
Disconnects the start figure.

Specified by:
disconnectStart in interface ConnectionFigure

disconnectEnd

public void disconnectEnd()
Disconnects the end figure.

Specified by:
disconnectEnd in interface ConnectionFigure

connectsSame

public boolean connectsSame(ConnectionFigure other)
Tests whether a connection connects the same figures as another ConnectionFigure.

Specified by:
connectsSame in interface ConnectionFigure

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.


startFigure

public Figure startFigure()
Gets the start figure of the connection.

Specified by:
startFigure in interface ConnectionFigure

endFigure

public Figure endFigure()
Gets the end figure of the connection.

Specified by:
endFigure in interface ConnectionFigure

setStartConnector

protected void setStartConnector(Connector newStartConnector)

getStartConnector

public Connector getStartConnector()
Gets the start figure of the connection.

Specified by:
getStartConnector in interface ConnectionFigure

setEndConnector

protected void setEndConnector(Connector newEndConnector)

getEndConnector

public Connector getEndConnector()
Gets the end figure of the connection.

Specified by:
getEndConnector in interface ConnectionFigure

canConnect

public boolean canConnect(Figure start,
                          Figure end)
Tests whether two figures can be connected.

Specified by:
canConnect in interface ConnectionFigure

startPoint

public void startPoint(int x,
                       int y)
Sets the start point.

Specified by:
startPoint in interface ConnectionFigure

endPoint

public void endPoint(int x,
                     int y)
Sets the end point.

Specified by:
endPoint in interface ConnectionFigure

startPoint

public java.awt.Point startPoint()
Gets the start point.

Specified by:
startPoint in interface ConnectionFigure

endPoint

public java.awt.Point endPoint()
Gets the end point.

Specified by:
endPoint in interface ConnectionFigure

handles

public HandleEnumeration handles()
Gets the handles of the figure. It returns the normal PolyLineHandles but adds ChangeConnectionHandles at the start and end.

Specified by:
handles in interface Figure
Overrides:
handles in class PolyLineFigure
Returns:
a type-safe iterator of handles
See Also:
Handle

setPointAt

public void setPointAt(java.awt.Point p,
                       int i)
Sets the point and updates the connection.

Specified by:
setPointAt in interface ConnectionFigure
Overrides:
setPointAt in class PolyLineFigure

insertPointAt

public void insertPointAt(java.awt.Point p,
                          int i)
Inserts the point and updates the connection.

Overrides:
insertPointAt in class PolyLineFigure

removePointAt

public void removePointAt(int i)
Removes the point and updates the connection.

Overrides:
removePointAt in class PolyLineFigure

updateConnection

public void updateConnection()
Updates the connection.

Specified by:
updateConnection in interface ConnectionFigure

layoutConnection

public void layoutConnection()
Lays out the connection. This is called when the connection itself changes. By default the connection is recalculated


figureChanged

public void figureChanged(FigureChangeEvent e)
Description copied from interface: FigureChangeListener
Sent when a figure changed

Specified by:
figureChanged in interface FigureChangeListener

figureRemoved

public void figureRemoved(FigureChangeEvent e)
Description copied from interface: FigureChangeListener
Sent when a figure was removed

Specified by:
figureRemoved in interface FigureChangeListener

figureRequestRemove

public void figureRequestRemove(FigureChangeEvent e)
Description copied from interface: FigureChangeListener
Sent when requesting to remove a figure.

Specified by:
figureRequestRemove in interface FigureChangeListener

figureInvalidated

public void figureInvalidated(FigureChangeEvent e)
Description copied from interface: FigureChangeListener
Sent when an area is invalid

Specified by:
figureInvalidated in interface FigureChangeListener

figureRequestUpdate

public void figureRequestUpdate(FigureChangeEvent e)
Description copied from interface: FigureChangeListener
Sent when an update should happen.

Specified by:
figureRequestUpdate in interface FigureChangeListener

release

public void release()
Description copied from class: AbstractFigure
A figure is released from the drawing. You never call this method directly. Release notifies its listeners.

Specified by:
release in interface Figure
Overrides:
release in class AbstractFigure
See Also:
Figure.release()

write

public void write(StorableOutput dw)
Description copied from class: AbstractFigure
Stores the Figure to a StorableOutput.

Specified by:
write in interface Storable
Overrides:
write in class PolyLineFigure

read

public void read(StorableInput dr)
          throws java.io.IOException
Description copied from class: AbstractFigure
Reads the Figure from a StorableInput.

Specified by:
read in interface Storable
Overrides:
read in class PolyLineFigure
Throws:
java.io.IOException

visit

public void visit(FigureVisitor visitor)
Specified by:
visit in interface Figure
Overrides:
visit in class AbstractFigure

removeFromContainer

public void removeFromContainer(FigureChangeListener c)
Description copied from class: AbstractFigure
Removes a figure from the given container and unregisters it as a change listener.

Specified by:
removeFromContainer in interface Figure
Overrides:
removeFromContainer in class AbstractFigure
See Also:
Figure.removeFromContainer(org.jhotdraw.framework.FigureChangeListener)

JHotDraw 6.0b1