edu.hawaii.ics.yucheng
Class SpanningTreeApplet.Worker

java.lang.Object
  extended by edu.hawaii.ics.yucheng.BackgroundWorker<GraphSolution,java.lang.Object>
      extended by edu.hawaii.ics.yucheng.SpanningTreeApplet.Worker
Direct Known Subclasses:
SpanningTreeApplet.DownloadGraphWorker, SpanningTreeApplet.RandomGraphWorker
Enclosing class:
SpanningTreeApplet

abstract class SpanningTreeApplet.Worker
extends BackgroundWorker<GraphSolution,java.lang.Object>

A class that downloads graphs and solves them in a background thread.


Nested Class Summary
(package private)  class SpanningTreeApplet.Worker.Delegate
          A simple class that listens for progress messages from the graph solver and sends the progress data to the GUI thread.
 
Constructor Summary
SpanningTreeApplet.Worker()
           
 
Method Summary
protected  void processError(java.lang.Exception error)
          When overridden by a derived class, this method processes an error thrown from the background worker thread.
protected  void processProgress(java.lang.Object progress)
          Executes when progress messages arrive from the background thread.
protected  void processResult(GraphSolution result)
          Executes when the background thread finishes.
protected  GraphSolution run()
          The entry point for the background thread.
protected abstract  GraphSolution solve(GraphSolver solver)
          Solves a graph and returns the solution.
 
Methods inherited from class edu.hawaii.ics.yucheng.BackgroundWorker
cancel, isCancelled, isRunning, join, processDelegate, sendProgress, start
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpanningTreeApplet.Worker

SpanningTreeApplet.Worker()
Method Detail

processError

protected void processError(java.lang.Exception error)
Description copied from class: BackgroundWorker
When overridden by a derived class, this method processes an error thrown from the background worker thread. The default implementation does nothing but displays the error message to standard error output.

Overrides:
processError in class BackgroundWorker<GraphSolution,java.lang.Object>
Parameters:
error - The error thrown by the background worker thread.

processProgress

protected void processProgress(java.lang.Object progress)
Executes when progress messages arrive from the background thread.

Overrides:
processProgress in class BackgroundWorker<GraphSolution,java.lang.Object>
Parameters:
progress - A list of messages that have arrived.

processResult

protected void processResult(GraphSolution result)
Executes when the background thread finishes.

Overrides:
processResult in class BackgroundWorker<GraphSolution,java.lang.Object>
Parameters:
result - The result from the background worker thread.

run

protected GraphSolution run()
                     throws java.lang.Exception
The entry point for the background thread.

Specified by:
run in class BackgroundWorker<GraphSolution,java.lang.Object>
Returns:
A solution for a graph.
Throws:
java.lang.Exception - Thrown if any kind of exception occurs during execution.

solve

protected abstract GraphSolution solve(GraphSolver solver)
                                throws java.lang.Exception
Solves a graph and returns the solution.

Parameters:
solver - The graph solver.
Returns:
The solution.
Throws:
java.lang.Exception - Thrown if there are any errors of any kind.