org.geotools.geometry
Class Envelope2D

java.lang.Object
  extended byjava.awt.geom.RectangularShape
      extended byjava.awt.geom.Rectangle2D
          extended byjava.awt.geom.Rectangle2D.Double
              extended byorg.geotools.geometry.Envelope2D
All Implemented Interfaces:
java.lang.Cloneable, org.opengis.util.Cloneable, org.opengis.spatialschema.geometry.Envelope, java.awt.Shape

public class Envelope2D
extends java.awt.geom.Rectangle2D.Double
implements org.opengis.spatialschema.geometry.Envelope, org.opengis.util.Cloneable

A two-dimensional envelope on top of Rectangle2D. This implementation is provided for interoperability between Java2D and GeoAPI.

Note: This class inherits x and y fields. But despite their names, they don't need to be oriented toward East and North respectively. The (x,y) axis can have any orientation and should be understood as "ordinate 0" and "ordinate 1" values instead. This is not specific to this implementation; in Java2D too, the visual axis orientation depend on the affine transform in the graphics context.

Since:
2.1
Version:
$Id: Envelope2D.java 17720 2006-01-24 22:28:04Z desruisseaux $
Author:
Martin Desruisseaux
See Also:
GeneralEnvelope, ReferencedEnvelope, GeographicBoundingBox

Nested Class Summary
 
Nested classes inherited from class java.awt.geom.Rectangle2D
java.awt.geom.Rectangle2D.Double, java.awt.geom.Rectangle2D.Float
 
Field Summary
 
Fields inherited from class java.awt.geom.Rectangle2D.Double
height, width, x, y
 
Fields inherited from class java.awt.geom.Rectangle2D
OUT_BOTTOM, OUT_LEFT, OUT_RIGHT, OUT_TOP
 
Constructor Summary
Envelope2D(org.opengis.referencing.crs.CoordinateReferenceSystem crs, double x, double y, double width, double height)
          Constructs two-dimensional envelope defined by the specified coordinates.
Envelope2D(org.opengis.referencing.crs.CoordinateReferenceSystem crs, java.awt.geom.Rectangle2D rect)
          Constructs two-dimensional envelope defined by an other Rectangle2D.
Envelope2D(org.opengis.spatialschema.geometry.Envelope envelope)
          Constructs two-dimensional envelope defined by an other Envelope.
 
Method Summary
 boolean boundsEquals(org.opengis.spatialschema.geometry.Envelope that, int xDim, int yDim, double eps)
          Returns if envelope bounds is equals to envelope bounds in two specified dimensions.
 boolean equals(java.lang.Object object)
          Compares the specified object with this envelope for equality.
 double getCenter(int dimension)
          Returns the center ordinate along the specified dimension.
 org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
          Returns the coordinate reference system in which the coordinates are given.
 int getDimension()
          Returns the number of dimensions.
 double getLength(int dimension)
          Returns the envelope length along the specified dimension.
 org.opengis.spatialschema.geometry.DirectPosition getLowerCorner()
          A coordinate position consisting of all the minimal ordinates for each dimension for all points within the .
 double getMaximum(int dimension)
          Returns the maximal ordinate along the specified dimension.
 double getMinimum(int dimension)
          Returns the minimal ordinate along the specified dimension.
 org.opengis.spatialschema.geometry.DirectPosition getUpperCorner()
          A coordinate position consisting of all the maximal ordinates for each dimension for all points within the .
 int hashCode()
          Returns a hash value for this envelope.
 void setCoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
          Set the coordinate reference system in which the coordinate are given.
 
Methods inherited from class java.awt.geom.Rectangle2D.Double
createIntersection, createUnion, getBounds2D, getHeight, getWidth, getX, getY, isEmpty, outcode, setRect, setRect, toString
 
Methods inherited from class java.awt.geom.Rectangle2D
add, add, add, contains, contains, getPathIterator, getPathIterator, intersect, intersects, intersectsLine, intersectsLine, outcode, setFrame, union
 
Methods inherited from class java.awt.geom.RectangularShape
clone, contains, contains, getBounds, getCenterX, getCenterY, getFrame, getMaxX, getMaxY, getMinX, getMinY, intersects, setFrame, setFrame, setFrameFromCenter, setFrameFromCenter, setFrameFromDiagonal, setFrameFromDiagonal
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.opengis.util.Cloneable
clone
 

Constructor Detail

Envelope2D

public Envelope2D(org.opengis.spatialschema.geometry.Envelope envelope)
Constructs two-dimensional envelope defined by an other Envelope.


Envelope2D

public Envelope2D(org.opengis.referencing.crs.CoordinateReferenceSystem crs,
                  java.awt.geom.Rectangle2D rect)
Constructs two-dimensional envelope defined by an other Rectangle2D.


Envelope2D

public Envelope2D(org.opengis.referencing.crs.CoordinateReferenceSystem crs,
                  double x,
                  double y,
                  double width,
                  double height)
Constructs two-dimensional envelope defined by the specified coordinates. Despite their name, the (x,y) coordinates don't need to be oriented toward (East, North). Those parameter names simply match the x and y fields. The actual axis orientations are determined by the specified CRS. See the class javadoc for details.

Method Detail

getCoordinateReferenceSystem

public final org.opengis.referencing.crs.CoordinateReferenceSystem getCoordinateReferenceSystem()
Returns the coordinate reference system in which the coordinates are given.

Returns:
The coordinate reference system, or .

setCoordinateReferenceSystem

public void setCoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
Set the coordinate reference system in which the coordinate are given.

Parameters:
crs - The new coordinate reference system, or .

getDimension

public final int getDimension()
Returns the number of dimensions.

Specified by:
getDimension in interface org.opengis.spatialschema.geometry.Envelope

getLowerCorner

public org.opengis.spatialschema.geometry.DirectPosition getLowerCorner()
A coordinate position consisting of all the minimal ordinates for each dimension for all points within the .

Specified by:
getLowerCorner in interface org.opengis.spatialschema.geometry.Envelope
Returns:
The lower corner.

getUpperCorner

public org.opengis.spatialschema.geometry.DirectPosition getUpperCorner()
A coordinate position consisting of all the maximal ordinates for each dimension for all points within the .

Specified by:
getUpperCorner in interface org.opengis.spatialschema.geometry.Envelope
Returns:
The upper corner.

getMinimum

public final double getMinimum(int dimension)
Returns the minimal ordinate along the specified dimension.

Specified by:
getMinimum in interface org.opengis.spatialschema.geometry.Envelope

getMaximum

public final double getMaximum(int dimension)
Returns the maximal ordinate along the specified dimension.

Specified by:
getMaximum in interface org.opengis.spatialschema.geometry.Envelope

getCenter

public final double getCenter(int dimension)
Returns the center ordinate along the specified dimension.

Specified by:
getCenter in interface org.opengis.spatialschema.geometry.Envelope

getLength

public final double getLength(int dimension)
Returns the envelope length along the specified dimension. This length is equals to the maximum ordinate minus the minimal ordinate.

Specified by:
getLength in interface org.opengis.spatialschema.geometry.Envelope

hashCode

public int hashCode()
Returns a hash value for this envelope. This value need not remain consistent between different implementations of the same class.


equals

public boolean equals(java.lang.Object object)
Compares the specified object with this envelope for equality.


boundsEquals

public boolean boundsEquals(org.opengis.spatialschema.geometry.Envelope that,
                            int xDim,
                            int yDim,
                            double eps)
Returns if envelope bounds is equals to envelope bounds in two specified dimensions. The coordinate reference system is not compared, since it doesn't need to have the same number of dimensions.

Parameters:
that - The envelope to compare to.
xDim - The dimension of envelope to compare to the x dimension of envelope.
yDim - The dimension of envelope to compare to the y dimension of envelope.
eps - A small tolerance number for floating point number comparaisons. This value will be scaled according this envelope width and height.
Returns:
if the envelope bounds are the same (up to the specified tolerance level) in the specified dimensions, or otherwise.


Copyright © GeoTools. All Rights Reserved.