net.grelf.grip
Class Im

java.lang.Object
  extended by net.grelf.grip.ImBase
      extended by net.grelf.grip.Im

public class Im
extends ImBase

This class holds an image, to be displayed by class ImPane in the content pane of an ImFrame. It may also hold metadata and thumbnail(s). The image is of class java.awt.BufferedImage. The present class handles loading and saving the image and its calibration. It also has a method for scaling the image down by an integer factor, which ImPane uses.


Field Summary
 
Fields inherited from class net.grelf.grip.ImBase
DEFAULT_COLOUR_IMAGE_TYPE, DEFAULT_MONO_IMAGE_TYPE, iioi, image, SCREEN_FRACTION
 
Constructor Summary
Im(java.awt.image.BufferedImage bim)
           
Im(javax.imageio.IIOImage iioi)
           
Im(Image image)
           
Im(int width, int height, boolean compatibleWithDisplay)
          If the boolean is false an image of type java.awt.image.BufferedImage.TYPE_INT_RGB will be created.
Im(int width, int height, boolean compatibleWithDisplay, boolean monochrome)
           
Im(int width, int height, java.awt.image.ColorModel cm)
           
 
Method Summary
 void addMetadata(Metadata metadata)
          Merge the metadata from the map, if the image supports the standard format, javax_imageio_1.0.
 void dispose()
          Tidy up when the frame displaying this image is closed.
 void experiment(javax.imageio.metadata.IIOMetadataNode tree)
           
 float getAperture()
          Get aperture (f/) from the metadata if it is present, otherwise return 0.
 Calibration getCalibration()
          Get a reference to the Calibration object for this image.
 java.lang.String getDateTime()
          Get date and time taken (yyyy:mm:dd hh:mm:ss) from the metadata if it is present (with key "DateTimeOriginal"), otherwise return empty string.
 float getExposure()
          Get exposure (s) from the metadata if it is present, otherwise return 0.
 java.lang.String getFilePath()
           
 int getFocalLength()
          Get focal length (mm) from the metadata if it is present, otherwise return 0.
static java.lang.String getFormat(java.lang.String filename)
          Get the format name as used by ImageIO readers, from the file extension.
 javax.imageio.metadata.IIOMetadata getIIOMetadata()
          Get the metadata from the IIOImage.
 java.util.Map<java.lang.String,java.lang.String> getImageMetadataAsMap()
          Get the image metadata as read from the file, as a Map.
 java.lang.StringBuffer getImageMetadataAsXML()
          Get the image metadata as read from the file, as an XML document held in a StringBuffer.
 int getISO()
          Get sensitivity (ISO) from the metadata if it is present, otherwise return 0.
 javax.imageio.metadata.IIOMetadata getStreamMetadata()
           
 long getTimeInMillis()
          Get date and time taken, in ms since 1970.0, or 0 if "DateTimeOriginal" key was not present in the metadata or the value was invalid.
 boolean isRaw()
          Whether the image was loaded as a raw file and has not yet undergone interpolation to set all channels for every pixel.
static Im load(java.io.File f)
          Load an image and, if available, its metadata and thumbnail(s).
static Im load(java.lang.String imFilePath)
          Load an image and, if available, its metadata and thumbnail(s).
static java.util.List<Im> loadAll(java.io.File f)
          For cases where the file may contain more than one image, load all of them.
static java.util.List<Im> loadAll(java.lang.String imFilePath)
          For cases where the file may contain more than one image, load all of them.
 void save(java.io.File f)
          Save the image in the given file, determining the format from the file's name.
 void save(java.io.File f, Metadata metadata)
          Save the image in the given file, determining the format from the file's name.
 void save(java.lang.String imFilePath)
          Save the image in the given file, determining the format from the file's name.
 Im scaleDown(int factor)
          Return a new image which is compatible with the display and contains the data from the current image scaled down by an integer factor in both x and y.
 Im scaleDown(int factor, Pseudocolour ps)
          Return a new image which is compatible with the display and contains the data from the current image scaled down by an integer factor in both x and y.
 void setCalibration(Calibration aCalib)
           
 void setMetadata(javax.imageio.metadata.IIOMetadata md)
          Set metadata from the given object.
protected  void setRaw(boolean raw)
           
static boolean testLittleEndian(java.lang.String path)
          Read the start of a TIFF file to find out the byte order.
 
Methods inherited from class net.grelf.grip.ImBase
create16BitImage, create16BitImage, getAccumulator, getBufferedImage, getGraphicsConfiguration, getHeight, getImage, getImageTypeAsString, getImageTypeAsString, getMaxLevel, getMaxLevel, getMetadata, getNBands, getNBands, getNBits, getNBits, getNBits, getThumbnail, getWidth, hasAccumulator, hasImage, setAccumulator, setBufferedImage, setImage, setImage, setMetadata
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Im

public Im(int width,
          int height,
          boolean compatibleWithDisplay)
If the boolean is false an image of type java.awt.image.BufferedImage.TYPE_INT_RGB will be created.


Im

public Im(int width,
          int height,
          boolean compatibleWithDisplay,
          boolean monochrome)

Im

public Im(int width,
          int height,
          java.awt.image.ColorModel cm)

Im

public Im(java.awt.image.BufferedImage bim)

Im

public Im(javax.imageio.IIOImage iioi)

Im

public Im(Image image)
Method Detail

getStreamMetadata

public javax.imageio.metadata.IIOMetadata getStreamMetadata()

getFilePath

public java.lang.String getFilePath()

isRaw

public boolean isRaw()
Whether the image was loaded as a raw file and has not yet undergone interpolation to set all channels for every pixel.


setRaw

protected void setRaw(boolean raw)

getCalibration

public Calibration getCalibration()
Get a reference to the Calibration object for this image.


setCalibration

public void setCalibration(Calibration aCalib)

getFormat

public static java.lang.String getFormat(java.lang.String filename)
Get the format name as used by ImageIO readers, from the file extension.


dispose

public void dispose()
Tidy up when the frame displaying this image is closed. The garbage collection will remove the image, metadata, calibration, etc.


getIIOMetadata

public javax.imageio.metadata.IIOMetadata getIIOMetadata()
Get the metadata from the IIOImage.


setMetadata

public void setMetadata(javax.imageio.metadata.IIOMetadata md)
Set metadata from the given object. Does nothing if using an Image.


addMetadata

public void addMetadata(Metadata metadata)
Merge the metadata from the map, if the image supports the standard format, javax_imageio_1.0. This is particularly useful at the end of the batch astro-process for putting combined metadata into the new image created from the accumulator. The metadata then consist of camera/telescope settings and calculated creation and exposure times from the original sequence of images. Does nothing if the Im has an Image.


getImageMetadataAsXML

public java.lang.StringBuffer getImageMetadataAsXML()
Get the image metadata as read from the file, as an XML document held in a StringBuffer.

Returns:
XML document held in a StringBuffer. Returns an empty if this Im uses an Image.

getImageMetadataAsMap

public java.util.Map<java.lang.String,java.lang.String> getImageMetadataAsMap()
Get the image metadata as read from the file, as a Map.

Returns:
Properties held in a Map. Will be empty if no metadata are found.

getFocalLength

public int getFocalLength()
Get focal length (mm) from the metadata if it is present, otherwise return 0.


getExposure

public float getExposure()
Get exposure (s) from the metadata if it is present, otherwise return 0.


getAperture

public float getAperture()
Get aperture (f/) from the metadata if it is present, otherwise return 0.


getISO

public int getISO()
Get sensitivity (ISO) from the metadata if it is present, otherwise return 0.


getDateTime

public java.lang.String getDateTime()
Get date and time taken (yyyy:mm:dd hh:mm:ss) from the metadata if it is present (with key "DateTimeOriginal"), otherwise return empty string.


getTimeInMillis

public long getTimeInMillis()
Get date and time taken, in ms since 1970.0, or 0 if "DateTimeOriginal" key was not present in the metadata or the value was invalid. Reasons for returning 0 are logged as warnings.


load

public static Im load(java.lang.String imFilePath)
Load an image and, if available, its metadata and thumbnail(s).


load

public static Im load(java.io.File f)
Load an image and, if available, its metadata and thumbnail(s).


loadAll

public static java.util.List<Im> loadAll(java.lang.String imFilePath)
For cases where the file may contain more than one image, load all of them.


loadAll

public static java.util.List<Im> loadAll(java.io.File f)
For cases where the file may contain more than one image, load all of them.


testLittleEndian

public static boolean testLittleEndian(java.lang.String path)
Read the start of a TIFF file to find out the byte order.


save

public void save(java.lang.String imFilePath)
Save the image in the given file, determining the format from the file's name.


save

public void save(java.io.File f)
Save the image in the given file, determining the format from the file's name.


save

public void save(java.io.File f,
                 Metadata metadata)
Save the image in the given file, determining the format from the file's name. Metadata will be written in the standard format (javax_imageio_1.0) if the writer supports it.


scaleDown

public Im scaleDown(int factor)
Return a new image which is compatible with the display and contains the data from the current image scaled down by an integer factor in both x and y.

Overrides:
scaleDown in class ImBase

scaleDown

public Im scaleDown(int factor,
                    Pseudocolour ps)
Return a new image which is compatible with the display and contains the data from the current image scaled down by an integer factor in both x and y. During scaling use a look-up table to apply pseudocolour.


experiment

public void experiment(javax.imageio.metadata.IIOMetadataNode tree)