|
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.AbstractSelectionBoxMode y.view.SelectionBoxMode
public class SelectionBoxMode
This ViewMode is responsible for letting the user open up a selection box. Graph elements inside that box will automatically be selected.
By default, this mode never selects nodes and edges at the same time. What actually gets selected depends on whether or not the shift key is pressed down when opening the selection box and on the set of currently selected graph elements.
If the shift key is pressed down when opening the selection box the new selection will consist of the previously selected elements plus the ones that lie inside of the selection box.
By default, the shift key driven union mechanism selects more edges if the graph elements already selected were edges. Otherwise more nodes and bends will be selected.
Use method setExtendedTypeSelectionEnabled(boolean)
to enable
this mode to select graph elements such as node and edge labels and/or node
ports besides nodes, edges, and bends.
Field Summary | |
---|---|
static int |
TYPE_BEND
Type bit mask representing bends. |
static int |
TYPE_EDGE
Type bit mask representing edges. |
static int |
TYPE_EDGE_LABEL
Type bit mask representing edge labels. |
static int |
TYPE_NODE
Type bit mask representing nodes. |
static int |
TYPE_NODE_LABEL
Type bit mask representing node labels. |
static int |
TYPE_NODE_PORT
Type bit mask representing node ports. |
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 | |
---|---|
SelectionBoxMode()
Instantiates a new SelectionBoxMode. |
|
SelectionBoxMode(ViewContainer view)
Instantiates a new SelectionBoxMode for a given ViewContainer |
Method Summary | |
---|---|
protected int |
adjustTypes(int typeMask)
Determines which types of graph elements have to be selected. |
protected boolean |
belongsToSelection(Bend b,
java.awt.geom.Rectangle2D box)
Callback method that decides whether or not the given bend should be selected, by the given selection box bounds. |
protected boolean |
belongsToSelection(Edge e,
java.awt.geom.Rectangle2D box)
Callback method that decides whether or not the given edge should be selected, by the given selection box bounds. |
protected boolean |
belongsToSelection(NodePort p,
java.awt.geom.Rectangle2D box)
Callback method that decides whether or not the given node port should be selected, by the given selection box bounds. |
protected boolean |
belongsToSelection(Node v,
java.awt.geom.Rectangle2D box)
Callback method that decides whether or not the given node should be selected, by the given selection box bounds. |
protected boolean |
belongsToSelection(YLabel l,
java.awt.geom.Rectangle2D box)
Callback method that decides whether or not the given label should be selected, by the given selection box bounds. |
protected int |
getSelectedEdgeTypes(Graph2D graph,
Edge edge)
Determines whether the specified edge and/or any graph elements related to the specified edge (that is edge labels and/or bends) are selected. |
protected int |
getSelectedNodeTypes(Graph2D graph,
Node node)
Determines whether the specified node and/or any graph elements related to the specified node (that is node labels and/or node ports) are selected. |
protected int |
getSelectedTypes(Graph2D graph)
Determines the types of graph elements that are selected in the specified graph. |
boolean |
isExtendedTypeSelectionEnabled()
Determines whether or not this mode supports selecting graph elements other than nodes, edges, and bends such as node and edge labels and/or node ports. |
boolean |
isMixedSelectionEnabled()
Determines whether or not this mode supports selecting different types of graph elements at once when extendedTypeSelectionEnabled is
set to true . |
protected boolean |
isSelected(Graph2D graph,
Bend bend)
Returns true if the specified bend is currently selected;
false otherwise. |
protected boolean |
isSelected(Graph2D graph,
Edge edge)
Returns true if the specified edge is currently selected;
false otherwise. |
protected boolean |
isSelected(Graph2D graph,
Node node)
Returns true if the specified node is currently selected;
false otherwise. |
protected boolean |
isSelected(Graph2D graph,
NodePort port)
Returns true if the specified port is currently selected;
false otherwise. |
protected boolean |
isSelected(Graph2D graph,
YLabel label)
Returns true if the specified label is currently selected;
false otherwise. |
protected void |
selectEdgeTypes(Graph2D graph,
Edge edge,
int typeMask,
java.awt.Rectangle sb,
boolean shiftMode)
Selects the specified edge and/or related graph elements (that is edge labels and bends) depending on whether or not the elements intersect or lie in the specified rectangle. |
protected void |
selectionBoxAction(java.awt.Rectangle sb,
boolean shiftMode)
Selects graph objects within selection box bounds. |
protected void |
selectNodeTypes(Graph2D graph,
Node node,
int typeMask,
java.awt.Rectangle sb,
boolean shiftMode)
Selects the specified node and/or related graph elements (that is node labels and node ports) depending on whether or not the elements lie in the specified rectangle. |
protected void |
selectTypes(Graph2D graph,
int typeMask,
java.awt.Rectangle sb,
boolean shiftMode)
Selects the specified types of graph elements that lie in the specified rectangle. |
void |
setExtendedTypeSelectionEnabled(boolean enabled)
Specifies whether or not this mode supports selecting graph elements other than nodes, edges, and bends such as node and edge labels and/or node ports. |
void |
setMixedSelectionEnabled(boolean enabled)
Specifies whether or not this mode supports selecting different types of graph elements at once when extendedTypeSelectionEnabled is
set to true . |
protected void |
setSelected(Graph2D graph,
Bend b,
boolean state)
Sets the specified selection state for the specified bend. |
protected void |
setSelected(Graph2D graph,
Edge e,
boolean state)
Sets the specified selection state for the specified edge. |
protected void |
setSelected(Graph2D graph,
Node n,
boolean state)
Sets the specified selection state for the specified node. |
protected void |
setSelected(Graph2D graph,
NodePort p,
boolean state)
Sets the specified selection state for the specified node port. |
protected void |
setSelected(Graph2D graph,
YLabel l,
boolean state)
Sets the specified selection state for the specified label. |
protected void |
unselectAll(Graph2D graph)
Sets the selection state of all nodes, node labels, node ports, edges, edge labels, and bends to false . |
Methods inherited from class y.view.AbstractSelectionBoxMode |
---|
cancelEditing, mouseDraggedLeft, mousePressedLeft, mouseReleasedLeft, mouseReleasedRight, mouseShiftPressedLeft, mouseShiftReleasedLeft, selectionBoxAction, updateDoubleSelectionBox |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int TYPE_NODE
public static final int TYPE_EDGE
public static final int TYPE_BEND
public static final int TYPE_NODE_LABEL
public static final int TYPE_EDGE_LABEL
public static final int TYPE_NODE_PORT
Constructor Detail |
---|
public SelectionBoxMode(ViewContainer view)
public SelectionBoxMode()
Method Detail |
---|
public boolean isExtendedTypeSelectionEnabled()
By default, this property is set to false
.
true
if this mode supports selecting node and edge
labels and/or node ports as well as nodes, edges, and bends;
false
if this mode supports selecting nodes, edges, and bends
only.setExtendedTypeSelectionEnabled(boolean)
,
isMixedSelectionEnabled()
,
setMixedSelectionEnabled(boolean)
public void setExtendedTypeSelectionEnabled(boolean enabled)
By default, this property is set to false
.
enabled
- if true
this mode supports selecting node and
edge labels and/or node ports as well as nodes, edges, and bends; otherwise
this mode supports selecting nodes, edges, and bends only.isExtendedTypeSelectionEnabled()
,
isMixedSelectionEnabled()
,
setMixedSelectionEnabled(boolean)
public boolean isMixedSelectionEnabled()
extendedTypeSelectionEnabled
is
set to true
.
By default, this property is set to false
.
Note: Nodes and bends will be selected at the same time independent of the value of this property.
true
if this mode supports selecting different types
of graph elements at once; false
otherwise.setMixedSelectionEnabled(boolean)
,
isExtendedTypeSelectionEnabled()
,
setExtendedTypeSelectionEnabled(boolean)
public void setMixedSelectionEnabled(boolean enabled)
extendedTypeSelectionEnabled
is
set to true
.
By default, this property is set to false
.
enabled
- if true
if this mode supports selecting
different types of graph elements at once; otherwise only one type
of graph elements can be selected.isMixedSelectionEnabled()
,
isExtendedTypeSelectionEnabled()
,
setExtendedTypeSelectionEnabled(boolean)
protected void selectionBoxAction(java.awt.Rectangle sb, boolean shiftMode)
selectionBoxAction
in class AbstractSelectionBoxMode
sb
- The position and size of the selection box.shiftMode
- true
if shift was pressed when
box was closed, false
otherwise.protected boolean belongsToSelection(Node v, java.awt.geom.Rectangle2D box)
protected boolean belongsToSelection(Edge e, java.awt.geom.Rectangle2D box)
protected boolean belongsToSelection(Bend b, java.awt.geom.Rectangle2D box)
protected boolean belongsToSelection(YLabel l, java.awt.geom.Rectangle2D box)
protected boolean belongsToSelection(NodePort p, java.awt.geom.Rectangle2D box)
protected int adjustTypes(int typeMask)
selectionBoxAction(java.awt.Rectangle, boolean)
.
typeMask
- bit mask specifying the types of graph elements that
are already selected.
getSelectedTypes(Graph2D)
,
selectTypes(Graph2D, int, java.awt.Rectangle, boolean)
,
TYPE_BEND
,
TYPE_EDGE
,
TYPE_EDGE_LABEL
,
TYPE_NODE
,
TYPE_NODE_LABEL
,
TYPE_NODE_PORT
protected int getSelectedTypes(Graph2D graph)
selectionBoxAction(java.awt.Rectangle, boolean)
.
The default implementation queries
getSelectedEdgeTypes(Graph2D, y.base.Edge)
for each edge and
getSelectedNodeTypes(Graph2D, y.base.Node)
for each node in the
graph to determine the types of selected elements in the graph.
graph
- the graph whose elements have to be checked.
true
.adjustTypes(int)
,
selectTypes(Graph2D, int, java.awt.Rectangle, boolean)
,
TYPE_BEND
,
TYPE_EDGE
,
TYPE_EDGE_LABEL
,
TYPE_NODE
,
TYPE_NODE_LABEL
,
TYPE_NODE_PORT
protected int getSelectedEdgeTypes(Graph2D graph, Edge edge)
graph
- the graph to which the specified edge belongs.edge
- the edge to check.
true
.getSelectedTypes(Graph2D)
,
getSelectedNodeTypes(Graph2D, y.base.Node)
protected int getSelectedNodeTypes(Graph2D graph, Node node)
graph
- the graph to which the specified node belongs.node
- the node to check.
true
.getSelectedTypes(Graph2D)
,
getSelectedEdgeTypes(Graph2D, y.base.Edge)
protected void selectTypes(Graph2D graph, int typeMask, java.awt.Rectangle sb, boolean shiftMode)
selectionBoxAction(java.awt.Rectangle, boolean)
.
The default implementation delegates selecting elements to
selectEdgeTypes(Graph2D, y.base.Edge, int, java.awt.Rectangle, boolean)
and
selectNodeTypes(Graph2D, y.base.Node, int, java.awt.Rectangle, boolean)
for each edge and each node in the graph.
graph
- the graph whose elements are selected.typeMask
- a bit mask specifying which types of elements to select.sb
- the rectangle that contains elements that have to be selected.shiftMode
- if true
elements that are selected but lie
outside the specified rectangle will remain selected; if false
the selection state of said elements is set to false
.adjustTypes(int)
,
getSelectedTypes(Graph2D)
,
TYPE_BEND
,
TYPE_EDGE
,
TYPE_EDGE_LABEL
,
TYPE_NODE
,
TYPE_NODE_LABEL
,
TYPE_NODE_PORT
protected void selectEdgeTypes(Graph2D graph, Edge edge, int typeMask, java.awt.Rectangle sb, boolean shiftMode)
graph
- the graph to which the specified edge belongs.edge
- the edge to select.typeMask
- a bit mask specifying which types of elements to select.sb
- the rectangle that contains elements that have to be selected.shiftMode
- if true
elements that are selected but lie
outside the specified rectangle will remain selected; if false
the selection state of said elements is set to false
.selectTypes(Graph2D, int, java.awt.Rectangle, boolean)
,
selectNodeTypes(Graph2D, y.base.Node, int, java.awt.Rectangle, boolean)
protected void selectNodeTypes(Graph2D graph, Node node, int typeMask, java.awt.Rectangle sb, boolean shiftMode)
graph
- the graph to which the specified node belongs.node
- the node to select.typeMask
- a bit mask specifying which types of elements to select.sb
- the rectangle that contains elements that have to be selected.shiftMode
- if true
elements that are selected but lie
outside the specified rectangle will remain selected; if false
the selection state of said elements is set to false
.selectTypes(Graph2D, int, java.awt.Rectangle, boolean)
,
selectEdgeTypes(Graph2D, y.base.Edge, int, java.awt.Rectangle, boolean)
protected void unselectAll(Graph2D graph)
false
.
graph
- the graph whose elements' selection states have to be changed.protected void setSelected(Graph2D graph, Node n, boolean state)
The default implementation sets the selection state of the specified node as well as the states of all bends in self loop edges incident to the specified node.
graph
- the graph the specified node resides in.n
- the node whose selection state has to be changed.state
- the new selection state for the specified node.protected void setSelected(Graph2D graph, Bend b, boolean state)
graph
- the graph the specified bend's associated edge resides in.b
- the bend whose selection state has to be changed.state
- the new selection state for the specified bend.protected void setSelected(Graph2D graph, Edge e, boolean state)
graph
- the graph the specified edge resides in.e
- the edge whose selection state has to be changed.state
- the new selection state for the specified edge.protected void setSelected(Graph2D graph, YLabel l, boolean state)
graph
- the graph the specified label's associated node or edge resides
in.l
- the label whose selection state has to be changed.state
- the new selection state for the specified label.protected void setSelected(Graph2D graph, NodePort p, boolean state)
graph
- the graph the specified port's associated node resides in.p
- the node port whose selection state has to be changed.state
- the new selection state for the specified node port.protected boolean isSelected(Graph2D graph, Bend bend)
true
if the specified bend is currently selected;
false
otherwise.
graph
- the graph that holds the specified bend's associated edge.bend
- the bend whose selection state is checked.
true
if the specified bend is currently selected;
false
otherwise.protected boolean isSelected(Graph2D graph, YLabel label)
true
if the specified label is currently selected;
false
otherwise.
graph
- the graph that holds the specified label's associated edge
or node.label
- the label whose selection state is checked.
true
if the specified label is currently selected;
false
otherwise.protected boolean isSelected(Graph2D graph, Edge edge)
true
if the specified edge is currently selected;
false
otherwise.
graph
- the graph that holds the specified edge.edge
- the edge whose selection state is checked.
true
if the specified edge is currently selected;
false
otherwise.protected boolean isSelected(Graph2D graph, Node node)
true
if the specified node is currently selected;
false
otherwise.
graph
- the graph that holds the specified node.node
- the node whose selection state is checked.
true
if the specified node is currently selected;
false
otherwise.protected boolean isSelected(Graph2D graph, NodePort port)
true
if the specified port is currently selected;
false
otherwise.
graph
- the graph that holds the specified port's associated node.port
- the node port whose selection state is checked.
true
if the specified port is currently selected;
false
otherwise.
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |