uk.ac.leeds.ccg.andyt.grids.core
Class AbstractGrid2DSquareCellIntChunk

java.lang.Object
  extended by uk.ac.leeds.ccg.andyt.grids.core.AbstractGrid2DSquareCellChunk
      extended by uk.ac.leeds.ccg.andyt.grids.core.AbstractGrid2DSquareCellIntChunk
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Grid2DSquareCellIntChunk64CellMap, Grid2DSquareCellIntChunkArray, Grid2DSquareCellIntChunkJAI, Grid2DSquareCellIntChunkMap, Grid2DSquareCellIntChunkRAF

public abstract class AbstractGrid2DSquareCellIntChunk
extends AbstractGrid2DSquareCellChunk
implements java.io.Serializable

Provides general methods and controls what methods extended classes must implement acting as an interface.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class uk.ac.leeds.ccg.andyt.grids.core.AbstractGrid2DSquareCellChunk
AbstractGrid2DSquareCellChunk.ChunkCellID
 
Field Summary
 
Fields inherited from class uk.ac.leeds.ccg.andyt.grids.core.AbstractGrid2DSquareCellChunk
_ChunkID, _Grid2DSquareCell, isSwapUpToDate
 
Constructor Summary
AbstractGrid2DSquareCellIntChunk()
           
 
Method Summary
protected abstract  void clearData()
          For clearing the data associated with this.
protected  java.math.BigDecimal getArithmeticMeanBigDecimal(int numberOfDecimalPlaces)
          Returns the Arithmetic Mean of all non noDataValues as a BigDecimal.
 java.math.BigDecimal getArithmeticMeanBigDecimal(int numberOfDecimalPlaces, boolean handleOutOfMemoryError)
          Returns the Arithmetic Mean of all non noDataValues as a BigDecimal.
protected  double getArithmeticMeanDouble()
          For returning the Arithmetic Mean of all non noDataValues as a double.
 double getArithmeticMeanDouble(boolean handleOutOfMemoryError)
          For returning the Arithmetic Mean of all non noDataValues as a double.
protected abstract  int getCell(int chunkCellRowIndex, int chunkCellColIndex, int noDataValue)
          Returns the value at position given by: chunk cell row chunkCellRowIndex; chunk cell col chunkCellColIndex as a int.
 int getCell(int chunkCellRowIndex, int chunkCellColIndex, int noDataValue, boolean handleOutOfMemoryError)
          Returns the value at position given by: chunk cell row chunkCellRowIndex; chunk cell row chunkCellColIndex, as a double.
 double getCellDouble(int chunkCellRowIndex, int chunkCellColIndex, int noDataValue, boolean handleOutOfMemoryError)
          Returns the value at position given by: chunk cell row chunkCellRowIndex; chunk cell col chunkCellColIndex as a double.
protected  Grid2DSquareCellInt getGrid2DSquareCellInt()
           
 Grid2DSquareCellInt getGrid2DSquareCellInt(boolean handleOutOfMemoryError)
           
protected  int getMaxInt()
          For returning the maximum of all non noDataValues as a double.
 int getMaxInt(boolean handleOutOfMemoryError)
          For returning the maximum of all non noDataValues as a double.
protected  double getMedianDouble()
          Returns the median of all non noDataValues as a double.
 double getMedianDouble(boolean handleOutOfMemoryError)
          Returns the median of all non noDataValues as a double.
protected  int getMinInt()
          For returning the minimum of all non noDataValues as a int
 int getMinInt(boolean handleOutOfMemoryError)
          For returning the minimum of all non noDataValues as a int.
protected  gnu.trove.TIntHashSet getModeTIntHashSet()
          For returning the mode of all non noDataValues as a TDoubleHashSet.
 gnu.trove.TIntHashSet getModeTIntHashSet(boolean handleOutOfMemoryError)
          For returning the mode of all non noDataValues as a TDoubleHashSet.
protected  java.math.BigInteger getNonNoDataValueCountBigInteger()
          For returning the number of cells with noDataValues as a BigInteger.
 java.math.BigInteger getNonNoDataValueCountBigInteger(boolean handleOutOfMemoryError)
          For returning the number of cells with noDataValues as a BigInteger.
protected  int getNonNoDataValueCountInt()
          Returns the number of cells with noDataValues as an int.
 int getNonNoDataValueCountInt(boolean handleOutOfMemoryError)
          Returns the number of cells with noDataValues as an int.
protected  double getStandardDeviationDouble()
          Returns the standard deviation of all non noDataValues as a double.
 double getStandardDeviationDouble(boolean handleOutOfMemoryError)
          Returns the standard deviation of all non noDataValues as a double.
protected  java.math.BigDecimal getSumBigDecimal()
          For returning the sum of all non noDataValues as a BigDecimal.
 java.math.BigDecimal getSumBigDecimal(boolean handleOutOfMemoryError)
          For returning the sum of all non noDataValues as a BigDecimal.
protected abstract  void initCell(int chunkCellRowIndex, int chunkCellColIndex, int valueToInitialise)
          Initialises the value at position given by: chunk cell row chunkCellRowIndex; chunk cell column chunkCellColIndex.
 void initCell(int chunkCellRowIndex, int chunkCellColIndex, int valueToInitialise, boolean handleOutOfMemoryError)
          Initialises the value at position given by: chunk cell row chunkCellRowIndex; chunk cell column chunkCellColIndex.
protected  void initCells(Grid2DSquareCellIntChunkRAF grid2DSquareCellIntChunkRAF)
          Initialises the value of this with those in the Grid2DSquareCellIntChunkRAF grid2DSquareCellIntChunkRAF.
protected  void initCells(Grid2DSquareCellIntChunkRAF grid2DSquareCellIntChunkRAF, boolean handleOutOfMemoryError)
          Initialises the value of this with those in the Grid2DSquareCellIntChunkRAF grid2DSquareCellIntChunkRAF.
protected abstract  void initData()
          For initialising the data associated with this.
protected abstract  int setCell(int chunkCellRowIndex, int chunkCellColIndex, int valueToSet, int noDataValue)
          Returns the value at position given by: chunk cell row chunkCellRowIndex; chunk cell row chunkCellColIndex and sets it to valueToSet
 int setCell(int chunkCellRowIndex, int chunkCellColIndex, int valueToSet, int noDataValue, boolean handleOutOfMemoryError)
          Returns the value at position given by: chunk cell row chunkCellRowIndex; chunk cell row chunkCellColIndex and sets it to valueToSet
protected  void sort1(int[] x, int off, int len)
          Sorts the specified sub-array of doubles into ascending order.
protected  int[] toArrayIncludingNoDataValues()
          Returns values in row major order as an int[].
 int[] toArrayIncludingNoDataValues(boolean handleOutOfMemoryError)
          Returns values in row major order as an int[].
protected  int[] toArrayNotIncludingNoDataValues()
          Returns values (except those that are noDataValues) in row major order as an int[].
 int[] toArrayNotIncludingNoDataValues(boolean handleOutOfMemoryError)
          Returns values (except those that are noDataValues) in row major order as an int[].
 
Methods inherited from class uk.ac.leeds.ccg.andyt.grids.core.AbstractGrid2DSquareCellChunk
getChunkID, getChunkID, getDescription, getGrid2DSquareCell, getGrid2DSquareCell, getIsSwapUpToDate, getIsSwapUpToDate, getName, getName, inChunk, inChunk, initChunkID, initGrid2DSquareCell, iterator, iterator, setIsSwapUpToDate, setIsSwapUpToDate, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractGrid2DSquareCellIntChunk

public AbstractGrid2DSquareCellIntChunk()
Method Detail

getGrid2DSquareCellInt

public Grid2DSquareCellInt getGrid2DSquareCellInt(boolean handleOutOfMemoryError)
Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.
Returns:
( Grid2DSquareCellInt ) this._Grid2DSquareCell.

getGrid2DSquareCellInt

protected Grid2DSquareCellInt getGrid2DSquareCellInt()
Returns:
( Grid2DSquareCellInt ) this._Grid2DSquareCell.

getCell

public int getCell(int chunkCellRowIndex,
                   int chunkCellColIndex,
                   int noDataValue,
                   boolean handleOutOfMemoryError)
Returns the value at position given by: chunk cell row chunkCellRowIndex; chunk cell row chunkCellColIndex, as a double.

Parameters:
chunkCellRowIndex - The row index of the cell w.r.t. the origin of this chunk.
chunkCellColIndex - The column index of the cell w.r.t. the origin of this chunk.
noDataValue - The noDataValue of this.grid2DSquareCellDouble.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

getCell

protected abstract int getCell(int chunkCellRowIndex,
                               int chunkCellColIndex,
                               int noDataValue)
Returns the value at position given by: chunk cell row chunkCellRowIndex; chunk cell col chunkCellColIndex as a int.

Parameters:
chunkCellRowIndex - The row index of the cell w.r.t. the origin of this chunk
chunkCellColIndex - The column index of the cell w.r.t. the origin of this chunk
noDataValue - The noDataValue of this.grid2DSquareCellInt

getCellDouble

public double getCellDouble(int chunkCellRowIndex,
                            int chunkCellColIndex,
                            int noDataValue,
                            boolean handleOutOfMemoryError)
Returns the value at position given by: chunk cell row chunkCellRowIndex; chunk cell col chunkCellColIndex as a double.

Parameters:
chunkCellRowIndex - the row index of the cell w.r.t. the origin of this chunk
chunkCellColIndex - the column index of the cell w.r.t. the origin of this chunk
noDataValue - the noDataValue of this.grid2DSquareCellInt
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown. TODO: Ensure the int can be represented exactly as a double. If not throw Exception of some kind.

initCell

public void initCell(int chunkCellRowIndex,
                     int chunkCellColIndex,
                     int valueToInitialise,
                     boolean handleOutOfMemoryError)
Initialises the value at position given by: chunk cell row chunkCellRowIndex; chunk cell column chunkCellColIndex. Utility method for constructors of extending classes.

Parameters:
chunkCellRowIndex - the row index of the cell w.r.t. the origin of this chunk
chunkCellColIndex - the column index of the cell w.r.t. the origin of this chunk
valueToInitialise - the value with which the cell is initialised
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

initCell

protected abstract void initCell(int chunkCellRowIndex,
                                 int chunkCellColIndex,
                                 int valueToInitialise)
Initialises the value at position given by: chunk cell row chunkCellRowIndex; chunk cell column chunkCellColIndex. Utility method for constructors of extending classes.

Parameters:
chunkCellRowIndex - the row index of the cell w.r.t. the origin of this chunk
chunkCellColIndex - the column index of the cell w.r.t. the origin of this chunk
valueToInitialise - the value with which the cell is initialised

initCells

protected void initCells(Grid2DSquareCellIntChunkRAF grid2DSquareCellIntChunkRAF,
                         boolean handleOutOfMemoryError)
Initialises the value of this with those in the Grid2DSquareCellIntChunkRAF grid2DSquareCellIntChunkRAF.

Parameters:
grid2DSquareCellIntChunkRAF - The Grid2DSquareCellIntChunkRAF used to initialise this.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

initCells

protected void initCells(Grid2DSquareCellIntChunkRAF grid2DSquareCellIntChunkRAF)
Initialises the value of this with those in the Grid2DSquareCellIntChunkRAF grid2DSquareCellIntChunkRAF.

Parameters:
grid2DSquareCellIntChunkRAF - The Grid2DSquareCellIntChunkRAF used to initialise this.

setCell

public int setCell(int chunkCellRowIndex,
                   int chunkCellColIndex,
                   int valueToSet,
                   int noDataValue,
                   boolean handleOutOfMemoryError)
Returns the value at position given by: chunk cell row chunkCellRowIndex; chunk cell row chunkCellColIndex and sets it to valueToSet

Parameters:
chunkCellRowIndex - the row index of the cell w.r.t. the origin of this chunk
chunkCellColIndex - the column index of the cell w.r.t. the origin of this chunk
valueToSet - the value the cell is to be set to
noDataValue - the noDataValue of this.grid2DSquareCellDouble
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

setCell

protected abstract int setCell(int chunkCellRowIndex,
                               int chunkCellColIndex,
                               int valueToSet,
                               int noDataValue)
Returns the value at position given by: chunk cell row chunkCellRowIndex; chunk cell row chunkCellColIndex and sets it to valueToSet

Parameters:
chunkCellRowIndex - the row index of the cell w.r.t. the origin of this chunk
chunkCellColIndex - the column index of the cell w.r.t. the origin of this chunk
valueToSet - the value the cell is to be set to
noDataValue - the noDataValue of this.grid2DSquareCellDouble

clearData

protected abstract void clearData()
For clearing the data associated with this.

Specified by:
clearData in class AbstractGrid2DSquareCellChunk

initData

protected abstract void initData()
For initialising the data associated with this.

Specified by:
initData in class AbstractGrid2DSquareCellChunk

toArrayIncludingNoDataValues

public int[] toArrayIncludingNoDataValues(boolean handleOutOfMemoryError)
Returns values in row major order as an int[].

Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

toArrayIncludingNoDataValues

protected int[] toArrayIncludingNoDataValues()
Returns values in row major order as an int[].


toArrayNotIncludingNoDataValues

public int[] toArrayNotIncludingNoDataValues(boolean handleOutOfMemoryError)
Returns values (except those that are noDataValues) in row major order as an int[].

Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

toArrayNotIncludingNoDataValues

protected int[] toArrayNotIncludingNoDataValues()
Returns values (except those that are noDataValues) in row major order as an int[].


getNonNoDataValueCountBigInteger

public java.math.BigInteger getNonNoDataValueCountBigInteger(boolean handleOutOfMemoryError)
For returning the number of cells with noDataValues as a BigInteger.

Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

getNonNoDataValueCountBigInteger

protected java.math.BigInteger getNonNoDataValueCountBigInteger()
For returning the number of cells with noDataValues as a BigInteger.


getNonNoDataValueCountInt

public int getNonNoDataValueCountInt(boolean handleOutOfMemoryError)
Returns the number of cells with noDataValues as an int.

Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

getNonNoDataValueCountInt

protected int getNonNoDataValueCountInt()
Returns the number of cells with noDataValues as an int.


getSumBigDecimal

public java.math.BigDecimal getSumBigDecimal(boolean handleOutOfMemoryError)
For returning the sum of all non noDataValues as a BigDecimal.

Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

getSumBigDecimal

protected java.math.BigDecimal getSumBigDecimal()
For returning the sum of all non noDataValues as a BigDecimal.


getMinInt

public int getMinInt(boolean handleOutOfMemoryError)
For returning the minimum of all non noDataValues as a int.

Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

getMinInt

protected int getMinInt()
For returning the minimum of all non noDataValues as a int


getMaxInt

public int getMaxInt(boolean handleOutOfMemoryError)
For returning the maximum of all non noDataValues as a double.

Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

getMaxInt

protected int getMaxInt()
For returning the maximum of all non noDataValues as a double.


getArithmeticMeanBigDecimal

public java.math.BigDecimal getArithmeticMeanBigDecimal(int numberOfDecimalPlaces,
                                                        boolean handleOutOfMemoryError)
Returns the Arithmetic Mean of all non noDataValues as a BigDecimal. If all cells are noDataValues, then null is returned.

Parameters:
numberOfDecimalPlaces - The number of decimal places to which the result is precise.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

getArithmeticMeanBigDecimal

protected java.math.BigDecimal getArithmeticMeanBigDecimal(int numberOfDecimalPlaces)
Returns the Arithmetic Mean of all non noDataValues as a BigDecimal. If all cells are noDataValues, then null is returned.

Parameters:
numberOfDecimalPlaces - The number of decimal places to which the result is precise.

getArithmeticMeanDouble

public double getArithmeticMeanDouble(boolean handleOutOfMemoryError)
For returning the Arithmetic Mean of all non noDataValues as a double. Using BigDecimal this should be as precise as possible with doubles.

Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

getArithmeticMeanDouble

protected double getArithmeticMeanDouble()
For returning the Arithmetic Mean of all non noDataValues as a double. Using BigDecimal this should be as precise as possible with doubles.


getModeTIntHashSet

public gnu.trove.TIntHashSet getModeTIntHashSet(boolean handleOutOfMemoryError)
For returning the mode of all non noDataValues as a TDoubleHashSet.

Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

getModeTIntHashSet

protected gnu.trove.TIntHashSet getModeTIntHashSet()
For returning the mode of all non noDataValues as a TDoubleHashSet. TODO: Better to use toArray and go through a sorted version?


getMedianDouble

public double getMedianDouble(boolean handleOutOfMemoryError)
Returns the median of all non noDataValues as a double.

Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

getMedianDouble

protected double getMedianDouble()
Returns the median of all non noDataValues as a double. This method requires that all data in chunk can be stored as a new array.


sort1

protected void sort1(int[] x,
                     int off,
                     int len)
Sorts the specified sub-array of doubles into ascending order. Source copied from java.util.Arrays and method changed so not static for performance reasons.


getStandardDeviationDouble

public double getStandardDeviationDouble(boolean handleOutOfMemoryError)
Returns the standard deviation of all non noDataValues as a double.

Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

getStandardDeviationDouble

protected double getStandardDeviationDouble()
Returns the standard deviation of all non noDataValues as a double.