jwo.landserf.process
Class CentroidThread

java.lang.Object
  extended by java.lang.Thread
      extended by jwo.landserf.process.LSThread
          extended by jwo.landserf.process.CentroidThread
All Implemented Interfaces:
Runnable, Scriptable, JWInterruptionListener

public class CentroidThread
extends LSThread
implements Scriptable

Allows polygon centroids to be found.

Version:
2.3, 10th August, 2007.
Author:
Jo Wood

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
CentroidThread(GISFrame gisFrame)
          Creates an object ready for vector map centroid calculation but does not perform the calculation.
 
Method Summary
 boolean doCommand(LSCommand command)
          Finds the centroids in the vector map supplied as a command parameter.
 void doProcessing()
          Finds the centroids of all polygons in the primary vector map.
 VectorMap getCentroids()
          Retrieves the vector map containing the centroids.
 LSCommand getCommand()
          Reports the syntax required to allow vector map to be simplified via a scripting command.
 GISFrame getGISFrame()
          Retrieves the GISFrame that can be used for storing multiple spatial objects and messages.
 Object getReturnedObject()
          Returns the vector map containing the polygon centroids only.
 
Methods inherited from class jwo.landserf.process.LSThread
checkStoppedThread, interruptionRequested, resetTimer, run, setErrorMessage, setFinalMessage, setMessage
 
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
 

Constructor Detail

CentroidThread

public CentroidThread(GISFrame gisFrame)
Creates an object ready for vector map centroid calculation but does not perform the calculation.

Parameters:
gisFrame - Frame holding spatial objects and in which to report results.
Method Detail

doProcessing

public void doProcessing()
Finds the centroids of all polygons in the primary vector map. The resulting vector map contains only centroids and shares the attributes and colours of the original polygons. The map is added to the GISFrame provided to the constructor and selected as the new primary vector map. To retrieve it either call getCentroids() from this class or call gisFrame.getVectorMap1();.

Note that this method will be called automatically if this is run as a threaded process (e.g. myCentroidThread.start()). Alternatively it can be called directly as a non-threaded process.

Specified by:
doProcessing in class LSThread
See Also:
GISFrame

getCommand

public LSCommand getCommand()
Reports the syntax required to allow vector map to be simplified via a scripting command.

Specified by:
getCommand in interface Scriptable
Returns:
Command syntax.

doCommand

public boolean doCommand(LSCommand command)
Finds the centroids in the vector map supplied as a command parameter.

Specified by:
doCommand in interface Scriptable
Parameters:
command - Command containing parameter values.
Returns:
True if centroids found successfully. If false, the details of the problem are reported to the gisFrame.

getReturnedObject

public Object getReturnedObject()
Returns the vector map containing the polygon centroids only. This is identical to getCentroids() except that it is compatible with the scriptable interface. If command has yet to be issued this will return null.

Specified by:
getReturnedObject in interface Scriptable
Returns:
New spatial object or null if problems finding centroids or command has not yet been issued.

getGISFrame

public GISFrame getGISFrame()
Retrieves the GISFrame that can be used for storing multiple spatial objects and messages.

Specified by:
getGISFrame in interface Scriptable
Returns:
GISFrame storing spatial objects and messages.

getCentroids

public VectorMap getCentroids()
Retrieves the vector map containing the centroids.

Returns:
New vector map with polygon centroids, or null if problems or calculation is yet to take place.


Copyright Jo Wood, 1996-2009, last modified, 17th April, 2009