org.jaitools.jiffle.runtime
Class AbstractDirectRuntime

java.lang.Object
  extended by org.jaitools.jiffle.runtime.AbstractJiffleRuntime
      extended by org.jaitools.jiffle.runtime.AbstractDirectRuntime
All Implemented Interfaces:
JiffleDirectRuntime, JiffleRuntime

public abstract class AbstractDirectRuntime
extends AbstractJiffleRuntime
implements JiffleDirectRuntime

The default abstract base class for runtime classes that implement direct evaluation.

Since:
0.1
Version:
$Id: AbstractDirectRuntime.java 1653 2011-06-16 10:23:02Z michael.bedward $
Author:
Michael Bedward

Nested Class Summary
 
Nested classes/interfaces inherited from class org.jaitools.jiffle.runtime.AbstractJiffleRuntime
AbstractJiffleRuntime.ImageScopeVar
 
Field Summary
protected  java.util.Map images
          Maps image variable names (String) to images (RenderedImage).
protected  java.util.Map readers
          Maps source image variable names (String) to image iterators (RandomIter).
protected  java.util.Map writers
          Maps destination image variable names (String to image iterators (WritableRandomIter).
 
Fields inherited from class org.jaitools.jiffle.runtime.AbstractJiffleRuntime
_FN, _imageScopeVarsInitialized, _numVars, _outsideValue, _outsideValueSet, _stk, _vars, VAR_STRING
 
Constructor Summary
AbstractDirectRuntime()
          Creates a new instance and initializes script-option variables.
 
Method Summary
 void evaluateAll(JiffleProgressListener pl)
          Evaluates the script for all pixel locations within the world bounds.
 java.util.Map getImages()
          Returns the images set for this runtime object as a Map with variable name as key and iamge as value.
 double readFromImage(java.lang.String srcImageName, double x, double y, int band)
          Gets a value from a source image for a given world position and image band.
 void setDefaultBounds()
          Sets default bounds for the processing area.
 void setDestinationImage(java.lang.String varName, java.awt.image.WritableRenderedImage image)
          Associates a variable name with a destination image.
 void setDestinationImage(java.lang.String varName, java.awt.image.WritableRenderedImage image, CoordinateTransform tr)
          Associates a variable name with a destination image and coordinate transform.
 void setSourceImage(java.lang.String varName, java.awt.image.RenderedImage image)
          Associates a variable name with a source image.
 void setSourceImage(java.lang.String varName, java.awt.image.RenderedImage image, CoordinateTransform tr)
          Associates a variable name with a source image and coordinate transform.
 void writeToImage(java.lang.String destImageName, double x, double y, int band, double value)
          Writes a value to a destination image for a given world position and image band.
 
Methods inherited from class org.jaitools.jiffle.runtime.AbstractJiffleRuntime
getDefaultValue, getDestinationVarNames, getHeight, getMaxX, getMaxY, getMinX, getMinY, getNumPixels, getSourceVarNames, getTransform, getVar, getVarIndex, getVarNames, getWidth, getXRes, getYRes, initImageScopeVars, initOptionVars, isWorldSet, registerVar, setDefaultTransform, setImageParams, setTransform, setVar, setVarValue, setWorldByNumPixels, setWorldByResolution
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.jaitools.jiffle.runtime.JiffleDirectRuntime
evaluate
 
Methods inherited from interface org.jaitools.jiffle.runtime.JiffleRuntime
getDestinationVarNames, getHeight, getMaxX, getMaxY, getMinX, getMinY, getNumPixels, getSourceVarNames, getVar, getVarNames, getWidth, getXRes, getYRes, isWorldSet, setDefaultTransform, setImageParams, setVar, setWorldByNumPixels, setWorldByResolution
 

Field Detail

images

protected java.util.Map images
Maps image variable names (String) to images (RenderedImage).


readers

protected java.util.Map readers
Maps source image variable names (String) to image iterators (RandomIter).


writers

protected java.util.Map writers
Maps destination image variable names (String to image iterators (WritableRandomIter).

Constructor Detail

AbstractDirectRuntime

public AbstractDirectRuntime()
Creates a new instance and initializes script-option variables.

Method Detail

setDestinationImage

public void setDestinationImage(java.lang.String varName,
                                java.awt.image.WritableRenderedImage image)
Associates a variable name with a destination image. Equivalent to:

 setDestinationImage(varName, image, null)
 
This convenience method is defined in the interface because it will be commonly when working directly with image coordinates.

Specified by:
setDestinationImage in interface JiffleDirectRuntime
Parameters:
varName - script variable representing the destination image
image - writable image

setDestinationImage

public void setDestinationImage(java.lang.String varName,
                                java.awt.image.WritableRenderedImage image,
                                CoordinateTransform tr)
                         throws JiffleException
Associates a variable name with a destination image and coordinate transform. The transform defines how to convert from processing area coordinates to image (pixel) coordinates. If tr is null the default identify transform will be used.

Note that Jiffle uses rounding to reduce the transformed coordinates to integers.

Specified by:
setDestinationImage in interface JiffleDirectRuntime
Parameters:
varName - script variable representing the destination image
image - writable image
tr - transform for processing area to image coordinates
Throws:
JiffleException - if the world bounds and resolution have not been set previously

setSourceImage

public void setSourceImage(java.lang.String varName,
                           java.awt.image.RenderedImage image)
Associates a variable name with a source image. Equivalent to:

 setSourceImage(varName, image, null)
 
This convenience method is defined in the interface because it will be commonly when working directly with image coordinates.

Specified by:
setSourceImage in interface JiffleDirectRuntime
Parameters:
varName - script variable representing the source image
image - writable image

setSourceImage

public void setSourceImage(java.lang.String varName,
                           java.awt.image.RenderedImage image,
                           CoordinateTransform tr)
                    throws JiffleException
Associates a variable name with a source image and coordinate transform. The transform defines how to convert from processing area coordinates to image (pixel) coordinates. If tr is null the default identify transform will be used.

Note that Jiffle uses rounding to reduce the transformed coordinates to integers.

Specified by:
setSourceImage in interface JiffleDirectRuntime
Parameters:
varName - script variable representing the source image
image - writable image
tr - transform for processing area to image coordinates
Throws:
JiffleException - if the world bounds and resolution have not been set previously

evaluateAll

public void evaluateAll(JiffleProgressListener pl)
Evaluates the script for all pixel locations within the world bounds.

Specified by:
evaluateAll in interface JiffleDirectRuntime
Parameters:
pl - an optional progress listener (may be null

readFromImage

public double readFromImage(java.lang.String srcImageName,
                            double x,
                            double y,
                            int band)
Gets a value from a source image for a given world position and image band.

Specified by:
readFromImage in interface JiffleDirectRuntime
Parameters:
srcImageName - the source image
x - source X ordinate in world units
y - source Y ordinate in world units
band - source band
Returns:
image value

writeToImage

public void writeToImage(java.lang.String destImageName,
                         double x,
                         double y,
                         int band,
                         double value)
Writes a value to a destination image for a given world position and image band.

Specified by:
writeToImage in interface JiffleDirectRuntime
x - destination X ordinate in world units
y - destination Y ordinate in world units
band - destination band
value - the value to write

setDefaultBounds

public void setDefaultBounds()
Sets default bounds for the processing area. These are the bounds of the first destination image or, if there are no destination images, the bounds of the first source image, where first means first added to the run-time object's list of images.

Specified by:
setDefaultBounds in interface JiffleDirectRuntime

getImages

public java.util.Map getImages()
Returns the images set for this runtime object as a Map with variable name as key and iamge as value. The returned Map is a copy of the one held by this object, so it can be safely modified by the caller.

Specified by:
getImages in interface JiffleDirectRuntime
Returns:
images keyed by variable name


Copyright © 2011. All Rights Reserved.