org.openbp.cockpit.modeler.tools
Class XConnectionTool

java.lang.Object
  extended by org.openbp.cockpit.modeler.tools.ModelerTool
      extended by org.openbp.cockpit.modeler.tools.XConnectionTool
Direct Known Subclasses:
FlowConnectionTool, ParamConnectionTool

public abstract class XConnectionTool
extends ModelerTool

The connection tool can be used to connect figures, to split connections, and to join two segments of a connection. The connection tool turns the visibility of the connectors on when it enters a figure. The connection object to be created is specified by a prototype.

Author:
Stephan Pauxberger

Nested Class Summary
 class XConnectionTool.CanConnectDecorator
          Decorator that paints figures we can connect to in green.
 
Constructor Summary
XConnectionTool(ModelerToolSupport toolSupport)
           
 
Method Summary
 void activate()
           
 boolean appliesTo(java.lang.Object affectedObject)
          Checks if the tool can be applied to the given figure.
 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  PolySplineConnection createConnection()
          Creates the connection figure.
 void deactivate()
           
protected  CH.ifa.draw.framework.Figure findConnectableFigure(int x, int y, CH.ifa.draw.framework.Drawing drawing)
          Finds a figure we can connect to at the given position.
protected  CH.ifa.draw.framework.Figure findConnectionStart(int x, int y, CH.ifa.draw.framework.Drawing drawing)
          Finds a connection start figure at the given position.
protected  CH.ifa.draw.framework.Connector findConnector(int x, int y, CH.ifa.draw.framework.Figure figure)
          Finds a connector of the given figure at the given position.
protected  CH.ifa.draw.framework.Figure findSourceFigure(int x, int y, CH.ifa.draw.framework.Drawing drawing)
          Finds a connectable figure as source at the given position.
protected  CH.ifa.draw.framework.Figure findTargetFigure(int x, int y, CH.ifa.draw.framework.Drawing drawing)
          Finds a connectable figure as target at the given position.
 void mouseDown(java.awt.event.MouseEvent e, int x, int y)
           
 void mouseDrag(java.awt.event.MouseEvent e, int x, int y)
           
 void mouseMove(java.awt.event.MouseEvent e, int x, int y)
           
 void mouseUp(java.awt.event.MouseEvent e, int x, int y)
           
protected  void trackConnectors(java.awt.event.MouseEvent e, int x, int y)
          Tracks connectors.
 
Methods inherited from class org.openbp.cockpit.modeler.tools.ModelerTool
getAffectedFigure, getAffectedObject, getDrawing, getEditor, getLastPoint, getToolCursor, getToolHintMsg, getToolSupport, getView, keyDown, keyUp, setAffectedObject, setToolCursor, setToolHintMsg
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XConnectionTool

public XConnectionTool(ModelerToolSupport toolSupport)
Method Detail

appliesTo

public boolean appliesTo(java.lang.Object affectedObject)
Checks if the tool can be applied to the given figure.

Overrides:
appliesTo in class ModelerTool
Parameters:
affectedObject - Object the cursor is over
Returns:
true if the tool is suitable for the figure

activate

public void activate()
Overrides:
activate in class ModelerTool

deactivate

public void deactivate()
Overrides:
deactivate in class ModelerTool

mouseDown

public void mouseDown(java.awt.event.MouseEvent e,
                      int x,
                      int y)
Overrides:
mouseDown in class ModelerTool

mouseDrag

public void mouseDrag(java.awt.event.MouseEvent e,
                      int x,
                      int y)
Overrides:
mouseDrag in class ModelerTool

mouseUp

public void mouseUp(java.awt.event.MouseEvent e,
                    int x,
                    int y)
Overrides:
mouseUp in class ModelerTool

mouseMove

public void mouseMove(java.awt.event.MouseEvent e,
                      int x,
                      int y)
Overrides:
mouseMove in class ModelerTool

createConnection

protected abstract PolySplineConnection createConnection()
Creates the connection figure.

Returns:
The prototype

trackConnectors

protected void trackConnectors(java.awt.event.MouseEvent e,
                               int x,
                               int y)
Tracks connectors.

Parameters:
e - Mouse event which should be interpreted
x - Document coordinate
y - Document coordinate

findSourceFigure

protected CH.ifa.draw.framework.Figure findSourceFigure(int x,
                                                        int y,
                                                        CH.ifa.draw.framework.Drawing drawing)
Finds a connectable figure as source at the given position.

Parameters:
x - Document coordinate
y - Document coordinate
drawing - Drawing we operate on
Returns:
The figure or null

findTargetFigure

protected CH.ifa.draw.framework.Figure findTargetFigure(int x,
                                                        int y,
                                                        CH.ifa.draw.framework.Drawing drawing)
Finds a connectable figure as target at the given position.

Parameters:
x - Document coordinate
y - Document coordinate
drawing - Drawing we operate on
Returns:
The figure or null

findConnectionStart

protected CH.ifa.draw.framework.Figure findConnectionStart(int x,
                                                           int y,
                                                           CH.ifa.draw.framework.Drawing drawing)
Finds a connection start figure at the given position.

Parameters:
x - Document coordinate
y - Document coordinate
drawing - Drawing we operate on
Returns:
The figure or null

findConnectableFigure

protected CH.ifa.draw.framework.Figure findConnectableFigure(int x,
                                                             int y,
                                                             CH.ifa.draw.framework.Drawing drawing)
Finds a figure we can connect to at the given position.

Parameters:
x - Document coordinate
y - Document coordinate
drawing - Drawing we operate on
Returns:
The figure or null

findConnector

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

Parameters:
x - Document coordinate
y - Document coordinate
figure - Figure to search
Returns:
The connector or null

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.