com.jgraph.navigation

Class GraphNavigator

public class GraphNavigator extends JPanel implements GraphLayoutCacheListener, GraphModelListener, PropertyChangeListener, AdjustmentListener

Nested Class Summary
classGraphNavigator.NavigatorPane
Scrollpane that implements special painting used for the navigator preview.
Field Summary
protected JGraphbackingGraph
Holds the backing graph and references the displayed (current) graph.
protected ComponentListenercomponentListener
Component listener to udpate the scale.
protected WeakReferencecurrentGraph
Weak reference to the current graph.
protected static CursorCURSOR_DEFAULT
Shared cursor objects to avoid expensive constructor calls.
protected static CursorCURSOR_HAND
Shared cursor objects to avoid expensive constructor calls.
protected GraphLayoutCacheinitialLayoutCache
References the inital layout cache of the backing graph.
protected doublemaximumScale
Specifies the maximum scale for the navigator view.
protected GraphNavigator.NavigatorPanenavigatorPane
Holds the navigator pane the displays the backing graph.
Constructor Summary
GraphNavigator(JGraph backingGraph)
Constructs a new graph navigator using backingGraph to display the graph in currentGraph.
Method Summary
voidadjustmentValueChanged(AdjustmentEvent e)
static GraphNavigatorcreateInstance(JGraph graph)
JGraphgetBackingGraph()
Returns the backing graph that is used to display currentGraph.
JGraphgetCurrentGraph()
Returns the graph that is currently displayed.
doublegetMaximumScale()
Returns the maximum scale to be used for the backing graph.
static JGraphgetParentGraph(Component component)
Helper method that returns the parent JGraph for the specified component in the component hierarchy.
static JScrollPanegetParentScrollPane(Component component)
Helper method that returns the parent scrollpane for the specified component in the component hierarchy.
GraphNavigator.NavigatorPanegetScrollPane()
Returns the navigator pane that contains the backing graph.
voidgraphChanged(GraphModelEvent e)
voidgraphLayoutCacheChanged(GraphLayoutCacheEvent e)
voidpropertyChange(PropertyChangeEvent event)
voidsetBackingGraph(JGraph backingGraph)
Sets the backing graph that is used to display currentGraph.
voidsetCurrentGraph(JGraph sourceGraph)
Sets the graph that is currently displayed.
voidsetMaximumScale(double maximumScale)
Sets the maximum scale to be used for the backing graph.
protected voidupdateScale()
Updates the scale of the backing graph.

Field Detail

backingGraph

protected JGraph backingGraph
Holds the backing graph and references the displayed (current) graph.

componentListener

protected ComponentListener componentListener
Component listener to udpate the scale.

currentGraph

protected WeakReference currentGraph
Weak reference to the current graph.

CURSOR_DEFAULT

protected static final Cursor CURSOR_DEFAULT
Shared cursor objects to avoid expensive constructor calls.

CURSOR_HAND

protected static final Cursor CURSOR_HAND
Shared cursor objects to avoid expensive constructor calls.

initialLayoutCache

protected transient GraphLayoutCache initialLayoutCache
References the inital layout cache of the backing graph.

maximumScale

protected double maximumScale
Specifies the maximum scale for the navigator view. Default is 0.5

navigatorPane

protected GraphNavigator.NavigatorPane navigatorPane
Holds the navigator pane the displays the backing graph.

Constructor Detail

GraphNavigator

public GraphNavigator(JGraph backingGraph)
Constructs a new graph navigator using backingGraph to display the graph in currentGraph.

Parameters: backingGraph The backing graph to render the display.

Method Detail

adjustmentValueChanged

public void adjustmentValueChanged(AdjustmentEvent e)

createInstance

public static GraphNavigator createInstance(JGraph graph)

getBackingGraph

public JGraph getBackingGraph()
Returns the backing graph that is used to display currentGraph.

Returns: Returns the backing graph.

getCurrentGraph

public JGraph getCurrentGraph()
Returns the graph that is currently displayed.

Returns: Returns the backing graph.

getMaximumScale

public double getMaximumScale()
Returns the maximum scale to be used for the backing graph.

Returns: Returns the maximumScale.

getParentGraph

public static JGraph getParentGraph(Component component)
Helper method that returns the parent JGraph for the specified component in the component hierarchy. The component itself is never returned.

Returns: Returns the parent scrollpane or component.

getParentScrollPane

public static JScrollPane getParentScrollPane(Component component)
Helper method that returns the parent scrollpane for the specified component in the component hierarchy. If the component is itself a scrollpane then it is returned.

Returns: Returns the parent scrollpane or component.

getScrollPane

public GraphNavigator.NavigatorPane getScrollPane()
Returns the navigator pane that contains the backing graph.

Returns: Returns the navigator pane.

graphChanged

public void graphChanged(GraphModelEvent e)

graphLayoutCacheChanged

public void graphLayoutCacheChanged(GraphLayoutCacheEvent e)

propertyChange

public void propertyChange(PropertyChangeEvent event)

setBackingGraph

public void setBackingGraph(JGraph backingGraph)
Sets the backing graph that is used to display currentGraph.

Parameters: backingGraph The backing graph to set.

setCurrentGraph

public void setCurrentGraph(JGraph sourceGraph)
Sets the graph that is currently displayed.

Parameters: sourceGraph The current graph to set.

setMaximumScale

public void setMaximumScale(double maximumScale)
Sets the maximum scale to be used for the backing graph.

Parameters: maximumScale The maximumScale to set.

updateScale

protected void updateScale()
Updates the scale of the backing graph.
Copyright (C) 2001-2009 JGraph Ltd. All rights reserved.