JHotDraw 6.0b1

org.jhotdraw.standard
Class AbstractConnector

java.lang.Object
  extended by org.jhotdraw.standard.AbstractConnector
All Implemented Interfaces:
java.io.Serializable, Connector, Storable
Direct Known Subclasses:
ChopBoxConnector, LocatorConnector, NullConnector, ShortestDistanceConnector

public abstract class AbstractConnector
extends java.lang.Object
implements Connector

AbstractConnector provides default implementation for the Connector interface.

See Also:
Connector, Serialized Form

Field Summary
protected  Figure fOwner
          the owner of the connector
 
Constructor Summary
AbstractConnector()
          Constructs a connector that has no owner.
AbstractConnector(Figure owner)
          Constructs a connector with the given owner figure.
 
Method Summary
 java.awt.Point connectorMovedTo(int x, int y)
          SupportsConnector dragging.
 void connectorVisibility(boolean isVisible, ConnectionFigure courtingConnection)
          Requests that the connector should show itself or hide itself.
 boolean containsPoint(int x, int y)
          Tests if a point is contained in the connector.
 java.awt.Rectangle displayBox()
          Gets the display box of the connector.
 void draw(java.awt.Graphics g)
          Draws this connector.
 Connector finalizeConnector(boolean start)
          Returns a 'finalized' connector.
 java.awt.Point findEnd(ConnectionFigure connection)
          Finds the end point for the connection.
protected  java.awt.Point findPoint(ConnectionFigure connection)
          Gets the connection point.
 java.awt.Point findStart(ConnectionFigure connection)
          Finds the start point for the connection.
 Figure owner()
          Gets the connector's owner.
 void read(StorableInput dr)
          Reads the connector and its owner from a StorableInput.
 void write(StorableOutput dw)
          Stores the connector and its owner to a StorableOutput.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fOwner

protected Figure fOwner
the owner of the connector

Constructor Detail

AbstractConnector

public AbstractConnector()
Constructs a connector that has no owner. It is only used internally to resurrect a connectors from a StorableOutput. It should never be called directly.


AbstractConnector

public AbstractConnector(Figure owner)
Constructs a connector with the given owner figure.

Method Detail

owner

public Figure owner()
Gets the connector's owner. Which is the figure this is attached too and NOT the connection it may be attached too.

Specified by:
owner in interface Connector

findStart

public java.awt.Point findStart(ConnectionFigure connection)
Description copied from interface: Connector
Finds the start point for the connection.

Specified by:
findStart in interface Connector

findEnd

public java.awt.Point findEnd(ConnectionFigure connection)
Description copied from interface: Connector
Finds the end point for the connection.

Specified by:
findEnd in interface Connector

findPoint

protected java.awt.Point findPoint(ConnectionFigure connection)
Gets the connection point. Override when the connector does not need to distinguish between the start and end point of a connection.


displayBox

public java.awt.Rectangle displayBox()
Gets the display box of the connector.

Specified by:
displayBox in interface Connector

containsPoint

public boolean containsPoint(int x,
                             int y)
Tests if a point is contained in the connector.

Specified by:
containsPoint in interface Connector

draw

public void draw(java.awt.Graphics g)
Draws this connector. By default connectors are invisible.

Specified by:
draw in interface Connector

write

public void write(StorableOutput dw)
Stores the connector and its owner to a StorableOutput.

Specified by:
write in interface Storable

read

public void read(StorableInput dr)
          throws java.io.IOException
Reads the connector and its owner from a StorableInput.

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

connectorVisibility

public void connectorVisibility(boolean isVisible,
                                ConnectionFigure courtingConnection)
Requests that the connector should show itself or hide itself. The ConnectionFigure which desires to connect to this Connector is passed in. It a connector should show itself it should do so when draw is called, if so desired.

Specified by:
connectorVisibility in interface Connector

connectorMovedTo

public java.awt.Point connectorMovedTo(int x,
                                       int y)
SupportsConnector dragging.

Specified by:
connectorMovedTo in interface Connector

finalizeConnector

public Connector finalizeConnector(boolean start)
Returns a 'finalized' connector. Can be used to change Connector.

Specified by:
finalizeConnector in interface Connector
Parameters:
start - - true if a startConnector
Returns:
- final Connector

JHotDraw 6.0b1