JGraphpad Pro
v6.0.5.0


com.jgraph.pad.util
Class JGraphpadFocusManager

java.lang.Object
  extended byjava.util.Observable
      extended bycom.jgraph.pad.util.JGraphpadFocusManager
All Implemented Interfaces:
EventListener, org.jgraph.event.GraphLayoutCacheListener, org.jgraph.event.GraphModelListener, org.jgraph.event.GraphSelectionListener, MouseListener, MouseMotionListener, PropertyChangeListener, UndoableEditListener

public class JGraphpadFocusManager
extends Observable
implements org.jgraph.event.GraphLayoutCacheListener, org.jgraph.event.GraphModelListener, org.jgraph.event.GraphSelectionListener, MouseListener, MouseMotionListener, UndoableEditListener, PropertyChangeListener

Indirection to dispatch events from the permanent focus owner graph to the registered listeners. For redispatching mouse events the built-in multicasters are used.

See Also:
AWTEventMulticaster

Field Summary
protected  SwingPropertyChangeSupport changeSupport
          Property change support for event notification.
static JGraphpadFocusManager currentGraphFocusManager
          Shared singleton instance.
static String FOCUSED_GRAPH_PROPERTY
          Bound property name for focusedGraph.
protected  org.jgraph.JGraph focusedGraph
          Reference to the current and last focused graph.
static String GRAPHLAYOUT_CHANGE_NOTIFICATION
          Bound property name for graph layout changes.
protected  EventListenerList listenerList
          Listeners to all graph-specific events (the other use event multicasters).
static String MODEL_CHANGE_NOTIFICATION
          Bound property name for model changes.
protected  MouseListener mouseListener
          Used to manage mouse listeners as an event multicaster.
protected  MouseMotionListener mouseMotionListener
          Used to manage mouse motion listeners as an event multicaster.
static String SELECTION_CHANGE_NOTIFICATION
          Bound property name for graph selection changes.
static String UNDOABLE_CHANGE_NOTIFICATION
          Bound property name for graph undoable changes.
 
Constructor Summary
JGraphpadFocusManager()
          Constructs a new focus manager.
 
Method Summary
 void addGraphLayoutCacheListener(org.jgraph.event.GraphLayoutCacheListener l)
          Adds a listener for the GraphLayoutCacheEvent posted after the graph layout cache changes.
 void addGraphModelListener(org.jgraph.event.GraphModelListener l)
          Adds a listener for the GraphModelEvent posted after the graph changes.
 void addGraphSelectionListener(org.jgraph.event.GraphSelectionListener x)
          Adds x to the list of listeners that are notified each time the set of selected cells changes.
 void addMouseListener(MouseListener l)
          Adds a listener for the MouseEvent.
 void addMouseMotionListener(MouseMotionListener l)
          Adds a listener for the MouseMotionEvent.
 void addPropertyChangeListener(PropertyChangeListener listener)
          Adds a PropertyChangeListener to the listener list.
protected  void fireGraphChanged(org.jgraph.event.GraphModelEvent e)
          Notify all listeners that have registered interest for notification on this event type.
protected  void fireGraphLayoutCacheChanged(org.jgraph.event.GraphLayoutCacheEvent e)
          Notifies all listeners that have registered interest for notification on this event type.
protected  void fireValueChanged(org.jgraph.event.GraphSelectionEvent e)
          Notifies all listeners that are registered for graph selection events on this object.
static JGraphpadFocusManager getCurrentGraphFocusManager()
          Returns the shared graph focused manager.
 org.jgraph.JGraph getFocusedGraph()
          Returns the focused graph.
 org.jgraph.event.GraphLayoutCacheListener[] getGraphLayoutCacheListeners()
          Returns an array of all GraphModelListeners that were added to this model.
 org.jgraph.event.GraphModelListener[] getGraphModelListeners()
          Return an array of all graph model listeners.
 EventListener[] getListeners(Class listenerType)
          Returns an array of all the listeners of the given type that were added to this manager.
 void graphChanged(org.jgraph.event.GraphModelEvent e)
          Redispatches the graph model event and fires a property change for MODEL_CHANGE_NOTIFICATION.
 void graphLayoutCacheChanged(org.jgraph.event.GraphLayoutCacheEvent e)
          Redispatches the graph layout cache event and fires a property change for UNDOABLE_CHANGE_NOTIFICATION.
