Class BendpointEditPolicy

All Implemented Interfaces:
PropertyChangeListener, EventListener, IAdaptable, EditPolicy, RequestConstants

public abstract class BendpointEditPolicy extends SelectionHandlesEditPolicy implements PropertyChangeListener
Used to add bendpoint handles on a ConnectionEditPart.

BendpointEditPolicy will automatically observe the Connection figure. If the number of bends in the Connection changes, the handles will be updated.

  • Constructor Details

    • BendpointEditPolicy

      public BendpointEditPolicy()
  • Method Details

    • activate

      public void activate()
      activate() is extended to add a listener to the Connection figure.
      Specified by:
      activate in interface EditPolicy
      Overrides:
      activate in class SelectionEditPolicy
      See Also:
    • 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.
      Specified by:
      createSelectionHandles in class SelectionHandlesEditPolicy
      Returns:
      List of handles; cannot be null
      See Also:
    • deactivate

      public void deactivate()
      deactivate() is extended to remove the property change listener on the Connection figure.
      Specified by:
      deactivate in interface EditPolicy
      Overrides:
      deactivate in class SelectionEditPolicy
      See Also:
    • eraseConnectionFeedback

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

      public void eraseSourceFeedback(Request request)
      Description copied from class: AbstractEditPolicy
      Does nothing by default.
      Specified by:
      eraseSourceFeedback in interface EditPolicy
      Overrides:
      eraseSourceFeedback in class AbstractEditPolicy
      Parameters:
      request - the Request
      See Also:
    • getCommand

      public Command getCommand(Request request)
      Factors the Request into either a MOVE, a DELETE, or a CREATE of a bendpoint.
      Specified by:
      getCommand in interface EditPolicy
      Overrides:
      getCommand in class AbstractEditPolicy
      Parameters:
      request - the Request
      Returns:
      null or a Command contribution
      See Also:
    • getConnection

      protected Connection getConnection()
      Convenience method for obtaining the host's Connection figure.
      Returns:
      the Connection figure
    • getCreateBendpointCommand

      protected abstract Command getCreateBendpointCommand(BendpointRequest request)
      Implement this method to return a Command that will create a bendpoint.
      Parameters:
      request - the BendpointRequest
      Returns:
      a Command to create a bendpoint
    • getDeleteBendpointCommand

      protected abstract Command getDeleteBendpointCommand(BendpointRequest request)
      Implement this method to return a Command that will delete a bendpoint.
      Parameters:
      request - the BendpointRequest
      Returns:
      a Command to delete a bendpoint
    • getHost

      public ConnectionEditPart getHost()
      Description copied from class: GraphicalEditPolicy
      Cast the parent getHost to GraphicalEditPart This reduces the necessary cast operations in this and all child classes as well as in any users of a GraphicalEditPolicy.
      Specified by:
      getHost in interface EditPolicy
      Overrides:
      getHost in class GraphicalEditPolicy
      Returns:
      the host EditPart on which this policy is installed.
      Since:
      3.17
      See Also:
    • getMoveBendpointCommand

      protected abstract Command getMoveBendpointCommand(BendpointRequest request)
      Implement this method to return a Command that will move a bendpoint.
      Parameters:
      request - the BendpointRequest
      Returns:
      a Command to move a bendpoint
    • propertyChange

      public void propertyChange(PropertyChangeEvent evt)
      If the number of bendpoints changes, handles are updated.
      Specified by:
      propertyChange in interface PropertyChangeListener
      See Also:
    • 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.
      Parameters:
      request - the BendpointRequest
    • 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.
      Parameters:
      request - the BendpointRequest
    • 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.
      Parameters:
      request - the BendpointRequest
    • showSourceFeedback

      public void showSourceFeedback(Request request)
      Shows feedback when appropriate. Calls a different method depending on the request type.
      Specified by:
      showSourceFeedback in interface EditPolicy
      Overrides:
      showSourceFeedback in class AbstractEditPolicy
      Parameters:
      request - the Request
      See Also: