|
|||||||||||
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.Polyline
A succession of lines linked by their extremities. A polyline is closed if it is part of a
Polygon
(either the external ring of one of the holes). Each Polyline
object can have its own CoordinateSystem
object, usually specified at construction
time.
A set of Polyline
s can be built from an array of (x,y)
coordinates or from a geometric shape using one of
GeometryCollection.add(...)
methods. Points given
to those methods should not contain map border. Border points (orange points in the
figure below) are treated specially and must be specified using
appendBorder(...)
or prependBorder(...)
methods.
Polygon
,
GeometryCollection
,
Serialized FormField Summary |
Fields inherited from class org.geotools.renderer.geom.Geometry |
DEFAULT_COORDINATE_SYSTEM |
Constructor Summary | |
Polyline(CoordinateSystem coordinateSystem)
Construct an empty Polyline .
|
|
Polyline(Polyline polyline)
Construct a new Polyline with the same data as the specified one.
|
Method Summary | |
void |
append(float[] points,
int lower,
int upper)
Adds the specified coordinate points to the end of this polyline. |
void |
append(Polyline toAppend)
Adds to the end of this polyline the data of the specified polyline. |
void |
appendBorder(float[] border,
int lower,
int upper)
Adds points to the end of this polyline. |
Geometry |
clip(Clipper clipper)
Returns a polyline approximately equal to this polyline clipped to the specified bounds. |
java.lang.Object |
clone()
Return a clone of this polyline. |
void |
close()
Close this polyline. |
float |
compress(CompressionLevel level)
Compress this polyline. |
boolean |
contains(double x,
double y)
Indicates whether the specified (x,y) coordinate is inside this polyline. |
boolean |
contains(java.awt.geom.Point2D pt)
Checks whether a point pt is inside this polyline. |
boolean |
contains(java.awt.geom.Rectangle2D rect)
Test if the interior of this polyline entirely contains the given rectangle. |
boolean |
contains(java.awt.Shape shape)
Test if the interior of this polyline entirely contains the given shape. |
boolean |
equals(java.lang.Object object)
Compare the specified object with this polyline for equality. |
java.awt.geom.Rectangle2D |
getBounds2D()
Return the bounding box of this polyline, including its possible borders. |
int |
getCachedPointCount()
Returns the number of points in the cache. |
CoordinateSystem |
getCoordinateSystem()
Returns the polyline's coordinate system, or null if unknown. |
java.awt.geom.Point2D |
getFirstPoint(java.awt.geom.Point2D point)
Stores the value of the first point into the specified point object. |
void |
getFirstPoints(java.awt.geom.Point2D[] points)
Stores the values of points.length first points into the specified array. |
java.awt.geom.Point2D |
getLastPoint(java.awt.geom.Point2D point)
Stores the value of the last point into the specified point object. |
void |
getLastPoints(java.awt.geom.Point2D[] points)
Stores the values of points.length last points into the specified array. |
java.awt.geom.PathIterator |
getPathIterator(java.awt.geom.AffineTransform transform)
Returns a path iterator for this polyline. |
int |
getPointCount()
Return the number of points in this polyline. |
java.util.Collection |
getPoints()
Returns all polyline's points. |
float |
getRenderingResolution()
Returns the rendering resolution. |
Statistics |
getResolution()
Returns the polyline's resolution. |
int |
hashCode()
Returns a hash value for this polyline. |
boolean |
intersects(java.awt.geom.Rectangle2D rect)
Tests if the interior of the polyline intersects the interior of a specified rectangle. |
boolean |
intersects(java.awt.Shape shape)
Tests if the interior of the polyline intersects the interior of a specified shape. |
boolean |
isClosed()
Returns whether this polyline is closed or not. |
boolean |
isEmpty()
Test if this polyline is empty. |
void |
prependBorder(float[] border,
int lower,
int upper)
Adds points to the start of this polyline. |
static void |
print(Polyline[] polylines,
java.io.Writer out,
java.util.Locale locale)
Write all point coordinates of many polylines side by side. |
static void |
print(java.lang.String[] titles,
java.util.Collection[] points,
java.io.Writer out,
java.util.Locale locale)
Write all points from arbitrary collections side by side. |
void |
print(java.io.Writer out,
java.util.Locale locale)
Write all point coordinates to the specified stream. |
protected void |
readObject(java.io.ObjectInputStream in)
Invoked during deserialization. |
void |
reverse()
Reverse point order in this polyline. |
void |
setCoordinateSystem(CoordinateSystem coordinateSystem)
Sets the polyline's coordinate system. |
void |
setRenderingResolution(float resolution)
Hints this polyline that the specified resolution is sufficient for rendering. |
void |
setResolution(double resolution)
Sets the polyline's resolution. |
Polyline |
subpoly(int lower,
int upper)
Returns a polyline with the point of this polyline from lower
inclusive to upper exclusive. |
float[] |
toArray(float resolution)
Returns a copy of all coordinates of this polyline. |
Methods inherited from class org.geotools.renderer.geom.Geometry |
contains, getBounds, getID, getName, 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 Polyline(CoordinateSystem coordinateSystem)
Polyline
.
Points can be added after the construction with the append(float[], int, int)
method.
coordinateSystem
- The coordinate system to use for all points in this
Polyline
, or null
if unknown.public Polyline(Polyline polyline)
Polyline
with the same data as the specified one.
The new Polyline
will have a copy semantic. However, implementation
shares as much internal data as possible in order to reduce memory footprint.
Method Detail |
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 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 void prependBorder(float[] border, int lower, int upper) throws org.opengis.referencing.operation.TransformException, java.lang.IllegalStateException
border
- Coordinates to add as (x,y) number pairs.lower
- Index of the first x ordinate to add to the border.upper
- Index after the last y ordinate to add to the border.
org.opengis.referencing.operation.TransformException
- if border
contains points that are invalid
for this polyline's native coordinate system.
UnmodifiableGeometryException
- if modifying this geometry would corrupt a container.
To avoid this exception, clone this geometry before to modify it.
java.lang.IllegalStateException
- if this polyline has already been closed.public void appendBorder(float[] border, int lower, int upper) throws org.opengis.referencing.operation.TransformException, java.lang.IllegalStateException
border
- Coordinates to add as (x,y) number pairs.lower
- Index of the first x ordinate to add to the border.upper
- Index after the last y ordinate to add to the border.
org.opengis.referencing.operation.TransformException
- if border
contains points that are invalid
for this polyline's native coordinate system.
UnmodifiableGeometryException
- if modifying this geometry would corrupt a container.
To avoid this exception, clone this geometry before to modify it.
java.lang.IllegalStateException
- if this polyline has already been closed.public void append(float[] points, int lower, int upper) throws org.opengis.referencing.operation.TransformException, java.lang.IllegalStateException
points
- Array of (x,y) coordinates points.
These data will be copied, in such a way that any future modifications of
data
will have no impact on the Polyline
s created.lower
- Index of the first x ordinate to add to the polyline.upper
- Index after the last y ordinate to add to the polyline.
org.opengis.referencing.operation.TransformException
- if points
contains points that are invalid
for this polyline's native coordinate system.
UnmodifiableGeometryException
- if modifying this geometry would corrupt a container.
To avoid this exception, clone this geometry before to modify it.
java.lang.IllegalStateException
- if this polyline has already been closed.public void append(Polyline toAppend) throws org.opengis.referencing.operation.TransformException, java.lang.IllegalStateException
toAppend
is null.
toAppend
- Polyline
to add to the end of this
.
The polyline toAppend
will not be modified.
java.lang.IllegalStateException
- if this polyline has already been closed.
org.opengis.referencing.operation.TransformException
- if toAppend
contains points that are invalid
for this polyline's native coordinate system.
UnmodifiableGeometryException
- if modifying this geometry would corrupt a container.
To avoid this exception, clone this geometry before to modify it.
java.lang.IllegalArgumentException
- if the polyline toAppend
has already been closed.public void reverse()
public Polyline subpoly(int lower, int upper)
lower
inclusive to upper
exclusive. The returned polyline may not be
closed. If no data are available in the specified range, this method returns
null
.
public void close()
public boolean isClosed()
Polygon
instance.
public boolean isEmpty()
isEmpty
in class Geometry
getPointCount()
public int getCachedPointCount()
public int getPointCount()
getPointCount
in class Geometry
isEmpty()
,
getPoints()
,
getFirstPoint(java.awt.geom.Point2D)
,
getFirstPoints(java.awt.geom.Point2D[])
,
getLastPoint(java.awt.geom.Point2D)
,
getLastPoints(java.awt.geom.Point2D[])
,
toArray(float)
public java.util.Collection getPoints()
Point2D
objects using this polyline's coordinate system (getCoordinateSystem()
).
This method returns an immutable collection: changes done to Polyline
after calling this method will not affect the collection. Despite the fact that
this method has a copy semantic, the collection will share many internal structures
in such a way that memory consumption should stay low.
Point2D
objects.getFirstPoint(java.awt.geom.Point2D)
,
getFirstPoints(java.awt.geom.Point2D[])
,
getLastPoint(java.awt.geom.Point2D)
,
getLastPoints(java.awt.geom.Point2D[])
public java.awt.geom.Point2D getFirstPoint(java.awt.geom.Point2D point) throws java.util.NoSuchElementException
point
- Object in which to store the unprojected coordinate.
point
, or a new Point2D
if point
was null.
java.util.NoSuchElementException
- If this polyline contains no point.getFirstPoints(Point2D[])
,
getLastPoint(Point2D)
public java.awt.geom.Point2D getLastPoint(java.awt.geom.Point2D point) throws java.util.NoSuchElementException
point
- Object in which to store the unprojected coordinate.
point
, or a new Point2D
if point
was null.
java.util.NoSuchElementException
- If this polyline contains no point.getLastPoints(Point2D[])
,
getFirstPoint(Point2D)
public void getFirstPoints(java.awt.geom.Point2D[] points) throws java.util.NoSuchElementException
points.length
first points into the specified array.
points
- An array to fill with first polyline's points. points[0]
will contains the first point, points[1]
the second point,
etc.
java.util.NoSuchElementException
- If this polyline doesn't contain enough points.public void getLastPoints(java.awt.geom.Point2D[] points) throws java.util.NoSuchElementException
points.length
last points into the specified array.
points
- An array to fill with last polyline's points.
points[points.length-1]
will contains the last point,
points[points.length-2]
the point before the last one, etc.
java.util.NoSuchElementException
- If this polyline doesn't contain enough points.public java.awt.geom.Rectangle2D getBounds2D()
getBounds2D
in interface java.awt.Shape
getBounds2D
in class Geometry
public boolean contains(double x, double y)
getCoordinateSystem()
. The polyline must also
have been closed before the call to this method (see close()
), if it wasn't
this method will always return false
.
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 pt)
pt
is inside this polyline. The point's coordinates
must be expressed according to the polyline's coordinate system, that is
getCoordinateSystem()
. The polyline must also have been closed before the call
to this method (see close()
), if it wasn't this method will always return
false
.
contains
in interface java.awt.Shape
contains
in class Geometry
pt
- 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)
getCoordinateSystem()
).
contains
in interface java.awt.Shape
contains
in class Geometry
public boolean contains(java.awt.Shape shape)
contains
in class Geometry
public boolean intersects(java.awt.geom.Rectangle2D rect)
getCoordinateSystem()
).
intersects
in interface java.awt.Shape
intersects
in class Geometry
public boolean intersects(java.awt.Shape shape)
getCoordinateSystem()
).
intersects
in class Geometry
public Geometry clip(Clipper clipper)
this
. If this polyline doesn't intersect the clip area, then this
method returns null
. Otherwise, a new polyline is created and returned. The new
polyline 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 clip area.
null
if this polyline doesn't intersect the clip, this
if no clip has been performed, or a new clipped polyline otherwise.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). Compressing polyline
may help to reduce memory usage, providing that there is no reference to the
(x,y) coordinate points outside this polyline (otherwise
the garbage collector will not reclaim the old data).
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 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 Statistics getResolution()
ProjectedCoordinateSystem
or a GeographicCoordinateSystem
.
More specifically:
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 polyline'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 polyline'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 float[] toArray(float resolution)
null
, but may return an array
of length 0 if no data are available.
resolution
- The minimum distance desired between points, in the same units
as for the getResolution()
method (i.e. linear units as much as
possible - usually meters - even for geographic coordinate system).
If resolution
is greater than 0, then points that are closer
than resolution
from previous points will be skipped. This method
is not required to perform precise distance computations.
public void print(java.io.Writer out, java.util.Locale locale) throws java.io.IOException
out
- The destination stream, or null
for the standard output.locale
- Desired locale, or null
for a default one.
java.io.IOException
- If an error occured while writing to the destination stream.public static void print(Polyline[] polylines, java.io.Writer out, java.util.Locale locale) throws java.io.IOException
polylines
- The set of polylines. Polygons may have different lengths.out
- The destination stream, or null
for the standard output.locale
- Desired locale, or null
for a default one.
java.io.IOException
- If an error occured while writing to the destination stream.public static void print(java.lang.String[] titles, java.util.Collection[] points, java.io.Writer out, java.util.Locale locale) throws java.io.IOException
titles
- The column's titles. Should have the same length as points
.points
- Array of points collections. Collections may have different sizes.out
- The destination stream, or null
for the standard output.locale
- Desired locale, or null
for a default one.
java.io.IOException
- If an error occured while writing to the destination stream.public java.lang.Object clone()
clone
in interface org.opengis.util.Cloneable
clone
in class Geometry
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
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |