|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objecty.view.ViewMode
y.view.HotSpotMode
public class HotSpotMode
Handles hotspot drags. Causes selected nodes to change their size when the user drags one of the hotspots visible around such a node.
The mode is activated when the mouse is moved over a hotspot. It changes the mouse cursor according to the hotspot. In this state the HotSpotMode is *inactive*. When the left mouse button is pressed it goes into *active* mode.
This mode provides two modifiers to influence the resizing. The first one
(isModifierPressed(java.awt.event.MouseEvent)) determines whether
resizing shall keep the aspect ratio of the selected node(s). The second modifier
(isKeepNodeCenterModifierPressed(java.awt.event.MouseEvent)) determines whether
the selected node(s) shall keep their center locations when being resized.
Both can be used in conjunction.
![]() |
![]() |
![]() |
![]() |
| Field Summary | |
|---|---|
static byte |
BLOCK_UPON_MINIMUM_SIZE
Resize policy specifier. |
static byte |
DISCRETE_BLOCK_POLICY
Resize policy specifier. |
static byte |
FIXED_AUTOBOUNDS_INSETS
Group bounds policy specifier. |
static byte |
FIXED_MINIMUM_GROUP_BOUNDS
Group bounds policy specifier. |
static byte |
FLIP_SIDES_UPON_MINIMUM_SIZE
Resize policy specifier. |
static String |
NODE_CENTER_RESIZING_MODIFIER_MASK_PROPERTY
Property name constant used for PropertyChangeEvent.getPropertyName(). |
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 HotSpotMode. |
|
HotSpotMode(ViewContainer vc)
Instantiates a new HotSpotMode 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. |
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. |
protected void |
cancelNodeResize()
Calling this method cancels node resizing properly. |
protected HotSpotSnapContext |
createSnapContext()
Creates the MoveSnapContext that will be used by this instance to snap the mouse coordinates. |
int |
getCancelKeyCode()
Sets the virtual key code as defined in KeyEvent
which cancels the edge creation. |
static Cursor |
getCursor(byte hotSpotType)
Returns a suitable cursor for the given hotSpotType. |
int |
getDisableSnappingModifier()
Gets the modifier mask that can be used to determine whether
the user disables snapping via the snap context
temporarily. |
byte |
getGroupBoundsPolicy()
Returns the group bounds policy used when resizing the child nodes of a group. |
int |
getKeepNodeCenterModifierMask()
Gets the current modifierMask for the second modifier. |
byte |
getResizePolicy()
Returns the resize policy employed when dragging at a hotspot of a node. |
HotSpotSnapContext |
getSnapContext()
Gets the HotSpotSnapContext instance that can be used by this instance to
perform mouse snapping during the move operation if snapping is enabled. |
protected boolean |
isDisableSnappingModifierPressed(MouseEvent e)
Callback used by this mode to determine whether the modifier to disable snapping
has been currently pressed. |
protected boolean |
isKeepNodeCenterModifierPressed(MouseEvent me)
This method determines whether at the creation time of the given MouseEvent the modifier key was pressed. |
protected boolean |
isModifierPressed(MouseEvent me)
This method determines whether at the creation time of the given MouseEvent the modifier key was pressed. |
protected boolean |
isOrthogonalRouting(Edge edge)
Determines whether the given edge instance should be routed orthogonally. |
boolean |
isRemovingInnerBends()
Determines whether this instance should remove bends of edges adjacent to nodes that are contained in these nodes that have been resized during the resize operation
after the move is finished. |
boolean |
isSnappingEnabled()
Whether this mode should use the getSnapContext() to HotSpotSnapContext.adjustMouseCoordinates(y.geom.YPoint, byte, boolean, boolean)
adjust the mouse coordinates so that the resized items snap to the precalculated SnapLines. |
void |
mouseDraggedLeft(double x,
double y)
Resizes selected nodes. |
void |
mousePressedLeft(double x,
double y)
Initiates resizing of selected nodes. |
void |
mouseReleased(MouseEvent ev)
Perform additional cleanup. |
void |
mouseReleasedLeft(double x,
double y)
Terminates resizing of selected nodes. |
void |
reactivateParent()
The parent of this ViewMode is reactivated and this ViewMode is deactivated. |
void |
setCancelKeyCode(int cancelKeyCode)
Sets the virtual key code as defined in KeyEvent
which cancels the edge creation. |
void |
setDisableSnappingModifier(int disableSnappingModifier)
Sets the modifier mask that can be used to determine whether
the user disables snapping via the snap context
temporarily. |
void |
setGroupBoundsPolicy(byte groupBoundsPolicy)
Sets the group bounds policy used when resizing the child nodes of a group. |
void |
setKeepNodeCenterModifierMask(int modifierMask)
Sets the current modifierMask for the second modifier. |
void |
setRemovingInnerBends(boolean removingInnerBends)
Determines whether this instance should remove bends of edges adjacent to nodes that are contained in these nodes that have been resized during the resize operation
after the move is finished. |
void |
setResizePolicy(byte policy)
Sets the resize policy employed when dragging one of the hotspots of a selected node. |
void |
setSnapContext(HotSpotSnapContext snapContext)
Sets a different HotSpotSnapContext to use for this instance. |
void |
setSnappingEnabled(boolean snappingEnabled)
Whether this mode should use the getSnapContext() to HotSpotSnapContext.adjustMouseCoordinates(y.geom.YPoint, byte, boolean, boolean)
adjust the mouse coordinates so that the resized items snap to the precalculated SnapLines. |
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 java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final byte FIXED_AUTOBOUNDS_INSETS
AutoBoundsFeature, the group node's
autoBoundsInsets will stay fixed. It's overall bounds can grow or shrink.
public static final byte FIXED_MINIMUM_GROUP_BOUNDS
AutoBoundsFeature, the group node's
bounds can grow but not shrink. Before a group node starts to grow
its autoBoundsInset will be reduced, first.
public static final String NODE_CENTER_RESIZING_MODIFIER_MASK_PROPERTY
PropertyChangeEvent.getPropertyName().
This property is used if setKeepNodeCenterModifierMask(int) is called.
public static final byte SEMI_BLOCK_UPON_MINIMUM_SIZE
SizeConstraintProvider if provided using method
NodeRealizer.getSizeConstraintProvider(). If no SizeConstraintProvider is provided the minimum size is 1,1
for normal nodes or determined by the minimum group bounds for open group nodes.
setResizePolicy(byte),
Constant Field Valuespublic static final byte BLOCK_UPON_MINIMUM_SIZE
SizeConstraintProvider if provided using method
NodeRealizer.getSizeConstraintProvider(). If no SizeConstraintProvider is provided the minimum size is 1,1
for normal nodes or determined by the minimum group bounds for open group nodes.
setResizePolicy(byte),
Constant Field Valuespublic static final byte FLIP_SIDES_UPON_MINIMUM_SIZE
setResizePolicy(byte),
Constant Field Valuespublic static final byte DISCRETE_BLOCK_POLICY
isModifierPressed(java.awt.event.MouseEvent))
as well as keeping the center locations (isKeepNodeCenterModifierPressed(java.awt.event.MouseEvent))
of selected nodes.
setResizePolicy(byte),
Constant Field Values| Constructor Detail |
|---|
public HotSpotMode(ViewContainer vc)
public HotSpotMode()
| Method Detail |
|---|
public int getDisableSnappingModifier()
modifier mask that can be used to determine whether
the user disables snapping via the snap context
temporarily. By default this is set to 0 so there is no
modifier that will allow the user to take full control over the resizing without the aid of snap lines.
public void setDisableSnappingModifier(int disableSnappingModifier)
modifier mask that can be used to determine whether
the user disables snapping via the snap context
temporarily. By default this is set to 0 so there is no
modifier that will allow the user to take full control over the resizing without the aid of snap lines.
protected boolean isDisableSnappingModifierPressed(MouseEvent e)
modifier to disable snapping
has been currently pressed.
This implementation uses the getDisableSnappingModifier() to determine whether the modifier is currently applied.
e - The last mouse event.
getSnapContext(),
getDisableSnappingModifier()public HotSpotSnapContext getSnapContext()
HotSpotSnapContext instance that can be used by this instance to
perform mouse snapping during the move operation if snapping is enabled.
setSnapContext(HotSpotSnapContext)public void setSnapContext(HotSpotSnapContext snapContext)
HotSpotSnapContext to use for this instance.
Note that unless setSnappingEnabled(boolean) is called to enable snapping, this instance will not be used.
snapContext - The new context to use.public boolean isSnappingEnabled()
getSnapContext() to HotSpotSnapContext.adjustMouseCoordinates(y.geom.YPoint, byte, boolean, boolean)
adjust the mouse coordinates so that the resized items snap to the precalculated SnapLines.
By default this is disabled.
public void setSnappingEnabled(boolean snappingEnabled)
getSnapContext() to HotSpotSnapContext.adjustMouseCoordinates(y.geom.YPoint, byte, boolean, boolean)
adjust the mouse coordinates so that the resized items snap to the precalculated SnapLines.
By default this is disabled.
protected HotSpotSnapContext createSnapContext()
MoveSnapContext that will be used by this instance to snap the mouse coordinates.
MoveSnapContext.public boolean isRemovingInnerBends()
contained in these nodes that have been resized during the resize operation
after the move is finished.
If enabled this will remove all bends inside adjacent node and instead place the corresponding port at the location
of the last bend that lay inside the node.
By default this feature is turned off.
public void setRemovingInnerBends(boolean removingInnerBends)
contained in these nodes that have been resized during the resize operation
after the move is finished.
If enabled this will remove all bends inside adjacent node and instead place the corresponding port at the location
of the last bend that lay inside the node.
By default this feature is turned off.
public void setResizePolicy(byte policy)
DISCRETE_BLOCK_POLICY-policy supports the modifiers
isModifierPressed(java.awt.event.MouseEvent) and isKeepNodeCenterModifierPressed(java.awt.event.MouseEvent).
policy - One of SEMI_BLOCK_UPON_MINIMUM_SIZE, BLOCK_UPON_MINIMUM_SIZE,
FLIP_SIDES_UPON_MINIMUM_SIZE, or DISCRETE_BLOCK_POLICY.
DISCRETE_BLOCK_POLICY is set.public byte getResizePolicy()
setResizePolicy(byte)
public void mousePressedLeft(double x,
double y)
mousePressedLeft in class ViewModex - the x-coordinate of the mouse event in world coordinates.y - the y-coordinate of the mouse event in world coordinates.public void mouseReleased(MouseEvent ev)
mouseReleased in interface MouseListenermouseReleased in class ViewModeprotected boolean isOrthogonalRouting(Edge edge)
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.
edge - the edge to decide
true if the edge should be routed orthogonally.EditMode.isOrthogonalRouting(y.base.Edge)
public void mouseDraggedLeft(double x,
double y)
updateNodeRealizerBounds(NodeRealizer, double, double, double, double)
and adjustPortOffsets(Graph2D, y.base.Node, double, double, double, double)
for each node that is being resized.
mouseDraggedLeft in class ViewModex - the x-coordinate of the mouse event in world coordinates.y - the y-coordinate of the mouse event in world coordinates.protected boolean isModifierPressed(MouseEvent me)
ViewMode
isModifierPressed in class ViewModeViewMode.setModifierMask(int),
ViewMode.getModifierMask()protected boolean isKeepNodeCenterModifierPressed(MouseEvent me)
setKeepNodeCenterModifierMask(int),
getKeepNodeCenterModifierMask()public void setKeepNodeCenterModifierMask(int modifierMask)
(mouseEvent.getModifier() & modifierMask) != 0.
Valid values are the static fields in the MouseEvent class.
modifierMask - the new modifier mask that will be used to determine
whether the node shall be resized while keeping its center location.public int getKeepNodeCenterModifierMask()
(mouseEvent.getModifier() & modifierMask) != 0.
The default is MouseEvent.CTRL_MASK.
protected void adjustPortOffsets(Graph2D graph,
Node node,
double wOld,
double hOld,
double wNew,
double hNew)
graph - the graph that contains the nodenode - the node whose ports shall be adjustedwOld - the old widthhOld - the old heightwNew - the new widthhNew - the new height
protected void updateNodeRealizerBounds(NodeRealizer vr,
double x,
double y,
double w,
double h)
vr - the realizer of the node whose bounds should 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.
public void mouseReleasedLeft(double x,
double y)
mouseReleasedLeft in class ViewModex - the x-coordinate of the mouse event in world coordinates.y - the y-coordinate of the mouse event in world coordinates.public void activate(boolean b)
ViewModeViewMode.ACTIVE_PROPERTY as the property name.
activate in class ViewModeb - set true when mode was activated
false otherwisepublic void reactivateParent()
ViewMode
reactivateParent in class ViewModeprotected void cancelNodeResize()
public static Cursor getCursor(byte hotSpotType)
public int getCancelKeyCode()
KeyEvent
which cancels the edge creation. Negative values disable this feature.
Default is KeyEvent.VK_ESCAPE.
public void setCancelKeyCode(int cancelKeyCode)
KeyEvent
which cancels the edge creation. Negative values disable this feature.
public void cancelEditing()
throws UnsupportedOperationException
ViewModesetEditing(false) if
ViewMode.isEditing() returns true
cancelEditing in class ViewModeUnsupportedOperationException - if the editing cannot be canceled
for any reason.public byte getGroupBoundsPolicy()
FIXED_AUTOBOUNDS_INSETS and
FIXED_MINIMUM_GROUP_BOUNDS.public void setGroupBoundsPolicy(byte groupBoundsPolicy)
FIXED_AUTOBOUNDS_INSETS is set.
groupBoundsPolicy - one of FIXED_AUTOBOUNDS_INSETS and
FIXED_MINIMUM_GROUP_BOUNDS.
|
© Copyright 2000-2010, yWorks GmbH. All rights reserved. |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||