org.openbp.cockpit.modeler.figures.spline
Class ChangeConnectionHandle

java.lang.Object
  extended by CH.ifa.draw.standard.AbstractHandle
      extended by org.openbp.cockpit.modeler.figures.spline.ChangeConnectionHandle
All Implemented Interfaces:
CH.ifa.draw.framework.Handle
Direct Known Subclasses:
ChangeConnectionEndHandle, ChangeConnectionStartHandle

public abstract class ChangeConnectionHandle
extends CH.ifa.draw.standard.AbstractHandle

ChangeConnectionHandle factors the common code for handles that can be used to reconnect connections.

Author:
Stephan Moritz
See Also:
ChangeConnectionEndHandle, ChangeConnectionStartHandle

Nested Class Summary
 class ChangeConnectionHandle.CanConnectDecorator
          Decorator that decorates a figure if the source of the connection can connect to it with a transparent green overlay rectangle.
 
Field Summary
protected  PolySplineConnection connectionFigure
          Connection the handle belongs to
 
Fields inherited from class CH.ifa.draw.standard.AbstractHandle
HANDLESIZE
 
Constructor Summary
protected ChangeConnectionHandle(CH.ifa.draw.framework.Figure owner)
          Initializes the change connection handle.
 
Method Summary
 boolean canLinkFigures(CH.ifa.draw.framework.Figure start, CH.ifa.draw.framework.Figure target)
          Checks if two figures can be connected using a control link.
protected abstract  void connect(CH.ifa.draw.framework.Connector c)
          Connect the spline with the given figure.
protected abstract  void disconnect()
          Disconnects the connection.
 void draw(java.awt.Graphics g)
           
protected  CH.ifa.draw.framework.Connector findConnector(int x, int y, CH.ifa.draw.framework.Figure figure)
          Finds a connection target of the given figure at the given position.
 void invokeEnd(int x, int y, int anchorX, int anchorY, CH.ifa.draw.framework.DrawingView view)
          Connects the figure to the new target.
 void invokeStart(int x, int y, CH.ifa.draw.framework.DrawingView view)
          Disconnects the connection.
 void invokeStep(int x, int y, int anchorX, int anchorY, CH.ifa.draw.framework.DrawingView view)
          Finds a new target of the connection.
protected abstract  void setPoint(int x, int y)
          Sets the location of the target point.
protected  CH.ifa.draw.framework.Connector source()
          Gets the side of the connection that is unaffected by the change.
protected abstract  CH.ifa.draw.framework.Connector target()
          Returns the target connector of the change.
 
Methods inherited from class CH.ifa.draw.standard.AbstractHandle
containsPoint, displayBox, getUndoActivity, invokeEnd, invokeStart, invokeStep, locate, owner, setUndoActivity
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

connectionFigure

protected PolySplineConnection connectionFigure
Connection the handle belongs to

Constructor Detail

ChangeConnectionHandle

protected ChangeConnectionHandle(CH.ifa.draw.framework.Figure owner)
Initializes the change connection handle.

Parameters:
owner - Owner figure of the handle
Method Detail

disconnect

protected abstract void disconnect()
Disconnects the connection.


connect

protected abstract void connect(CH.ifa.draw.framework.Connector c)
Connect the spline with the given figure.

Parameters:
c - Connector of the figure to connect to

setPoint

protected abstract void setPoint(int x,
                                 int y)
Sets the location of the target point.

Parameters:
x - Document coordinate
y - Document coordinate

target

protected abstract CH.ifa.draw.framework.Connector target()
Returns the target connector of the change.


source

protected CH.ifa.draw.framework.Connector source()
Gets the side of the connection that is unaffected by the change.


invokeStart

public void invokeStart(int x,
                        int y,
                        CH.ifa.draw.framework.DrawingView view)
Disconnects the connection.

Specified by:
invokeStart in interface CH.ifa.draw.framework.Handle
Overrides:
invokeStart in class CH.ifa.draw.standard.AbstractHandle
Parameters:
x - Document coordinate
y - Document coordinate
view - View to draw on
See Also:
AbstractHandle.invokeStart(int x, int y, DrawingView view)

invokeStep

public void invokeStep(int x,
                       int y,
                       int anchorX,
                       int anchorY,
                       CH.ifa.draw.framework.DrawingView view)
Finds a new target of the connection.

Specified by:
invokeStep in interface CH.ifa.draw.framework.Handle
Overrides:
invokeStep in class CH.ifa.draw.standard.AbstractHandle
Parameters:
x - Document coordinate
y - Document coordinate
anchorX - Document coordinate of the anchor point of the handle
anchorY - Document coordinate of the anchor point of the handle
view - View to draw on
See Also:
AbstractHandle.invokeStep(int x, int y, int anchorX, int anchorY, DrawingView view)

invokeEnd

public void invokeEnd(int x,
                      int y,
                      int anchorX,
                      int anchorY,
                      CH.ifa.draw.framework.DrawingView view)
Connects the figure to the new target. If there is no new target the connection reverts to its original one.

Specified by:
invokeEnd in interface CH.ifa.draw.framework.Handle
Overrides:
invokeEnd in class CH.ifa.draw.standard.AbstractHandle
Parameters:
x - Document coordinate
y - Document coordinate
anchorX - Document coordinate of the anchor point of the handle
anchorY - Document coordinate of the anchor point of the handle
view - View to draw on
See Also:
AbstractHandle.invokeEnd(int x, int y, int anchorX, int anchorY, DrawingView view)

findConnector

protected CH.ifa.draw.framework.Connector findConnector(int x,
                                                        int y,
                                                        CH.ifa.draw.framework.Figure figure)
Finds a connection target of the given figure at the given position.

Parameters:
x - Document coordinate
y - Document coordinate
figure - Figure to search
Returns:
The connector of the target or null if there is none at this position

draw

public void draw(java.awt.Graphics g)
Specified by:
draw in interface CH.ifa.draw.framework.Handle
Overrides:
draw in class CH.ifa.draw.standard.AbstractHandle
See Also:
AbstractHandle.draw(Graphics g)

canLinkFigures

public boolean canLinkFigures(CH.ifa.draw.framework.Figure start,
                              CH.ifa.draw.framework.Figure target)
Checks if two figures can be connected using a control link. In case of parameter figures, the method will check if the data types expected/returned by the parameters are compatible. If the CTRL key is pressed, this check will be omitted. This is useful if the data link properties (source/target member path) need to be edited in order to make the figure data types compatible.

Parameters:
start - Start figure
target - Target figure
Returns:
true: The figures can be connected.
false: The figures can be connected.


Copyright © 2011. All Rights Reserved.