net.jbeans.j3d.data
Class DataArray

java.lang.Object
  extended bynet.jbeans.j3d.data.DataArray
Direct Known Subclasses:
BitArray, CharArray, DoubleArray, FloatArray, IntArray, LongArray, ShortArray, StringArray

public abstract class DataArray
extends java.lang.Object

DataArray is an superclass for all net.jbeans.j3d.data array objects. Subclasses of this class handle specific primitive data (boolean, bit, char, short, int, long, float, double, String.) The data structure of DataArray is an array of tuples. Each tuple is a n-dimensional array. DataArray also can be seen as a m x n matrix, where m is the number of tuples, and n is the number of dimension in a tuple. the DataArray can be used to represent various data such as scalars, vectors, texture coordinates, tensors... The Visualization Toolkit (VTK)'s data model was used to create this class and associated subclasses.

Version:
$Revision: 1.3 $
Author:
Masahiro Takatsuka (masa@jbeans.net)

Field Summary
protected  java.lang.Object array
           
protected  int dimension
           
protected  int maxId
           
protected  int size
           
protected  double[] tupleT
           
 
Constructor Summary
DataArray(DataArray da)
           
DataArray(int dim)
          Construct a DataArray object with the specified tuple dimension.
 
Method Summary
abstract  boolean allocate(int size)
           
 void copy(DataArray da)
           
 java.lang.Object ensureSpace(int id, int number)
          ensures data is allocated from the location id for the number of items requested.
 java.lang.Object getData()
          Return a array pointer.
 void getData(int tupleMin, int tupleMax, int eleMin, int eleMax, DataArray data)
          Get the data as a double array in the range (tupleMin,tupleMax) and (compMin, compMax).
 int getDataType()
          Return the underlying data type.
 int getDimension()
          Get the dimension (n) of the elements.
 double getElement(int i, int j)
          Return the data element at the ith tuple and jth element location.
 int getMaxId()
          What is the maximum id currently in the array.
 int getNumberOfTuples()
          Get the number of tuples (a element group) in the array.
 int getSize()
          Return the size of the data.
abstract  double[] getTuple(int i)
          Get the data tuple at ith location.
abstract  void getTuple(int i, double[] tuple)
          Get the data tuple at ith location by filling in a user-provided array.
 void initialize()
          Release storage and reset array to initial state.
 void insertElement(int i, int j, double e)
          Insert the data element at ith tuple and jth element location.
abstract  int insertNextTuple(double[] tuple)
          Insert the data tuple at the end of the array and return the location at which the data was inserted.
abstract  void insertTuple(int i, double[] tuple)
          Insert the data tuple at ith location.
abstract  DataArray makeObject()
          Virtual constructor creates an object of the same type as this one.
 void reset()
          Reset to an empty state, without freeing any memory.
protected abstract  java.lang.Object resize(int size)
          resize the array.
 void setDimension(int dim)
          Set the dimension (n).
 void setElement(int i, int j, double e)
          Set the data element at the ith tuple and jth element location.
abstract  void setNumberOfTuples(int number)
          Set the number of tuples (a element group) in the array.
abstract  void setTuple(int i, double[] tuple)
          Set the data tuple at ith location.
 void squeeze()
          Resize object to just fit data requirement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

array

protected java.lang.Object array

size

protected int size

maxId

protected int maxId

dimension

protected int dimension

tupleT

protected double[] tupleT
Constructor Detail

DataArray

public DataArray(int dim)
Construct a DataArray object with the specified tuple dimension.
 

Parameters:
dim - the dimension of the tuple.

DataArray

public DataArray(DataArray da)
Method Detail

copy

public void copy(DataArray da)

allocate

public abstract boolean allocate(int size)

initialize

public void initialize()
Release storage and reset array to initial state.


makeObject

public abstract DataArray makeObject()
Virtual constructor creates an object of the same type as this one. The created object also has the same number of components. You are responsible for freeing the object.


getData

public java.lang.Object getData()
Return a array pointer. For image pipeline interface and other special pointer manipulation.


resize

