|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.Observable fr.inria.opengve.bridge.algorithms.StepAlgo<V,E>
public abstract class StepAlgo<V,E extends Link<V>>
StepAlgo is a class wich provides a way of running an algorithm step by step.
The goal is to implement an algorithm in two way: the common way where the algorithm is running as fast as possible. The other way is to perform demos. We want in this case, pause each step of the algo during some seconds or waitings notification. This class implements this behavior.
Note that this class is derivated from Runnable wich implement the Thread system.
For optimisation reason you must set the step mode in the constructor (use of final modifier).
This class extends the Observable
class but the
notification mechanism is only activate when the class is in "demoMode".
There is five kinds of notifications (StepAlgo.StepAlgoMessage
) :
- StepAlgo.StepAlgoMessageType.PAUSE_NOTIFICATION
for notify
that algorithms leave a pause.
- StepAlgo.StepAlgoMessageType.END_NOTIFICATION
for notify that
algorithms call ends()
method.
- StepAlgo.StepAlgoMessageType.DISPLAY_GRAPH_NEW_WINDOW
send a
request to display a graph in a new window.
- StepAlgo.StepAlgoMessageType.EDGES_LABEL
send a request to
change edges labels.
- StepAlgo.StepAlgoMessageType.VERTICES_LABEL
send a request to
change vertices labels.
This class can be use with mascoptLib.gui.stepAlgoGui.StepAlgoGui
for
adding graphic representation.
Nested Class Summary | |
---|---|
class |
StepAlgo.StepAlgoMessage
This class is used by StepAlgo to notify this obsevers. |
static class |
StepAlgo.StepAlgoMessageType
Enum of the type of message. |
Constructor Summary | |
---|---|
StepAlgo(boolean demoMode)
Constructor that permit to specify the step by step mode. |
Method Summary | |
---|---|
void |
ends()
Indicate that this algorithm is terminated. |
boolean |
getDemoMode()
Say if the algorithm is in demo mode ie step by step. |
boolean |
getStepMode()
Say if the algorithms stop in pause() . |
boolean |
isEnded()
As the algorithm is run as a thread, we want to know when it ends. |
void |
nextStep()
When calling nextStep, the algorithm is unpaused. |
protected void |
notifyGraphDisplayRequest(Graph<V,E> g)
Send a graphic request. |
protected void |
notifyGraphDisplayRequest(Graph<V,E> g,
java.lang.String name)
Send a graphic request. |
protected void |
notifyLabelEdgesRequest(Graph<V,E> g,
Map m,
java.lang.Object context,
java.lang.String label)
Request a edges label display for a graph. |
protected void |
notifyLabelVerticesRequest(Graph<V,E> g,
Map m,
java.lang.Object context,
java.lang.String label)
Request a vertices label display for a graph. |
void |
pause()
Give a method to put a pause in your algorithm. |
abstract void |
run()
Run the algorithm. |
void |
setPauseMode(boolean pauseMode)
Change the behavior of pause() methods. |
void |
setTime(int time)
Set wait time in milliseconds |
java.lang.Thread |
start()
Launch the algorithm |
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 |
Constructor Detail |
---|
public StepAlgo(boolean demoMode)
demoMode
- The step by step mode of the algorithm.Method Detail |
---|
public void setTime(int time)
time
- the time to wait between stepspublic java.lang.Thread start()
public void nextStep()
public final boolean isEnded()
public void ends()
public void setPauseMode(boolean pauseMode)
pause()
methods.
pauseMode
- true
for waiting notification and
false
to wait a given time (setTime(int)
).public final boolean getStepMode()
pause()
.
true
if the algorithm pause in
pause()
and false
otherwise.public final boolean getDemoMode()
public final void pause()
public abstract void run()
run
in interface java.lang.Runnable
protected final void notifyGraphDisplayRequest(Graph<V,E> g)
g
- The graph to display.protected final void notifyGraphDisplayRequest(Graph<V,E> g, java.lang.String name)
g
- The graph to display.name
- The name of the windowsprotected final void notifyLabelEdgesRequest(Graph<V,E> g, Map m, java.lang.Object context, java.lang.String label)
g
- The graph.m
- The map to use to resolve names.context
- The context used to resolves names.label
- The label definition.protected final void notifyLabelVerticesRequest(Graph<V,E> g, Map m, java.lang.Object context, java.lang.String label)
g
- The graph.m
- The map to use to resolve names.context
- The context used to resolves names.label
- The label definition.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |