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
ChangeListener s 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 VisualizationModel
public void setRelaxerThreadSleepTime(long relaxerThreadSleepTime)
setRelaxerThreadSleepTime
in interface VisualizationModel
relaxerThreadSleepTime
- The relaxerThreadSleepTime to set.getRelaxerThreadSleepTime()
public void setGraphLayout(Layout layout, java.awt.Dimension viewSize)
setGraphLayout
in interface VisualizationModel
layout
- the new layout to useviewSize
- the size of the View that will display this layoutpublic void setGraphLayout(Layout layout)
setGraphLayout
in interface VisualizationModel
public Layout getGraphLayout()
getGraphLayout
in interface VisualizationModel
public void restartThreadOnly()
restartThreadOnly
in interface VisualizationModel
public void init()
init
in interface VisualizationModel
public void restart()
restart
in interface VisualizationModel
public void prerelax()
prerelax
in interface VisualizationModel
public void start()
start
in interface VisualizationModel
public void suspend()
suspend
in interface VisualizationModel
public void unsuspend()
unsuspend
in interface VisualizationModel
public boolean isVisRunnerRunning()
isVisRunnerRunning
in interface VisualizationModel
protected double average(long[] paintTimes)
paintTimes
- an array of longspublic void setTextCallback(StatusCallback scb)
VisualizationModel
setTextCallback
in interface VisualizationModel
scb
- public void stop()
stop
in interface VisualizationModel
public void addChangeListener(javax.swing.event.ChangeListener l)
ChangeListener
.addChangeListener
in interface ChangeEventSupport
addChangeListener
in interface VisualizationModel
l
- the listener to be addedpublic void removeChangeListener(javax.swing.event.ChangeListener l)
removeChangeListener
in interface ChangeEventSupport
removeChangeListener
in interface VisualizationModel
l
- the listener to be removedpublic javax.swing.event.ChangeListener[] getChangeListeners()
ChangeListener
s added
with addChangeListener().getChangeListeners
in interface ChangeEventSupport
getChangeListeners
in interface VisualizationModel
ChangeListener
s added or an empty
array if no listeners have been addedpublic void fireStateChanged()
fireStateChanged
in interface ChangeEventSupport
EventListenerList