Jedit 4.1

edu.bsu.cs.algorithm
Class Algorithm

java.lang.Object
  |
  +--edu.bsu.cs.algorithm.Algorithm
Direct Known Subclasses:
BlockFinding, BreadthSearch, Center, ComponentSearch, DegreeSequence, DeleteAllEdges, DepthSearch, Dijkstra1, Dijkstra2, EulerianWalk, Floyd, Fragments, HavelHakimi, Heawood, Hypercube, Kmn, Kn, MaxFlowMinCut, Median, NetworkFlow, Petersen, Prim, PruferCode, PruferTree

public abstract class Algorithm
extends Object

Serves as a superclass of all algorithms for Jedit. Any properly written subclass can be used in Jedit 3.1 or higher with a single line of code in the JeditAlgorithms.java file. However, to add to menus and buttons, more must be done.

Since:
30 Jun 1998
Version:
31 Mar 1999
Author:
Aaron Nall
See Also:
JeditAlgorithms

Constructor Summary
Algorithm()
          Default constructor.
Algorithm(String newName)
          Constructor with a parameter to set the algorithm name to newName.
 
Method Summary
abstract  void callOwnConstructor(JavaGraph jGraph, Vector inputs, Vector animation)
          This method is called by Jedit for any algorithm it executes and must be used in any working algorithm.
 String getCode()
          Returns the value of code - generally the class name of the algorithm.
 Vector getDescription()
          Returns the description of the algorithm.
 String getName()
          Returns the algorithm's name.
 int getType()
          Returns the type of the algorithm.
 void setCode(String newCode)
          Sets the value of code - generally the class name of the algorithm.
 void setDescription(Vector d)
          Sets the description of the algorithm to d.
 void setFromResources()
          Sets algorithm attributes from the external resource file jedit.properties stored in the classes subdirectory.
 void setName(String newName)
          Sets the algorithm's name to newName.
 void setType(int t)
          Sets the algorithm type to t.
 boolean succeeded()
          Returns true if the Algorithm succeeded, otherwise returns false.
 void succeeded(boolean newValue)
          Sets the value of success.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Algorithm

public Algorithm()
Default constructor. Sets internal private values with the following defaults:
success = false
code = this.getClass().getName()


Algorithm

public Algorithm(String newName)
Constructor with a parameter to set the algorithm name to newName. Sets internal private values with the following defaults:
success = false
code = this.getClass().getName()

Parameters:
newName - the name of the algorithm
Method Detail

succeeded

public boolean succeeded()
Returns true if the Algorithm succeeded, otherwise returns false. Algorithms are initialized to having a success value of false.

Returns:
boolean

succeeded

public void succeeded(boolean newValue)
Sets the value of success. Use this to report a successful or unsuccessful algorithm execution. 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.

Parameters:
newValue - new value for algorithm success

getName

public String getName()
Returns the algorithm's name.

Returns:
String

setName

public void setName(String newName)
Sets the algorithm's name to newName.

Parameters:
newName - the new name for the algorithm

getDescription

public Vector getDescription()
Returns the description of the algorithm.

Returns:
Vector

setDescription

public void setDescription(Vector d)
Sets the description of the algorithm to d.

Parameters:
d - a Vector containing the description of the algorithm

getType

public int getType()
Returns the type of the algorithm. The options are

Returns:
int

setType

public void setType(int t)
Sets the algorithm type to t. The options are

Parameters:
t - the algorithm type (see options above)

getCode

public String getCode()
Returns the value of code - generally the class name of the algorithm.

Returns:
String

setCode

public void setCode(String newCode)
Sets the value of code - generally the class name of the algorithm.

Parameters:
newCode - the String to set the algorithm code value to

setFromResources

public void setFromResources()
Sets algorithm attributes from the external resource file jedit.properties stored in the classes subdirectory.


callOwnConstructor

public abstract void callOwnConstructor(JavaGraph jGraph,
                                        Vector inputs,
                                        Vector animation)
This method is called by Jedit for any algorithm it executes and must be used in any working algorithm.

Parameters:
jGraph - the edu.bsu.cs.graph.JavaGraph that the algorithm is performed on
inputs - 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 - a Vector that is filled with AnimObjects as the algorithm proceeds. It must be instantiated before this method is called.

Jedit 4.1