net.aerith.misao.image.io
Class Format

java.lang.Object
  |
  +--net.aerith.misao.image.io.Format
Direct Known Subclasses:
Fits, JimiFormat, Ppm, RawGray, Sbig

public abstract class Format
extends java.lang.Object

The Format is an abstract class to read and save image file. It is just an access interface to the file.


Field Summary
protected  java.net.URL url
          The url of the image file.
 
Constructor Summary
Format()
           
 
Method Summary
static Format create(java.io.File file)
          Creates the proper image file format object based on the specified file object.
static Format create(java.io.File file, java.lang.String format_id)
          Creates the proper image file format object based on the specified file object and the file format ID recorded in an XML document.
abstract  java.lang.String getName()
          Gets the name of the image format.
static java.lang.String getTruncatedFilename(java.io.File file)
          Gets the file name without extension.
 boolean isFits()
          Returns true if the format is FITS.
abstract  MonoImage read()
          Reads image file and creates image buffer.
abstract  void save(MonoImage image)
          Saves image buffer into an image file.
 void setURL(java.net.URL url)
          Sets the url of the image file.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

url

protected java.net.URL url
The url of the image file.
Constructor Detail

Format

public Format()
Method Detail

setURL

public void setURL(java.net.URL url)
Sets the url of the image file.
Parameters:
url - the url of the image file.

isFits

public boolean isFits()
Returns true if the format is FITS.
Returns:
true if the format is FITS.

create

public static Format create(java.io.File file)
                     throws java.io.FileNotFoundException,
                            java.net.MalformedURLException,
                            UnsupportedFileTypeException
Creates the proper image file format object based on the specified file object.
Parameters:
file - the image file.
Returns:
the image file format object.
Throws:
java.io.FileNotFoundException - if the file does not exist.
java.net.MalformedURLException - if an unknown protocol is specified.
UnsupportedFileTypeException - if the file type is unsupported.

create

public static Format create(java.io.File file,
                            java.lang.String format_id)
                     throws java.io.FileNotFoundException,
                            java.net.MalformedURLException,
                            UnsupportedFileTypeException
Creates the proper image file format object based on the specified file object and the file format ID recorded in an XML document.
Parameters:
file - the image file.
format_id - the file format ID.
Returns:
the image file format object.
Throws:
java.io.FileNotFoundException - if the file does not exist.
java.net.MalformedURLException - if an unknown protocol is specified.
UnsupportedFileTypeException - if the file type is unsupported.

getTruncatedFilename

public static java.lang.String getTruncatedFilename(java.io.File file)
Gets the file name without extension.
Parameters:
file - the image file.
Returns:
the file name without extension.

getName

public abstract java.lang.String getName()
Gets the name of the image format.
Returns:
the name of the image format.

read

public abstract MonoImage read()
                        throws java.io.IOException,
                               UnsupportedBufferTypeException,
                               UnsupportedFileTypeException
Reads image file and creates image buffer. The url of the image file must be set previously.
Returns:
the monochrome image buffer.
Throws:
java.io.IOException - if I/O error occurs.
UnsupportedBufferTypeException - if the data type is unsupported.
UnsupportedFileTypeException - if the file type is unsupported.

save

public abstract void save(MonoImage image)
                   throws java.io.IOException,
                          UnsupportedBufferTypeException,
                          UnsupportedFileTypeException
Saves image buffer into an image file. The url of the image file must be set previously.
Parameters:
image - the monochrome image buffer to save.
Throws:
java.io.IOException - if I/O error occurs.
UnsupportedBufferTypeException - if the data type is unsupported.
UnsupportedFileTypeException - if the file type is unsupported.