GRASS
Class CELL

java.lang.Object
  |
  +--GRASS.CELL

public class CELL
extends java.lang.Object

This class wraps GRASS library CELL*. Note that this CELL is a row of cells and not a single CELL. See the GRASS 4.2 Programmer's Manual, Appendix B The CELL Data Type

See Also:
libgis

Constructor Summary
CELL()
          Constructs an empty object and allocates memory for a row of CELLs.
 
Method Summary
 int cellAt(int pos)
          Inquires for category value in the buffer at the position pos.
 void fromArray(int[] ar)
          Fills the buffer with values from the provided array.
 void G_zero_cell_buf()
          Assigns each member of raster buffer to zero.
 int getSize()
          Returns the size of this CELL buffer in cells.
 void setCellAt(int pos, int val)
          Sets category value in the buffer at the position pos.
 int[] toArray()
          Allocates array and fills it with the content of the buffer.
 int[] toArray(int[] ar)
          Fills the provided array with the content of the buffer.
 int[] toColorArray(Colors colors)
          Creates and fills an array with the content of the buffer converted into integer color values.
 int[] toColorArray(int[] ar, Colors colors)
          Fills the provided array with the content of the buffer converted into integer color values.
 java.lang.String toString()
          Returns a string representation of the object.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CELL

public CELL()
Constructs an empty object and allocates memory for a row of CELLs. Somewhat equivivalent to GRASS library routine:
 CELL *cell;
 cell = G_allocate_cell_buf( );
 
See the GRASS 4.2 Programmer's Manual, Section 12.9.5 Allocating Raster I/O Buffers
Parameters:
gl - Previously initialized GRASS library
Method Detail

getSize

public int getSize()
Returns the size of this CELL buffer in cells. Buffer size is determined at the moment of creation by calling G_window_cols() routine.
Returns:
size of the buffer

G_zero_cell_buf

public void G_zero_cell_buf()
                     throws GRASSException
Assigns each member of raster buffer to zero. Wraps GRASS library routine:
 G_zero_cell_buf(buf);
 CELL *buf;
 
See the GRASS 4.2 Programmer's Manual, Section 12.9.5 Allocating Raster I/O Buffers
Throws:
GRASSException - is thrown if an attempt to call this method was done when this buffer size is not equall to G_window_cols()

cellAt

public int cellAt(int pos)
           throws GRASSException
Inquires for category value in the buffer at the position pos.
Parameters:
pos - position in the cell buffer
Returns:
category value at the specified position
Throws:
GRASSException - Exception with an appropriate error message is thrown if specified position falls outside buffer size.

setCellAt

public void setCellAt(int pos,
                      int val)
               throws GRASSException
Sets category value in the buffer at the position pos.
Parameters:
pos - position in the cell buffer
val - category value position to set position to
Throws:
GRASSException - Exception with an appropriate error message is thrown if specified position falls outside buffer size.

toArray

public int[] toArray()
Allocates array and fills it with the content of the buffer.
Returns:
content of the buffer

toArray

public int[] toArray(int[] ar)
              throws GRASSException
Fills the provided array with the content of the buffer. To save memory allocate array with toArray() method and then use this method to update it on each iteration. This method is more effective then calling cellAt().
Parameters:
ar - array to save buffer values to
Returns:
content of the buffer
Throws:
GRASSException - is thrown if size of the provided array is not equal to the size of the buffer

fromArray

public void fromArray(int[] ar)
               throws GRASSException
Fills the buffer with values from the provided array. This method is more effective then calling setCellAt().
Parameters:
ar - array to read buffer values from
Throws:
GRASSException - is thrown if size of the provided array is not equal to the size of the buffer

toColorArray

public int[] toColorArray(Colors colors)
Creates and fills an array with the content of the buffer converted into integer color values. This method is convinient for in-memory images
Parameters:
color - Colors object used to convert original buffer values
ar - array to save color values to
Returns:
content of the buffer
See Also:
Color

toColorArray

public int[] toColorArray(int[] ar,
                          Colors colors)
                   throws GRASSException
Fills the provided array with the content of the buffer converted into integer color values. To save memory allocate array with toColorArray() method and then use this method to update it on each iteration. This method is convinient for in-memory images
Parameters:
color - Colors object used to convert original buffer values
ar - array to save color values to
Returns:
content of the buffer
Throws:
GRASSException - is thrown if size of the provided array is not equal to the size of the buffer
See Also:
Color

toString

public java.lang.String toString()
Returns a string representation of the object.
Returns:
String that represents this object (only its location in memory and row length)
Overrides:
toString in class java.lang.Object


GRASS-JNI Home Page