gov.nih.mipav.model.file
Class FileHistoLUT

java.lang.Object
  extended by gov.nih.mipav.model.file.FileBase
      extended by gov.nih.mipav.model.file.FileHistoLUT

public class FileHistoLUT
extends FileBase

HistoLUT reader/writer. This classes incorporates the ability to write/read ModelLUT and ModelRGB information in two ways. The first saves the LUT arrays (not available with ModelRGB), and the second saves the transfer and RGB functions. The LUT transfer Line is saved by default (and likewise opened) when the saveLUT method is called.

NOTE: Reading a LUT does not return a ModelLUT. Rather, it updates the arrays and transfer functions in a provided ModelLUT.

Version:
May 14, 2002
Author:
Lynne M. Pusanik
See Also:
ModelLUT, ModelRGB, ViewJFrameHistoLUT, ViewJFrameHistoRGB

Field Summary
 
Fields inherited from class gov.nih.mipav.model.file.FileBase
BIG_ENDIAN, bitsPerPixel, fileNames, LITTLE_ENDIAN, pBarVisible, raFile, READ, READ_WRITE
 
Constructor Summary
FileHistoLUT(String fileName, String fileDir)
          LUT reader/writer constructor.
FileHistoLUT(String fileName, String fileDir, ModelLUT lut)
          LUT reader/writer constructor.
FileHistoLUT(String fileName, String fileDir, ModelRGB rgb)
          RGB reader/writer constructor.
 
Method Summary
 void readFunctions()
          This method reads the transfer and RGB functions associated with a LUT.
 void readFunctions(ModelLUT lut)
          This method reads the transfer and RGB functions associated with a LUT.
 void readFunctions(ModelRGB rgb)
          This method reads the transfer and RGB functions associated with a ModelRGB.
 void readLUT(boolean quietMode)
          This method reads a LUT file and its associated transfer function.
 void readLUT(ModelLUT lut, boolean quietMode)
          This method reads a LUT file and its associated transfer function.
 void readOnlyLUT(boolean quietMode)
          This method reads a LUT file and its associated transfer function.
 void readOnlyLUT(ModelLUT lut, boolean quietMode)
          This method reads a LUT file and its associated transfer function.
 void readOpacityFunctions(ModelLUT _lut)
          This method reads the transfer and RGB functions associated with a LUT.
 void readTransferFunction(RandomAccessFile file, TransferFunction funct)
          Reads in a transfer function from a file.
 void readUDTransferFunction(String fName, String dName)
          Reads a transfer function (0->1) remaps to min->max and loads into LUT.
 void setLUT(ModelLUT lut)
          Accessor to set the LUT.
 void setOpacityFunction(TransferFunction opacFunction)
          Sets the opacity function, which indicates that we want it to be saved / read in with the rest of the transfer functions.
 void setRGB(ModelRGB rgb)
          Accessor to set the RGB.
 void write()
          Writes the default ModelLUT or ModelRGB to a file.
 void writeAll()
          Writes the default ModelLUT or ModelRGB to a file.
 void writeFunctions()
          Writes the transfer and RGB functions to a file.
 void writeLUT()
          Writes the default ModelLUT or ModelRGB to a file.
 void writeLUT(ModelLUT lut)
          Writes a ModelLUT to a file.
 void writeOpacityFunctions()
          Writes the transfer and RGB functions to a file.
 void writeTransferFunction(RandomAccessFile file, TransferFunction funct, String name)
          Write out a transfer function to a file.
 void writeUDTransferFunction(String fName, String dName)
          Remaps the transfer function from 0->1 and writes to a files.
 
Methods inherited from class gov.nih.mipav.model.file.FileBase
addProgressChangeListener, bytesToFloat, bytesToInt, bytesToShort, finalize, fireProgressStateChanged, fireProgressStateChanged, fireProgressStateChanged, floatToBytes, getBitsPerPixel, getBufferFloat, getBufferInt, getBufferShort, getDataType, getDouble, getFloat, getInt, getLong, getProgressChangeListeners, getRaFile, getSignedShort, getString, getUInt, getUnsignedByte, getUnsignedShort, intToBytes, isBigEndian, isProgressBarVisible, linkProgress, longToBytes, readDouble, readFloat, readInt, readLong, readShort, readString, readUnsignedShort, removeProgressChangeListener, setBigEndian, setBufferFloat, setBufferInt, setBufferLong, setBufferShort, setBufferString, setDataType, setEndianess, shortToBytes, stringToBytes, writeDouble, writeFloat, writeInt, writeLong, writeShort
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileHistoLUT

public FileHistoLUT(String fileName,
                    String fileDir)
             throws IOException
LUT reader/writer constructor.

Parameters:
fileName - file name
fileDir - file directory
Throws:
IOException - if there is an error making the files

FileHistoLUT

public FileHistoLUT(String fileName,
                    String fileDir,
                    ModelLUT lut)
             throws IOException
LUT reader/writer constructor.

Parameters:
fileName - file name
fileDir - file directory
lut - the ModelLUT
Throws:
IOException - if there is an error making the files, or if lut is null

FileHistoLUT

public FileHistoLUT(String fileName,
                    String fileDir,
                    ModelRGB rgb)
             throws IOException
RGB reader/writer constructor.

Parameters:
fileName - file name
fileDir - file directory
rgb - the ModelRGB
Throws:
IOException - if there is an error making the files, or if rgb is null
Method Detail

readFunctions

public void readFunctions()
                   throws IOException
This method reads the transfer and RGB functions associated with a LUT.

Throws:
IOException - if there is an error reading the file

readFunctions

public void readFunctions(ModelLUT lut)
                   throws IOException
This method reads the transfer and RGB functions associated with a LUT.

Parameters:
lut - The ModelLUT that these functions are read to
Throws:
IOException - if there is an error reading the file

readFunctions

public void readFunctions(ModelRGB rgb)
                   throws IOException
This method reads the transfer and RGB functions associated with a ModelRGB.

Parameters:
rgb - The ModelRGB that these functions are read to
Throws:
IOException - if there is an error reading the file

readLUT

public void readLUT(boolean quietMode)
             throws IOException
This method reads a LUT file and its associated transfer function.

Parameters:
quietMode - if true indicates that warnings should not be displayed.
Throws:
IOException - if there is an error reading the file

readLUT

public void readLUT(ModelLUT lut,
                    boolean quietMode)
             throws IOException
This method reads a LUT file and its associated transfer function.

Parameters:
lut - The ModelLUT that the LUT data gets applied to
quietMode - if true indicates that warnings should not be displayed.
Throws:
IOException - if there is an error reading the file

readOnlyLUT

public void readOnlyLUT(boolean quietMode)
                 throws IOException
This method reads a LUT file and its associated transfer function.

Parameters:
quietMode - if true indicates that warnings should not be displayed.
Throws:
IOException - if there is an error reading the file

readOnlyLUT

public void readOnlyLUT(ModelLUT lut,
                        boolean quietMode)
                 throws IOException
This method reads a LUT file and its associated transfer function.

Parameters:
lut - The ModelLUT that the LUT data gets applied to
quietMode - if true indicates that warnings should not be displayed.
Throws:
IOException - if there is an error reading the file

readOpacityFunctions

public void readOpacityFunctions(ModelLUT _lut)
                          throws IOException
This method reads the transfer and RGB functions associated with a LUT.

Parameters:
_lut - The ModelLUT that these functions are read to
Throws:
IOException - if there is an error reading the file

readTransferFunction

public void readTransferFunction(RandomAccessFile file,
                                 TransferFunction funct)
                          throws IOException
Reads in a transfer function from a file.

Parameters:
file - the file to read from
funct - the function to add points to
Throws:
IOException - if there is a problem reading from the file

readUDTransferFunction

public void readUDTransferFunction(String fName,
                                   String dName)
                            throws IOException
Reads a transfer function (0->1) remaps to min->max and loads into LUT.

Parameters:
fName - String file name
dName - String dir name
Throws:
IOException - DOCUMENT ME!

setLUT

public void setLUT(ModelLUT lut)
            throws IOException
Accessor to set the LUT.

Parameters:
lut - the ModelLUT
Throws:
IOException - if lut is null

setOpacityFunction

public void setOpacityFunction(TransferFunction opacFunction)
Sets the opacity function, which indicates that we want it to be saved / read in with the rest of the transfer functions.

Parameters:
opacFunction - the (grayscale) opacity function

setRGB

public void setRGB(ModelRGB rgb)
            throws IOException
Accessor to set the RGB.

Parameters:
rgb - the ModelRGB
Throws:
IOException - if rgb is null

write

public void write()
           throws IOException
Writes the default ModelLUT or ModelRGB to a file.

Throws:
IOException - if there is an error writing the file

writeAll

public void writeAll()
              throws IOException
Writes the default ModelLUT or ModelRGB to a file. Also writes the functions for a ModelLUT.

Throws:
IOException - if there is an error writing the file

writeFunctions

public void writeFunctions()
                    throws IOException
Writes the transfer and RGB functions to a file.

Throws:
IOException - if there is an error writing the file

writeLUT

public void writeLUT()
              throws IOException
Writes the default ModelLUT or ModelRGB to a file. Also writes the functions for a ModelLUT.

Throws:
IOException - if there is an error writing the file

writeLUT

public void writeLUT(ModelLUT lut)
              throws IOException
Writes a ModelLUT to a file.

Parameters:
lut - ModelLUT to write
Throws:
IOException - if there is an error writing the file

writeOpacityFunctions

public void writeOpacityFunctions()
                           throws IOException
Writes the transfer and RGB functions to a file.

Throws:
IOException - if there is an error writing the file

writeTransferFunction

public void writeTransferFunction(RandomAccessFile file,
                                  TransferFunction funct,
                                  String name)
                           throws IOException
Write out a transfer function to a file.

Parameters:
file - the file to write the function to
funct - the transfer function
name - the label to apply to the function data
Throws:
IOException - if there is a problem writing out to the file

writeUDTransferFunction

public void writeUDTransferFunction(String fName,
                                    String dName)
                             throws IOException
Remaps the transfer function from 0->1 and writes to a files.

Parameters:
fName - String file name
dName - String dir name
Throws:
IOException - DOCUMENT ME!