org.fraid.plugin
Class PaintAlgorithmThread

java.lang.Object
  extended by java.lang.Thread
      extended by org.fraid.plugin.PaintAlgorithmThread
All Implemented Interfaces:
java.lang.Runnable
Direct Known Subclasses:
BufferedImagePaintAlgorithmThread, RawArrayPaintAlgorithmThread

public abstract class PaintAlgorithmThread
extends java.lang.Thread

The super class for all graphics algorithms in FrAid.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
protected  boolean mFirstTime
           
protected  BehaviorBean mPlugIn
          The plugin we are working with (very important, an algorithm can't do anything without its plugin).
protected  int mProgressVar
          If you increment this variable within your algorithm loops a progress bar somewhere can show where are we.
protected  long mTime
           
protected  GraphicsUser owner
          The user for the image we are generating.
protected  int screenHeight
           
protected  int screenWidth
           
protected  int state
          The current state.
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
PaintAlgorithmThread(GraphicsUser aOwner, BehaviorBean aPlugIn)
          Creates a new PaintAlgorithmThread instance.
 
Method Summary
protected abstract  void allocateNewImage()
          Depending what the underlying image is (BufferedImage or int array) storrage is allocated.
protected abstract  void applyAlgorithm()
          This is the actual algorithm.
abstract  java.awt.image.BufferedImage createImage()
          Turns its internal representation to a BufferedImage.
abstract  void drawGridLines(DoublePoint aP)
          Plots the grid (if there was created one).
 void fillModel()
           
 GraphicsUser getOwner()
          Returns the current user of our graphics.
 ProgressStatistics getProgressStatistics()
          If mProgressVar is used will return some info what progress is being done.
 java.lang.String getThreadName()
           
 int getThreadState()
          The current state.
 void goToWait()
          Effectively suspends the thread.
 void goToWork()
          If the thread is not working wake it up.
 void printDebugMessage(java.lang.String aComment)
           
 void requestStop()
          Allways do this when you close the owning window/user.
 void restart(java.awt.Dimension screenSize)
          The requirements changed, start over.
 void run()
          This is all an algorithm does.
 void subjectChanged()
          Notification that the subject we are plotting changed.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

screenWidth

protected int screenWidth

screenHeight

protected int screenHeight

mFirstTime

protected boolean mFirstTime

mTime

protected long mTime

owner

protected GraphicsUser owner
The user for the image we are generating. Could be an image for the screen, could be an image for a file.


mPlugIn

protected BehaviorBean mPlugIn
The plugin we are working with (very important, an algorithm can't do anything without its plugin).


state

protected volatile int state
The current state.

See Also:
ThreadState

mProgressVar

protected volatile int mProgressVar
If you increment this variable within your algorithm loops a progress bar somewhere can show where are we. Currently used by SaveToFileUser.

Constructor Detail

PaintAlgorithmThread

public PaintAlgorithmThread(GraphicsUser aOwner,
                            BehaviorBean aPlugIn)
Creates a new PaintAlgorithmThread instance.

Parameters:
aOwner - a GraphicsUser value
aPlugIn - a BehaviourPlugInAdapter value
Method Detail

getThreadName

public java.lang.String getThreadName()

printDebugMessage

public void printDebugMessage(java.lang.String aComment)

getOwner

public GraphicsUser getOwner()
Returns the current user of our graphics.

Returns:
a GraphicsUser value

goToWait

public void goToWait()
Effectively suspends the thread. To make sure this works, check for interruptions within your loops.


goToWork

public void goToWork()
If the thread is not working wake it up.


requestStop

public void requestStop()
Allways do this when you close the owning window/user.


restart

public void restart(java.awt.Dimension screenSize)
The requirements changed, start over.

Parameters:
screenSize - a Dimension value

allocateNewImage

protected abstract void allocateNewImage()
Depending what the underlying image is (BufferedImage or int array) storrage is allocated.


createImage

public abstract java.awt.image.BufferedImage createImage()
Turns its internal representation to a BufferedImage.

Returns:
a BufferedImage value

getThreadState

public int getThreadState()
The current state.

Returns:
an int value
See Also:
ThreadState

getProgressStatistics

public ProgressStatistics getProgressStatistics()
If mProgressVar is used will return some info what progress is being done. May varry how relevant this info is from algorithm to algorithm.

Returns:
a ProgressStatistics value

run

public void run()
This is all an algorithm does.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread

drawGridLines

public abstract void drawGridLines(DoublePoint aP)
Plots the grid (if there was created one).

Parameters:
aP - a DoublePoint value

subjectChanged

public void subjectChanged()
Notification that the subject we are plotting changed. Introduced with the 3D plots where model needs to be recreated after a function changed.


applyAlgorithm

protected abstract void applyAlgorithm()
This is the actual algorithm. The image is generated here.


fillModel

public void fillModel()


Fraid (system and language). (C) 2003-2007 Ivaylo Iliev
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.