Package org.geotools.coverage.grid
Class GridCoordinates2D
-
- All Implemented Interfaces:
Serializable
,Cloneable
,GridCoordinates
,Cloneable
public class GridCoordinates2D extends Point implements GridCoordinates
Holds the set of two-dimensional grid coordinates that specifies the location of the grid point within the grid. This class extendsPoint
for interoperability with Java2D.- Since:
- 2.5
- Author:
- Martin Desruisseaux
- See Also:
GeneralGridCoordinates
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class Point2D
Point2D.Double, Point2D.Float
-
-
Constructor Summary
Constructors Constructor Description GridCoordinates2D()
Creates 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.String
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 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(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 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
public int getCoordinateValue(int dimension) throws IndexOutOfBoundsException
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
public String toString()
Returns a string representation of this grid coordinates.
-
clone
public GridCoordinates2D clone()
Returns a clone of this coordinates.- Specified by:
clone
in interfaceCloneable
- Overrides:
clone
in classPoint2D
- Returns:
- A clone of this coordinates.
- See Also:
Object.clone()
-
-