ij.io
Class Opener

java.lang.Object
  extended by ij.io.Opener

public class Opener
extends java.lang.Object

Opens tiff (and tiff stacks), dicom, fits, pgm, jpeg, bmp or gif images, and look-up tables, using a file open dialog or a path. Calls HandleExtraFileTypes plugin if the file type is unrecognised.


Field Summary
static int BMP
           
static int CUSTOM
           
static int DICOM
           
static int FITS
           
static int GIF
           
static int JAVA_OR_TEXT
           
static int JPEG
           
static int LUT
           
static int PGM
           
static int PNG
           
static int ROI
           
static int TEXT
           
static int TIFF
           
static int TIFF_AND_DICOM
           
static int UNKNOWN
           
static int ZIP
           
 
Constructor Summary
Opener()
           
 
Method Summary
static void convertGrayJpegTo8Bits(ImagePlus imp)
          If this image is grayscale, convert it to 8-bits.
 java.lang.String getDir(java.lang.String path)
           
 int getFileType(java.lang.String path)
          Attempts to determine the image file type by looking for 'magic numbers' and the file name extension.
 java.lang.String getName(java.lang.String path)
           
static boolean getOpenUsingPlugins()
          Returns the state of the openUsingPlugins flag.
 void open()
          Displays a file open dialog box and then opens the tiff, dicom, fits, pgm, jpeg, bmp, gif, lut, roi, or text file selected by the user.
 void open(java.lang.String path)
          Opens and displays a tiff, dicom, fits, pgm, jpeg, bmp, gif, lut, roi, or text file.
 boolean openAndAddToRecent(java.lang.String path)
          Opens the specified file and adds it to the File/Open Recent menu.
 ImagePlus openImage(java.lang.String path)
          Attempts to open the specified file as a tiff, bmp, dicom, fits, pgm, gif or jpeg.
 ImagePlus openImage(java.lang.String directory, java.lang.String name)
          Attempts to open the specified file as a tiff, bmp, dicom, fits, pgm, gif or jpeg image.
 void openMultiple()
          Displays a JFileChooser and then opens the tiff, dicom, fits, pgm, jpeg, bmp, gif, lut, roi, or text files selected by the user.
 Roi openRoi(java.lang.String path)
          Attempts to open the specified ROI, returning null if unsuccessful.
 ImagePlus openTiff(java.io.InputStream in, java.lang.String name)
          Attempts to open the specified inputStream as a TIFF, returning an ImagePlus object if successful.
 ImagePlus openTiff(java.lang.String directory, java.lang.String name)
          Attempts to open the specified file as a tiff.
 ImagePlus openTiffStack(FileInfo[] info)
          Attemps to open a tiff file as a stack.
 ImagePlus openURL(java.lang.String url)
          Attempts to open the specified url as a tiff, zip compressed tiff, dicom, gif or jpeg.
static void setOpenUsingPlugins(boolean b)
          Open all images using HandleExtraFileTypes.
 void setSilentMode(boolean mode)
          The "Opening: path" status message is not displayed in silent mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNKNOWN

public static final int UNKNOWN
See Also:
Constant Field Values

TIFF

public static final int TIFF
See Also:
Constant Field Values

DICOM

public static final int DICOM
See Also:
Constant Field Values

FITS

public static final int FITS
See Also:
Constant Field Values

PGM

public static final int PGM
See Also:
Constant Field Values

JPEG

public static final int JPEG
See Also:
Constant Field Values

GIF

public static final int GIF
See Also:
Constant Field Values

LUT

public static final int LUT
See Also:
Constant Field Values

BMP

public static final int BMP
See Also:
Constant Field Values

ZIP

public static final int ZIP
See Also:
Constant Field Values

JAVA_OR_TEXT

public static final int JAVA_OR_TEXT
See Also:
Constant Field Values

ROI

public static final int ROI
See Also:
Constant Field Values

TEXT

public static final int TEXT
See Also:
Constant Field Values

PNG

public static final int PNG
See Also:
Constant Field Values

TIFF_AND_DICOM

public static final int TIFF_AND_DICOM
See Also:
Constant Field Values

CUSTOM

public static final int CUSTOM
See Also:
Constant Field Values
Constructor Detail

Opener

public Opener()
Method Detail

open

public void open()
Displays a file open dialog box and then opens the tiff, dicom, fits, pgm, jpeg, bmp, gif, lut, roi, or text file selected by the user. Displays an error message if the selected file is not in one of the supported formats. This is the method that ImageJ's File/Open command uses to open files.


openMultiple

public void openMultiple()
Displays a JFileChooser and then opens the tiff, dicom, fits, pgm, jpeg, bmp, gif, lut, roi, or text files selected by the user. Displays error messages if one or more of the selected files is not in one of the supported formats. This is the method that ImageJ's File/Open command uses to open files if "Open/Save Using JFileChooser" is checked in EditOptions/Misc.


open

public void open(java.lang.String path)
Opens and displays a tiff, dicom, fits, pgm, jpeg, bmp, gif, lut, roi, or text file. Displays an error message if the specified file is not in one of the supported formats.


openAndAddToRecent

public boolean openAndAddToRecent(java.lang.String path)
Opens the specified file and adds it to the File/Open Recent menu. Returns true if the file was opened successfully.


openImage

public ImagePlus openImage(java.lang.String directory,
                           java.lang.String name)
Attempts to open the specified file as a tiff, bmp, dicom, fits, pgm, gif or jpeg image. Returns an ImagePlus object if successful. Modified by Gregory Jefferis to call HandleExtraFileTypes plugin if the file type is unrecognised.


openImage

public ImagePlus openImage(java.lang.String path)
Attempts to open the specified file as a tiff, bmp, dicom, fits, pgm, gif or jpeg. Returns an ImagePlus object if successful.


openURL

public ImagePlus openURL(java.lang.String url)
Attempts to open the specified url as a tiff, zip compressed tiff, dicom, gif or jpeg. Tiff file names must end in ".tif", ZIP file names must end in ".zip" and dicom file names must end in ".dcm". Returns an ImagePlus object if successful.


convertGrayJpegTo8Bits

public static void convertGrayJpegTo8Bits(ImagePlus imp)
If this image is grayscale, convert it to 8-bits.


openTiffStack

public ImagePlus openTiffStack(FileInfo[] info)
Attemps to open a tiff file as a stack. Returns an ImagePlus object if successful.


openTiff

public ImagePlus openTiff(java.lang.String directory,
                          java.lang.String name)
Attempts to open the specified file as a tiff. Returns an ImagePlus object if successful.


openTiff

public ImagePlus openTiff(java.io.InputStream in,
                          java.lang.String name)
Attempts to open the specified inputStream as a TIFF, returning an ImagePlus object if successful.


getName

public java.lang.String getName(java.lang.String path)

getDir

public java.lang.String getDir(java.lang.String path)

openRoi

public Roi openRoi(java.lang.String path)
Attempts to open the specified ROI, returning null if unsuccessful.


getFileType

public int getFileType(java.lang.String path)
Attempts to determine the image file type by looking for 'magic numbers' and the file name extension.


setSilentMode

public void setSilentMode(boolean mode)
The "Opening: path" status message is not displayed in silent mode.


setOpenUsingPlugins

public static void setOpenUsingPlugins(boolean b)
Open all images using HandleExtraFileTypes. Set from a macro using setOption("openUsingPlugins", true).


getOpenUsingPlugins

public static boolean getOpenUsingPlugins()
Returns the state of the openUsingPlugins flag.