edu.uci.ics.jung.visualization
Class DefaultVisualizationModel<V,E>

java.lang.Object
  extended by edu.uci.ics.jung.visualization.DefaultVisualizationModel<V,E>
All Implemented Interfaces:
ChangeEventSupport, VisualizationModel<V,E>

public class DefaultVisualizationModel<V,E>
extends Object
implements VisualizationModel<V,E>, ChangeEventSupport

The model containing state values for visualizations of graphs. Refactored and extracted from the 1.6.0 version of VisualizationViewer

Author:
Tom Nelson

Field Summary
protected  ChangeListener changeListener
          listens for changes in the layout, forwards to the viewer
protected  Layout<V,E> layout
          the layout algorithm currently in use
protected  Relaxer relaxer
          manages the thread that applies the current layout algorithm
 
Constructor Summary
DefaultVisualizationModel(Layout<V,E> layout)
           
DefaultVisualizationModel(Layout<V,E> layout, Dimension d)
           
 
Method Summary
 void addChangeListener(ChangeListener l)
          Adds a ChangeListener.
 void fireStateChanged()
          Notifies all listeners that have registered interest for notification on this event type.
 ChangeListener[] getChangeListeners()
          Returns an array of all the ChangeListeners added with addChangeListener().
 Layout<V,E> getGraphLayout()
          Returns the current graph layout.
 Relaxer getRelaxer()
           
 void removeChangeListener(ChangeListener l)
          Removes a ChangeListener.
 void setGraphLayout(Layout<V,E> layout)
          set the graph Layout and if it is not already initialized, initialize it to the default VisualizationViewer preferred size of 600x600
 void setGraphLayout(Layout<V,E> layout, Dimension viewSize)
          Removes the current graph layout, and adds a new one.
 void setRelaxer(VisRunner relaxer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

relaxer

protected Relaxer relaxer
manages the thread that applies the current layout algorithm


layout

protected Layout<V,E> layout
the layout algorithm currently in use


changeListener

protected ChangeListener changeListener
listens for changes in the layout, forwards to the viewer

Constructor Detail

DefaultVisualizationModel

public DefaultVisualizationModel(Layout<V,E> layout)
Parameters:
layout - The Layout to apply, with its associated Graph

DefaultVisualizationModel

public DefaultVisualizationModel(Layout<V,E> layout,
                                 Dimension d)
Parameters:
layout -
d - The preferred size of the View that will display this graph
Method Detail

setGraphLayout

public void setGraphLayout(Layout<V,E> layout,
                           Dimension viewSize)
Removes the current graph layout, and adds a new one.

Specified by:
setGraphLayout in interface VisualizationModel<V,E>
Parameters:
layout - the new layout to use
viewSize - the size of the View that will display this layout

setGraphLayout

public void setGraphLayout(Layout<V,E> layout)
set the graph Layout and if it is not already initialized, initialize it to the default VisualizationViewer preferred size of 600x600

Specified by:
setGraphLayout in interface VisualizationModel<V,E>

getGraphLayout

public Layout<V,E> getGraphLayout()
Returns the current graph layout.

Specified by:
getGraphLayout in interface VisualizationModel<V,E>

getRelaxer

public Relaxer getRelaxer()
Specified by:
getRelaxer in interface VisualizationModel<V,E>
Returns:
the relaxer

setRelaxer

public void setRelaxer(VisRunner relaxer)
Parameters:
relaxer - the relaxer to set

addChangeListener

public void addChangeListener(ChangeListener l)
Adds a ChangeListener.

Specified by:
addChangeListener in interface ChangeEventSupport
Specified by:
addChangeListener in interface VisualizationModel<V,E>
Parameters:
l - the listener to be added

removeChangeListener

public void removeChangeListener(ChangeListener l)
Removes a ChangeListener.

Specified by:
removeChangeListener in interface ChangeEventSupport
Specified by:
removeChangeListener in interface VisualizationModel<V,E>
Parameters:
l - the listener to be removed

getChangeListeners

public ChangeListener[] getChangeListeners()
Returns an array of all the ChangeListeners added with addChangeListener().

Specified by:
getChangeListeners in interface ChangeEventSupport
Specified by:
getChangeListeners in interface VisualizationModel<V,E>
Returns:
all of the ChangeListeners added or an empty array if no listeners have been added

fireStateChanged

public void fireStateChanged()
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created. The primary listeners will be views that need to be repainted because of changes in this model instance

Specified by:
fireStateChanged in interface ChangeEventSupport
See Also:
EventListenerList


Copyright © 2009. All Rights Reserved.