Class AbstractModalGraphMouse
- java.lang.Object
-
- edu.uci.ics.jung.visualization.control.PluggableGraphMouse
-
- edu.uci.ics.jung.visualization.control.AbstractModalGraphMouse
-
- All Implemented Interfaces:
ModalGraphMouse,VisualizationViewer.GraphMouse,java.awt.event.MouseListener,java.awt.event.MouseMotionListener,java.awt.event.MouseWheelListener,java.awt.ItemSelectable,java.util.EventListener
- Direct Known Subclasses:
AnnotatingModalGraphMouse,DefaultModalGraphMouse,EditingModalGraphMouse,ModalLensGraphMouse
public abstract class AbstractModalGraphMouse extends PluggableGraphMouse implements ModalGraphMouse, java.awt.ItemSelectable
AbstractModalGraphMouse is a PluggableGraphMouse class that manages a collection of plugins for picking and transforming the graph. Additionally, it carries the notion of a Mode: Picking or Translating. Switching between modes allows for a more natural choice of mouse modifiers to be used for the various plugins. The default modifiers are intended to mimick those of mainstream software applications in order to be intuitive to users. To change between modes, two different controls are offered, a combo box and a menu system. These controls are lazily created in their respective 'getter' methods so they don't impact code that does not intend to use them. The menu control can be placed in an unused corner of the GraphZoomScrollPane, which is a common location for mouse mode selection menus in mainstream applications. Users must implement the loadPlugins() method to create and install the GraphMousePlugins. The order of the plugins is important, as they are evaluated against the mask parameters in the order that they are added.- Author:
- Tom Nelson
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface edu.uci.ics.jung.visualization.control.ModalGraphMouse
ModalGraphMouse.Mode
-
-
Field Summary
Fields Modifier and Type Field Description protected GraphMousePluginanimatedPickingPluginprotected floatinused by the scaling plugins for zoom inprotected javax.swing.event.EventListenerListlistenerListlisteners for mode changesprotected ModalGraphMouse.Modemodethe current modeprotected javax.swing.JComboBox<ModalGraphMouse.Mode>modeBoxa JComboBox control available to set the modeprotected java.awt.event.KeyListenermodeKeyListenerprotected java.awt.event.ItemListenermodeListenera listener for mode changesprotected javax.swing.JMenumodeMenua menu available to set the modeprotected floatoutused by the scaling plugins for zoom outprotected GraphMousePluginpickingPluginprotected GraphMousePluginrotatingPluginprotected GraphMousePluginscalingPluginprotected GraphMousePluginshearingPluginprotected GraphMousePlugintranslatingPlugin
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractModalGraphMouse(float in, float out)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddItemListener(java.awt.event.ItemListener aListener)add a listener for mode changesprotected voidfireItemStateChanged(java.awt.event.ItemEvent e)Notifies all listeners that have registered interest for notification on this event type.java.awt.event.ItemListener[]getItemListeners()Returns an array of all theItemListeners added to this JComboBox with addItemListener().javax.swing.JComboBox<ModalGraphMouse.Mode>getModeComboBox()java.awt.event.KeyListenergetModeKeyListener()java.awt.event.ItemListenergetModeListener()javax.swing.JMenugetModeMenu()create (if necessary) and return a menu that will change the modejava.lang.Object[]getSelectedObjects()protected abstract voidloadPlugins()create the plugins, and load the plugins for TRANSFORMING modevoidremoveItemListener(java.awt.event.ItemListener aListener)remove a listener for mode changesvoidsetMode(ModalGraphMouse.Mode mode)setter for the Mode.voidsetModeKeyListener(java.awt.event.KeyListener modeKeyListener)protected voidsetPickingMode()protected voidsetTransformingMode()voidsetZoomAtMouse(boolean zoomAtMouse)-
Methods inherited from class edu.uci.ics.jung.visualization.control.PluggableGraphMouse
add, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved, remove
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
-
-
Field Detail
-
in
protected float in
used by the scaling plugins for zoom in
-
out
protected float out
used by the scaling plugins for zoom out
-
modeListener
protected java.awt.event.ItemListener modeListener
a listener for mode changes
-
modeBox
protected javax.swing.JComboBox<ModalGraphMouse.Mode> modeBox
a JComboBox control available to set the mode
-
modeMenu
protected javax.swing.JMenu modeMenu
a menu available to set the mode
-
mode
protected ModalGraphMouse.Mode mode
the current mode
-
listenerList
protected javax.swing.event.EventListenerList listenerList
listeners for mode changes
-
pickingPlugin
protected GraphMousePlugin pickingPlugin
-
translatingPlugin
protected GraphMousePlugin translatingPlugin
-
animatedPickingPlugin
protected GraphMousePlugin animatedPickingPlugin
-
scalingPlugin
protected GraphMousePlugin scalingPlugin
-
rotatingPlugin
protected GraphMousePlugin rotatingPlugin
-
shearingPlugin
protected GraphMousePlugin shearingPlugin
-
modeKeyListener
protected java.awt.event.KeyListener modeKeyListener
-
-
Method Detail
-
loadPlugins
protected abstract void loadPlugins()
create the plugins, and load the plugins for TRANSFORMING mode
-
setMode
public void setMode(ModalGraphMouse.Mode mode)
setter for the Mode.- Specified by:
setModein interfaceModalGraphMouse
-
setPickingMode
protected void setPickingMode()
-
setTransformingMode
protected void setTransformingMode()
-
setZoomAtMouse
public void setZoomAtMouse(boolean zoomAtMouse)
- Parameters:
zoomAtMouse- The zoomAtMouse to set.
-
getModeListener
public java.awt.event.ItemListener getModeListener()
- Specified by:
getModeListenerin interfaceModalGraphMouse- Returns:
- Returns the modeListener.
-
getModeKeyListener
public java.awt.event.KeyListener getModeKeyListener()
- Returns:
- the modeKeyListener
-
setModeKeyListener
public void setModeKeyListener(java.awt.event.KeyListener modeKeyListener)
- Parameters:
modeKeyListener- the modeKeyListener to set
-
getModeComboBox
public javax.swing.JComboBox<ModalGraphMouse.Mode> getModeComboBox()
- Returns:
- Returns the modeBox.
-
getModeMenu
public javax.swing.JMenu getModeMenu()
create (if necessary) and return a menu that will change the mode- Returns:
- the menu
-
addItemListener
public void addItemListener(java.awt.event.ItemListener aListener)
add a listener for mode changes- Specified by:
addItemListenerin interfacejava.awt.ItemSelectable
-
removeItemListener
public void removeItemListener(java.awt.event.ItemListener aListener)
remove a listener for mode changes- Specified by:
removeItemListenerin interfacejava.awt.ItemSelectable
-
getItemListeners
public java.awt.event.ItemListener[] getItemListeners()
Returns an array of all theItemListeners added to this JComboBox with addItemListener().- Returns:
- all of the
ItemListeners added or an empty array if no listeners have been added - Since:
- 1.4
-
getSelectedObjects
public java.lang.Object[] getSelectedObjects()
- Specified by:
getSelectedObjectsin interfacejava.awt.ItemSelectable
-
fireItemStateChanged
protected void fireItemStateChanged(java.awt.event.ItemEvent e)
Notifies all listeners that have registered interest for notification on this event type.- Parameters:
e- the event of interest- See Also:
EventListenerList
-
-