public class DefaultVisualizationModel extends java.lang.Object implements VisualizationModel, ChangeEventSupport
| Modifier and Type | Class and Description |
|---|---|
protected class |
DefaultVisualizationModel.VisRunner
the relaxer thread that applies the Layout algorithm to the graph
|
| Modifier and Type | Field and Description |
|---|---|
protected javax.swing.event.ChangeListener |
changeListener |
protected Layout |
layout
the layout algorithm currently in use
|
java.lang.Object |
pauseObject |
protected long |
relaxerThreadSleepTime
how long the relaxer thread pauses between iteration loops.
|
protected StatusCallback |
statusCallback
a callback called during relaxer iteration
|
| Constructor and Description |
|---|
DefaultVisualizationModel(Layout layout) |
DefaultVisualizationModel(Layout layout,
java.awt.Dimension d) |
| Modifier and Type | Method and Description |
|---|---|
void |
addChangeListener(javax.swing.event.ChangeListener l)
Adds a
ChangeListener. |
protected double |
average(long[] paintTimes)
Returns the double average of a number of long values.
|
void |
fireStateChanged()
Notifies all listeners that have registered interest for
notification on this event type.
|
javax.swing.event.ChangeListener[] |
getChangeListeners()
Returns an array of all the
ChangeListeners added
with addChangeListener(). |
Layout |
getGraphLayout()
Returns the current graph layout.
|
long |
getRelaxerThreadSleepTime()
Returns the time between iterations of the
Relaxer thread.
|
void |
init()
Pre-relaxes and starts a visRunner thread
|
boolean |
isVisRunnerRunning()
Returns a flag that says whether the visRunner thread is running.
|
void |
prerelax()
Runs the visualization forward a few hundred iterations (for half a
second)
|
void |
removeChangeListener(javax.swing.event.ChangeListener l)
Removes a ChangeListener.
|
void |
restart()
Restarts layout, then calls init();
|
void |
restartThreadOnly()
starts a visRunner thread without prerelaxing
|
void |
setGraphLayout(Layout 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 layout,
java.awt.Dimension viewSize)
Removes the current graph layout, and adds a new one.
|
void |
setRelaxerThreadSleepTime(long relaxerThreadSleepTime)
Sets the relaxerThreadSleepTime.
|
void |
setTextCallback(StatusCallback scb)
set a callback to be called during the relaxer iteration
|
void |
start()
If the visualization runner is not yet running, kick it off.
|
void |
stop()
set a flag to stop the VisRunner relaxer thread
|
void |
suspend()
set a flag to suspend the relaxer thread
|
void |
unsuspend()
un-set the suspend flag for the relaxer thead
|
protected StatusCallback statusCallback
protected Layout layout
protected long relaxerThreadSleepTime
protected javax.swing.event.ChangeListener changeListener
public java.lang.Object pauseObject
public DefaultVisualizationModel(Layout layout)
layout - The Layout to apply, with its associated Graphpublic DefaultVisualizationModel(Layout layout, java.awt.Dimension d)
layout - d - The preferred size of the View that will display this graphpublic long getRelaxerThreadSleepTime()
getRelaxerThreadSleepTime in interface VisualizationModelpublic void setRelaxerThreadSleepTime(long relaxerThreadSleepTime)
setRelaxerThreadSleepTime in interface VisualizationModelrelaxerThreadSleepTime - The relaxerThreadSleepTime to set.getRelaxerThreadSleepTime()public void setGraphLayout(Layout layout, java.awt.Dimension viewSize)
setGraphLayout in interface VisualizationModellayout - the new layout to useviewSize - the size of the View that will display this layoutpublic void setGraphLayout(Layout layout)
setGraphLayout in interface VisualizationModelpublic Layout getGraphLayout()
getGraphLayout in interface VisualizationModelpublic void restartThreadOnly()
restartThreadOnly in interface VisualizationModelpublic void init()
init in interface VisualizationModelpublic void restart()
restart in interface VisualizationModelpublic void prerelax()
prerelax in interface VisualizationModelpublic void start()
start in interface VisualizationModelpublic void suspend()
suspend in interface VisualizationModelpublic void unsuspend()
unsuspend in interface VisualizationModelpublic boolean isVisRunnerRunning()
isVisRunnerRunning in interface VisualizationModelprotected double average(long[] paintTimes)
paintTimes - an array of longspublic void setTextCallback(StatusCallback scb)
VisualizationModelsetTextCallback in interface VisualizationModelscb - public void stop()
stop in interface VisualizationModelpublic void addChangeListener(javax.swing.event.ChangeListener l)
ChangeListener.addChangeListener in interface ChangeEventSupportaddChangeListener in interface VisualizationModell - the listener to be addedpublic void removeChangeListener(javax.swing.event.ChangeListener l)
removeChangeListener in interface ChangeEventSupportremoveChangeListener in interface VisualizationModell - the listener to be removedpublic javax.swing.event.ChangeListener[] getChangeListeners()
ChangeListeners added
with addChangeListener().getChangeListeners in interface ChangeEventSupportgetChangeListeners in interface VisualizationModelChangeListeners added or an empty
array if no listeners have been addedpublic void fireStateChanged()
fireStateChanged in interface ChangeEventSupportEventListenerList