org.geotools.renderer.array
Class JTSArray

java.lang.Object
  extended byorg.geotools.renderer.array.PointArray
      extended byorg.geotools.renderer.array.JTSArray
All Implemented Interfaces:
RandomAccess, java.io.Serializable

public final class JTSArray
extends PointArray
implements RandomAccess

A wrapper around an array of JTS Coordinates. As of JTS 1.3, LineString stores its internal data as an array of type Coordinate[]. This JTSArray class wrap directly this LineString internal array, in order to avoid object creation and copies.

Version:
$Id: JTSArray.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Martin Desruisseaux
See Also:
DefaultArray, GenericArray, DefaultArray.getInstance(float[], int, int, boolean), Serialized Form

Constructor Summary
JTSArray(com.vividsolutions.jts.geom.Coordinate[] coords)
          Construct a new JTSArray for the specified coordinate points.
JTSArray(com.vividsolutions.jts.geom.Coordinate[] coords, int lower, int upper)
          Construct a new JTSArray which is a sub-array of the specified coordinates.
 
Method Summary
 int count()
          Returns the number of points in this array.
 java.awt.geom.Rectangle2D getBounds2D()
          Returns the bounding box of all x and y ordinates.
 PointArray getFinal(CompressionLevel level)
          Retourne un tableau immutable qui contient les m?mes donn?es que celui-ci.
 java.awt.geom.Point2D getFirstPoint(java.awt.geom.Point2D point)
          Returns the first point in this array.
 java.awt.geom.Point2D getLastPoint(java.awt.geom.Point2D point)
          Returns the last point in this array.
 long getMemoryUsage()
          Returns an estimation of memory usage in bytes.
 java.awt.geom.Point2D getValue(int index)
          Returns the point at the specified index.
 PointArray insertAt(int index, float[] toMerge, int lower, int upper, boolean reverse)
          Ins?re les donn?es (x,y) du tableau toMerge sp?cifi?.
 PointIterator iterator(int index)
          Returns an iterator object that iterates along the point coordinates.
 PointArray reverse()
          Renverse l'ordre de tous les points compris dans ce tableau.
 PointArray subarray(int lower, int upper)
          Retourne un tableau enveloppant les m?mes points que le tableau courant, mais des index lower inclusivement jusqu'? upper exclusivement.
 void toArray(ArrayData dest, float resolution2)
          Append (x,y) coordinates to the specified destination array.
 
Methods inherited from class org.geotools.renderer.array.PointArray
equals, equals, hashCode, insertAt, toArray, toShape, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JTSArray

public JTSArray(com.vividsolutions.jts.geom.Coordinate[] coords)
Construct a new JTSArray for the specified coordinate points.

Parameters:
coords - The array of coordinate points. This array is not cloned.

JTSArray

public JTSArray(com.vividsolutions.jts.geom.Coordinate[] coords,
                int lower,
                int upper)
Construct a new JTSArray which is a sub-array of the specified coordinates.

Parameters:
coords - The array of coordinate points. This array is not cloned.
lower - The first coordinate to use (inclusive).
upper - The last coordinate to use (exclusive).
Method Detail

getMemoryUsage

