|
Search this API | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object y.view.ViewMode y.view.MoveSelectionMode
public class MoveSelectionMode
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.
This mode automatically adds the contents of selected group nodes to the list of objects that need to be moved. Also, it automatically moves all children of a selected group node. This way the view mode naturally extends the selection in the presence of node groups. Additionally, this view mode allows to add or remove nodes to and from a group. To add a selected node to a group, the node has to be dragged with the mouse to the target group node, then while pressing themodifier key
the left mouse button needs to be released.
To remove a selected node from a group the modifier key needs to be held down while
pressing the left mouse button to initiate the move selection action.
Field Summary | |
---|---|
static byte |
FIXED_AUTOBOUNDS_INSETS
Group bounds policy specifier. |
static byte |
FIXED_MINIMUM_GROUP_BOUNDS
Group bounds 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 | |
---|---|
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 HitInfo |
createDropTargetHitInfo(double x,
double y)
Performs a hit test for a target group node at the specified drop target location. |
protected MoveSnapContext |
createSnapContext()
Creates the MoveSnapContext that will be used by this instance to snap the mouse coordinates. |
protected void |
drawTargetNodeIndicator(java.awt.Graphics2D gfx,
NodeRealizer nodeRealizer)
Callback method that actually renders the target group node indicator . |
protected void |
findAdditionalElements(NodeList nodesToBeMoved,
BendList bendsToBeMoved)
Determines nodes and bends that are moved in addition to the ones returned by getNodesToBeMoved() and getBendsToBeMoved() . |
protected void |
findAdditionalElements(NodeList nodesToBeMoved,
NodeList ancestorNodes,
BendList bendsToBeMoved)
Determines nodes and bends that are moved in addition to the ones returned by getNodesToBeMoved() and getBendsToBeMoved() . |
protected BendList |
getBendsToBeMoved()
Returns the bends that should be moved by this view mode. |
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 moving the child nodes of a group. |
protected java.lang.Object |
getGroupingDropTarget(double x,
double y)
Determines the Node or Graph that will be used for the given coordinates for a
reparenting move operation. |
protected HierarchyManager |
getHierarchyManager()
Returns the HierarchyManager associated with the graph displayed in the underlying Graph2DView. |
protected NodeList |
getNodesToBeMoved()
Returns the nodes that should be moved by this view mode. |
MoveSnapContext |
getSnapContext()
Gets the MoveSnapContext instance that can be used by this instance to
perform mouse snapping during the move operation if snapping is enabled . |
protected java.awt.geom.Rectangle2D |
getTargetNodeIndicatorBounds(NodeRealizer nodeRealizer)
Yields the bounds of the target group node indicator Drawable . |
protected boolean |
isDisableSnappingModifierPressed(java.awt.event.MouseEvent e)
Callback used by this mode to determine whether the modifier to disable snapping
has been currently pressed. |
boolean |
isGroupReassignmentEnabled()
Returns whether or not reassignment of nodes to other groups is enabled. |
boolean |
isIndicatingTargetGroup()
Whether this instance indicates the target group node for a group reassignment operation using a Drawable . |
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 nodes that have been moved during the move operation
after the move is finished. |
boolean |
isSnappingEnabled()
Whether this mode should use the getSnapContext() to MoveSnapContext.adjustMouseCoordinates(y.geom.YPoint)
adjust the mouse coordinates so that the moved items snap to the precalculated SnapLine s. |
void |
mouseDraggedLeft(double x,
double y)
Moves the selected graph elements around. |
void |
mouseDraggedRight(double x,
double y)
Called when the mouse was dragged with the right button down. |
void |
mousePressedLeft(double x,
double y)
Initiates the movement of the selected graph elements. |
void |
mouseReleased(java.awt.event.MouseEvent ev)
A mouse button get released |
void |
mouseReleasedLeft(double x,
double y)
Terminates the movements of the selected graph elements. |
void |
mouseReleasedRight(double x,
double y)
Called when the right mouse button was released |
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. |
void |
reactivateParent()
The parent of this ViewMode is reactivated and this ViewMode is deactivated. |
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. |
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 moving the child nodes of a group. |
void |
setGroupReassignmentEnabled(boolean enabled)
Sets whether or not a reassignment of nodes to other groups can be triggered by a mouse/keyboard gesture. |
void |
setIndicatingTargetGroup(boolean indicatingTargetGroup)
Determines whether this instance indicates the target group node for a group reassignment operation using a Drawable . |
void |
setRemovingInnerBends(boolean removingInnerBends)
Determines whether this instance should remove bends of edges adjacent to nodes that are contained in nodes that have been moved during the move operation
after the move is finished. |
void |
setSnapContext(MoveSnapContext snapContext)
Sets a different MoveSnapContext to use for this instance. |
void |
setSnappingEnabled(boolean snappingEnabled)
Whether this mode should use the getSnapContext() to MoveSnapContext.adjustMouseCoordinates(y.geom.YPoint)
adjust the mouse coordinates so that the moved items snap to the precalculated SnapLine s. |
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.
Constructor Detail |
---|
public MoveSelectionMode(ViewContainer view)
public MoveSelectionMode()
Method Detail |
---|
public boolean isRemovingInnerBends()
contained
in nodes that have been moved during the move 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 nodes that have been moved during the move 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 activate(boolean b)
ViewMode
ViewMode.ACTIVE_PROPERTY
as the property name.
activate
in class ViewMode
b
- set true
when mode was activated
false
otherwisepublic 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 InputEvent.CTRL_MASK
so that pressing
the CTRL modifier will allow the user to take full control over the movement 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 InputEvent.CTRL_MASK
so that pressing
the CTRL modifier will allow the user to take full control over the movement without the aid of snap lines.
protected boolean isDisableSnappingModifierPressed(java.awt.event.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 MoveSnapContext getSnapContext()
MoveSnapContext
instance that can be used by this instance to
perform mouse snapping during the move operation if snapping is enabled
.
setSnapContext(MoveSnapContext)
public void setSnapContext(MoveSnapContext snapContext)
MoveSnapContext
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.protected MoveSnapContext createSnapContext()
MoveSnapContext
that will be used by this instance to snap the mouse coordinates.
MoveSnapContext
.public boolean isSnappingEnabled()
getSnapContext()
to MoveSnapContext.adjustMouseCoordinates(y.geom.YPoint)
adjust the mouse coordinates so that the moved items snap to the precalculated SnapLine
s.
By default this is disabled.
public void setSnappingEnabled(boolean snappingEnabled)
getSnapContext()
to MoveSnapContext.adjustMouseCoordinates(y.geom.YPoint)
adjust the mouse coordinates so that the moved items snap to the precalculated SnapLine
s.
By default this is disabled.
public void mouseShiftPressedLeft(double x, double y)
mouseShiftPressedLeft
in class ViewMode
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.public void mousePressedLeft(double x, double y)
mousePressedLeft
in class ViewMode
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.public void mouseShiftReleasedLeft(double x, double y)
mouseShiftReleasedLeft
in class ViewMode
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.public void mouseReleasedLeft(double x, double y)
mouseReleasedLeft
in class ViewMode
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.public void reactivateParent()
ViewMode
reactivateParent
in class ViewMode
public void mouseDraggedLeft(double x, double y)
mouseDraggedLeft
in class ViewMode
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.protected void selectionMoveStarted(double x, double y)
protected void selectionOnMove(double dx, double dy, double x, double y)
dx
- the difference between the given x-coordinate and the
x-coordinate of the last mouse event handled by this mode.dy
- the difference between the given y-coordinate and the
y-coordinate of the last mouse event handled by this mode.x
- the x-coordinate of the triggering mouse event in the world
coordinate system.y
- the y-coordinate of the triggering mouse event in the world
coordinate system.protected void selectionMovedAction(double dx, double dy, double x, double y)
protected NodeList getNodesToBeMoved()
protected BendList getBendsToBeMoved()
protected void findAdditionalElements(NodeList nodesToBeMoved, BendList bendsToBeMoved)
getNodesToBeMoved()
and getBendsToBeMoved()
.
The default implementation does nothing.
This method is called for flat graphs (i.e. graphs with no associated
HierarchyManager
instance) only.
nodesToBeMoved
- input/output parameter. Contains the nodes returned
by getNodesToBeMoved()
. Add all additional nodes to this list as
well.bendsToBeMoved
- input/output parameter. Contains the bends returned
by getBendsToBeMoved()
. Add all additional bends to this list as
well.findAdditionalElements(y.base.NodeList, y.base.NodeList, BendList)
protected void findAdditionalElements(NodeList nodesToBeMoved, NodeList ancestorNodes, BendList bendsToBeMoved)
getNodesToBeMoved()
and getBendsToBeMoved()
.
In the default implementation, the additional nodes are descendant nodes
of group nodes in the specified nodesToBeMoved
list that do
not belong to said list themselves.
Additional bends collected by this method are bends of edges connecting
the aforementioned additional nodes that do not already belong to the
specified bendsToBeMoved
list themselves.
This method is called for nested graphs (i.e. graphs with an associated
HierarchyManager
instance) only.
nodesToBeMoved
- input/output parameter. Contains the nodes returned
by getNodesToBeMoved()
. Add all additional nodes to this list as
well.ancestorNodes
- output parameter. Add all ancestor group nodes of
the specified nodesToBeMoved
(including the additional nodesbendsToBeMoved
- input/output parameter. Contains the bends returned
by getBendsToBeMoved()
. Add all additional bends to this list as
well.findAdditionalElements(y.base.NodeList, BendList)
protected 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 cancelEditing() throws java.lang.UnsupportedOperationException
ViewMode
setEditing(false)
if
ViewMode.isEditing()
returns true
cancelEditing
in class ViewMode
java.lang.UnsupportedOperationException
- if the editing cannot be canceled
for any reason.protected java.lang.Object getGroupingDropTarget(double x, double y)
Node
or Graph
that will be used for the given coordinates for a
reparenting move operation.
protected HitInfo createDropTargetHitInfo(double x, double y)
protected HierarchyManager getHierarchyManager()
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
.public boolean isGroupReassignmentEnabled()
setGroupReassignmentEnabled(boolean)
public void setGroupReassignmentEnabled(boolean enabled)
public boolean isIndicatingTargetGroup()
Drawable
.
The default is false
.
public void setIndicatingTargetGroup(boolean indicatingTargetGroup)
Drawable
.
The default is false
.
protected void drawTargetNodeIndicator(java.awt.Graphics2D gfx, NodeRealizer nodeRealizer)
target group node indicator
.
This callback is used by the actual drawable implementation.
gfx
- The graphics to render into.nodeRealizer
- The realizer to highlight.protected java.awt.geom.Rectangle2D getTargetNodeIndicatorBounds(NodeRealizer nodeRealizer)
target group node indicator
Drawable
.
This method is used as a callback by the actual drawable implementation so that it can be overridden, here, easily.
nodeRealizer
- The realizer to highlight.
public void mouseReleased(java.awt.event.MouseEvent ev)
ViewMode
mouseReleased
in interface java.awt.event.MouseListener
mouseReleased
in class ViewMode
public void mouseReleasedRight(double x, double y)
ViewMode
mouseReleasedRight
in class ViewMode
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.public void mouseDraggedRight(double x, double y)
ViewMode
mouseDraggedRight
in class ViewMode
x
- the x-coordinate of the mouse event in world coordinates.y
- the y-coordinate of the mouse event in world coordinates.
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |