y.view
Class HotSpotMode

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

public class HotSpotMode
extends ViewMode

Handles hotspot drags. Causes selected nodes to change their size. when the user drags on a hot spot visible around such a node.

The mode is activated when the mouse is moved over an hotspot point. It changes the mouse-cursor according to the hotspot point. In this state the HotSpotMode is *inactive*. When the left mouse button is pressed it goes into *active* mode.

 

Field Summary
static byte BLOCK_UPON_MINIMUM_SIZE
          Resize policy specifier.
static byte FLIP_SIDES_UPON_MINIMUM_SIZE
          Resize policy specifier.
static byte SEMI_BLOCK_UPON_MINIMUM_SIZE
          Resize policy specifier.
 
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
HotSpotMode()
          Instantiates a new HotSportMode.
HotSpotMode(ViewContainer vc)
          Instantiates a new HotSpotMode for a given ViewContainer
 
Method Summary
protected  void adjustPortOffsets(Graph2D graph, Node node, double wOld, double hOld, double wNew, double hNew)
          Callback method that adjusts the ports of a NodeRealizer after that NodeRealizer's bounds have been changed.
 void cancelEditing()
          This can be used to cleanly exit an edit that is currently in progress.
static Cursor getCursor(byte hotSpotType)
          Returns a suitable cursor for the given hotSpotType.
 byte getResizePolicy()
          Returns the resize policy employed when dragging at a hotspot of a node.
protected  boolean isOrthogonalRouting(Edge edge)
          Determines whether the given edge instance should be routed orthogonally.
 void mouseDraggedLeft(double x, double y)
          Resizes selected nodes.
 void mousePressedLeft(double x, double y)
          Initiates resizing of selected nodes.
 void mouseReleasedLeft(double x, double y)
          Terminates resizing of selected nodes.
 void setResizePolicy(byte policy)
          Sets the resize policy employed when dragging at a hotspot of a node.
protected  void updateNodeRealizerBounds(NodeRealizer vr, double x, double y, double w, double h)
          This method will be invoked by this view mode when the current bounds of a node need to be updated.
 
Methods inherited from class y.view.ViewMode
activate, 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, 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
 

Field Detail

SEMI_BLOCK_UPON_MINIMUM_SIZE

public static final byte SEMI_BLOCK_UPON_MINIMUM_SIZE
Resize policy specifier. Unless a node has not yet reached minimum size, each drag gesture will cause the node to change its size. With this policy the mouse location can easily get out of sync with the active hotspot of a node.

See Also:
setResizePolicy(byte), Constant Field Values

BLOCK_UPON_MINIMUM_SIZE

public static final byte BLOCK_UPON_MINIMUM_SIZE
Resize policy specifier. Resizes the nodes until a minimum size is reached. Resizing will be blocked whenever the mouse location is out of sync with the hotspot location.

See Also:
setResizePolicy(byte), Constant Field Values

FLIP_SIDES_UPON_MINIMUM_SIZE

public static final byte FLIP_SIDES_UPON_MINIMUM_SIZE
Resize policy specifier. When the minimum size of a node is reached, the sides of the nodes will be exchanged so that the size of the node grows again.

See Also:
setResizePolicy(byte), Constant Field Values
Constructor Detail

HotSpotMode

public HotSpotMode(ViewContainer vc)
Instantiates a new HotSpotMode for a given ViewContainer


HotSpotMode

public HotSpotMode()
Instantiates a new HotSportMode.

Method Detail

setResizePolicy

public void setResizePolicy(byte policy)
Sets the resize policy employed when dragging at a hotspot of a node.

Parameters:
policy - one of SEMI_BLOCK_UPON_MINIMUM_SIZE, BLOCK_UPON_MINIMUM_SIZE or FLIP_SIDES_UPON_MINIMUM_SIZE. by default SEMI_BLOCK_UPON_MINIMUM_SIZE is set.

getResizePolicy

public byte getResizePolicy()
Returns the resize policy employed when dragging at a hotspot of a node.

Returns:
the currently set resize policy
See Also:
setResizePolicy(byte)

mousePressedLeft

public void mousePressedLeft(double x,
                             double y)
Initiates resizing of selected nodes.

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.

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)

mouseDraggedLeft

public void mouseDraggedLeft(double x,
                             double y)
Resizes selected nodes. Calls updateNodeRealizerBounds(NodeRealizer, double, double, double, double) and adjustPortOffsets(Graph2D, y.base.Node, double, double, double, double) for each node that is being resized.

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.

adjustPortOffsets

protected void adjustPortOffsets(Graph2D graph,
                                 Node node,
                                 double wOld,
                                 double hOld,
                                 double wNew,
                                 double hNew)
Callback method that adjusts the ports of a NodeRealizer after that NodeRealizer's bounds have been changed.

Parameters:
graph - the graph that contains the node
node - the node whose ports shall be adjusted
wOld - the old width
hOld - the old height
wNew - the new width
hNew - the new height

updateNodeRealizerBounds

protected void updateNodeRealizerBounds(NodeRealizer vr,
                                        double x,
                                        double y,
                                        double w,
                                        double h)
This method will be invoked by this view mode when the current bounds of a node need to be updated.

Parameters:
vr - the realizer of the node whose bounds shoud change.
x - the desired x-coordinate of the node bounds.
y - the desired y-coordinate of the node bounds.
w - the desired width of the node.
h - the desired height of the node.

mouseReleasedLeft

public void mouseReleasedLeft(double x,
                              double y)
Terminates resizing of selected nodes.

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.

getCursor

public static Cursor getCursor(byte hotSpotType)
Returns a suitable cursor for the given hotSpotType. The cursor indicates the kind of resize action that is being performed.


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.