Package org.geotools.coverage.grid
Class GridCoordinates2D
- All Implemented Interfaces:
Serializable
,Cloneable
,GridCoordinates
,Cloneable
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
- Author:
- Martin Desruisseaux
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class Point2D
Point2D.Double, Point2D.Float
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an initially empty grid coordinates.GridCoordinates2D
(int x, int y) Creates a grid coordinates initialized to the specified values.GridCoordinates2D
(Point coordinates) Creates a grid coordinates initialized to the specified point. -
Method Summary
Modifier and TypeMethodDescriptionclone()
Returns a clone of this coordinates.int
getCoordinateValue
(int dimension) Returns the coordinate value at the specified dimension.int[]
Returns one integer value for each dimension of the grid.final int
Returns the number of dimensions, which is always 2.void
setCoordinateValue
(int dimension, int value) Sets the coordinate value at the specified dimension.toString()
Returns a string representation of this grid coordinates.Methods inherited from class Point
equals, getLocation, getX, getY, move, setLocation, setLocation, setLocation, translate
Methods inherited from class Point2D
distance, distance, distance, distanceSq, distanceSq, distanceSq, hashCode, setLocation
-
Constructor Details
-
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
Creates a grid coordinates initialized to the specified point.- Parameters:
coordinates
- The coordinate values to copy.
-
-
Method Details
-
getDimension
public final int getDimension()Returns the number of dimensions, which is always 2.- Specified by:
getDimension
in interfaceGridCoordinates
- Returns:
- The number of dimensions.
-
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 interfaceGridCoordinates
- Returns:
- A copy of the coordinates. Changes in the returned array will not be reflected back in this
GridCoordinates
object.
-
getCoordinateValue
Returns the coordinate value at the specified dimension. This method is equivalent togetCoordinateValues()[i]
. It is provided for efficienty.- Specified by:
getCoordinateValue
in interfaceGridCoordinates
- Parameters:
dimension
- The dimension from 0 inclusive togetDimension()
exclusive.- Returns:
- The value at the requested dimension.
- Throws:
IndexOutOfBoundsException
- if the specified dimension is out of bounds.
-
setCoordinateValue
public void setCoordinateValue(int dimension, int value) throws IndexOutOfBoundsException, UnsupportedOperationException Sets the coordinate value at the specified dimension.- Specified by:
setCoordinateValue
in interfaceGridCoordinates
- Parameters:
dimension
- The index of the value to set.value
- The new value.- Throws:
IndexOutOfBoundsException
- if the specified dimension is out of bounds.UnsupportedOperationException
- if this grid coordinates is not modifiable.
-
toString
Returns a string representation of this grid coordinates. -
clone
Returns a clone of this coordinates.
-