protected abstract java.lang.Object resize(int size)
resize the array.


getDataType

public int getDataType()
Return the underlying data type. An integer indicating data type is returned as specified in DataType class.
 

Returns:
the underlying data type.

squeeze

public void squeeze()
Resize object to just fit data requirement. Reclaims extra memory.


reset

public void reset()
Reset to an empty state, without freeing any memory.


getSize

public int getSize()
Return the size of the data.


getMaxId

public int getMaxId()
What is the maximum id currently in the array.


ensureSpace

public java.lang.Object ensureSpace(int id,
                                    int number)
ensures data is allocated from the location id for the number of items requested. Set maxId according to the number of data values requested.


getElement

public double getElement(int i,
                         int j)
                  throws java.lang.ArrayIndexOutOfBoundsException
Return the data element at the ith tuple and jth element location. Note that i is less than number of tuples and j is less than the dimension. This method can be overridden for more efficiency.
 

Parameters:
i - the index to the ith tuple.
j - the index to the jth element of the tuple.
Returns:
element.
Throws:
java.lang.ArrayIndexOutOfBoundsException

setElement

public void setElement(int i,
                       int j,
                       double e)
                throws java.lang.ArrayIndexOutOfBoundsException
Set the data element at the ith tuple and jth element location. Note that i is less than number of tuples and j is less than the dimension.
 

Parameters:
i - the index to the ith tuple.
j - the index to the jth element of the tuple.
e - the element to be set.
Returns:
void
Throws:
java.lang.ArrayIndexOutOfBoundsException

insertElement

public void insertElement(int i,
                          int j,
                          double e)
                   throws java.lang.ArrayIndexOutOfBoundsException
Insert the data element at ith tuple and jth element location.
 

Returns:
void
Throws:
java.lang.ArrayIndexOutOfBoundsException

setDimension

public void setDimension(int dim)
Set the dimension (n). Must be >= 1.


getDimension

public int getDimension()
Get the dimension (n) of the elements.


getData

public void getData(int tupleMin,
                    int tupleMax,
                    int eleMin,
                    int eleMax,
                    DataArray data)
Get the data as a double array in the range (tupleMin,tupleMax) and (compMin, compMax). The resulting float array consists of all data in the tuple range specified and only the element range specified. This process typically requires casting the data from native form into floating point values. This method is provided as a convenience for data exchange, and is not very fast.
 

Parameters:
tupleMin -
tupleMax -
eleMin -
eleMax -
Returns:
void

getTuple

public abstract void getTuple(int i,
                              double[] tuple)
Get the data tuple at ith location by filling in a user-provided array. Make sure that your array is large enough to hold number of elements being returned.
 

Parameters:
i -
tuple -
Returns:
void

setTuple

public abstract void setTuple(int i,
                              double[] tuple)
Set the data tuple at ith location. Note that range checking is not performed; use this method in conjunction with setNumberOfTuples() to allocate space.
 

Parameters:
i -
tuple -
Returns:
void

insertTuple

public abstract void insertTuple(int i,
                                 double[] tuple)
Insert the data tuple at ith location. Note that memory allocation is performed as necessary to hold the data.
 

Parameters:
i -
tuple -
Returns:
void

insertNextTuple

public abstract int insertNextTuple(double[] tuple)
Insert the data tuple at the end of the array and return the location at which the data was inserted. Memory is allocated as necessary to hold the data.
 

Parameters:
tuple -
Returns:
the location at which the data was inserted.

setNumberOfTuples

public abstract void setNumberOfTuples(int number)
Set the number of tuples (a element group) in the array. Note that this may allocate space depending on the number of elements.
 

Parameters:
number - the number of tuples.
Returns:
void

getNumberOfTuples

public int getNumberOfTuples()
Get the number of tuples (a element group) in the array.
 

Returns:
the number of tuples.

getTuple

public abstract double[] getTuple(int i)
Get the data tuple at ith location. Return it as an array.
 

Parameters:
i - the index of the ith tuple.
Returns:
an array containing tuple.


Copyright © 1995-2004 net.jbeans. All Rights Reserved.