protected  void installListeners(org.jgraph.JGraph graph)
          Installs all listeners in the specified graph.
 void mouseClicked(MouseEvent arg0)
          Redirects the mouse event to the registered listeners.
 void mouseDragged(MouseEvent arg0)
          Redirects the mouse event to the registered listeners.
 void mouseEntered(MouseEvent arg0)
          Redirects the mouse event to the registered listeners.
 void mouseExited(MouseEvent arg0)
          Redirects the mouse event to the registered listeners.
 void mouseMoved(MouseEvent arg0)
          Redirects the mouse event to the registered listeners.
 void mousePressed(MouseEvent arg0)
          Redirects the mouse event to the registered listeners.
 void mouseReleased(MouseEvent arg0)
          Redirects the mouse event to the registered listeners.
 void propertyChange(PropertyChangeEvent evt)
          Redispatches the property change event using the changeSupport.
 void removeGraphLayoutCacheListener(org.jgraph.event.GraphLayoutCacheListener l)
          Removes a listener previously added with addGraphModelListener() .
 void removeGraphModelListener(org.jgraph.event.GraphModelListener l)
          Removes a listener previously added with addGraphModelListener() .
 void removeGraphSelectionListener(org.jgraph.event.GraphSelectionListener x)
          Removes x from the list of listeners that are notified each time the set of selected cells changes.
 void removeMouseListener(MouseListener l)
          Removes a listener previously added with addMouseListener() .
 void removeMouseMotionListener(MouseMotionListener l)
          Removes a listener previously added with addMouseMotionListeneraddMouseMotionListener() .
 void removePropertyChangeListener(PropertyChangeListener listener)
          Removes a PropertyChangeListener from the listener list.
 void setFocusedGraph(org.jgraph.JGraph newGraph)
          Sets the focused graph to the specified value.
 void undoableEditHappened(UndoableEditEvent e)
          Fires a property change for UNDOABLE_CHANGE_NOTIFICATION.
protected  void uninstallListeners(org.jgraph.JGraph graph)
          Uninstalls all listeners previously registered using installListeners(JGraph) from the specified graph.
 void valueChanged(org.jgraph.event.GraphSelectionEvent e)
          Redirects the value change event and fires a property change for SELECTION_CHANGE_NOTIFICATION.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FOCUSED_GRAPH_PROPERTY

public static final String FOCUSED_GRAPH_PROPERTY
Bound property name for focusedGraph.

See Also:
Constant Field Values

MODEL_CHANGE_NOTIFICATION

public static final String MODEL_CHANGE_NOTIFICATION
Bound property name for model changes. This is fired whenever a graph model event is received from the focused graph.

See Also:
Constant Field Values

GRAPHLAYOUT_CHANGE_NOTIFICATION

public static final String GRAPHLAYOUT_CHANGE_NOTIFICATION
Bound property name for graph layout changes. This is fired whenever a graph layout event is received from the focused graph.

See Also:
Constant Field Values

SELECTION_CHANGE_NOTIFICATION

public static final String SELECTION_CHANGE_NOTIFICATION
Bound property name for graph selection changes. This is fired whenever a graph selection event is received from the focused graph.

See Also:
Constant Field Values

UNDOABLE_CHANGE_NOTIFICATION

public static final String UNDOABLE_CHANGE_NOTIFICATION
Bound property name for graph undoable changes. This is fired whenever a graph undoable event is received from the focused graph.

See Also:
Constant Field Values

currentGraphFocusManager

public static JGraphpadFocusManager currentGraphFocusManager
Shared singleton instance.


listenerList

protected transient EventListenerList listenerList
Listeners to all graph-specific events (the other use event multicasters).


changeSupport

protected SwingPropertyChangeSupport changeSupport
Property change support for event notification.


mouseListener

protected MouseListener mouseListener
Used to manage mouse listeners as an event multicaster.


mouseMotionListener

protected MouseMotionListener mouseMotionListener
Used to manage mouse motion listeners as an event multicaster.


focusedGraph

protected org.jgraph.JGraph focusedGraph
Reference to the current and last focused graph.

Constructor Detail

JGraphpadFocusManager

