y.view
Class PopupMode

java.lang.Object
  extended by y.view.ViewMode
      extended by y.view.PopupMode
All Implemented Interfaces:
MouseListener, MouseMotionListener, EventListener, MouseInputListener

public abstract class PopupMode
extends ViewMode

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.

 
Your browser does not support SVG content.

Field Summary
 
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
 JPopupMenu getBendPopup(Bend b)
          Provides a JPopupMenu that is displayed for the given bend.
 JPopupMenu getEdgeLabelPopup(EdgeLabel label)
          Provides a JPopupMenu that is displayed for the given edge label.
 JPopupMenu getEdgePopup(Edge e)
          Provides a JPopupMenu that is displayed for the given edge.
 JPopupMenu getNodeLabelPopup(NodeLabel label)
          Provides a JPopupMenu that is displayed for the given node label.
 JPopupMenu getNodePopup(Node v)
          Provides a JPopupMenu that is displayed for the given node.
 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.
 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()
           
 void mousePressed(MouseEvent e)
          Internal use only
 void mouseReleased(MouseEvent e)
          Triggers the display of a context sensitive menu on a right mouse button press.
 void reactivateParent()
          Internal use only.
 void setSelectSubject(boolean select)
          Sets whether or not to automatically select the subject (node, edge, bend,...) for which the popup menu gets activated.
 
Methods inherited from class y.view.ViewMode
activate, addPropertyChangeListener, addPropertyChangeListener, cancelEditing, firePropertyChange, firePropertyChange, firePropertyChange, getChild, getGraph2D, getGridX, getGridY, getHitInfo, getHitInfo, getLastHitInfo, getModifierMask, getName, getParent, init, isActive, isEditing, isGrabFocusEnabled, isGridMode, isModifierPressed, mouseClicked, mouseClicked, mouseDragged, mouseDraggedLeft, mouseDraggedMiddle, mouseDraggedRight, mouseEntered, mouseExited, mouseMoved, mouseMoved, mousePressedLeft, mousePressedMiddle, mousePressedRight, mouseReleased, mouseReleasedLeft, mouseReleasedMiddle, mouseReleasedRight, mouseShiftPressedLeft, mouseShiftPressedMiddle, mouseShiftPressedRight, mouseShiftReleasedLeft, mouseShiftReleasedMiddle, mouseShiftReleasedRight, 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
 

Constructor Detail

PopupMode

public PopupMode()
Initializes a new PopupMode


PopupMode

public PopupMode(ViewContainer vc)
Initializes a new PopupMode for a given ViewContainer

Method Detail

mousePressed

public void mousePressed(MouseEvent e)
Internal use only

Specified by:
mousePressed in interface MouseListener
Overrides:
mousePressed in class ViewMode

reactivateParent

public void reactivateParent()
Internal use only.

Overrides:
reactivateParent in class ViewMode

mouseReleased

public void mouseReleased(MouseEvent e)
Triggers the display of a context sensitive menu on a right mouse button press. Depending on the kind of hit element an appropriate JPopupMenu will be displayed.

Specified by:
mouseReleased in interface MouseListener
Overrides:
mouseReleased in class ViewMode

getNodePopup

public JPopupMenu getNodePopup(Node v)
Provides a JPopupMenu that is displayed for the given node. This method will be called if no graph elements are selected and a right click on a node occurred. If the JPopupMenu contains no elements or is null no popup menu will be displayed.


getBendPopup

public JPopupMenu getBendPopup(Bend b)
Provides a JPopupMenu that is displayed for the given bend. This method will be called if no graph elements are selected and a right click on a bend occurred. If the JPopupMenu contains no elements or is null no popup menu will be displayed.


getEdgePopup

public JPopupMenu getEdgePopup(Edge e)
Provides a JPopupMenu that is displayed for the given edge. This method will be called if no graph elements are selected and a right click on an edge occurred. If the JPopupMenu contains no elements or is null no popup menu will be displayed.


getPaperPopup

public 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.

The hit on the background occurred at the given world coordinate.

If the JPopupMenu contains no elements or is null no popup menu will be displayed.


getSelectionPopup

public 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.

The hit on the background occurred at the given world coordinate.

If the JPopupMenu contains no elements or is null no popup menu will be displayed.


getEdgeLabelPopup

public JPopupMenu getEdgeLabelPopup(EdgeLabel label)
Provides a JPopupMenu that is displayed for the given edge label. If the JPopupMenu contains no elements or is null no popup menu will be displayed.


getNodeLabelPopup

public JPopupMenu getNodeLabelPopup(NodeLabel label)
Provides a JPopupMenu that is displayed for the given node label. If the JPopupMenu contains no elements or is null no popup menu will be displayed.

Parameters:
label - the label
Returns:
the popup menu for the label

setSelectSubject

public void setSelectSubject(boolean select)
Sets whether or not to automatically select the subject (node, edge, bend,...) for which the popup menu gets activated. By default the subject gets automatically selected.


getSelectSubject

public boolean getSelectSubject()

© Copyright 2000-2008,
yWorks GmbH.
All rights reserved.