uk.ac.essex.ia.imageview
Class ImageFileOp

java.lang.Object
  extended by uk.ac.essex.common.io.FileOp<T>
      extended by uk.ac.essex.common.io.FileOpImpl<ImageFile>
          extended by uk.ac.essex.ia.imageview.ImageFileOp

public class ImageFileOp
extends FileOpImpl<ImageFile>

Handles reading and writing image data to/from files TODO: Tidy up this class


Field Summary
 
Fields inherited from class uk.ac.essex.common.io.FileOpImpl
currentCaller, fileChooser, LAST_DIR, lastDir
 
Fields inherited from class uk.ac.essex.common.io.FileOp
file
 
Constructor Summary
ImageFileOp()
          The file fileChooser is just a plain old JFileChooser.
 
Method Summary
 java.lang.String getDefaultEnding()
          Gets the default file ending to postfix to the file name, this is only used if the file to save to has not been given by the user.
 java.lang.String getWriteParam(java.lang.String s)
          Returns the string needed by the "filestore" and "encode" operations is also used to check users have entered a valid filetype ending ie/ it returns null for invalid file endings.
 void main(java.lang.String[] args)
          Test method - Should test this class by opening an image file from disk then saving it under another name.
 ImageFile openFile(java.io.File fileToOpen)
          Opens the file specied by fname and returns this as type RenderedImage
 void save(ImageFile toBeSaved)
          Saves an image to file the first parameter should be a RenderedImage or this will do nothing.
 boolean saveAs(ImageFile toBeSaved, java.awt.Component caller)
          Saves an image file under a new name.
protected  void saveFile()
          Saves the image stored in source, in the File stored in file.
 
Methods inherited from class uk.ac.essex.common.io.FileOpImpl
getFileChooser, hasEnding, open, setFileChooser
 
Methods inherited from class uk.ac.essex.common.io.FileOp
getFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ImageFileOp

public ImageFileOp()
The file fileChooser is just a plain old JFileChooser.

Method Detail

getWriteParam

public java.lang.String getWriteParam(java.lang.String s)
Returns the string needed by the "filestore" and "encode" operations is also used to check users have entered a valid filetype ending ie/ it returns null for invalid file endings. The parameter it takes should be one of the supported file types( ie/.jpg, .tif etc) it would then return JPEG and TIFF respectively. (N.B. see the JAI documentation for more details of the supported file types and parameters to filestore/encode)

Parameters:
s - - The file ending to check
Returns:
The corresponding parameter required by filestore/encode

saveAs

public boolean saveAs(ImageFile toBeSaved,
                      java.awt.Component caller)
Saves an image file under a new name. It first opens up an ImageJFileChooser where users can select the new file name. The first parameter should be a RenderedImage or this will fail. Users can select the encoding of data(ie/.jpg, .gif etc) either by entering it in box they put the name in or by selecting it from the drop down box

Overrides:
saveAs in class FileOpImpl<ImageFile>
Parameters:
toBeSaved - - the Object to save
caller - - The GUI that called this function
Returns:
boolean - true if the file saved ok, false otherwise
See Also:
FileOp.save(T)

openFile

public ImageFile openFile(java.io.File fileToOpen)
Opens the file specied by fname and returns this as type RenderedImage

Specified by:
openFile in class FileOpImpl<ImageFile>
Parameters:
fileToOpen - - The file to open

getDefaultEnding

public java.lang.String getDefaultEnding()
Gets the default file ending to postfix to the file name, this is only used if the file to save to has not been given by the user.

Specified by:
getDefaultEnding in class FileOpImpl<ImageFile>
Returns:
String - The default file ending to postfix to the file name

save

public void save(ImageFile toBeSaved)
Saves an image to file the first parameter should be a RenderedImage or this will do nothing.

Specified by:
save in class FileOp<ImageFile>
Parameters:
toBeSaved - - The Object to be saved

saveFile

protected void saveFile()
Saves the image stored in source, in the File stored in file. This creates a new thread to doo the work.


main

public void main(java.lang.String[] args)
Test method - Should test this class by opening an image file from disk then saving it under another name.