public class ROIGeometry
extends javax.media.jai.ROI
JAI operations often involve converting ROI objects to images. This class
implements its getAsImage()
method using the JAITools "VectorBinarize"
operator to avoid exhausting available memory when dealing with ROIs that
cover massive image areas.
Note that this class can be used to honour floating precision pixel coordinates
by setting the useFixedPrecision
constructor argument to false
.
The effect of the default fixed coordinate precision is to provide equivalent
behaviour to that of the standard ROIShape
, where pixel coordinates
are treated as referring to the upper-left pixel corner.
Modifier and Type | Field and Description |
---|---|
static boolean |
DEFAULT_ROIGEOMETRY_ANTIALISING
Default setting for use of anti-aliasing when drawing the reference
Geometry during a getAsImage() request. |
static boolean |
DEFAULT_ROIGEOMETRY_USEFIXEDPRECISION
Default setting for use of fixed precision (
true ). |
Constructor and Description |
---|
ROIGeometry(com.vividsolutions.jts.geom.Geometry geom)
Constructor which takes a
Geometry object to be used
as the reference against which to test inclusion of image coordinates. |
ROIGeometry(com.vividsolutions.jts.geom.Geometry geom,
boolean useFixedPrecision)
Constructor which takes a
Geometry object and a boolean
value for whether to use fixed coordinate precision (equivalent to
working with integer pixel coordinates). |
ROIGeometry(com.vividsolutions.jts.geom.Geometry geom,
boolean antiAliasing,
boolean useFixedPrecision)
Constructors a new ROIGeometry.
|
ROIGeometry(com.vividsolutions.jts.geom.Geometry geom,
boolean antiAliasing,
boolean useFixedPrecision,
RenderingHints hints)
Fully-specified constructor.
|
ROIGeometry(com.vividsolutions.jts.geom.Geometry geom,
RenderingHints hints)
Builds a new ROIGeometry.
|
Modifier and Type | Method and Description |
---|---|
javax.media.jai.ROI |
add(javax.media.jai.ROI roi)
Returns a new instance which is the union of this ROI and
roi . |
boolean |
contains(double x,
double y)
Tests if this ROI contains the given image location.
|
boolean |
contains(double x,
double y,
double w,
double h)
Tests if this ROI contains the given rectangle.
|
boolean |
contains(int x,
int y)
Tests if this ROI contains the given image location.
|
boolean |
contains(int x,
int y,
int w,
int h)
Tests if this ROI contains the given rectangle.
|
boolean |
contains(Point p)
Tests if this ROI contains the given point.
|
boolean |
contains(Point2D p)
Tests if this ROI contains the given point.
|
boolean |
contains(Rectangle rect)
Tests if this ROI contains the given rectangle.
|
boolean |
contains(Rectangle2D rect)
Tests if this ROI contains the given rectangle.
|
javax.media.jai.ROI |
exclusiveOr(javax.media.jai.ROI roi)
Returns a new instance which is the exclusive OR of this ROI and
roi . |
int[][] |
getAsBitmask(int x,
int y,
int width,
int height,
int[][] mask) |
com.vividsolutions.jts.geom.Geometry |
getAsGeometry()
Returns the ROI as a JTS
Geometry . |
javax.media.jai.PlanarImage |
getAsImage()
Gets an image representation of this ROI using the
VectorBinarize
operation. |
LinkedList |
getAsRectangleList(int x,
int y,
int width,
int height) |
Shape |
getAsShape()
Gets a new
Shape representing this ROI. |
Rectangle |
getBounds()
Gets the enclosing rectangle of this ROI.
|
Rectangle2D |
getBounds2D()
Gets the enclosing double-precision rectangle of this ROI.
|
int |
getThreshold() |
javax.media.jai.ROI |
intersect(javax.media.jai.ROI roi)
Returns a new instance which is the intersection of this ROI and
roi . |
boolean |
intersects(double x,
double y,
double w,
double h)
Tests if the given rectangle intersects with this ROI.
|
boolean |
intersects(int x,
int y,
int w,
int h)
Tests if the given rectangle intersects with this ROI.
|
boolean |
intersects(Rectangle rect)
Tests if the given rectangle intersects with this ROI.
|
boolean |
intersects(Rectangle2D rect)
Tests if the given rectangle intersects with this ROI.
|
javax.media.jai.ROI |
performImageOp(RenderedImageFactory RIF,
ParameterBlock paramBlock,
int sourceIndex,
RenderingHints renderHints) |
javax.media.jai.ROI |
performImageOp(String name,
ParameterBlock paramBlock,
int sourceIndex,
RenderingHints renderHints) |
void |
setThreshold(int threshold) |
javax.media.jai.ROI |
subtract(javax.media.jai.ROI roi)
Returns a new instance which is the difference of this ROI and
roi . |
javax.media.jai.ROI |
transform(AffineTransform at)
Returns a new ROI created by applying the given transform to
this ROI.
|
javax.media.jai.ROI |
transform(AffineTransform at,
javax.media.jai.Interpolation interp)
Returns a new ROI created by applying the given transform to
this ROI.
|
public static final boolean DEFAULT_ROIGEOMETRY_ANTIALISING
Geometry
during a getAsImage()
request.
The default value is true
which provides behaviour corresponding
to that of the standard JAI ROIShape
class.public static final boolean DEFAULT_ROIGEOMETRY_USEFIXEDPRECISION
true
).public ROIGeometry(com.vividsolutions.jts.geom.Geometry geom)
Geometry
object to be used
as the reference against which to test inclusion of image coordinates.
The argument geom
must be either a Polygon
or
MultiPolygon
.
The input geometry is copied so subsequent changes to it will
not be reflected in the ROIGeometry
object.geom
- either a Polygon
or MultiPolygon
object
defining the area(s) of inclusion.IllegalArgumentException
- if geom
is null
or
not an instance of either Polygon
or MultiPolygon
public ROIGeometry(com.vividsolutions.jts.geom.Geometry geom, boolean useFixedPrecision)
Geometry
object and a boolean
value for whether to use fixed coordinate precision (equivalent to
working with integer pixel coordinates).
The argument geom
must be either a Polygon
or
MultiPolygon
.
The input geometry is copied so subsequent changes to it will
not be reflected in the ROIGeometry
object.geom
- either a Polygon
or MultiPolygon
object
defining the area(s) of inclusion.useFixedPrecision
- whether to use fixed precision when comparing
pixel coordinates to the reference geometryIllegalArgumentException
- if geom
is null
or
not an instance of either Polygon
or MultiPolygon
public ROIGeometry(com.vividsolutions.jts.geom.Geometry geom, boolean antiAliasing, boolean useFixedPrecision)
geom
must be either a Polygon
or
MultiPolygon
.
The input geometry is copied so subsequent changes to it will
not be reflected in the ROIGeometry
object.geom
- either a Polygon
or MultiPolygon
object
defining the area(s) of inclusion.antiAliasing
- whether to use anti-aliasing when converting this
ROI to an imageuseFixedPrecision
- whether to use fixed precision when comparing
pixel coordinates to the reference geometryIllegalArgumentException
- if geom
is null
or
not an instance of either Polygon
or MultiPolygon
public ROIGeometry(com.vividsolutions.jts.geom.Geometry geom, RenderingHints hints)
geom
must be either a Polygon
or
MultiPolygon
.
The input geometry is copied so subsequent changes to it will
not be reflected in the ROIGeometry
object.geom
- either a Polygon
or MultiPolygon
object
defining the area(s) of inclusion.hints
- The JAI hints to be used when generating the raster equivalent of this ROIIllegalArgumentException
- if geom
is null
or
not an instance of either Polygon
or MultiPolygon
public ROIGeometry(com.vividsolutions.jts.geom.Geometry geom, boolean antiAliasing, boolean useFixedPrecision, RenderingHints hints)
geom
must be either a Polygon
or
MultiPolygon
.
The input geometry is copied so subsequent changes to it will
not be reflected in the ROIGeometry
object.geom
- either a Polygon
or MultiPolygon
object
defining the area(s) of inclusion.antiAliasing
- whether to use anti-aliasing when converting this
ROI to an imageuseFixedPrecision
- whether to use fixed precision when comparing
pixel coordinates to the reference geometryhints
- The JAI hints to be used when generating the raster equivalent of this ROIIllegalArgumentException
- if geom
is null
or
not an instance of either Polygon
or MultiPolygon
public javax.media.jai.ROI add(javax.media.jai.ROI roi)
roi
.
This is only possible if roi
is an instance of ROIGeometry
or ROIShape
.add
in class javax.media.jai.ROI
roi
- the ROI to addpublic boolean contains(Point p)
contains
in class javax.media.jai.ROI
p
- the pointtrue
if the point is within this ROI;
false
otherwisepublic boolean contains(Point2D p)
contains
in class javax.media.jai.ROI
p
- the pointtrue
if the point is within this ROI;
false
otherwisepublic boolean contains(int x, int y)
contains
in class javax.media.jai.ROI
x
- location X ordinatey
- location Y ordinatetrue
if the location is within this ROI;
false
otherwisepublic boolean contains(double x, double y)
contains
in class javax.media.jai.ROI
x
- location X ordinatey
- location Y ordinatetrue
if the location is within this ROI;
false
otherwisepublic boolean contains(Rectangle rect)
contains
in class javax.media.jai.ROI
rect
- the rectangletrue
if the rectangle is within this ROI;
false
otherwisepublic boolean contains(Rectangle2D rect)
contains
in class javax.media.jai.ROI
rect
- the rectangletrue
if the rectangle is within this ROI;
false
otherwisepublic boolean contains(int x, int y, int w, int h)
contains
in class javax.media.jai.ROI
x
- rectangle origin X ordinatey
- rectangle origin Y ordinatew
- rectangle widthh
- rectangle heighttrue
if the rectangle is within this ROI;
false
otherwisepublic boolean contains(double x, double y, double w, double h)
contains
in class javax.media.jai.ROI
x
- rectangle origin X ordinatey
- rectangle origin Y ordinatew
- rectangle widthh
- rectangle heighttrue
if the rectangle is within this ROI;
false
otherwisepublic javax.media.jai.ROI exclusiveOr(javax.media.jai.ROI roi)
roi
.
This is only possible if roi
is an instance of ROIGeometry
or ROIShape
.exclusiveOr
in class javax.media.jai.ROI
roi
- the ROI to addpublic int[][] getAsBitmask(int x, int y, int width, int height, int[][] mask)
getAsBitmask
in class javax.media.jai.ROI
public javax.media.jai.PlanarImage getAsImage()
VectorBinarize
operation. For an ROI with very large bounds but simple shape(s) the
resulting image has a small memory footprint.getAsImage
in class javax.media.jai.ROI
VectorBinarizeDescriptor
public LinkedList getAsRectangleList(int x, int y, int width, int height)
getAsRectangleList
in class javax.media.jai.ROI
public Shape getAsShape()
Shape
representing this ROI.getAsShape
in class javax.media.jai.ROI
public com.vividsolutions.jts.geom.Geometry getAsGeometry()
Geometry
.public Rectangle getBounds()
getBounds
in class javax.media.jai.ROI
public Rectangle2D getBounds2D()
getBounds2D
in class javax.media.jai.ROI
public int getThreshold()
getThreshold
in class javax.media.jai.ROI
public javax.media.jai.ROI intersect(javax.media.jai.ROI roi)
roi
.
This is only possible if roi
is an instance of ROIGeometry
or ROIShape
.intersect
in class javax.media.jai.ROI
roi
- the ROI to intersect withpublic boolean intersects(Rectangle rect)
intersects
in class javax.media.jai.ROI
rect
- the rectangletrue
if there is an intersection; false
otherwisepublic boolean intersects(Rectangle2D rect)
intersects
in class javax.media.jai.ROI
rect
- the rectangletrue
if there is an intersection; false
otherwisepublic boolean intersects(int x, int y, int w, int h)
intersects
in class javax.media.jai.ROI
x
- rectangle origin X ordinatey
- rectangle origin Y ordinatew
- rectangle widthh
- rectangle heighttrue
if there is an intersection; false
otherwisepublic boolean intersects(double x, double y, double w, double h)
intersects
in class javax.media.jai.ROI
x
- rectangle origin X ordinatey
- rectangle origin Y ordinatew
- rectangle widthh
- rectangle heighttrue
if there is an intersection; false
otherwisepublic javax.media.jai.ROI performImageOp(RenderedImageFactory RIF, ParameterBlock paramBlock, int sourceIndex, RenderingHints renderHints)
performImageOp
in class javax.media.jai.ROI
public javax.media.jai.ROI performImageOp(String name, ParameterBlock paramBlock, int sourceIndex, RenderingHints renderHints)
performImageOp
in class javax.media.jai.ROI
public void setThreshold(int threshold)
setThreshold
in class javax.media.jai.ROI
public javax.media.jai.ROI subtract(javax.media.jai.ROI roi)
roi
.
This is only possible if roi
is an instance of ROIGeometry
or ROIShape
.subtract
in class javax.media.jai.ROI
roi
- the ROI to addpublic javax.media.jai.ROI transform(AffineTransform at, javax.media.jai.Interpolation interp)
transform
in class javax.media.jai.ROI
at
- the transforminterp
- ignoredpublic javax.media.jai.ROI transform(AffineTransform at)
transform
in class javax.media.jai.ROI
at
- the transformCopyright © 2006–2018 GeoSolutions. All rights reserved.