|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.geotools.renderer.geom.Geometry org.geotools.renderer.geom.GeometryCollection
A collection of geometry shapes. Included geometries may be Polyline
s, Polygon
s
or others GeometryCollection
. Regrouping related polygons in a single collection
help to speed up the rendering. Polygons can be regrouped on a spatial basis (European polygons,
African polygons, etc.) or on a value basis (50 meters isobath, 100 meters isobath, etc.).
A GeometryCollection
is initially built with a coordinate system. An arbitrary amount of geometries can be added
after construction using add(Geometry)
or add(float[],int,int)
. Geometries
will be rendered in the order they were added. If polygons are broken in many pieces, then
the assemble(...)
method may help
to assemble them before rendering.
Note: this class has a natural ordering that is inconsistent with equals.
The compareTo(java.lang.Object)
method compares only the collection's value, while equals(java.lang.Object)
compares also all coordinate points. The natural ordering for
GeometryCollection
is convenient for sorting collections in alphabetical order
or isobaths in increasing order of altitude.
Polyline
,
Polygon
,
Serialized FormField Summary |
Fields inherited from class org.geotools.renderer.geom.Geometry |
DEFAULT_COORDINATE_SYSTEM |
Constructor Summary | |
GeometryCollection()
Construct an initially empty collection using the default coordinate system. |
|
GeometryCollection(CoordinateSystem coordinateSystem)
Construct an initially empty collection. |
|
GeometryCollection(GeometryCollection geometry)
Construct a collection with the same data as the specified collection. |
Method Summary | |
void |
add(float[] array,
int lower,
int upper)
Adds points to this collection. |
Geometry |
add(Geometry toAdd)
Add a geometry to this collection. |
void |
add(java.awt.Shape shape)
Add geometries from the specified shape. |
void |
assemble(ProgressListener progress)
Assemble all polylines with default setting. |
void |
assemble(java.awt.Shape mapBounds,
float[] toComplete,
ProgressListener progress)
Assemble all polylines in order to create closed polygons for proper rendering. |
Geometry |
clip(Clipper clipper)
Returns an geometry approximately equal to this geometry clipped to the specified bounds. |
java.lang.Object |
clone()
Return a copy of this geometry. |
int |
compareTo(java.lang.Object object)
Compare this geometry with the specified object for order. |
float |
compress(CompressionLevel level)
Compress all geometries in this collection. |
boolean |
contains(double x,
double y)
Indicates whether the specified (x,y) point is inside this geometry. |
boolean |
contains(java.awt.geom.Point2D point)
Indicates whether the specified point is inside this geometry. |
boolean |
contains(java.awt.geom.Rectangle2D rect)
Checks whether the specified rectangle is entirely contained within this geometry. |
boolean |
contains(java.awt.Shape shape)
Checks whether the specified shape is entirely contained within this geometry. |
boolean |
equals(java.lang.Object object)
Compares the specified object with this geometry for equality. |
java.awt.geom.Rectangle2D |
getBounds2D()
Return the bounding box of this geometry, including its possible borders. |
CoordinateSystem |
getCoordinateSystem()
Returns the geometry's coordinate system, or null if unknown. |
java.util.Collection |
getGeometries()
Returns the collection of Geometry objects. |
java.util.Collection |
getGeometries(java.awt.geom.Point2D point)
Returns the collection of geometries containing the specified point. |
java.util.Collection |
getGeometriesContaining(java.awt.Shape shape)
Returns the collection of geometries containing the specified shape. |
java.util.Collection |
getGeometriesIntersecting(java.awt.Shape shape)
Returns the collection of geometries intersecting the specified shape. |
java.lang.String |
getName(java.util.Locale locale)
Returns the localized name for this geometry, or null if none. |
java.awt.geom.PathIterator |
getPathIterator(java.awt.geom.AffineTransform transform)
Returns a path iterator for this geometry. |
int |
getPointCount()
Returns the number of points in this geometry. |
java.lang.String |
getPolygonName(java.awt.geom.Point2D point,
java.util.Locale locale)
Returns the name of the smallest polygon at the given location. |
float |
getRenderingResolution()
Returns the rendering resolution. |
Statistics |
getResolution()
Returns the geometry's resolution. |
float |
getValue()
Returns the value for this collection, or NaN if none.
|
int |
hashCode()
Returns a hash value for this geometry. |
boolean |
intersects(java.awt.geom.Rectangle2D rect)
Tests whether the specified rectangle intersects the interior of this geometry. |
boolean |
intersects(java.awt.Shape shape)
Tests whether the specified shape intersects the interior of this geometry. |
boolean |
isEmpty()
Determines whetever the collection is empty. |
protected void |
readObject(java.io.ObjectInputStream in)
Invoked during deserialization. |
boolean |
remove(Geometry toRemove)
Removes a geometry from this collection. |
void |
removeAll()
Remove all geometries from this geometry. |
void |
setCoordinateSystem(CoordinateSystem coordinateSystem)
Set the geometry's coordinate system. |
void |
setRenderingResolution(float resolution)
Hints this geometry that the specified resolution is sufficient for rendering. |
void |
setResolution(double resolution)
Set the geometry's resolution. |
void |
setValue(java.lang.Comparable value)
Set the value for this geometry. |
void |
setValue(float value)
Set the value for this geometry. |
protected void |
writeObject(java.io.ObjectOutputStream out)
Invoked during serialization. |
Methods inherited from class org.geotools.renderer.geom.Geometry |
contains, getBounds, getID, getPathIterator, getStyle, getUserObject, intersects, setID, setStyle, setUserObject, toString |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public GeometryCollection()
add(...)
methods.
add(float[],int,int)
,
add(Shape)
,
add(Geometry)
public GeometryCollection(CoordinateSystem coordinateSystem)
add(...)
methods.
coordinateSystem
- The coordinate system to use for all
points in this collection, or null
if unknown.Geometry.DEFAULT_COORDINATE_SYSTEM
,
LocalCoordinateSystem.PROMISCUOUS
,
LocalCoordinateSystem.CARTESIAN
,
GeographicCoordinateSystem.WGS84
,
add(float[],int,int)
,
add(Shape)
,
add(Geometry)
public GeometryCollection(GeometryCollection geometry)
Method Detail |
public java.lang.String getName(java.util.Locale locale)
null
if none.
getName
in class Geometry
locale
- The desired locale. If no name is available
for this locale, a default locale will be used.
public float getValue()
NaN
if none.
If this collection is an isobath, then the value is typically the isobath altitude.
public void setValue(float value)
public void setValue(java.lang.Comparable value)
String
(for example "Africa"),
or a value as a Number
object (for example Float
(-50)
for the -50 meters isobath). There is two advantages in using Number
instead of String
for values:
compareTo(java.lang.Object)
.getName(java.util.Locale)
.
value
- The value of value for this geometry.public CoordinateSystem getCoordinateSystem()
null
if unknown.
getCoordinateSystem
in class Geometry
public void setCoordinateSystem(CoordinateSystem coordinateSystem) throws org.opengis.referencing.operation.TransformException, UnmodifiableGeometryException
setCoordinateSystem
in class Geometry
coordinateSystem
- The new coordinate system. A null
value
resets the coordinate system given at construction time.
org.opengis.referencing.operation.TransformException
- If a transformation failed. In case of failure,
the state of this object will remain 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 void add(float[] array, int lower, int upper) throws UnmodifiableGeometryException
geometry's coordinate system
. NaN
values will be considered as disjoint lines.
array
- Coordinate array (may contain NaNs). These data will be copied. Consequently,
any modification on data
will have no impact on the geometries created
by this method.lower
- Index of the first x ordinate to add to the polyline.upper
- Index after of the last y ordinate to add to the polyline.
UnmodifiableGeometryException
- if modifying this geometry would corrupt a container.
To avoid this exception, clone this geometry before to modify it.public void add(java.awt.Shape shape) throws java.lang.IllegalArgumentException, UnmodifiableGeometryException
geometry's coordinate system
.
shape
- The shape to add.
java.lang.IllegalArgumentException
- if the specified shape can't be added. This error may
occur if shape
is an instance of Geometry
and uses an
incompatible coordinate system.
UnmodifiableGeometryException
- if modifying this geometry would corrupt a container.
To avoid this exception, clone this geometry before to modify it.public Geometry add(Geometry toAdd) throws org.opengis.referencing.operation.TransformException, UnmodifiableGeometryException
toAdd
- Geometry to add.
org.opengis.referencing.operation.TransformException
- if the specified geometry can't
be transformed in this collection coordinate system.
UnmodifiableGeometryException
- if modifying this geometry would corrupt a container.
To avoid this exception, clone this geometry before to modify it.public boolean remove(Geometry toRemove) throws UnmodifiableGeometryException
toRemove
- The geometry to remove.
true
if the geometry has been removed.
UnmodifiableGeometryException
- if modifying this geometry would corrupt a container.
To avoid this exception, clone this geometry before to modify it.public void removeAll() throws UnmodifiableGeometryException
UnmodifiableGeometryException
- if modifying this geometry would corrupt a container.
To avoid this exception, clone this geometry before to modify it.public void assemble(java.awt.Shape mapBounds, float[] toComplete, ProgressListener progress) throws org.opengis.referencing.operation.TransformException, UnmodifiableGeometryException
Running this method once for a given collection of geometries before renderering helps to repair them. The algorithm is:
GeometryCollection
objects (one for each isobath) with value set to the bathymetric value (for example -50
for the -50 meters
isobath). The toComplete
argument tells which isobaths to complete with
the map border provided by the mapBounds
argument.
mapBounds
- The bounded shape of the map, or null
for assuming a
rectangular map inferred from this geometry. This is the bounding shape of
the software that created the polylines, not an arbitrary clip that the
application would like.toComplete
- value
of collections to complete with map border,
or null
if none.progress
- An optional progress listener (null
in none). This is an
optional but recommanded argument, since the computation may be very long.
org.opengis.referencing.operation.TransformException
- if a transformation was required and failed.
UnmodifiableGeometryException
- if modifying this geometry would corrupt a container.
To avoid this exception, clone this geometry before to modify it.public void assemble(ProgressListener progress) throws org.opengis.referencing.operation.TransformException, UnmodifiableGeometryException
progress
- An optional progress listener (null
in none). This is an
optional but recommanded argument, since the computation may be very long.
org.opengis.referencing.operation.TransformException
- if a transformation was required and failed.
UnmodifiableGeometryException
- if modifying this geometry would corrupt a container.
To avoid this exception, clone this geometry before to modify it.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.
clip
in class Geometry
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 java.util.Collection getGeometries()
Geometry
objects. The collection will
contains geometries in the order they were added.
Geometry
objects.public java.util.Collection getGeometries(java.awt.geom.Point2D point)
point
- The coordinates to look at in this
geometry's coordinate system.
public java.util.Collection getGeometriesContaining(java.awt.Shape shape)
shape
- A shape with coordinates expressed according to getCoordinateSystem()
.
public java.util.Collection getGeometriesIntersecting(java.awt.Shape shape)
shape
- A shape with coordinates expressed according to getCoordinateSystem()
.
public java.lang.String getPolygonName(java.awt.geom.Point2D point, java.util.Locale locale)
point
- The coordinates to look at in this
geometry's coordinate system.locale
- The desired locale for the geometry name.
null
if there is none.public boolean isEmpty()
isEmpty
in class Geometry
public int getPointCount()
getPointCount
in class Geometry
public java.awt.geom.Rectangle2D getBounds2D()
getBounds2D
in interface java.awt.Shape
getBounds2D
in class Geometry
public boolean contains(double x, double y)
getCoordinateSystem()
.
contains
in interface java.awt.Shape
contains
in class Geometry
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 boolean contains(java.awt.geom.Point2D point)
getCoordinateSystem()
.
contains
in interface java.awt.Shape
contains
in class Geometry
point
- the specified point in this geometry coordinate system.
true
if the specified point is inside
the geometry boundary; false
otherwise.public boolean contains(java.awt.geom.Rectangle2D rect)
contains
in interface java.awt.Shape
contains
in class Geometry
public boolean contains(java.awt.Shape shape)
getCoordinateSystem()
.
contains
in class Geometry
public boolean intersects(java.awt.geom.Rectangle2D rect)
intersects
in interface java.awt.Shape
intersects
in class Geometry
public boolean intersects(java.awt.Shape shape)
intersects
in class Geometry
public 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). For example, the
compression may replaces direct positions by relative positions, as in the figures below:
compress
in class Geometry
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 occurred 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 Statistics getResolution()
getResolution
in class Geometry
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 void setResolution(double resolution) throws org.opengis.referencing.operation.TransformException, UnmodifiableGeometryException
resolution
units (usually meters)
from the previous one.
setResolution
in class Geometry
resolution
- Desired resolution, in the same units as getResolution()
.
org.opengis.referencing.operation.TransformException
- If some coordinate transformations were needed and failed.
There is no guarantee on contour'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.
getRenderingResolution
in class Geometry
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.
setRenderingResolution
in class Geometry
resolution
- The resolution to use at rendering time, in units of this geometry's
coordinate system (linear or angular units).public java.awt.geom.PathIterator getPathIterator(java.awt.geom.AffineTransform transform)
getPathIterator
in interface java.awt.Shape
getPathIterator
in class Geometry
public final java.lang.Object clone()
final
for implementation reason.
clone
in interface org.opengis.util.Cloneable
clone
in class Geometry
public int compareTo(java.lang.Object object)
equals
. The method compareTo
compares only the
value, while equals
compares all coordinate
points. The natural ordering for GeometryCollection
is convenient for sorting
geometries in alphabetical order or isobaths in increasing order of altitude. Geometries
without value are sorted last.
compareTo
in interface java.lang.Comparable
object
- The geometry to compare value with.
public boolean equals(java.lang.Object object)
equals
in class Geometry
public int hashCode()
hashCode
in class Geometry
protected void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
java.io.IOException
java.lang.ClassNotFoundException
protected void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException
java.io.IOException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |