IsoSurface Rendering of an AR Representation

rlaramee
Class FileHandler

java.lang.Object
  |
  +--rlaramee.FileHandler

public class FileHandler
extends java.lang.Object

Description The class has the file methods that we use over and over again.

start date Mon 24 Apr 00

Version:
1.0
Author:
Robert S Laramee
See Also:
ASCIItoBinarySortedCube.java

Field Summary
private  java.io.DataInputStream dataInputStream
          added 26 Feb '01, used to read binary floats, ints
private  java.io.DataOutputStream dataOutputStream
           
private  java.io.FileInputStream fileInputStream
           
private  java.io.FileOutputStream fileOutputStream
           
private  java.io.ObjectInputStream objectInputStream
           
private  java.io.ObjectOutputStream objectOutputStream
           
private  java.io.StreamTokenizer streamTokenizer
           
 
Constructor Summary
FileHandler()
          constructor
 
Method Summary
 boolean closeASCIIinputFile()
          This method closes this FileHandler's FileInputStream.
 boolean closeBinaryInputFile()
          This method closes the input file.
 boolean closeBinaryOutputFile()
          This method closes the output file.
 boolean closeSerializedInputFile()
          This method closes the input file.
 boolean closeSerializedOutputFile()
          This method closes the output file.
private  java.lang.String getASCIIdataSet(byte dataSet)
           
private  java.lang.String getASCIIlevel(int level)
          Deprecated. -use the getASCIIresolution() method instead
 java.lang.String getASCIIrepresentation(int representation)
          This method is used when reading AR data files.
private  java.lang.String getASCIIresolution(short resolution)
          The float data sets (MR) are 2^N + 1 while the cube data sets (AR) are 2^N (even)
 java.lang.String getASCIIvariate(byte variate)
          This method is used when reading files of uniform resolution floats, each of which stores 1 variate of a data set
 java.io.DataInputStream getDataInputStream()
           
 java.io.DataOutputStream getDataOutputStream()
           
private  java.lang.String getDirectory(short resolution)
           
 java.io.FileInputStream getFileInputStream()
           
 java.io.FileOutputStream getFileOutputStream()
           
 java.lang.String getInputFileName(byte dataSet, short resolution, byte variate)
          This method is called from the FromFloatToCube object a file name looks like: ../data/res128/headRes128variate1floats.bin for example
 java.lang.String getInputFileName(byte dataSet, short resolution, short representation, boolean binaryFormat)
          This method is called from the BinaryCubesReader object a file name looks like: ../data/res128/headRes128cubes.bin for example
 java.io.ObjectInputStream getObjectInputStream()
           
 java.io.ObjectOutputStream getObjectOutputStream()
           
 java.io.StreamTokenizer getStreamTokenizer()
           
static void main(java.lang.String[] args)
          Used for testing
 boolean openASCIIinputStream(java.lang.String inputFileName)
          This method opens a FileInputStream and initializes the StreamTokenizer.
 boolean openBinaryInputFile(java.lang.String inputFileName)
          This method opens a FileInputStream and a DataInputStream
 boolean openBinaryOutputFile(java.lang.String outputFileName)
          This function opens the file specified by filename
 boolean openInputFile(java.lang.String inputFileName)
          This function opens the file specified by filename
 boolean openOutputFileForSerialization(java.lang.String outputFileName)
          Deprecated. -serialization is too slow, use openBinaryOutputFile() instead
 boolean openSerializedInputStream(java.lang.String inputFileName)
          Deprecated. -serialization is too slow, use openBinaryInputFile() instead
 float readFloat()
           
 boolean resetObjectOutputStream()
          Resets this FileHandler's ObjectOutputStream
 boolean setDataInputStream()
           
 boolean setDataOutputStream()
           
 boolean setFileInputStream(java.io.FileInputStream fip)
           
 boolean setFileOutputStream(java.io.FileOutputStream fop)
           
 boolean setObjectInputStream()
           
 boolean setObjectOutputStream()
           
 boolean setStreamTokenizer()
           
 boolean writeFloat(float f)
           
 boolean writeShort(short s)
           
 boolean writeUsingSerialization(Cube cube)
          Deprecated. -serialization is too slow, write an object in native binary format instead
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

fileInputStream

private java.io.FileInputStream fileInputStream

objectInputStream

private java.io.ObjectInputStream objectInputStream

streamTokenizer

private java.io.StreamTokenizer streamTokenizer

fileOutputStream

private java.io.FileOutputStream fileOutputStream

objectOutputStream

private java.io.ObjectOutputStream objectOutputStream

dataInputStream

private java.io.DataInputStream dataInputStream
added 26 Feb '01, used to read binary floats, ints

dataOutputStream

private java.io.DataOutputStream dataOutputStream
Constructor Detail

FileHandler

public FileHandler()
constructor
Method Detail

getObjectInputStream

public java.io.ObjectInputStream getObjectInputStream()
Returns:
this fileHandler's objectInputStream

setObjectInputStream

public boolean setObjectInputStream()
Returns:
TRUE on success

getObjectOutputStream

public java.io.ObjectOutputStream getObjectOutputStream()
Returns:
this fileHandler's ObjectOutputStream

setObjectOutputStream

public boolean setObjectOutputStream()
Returns:
TRUE on success

getDataInputStream

public java.io.DataInputStream getDataInputStream()
Returns:
this fileHandler's DataIntputStream

setDataInputStream

public boolean setDataInputStream()
Returns:
TRUE on success

getDataOutputStream

public java.io.DataOutputStream getDataOutputStream()
Returns:
this fileHandler's DataOutputStream

setDataOutputStream

public boolean setDataOutputStream()
Returns:
TRUE on success

getFileInputStream

public java.io.FileInputStream getFileInputStream()
Returns:
this FileHandler's inputFileStream

setFileInputStream

public boolean setFileInputStream(java.io.FileInputStream fip)
Parameters:
fip - a FileInputStream object
Returns:
TRUE if set() was successful

getFileOutputStream

public java.io.FileOutputStream getFileOutputStream()
Returns:
this FileHandler's fileOutputStream

setFileOutputStream

public boolean setFileOutputStream(java.io.FileOutputStream fop)
Parameters:
fop - a fileOutputStreamObject
Returns:
TRUE if set() was successful

getStreamTokenizer

public java.io.StreamTokenizer getStreamTokenizer()
Returns:
this fileHandler's streamTokenizer

setStreamTokenizer

public boolean setStreamTokenizer()
Returns:
TRUE if successful

openInputFile

public boolean openInputFile(java.lang.String inputFileName)
This function opens the file specified by filename

Parameters:
filename - the name of input file to open

openBinaryOutputFile

public boolean openBinaryOutputFile(java.lang.String outputFileName)
This function opens the file specified by filename

Parameters:
filename - the name of output file to open

openOutputFileForSerialization

public boolean openOutputFileForSerialization(java.lang.String outputFileName)
Deprecated. -serialization is too slow, use openBinaryOutputFile() instead

This function opens the file specified by filename

Parameters:
filename - the name of output file to open

openBinaryInputFile

public boolean openBinaryInputFile(java.lang.String inputFileName)
This method opens a FileInputStream and a DataInputStream

Parameters:
inputFileName - an input file name
Returns:
TRUE if the call was successful

openSerializedInputStream

public boolean openSerializedInputStream(java.lang.String inputFileName)
Deprecated. -serialization is too slow, use openBinaryInputFile() instead

This method opens a FileInputStream and an ObjectInputStream

Parameters:
inputFileName - an input file name
Returns:
TRUE if the call was successful

openASCIIinputStream

public boolean openASCIIinputStream(java.lang.String inputFileName)
This method opens a FileInputStream and initializes the StreamTokenizer. Very useful for testing and debugging

Parameters:
inputFileName - input file name
Returns:
TRUE if the call was successful

closeASCIIinputFile

public boolean closeASCIIinputFile()
This method closes this FileHandler's FileInputStream.

Returns:
TRUE if the call was successful

writeUsingSerialization

public boolean writeUsingSerialization(Cube cube)
Deprecated. -serialization is too slow, write an object in native binary format instead

Parameters:
cube - the cube to write to the file, serialized
Returns:
TRUE if successful

readFloat

public float readFloat()
Returns:
the float we are reading from this fileHandler's dataInputStream

writeFloat

public boolean writeFloat(float f)
Parameters:
the - float we are writing to this fileHandlers dataOutputStream
Returns:
true if the write was successful

writeShort

public boolean writeShort(short s)
Parameters:
the - short we are writing to this fileHandlers dataOutputStream
Returns:
true if the write was successful

closeBinaryInputFile

public boolean closeBinaryInputFile()
This method closes the input file. IF there's a dataInputStream, close that too.

Returns:
[true|false] on [success|failure]

closeSerializedInputFile

public boolean closeSerializedInputFile()
This method closes the input file. IF there's an objectInputStream, close that too.

Returns:
[true|false] on [success|failure]

closeBinaryOutputFile

public boolean closeBinaryOutputFile()
This method closes the output file.

Returns:
[true|false] on [success|failure]

closeSerializedOutputFile

public boolean closeSerializedOutputFile()
This method closes the output file.

Returns:
[true|false] on [success|failure]

getInputFileName

public java.lang.String getInputFileName(byte dataSet,
                                         short resolution,
                                         short representation,
                                         boolean binaryFormat)
This method is called from the BinaryCubesReader object a file name looks like: ../data/res128/headRes128cubes.bin for example
Parameters:
dataSet - the data set we are reading either Constant.HEAD , Constant.KNEE , or Constant.LOBSTER .
resolution - the resolution of the data
representation - the representation of the data
binaryFormat - TRUE if we are reading binary formated data
Returns:
the input file name

getInputFileName

public java.lang.String getInputFileName(byte dataSet,
                                         short resolution,
                                         byte variate)
This method is called from the FromFloatToCube object a file name looks like: ../data/res128/headRes128variate1floats.bin for example

Parameters:
dataSet - the data set we are reading either Constant.HEAD , Constant.KNEE , or Constant.LOBSTER .
resolution - the resolution of the data
variate - which variate file we are opening
Returns:
the input file name

getASCIIvariate

public java.lang.String getASCIIvariate(byte variate)
This method is used when reading files of uniform resolution floats, each of which stores 1 variate of a data set

Parameters:
the - variate number being read
Returns:
the ASCII string for that variate

getASCIIrepresentation

public java.lang.String getASCIIrepresentation(int representation)
This method is used when reading AR data files.

Parameters:
the - representation being read
Returns:
the ASCII string for that representation

getASCIIdataSet

private java.lang.String getASCIIdataSet(byte dataSet)
Parameters:
dataSet - a constant idendifying a data set
return - the ASCII string for that data set

getDirectory

private java.lang.String getDirectory(short resolution)
Parameters:
resolution - the resolution of the data
Returns:
the directory the data is in

getASCIIlevel

private java.lang.String getASCIIlevel(int level)
Deprecated. -use the getASCIIresolution() method instead

Parameters:
level - an integer level
Returns:
the string representation of the given level

getASCIIresolution

private java.lang.String getASCIIresolution(short resolution)
The float data sets (MR) are 2^N + 1 while the cube data sets (AR) are 2^N (even)

Parameters:
resolution - as a short
Returns:
the string representation of the given resolution

resetObjectOutputStream

public boolean resetObjectOutputStream()
Resets this FileHandler's ObjectOutputStream

main

public static void main(java.lang.String[] args)
Used for testing

IsoSurface Rendering of an AR Representation