|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.graffiti.plugin.algorithm.animation.AbstractAnimation
org.graffiti.plugins.algorithms.mst.animation.PrimsAlgorithmAnimation
public class PrimsAlgorithmAnimation
Animated version of Prim's algorithm; supports steps to previous states. This implementation uses instances of ForwardAnimation and BidirectionalAnimation to implement its iteration logic. Both use PrimsAlgorithmStep as a first step. Depending on which instance is used, this animation acts as either a forward or bidirectional animation. You select an instance by passing the appropriate value of supportsPreviousSteps to this animation's constructor. This instance acts as a delegate for all public methods of this animation except isReady. Some of them such as supportsPreviousStep delegate directly to the enclosed instance, others such as nextStep augment the delegates functionality with additional processing. Consult the specification of these methods for further information.
Both delegates use instances of PrimsAlgorithmStep.
ForwardAnimation
,
BidirectionalAnimation
,
PrimsAlgorithmStep
,
PrimsAlgorithmAnimation(GraphAdapter, HeapAdapter, boolean)
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.graffiti.plugin.algorithm.animation.Animation |
---|
Animation.GraphModificationPolicy |
Field Summary |
---|
Fields inherited from interface org.graffiti.plugin.algorithm.animation.Animation |
---|
EMPTY_ANIMATION |
Constructor Summary | |
---|---|
PrimsAlgorithmAnimation(org.graffiti.plugins.algorithms.mst.adapters.GraphAdapter g,
org.graffiti.plugins.algorithms.mst.adapters.HeapAdapter h,
boolean supportsPreviousSteps)
Initializes this animation with the given GraphProxy and HeapProxy. |
Method Summary | |
---|---|
void |
disableGraphModificationPolicy()
Disables the graph modification policies of all instances of PrimsAlgorithmAnimation. |
void |
enableGraphModificationPolicy()
Enables the graph modification policies of all instances of PrimsAlgorithmAnimation. |
String |
getName()
Returns "Prim's Algorithm". |
boolean |
hasNextStep()
Returns true if this animation has a next step. |
boolean |
hasPreviousStep()
Returns true if this animation has a previous step. |
boolean |
isCleared()
Returns true if this animation is cleared. |
boolean |
isReady()
Returns true if the preconditions of the algorithm underlying this animation are satisfied. |
void |
performClear()
Resets this animation to its initial state. |
void |
performNextStep()
Computes the next state of the underlying algorithm; i.e. |
void |
performPreviousStep()
Computes the previous state of the underlying algorithm; i.e. |
boolean |
supportsClear()
This animation supports clear; returns true. |
boolean |
supportsPreviousStep()
Returns true if this animation supports steps to previous states of the underlying algorithm. |
Methods inherited from class org.graffiti.plugin.algorithm.animation.AbstractAnimation |
---|
clear, getGraphModificationPolicy, nextStep, previousStep |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PrimsAlgorithmAnimation(org.graffiti.plugins.algorithms.mst.adapters.GraphAdapter g, org.graffiti.plugins.algorithms.mst.adapters.HeapAdapter h, boolean supportsPreviousSteps)
Depending on the value of supportsPreviousSteps this animation is initialized either with an instance of ForwardAnimation or BidirectionalAnimation. This instance acts as a delegate for calls to all public methods except isReady.
g
- h
- supportsPreviousSteps
- Method Detail |
---|
public boolean isReady()
This implementation returns true if the underlying graph of this animation is undirected and connected.
isReady
in interface Animation
isReady
in class AbstractAnimation
public boolean hasNextStep()
This implementation first checks whether this animation is ready. If not it throws IllegalStateException. Otherwise it checks whether this animation is cleared. If so, it returns true if the underlying graph is not empty. Otherwise it delegates to hasNextStep of its enclosed Animation instance.
hasNextStep
in interface Animation
hasNextStep
in class AbstractAnimation
public boolean supportsPreviousStep()
This implementation delegates to supportsPreviousStep of its enclosed Animation instance.
supportsPreviousStep
in interface Animation
supportsPreviousStep
in class AbstractAnimation
public boolean hasPreviousStep()
This implementation first checks whether this animation is ready. If not it throws IllegalStateException. Otherwise it delegates to hasPreviousStep of its enclosed Animation instance.
hasPreviousStep
in interface Animation
hasPreviousStep
in class AbstractAnimation
IllegalStateException
- if this animation is not ready.Animation.previousStep()
,
Animation.supportsPreviousStep()
public void performNextStep()
This implementation first checks whether this animation is ready. If not it throws IllegalStateException. Otherwise if proceeds as follows:
performNextStep
in class AbstractAnimation
IllegalStateException
- if this animation does not have a next step.
IllegalStateException
- if this animation is not ready.hasNextStep()
,
isReady()
public void performPreviousStep()
This implementation first checks whether this animation is ready. If not it throws IllegalStateException. Otherwise it delegates to previousStep of the enclosed Animation instance.
performPreviousStep
in class AbstractAnimation
IllegalStateException
- if this animation does not have a previous step or does not
support steps to previous states at all.
IllegalStateException
- if this animation is not ready.
UnsupportedOperationException
- if this animation does not support steps to previous states.supportsPreviousStep()
,
hasPreviousStep()
,
isReady()
public boolean supportsClear()
supportsClear
in interface Animation
supportsClear
in class AbstractAnimation
AbstractAnimation.clear()
,
AbstractAnimation.isCleared()
public boolean isCleared()
isCleared
in interface Animation
isCleared
in class AbstractAnimation
AbstractAnimation.supportsClear()
,
AbstractAnimation.clear()
public void performClear()
This implementation first calls clear on this animation's delegate. Then this animations GraphProxy and HeapProxy instance are cleared.
performClear
in class AbstractAnimation
GraphAdapter.clear()
,
HeapAdapter.clear()
public String getName()
getName
in interface Animation
getName
in class AbstractAnimation
public void enableGraphModificationPolicy()
enableGraphModificationPolicy
in class AbstractAnimation
AbstractAnimation.graphModificationPolicy
public void disableGraphModificationPolicy()
disableGraphModificationPolicy
in class AbstractAnimation
AbstractAnimation.graphModificationPolicy
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |