visad.data.bio
Class LociForm

java.lang.Object
  extended by visad.data.FormNode
      extended by visad.data.Form
          extended by visad.data.bio.LociForm
All Implemented Interfaces:
FormBlockReader, FormFileInformer, FormProgressInformer, MetadataReader
Direct Known Subclasses:
AVIForm, BioRadForm, DeltavisionForm, FluoviewTiffForm, GatanForm, ICSForm, ImageProSeqForm, IPLabForm, IPWForm, LegacyZVIForm, LeicaForm, MetamorphForm, OpenlabForm, PerkinElmerForm, PictForm, QTForm, TiffForm, ZeissForm, ZVIForm

public class LociForm
extends Form
implements FormBlockReader, FormFileInformer, FormProgressInformer, MetadataReader

LociForm is the VisAD data adapter for images handled by the Bio-Formats package (loci.formats). It works by wrapping a loci.formats.IFormatReader and/or loci.formats.IFormatWriter object.


Field Summary
protected  double percent
          Percent complete for current operation.
protected  loci.formats.IFormatReader reader
          Reader to use for open-related functions.
protected  FileFilter[] rFilters
          File filters for reader formats.
protected  FileFilter[] wFilters
          File filters for writer formats.
protected  loci.formats.IFormatWriter writer
          Writer to use for save-related functions.
 
Fields inherited from class visad.data.Form
mathType
 
Constructor Summary
LociForm()
          Constructs a new LociForm that handles anything from loci.formats.
LociForm(loci.formats.IFormatReader reader)
          Constructs a new LociForm that handles the given reader.
LociForm(loci.formats.IFormatReader reader, loci.formats.IFormatWriter writer)
          Constructs a new LociForm that handles the given reader/writer pair.
LociForm(loci.formats.IFormatWriter writer)
          Constructs a new LociForm that handles the given writer.
 
Method Summary
 void add(String id, Data data, boolean replace)
          Adds data to an existing image file.
 void close()
          Closes any open files.
 int getBlockCount(String id)
          Determines the number of images in the given image file.
 String[] getDefaultSuffixes()
          Returns the default file suffixes for this file format.
 FormNode getForms(Data data)
          Returns the data forms that are compatible with a data object.
 Hashtable getMetadata(String id)
          Obtains the hashtable containing the metadata field/value pairs from the given image file.
 Object getMetadataValue(String id, String field)
          Obtains the specified metadata field's value for the given file.
 double getPercentComplete()
          Gets the percentage complete of the form's current operation.
 loci.formats.IFormatReader getReader()
          Gets the IFormatReader backing this form's reading capabilities.
 FileFilter[] getReaderFilters()
          Gets file filters for use with formats supported for reading.
 loci.formats.IFormatWriter getWriter()
          Gets the IFormatWriter backing this form's writing capabilities.
 FileFilter[] getWriterFilters()
          Gets file filters for use with formats supported for writing.
 void initHandler(loci.formats.IFormatHandler h, String id)
           
 boolean isThisType(byte[] block)
          Checks if the given block is a valid header for an image file.
 boolean isThisType(String name)
          Checks if the given string is a valid filename for an image file.
static void main(String[] args)
           
 DataImpl open(String id)
          Opens an existing image file from the given filename.
 DataImpl open(String id, int block_number)
          Obtains the specified image from the given image file.
 DataImpl open(URL url)
          Opens an existing image file from the given URL.
 void save(String id, Data data, boolean replace)
          Saves a VisAD Data object at the given location.
 void setFrameRate(int fps)
          Sets the frames per second to use when writing files.
 void testRead(String[] args)
          A utility method for test reading a file from the command line, and displaying the results in a simple display.
 
Methods inherited from class visad.data.Form
getMathType
 
Methods inherited from class visad.data.FormNode
getName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

reader

protected loci.formats.IFormatReader reader
Reader to use for open-related functions.


writer

protected loci.formats.IFormatWriter writer
Writer to use for save-related functions.


percent

protected double percent
Percent complete for current operation.


rFilters

protected FileFilter[] rFilters
File filters for reader formats.


wFilters

protected FileFilter[] wFilters
File filters for writer formats.

Constructor Detail

LociForm

public LociForm()
Constructs a new LociForm that handles anything from loci.formats.


LociForm

public LociForm(loci.formats.IFormatReader reader)
Constructs a new LociForm that handles the given reader.


LociForm

public LociForm(loci.formats.IFormatWriter writer)
Constructs a new LociForm that handles the given writer.


LociForm

public LociForm(loci.formats.IFormatReader reader,
                loci.formats.IFormatWriter writer)
Constructs a new LociForm that handles the given reader/writer pair.

Method Detail

getReader

public loci.formats.IFormatReader getReader()
Gets the IFormatReader backing this form's reading capabilities.


getWriter

public loci.formats.IFormatWriter getWriter()
Gets the IFormatWriter backing this form's writing capabilities.


setFrameRate

public void setFrameRate(int fps)
Sets the frames per second to use when writing files.


testRead

public void testRead(String[] args)
              throws VisADException,
                     IOException
A utility method for test reading a file from the command line, and displaying the results in a simple display.

Throws:
VisADException
IOException

getReaderFilters

public FileFilter[] getReaderFilters()
Gets file filters for use with formats supported for reading.


getWriterFilters

public FileFilter[] getWriterFilters()
Gets file filters for use with formats supported for writing.


open

public DataImpl open(String id)
              throws BadFormException,
                     IOException,
                     VisADException
Opens an existing image file from the given filename.

Specified by:
open in class FormNode
Returns:
VisAD Data object containing image data
Throws:
BadFormException
IOException
VisADException

save

public void save(String id,
                 Data data,
                 boolean replace)
          throws BadFormException,
                 IOException,
                 RemoteException,
                 VisADException
Saves a VisAD Data object at the given location.

Specified by:
save in class FormNode
Throws:
BadFormException
IOException
RemoteException
VisADException

add

public void add(String id,
                Data data,
                boolean replace)
         throws BadFormException
Adds data to an existing image file.

Specified by:
add in class FormNode
Throws:
BadFormException - Always thrown (this method not implemented).

open

public DataImpl open(URL url)
              throws BadFormException,
                     IOException,
                     VisADException
Opens an existing image file from the given URL.

Specified by:
open in class FormNode
Returns:
VisAD data object containing image data
Throws:
UnimplementedException - Always thrown (this method not implemented).
BadFormException
IOException
VisADException

getForms

public FormNode getForms(Data data)
Returns the data forms that are compatible with a data object.

Specified by:
getForms in class FormNode

open

public DataImpl open(String id,
                     int block_number)
              throws BadFormException,
                     IOException,
                     VisADException
Obtains the specified image from the given image file.

Specified by:
open in interface FormBlockReader
Parameters:
id - The file from which to load data blocks.
block_number - The block number of the block to load.
Throws:
VisADException - If the block number is invalid.
BadFormException
IOException

getBlockCount

public int getBlockCount(String id)
                  throws BadFormException,
                         IOException,
                         VisADException
Determines the number of images in the given image file.

Specified by:
getBlockCount in interface FormBlockReader
Parameters:
id - The file for which to get a block count.
Throws:
BadFormException
IOException
VisADException

close

public void close()
           throws BadFormException,
                  IOException,
                  VisADException
Closes any open files.

Specified by:
close in interface FormBlockReader
Throws:
BadFormException
IOException
VisADException

isThisType

public boolean isThisType(String name)
Checks if the given string is a valid filename for an image file.

Specified by:
isThisType in interface FormFileInformer
Parameters:
name - name of the file
Returns:
true if the name is right for this type of form

isThisType

public boolean isThisType(byte[] block)
Checks if the given block is a valid header for an image file.

Specified by:
isThisType in interface FormFileInformer
Parameters:
block - block of bytes from file
Returns:
true if the magic number is right

getDefaultSuffixes

public String[] getDefaultSuffixes()
Returns the default file suffixes for this file format.

Specified by:
getDefaultSuffixes in interface FormFileInformer
Returns:
array of suffixes

getPercentComplete

public double getPercentComplete()
Gets the percentage complete of the form's current operation.

Specified by:
getPercentComplete in interface FormProgressInformer
Returns:
The percentage complete (0.0 - 100.0), or Double.NaN if no operation is currently taking place.

getMetadataValue

public Object getMetadataValue(String id,
                               String field)
                        throws BadFormException,
                               IOException,
                               VisADException
Obtains the specified metadata field's value for the given file.

Specified by:
getMetadataValue in interface MetadataReader
Parameters:
field - the name associated with the metadata field
Returns:
the value, or null if the field doesn't exist
Throws:
BadFormException
IOException
VisADException

getMetadata

public Hashtable getMetadata(String id)
                      throws BadFormException,
                             IOException,
                             VisADException
Obtains the hashtable containing the metadata field/value pairs from the given image file.

Specified by:
getMetadata in interface MetadataReader
Parameters:
id - the filename
Returns:
the hashtable containing all metadata from the file
Throws:
BadFormException
IOException
VisADException

main

public static void main(String[] args)
                 throws Exception
Throws:
Exception

initHandler

public void initHandler(loci.formats.IFormatHandler h,
                        String id)
                 throws BadFormException,
                        IOException
Throws:
BadFormException
IOException