org.opengis.example.coverage
Class SimpleGridCoordinates

Show UML class diagram
Object
  extended by SimpleGridCoordinates
All Implemented Interfaces:
Serializable, GridCoordinates

public class SimpleGridCoordinates
extends Object
implements GridCoordinates, Serializable

A GridCoordinates implementation which store value in a int[] array. This class holds the set of grid coordinates that specifies the location of the grid point within the grid.

Since:
3.1
See Also:
Serialized Form

Field Summary
protected  int[] coordinates
          The grid coordinates.
 
Constructor Summary
SimpleGridCoordinates(int dimension)
          Creates a grid coordinates of the specified dimension.
SimpleGridCoordinates(int[] coordinates)
          Creates a grid coordinates initialized to the specified values.
SimpleGridCoordinates(int[] coordinates, int lower, int upper)
          Creates a grid coordinates initialized to the specified values in the specified range.
 
Method Summary
 boolean equals(Object object)
          Compares this grid coordinates with the specified object for equality.
 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.
 int hashCode()
          Returns a hash code value for this object.
 void setCoordinateValue(int dimension, int value)
          Sets the coordinate value at the specified dimension (optional operation).
 String toString()
          Returns a string representation of this grid coordinates.
 
Methods inherited from class Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

coordinates

protected final int[] coordinates
The grid coordinates.

Constructor Detail

SimpleGridCoordinates

public SimpleGridCoordinates(int dimension)
Creates a grid coordinates of the specified dimension. All coordinates are initially set to 0.

Parameters:
dimension - The number of dimension.

SimpleGridCoordinates

public SimpleGridCoordinates(int[] coordinates)
Creates a grid coordinates initialized to the specified values.

Parameters:
coordinates - The grid coordinates to copy.

SimpleGridCoordinates

public SimpleGridCoordinates(int[] coordinates,
                             int lower,
                             int upper)
Creates a grid coordinates initialized to the specified values in the specified range.

Parameters:
coordinates - The coordinates to copy.
lower - Index of the first value to copy, inclusive.
upper - Index of the last value to copy, exclusive.
Method Detail

getDimension

public int getDimension()
Returns the number of dimensions. This method is equivalent to getCoordinateValues().length. It is provided for efficiency.

Specified by:
getDimension in interface GridCoordinates

getCoordinateValues

public int[] getCoordinateValues()
Returns one integer value for each dimension of the grid. The ordering of these coordinate values shall be the same as that of the elements of Grid.getAxisNames(). The value of a single coordinate shall be the number of offsets from the origin of the grid in the direction of a specific axis.

Specified by:
getCoordinateValues in interface GridCoordinates
Returns:
A copy of the coordinates. Changes in the returned array will not be reflected back in this SimpleGridCoordinates object.

getCoordinateValue

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

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

setCoordinateValue

public void setCoordinateValue(int dimension,
                               int value)
                        throws ArrayIndexOutOfBoundsException
Sets the coordinate value at the specified dimension (optional operation).

Specified by:
setCoordinateValue in interface GridCoordinates
Parameters:
dimension - The index of the value to set.
value - The new value.
Throws:
ArrayIndexOutOfBoundsException - if the specified dimension is out of bounds.

equals

public boolean equals(Object object)
Compares this grid coordinates with the specified object for equality.

Overrides:
equals in class Object
Parameters:
object - The object to compares with this grid coordinates.
Returns:
true if the given object is equal to this grid coordinates.

hashCode

public int hashCode()
Returns a hash code value for this object.

Overrides:
hashCode in class Object

toString

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

Overrides:
toString in class Object


Copyright © 1994-2013 Open Geospatial Consortium. All Rights Reserved.