JHotDraw 7.1

org.jhotdraw.draw
Class AbstractConnectionHandle

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

public abstract class AbstractConnectionHandle
extends AbstractHandle

AbstractConnectionHandle factors the common code for handles that can be used to change the connection of a ConnectionFigure. XXX - Undo/Redo is not implemented yet.

Version:
3.0 2007-05-18 Changed due to changes in the canConnect methods of the ConnectionFigure interface. Shortened the name from AbstractChangeConnectionHandle to AbstractConnectionHandle.
2.1 2006-02-16 Remove savedLiner from connection while tracking.
2.0 2006-01-14 Changed to support double coordinates.
1.0 2003-12-01 Derived from JHotDraw 5.4b1.
Author:
Werner Randelshofer

Field Summary
protected  java.util.Collection<Connector> connectors
          All connectors of the connectable Figure.
 
Fields inherited from class org.jhotdraw.draw.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.AbstractHandle
addHandleListener, areaInvalidated, attributeChanged, contains, dispose, drawCircle, drawDiamond, drawRectangle, figureAdded, figureChanged, figureHandlesChanged, figureRemoved, figureRequestRemove, fireAreaInvalidated, fireHandleRequestRemove, fireHandleRequestSecondaryHandles, fireUndoableEditHappened, getBounds, getCursor, getDrawingArea, getHandlesize, getView, invalidate, keyPressed, keyReleased, keyTyped, removeHandleListener, 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 interface: Handle
Returns a tooltip for the specified location.

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-2007 (c) JHotDraw.org.
Some rights reserved.