|
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.PopupMode
public abstract class PopupMode
A view mode that is responsible for showing context sensitive popup menus when a right click occurs on a view element. The popup menus will be displayed at the view coordinate where the right click occurred.
Subclasses should overwrite the methods that provide JPopupMenu objects for different kinds of contexts. By default these methods return empty popup menus.
Field Summary | |
---|---|
static int |
POPUP_TYPE_BEND
Popup type specifier that will result in opening a popup menu returned by getBendPopup(Bend) |
static int |
POPUP_TYPE_EDGE
Popup type specifier that will result in opening a popup menu returned by getEdgePopup(Edge) |
static int |
POPUP_TYPE_EDGE_LABEL
Popup type specifier that will result in opening a popup menu returned by getEdgeLabelPopup(EdgeLabel) |
static int |
POPUP_TYPE_NODE
Popup type specifier that indicates will result in opening a popup menu returned by getNodePopup(Node) |
static int |
POPUP_TYPE_NODE_LABEL
Popup type specifier that will result in opening a popup menu returned by getNodeLabelPopup(NodeLabel) |
static int |
POPUP_TYPE_NODE_PORT
Popup type specifier that will result in opening a popup menu returned by getNodePortPopup(NodePort) |
static int |
POPUP_TYPE_PAPER
Popup type specifier that will result in opening a popup menu returned by getPaperPopup(double, double) |
static int |
POPUP_TYPE_SELECTION
Popup type specifier that will result in opening a popup menu returned by getSelectionPopup(double, double) |
static int |
POPUP_TYPE_UNKNOWN
Popup type specifier that will result in not opening a popup menu. |
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 | |
---|---|
PopupMode()
Initializes a new PopupMode |
|
PopupMode(ViewContainer vc)
Initializes a new PopupMode for a given ViewContainer |
Method Summary | |
---|---|
protected void |
adjustSelectionState(HitInfo hitInfo,
double x,
double y,
int popupType)
Adjusts the selection state of elements depending on the popup type and hit info. |
javax.swing.JPopupMenu |
getBendPopup(Bend b)
Provides a JPopupMenu that is displayed for the given bend. |
javax.swing.JPopupMenu |
getEdgeLabelPopup(EdgeLabel label)
Provides a JPopupMenu that is displayed for the given edge label. |
javax.swing.JPopupMenu |
getEdgePopup(Edge e)
Provides a JPopupMenu that is displayed for the given edge. |
javax.swing.JPopupMenu |
getNodeLabelPopup(NodeLabel label)
Provides a JPopupMenu that is displayed for the given node label. |
javax.swing.JPopupMenu |
getNodePopup(Node v)
Provides a JPopupMenu that is displayed for the given node. |
javax.swing.JPopupMenu |
getNodePortPopup(NodePort port)
Provides a JPopupMenu that is displayed for the given node port. |
javax.swing.JPopupMenu |
getPaperPopup(double x,
double y)
Provides a JPopupMenu that is displayed if a hit on the view background occurred and no graph elements are selected. |
protected javax.swing.JPopupMenu |
getPopup(HitInfo hitInfo,
double x,
double y,
int popupType)
Returns the popup menu to be opened by this view mode. |
protected int |
getPopupType(HitInfo info,
double x,
double y)
Returns the popup type for a given HitInfo and hit coordinates. |
javax.swing.JPopupMenu |
getSelectionPopup(double x,
double y)
Provides a JPopupMenu that is displayed if a hit on the view background occurred and some graph elements are selected. |
boolean |
getSelectSubject()
Returns whether or not to automatically select the subject (node, edge, bend,...) for which the popup menu gets activated. |
protected boolean |
isSelectionEmpty(Graph2D graph)
Returns true if there are no selected nodes, node labels,
node ports, edges, edge labels, and/or bends in the specified graph and
false otherwise. |
boolean |
isSingleNodeSelectionModeEnabled()
Returns whether or not single node selection mode is enabled. |
void |
mousePressed(java.awt.event.MouseEvent e)
Internal use only |
void |
mouseReleased(java.awt.event.MouseEvent e)
Triggers the display of a context sensitive menu on a right mouse button press. |
void |
reactivateParent()
Internal use only. |
protected void |
setSelected(Graph2D graph,
Bend bend,
boolean flag)
Sets the specified selection state for the specified bend. |
protected void |
setSelected(Graph2D graph,
Edge edge,
boolean flag)
Sets the specified selection state for the specified edge. |
protected void |
setSelected(Graph2D graph,
Node node,
boolean flag)
Sets the specified selection state for the specified node. |
protected void |
setSelected(Graph2D graph,
NodePort port,
boolean flag)
Sets the specified selection state for the specified node port. |
protected void |
setSelected(Graph2D graph,
YLabel label,
boolean flag)
Sets the specified selection state for the specified label. |
void |
setSelectSubject(boolean select)
Sets whether or not to automatically select the subject (node, edge, bend,...) for which the popup menu gets activated. |
void |
setSingleNodeSelectionModeEnabled(boolean singleNodeSelectionModeEnabled)
Whether or not single node selection mode is enabled. |
protected void |
showPopup(javax.swing.JPopupMenu pm,
double x,
double y)
Opens the given popup menu at the world coordinates (x,y). |
protected void |
startAction(double x,
double y)
Starts the popup mode action. |
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 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int POPUP_TYPE_NODE
getNodePopup(Node)
public static final int POPUP_TYPE_BEND
getBendPopup(Bend)
public static final int POPUP_TYPE_EDGE_LABEL
getEdgeLabelPopup(EdgeLabel)
public static final int POPUP_TYPE_EDGE
getEdgePopup(Edge)
public static final int POPUP_TYPE_NODE_LABEL
getNodeLabelPopup(NodeLabel)
public static final int POPUP_TYPE_PAPER
getPaperPopup(double, double)
public static final int POPUP_TYPE_SELECTION
getSelectionPopup(double, double)
public static final int POPUP_TYPE_UNKNOWN
public static final int POPUP_TYPE_NODE_PORT
getNodePortPopup(NodePort)
Constructor Detail |
---|
public PopupMode()
public PopupMode(ViewContainer vc)
Method Detail |
---|
public void mousePressed(java.awt.event.MouseEvent e)
mousePressed
in interface java.awt.event.MouseListener
mousePressed
in class ViewMode
public void reactivateParent()
reactivateParent
in class ViewMode
public void mouseReleased(java.awt.event.MouseEvent e)
mouseReleased
in interface java.awt.event.MouseListener
mouseReleased
in class ViewMode
protected int getPopupType(HitInfo info, double x, double y)
POPUP_TYPE_BEND
, POPUP_TYPE_EDGE
,
POPUP_TYPE_EDGE_LABEL
, POPUP_TYPE_NODE
,
POPUP_TYPE_NODE_LABEL
, POPUP_TYPE_PAPER
,
POPUP_TYPE_SELECTION
, POPUP_TYPE_NODE_PORT
, or
POPUP_TYPE_UNKNOWN
.protected void adjustSelectionState(HitInfo hitInfo, double x, double y, int popupType)
protected boolean isSelectionEmpty(Graph2D graph)
true
if there are no selected nodes, node labels,
node ports, edges, edge labels, and/or bends in the specified graph and
false
otherwise.
graph
- the graph whose elements' selection states are checked.
true
if there are no selected nodes, node labels,
node ports, edges, edge labels, and/or bends in the specified graph and
false
otherwise.protected void unselectAll(Graph2D graph)
false
.
graph
- the graph whose elements' selection states have to be changed.protected void setSelected(Graph2D graph, NodePort port, boolean flag)
graph
- the graph the specified port's associated node resides in.port
- the node port whose selection state has to be changed.flag
- the new selection state for the specified node port.protected void setSelected(Graph2D graph, Node node, boolean flag)
graph
- the graph the specified node resides in.node
- the node whose selection state has to be changed.flag
- the new selection state for the specified node.protected void setSelected(Graph2D graph, YLabel label, boolean flag)
graph
- the graph the specified label's associated node or edge resides
in.label
- the label whose selection state has to be changed.flag
- the new selection state for the specified label.protected void setSelected(Graph2D graph, Edge edge, boolean flag)
graph
- the graph the specified edge resides in.edge
- the edge whose selection state has to be changed.flag
- the new selection state for the specified edge.protected void setSelected(Graph2D graph, Bend bend, boolean flag)
graph
- the graph the specified bend's associated edge resides in.bend
- the bend whose selection state has to be changed.flag
- the new selection state for the specified bend.protected void startAction(double x, double y)
x
- x-coordinate measured in world coordinates where the mouse gesture has occurred.y
- y-coordinate measured in world coordinates where the mouse gesture has occurred.protected javax.swing.JPopupMenu getPopup(HitInfo hitInfo, double x, double y, int popupType)
protected void showPopup(javax.swing.JPopupMenu pm, double x, double y)
public javax.swing.JPopupMenu getNodePopup(Node v)
null
no popup menu will be displayed.
public javax.swing.JPopupMenu getBendPopup(Bend b)
null
no popup menu will be displayed.
public javax.swing.JPopupMenu getEdgePopup(Edge e)
null
no popup menu will be displayed.
public javax.swing.JPopupMenu getPaperPopup(double x, double y)
null
no popup menu will be displayed.
public javax.swing.JPopupMenu getSelectionPopup(double x, double y)
null
no popup menu will be displayed.
public javax.swing.JPopupMenu getEdgeLabelPopup(EdgeLabel label)
null
no popup menu will be displayed.
public javax.swing.JPopupMenu getNodePortPopup(NodePort port)
null
no popup menu will be displayed.
port
- the node port
public javax.swing.JPopupMenu getNodeLabelPopup(NodeLabel label)
null
no popup menu will be displayed.
label
- the label
public void setSelectSubject(boolean select)
public boolean getSelectSubject()
public void setSingleNodeSelectionModeEnabled(boolean singleNodeSelectionModeEnabled)
POPUP_TYPE_NODE
. If not enabled
a click on an unselected node will not change the selection. The popup type is set to
POPUP_TYPE_SELECTION
.
By default, this feature is enabled.
public boolean isSingleNodeSelectionModeEnabled()
setSingleNodeSelectionModeEnabled(boolean)
|
© Copyright 2000-2022, yWorks GmbH. All rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |