org.geotools.coverage.grid
Class GridCoordinates2D

java.lang.Object
  extended by java.awt.geom.Point2D
      extended by java.awt.Point
          extended by org.geotools.coverage.grid.GridCoordinates2D
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, org.opengis.coverage.grid.GridCoordinates

public class GridCoordinates2D
extends java.awt.Point
implements org.opengis.coverage.grid.GridCoordinates

Holds the set of two-dimensional grid coordinates that specifies the location of the grid point within the grid. This class extends Point for interoperability with Java2D.

Since:
2.5
Version:
$Id: GridCoordinates2D.java 30776 2008-06-20 17:00:11Z desruisseaux $
Author:
Martin Desruisseaux
See Also:
GeneralGridCoordinates, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.geom.Point2D
java.awt.geom.Point2D.Double, java.awt.geom.Point2D.Float
 
Field Summary
 
Fields inherited from class java.awt.Point
x, y
 
Constructor Summary
GridCoordinates2D()
          Creates an initially empty grid coordinates.
GridCoordinates2D(int x, int y)
          Creates a grid coordinates initialized to the specified values.
GridCoordinates2D(java.awt.Point coordinates)
          Creates a grid coordinates initialized to the specified point.
 
Method Summary
 GridCoordinates2D clone()
          Returns a clone of this coordinates.
 int getCoordinateValue(int dimension)
          Returns the coordinate value at the specified dimension.
 int[] getCoordinateValues()
          Returns one integer value for each dimension of the grid.
 int getDimension()
          Returns the number of dimensions, which is always 2.
 void setCoordinateValue(int dimension, int value)
          Sets the coordinate value at the specified dimension.
 java.lang.String toString()
          Returns a string representation of this grid coordinates.
 
Methods inherited from class java.awt.Point
equals, getLocation, getX, getY, move, setLocation, setLocation, setLocation, translate
 
Methods inherited from class java.awt.geom.Point2D
distance, distance, distance, distanceSq, distanceSq, distanceSq, hashCode, setLocation
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GridCoordinates2D

public GridCoordinates2D()
Creates an initially empty grid coordinates.


GridCoordinates2D

public GridCoordinates2D(int x,
                         int y)
Creates a grid coordinates initialized to the specified values.

Parameters:
x - The x coordinate value.
y - The y coordinate value.

GridCoordinates2D

public GridCoordinates2D(java.awt.Point coordinates)
Creates a grid coordinates initialized to the specified point.

Parameters:
coordinates - The coordinate values to copy.
Method Detail

getDimension

public final int getDimension()
Returns the number of dimensions, which is always 2.

Specified by:
getDimension in interface org.opengis.coverage.grid.GridCoordinates

getCoordinateValues

public int[] getCoordinateValues()
Returns one integer value for each dimension of the grid. This method returns (x,y) in an array of length 2.

Specified by:
getCoordinateValues in interface org.opengis.coverage.grid.GridCoordinates

getCoordinateValue

public int getCoordinateValue(int dimension)
                       throws java.lang.IndexOutOfBoundsException
Returns the coordinate value at the specified dimension. This method is equivalent to getCoordinateValues()[i]. It is provided for efficienty.

Specified by:
getCoordinateValue in interface org.opengis.coverage.grid.GridCoordinates
Parameters:
dimension - The dimension from 0 inclusive to getDimension() exclusive.
Returns:
The value at the requested dimension.
Throws:
java.lang.IndexOutOfBoundsException - if the specified dimension is out of bounds.

setCoordinateValue

public void setCoordinateValue(int dimension,
                               int value)
                        throws java.lang.IndexOutOfBoundsException,
                               java.lang.UnsupportedOperationException
Sets the coordinate value at the specified dimension.

Specified by:
setCoordinateValue in interface org.opengis.coverage.grid.GridCoordinates
Parameters:
dimension - The index of the value to set.
value - The new value.
Throws:
java.lang.IndexOutOfBoundsException - if the specified dimension is out of bounds.
java.lang.UnsupportedOperationException - if this grid coordinates is not modifiable.

toString

public java.lang.String toString()
Returns a string representation of this grid coordinates.

Overrides:
toString in class java.awt.Point

clone

public GridCoordinates2D clone()
Returns a clone of this coordinates.

Overrides:
clone in class java.awt.geom.Point2D
Returns:
A clone of this coordinates.


Copyright © 1996-2010 Geotools. All Rights Reserved.