y.view
Class MoveSelectionMode

java.lang.Object
  extended by y.view.ViewMode
      extended by y.view.MoveSelectionMode
All Implemented Interfaces:
MouseListener, MouseMotionListener, EventListener, MouseInputListener
Direct Known Subclasses:
HierarchyMoveSelectionMode, PortAssignmentMoveSelectionMode

public class MoveSelectionMode
extends ViewMode

This view mode is responsible for moving selected parts of the displayed graph. On a left press this mode starts to move selected graph elements around. While the mouse is being dragged the selected parts will be moved around. If the mouse gets released the operation will end and all registered views will receive an update event.

 

Field Summary
 
Fields inherited from class y.view.ViewMode
ACTIVE_PROPERTY, ACTIVE_VIEW_PROPERTY, CHILD_MODE_PROPERTY, EDITING_PROPERTY, GRAB_FOCUS_ENABLED_PROPERTY, lastClickEvent, lastDragEvent, lastMoveEvent, lastPressEvent, lastReleaseEvent, MODIFIER_MASK_PROPERTY, NAME_PROPERTY, originalX, originalY, PARENT_MODE_PROPERTY, view
 
Constructor Summary
MoveSelectionMode()
          Initializes a new MoveSelectionMode.
MoveSelectionMode(ViewContainer view)
          Initializes a new MoveSelectionMode for a given ViewContainer
 
Method Summary
 void activate(boolean b)
          Invoked when the Mode is activated/deactivated from the ViewControl or via the setChild() and reactivateParent operations This behaves like a bound property using ViewMode.ACTIVE_PROPERTY as the property name.
 void cancelEditing()
          This can be used to cleanly exit an edit that is currently in progress.
protected  BendList getBendsToBeMoved()
          Returns the bends that should will be moved by this view mode.
protected  NodeList getNodesToBeMoved()
          Returns the nodes that should will be moved by this view mode.
protected  boolean isOrthogonalRouting(Edge edge)
          Determines whether the given edge instance should be routed orthogonally.
 void mouseDraggedLeft(double x, double y)
          Moves the selected graph elements around.
 void mousePressedLeft(double x, double y)
          Initiates the movement of the selected graph elements.
 void mouseReleasedLeft(double x, double y)
          Terminates the movements of the selected graph elements.
 void mouseShiftPressedLeft(double x, double y)
          Initiates the movement of the selected graph elements.
 void mouseShiftReleasedLeft(double x, double y)
          Terminates the movements of the selected graph elements.
protected  void selectionMovedAction(double dx, double dy, double x, double y)
          Performs an action after the selection was moved.
protected  void selectionMoveStarted(double x, double y)
          Performs an action when the selection is about to be moved.
protected  void selectionOnMove(double dx, double dy, double x, double y)
          Performs an action when the selection is moving.
 
Methods inherited from class y.view.ViewMode
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, getChild, getGraph2D, getGridX, getGridY, getHitInfo, getHitInfo, getLastHitInfo, getModifierMask, getName, getParent, init, isActive, isEditing, isGrabFocusEnabled, isGridMode, isModifierPressed, mouseClicked, mouseClicked, mouseDragged, mouseDraggedMiddle, mouseDraggedRight, mouseEntered, mouseExited, mouseMoved, mouseMoved, mousePressed, mousePressedMiddle, mousePressedRight, mouseReleased, mouseReleased, mouseReleasedMiddle, mouseReleasedRight, mouseShiftPressedMiddle, mouseShiftPressedRight, mouseShiftReleasedMiddle, mouseShiftReleasedRight, reactivateParent, removePropertyChangeListener, removePropertyChangeListener, setActiveView, setChild, setChild, setEditing, setGrabFocusEnabled, setGridMode, setLastHitInfo, setModifierMask, setName, setParent, translateX, translateY
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MoveSelectionMode

public MoveSelectionMode(ViewContainer view)
Initializes a new MoveSelectionMode for a given ViewContainer


MoveSelectionMode

