JHotDraw 7.4.1

org.jhotdraw.draw.handle
Class AbstractConnectionHandle

java.lang.Object
  extended by org.jhotdraw.draw.handle.AbstractHandle
      extended by org.jhotdraw.draw.handle.AbstractConnectionHandle
All Implemented Interfaces:
java.awt.event.KeyListener, java.util.EventListener, FigureListener, Handle
Direct Known Subclasses:
ConnectionEndHandle, ConnectionStartHandle

public abstract class AbstractConnectionHandle
extends AbstractHandle

This abstract class can be extended to implement a Handle the start or end point of a ConnectionFigure. XXX - Undo/Redo is not implemented yet.

Version:
$Id: AbstractConnectionHandle.java 527 2009-06-07 14:28:19Z rawcoder $
Author:
Werner Randelshofer

Field Summary
protected  java.util.Collection<Connector> connectors
          All connectors of the connectable Figure.
 
Fields inherited from class org.jhotdraw.draw.handle.AbstractHandle
listenerList, view
 
Constructor Summary
protected AbstractConnectionHandle(ConnectionFigure owner)
          Initializes the change connection handle.
 
Method Summary
protected  java.awt.Rectangle basicGetBounds()
           
protected abstract  boolean canConnect(Connector existingEnd, Connector targetEnd)
           
protected abstract  void connect(Connector c)
          Connect the connection with the given figure.
 java.util.Collection<Handle> createSecondaryHandles()
          Creates secondary handles.
protected abstract  void disconnect()
          Disconnects the connection.
 void draw(java.awt.Graphics2D g)
          Draws this handle.
protected  Connector findConnector(java.awt.geom.Point2D.Double p, Figure f, ConnectionFigure prototype)
           
protected  BezierFigure getBezierFigure()
           
protected  BezierPath.Node getBezierNode()
           
protected abstract  int getBezierNodeIndex()
           
protected abstract  java.awt.geom.Point2D.Double getLocation()
          Returns the start point of the connection.
 ConnectionFigure getOwner()
          Returns the owner of this handle.
protected  Connector getSource()
          Gets the side of the connection that is unaffected by the change.
protected abstract  Connector getTarget()
          Returns the connector of the change.
 java.lang.String getToolTipText(java.awt.Point p)
          Returns a tooltip for the specified location.
 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 abstract  void setLocation(java.awt.geom.Point2D.Double p)
          Sets the location of the connectableConnector point.
protected  void setPotentialTarget(Connector newTarget)
           
 void trackEnd(java.awt.Point anchor, java.awt.Point lead, int modifiersEx)
          Connects the figure to the new connectableConnector.
 void trackStart(java.awt.Point anchor, int modifiersEx)
          Disconnects the connection.
 void trackStep(java.awt.Point anchor, java.awt.Point lead, int modifiersEx)
          Finds a new connectableConnector of the connection.
 
Methods inherited from class org.jhotdraw.draw.handle.AbstractHandle
addHandleListener, areaInvalidated, attributeChanged, contains, dispose, drawCircle, drawDiamond, drawRectangle, figureAdded, figureChanged, figureHandlesChanged, figureRemoved, figureRequestRemove, fireAreaInvalidated, fireHandleRequestRemove, fireHandleRequestSecondaryHandles, fireUndoableEditHappened, getBounds, getCursor, getDrawingArea, getEditor, getHandlesize, 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

connectors

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

Constructor Detail

AbstractConnectionHandle

protected AbstractConnectionHandle(ConnectionFigure owner)
Initializes the change connection handle.

Method Detail

getOwner

public ConnectionFigure getOwner()
Description copied from interface: Handle
Returns the owner of this handle.

Specified by:
getOwner in interface Handle
Overrides:
getOwner 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

getTarget

protected abstract Connector getTarget()
Returns the connector of the change.


disconnect

protected abstract void disconnect()
Disconnects the connection.


connect

protected abstract void connect(Connector c)
Connect the connection with the given figure.


setLocation

protected abstract void setLocation(java.awt.geom.Point2D.Double p)
Sets the location of the connectableConnector point.


getLocation

protected abstract java.awt.geom.Point2D.Double getLocation()
Returns the start point of the connection.


getSource

protected Connector getSource()
Gets the side of the connection that is unaffected by the change.


trackStart

public void trackStart(java.awt.Point anchor,
                       int modifiersEx)
Disconnects the connection.

Parameters:
anchor - the position where the interaction started

trackStep

public void trackStep(java.awt.Point anchor,
                      java.awt.Point lead,
                      int modifiersEx)
Finds a new connectableConnector of the connection.

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

trackEnd

public void trackEnd(java.awt.Point anchor,
                     java.awt.Point lead,
                     int modifiersEx)
Connects the figure to the new connectableConnector. If there is no new connectableConnector the connection reverts to its original one.

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

canConnect

protected abstract boolean canConnect(Connector existingEnd,
                                      Connector targetEnd)

findConnector

protected Connector findConnector(java.awt.geom.Point2D.Double p,
                                  Figure f,
                                  ConnectionFigure prototype)

draw

public void draw(java.awt.Graphics2D g)
Draws this handle.

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

setPotentialTarget

protected void setPotentialTarget(Connector newTarget)

basicGetBounds

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

getBezierFigure

protected BezierFigure getBezierFigure()

getBezierNodeIndex

protected abstract int getBezierNodeIndex()

createSecondaryHandles

public final java.util.Collection<Handle> createSecondaryHandles()
Description copied from interface: Handle
Creates secondary handles.

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

getBezierNode

protected BezierPath.Node getBezierNode()

getToolTipText

public java.lang.String getToolTipText(java.awt.Point p)
Description copied from class: AbstractHandle
Returns a tooltip for the specified location. By default, AbstractHandle returns null.

Specified by:
getToolTipText in interface Handle
Overrides:
getToolTipText 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.


Copyright 1996-2010 (c) by the authors and contributors of the JHotDraw project.
Some rights reserved.