GEF v2.0

org.eclipse.gef.editpolicies
Class BendpointEditPolicy

java.lang.Object
  |
  +--org.eclipse.gef.editpolicies.AbstractEditPolicy
        |
        +--org.eclipse.gef.editpolicies.GraphicalEditPolicy
              |
              +--org.eclipse.gef.editpolicies.SelectionEditPolicy
                    |
                    +--org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy
                          |
                          +--org.eclipse.gef.editpolicies.BendpointEditPolicy
All Implemented Interfaces:
EditPolicy, EventListener, IAdaptable, PropertyChangeListener, RequestConstants

public abstract class BendpointEditPolicy
extends SelectionHandlesEditPolicy
implements PropertyChangeListener

This EditPolicy defines the behavior of Bendpoints on a Connection.


Fields inherited from class org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy
handles
 
Fields inherited from interface org.eclipse.gef.EditPolicy
COMPONENT_ROLE, CONNECTION_BENDPOINTS_ROLE, CONNECTION_ENDPOINTS_ROLE, CONNECTION_ROLE, CONTAINER_ROLE, DIRECT_EDIT_ROLE, GRAPHICAL_NODE_ROLE, LAYOUT_ROLE, NODE_ROLE, PRIMARY_DRAG_ROLE, SELECTION_FEEDBACK_ROLE, TREE_CONTAINER_ROLE
 
Fields inherited from interface org.eclipse.gef.RequestConstants
REQ_ADD, REQ_ALIGN, REQ_ALIGN_CHILD, REQ_ALIGN_CHILDREN, REQ_ANCESTOR_DELETED, REQ_CONNECTION_END, REQ_CONNECTION_START, REQ_CREATE, REQ_CREATE_BENDPOINT, REQ_DELETE, REQ_DELETE_BENDPOINT, REQ_DELETE_DEPENDANT, REQ_DIRECT_EDIT, REQ_MOVE, REQ_MOVE_BENDPOINT, REQ_MOVE_CHILD, REQ_MOVE_CHILDREN, REQ_ORPHAN, REQ_ORPHAN_CHILDREN, REQ_RECONNECT_END, REQ_RECONNECT_SOURCE, REQ_RECONNECT_START, REQ_RECONNECT_TARGET, REQ_RESIZE, REQ_RESIZE_CHILD, REQ_RESIZE_CHILDREN, REQ_SELECTION, REQ_SELECTION_HOVER, REQ_SOURCE_DELETED, REQ_TARGET_DELETED
 
Constructor Summary
BendpointEditPolicy()
           
 
Method Summary
 void activate()
          Adds a PropertyChangeListener to the Connection so we can react to point changes in the connection.
protected  List createSelectionHandles()
          Creates selection handles for the bendpoints.
 void deactivate()
          Removes this from the Connection's list of PropertyChangeListeners.
protected  void eraseConnectionFeedback(BendpointRequest request)
          Erases bendpoint feedback.
 void eraseSourceFeedback(Request request)
          Erases feedback, when appropriate.
 Command getCommand(Request request)
          Returns the appropriate Command for the request type given.
protected  Connection getConnection()
          Returns the Connection associated with this EditPolicy.
protected abstract  Command getCreateBendpointCommand(BendpointRequest request)
          Implement this method to return a Command that will create a bendpoint.
protected abstract  Command getDeleteBendpointCommand(BendpointRequest request)
          Implement this method to return a Command that will delete a bendpoint.
protected abstract  Command getMoveBendpointCommand(BendpointRequest request)
          Implement this method to return a Command that will move a bendpoint.
 void propertyChange(PropertyChangeEvent evt)
          Adds selection handles to the Connection, if it is selected, when the points property changes.
protected  void restoreOriginalConstraint()
          Restores the original constraint that was saved before feedback began to show.
protected  void saveOriginalConstraint()
          Since the original figure is used for feedback, this method saves the original constraint, so that is can be restored when the feedback is erased.
protected  void showCreateBendpointFeedback(BendpointRequest request)
          Shows feedback when a bendpoint is being created.
protected  void showDeleteBendpointFeedback(BendpointRequest request)
          Shows feedback when a bendpoint is being deleted.
protected  void showMoveBendpointFeedback(BendpointRequest request)
          Shows feedback when a bendpoint is being moved.
 void showSourceFeedback(Request request)
          Shows feedback, when appropriate.
 
Methods inherited from class org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy
addSelectionHandles, getAdapter, hideSelection, removeSelectionHandles, showSelection
 
Methods inherited from class org.eclipse.gef.editpolicies.SelectionEditPolicy
addSelectionListener, getTargetEditPart, hideFocus, removeSelectionListener, setFocus, setSelectedState, showFocus, showPrimarySelection
 
Methods inherited from class org.eclipse.gef.editpolicies.GraphicalEditPolicy
addFeedback, getHostFigure, getLayer, removeFeedback
 
Methods inherited from class org.eclipse.gef.editpolicies.AbstractEditPolicy
debugFeedback, eraseTargetFeedback, getHost, initialize, setHost, showTargetFeedback, toString, understandsRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BendpointEditPolicy

public BendpointEditPolicy()
Method Detail

activate

public void activate()
Adds a PropertyChangeListener to the Connection so we can react to point changes in the connection.
Overrides:
activate in class SelectionEditPolicy
See Also:
SelectionEditPolicy.activate()

createSelectionHandles

protected List createSelectionHandles()
Creates selection handles for the bendpoints. Explicit (user-defined) bendpoints will have BendpointMoveHandles on them with a single BendpointCreationHandle between 2 consecutive explicit bendpoints. If implicit bendpoints (such as those created by the AutomaticRouter) are used, one BendpointCreationHandle is placed in the middle of the Connection.
Overrides:
createSelectionHandles in class SelectionHandlesEditPolicy

deactivate

public void deactivate()
Removes this from the Connection's list of PropertyChangeListeners.
Overrides:
deactivate in class SelectionEditPolicy
See Also:
SelectionEditPolicy.deactivate()

eraseConnectionFeedback

protected void eraseConnectionFeedback(BendpointRequest request)
Erases bendpoint feedback. Since the original figure is used for feedback, we just restore the original constraint that was saved before feedback started to show.

eraseSourceFeedback

public void eraseSourceFeedback(Request request)
Erases feedback, when appropriate.
Overrides:
eraseSourceFeedback in class AbstractEditPolicy
See Also:
eraseConnectionFeedback(BendpointRequest)

getCommand

public Command getCommand(Request request)
Returns the appropriate Command for the request type given. Handles creating, moving and deleting bendpoints. The actual creation of the command is taken care of by subclasses implementing the appropriate methods.
Overrides:
getCommand in class AbstractEditPolicy
See Also:
getCreateBendpointCommand(BendpointRequest), getMoveBendpointCommand(BendpointRequest), getDeleteBendpointCommand(BendpointRequest)

getConnection

protected Connection getConnection()
Returns the Connection associated with this EditPolicy.

getCreateBendpointCommand

protected abstract Command getCreateBendpointCommand(BendpointRequest request)
Implement this method to return a Command that will create a bendpoint.

getDeleteBendpointCommand

protected abstract Command getDeleteBendpointCommand(BendpointRequest request)
Implement this method to return a Command that will delete a bendpoint.

getMoveBendpointCommand

protected abstract Command getMoveBendpointCommand(BendpointRequest request)
Implement this method to return a Command that will move a bendpoint.

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Adds selection handles to the Connection, if it is selected, when the points property changes. Since we only listen for changes in the points property, this method is only called when the points of the Connection have changed.
Specified by:
propertyChange in interface PropertyChangeListener

restoreOriginalConstraint

protected void restoreOriginalConstraint()
Restores the original constraint that was saved before feedback began to show.

saveOriginalConstraint

protected void saveOriginalConstraint()
Since the original figure is used for feedback, this method saves the original constraint, so that is can be restored when the feedback is erased.

showCreateBendpointFeedback

protected void showCreateBendpointFeedback(BendpointRequest request)
Shows feedback when a bendpoint is being created. The original figure is used for feedback and the original constraint is saved, so that it can be restored when feedback is erased.

showDeleteBendpointFeedback

protected void showDeleteBendpointFeedback(BendpointRequest request)
Shows feedback when a bendpoint is being deleted. This method is only called once when the bendpoint is first deleted, not every mouse move. The original figure is used for feedback and the original constraint is saved, so that it can be restored when feedback is erased.

showMoveBendpointFeedback

protected void showMoveBendpointFeedback(BendpointRequest request)
Shows feedback when a bendpoint is being moved. Also checks to see if the bendpoint should be deleted and then calls showDeleteBendpointFeedback(BendpointRequest) if needed. The original figure is used for feedback and the original constraint is saved, so that it can be restored when feedback is erased.

showSourceFeedback

public void showSourceFeedback(Request request)
Shows feedback, when appropriate. Calls a different method depending on the request type.
Overrides:
showSourceFeedback in class AbstractEditPolicy
See Also:
showCreateBendpointFeedback(BendpointRequest), showMoveBendpointFeedback(BendpointRequest)

GEF v2.0