public MoveSelectionMode()
Initializes a new MoveSelectionMode.

Method Detail

activate

public void activate(boolean b)
Description copied from class: ViewMode
Invoked when the Mode is activated/deactivated from the ViewControl or via the setChild() and reactivateParent operations This behaves like a bound property using ViewMode.ACTIVE_PROPERTY as the property name.

Overrides:
activate in class ViewMode
Parameters:
b - set true when mode was activated false otherwise

mouseShiftPressedLeft

public void mouseShiftPressedLeft(double x,
                                  double y)
Initiates the movement of the selected graph elements.

Overrides:
mouseShiftPressedLeft in class ViewMode
Parameters:
x - the x-coordinate of the mouse event in world coordinates.
y - the y-coordinate of the mouse event in world coordinates.

mousePressedLeft

public void mousePressedLeft(double x,
                             double y)
Initiates the movement of the selected graph elements.

Overrides:
mousePressedLeft in class ViewMode
Parameters:
x - the x-coordinate of the mouse event in world coordinates.
y - the y-coordinate of the mouse event in world coordinates.

mouseShiftReleasedLeft

public void mouseShiftReleasedLeft(double x,
                                   double y)
Terminates the movements of the selected graph elements.

Overrides:
mouseShiftReleasedLeft in class ViewMode
Parameters:
x - the x-coordinate of the mouse event in world coordinates.
y - the y-coordinate of the mouse event in world coordinates.

mouseReleasedLeft

public void mouseReleasedLeft(double x,
                              double y)
Terminates the movements of the selected graph elements.

Overrides:
mouseReleasedLeft in class ViewMode
Parameters:
x - the x-coordinate of the mouse event in world coordinates.
y - the y-coordinate of the mouse event in world coordinates.

mouseDraggedLeft

public void mouseDraggedLeft(double x,
                             double y)
Moves the selected graph elements around.

Overrides:
mouseDraggedLeft in class ViewMode
Parameters:
x - the x-coordinate of the mouse event in world coordinates.
y - the y-coordinate of the mouse event in world coordinates.

selectionMoveStarted

protected void selectionMoveStarted(double x,
                                    double y)
Performs an action when the selection is about to be moved. By default this method does nothing. Subclasses may want to override this.


selectionOnMove

protected void selectionOnMove(double dx,
                               double dy,
                               double x,
                               double y)
Performs an action when the selection is moving. By default this method does nothing. Subclasses may want to override this.


selectionMovedAction

protected void selectionMovedAction(double dx,
                                    double dy,
                                    double x,
                                    double y)
Performs an action after the selection was moved. By default this method does nothing. Subclasses may want to override this.


getNodesToBeMoved

protected NodeList getNodesToBeMoved()
Returns the nodes that should will be moved by this view mode. By default the selected nodes of the graph will be returned.


getBendsToBeMoved

protected BendList getBendsToBeMoved()
Returns the bends that should will be moved by this view mode. By default the selected bends of the graph will be returned.


isOrthogonalRouting

protected boolean isOrthogonalRouting(Edge edge)
Determines whether the given edge instance should be routed orthogonally. This implementation uses the DataProvider bound to the current graph via the EditMode.ORTHOGONAL_ROUTING_DPKEY data provider key to determine whether the given edge should be routed orthogonally.

Parameters:
edge - the edge to decide
Returns:
true if the edge should be routed orthogonally.
See Also:
EditMode.isOrthogonalRouting(y.base.Edge)

cancelEditing

public void cancelEditing()
                   throws UnsupportedOperationException
Description copied from class: ViewMode
This can be used to cleanly exit an edit that is currently in progress.
The implementation and interpretation of "cancelling" is left to subclasses. This implementation does nothing but calls setEditing(false) if ViewMode.isEditing() returns true

Overrides:
cancelEditing in class ViewMode
Throws:
UnsupportedOperationException - if the editing cannot be cancelled for any reason.

© Copyright 2000-2008,
yWorks GmbH.
All rights reserved.