JHotDraw 6.0b1

org.jhotdraw.standard
Class ConnectionHandle

java.lang.Object
  extended by org.jhotdraw.standard.AbstractHandle
      extended by org.jhotdraw.standard.LocatorHandle
          extended by org.jhotdraw.standard.ConnectionHandle
All Implemented Interfaces:
Handle

public class ConnectionHandle
extends LocatorHandle

A handle to connect figures. The connection object to be created is specified by a prototype.


Design Patterns

 o Prototype
ConnectionHandle creates the connection by cloning a prototype.


See Also:
ConnectionFigure, Object.clone()

Field Summary
 
Fields inherited from class org.jhotdraw.standard.AbstractHandle
HANDLESIZE
 
Constructor Summary
ConnectionHandle(Figure owner, Locator l, ConnectionFigure prototype)
          Constructs a handle with the given owner, locator, and connection prototype
 
Method Summary
protected  ConnectionFigure createConnection()
          Creates the ConnectionFigure.
protected  Undoable createUndoActivity(DrawingView view)
          Factory method for undo activity.
 void draw(java.awt.Graphics g)
          Draws the connection handle, by default the outline of a blue circle.
protected  Connector findConnectionTarget(int x, int y, Drawing drawing)
          Finds a connection end figure.
protected  Connector findConnector(int x, int y, Figure f)
           
protected  ConnectionFigure getConnection()
           
 Cursor getCursor()
          Returns the preferred Cursor for this Handle.
protected  Figure getTargetFigure()
           
 void invokeEnd(int x, int y, int anchorX, int anchorY, DrawingView view)
          Connects the figures if the mouse is released over another figure.
 void invokeStart(int x, int y, DrawingView view)
          Creates the connection
 void invokeStep(int x, int y, int anchorX, int anchorY, DrawingView view)
          Tracks the connection.
protected  void setConnection(ConnectionFigure newConnection)
           
protected  void setTargetFigure(Figure newTargetFigure)
           
 
Methods inherited from class org.jhotdraw.standard.LocatorHandle
getLocator, locate
 
Methods inherited from class org.jhotdraw.standard.AbstractHandle
containsPoint, displayBox, getUndoActivity, invokeEnd, invokeStart, invokeStep, owner, setUndoActivity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConnectionHandle

public ConnectionHandle(Figure owner,
                        Locator l,
                        ConnectionFigure prototype)
Constructs a handle with the given owner, locator, and connection prototype

Method Detail

invokeStart

public void invokeStart(int x,
                        int y,
                        DrawingView view)
Creates the connection

Specified by:
invokeStart in interface Handle
Overrides:
invokeStart in class AbstractHandle
Parameters:
x - the x position where the interaction started
y - the y position where the interaction started
view - the handles container
See Also:
Handle.invokeStart(int, int, org.jhotdraw.framework.DrawingView)

invokeStep

public void invokeStep(int x,
                       int y,
                       int anchorX,
                       int anchorY,
                       DrawingView view)
Tracks the connection.

Specified by:
invokeStep in interface Handle
Overrides:
invokeStep in class AbstractHandle
Parameters:
x - the current x position
y - the current y position
anchorX - the x position where the interaction started
anchorY - the y position where the interaction started
See Also:
Handle.invokeStep(int, int, int, int, org.jhotdraw.framework.DrawingView)

invokeEnd

public void invokeEnd(int x,
                      int y,
                      int anchorX,
                      int anchorY,
                      DrawingView view)
Connects the figures if the mouse is released over another figure.

Specified by:
invokeEnd in interface Handle
Overrides:
invokeEnd in class AbstractHandle
Parameters:
x - the current x position
y - the current y position
anchorX - the x position where the interaction started
anchorY - the y position where the interaction started
See Also:
Handle.invokeEnd(int, int, int, int, org.jhotdraw.framework.DrawingView)

createConnection

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


createUndoActivity

protected Undoable createUndoActivity(DrawingView view)
Factory method for undo activity.


findConnectionTarget

protected Connector findConnectionTarget(int x,
                                         int y,
                                         Drawing drawing)
Finds a connection end figure.


findConnector

protected Connector findConnector(int x,
                                  int y,
                                  Figure f)

draw

public void draw(java.awt.Graphics g)
Draws the connection handle, by default the outline of a blue circle.

Specified by:
draw in interface Handle
Overrides:
draw in class AbstractHandle
See Also:
Handle.draw(java.awt.Graphics)

setConnection

protected void setConnection(ConnectionFigure newConnection)

getConnection

protected ConnectionFigure getConnection()

getTargetFigure

protected Figure getTargetFigure()

setTargetFigure

protected void setTargetFigure(Figure newTargetFigure)

getCursor

public Cursor getCursor()
Description copied from interface: Handle
Returns the preferred Cursor for this Handle.

Specified by:
getCursor in interface Handle
Overrides:
getCursor in class LocatorHandle
Returns:
Cursor
See Also:
Handle.getCursor()

JHotDraw 6.0b1