public abstract class AbstractJiffleRuntime extends Object implements JiffleRuntime
JiffleRuntime
methods plus
some common fields. The fields include those involved in handling image-scope
variables and script options; an instance of JiffleFunctions
; and an
integer stack used in evaluating con
statements.Modifier and Type | Class and Description |
---|---|
protected class |
AbstractJiffleRuntime.SourceImage |
Modifier and Type | Field and Description |
---|---|
protected CoordinateTransform |
_defaultTransform |
protected JiffleFunctions |
_FN
Provides runtime function support.
|
protected Map<String,AbstractJiffleRuntime.SourceImage> |
_images
Maps image variable names (
String ) to images
(RenderedImage ). |
protected boolean |
_imageScopeVarsInitialized |
protected double |
_outsideValue
The value to return for out-of-bounds image data requests if the
outside option is set.
|
protected boolean |
_outsideValueSet
Whether the outside option is set.
|
protected IntegerStack |
_stk
A stack of integer values used in the evaluation of if statements.
|
Constructor and Description |
---|
AbstractJiffleRuntime() |
AbstractJiffleRuntime(String[] variableNames)
Creates a new instance of this class and initializes its
JiffleFunctions and IntegerStack objects. |
Modifier and Type | Method and Description |
---|---|
Map<String,RenderedImage> |
get_images()
Returns the images set for this runtime object as a
Map with
variable name as key and iamge as value. |
String[] |
getDestinationVarNames()
Gets the variable names associated with destination images.
|
double |
getHeight()
Gets the height of the processing area.
|
double |
getMaxX()
Gets the max X ordinate of the processing area.
|
double |
getMaxY()
Gets the max Y ordinate of the processing area.
|
double |
getMinX()
Gets the min X ordinate of the processing area.
|
double |
getMinY()
Gets the min Y ordinate of the processing area.
|
long |
getNumPixels()
Gets the total number of pixels in the processing area.
|
String[] |
getSourceVarNames()
Gets the variable names associated with source images.
|
protected CoordinateTransform |
getTransform(String imageVarName)
Gets the coordinate transform to use with the image represented by
imageVarName . |
Double |
getVar(String varName)
Returns the value of a variable that was declared in the
script's init block.
|
protected Field |
getVariableField(String varName) |
String[] |
getVarNames()
Returns the names of image scope variables that can be used with
the
JiffleRuntime.getVar(String) and JiffleRuntime.setVar(String, Double)
methods. |
double |
getWidth()
Gets the width of the processing area.
|
double |
getXRes()
Gets the pixel width (resolution in X direction) in world units.
|
double |
getYRes()
Gets the pixel height (resolution in Y direction) in world units.
|
protected abstract void |
initImageScopeVars()
Initializes image-scope variables.
|
protected void |
initOptionVars()
Initializes runtime class fields related to Jiffle script options.
|
boolean |
isWorldSet()
Checks whether the world bounds and pixel dimensions have been set.
|
double |
readFromImage(String srcImageName,
double x,
double y,
int band)
Gets a value from a source image for a given world position and
image band.
|
abstract void |
setDefaultBounds() |
void |
setDefaultTransform(CoordinateTransform tr)
Sets a coordinate transform to be used by any source and destination images
submitted to the runtime object without their own transforms.
|
void |
setImageParams(Map imageParams)
Supplies the runtime object with the names and roles if image variables
used in the script.
|
void |
setSourceImage(String varName,
RenderedImage image)
Associates a variable name with a source image.
|
void |
setSourceImage(String varName,
RenderedImage image,
CoordinateTransform tr)
Associates a variable name with a source image and coordinate transform.
|
void |
setSourceImageBandTransform(String varName,
BandTransform btr)
Associates a given source image with a BandTransform
|
void |
setSourceImageCoordinateTransform(String varName,
CoordinateTransform tr)
Associates a given source image with a CoordinateTransform
|
void |
setVar(String varName,
Double value)
Sets the value of a variable that was declared in the script's
init block, overriding the default value in the script
if present.
|
void |
setWorldByNumPixels(Rectangle2D bounds,
int numX,
int numY)
Sets the world (processing area) bounds and the number of pixels in the
X and Y directions.
|
void |
setWorldByResolution(Rectangle2D bounds,
double xres,
double yres)
Sets the world (processing area) bounds and resolution (pixel dimensions).
|
protected boolean _imageScopeVarsInitialized
protected Map<String,AbstractJiffleRuntime.SourceImage> _images
String
) to images
(RenderedImage
).protected boolean _outsideValueSet
protected double _outsideValue
protected IntegerStack _stk
protected final JiffleFunctions _FN
protected CoordinateTransform _defaultTransform
public AbstractJiffleRuntime()
public AbstractJiffleRuntime(String[] variableNames)
JiffleFunctions
and IntegerStack
objects.public void setImageParams(Map imageParams)
jaitools.jiffle.Jiffle
instance that is creating the runtime object so that clients can use
the JiffleRuntime.getSourceVarNames()
and JiffleRuntime.getDestinationVarNames()
methods.setImageParams
in interface JiffleRuntime
imageParams
- a Map
of variable names (key) and roles (value)public String[] getSourceVarNames()
getSourceVarNames
in interface JiffleRuntime
null
public String[] getDestinationVarNames()
getDestinationVarNames
in interface JiffleRuntime
null
public void setWorldByResolution(Rectangle2D bounds, double xres, double yres)
setWorldByResolution
in interface JiffleRuntime
bounds
- outer bounds of the processing areaxres
- pixel width in world unitsyres
- pixel height in world unitspublic void setWorldByNumPixels(Rectangle2D bounds, int numX, int numY)
setWorldByNumPixels
in interface JiffleRuntime
bounds
- outer bounds of the processing areanumX
- number of pixels in the X directionnumY
- number of pixels in the Y directionpublic boolean isWorldSet()
isWorldSet
in interface JiffleRuntime
true
if set; false
otherwisepublic Double getVar(String varName)
getVar
in interface JiffleRuntime
varName
- variable namenull
if the variable name is
not foundpublic void setVar(String varName, Double value) throws JiffleRuntimeException
value
to null
results in the
default script value being used.setVar
in interface JiffleRuntime
varName
- variable namevalue
- the new valueJiffleRuntimeException
- if the variable name is not foundpublic String[] getVarNames()
JiffleRuntime.getVar(String)
and JiffleRuntime.setVar(String, Double)
methods.getVarNames
in interface JiffleRuntime
null
public double getMinX()
getMinX
in interface JiffleRuntime
public double getMaxX()
getMaxX
in interface JiffleRuntime
public double getMinY()
getMinY
in interface JiffleRuntime
public double getMaxY()
getMaxY
in interface JiffleRuntime
public double getWidth()
getWidth
in interface JiffleRuntime
public double getHeight()
getHeight
in interface JiffleRuntime
public double getXRes()
getXRes
in interface JiffleRuntime
public double getYRes()
getYRes
in interface JiffleRuntime
public long getNumPixels()
JiffleRuntime
getNumPixels
in interface JiffleRuntime
public void setDefaultTransform(CoordinateTransform tr) throws JiffleException
tr
is null
the system default transform (IdentityCoordinateTransform
)
will be used.setDefaultTransform
in interface JiffleRuntime
tr
- the coordinate transform to use as the default; or null
for the system defaultJiffleException
- if the world bounds and resolution have not
been set previouslyprotected CoordinateTransform getTransform(String imageVarName)
imageVarName
.imageVarName
- variable nameprotected abstract void initImageScopeVars()
JiffleRuntimeException
- if any variables do not have either a
default or provided valueprotected void initOptionVars()
public double readFromImage(String srcImageName, double x, double y, int band)
readFromImage
in interface JiffleRuntime
srcImageName
- the source imagex
- source X ordinate in world unitsy
- source Y ordinate in world unitsband
- source bandpublic void setSourceImage(String varName, RenderedImage image)
setSourceImage(varName, image, null)
This convenience method is defined in the interface because it will be
commonly when working directly with image coordinates.setSourceImage
in interface JiffleRuntime
varName
- script variable representing the source imageimage
- writable imagepublic void setSourceImage(String varName, RenderedImage image, CoordinateTransform tr) throws JiffleException
tr
is null
the default
identify transform will be used.
Note that Jiffle uses rounding to reduce the transformed coordinates to integers.
setSourceImage
in interface JiffleRuntime
varName
- script variable representing the source imageimage
- writable imagetr
- transform for processing area to image coordinatesJiffleException
- if the world bounds and resolution have not
been set previouslypublic Map<String,RenderedImage> get_images()
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.get_images
in interface JiffleRuntime
public void setSourceImageBandTransform(String varName, BandTransform btr) throws JiffleException
JiffleRuntime
setSourceImageBandTransform
in interface JiffleRuntime
varName
- script variable representing the source imageJiffleException
public void setSourceImageCoordinateTransform(String varName, CoordinateTransform tr) throws JiffleException
JiffleRuntime
setSourceImageCoordinateTransform
in interface JiffleRuntime
varName
- script variable representing the source imagetr
- transform for processing area to image coordinatesJiffleException
public abstract void setDefaultBounds()
Copyright © 2006–2018 GeoSolutions. All rights reserved.