edu.hawaii.ics.yucheng
Class GraphSolver

java.lang.Object
  extended by edu.hawaii.ics.yucheng.GraphSolver
Direct Known Subclasses:
JadeSolver

abstract class GraphSolver
extends java.lang.Object

An abstract class that solves graphs.


Field Summary
private  long myBroadcast
           
private  java.util.ArrayList<GraphListener> myListeners
           
private  long mySleepTime
           
private  long myTimeout
           
 
Constructor Summary
GraphSolver()
           
 
Method Summary
 void addGraphListener(GraphListener listener)
          Adds a listener for progress messages.
 boolean isAnimating()
          Returns true if the solver is animating.
protected  void publish(GraphSolution solution)
          Publishes progress to all added listeners.
 void removeGraphListener(GraphListener listener)
          Removes a progress listener.
private static void sleep(long milliseconds)
          Sleeps for a number of milliseconds.
abstract  GraphSolution solve(Graph g)
          Solves a graph or returns null if there is no solution.
 void startAnimation(long timeout)
          Starts animation.
 void startAnimation(long timeout, long sleepTime)
          Starts animation.
 void stopAnimation()
          Stops animation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

myBroadcast

private long myBroadcast

myListeners

private final java.util.ArrayList<GraphListener> myListeners

mySleepTime

private long mySleepTime

myTimeout

private long myTimeout
Constructor Detail

GraphSolver

GraphSolver()
Method Detail

sleep

private static void sleep(long milliseconds)
Sleeps for a number of milliseconds.

Parameters:
milliseconds - The number of milliseconds to sleep.

addGraphListener

public void addGraphListener(GraphListener listener)
Adds a listener for progress messages.

Parameters:
listener - The listener.

isAnimating

public boolean isAnimating()
Returns true if the solver is animating.

Returns:
True indicates the solver is animating and false otherwise.

publish

protected void publish(GraphSolution solution)
Publishes progress to all added listeners.

Parameters:
solution - The solution.

removeGraphListener

public void removeGraphListener(GraphListener listener)
Removes a progress listener.

Parameters:
listener - The listener.

solve

public abstract GraphSolution solve(Graph g)
Solves a graph or returns null if there is no solution.

Parameters:
g - The graph.
Returns:
The solution.

startAnimation

public void startAnimation(long timeout)
Starts animation.

Parameters:
timeout - The amount of time to delay before transmitting progress.

startAnimation

public void startAnimation(long timeout,
                           long sleepTime)
Starts animation.

Parameters:
timeout - The amount of time to delay before transmitting progress.
sleepTime - The amount of time to sleep after transmitting progress.

stopAnimation

public void stopAnimation()
Stops animation.