|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.geotools.renderer.geom.Geometry
Base class for geometric shape to be rendered in a given
coordinate system
. Those classes are not designed
for spatial analysis or topology: they are not a replacement
for JTS, neither
an implementation of ISO-19107. They are rather a wrapper around arbitrary source
of (x,y) coordinates to be rendered. With the rendering goal
in mind, this class implements the Shape
interface for interoperability with
Java2D. But it provides also
some more capabilities. For example, contains
and intersects
methods accepts arbitrary shapes instead of rectangle only. Geometry
objects
can have arbitrary two-dimensional coordinate system, which can be
changed at any time (i.e. the geometry can be reprojected).
Decimation can be applied at rendering time. Futhermore,
Geometry
s can compress and share their internal data in
order to reduce memory footprint.
Field Summary | |
static CoordinateSystem |
DEFAULT_COORDINATE_SYSTEM
The default coordinate system for all geometries. |
Constructor Summary | |
|
Geometry()
Construct an empty geographic shape. |
protected |
Geometry(Geometry geometry)
Construct a geographic shape with the same data than the specified geometry. |
Method Summary | |
Geometry |
clip(Clipper clipper)
Returns an geometry approximately equal to this geometry clipped to the specified bounds. |
java.lang.Object |
clone()
Return a clone of this geometry. |
abstract float |
compress(CompressionLevel level)
Compress this geometry. |
boolean |
contains(double x,
double y)
Tests if the specified coordinates are inside the boundary of this geometry. |
boolean |
contains(double x,
double y,
double width,
double height)
Test if the interior of this geometry entirely contains the given rectangle. |
abstract boolean |
contains(java.awt.geom.Point2D point)
Tests if a specified Point2D is inside the boundary of this geometry. |
boolean |
contains(java.awt.geom.Rectangle2D rectangle)
Tests if the interior of this geometry entirely contains the given rectangle. |
abstract boolean |
contains(java.awt.Shape shape)
Test if the interior of this geometry entirely contains the given shape. |
boolean |
equals(java.lang.Object object)
Compares the specified object with this geometry for equality. |
java.awt.Rectangle |
getBounds()
Deprecated. This method is required by the Shape interface,
but it doesn't provide enough precision for most cases.
Use getBounds2D() instead. |
abstract java.awt.geom.Rectangle2D |
getBounds2D()
Returns the bounding box of this geometry. |
abstract CoordinateSystem |
getCoordinateSystem()
Returns the geometry's coordinate system, or null if unknow. |
java.lang.String |
getID()
Returns the geometry ID. |
java.lang.String |
getName(java.util.Locale locale)
Returns the localized name for this geometry, or null if none.
|
abstract java.awt.geom.PathIterator |
getPathIterator(java.awt.geom.AffineTransform transform)
Returns an iterator object that iterates along the shape boundary and provides access to the geometry of the shape outline. |
java.awt.geom.PathIterator |
getPathIterator(java.awt.geom.AffineTransform transform,
double flatness)
Returns a flattened path iterator for this geometry. |
abstract int |
getPointCount()
Return the number of points in this geometry. |
float |
getRenderingResolution()
Returns the rendering resolution. |
abstract Statistics |
getResolution()
Returns the geometry's resolution. |
Style |
getStyle()
Returns the style attached to this geometry, or null if none. |
java.lang.Object |
getUserObject()
Returns the user object attached to this geometry. |
int |
hashCode()
Returns a hash value for this geometry. |
boolean |
intersects(double x,
double y,
double width,
double height)
Tests if the interior of the geometry intersects the interior of a specified rectangle. |
boolean |
intersects(java.awt.geom.Rectangle2D rectangle)
Tests if the interior of the geometry intersects the interior of a specified rectangle. |
abstract boolean |
intersects(java.awt.Shape shape)
Tests if the interior of the geometry intersects the interior of a specified shape. |
boolean |
isEmpty()
Determines whetever this geometry is empty. |
abstract void |
setCoordinateSystem(CoordinateSystem coordinateSystem)
Set the geometry's coordinate system. |
void |
setID(java.lang.String ID)
Sets the geometry ID. |
void |
setRenderingResolution(float resolution)
Hints this geometry that the specified resolution is sufficient for rendering. |
abstract void |
setResolution(double resolution)
Set the geometry's resolution. |
void |
setStyle(Style style)
Set the style attached to this geometry. |
void |
setUserObject(java.lang.Object userObject)
Set the user object for this geometry. |
java.lang.String |
toString()
Return a string representation of this geometry for debugging purpose. |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final CoordinateSystem DEFAULT_COORDINATE_SYSTEM
LocalCoordinateSystem.PROMISCUOUS
,
LocalCoordinateSystem.CARTESIAN
,
GeographicCoordinateSystem.WGS84
Constructor Detail |
public Geometry()
protected Geometry(Geometry geometry)
geometry
- The geometry to copy data from.Method Detail |
public java.lang.String getName(java.util.Locale locale)
null
if none.
The default implementation returns always null
.
locale
- The desired locale. If no name is available
for this locale, a default locale will be used.
public java.lang.String getID()
null
if none.public void setID(java.lang.String ID)
public java.lang.Object getUserObject()
public void setUserObject(java.lang.Object userObject)
public Style getStyle()
null
if none.
public void setStyle(Style style)
style
- The new style for this geometry, or null
if none.public abstract CoordinateSystem getCoordinateSystem()
null
if unknow.
public abstract void setCoordinateSystem(CoordinateSystem coordinateSystem) throws org.opengis.referencing.operation.TransformException, UnmodifiableGeometryException
coordinateSystem
- The new coordinate system. A null
value reset
the default coordinate system (usually the one that best fits internal data).
org.opengis.referencing.operation.TransformException
- If a transformation failed. In case of failure,
the state of this object will stay unchanged, as if this method has
never been invoked.
UnmodifiableGeometryException
- if modifying this geometry would corrupt a container.
To avoid this exception, clone this geometry before to modify it.public boolean isEmpty()
public abstract int getPointCount()
public java.awt.Rectangle getBounds()
Shape
interface,
but it doesn't provide enough precision for most cases.
Use getBounds2D()
instead.
getBounds2D()
.
getBounds
in interface java.awt.Shape
public abstract java.awt.geom.Rectangle2D getBounds2D()
getCoordinateSystem()
).
getBounds2D
in interface java.awt.Shape
public boolean contains(double x, double y)
contains
in interface java.awt.Shape
x
- the specified x coordinates in this geometry coordinate system.y
- the specified y coordinates in this geometry coordinate system.
true
if the specified coordinates are inside
the geometry boundary; false
otherwise.public abstract boolean contains(java.awt.geom.Point2D point)
Point2D
is inside the boundary of this geometry.
contains
in interface java.awt.Shape
point
- the specified point in this geometry coordinate system.
true
if the specified point is inside
the geometry boundary; false
otherwise.public boolean contains(double x, double y, double width, double height)
getCoordinateSystem()
).
contains
in interface java.awt.Shape
public boolean contains(java.awt.geom.Rectangle2D rectangle)
getCoordinateSystem()
).
contains
in interface java.awt.Shape
public abstract boolean contains(java.awt.Shape shape)
shape
argument
must be the same than this Geometry
object, as returned
by getCoordinateSystem()
.
public boolean intersects(double x, double y, double width, double height)
getCoordinateSystem()
).
intersects
in interface java.awt.Shape
public boolean intersects(java.awt.geom.Rectangle2D rectangle)
getCoordinateSystem()
).
intersects
in interface java.awt.Shape
public abstract boolean intersects(java.awt.Shape shape)
shape
argument
must be the same than this Geometry
object, as returned
by getCoordinateSystem()
.
public Geometry clip(Clipper clipper)
this
. If this geometry doesn't intersect the clip area, then this
method returns null
. Otherwise, a new geometry is created and returned. The new
geometry will try to share as much internal data as possible with this
in order
to keep memory footprint low.
clipper
- The clipping area.
null
if this geometry doesn't intersect the clip, this
if no clip has been performed, or a new clipped geometry otherwise.public abstract float compress(CompressionLevel level) throws org.opengis.referencing.operation.TransformException, UnmodifiableGeometryException
level
argument specify the algorithm,
which may be desctructive (i.e. data may loose precision). Compressing geometry
may help to reduce memory usage, providing that there is no reference to the
(x,y) coordinate points outside this geometry (otherwise
the garbage collector will not reclaim the old data).
level
- The compression level (or algorithm) to use. See the CompressionLevel
javadoc for an explanation of available algorithms.
org.opengis.referencing.operation.TransformException
- If an error has come up during a cartographic projection.
UnmodifiableGeometryException
- if modifying this geometry would corrupt a container.
To avoid this exception, clone this geometry before to modify it.public abstract Statistics getResolution()
null
if this geometry doesn't
contains any point. If non-null, the statistics object contains
minimum,
maximum,
mean,
root mean square and
standard deviation
always in linear units.public abstract void setResolution(double resolution) throws org.opengis.referencing.operation.TransformException, UnmodifiableGeometryException
resolution
units (usually meters)
from the previous one. Consequently, the resolution after
this call will have a standard deviation
close to 0.
compress(org.geotools.renderer.geom.CompressionLevel)
provides an alternative
way to reduce memory footprint).
This method is irreversible. Invoking setResolution
with a finner
resolution will increase memory consumption with no real resolution improvement.
resolution
- Desired resolution, in the same linear units than getResolution()
.
org.opengis.referencing.operation.TransformException
- If some coordinate transformations were needed and failed.
There is no guaranteed on geometry's state in case of failure.
UnmodifiableGeometryException
- if modifying this geometry would corrupt a container.
To avoid this exception, clone this geometry before to modify it.public float getRenderingResolution()
PathIterator
only; it has no effect on the underyling data. Note
that at the difference of getResolution()
, the units are not always
linear; they may be angular if the underlying coordinate system is geographic. Resolution in angular units is not very
meaningful for computation purpose (since the length of longitude degrees vary
with latitude), but is what the user see if the map is unprojected.
The rendering resolution is about what the user see.
public void setRenderingResolution(float resolution)
PathIterator
will skip as many points as it can while preserving a
distance equals or smaller than resolution
between two consecutive points.
Note that this method affect the PathIterator
behavior only; it has no impact
on the underlying data. This method is non-destructive; it is possible to set a finer
resolution after a large one.
resolution
- The resolution to use at rendering time, in units of this geometry's
coordinate system (linear or angular units,
see getRenderingResolution()
for a discussion).public abstract java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform transform)
AffineTransform
is specified,
the coordinates returned in the iteration are transformed accordingly. The iterator may
not iterate through all internal data. If a rendering
resolution has been specified, then some points may be skipped during the iteration.
getPathIterator
in interface java.awt.Shape
public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform transform, double flatness)
getPathIterator
in interface java.awt.Shape
public java.lang.Object clone()
clone
in interface org.opengis.util.Cloneable
public boolean equals(java.lang.Object object)
public int hashCode()
public java.lang.String toString()
Polygon["polygon name", 44?30'N-51?59'N 70?59'W-54?59'W (56 pts)]
".
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |