loci.formats
Class FormatTools

java.lang.Object
  extended by loci.formats.FormatTools

public final class FormatTools
extends Object

A utility class for format reader and writer implementations.

Source code:
Trac, SVN


Field Summary
static int CAN_GROUP
           
static int CANNOT_GROUP
           
static String CHANNEL
          Identifies the Channel dimensional type, representing a generic channel dimension.
static int DOUBLE
          Identifies the DOUBLE data type used to store pixel values.
static int FLOAT
          Identifies the FLOAT data type used to store pixel values.
static int INT16
          Identifies the INT16 data type used to store pixel values.
static int INT32
          Identifies the INT32 data type used to store pixel values.
static int INT8
          Identifies the INT8 data type used to store pixel values.
static String LIFETIME
          Identifies the Lifetime dimensional type, representing a dimension consisting of a lifetime histogram.
static int MUST_GROUP
          File grouping options.
static String POLARIZATION
          Identifies the Polarization dimensional type, representing a dimension consisting of polarization states.
static String SPECTRA
          Identifies the Spectra dimensional type, representing a dimension consisting of spectral channels.
static int UINT16
          Identifies the UINT16 data type used to store pixel values.
static int UINT32
          Identifies the UINT32 data type used to store pixel values.
static int UINT8
          Identifies the UINT8 data type used to store pixel values.
 
Method Summary
static void assertId(String currentId, boolean notNull, int depth)
          Asserts that the current file is either null, or not, according to the given flag.
static void checkBufferSize(IFormatReader r, int len)
           
static void checkPlaneNumber(IFormatReader r, int no)
          Checks that the given plane number is valid for the given reader.
static int getBytesPerPixel(int pixelType)
          Retrieves how many bytes per pixel the current plane or section has.
static int getIndex(IFormatReader reader, int z, int c, int t)
          Gets the rasterized index corresponding to the given Z, C and T coordinates.
static int getIndex(String order, int zSize, int cSize, int tSize, int num, int z, int c, int t)
          Gets the rasterized index corresponding to the given Z, C and T coordinates.
static String getPixelTypeString(int pixelType)
          Takes a pixel type value and gets a corresponding string representation.
static int getRasterLength(int[] lengths)
          Computes the number of raster values for a positional array with the given lengths.
static int getReorderedIndex(IFormatReader r, String order, int no)
          Converts indices from the given dimension order to the native one.
static int[] getZCTCoords(IFormatReader reader, int index)
          Gets the Z, C and T coordinates corresponding to the given rasterized index value.
static int[] getZCTCoords(String order, int zSize, int cSize, int tSize, int num, int index)
          Gets the Z, C and T coordinates corresponding to the given rasterized index value.
static int pixelTypeFromString(String pixelTypeAsString)
          Takes a string value and maps it to one of the pixel type enumerations.
static void populatePixels(MetadataStore store, IFormatReader r)
          Populates the 'pixels' element of the given metadata store, using core metadata from the given reader.
static int positionToRaster(int[] lengths, int[] pos)
          Computes a unique 1-D index corresponding to the given multidimensional position.
static int[] rasterToPosition(int[] lengths, int raster)
          Computes a unique N-D position corresponding to the given rasterized index value.
static int[] rasterToPosition(int[] lengths, int raster, int[] pos)
          Computes a unique N-D position corresponding to the given rasterized index value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INT8

public static final int INT8
Identifies the INT8 data type used to store pixel values.

See Also:
Constant Field Values

UINT8

public static final int UINT8
Identifies the UINT8 data type used to store pixel values.

See Also:
Constant Field Values

INT16

public static final int INT16
Identifies the INT16 data type used to store pixel values.

See Also:
Constant Field Values

UINT16

public static final int UINT16
Identifies the UINT16 data type used to store pixel values.

See Also:
Constant Field Values

INT32

public static final int INT32
Identifies the INT32 data type used to store pixel values.

See Also:
Constant Field Values

UINT32

public static final int UINT32
Identifies the UINT32 data type used to store pixel values.

See Also:
Constant Field Values

FLOAT

public static final int FLOAT
Identifies the FLOAT data type used to store pixel values.

See Also:
Constant Field Values

DOUBLE

public static final int DOUBLE
Identifies the DOUBLE data type used to store pixel values.

See Also:
Constant Field Values

CHANNEL

public static final String CHANNEL
Identifies the Channel dimensional type, representing a generic channel dimension.

See Also:
Constant Field Values

SPECTRA

