Class Algorithm
java.lang.Object
|
+----Algorithm
- public abstract class Algorithm
- extends Object
Algorithm.java
by Aaron Nall
Tue Jun 30 19:28:13 GMT 1998
This class is to serve as a superclass of all
algorithms for Jedit 3.x. Any properly written subclass
can be used in Jedit 3.1 or higher with a single line of
code in the JeditAlgorithms.java file.
-
description
- A Vector of strings that holds a descriptive paragraph
for each algorithm.
-
type
- A flag determining how the algorithm should be started by
Jedit.
-
Algorithm()
- This constructor only does the equivalent work of the call
succeeded(false);
-
Algorithm(JavaGraph, Vector, Vector)
- The intended constructor for all algorithms in Jedit3.0, it
is no longer called in Jedit3.1.
-
Algorithm(String)
- This constructor only does the equivalent work of the calls
succeeded(false); and setName(newName);
-
callOwnConstructor(JavaGraph, Vector, Vector)
- This method is called by Jedit for any algorithm it executes.
-
getDescription()
- Returns the description of the Vector as it will appear in the
description portion of the JeditAlgorithms menu.
-
getName()
- Return the algorithm's name as specified during
by the appropriate constructor or a call to the setName() method.
-
getType()
- Returns the type of the algorithm.
See type.
-
setName(String)
- Sets the algorithms name, as it will appear in the JeditAlgorithms menu, to newName.
-
succeeded()
- Returns true if the Algorithm succeeded,
otherwise returns false.
-
succeeded(boolean)
- Use this to report a successful or unseccessful algorithm executions.
description
protected Vector description
- A Vector of strings that holds a descriptive paragraph
for each algorithm. It must be instantiated in the subclasses'
constructors.
type
protected int type
- A flag determining how the algorithm should be started by
Jedit. The options are:
- JeditPanel.ONECLICKALGORITHM: For algorithms that require that the user click on a single vertex to start.
- JeditPanel.TEXTINPUTALGORITHM: For algorithms that will prompt the user for a string of input.
- JeditPanel.TWOCLICKALGORITHM: For algorithms that require that the user click on two vertices to start.
- JeditPanel.AUTOMATICALGORITHM: For algorithsm that require no additional input from the user.
Algorithm
public Algorithm()
- This constructor only does the equivalent work of the call
succeeded(false);
Algorithm
public Algorithm(String newName)
- This constructor only does the equivalent work of the calls
succeeded(false); and setName(newName);
Algorithm
public Algorithm(JavaGraph jGraph,
Vector inputs,
Vector animation)
- The intended constructor for all algorithms in Jedit3.0, it
is no longer called in Jedit3.1.
succeeded
public boolean succeeded()
- Returns true if the Algorithm succeeded,
otherwise returns false. Default is false.
succeeded
public void succeeded(boolean newValue)
- Use this to report a successful or unseccessful algorithm executions. If succeeded(true) is called, the algorithm's animation will be run.
A well-written algorithm will report success even for failed algorithms, producing an informative animation.
getName
public String getName()
- Return the algorithm's name as specified during
by the appropriate constructor or a call to the setName() method.
setName
public void setName(String newName)
- Sets the algorithms name, as it will appear in the JeditAlgorithms menu, to newName.
getDescription
public Vector getDescription()
- Returns the description of the Vector as it will appear in the
description portion of the JeditAlgorithms menu.
getType
public int getType()
- Returns the type of the algorithm.
See type.
callOwnConstructor
public abstract void callOwnConstructor(JavaGraph jGraph,
Vector inputs,
Vector animation)
- This method is called by Jedit for any algorithm it executes.
This method must be used in any working algorithm. Obviously,
the class can't call a constructor except from withing another
constructor. The name is historical. In Jedit 3.0, the algorithms
were launched from one of the constructors.
- jGraph is the JavaGraph that the algorithm is performed on.
- inputs is a Vector of inputs that consists of
- An Integer, if the algorithm uses a single vertex as a starting point
- Two Integers if the algorithm uses two vertices as starting points
- A String if the algorithm starts off of typed input
- Nothing if the algorithm runs automatically on a graph
- animation is a Vector that is filled with AnimObjects as the algorithm proceeds. It must be instantiated before this method is called.