ncsa.hdf.object
Class ScalarDS

java.lang.Object
  extended byncsa.hdf.object.HObject
      extended byncsa.hdf.object.Dataset
          extended byncsa.hdf.object.ScalarDS
All Implemented Interfaces:
DataFormat, java.io.Serializable
Direct Known Subclasses:
H4GRImage, H4SDS, H5ScalarDS

public abstract class ScalarDS
extends Dataset

A scalar dataset is a multiple dimension array of scalar points. Datatype of a scalar dataset must be a atomic datatype. Most common datatypes of a scalar dataset include char, byte, short, int, long, float, double and string.

A ScalarDS can be an image or spreadsheet data. ScalarDS defines few methods to deal with both image and spreadsheet.

ScalarDS is an abstract class. Current implementing classes are the H4SDS, H5GRImage and H5ScalarDS.

How to Select a Subset

Dataset defines APIs for read, write and subet a dataset. No function is defined to select a subset of a data array. The selection is done in an implicit way. Function calls to dimension information such as getSelectedDims() return an array of dimension values, which is a reference to the array in the dataset object. Changes of the array outside the dataset object directly change the values of the array in the dataset object. It is like pointers in C.

The following is an example of how to make a subset. In the example, the dataset is a 4-dimension with size of [200][100][50][10], i.e. dims[0]=200; dims[1]=100; dims[2]=50; dims[3]=10;
We want to select every other data points in dims[1] and dims[2]

     int rank = dataset.getRank();   // number of dimension of the dataset
     long[] dims = dataset.getDims(); // the dimension sizes of the dataset
     long[] selected = dataset.getSelectedDims(); // the selected size of the dataet
     long[] start = dataset.getStartDims(); // the off set of the selection
     long[] stride = dataset.getStride(); // the stride of the dataset
     int[]  selectedIndex = dataset.getSelectedIndex(); // the selected dimensions for display

     // select dim1 and dim2 as 2D data for display,and slice through dim0
     selectedIndex[0] = 1;
     selectedIndex[1] = 2;
     selectedIndex[1] = 0;

     // reset the selection arrays
     for (int i=0; i

 

See Also:
Serialized Form

Field Summary
protected  double[] imageDataRange
           
protected  int interlace
          The interlace mode of the stored raster image data
static int INTERLACE_LINE
          Each component is stored as a scan line.
static int INTERLACE_PIXEL
          The component value for a pixel are contiguous.
static int INTERLACE_PLANE
          Each component is stored as a plane.
protected  boolean isImage
          True if this dataset is an image.
protected  boolean isText
          True if this dataset is ASCII text.
protected  boolean isTrueColor
          True if this dataset is a true color image.
protected  boolean isUnsigned
          Flag to indicate if the original C data is unsigned integer.
protected  int nativeDatatype
          The data type of this scalar dataset such as 32-bit integer, 32-bit float, etc.
protected  byte[][] palette
          The indexed RGB color model with 256 colors.
protected  boolean unsignedConverted
          Flag to indicate is the original unsigned C data is converted.
 
Fields inherited from class ncsa.hdf.object.Dataset
chunkSize, compression, data, datatype, dimNames, dims, H5Z_FILTER_CONFIG_DECODE_ENABLED, H5Z_FILTER_CONFIG_ENCODE_ENABLED, rank, selectedDims, selectedIndex, selectedStride, startDims
 
Fields inherited from class ncsa.hdf.object.HObject
hasAttribute, oid, separator
 
Constructor Summary
ScalarDS(FileFormat fileFormat, java.lang.String name, java.lang.String path)
           
ScalarDS(FileFormat fileFormat, java.lang.String name, java.lang.String path, long[] oid)
          Creates a ScalarDS object with specific name, path, and parent.
 
Method Summary
 void clearData()
          Removes the data value of this dataset in memory.
 void convertFromUnsignedC()
           
 void convertToUnsignedC()
           
 double[] getImageDataRange()
           
 int getInterlace()
          Returns the interlace of data points.
 int getNativeDataType()
          Returns the type of this scalar dataset.
abstract  byte[][] getPalette()
          Returns the palette of this scalar dataset or null if palette does not exist.
abstract  byte[] getPaletteRefs()
          returns the byte array of palette refs.
 boolean isImage()
          Returns true if this dataset is an image.
 boolean isText()
          Returns true if this dataset is ASCII text.
 boolean isTrueColor()
          Returns true if this dataset is a true color image.
 boolean isUnsigned()
          Returns true if the original C data is unsigned integer.
abstract  byte[][] readPalette(int idx)
          read specific image palette from file.
 void setPalette(byte[][] pal)
          Sets the palette for this dataset.
 
Methods inherited from class ncsa.hdf.object.Dataset
byteToString, convertFromUnsignedC, convertToUnsignedC, copy, getChunkSize, getCompression, getData, getDatatype, getDimNames, getDims, getHeight, getRank, getSelectedDims, getSelectedIndex, getStartDims, getStride, getWidth, init, read, readBytes, setData, stringToByte, write, write
 
Methods inherited from class ncsa.hdf.object.HObject
close, equalsOID, getFID, getFile, getFileFormat, getName, getOID, getPath, hasAttribute, open, setName, setPath, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ncsa.hdf.object.DataFormat
getMetadata, removeMetadata, writeMetadata
 

Field Detail

INTERLACE_PIXEL

public static final int INTERLACE_PIXEL
The component value for a pixel are contiguous.

See Also:
Constant Field Values

INTERLACE_LINE

public static final int INTERLACE_LINE
Each component is stored as a scan line.

See Also:
Constant Field Values

INTERLACE_PLANE

public static final int INTERLACE_PLANE
Each component is stored as a plane.

See Also:
Constant Field Values

nativeDatatype

protected int nativeDatatype
The data type of this scalar dataset such as 32-bit integer, 32-bit float, etc.


interlace

protected int interlace
The interlace mode of the stored raster image data


imageDataRange

protected double[] imageDataRange

palette

protected byte[][] palette
The indexed RGB color model with 256 colors.

The palette values are stored in a two-dimensional byte array and arrange by color components of red, green and blue. palette[][] = byte[3][256], where, palette[0][], palette[1][] and palette[2][] are the red, green and blue components respectively.


isImage

protected boolean isImage
True if this dataset is an image.


isTrueColor

protected boolean isTrueColor
True if this dataset is a true color image.


isText

protected boolean isText
True if this dataset is ASCII text.


isUnsigned

protected boolean isUnsigned
Flag to indicate if the original C data is unsigned integer.


unsignedConverted

protected boolean unsignedConverted
Flag to indicate is the original unsigned C data is converted.

Constructor Detail

ScalarDS

public ScalarDS(FileFormat fileFormat,
                java.lang.String name,
                java.lang.String path)

ScalarDS

public ScalarDS(FileFormat fileFormat,
                java.lang.String name,
                java.lang.String path,
                long[] oid)
Creates a ScalarDS object with specific name, path, and parent.

Parameters:
fileFormat - the HDF file.
name - the name of this ScalarDS.
path - the full path of this ScalarDS.
oid - the unique identifier of this data object.
Method Detail

getNativeDataType

public final int getNativeDataType()
Returns the type of this scalar dataset.


clearData

public void clearData()
Removes the data value of this dataset in memory.

Overrides:
clearData in class Dataset

convertFromUnsignedC

public void convertFromUnsignedC()

convertToUnsignedC

public void convertToUnsignedC()

getPalette

public abstract byte[][] getPalette()
Returns the palette of this scalar dataset or null if palette does not exist.

Scalar dataset can be displayed as spreadsheet data or image. When a scalar dataset is chosen to display as an image, the palette or color table may be needed to translate a pixel value to color components (for example, red, green, and blue). Some scalar datasets have no palette and some datasets have one or more than one palettes. If an associated palette exists but not loaded, this interface retrieves the palette from the file and returns the palette. If the palette is loaded, it returnd the palette. It returns null if there is no palette assciated with the dataset.

Current implementation only supports palette model of indexed RGB with 256 colors. Other models such as YUV", "CMY", "CMYK", "YCbCr", "HSV will be supported in the future.

The palette values are stored in a two-dimensional byte array and arrange by color components of red, green and blue. palette[][] = byte[3][256], where, palette[0][], palette[1][] and palette[2][] are the red, green and blue components respectively.

Sub-classes have to implement this interface. HDF4 and HDF5 images use different library to retrieve the associated palette.


setPalette

public final void setPalette(byte[][] pal)
Sets the palette for this dataset.


readPalette

public abstract byte[][] readPalette(int idx)
read specific image palette from file.

Parameters:
idx - the palette index to read.

getPaletteRefs

public abstract byte[] getPaletteRefs()
returns the byte array of palette refs. returns null if there is no palette attribute attached to this dataset.


isImage

public final boolean isImage()
Returns true if this dataset is an image.


isTrueColor

public final boolean isTrueColor()
Returns true if this dataset is a true color image.


isText

public final boolean isText()
Returns true if this dataset is ASCII text.


getInterlace

public final int getInterlace()
Returns the interlace of data points.


isUnsigned

public final boolean isUnsigned()
Returns true if the original C data is unsigned integer.


getImageDataRange

public double[] getImageDataRange()