org.jhotdraw.draw
Class ConnectorHandle

java.lang.Object
  extended by org.jhotdraw.draw.AbstractHandle
      extended by org.jhotdraw.draw.ConnectorHandle
All Implemented Interfaces:
java.awt.event.KeyListener, java.util.EventListener, FigureListener, Handle

public class ConnectorHandle
extends AbstractHandle

A Handle associated to a Connector which allows to create a new ConnectionFigure by dragging the handle to another connector.

Version:
$Id: ConnectorHandle.java 536 2009-06-14 12:10:57Z rawcoder $
Author:
Werner Randelshofer.

Field Summary
private  Connector connectableConnector
          The current connectable Connector.
private  Figure connectableFigure
          The current connectable Figure.
private  Connector connector
          The Connector.
protected  java.util.Collection<Connector> connectors
          All connectors of the connectable Figure.
private  ConnectionFigure createdConnection
          Holds the ConnectionFigure which is currently being created.
private  ConnectionFigure prototype
          The prototype for the ConnectionFigure to be created
 
Fields inherited from class org.jhotdraw.draw.AbstractHandle
listenerList, view
 
Constructor Summary
ConnectorHandle(Connector connector, ConnectionFigure prototype)
          Creates a new instance.
 
Method Summary
protected  java.awt.Rectangle basicGetBounds()
           
protected  ConnectionFigure createConnection()
          Creates the ConnectionFigure.
 void draw(java.awt.Graphics2D g)
          Draws this handle.
protected  Connector findConnectableConnector(Figure connectableFigure, java.awt.geom.Point2D.Double p)
          Finds a connection end figure.
private  Figure findConnectableFigure(java.awt.geom.Point2D.Double p, Drawing drawing)
           
protected  ConnectionFigure getConnection()
           
 java.awt.Rectangle getDrawingArea()
          Returns the drawing area of the handle.
 java.awt.Point getLocation()
           
 java.awt.geom.Point2D.Double getLocationOnDrawing()
           
protected  Figure getTargetFigure()
           
 boolean isCombinableWith(Handle handle)
          Returns true, if the given handle is an instance of the same class or of a subclass of this handle,.
 void repaintConnectors()
          Updates the list of connectors that we draw when the user moves or drags the mouse over a figure to which can connect.
protected  void setConnection(ConnectionFigure newConnection)
           
protected  void setTargetFigure(Figure newTargetFigure)
           
 void trackEnd(java.awt.Point anchor, java.awt.Point lead, int modifiersEx)
          Tracks the end of the interaction.
 void trackStart(java.awt.Point anchor, int modifiersEx)
          Tracks the start of the interaction.
 void trackStep(java.awt.Point anchor, java.awt.Point lead, int modifiersEx)
          Tracks a step of the interaction.
 
Methods inherited from class org.jhotdraw.draw.AbstractHandle
addHandleListener, areaInvalidated, attributeChanged, contains, createSecondaryHandles, dispose, drawCircle, drawDiamond, drawRectangle, figureAdded, figureChanged, figureHandlesChanged, figureRemoved, figureRequestRemove, fireAreaInvalidated, fireHandleRequestRemove, fireHandleRequestSecondaryHandles, fireUndoableEditHappened, getBounds, getCursor, getEditor, getHandlesize, getOwner, getToolTipText, getView, invalidate, keyPressed, keyReleased, keyTyped, removeHandleListener, setToolTipText, setView, trackDoubleClick, updateBounds, viewTransformChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

createdConnection

private ConnectionFigure createdConnection
Holds the ConnectionFigure which is currently being created.


prototype

private ConnectionFigure prototype
The prototype for the ConnectionFigure to be created


connector

private Connector connector
The Connector.


connectableFigure

private Figure connectableFigure
The current connectable Figure.


connectableConnector

private Connector connectableConnector
The current connectable Connector.


connectors

protected java.util.Collection<Connector> connectors
All connectors of the connectable Figure.

Constructor Detail

ConnectorHandle

public ConnectorHandle(Connector connector,
                       ConnectionFigure prototype)
Creates a new instance.

Method Detail

getLocationOnDrawing

public java.awt.geom.Point2D.Double getLocationOnDrawing()

getLocation

public java.awt.Point getLocation()

draw

public void draw(java.awt.Graphics2D g)
Description copied from class: AbstractHandle
Draws this handle.

Specified by:
draw in interface Handle
Overrides:
draw in class AbstractHandle

trackStart

public void trackStart(java.awt.Point anchor,
                       int modifiersEx)
Description copied from interface: Handle
Tracks the start of the interaction. The default implementation does nothing.

Parameters:
anchor - the position where the interaction started

trackStep

public void trackStep(java.awt.Point anchor,
                      java.awt.Point lead,
                      int modifiersEx)
Description copied from interface: Handle
Tracks a step of the interaction.

Parameters:
anchor - the position where the interaction started
lead - the current position

getDrawingArea

public java.awt.Rectangle getDrawingArea()
Description copied from interface: Handle
Returns the drawing area of the handle. Note: The drawing area must be returned in the coordinate system of the DrawingView.

Specified by:
getDrawingArea in interface Handle
Overrides:
getDrawingArea in class AbstractHandle

trackEnd

public void trackEnd(java.awt.Point anchor,
                     java.awt.Point lead,
                     int modifiersEx)
Description copied from interface: Handle
Tracks the end of the interaction.

Parameters:
anchor - the position where the interaction started
lead - the current position

createConnection

protected ConnectionFigure createConnection()
Creates the ConnectionFigure. By default the figure prototype is cloned.


setConnection

protected void setConnection(ConnectionFigure newConnection)

getConnection

protected ConnectionFigure getConnection()

getTargetFigure

protected Figure getTargetFigure()

setTargetFigure

protected void setTargetFigure(Figure newTargetFigure)

findConnectableFigure

private Figure findConnectableFigure(java.awt.geom.Point2D.Double p,
                                     Drawing drawing)

findConnectableConnector

protected Connector findConnectableConnector(Figure connectableFigure,
                                             java.awt.geom.Point2D.Double p)
Finds a connection end figure.


basicGetBounds

protected java.awt.Rectangle basicGetBounds()
Specified by:
basicGetBounds in class AbstractHandle

isCombinableWith

public boolean isCombinableWith(Handle handle)
Description copied from class: AbstractHandle
Returns true, if the given handle is an instance of the same class or of a subclass of this handle,.

Specified by:
isCombinableWith in interface Handle
Overrides:
isCombinableWith in class AbstractHandle

repaintConnectors

public void repaintConnectors()
Updates the list of connectors that we draw when the user moves or drags the mouse over a figure to which can connect.