public final long getMemoryUsage()
Returns an estimation of memory usage in bytes. This method count 32 bytes for each Coordinate object plus 12 bytes for internal fields (the #array reference plus #lower and #upper values).

Specified by:
getMemoryUsage in class PointArray
Returns:
An estimation of memory usage in bytes.

count

public final int count()
Returns the number of points in this array.

Specified by:
count in interface RandomAccess
Specified by:
count in class PointArray

getFirstPoint

public final java.awt.geom.Point2D getFirstPoint(java.awt.geom.Point2D point)
Returns the first point in this array. If point is null, a new Point2D object is allocated and then the result is stored in this object.

Specified by:
getFirstPoint in class PointArray
Parameters:
point - The object in which to store the first point, or null.
Returns:
point or a new Point2D, which contains the first point.

getLastPoint

public final java.awt.geom.Point2D getLastPoint(java.awt.geom.Point2D point)
Returns the last point in this array. If point is null, a new Point2D object is allocated and then the result is stored in this object.

Specified by:
getLastPoint in class PointArray
Parameters:
point - The object in which to store the last point, or null.
Returns:
point or a new Point2D, which contains the last point.

getValue

public java.awt.geom.Point2D getValue(int index)
                               throws java.lang.IndexOutOfBoundsException
Returns the point at the specified index.

Specified by:
getValue in interface RandomAccess
Parameters:
index - The index from 0 inclusive to count() exclusive.
Returns:
The point at the given index.
Throws:
java.lang.IndexOutOfBoundsException - if index is out of bounds.

iterator

public final PointIterator iterator(int index)
Returns an iterator object that iterates along the point coordinates.

Specified by:
iterator in class PointArray
Parameters:
index - Index of the first point to returns in the iteration.
Returns:
The iterator.

getBounds2D

public final java.awt.geom.Rectangle2D getBounds2D()
Returns the bounding box of all x and y ordinates. If this array is empty, then this method returns null.

Overrides:
getBounds2D in class PointArray

subarray

public final PointArray subarray(int lower,
                                 int upper)
Retourne un tableau enveloppant les m?mes points que le tableau courant, mais des index lower inclusivement jusqu'? upper exclusivement. Si le sous-tableau ne contient aucun point (c'est-?-dire si lower==upper), alors cette m?thode retourne null.

Specified by:
subarray in class PointArray
Parameters:
lower - Index du premier point ? prendre en compte.
upper - Index suivant celui du dernier point ? prendre en compte.

insertAt

public PointArray insertAt(int index,
                           float[] toMerge,
                           int lower,
                           int upper,
                           boolean reverse)
Ins?re les donn?es (x,y) du tableau toMerge sp?cifi?.

Specified by:
insertAt in class PointArray
Parameters:
index - Index ? partir d'o? ins?rer les points dans ce tableau. Le point ? cet index ainsi que tous ceux qui le suivent seront d?cal?s vers des index plus ?lev?s.
toMerge - Tableau de coordonn?es (x,y) ? ins?rer dans ce tableau de points. Ses valeurs seront copi?es.
lower - Index de la premi?re coordonn?e de toMerge ? copier dans ce tableau.
upper - Index suivant celui de la derni?re coordonn?e de toMerge ? copier.
reverse - true s'il faut inverser l'ordre des points de toMerge lors de la copie. Cette inversion ne change pas l'ordre (x,y) des coordonn?es de chaque points.
Returns:
this si l'insertion ? pu ?tre faite sur place, ou un autre tableau si ?a n'a pas ?t? possible.

reverse

public PointArray reverse()
Renverse l'ordre de tous les points compris dans ce tableau.

Specified by:
reverse in class PointArray
Returns:
this si l'inversion a pu ?tre faite sur-place, ou un autre tableau si ?a n'a pas ?t? possible.

getFinal

public final PointArray getFinal(CompressionLevel level)
Retourne un tableau immutable qui contient les m?mes donn?es que celui-ci.

Overrides:
getFinal in class PointArray
Parameters:
level - The compression level, or null if no compression is wanted.
Returns:
Tableau immutable et ?ventuellement compress?, this si ce tableau r?pondait d?j? aux conditions ou null si ce tableau ne contient aucune donn?e.

toArray

public final void toArray(ArrayData dest,
                          float resolution2)
Append (x,y) coordinates to the specified destination array. The destination array will be filled starting at index ArrayData.length. If resolution2 is greater than 0, then points that are closer than sqrt(resolution2) from previous one will be skiped.

Specified by:
toArray in class PointArray
Parameters:
resolution2 - The minimum squared distance desired between points.


Copyright © GeoTools. All Rights Reserved.