com.monkeycoder.monkeyfractal.base
Class FractalThreadManager

java.lang.Object
  extended by java.util.Observable
      extended by com.monkeycoder.monkeyfractal.base.FractalThreadManager
All Implemented Interfaces:
java.lang.Runnable

public class FractalThreadManager
extends java.util.Observable
implements java.lang.Runnable

This is a manager class that provides threading control for FractalPlugins. For a plugin to function properly under this manager in the multi-threaded environment it provides, there are a few optional things that should be added into the code.

Originally part of the MonkeyFractal project.

Author:
David Stephens

Constructor Summary
FractalThreadManager()
          Constructs a new FractalThreadManager.
FractalThreadManager(FractalPlugin inFp)
          Constructs a new FractalThreadManager with the specified FractalPlugin to manage.
 
Method Summary
 FractalBuffer getFractalBuffer()
          This function returns the generated FractalBuffer.
 void run()
          This manages the process of generating the fractal.
 void sendUpdate(UpdateMessage inMessage)
          Relays an UpdateMessage to whatever is observing this class.
 void setFractalPlugin(FractalPlugin inFp)
          Sets a new FractalPlugin to manage.
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FractalThreadManager

public FractalThreadManager()
Constructs a new FractalThreadManager.


FractalThreadManager

public FractalThreadManager(FractalPlugin inFp)
Constructs a new FractalThreadManager with the specified FractalPlugin to manage.

Parameters:
inFp - The FractalPlugin to manage in a threaded fashion.
Method Detail

setFractalPlugin

public void setFractalPlugin(FractalPlugin inFp)
Sets a new FractalPlugin to manage.

Parameters:
inFp - The FractalPlugin to manage in a threaded fashion.

run

public void run()
This manages the process of generating the fractal. This method is called automatically when start() is called on its containing Thread.

Specified by:
run in interface java.lang.Runnable
See Also:
Thread.start()

sendUpdate

public void sendUpdate(UpdateMessage inMessage)
Relays an UpdateMessage to whatever is observing this class.

Parameters:
inMessage - The update that will be sent to observers.

getFractalBuffer

public FractalBuffer getFractalBuffer()
This function returns the generated FractalBuffer. Calling this method prior to receiving an UpdateMessage.UPDATE_FRACTAL_COMPLETE will result in receiving an unknown FractalBuffer. It may contain prior renders or be null.

Returns:
The FractalBuffer that was returned by generateFractal() on the FractalPlugin.
See Also:
FractalPlugin.generateFractal()