CH.ifa.draw.figures
Class LineConnection

java.lang.Object
  extended by CH.ifa.draw.standard.AbstractFigure
      extended by CH.ifa.draw.figures.PolyLineFigure
          extended by CH.ifa.draw.figures.LineConnection
All Implemented Interfaces:
ConnectionFigure, Figure, FigureChangeListener, Storable, java.io.Serializable, java.lang.Cloneable, java.util.EventListener
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 fEnd
           
protected  Connector fStart
           
 
Fields inherited from class CH.ifa.draw.figures.PolyLineFigure
ARROW_TIP_BOTH, ARROW_TIP_END, ARROW_TIP_NONE, ARROW_TIP_START, fEndDecoration, fFrameColor, fPoints, fStartDecoration
 
Fields inherited from interface CH.ifa.draw.framework.Figure
POPUP_MENU
 
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 end)
          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 start)
          Sets the start figure of the connection.
 void disconnectEnd()
          Disconnects the end figure.
 void disconnectStart()
          Disconnects the start figure.
 Connector end()
          Gets the end figure of the connection.
 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.
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.
 java.util.Vector 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 removePointAt(int i)
          Removes the point and updates the connection.
 void setPointAt(java.awt.Point p, int i)
          Sets the point and updates the connection.
 Connector start()
          Gets the start figure of the connection.
 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 write(StorableOutput dw)
          Stores the Figure to a StorableOutput.
 
Methods inherited from class CH.ifa.draw.figures.PolyLineFigure
addPoint, basicDisplayBox, connectorAt, containsPoint, displayBox, draw, drawLine, findSegment, getAttribute, getEndDecoration, getFrameColor, getStartDecoration, isEmpty, joinSegments, locator, pointAt, pointCount, points, setAttribute, setEndDecoration, setFrameColor, setStartDecoration, splitSegment
 
Methods inherited from class CH.ifa.draw.standard.AbstractFigure
addFigureChangeListener, addToContainer, center, changed, clone, connectedTextLocator, connectionInsets, connectorVisibility, decompose, displayBox, displayBox, figures, findFigureInside, includes, invalidate, listener, moveBy, removeFigureChangeListener, removeFromContainer, size, willChange
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface CH.ifa.draw.framework.ConnectionFigure
joinSegments, pointAt, pointCount, splitSegment
 
Methods inherited from interface CH.ifa.draw.framework.Figure
addFigureChangeListener, addToContainer, basicDisplayBox, center, changed, clone, connectedTextLocator, connectionInsets, connectorAt, connectorVisibility, containsPoint, decompose, displayBox, displayBox, displayBox, draw, figures, findFigureInside, getAttribute, includes, invalidate, isEmpty, listener, moveBy, removeFigureChangeListener, removeFromContainer, setAttribute, size, willChange
 

Field Detail

fStart

protected Connector fStart

fEnd

protected Connector fEnd
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 start)
Sets the start figure of the connection.

Specified by:
connectStart in interface ConnectionFigure

connectEnd

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

Specified by:
connectEnd in interface ConnectionFigure

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.


endFigure

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


start

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

Specified by:
start in interface ConnectionFigure

end

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

Specified by:
end 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 java.util.Vector 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 Vector 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