public JGraphpadFocusManager()
Constructs a new focus manager.

Method Detail

getCurrentGraphFocusManager

public static JGraphpadFocusManager getCurrentGraphFocusManager()
Returns the shared graph focused manager.

Returns:
Returns the shared graph focus manager.

getFocusedGraph

public org.jgraph.JGraph getFocusedGraph()
Returns the focused graph.

Returns:
Returns the focused graph.

setFocusedGraph

public void setFocusedGraph(org.jgraph.JGraph newGraph)
Sets the focused graph to the specified value. If the current focused graph points to a different instance then newGraph then this implementation updates the last focused graph with the current focused graph and removes all listeners from either the current graph or the last focused graph if the current graph is null. This method fires a property change event for FOCUSED_GRAPH_PROPERTY.

Parameters:
newGraph - The new focused graph.

installListeners

protected void installListeners(org.jgraph.JGraph graph)
Installs all listeners in the specified graph.

Parameters:
graph - The graph to install the listeners to.

uninstallListeners

protected void uninstallListeners(org.jgraph.JGraph graph)
Uninstalls all listeners previously registered using installListeners(JGraph) from the specified graph.

Parameters:
graph - The graph to uninstall the listeners from.

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list. The listener is registered for all properties.

Parameters:
listener - the PropertyChangeListener to be added

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties.

Parameters:
listener - the PropertyChangeListener to be removed

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Redispatches the property change event using the changeSupport.

Specified by:
propertyChange in interface PropertyChangeListener

undoableEditHappened

public void undoableEditHappened(UndoableEditEvent e)
Fires a property change for UNDOABLE_CHANGE_NOTIFICATION.

Specified by:
undoableEditHappened in interface UndoableEditListener
See Also:
UndoableEditListener.undoableEditHappened(javax.swing.event.UndoableEditEvent)

graphLayoutCacheChanged

public void graphLayoutCacheChanged(org.jgraph.event.GraphLayoutCacheEvent e)
Redispatches the graph layout cache event and fires a property change for UNDOABLE_CHANGE_NOTIFICATION.

Specified by:
graphLayoutCacheChanged in interface org.jgraph.event.GraphLayoutCacheListener
See Also:
UndoableEditListener.undoableEditHappened(javax.swing.event.UndoableEditEvent)

addGraphLayoutCacheListener

public void addGraphLayoutCacheListener(org.jgraph.event.GraphLayoutCacheListener l)
Adds a listener for the GraphLayoutCacheEvent posted after the graph layout cache changes.

Parameters:
l - the listener to add
See Also:
removeGraphLayoutCacheListener(GraphLayoutCacheListener)

removeGraphLayoutCacheListener

public void removeGraphLayoutCacheListener(org.jgraph.event.GraphLayoutCacheListener l)
Removes a listener previously added with addGraphModelListener() .

Parameters:
l - the listener to remove
See Also:
addGraphLayoutCacheListener(GraphLayoutCacheListener)

fireGraphLayoutCacheChanged

protected void fireGraphLayoutCacheChanged(org.jgraph.event.GraphLayoutCacheEvent e)
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.

See Also:
EventListenerList

getGraphLayoutCacheListeners

public org.jgraph.event.GraphLayoutCacheListener[] getGraphLayoutCacheListeners()
Returns an array of all GraphModelListeners that were added to this model.


graphChanged

public void graphChanged(org.jgraph.event.GraphModelEvent e)
Redispatches the graph model event and fires a property change for MODEL_CHANGE_NOTIFICATION.

Specified by:
graphChanged in interface org.jgraph.event.GraphModelListener
See Also:
GraphModelListener.graphChanged(org.jgraph.event.GraphModelEvent)

addGraphModelListener

public void addGraphModelListener(org.jgraph.event.GraphModelListener l)
Adds a listener for the GraphModelEvent posted after the graph changes.

Parameters:
l - the listener to add
See Also:
removeGraphModelListener(GraphModelListener)

removeGraphModelListener

public void removeGraphModelListener(org.jgraph.event.GraphModelListener l)
Removes a listener previously added with addGraphModelListener() .

Parameters:
l - the listener to remove
See Also:
addGraphModelListener(GraphModelListener)

fireGraphChanged

protected void fireGraphChanged(org.jgraph.event.GraphModelEvent e)
Notify all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.

See Also:
EventListenerList

getGraphModelListeners

public org.jgraph.event.GraphModelListener[] getGraphModelListeners()
Return an array of all graph model listeners.


valueChanged

public void valueChanged(org.jgraph.event.GraphSelectionEvent e)
Redirects the value change event and fires a property change for SELECTION_CHANGE_NOTIFICATION.

Specified by:
valueChanged in interface org.jgraph.event.GraphSelectionListener
See Also:
GraphSelectionListener.valueChanged(org.jgraph.event.GraphSelectionEvent)

addGraphSelectionListener

public void addGraphSelectionListener(org.jgraph.event.GraphSelectionListener x)
Adds x to the list of listeners that are notified each time the set of selected cells changes.

Parameters:
x - the new listener to be added

removeGraphSelectionListener

public void removeGraphSelectionListener(org.jgraph.event.GraphSelectionListener x)
Removes x from the list of listeners that are notified each time the set of selected cells changes.

Parameters:
x - the listener to remove

fireValueChanged

protected void fireValueChanged(org.jgraph.event.GraphSelectionEvent e)
Notifies all listeners that are registered for graph selection events on this object.

See Also:
addGraphSelectionListener(GraphSelectionListener), EventListenerList

getListeners

public EventListener[] getListeners(Class listenerType)
Returns an array of all the listeners of the given type that were added to this manager.

Returns:
all of the objects receiving listenerType notifications from this model

addMouseListener

public void addMouseListener(MouseListener l)
Adds a listener for the MouseEvent.

Parameters:
l - the listener to add
See Also:
removeMouseListener(MouseListener)

removeMouseListener

public void removeMouseListener(MouseListener l)
Removes a listener previously added with addMouseListener() .

Parameters:
l - the listener to remove
See Also:
addMouseListener(MouseListener)

addMouseMotionListener

public void addMouseMotionListener(MouseMotionListener l)
Adds a listener for the MouseMotionEvent.

Parameters:
l - the listener to add
See Also:
removeMouseMotionListener(MouseMotionListener)

removeMouseMotionListener

public void removeMouseMotionListener(MouseMotionListener l)
Removes a listener previously added with addMouseMotionListeneraddMouseMotionListener() .

Parameters:
l - the listener to remove
See Also:
addMouseListener(MouseListener)

mouseClicked

public void mouseClicked(MouseEvent arg0)
Redirects the mouse event to the registered listeners.

Specified by:
mouseClicked in interface MouseListener
See Also:
MouseListener.mouseClicked(java.awt.event.MouseEvent)

mousePressed

public void mousePressed(MouseEvent arg0)
Redirects the mouse event to the registered listeners.

Specified by:
mousePressed in interface MouseListener
See Also:
MouseListener.mousePressed(java.awt.event.MouseEvent)

mouseReleased

public void mouseReleased(MouseEvent arg0)
Redirects the mouse event to the registered listeners.

Specified by:
mouseReleased in interface MouseListener
See Also:
MouseListener.mouseReleased(java.awt.event.MouseEvent)

mouseEntered

public void mouseEntered(MouseEvent arg0)
Redirects the mouse event to the registered listeners.

Specified by:
mouseEntered in interface MouseListener
See Also:
MouseListener.mouseEntered(java.awt.event.MouseEvent)

mouseExited

public void mouseExited(MouseEvent arg0)
Redirects the mouse event to the registered listeners.

Specified by:
mouseExited in interface MouseListener
See Also:
MouseListener.mouseExited(java.awt.event.MouseEvent)

mouseDragged

public void mouseDragged(MouseEvent arg0)
Redirects the mouse event to the registered listeners.

Specified by:
mouseDragged in interface MouseMotionListener
See Also:
MouseMotionListener.mouseDragged(java.awt.event.MouseEvent)

mouseMoved

public void mouseMoved(MouseEvent arg0)
Redirects the mouse event to the registered listeners.

Specified by:
mouseMoved in interface MouseMotionListener
See Also:
MouseMotionListener.mouseMoved(java.awt.event.MouseEvent)

JGraphpad Pro
v6.0.5.0


Copyright (C) 2005 JGraph.com. All rights reserved.