JHotDraw 6.0b1

org.jhotdraw.framework
Interface ConnectionFigure

All Superinterfaces:
java.lang.Cloneable, java.util.EventListener, Figure, FigureChangeListener, java.io.Serializable, Storable
All Known Implementing Classes:
ElbowConnection, LineConnection, PertDependency

public interface ConnectionFigure
extends Figure, FigureChangeListener

Figures to connect Connectors provided by Figures. A ConnectionFigure knows its start and end Connector. It uses the Connectors to locate its connection points.

A ConnectionFigure can have multiple segments. It provides operations to split and join segments.


Design Patterns

 o Strategy
Strategy is used encapsulate the algorithm to locate the connection point. ConnectionFigure is the Strategy context and Connector is the Strategy.
 o Observer
Observer is used to track changes of the connected figures. A connection figure registers itself as listeners or observers of the source and target connector.


See Also:
Connector

Method Summary
 boolean canConnect(Figure start, Figure end)
          Checks if two figures can be connected.
 void connectEnd(Connector end)
          Sets the end Connector of the connection.
 boolean connectsSame(ConnectionFigure other)
          Checks if the ConnectionFigure connects the same figures.
 void connectStart(Connector start)
          Sets the start Connector of the connection.
 void disconnectEnd()
          Disconnects the end figure from the dependent figure
 void disconnectStart()
          Disconnects the start figure from the dependent 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.
 Connector getEndConnector()
          Gets the end Connector.
 Connector getStartConnector()
          Gets the start Connector
 boolean joinSegments(int x, int y)
          Joins the hit segments.
 java.awt.Point pointAt(int index)
          Gets the Point at the given position
 int pointCount()
          Gets the number of points or nodes of the connection
 void setPointAt(java.awt.Point p, int index)
          Sets the position of the point at the given position
 int splitSegment(int x, int y)
          Splits the hit segment.
 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
 
Methods inherited from interface org.jhotdraw.framework.Figure
addDependendFigure, addFigureChangeListener, addToContainer, basicDisplayBox, canConnect, center, changed, clone, connectedTextLocator, connectionInsets, connectorAt, connectorVisibility, containsPoint, decompose, displayBox, displayBox, displayBox, draw, figures, findFigureInside, getAttribute, getAttribute, getDecoratedFigure, getDependendFigures, getTextHolder, getZValue, handles, includes, invalidate, isEmpty, listener, moveBy, release, removeDependendFigure, removeFigureChangeListener, removeFromContainer, setAttribute, setAttribute, setZValue, size, visit, willChange
 
Methods inherited from interface org.jhotdraw.util.Storable
read, write
 
Methods inherited from interface org.jhotdraw.framework.FigureChangeListener
figureChanged, figureInvalidated, figureRemoved, figureRequestRemove, figureRequestUpdate
 

Method Detail

connectStart

void connectStart(Connector start)
Sets the start Connector of the connection.

Parameters:
start - the start connector of the connection

connectEnd

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

Parameters:
end - the end connector of the connection

updateConnection

void updateConnection()
Updates the connection


disconnectStart

void disconnectStart()
Disconnects the start figure from the dependent figure


disconnectEnd

void disconnectEnd()
Disconnects the end figure from the dependent figure


getStartConnector

Connector getStartConnector()
Gets the start Connector


getEndConnector

Connector getEndConnector()
Gets the end Connector.


canConnect

boolean canConnect(Figure start,
                   Figure end)
Checks if two figures can be connected. Implement this method to constrain the allowed connections between figures.


connectsSame

boolean connectsSame(ConnectionFigure other)
Checks if the ConnectionFigure connects the same figures.


startPoint

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


endPoint

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


startPoint

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


endPoint

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


setPointAt

void setPointAt(java.awt.Point p,
                int index)
Sets the position of the point at the given position


pointAt

java.awt.Point pointAt(int index)
Gets the Point at the given position


pointCount

int pointCount()
Gets the number of points or nodes of the connection


splitSegment

int splitSegment(int x,
                 int y)
Splits the hit segment.

Parameters:
x - the x position where the figure should be split
y - the y position where the figure should be split
Returns:
the index of the splitting point

joinSegments

boolean joinSegments(int x,
                     int y)
Joins the hit segments.

Parameters:
x - the position where the figure should be joined.
y - the position where the figure should be joined.
Returns:
whether the segment was joined

startFigure

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


endFigure

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


JHotDraw 6.0b1