y.view
Class MoveLabelMode

java.lang.Object
  extended by y.view.ViewMode
      extended by y.view.MoveLabelMode
All Implemented Interfaces:
MouseListener, MouseMotionListener, EventListener, MouseInputListener

public class MoveLabelMode
extends ViewMode

This view mode allows interactive reassignment of label positions.

A label can be moved to another position by pressing with the left mouse button on it and then by dragging the label around. While dragging label candidate boxes will appear. These boxes mark the positions that are available for the label. the set of available label positions depend on the LabelModel that is associated which the label. The move terminates it's action when the mouse is released again. The label will then automatically snap to the closest available label position.

 

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
MoveLabelMode()
          Instantiates a new MoveLabelMode
MoveLabelMode(ViewContainer view)
          Instantiates a new MoveLabelMode for a given ViewContainer
 
Method Summary
 void cancelEditing()
          This can be used to cleanly exit an edit that is currently in progress.
 void init()
          Called when this mode gets activeted.
 void mouseDraggedLeft(double x, double y)
          Moves the label.
 void mousePressedLeft(double x, double y)
          Initiates the movement of a hit label.
 void mouseReleasedLeft(double x, double y)
          Terminates the movement of a label.
protected  void selectionMovedAction(double dx, double dy, double x, double y)
          Performs an action after the selection was moved.
 
Methods inherited from class y.view.ViewMode
activate, addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, getChild, getGraph2D, getGridX, getGridY, getHitInfo, getHitInfo, getLastHitInfo, getModifierMask, getName, getParent, isActive, isEditing, isGrabFocusEnabled, isGridMode, isModifierPressed, mouseClicked, mouseClicked, mouseDragged, mouseDraggedMiddle, mouseDraggedRight, mouseEntered, mouseExited, mouseMoved, mouseMoved, mousePressed, mousePressedMiddle, mousePressedRight, mouseReleased, mouseReleased, mouseReleasedMiddle, mouseReleasedRight, mouseShiftPressedLeft, mouseShiftPressedMiddle, mouseShiftPressedRight, mouseShiftReleasedLeft, 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

MoveLabelMode

public MoveLabelMode(ViewContainer view)
Instantiates a new MoveLabelMode for a given ViewContainer


MoveLabelMode

public MoveLabelMode()
Instantiates a new MoveLabelMode

Method Detail

init

public void init()
Called when this mode gets activeted. This method WILL PROBABLY VANISH.

Overrides:
init in class ViewMode
See Also:
ViewMode.setChild(ViewMode,MouseEvent,MouseEvent)

mousePressedLeft

public void mousePressedLeft(double x,
                             double y)
Initiates the movement of a hit label.

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.

mouseReleasedLeft

public void mouseReleasedLeft(double x,
                              double y)
Terminates the movement of a label. The label will snap from it's current position to the closest available candidate box.

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 label.

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.

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.


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 "canceling" 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 canceled for any reason.

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