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.

Version:
<$CURRENT_VERSION$>
See Also:
Connector, Serialized Form

Constructor Summary
AbstractConnector()
          Constructs a connector that has no owner.
AbstractConnector(Figure owner)
          Constructs a connector with the given owner figure.
 
Method Summary
 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.
 java.awt.Point findEnd(ConnectionFigure connection)
          Finds the end point for the connection.
 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
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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

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