public static final String SPECTRA
Identifies the Spectra dimensional type, representing a dimension consisting of spectral channels.

See Also:
Constant Field Values

LIFETIME

public static final String LIFETIME
Identifies the Lifetime dimensional type, representing a dimension consisting of a lifetime histogram.

See Also:
Constant Field Values

POLARIZATION

public static final String POLARIZATION
Identifies the Polarization dimensional type, representing a dimension consisting of polarization states.

See Also:
Constant Field Values

MUST_GROUP

public static final int MUST_GROUP
File grouping options.

See Also:
Constant Field Values

CAN_GROUP

public static final int CAN_GROUP
See Also:
Constant Field Values

CANNOT_GROUP

public static final int CANNOT_GROUP
See Also:
Constant Field Values
Method Detail

getIndex

public static int getIndex(IFormatReader reader,
                           int z,
                           int c,
                           int t)
Gets the rasterized index corresponding to the given Z, C and T coordinates.


getIndex

public static int getIndex(String order,
                           int zSize,
                           int cSize,
                           int tSize,
                           int num,
                           int z,
                           int c,
                           int t)
Gets the rasterized index corresponding to the given Z, C and T coordinates.


getZCTCoords

public static int[] getZCTCoords(IFormatReader reader,
                                 int index)
Gets the Z, C and T coordinates corresponding to the given rasterized index value.


getZCTCoords

public static int[] getZCTCoords(String order,
                                 int zSize,
                                 int cSize,
                                 int tSize,
                                 int num,
                                 int index)
Gets the Z, C and T coordinates corresponding to the given rasterized index value.


getReorderedIndex

public static int getReorderedIndex(IFormatReader r,
                                    String order,
                                    int no)
                             throws FormatException
Converts indices from the given dimension order to the native one.

Throws:
FormatException

positionToRaster

public static int positionToRaster(int[] lengths,
                                   int[] pos)
Computes a unique 1-D index corresponding to the given multidimensional position.

Parameters:
lengths - the maximum value for each positional dimension
pos - position along each dimensional axis
Returns:
rasterized index value

rasterToPosition

public static int[] rasterToPosition(int[] lengths,
                                     int raster)
Computes a unique N-D position corresponding to the given rasterized index value.

Parameters:
lengths - the maximum value at each positional dimension
raster - rasterized index value
Returns:
position along each dimensional axis

rasterToPosition

public static int[] rasterToPosition(int[] lengths,
                                     int raster,
                                     int[] pos)
Computes a unique N-D position corresponding to the given rasterized index value.

Parameters:
lengths - the maximum value at each positional dimension
raster - rasterized index value
pos - preallocated position array to populate with the result
Returns:
position along each dimensional axis

getRasterLength

public static int getRasterLength(int[] lengths)
Computes the number of raster values for a positional array with the given lengths.


pixelTypeFromString

public static int pixelTypeFromString(String pixelTypeAsString)
Takes a string value and maps it to one of the pixel type enumerations.

Parameters:
pixelTypeAsString - the pixel type as a string.
Returns:
type enumeration value for use with class constants.

getPixelTypeString

public static String getPixelTypeString(int pixelType)
Takes a pixel type value and gets a corresponding string representation.

Parameters:
pixelType - the pixel type.
Returns:
string value for human-readable output.

getBytesPerPixel

public static int getBytesPerPixel(int pixelType)
Retrieves how many bytes per pixel the current plane or section has.

Parameters:
pixelType - the pixel type as retrieved from IFormatReader.getPixelType().
Returns:
the number of bytes per pixel.
See Also:
IFormatReader.getPixelType(String)

populatePixels

public static void populatePixels(MetadataStore store,
                                  IFormatReader r)
Populates the 'pixels' element of the given metadata store, using core metadata from the given reader.


assertId

public static void assertId(String currentId,
                            boolean notNull,
                            int depth)
Asserts that the current file is either null, or not, according to the given flag. If the assertion fails, an IllegalStateException is thrown.

Parameters:
currentId - File name to test.
notNull - True iff id should be non-null.
depth - How far back in the stack the calling method is; this name is reported as part of the exception message, if available. Use zero to suppress output of the calling method name.

checkPlaneNumber

public static void checkPlaneNumber(IFormatReader r,
                                    int no)
                             throws FormatException
Checks that the given plane number is valid for the given reader.

Throws:
FormatException

checkBufferSize

public static void checkBufferSize(IFormatReader r,
                                   int len)
                            throws FormatException
Throws:
FormatException