Class ViewImageFileFilter

  • All Implemented Interfaces:
    java.io.FileFilter

    public class ViewImageFileFilter
    extends javax.swing.filechooser.FileFilter
    implements java.io.FileFilter
    A simple file filter to display only files with the appropriate extension in the file dialog.
    Author:
    Harman Singh
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ALL
      Display all files.
      static int AVI
      Filter avi files (*.avi).
      static int CLASS
      Class Files (*.class).
      static int DATA_PROVENANCE
      mipav data provenance (*.xmp) files
      private static java.lang.String[] descriptions
      description strings for each filterType.
      static int DICOMMATRIX
      Dicom Matrix info Files (*.dicomMatrix).
      static int DYNAMIC
      Filter made up on-the-fly.
      protected java.lang.String dynamicDescription
      Description of dynamic filter.
      protected java.lang.String[] dynamicExts
      Extensions to look at for the dynamic filter.
      static int FIBER
      Fiber track files
      protected int filterType
      Filter type of this filter.
      static int FREESURFER
      FreeSurfer ascii files (*.asc).
      static int FUNCT
      Transfer Function Files (*.fun).
      static int GEN
      General( *.gif; *.jpeg; *.jpg; *.pict; *.psd; *.tif; *.tiff).
      static int JSON  
      static int LUT
      Look-Up-Table Files (*.lut).
      static int MATRIX
      .tps contains int N and float C[][] for thin plate spline
      static int MICROSCOPY
      Microscopy files (*.avi; *.ics; *.liff; *.lsm; *.pic; *.stk; *.tif; *.tiff; *.xml).
      static int MISC
      Misc.(*.bmp; *.pcx; *.png; *.tga; *.xbm; *.xpm).
      static int NLT
      B-Spline Nonlinear Transformation Files (*.nlt).
      static int OPTICAL
      Optical Files (for ophthalmology) (*.avi; *.bmp; *.jpg; *.pict; *.tif; *.tiff; *.img; *.psd).
      static int PLOT
      Graphs (*.plt).
      static int PLUGIN
      All plugin related files (.class, .jar, .zip, .tar, .tar.gz).
      static int RTABLE
      R-table (*.rtb)
      static int SCRIPT
      Script Files (*.sct).
      private static java.lang.String[] shortDescriptions
      short description strings for each filterType.
      static int SURFACE
      Surface Files (*.sur).
      static int TECH
      Medical Formats(*.dcm; *.ima; *.img; *.mnc; *.sig; *.xml; *.head; *.nii, *.rec, *.frec, *.nrrd, *.gz, *.bz2, *.zip).
      static int TIFF  
      static int UDEF
      User defined
      protected static java.lang.String udefExtsString
      This is the user defined file extensions String
      protected static java.lang.String[] userDefinedExtensions
      array of user defined extensions
      static int VOI
      VOI Files (*.voi).
    • Constructor Summary

      Constructors 
      Constructor Description
      ViewImageFileFilter​(int filterType)
      Constructs new filter of given type.
      ViewImageFileFilter​(java.lang.String[] exts)
      Constructs a dynamic filter, with the given extensions.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean accept​(java.io.File f)
      One of the overrides to FileFilter.
      boolean accept​(java.lang.String extension)
      Checks if extension matches what is accepted for the filter type.
      boolean equals​(javax.swing.filechooser.FileFilter filter)
      Determines if this file filter is equal (in value) to another.
      java.lang.String getDescription()
      One of the overrides to FileFilter.
      static java.lang.String getDescription​(int filter)
      Returns the description of the given file filter.
      static java.lang.String[] getDescriptions()
      Returns the list of descriptions.
      static int getFilterIndex​(java.lang.String filter)
      DOCUMENT ME!
      static java.lang.String getShortDescription​(int filter)
      Returns the dshort escription of the given file filter.
      java.lang.String[] listFiles​(java.io.File file)
      Returns a list of the files in the directory that satisfy the file filter.
      static boolean matches​(javax.swing.filechooser.FileFilter filter, int filterType)
      Determines if the given file filter's description matches the description associated with the given filterType.
      static void setUdefDescription​(java.lang.String desc)
      This sets the udef description becasue as the user edits the file extensions, the description changes
      static void setUserDefinedExtensions()
      This sets the user defined Exts String as well as the Arraay of exts from the Preferences
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • FREESURFER

        public static final int FREESURFER
        FreeSurfer ascii files (*.asc).
        See Also:
        Constant Field Values
      • GEN

        public static final int GEN
        General( *.gif; *.jpeg; *.jpg; *.pict; *.psd; *.tif; *.tiff).
        See Also:
        Constant Field Values
      • MATRIX

        public static final int MATRIX
        .tps contains int N and float C[][] for thin plate spline
        See Also:
        Constant Field Values
      • TECH

        public static final int TECH
        Medical Formats(*.dcm; *.ima; *.img; *.mnc; *.sig; *.xml; *.head; *.nii, *.rec, *.frec, *.nrrd, *.gz, *.bz2, *.zip).
        See Also:
        Constant Field Values
      • MICROSCOPY

        public static final int MICROSCOPY
        Microscopy files (*.avi; *.ics; *.liff; *.lsm; *.pic; *.stk; *.tif; *.tiff; *.xml).
        See Also:
        Constant Field Values
      • MISC

        public static final int MISC
        Misc.(*.bmp; *.pcx; *.png; *.tga; *.xbm; *.xpm).
        See Also:
        Constant Field Values
      • OPTICAL

        public static final int OPTICAL
        Optical Files (for ophthalmology) (*.avi; *.bmp; *.jpg; *.pict; *.tif; *.tiff; *.img; *.psd).
        See Also:
        Constant Field Values
      • NLT

        public static final int NLT
        B-Spline Nonlinear Transformation Files (*.nlt).
        See Also:
        Constant Field Values
      • PLUGIN

        public static final int PLUGIN
        All plugin related files (.class, .jar, .zip, .tar, .tar.gz).
        See Also:
        Constant Field Values
      • DATA_PROVENANCE

        public static final int DATA_PROVENANCE
        mipav data provenance (*.xmp) files
        See Also:
        Constant Field Values
      • DICOMMATRIX

        public static final int DICOMMATRIX
        Dicom Matrix info Files (*.dicomMatrix).
        See Also:
        Constant Field Values
      • descriptions

        private static java.lang.String[] descriptions
        description strings for each filterType.
      • shortDescriptions

        private static java.lang.String[] shortDescriptions
        short description strings for each filterType.
      • userDefinedExtensions

        protected static java.lang.String[] userDefinedExtensions
        array of user defined extensions
      • udefExtsString

        protected static java.lang.String udefExtsString
        This is the user defined file extensions String
      • dynamicDescription

        protected java.lang.String dynamicDescription
        Description of dynamic filter.
      • dynamicExts

        protected java.lang.String[] dynamicExts
        Extensions to look at for the dynamic filter.
      • filterType

        protected final int filterType
        Filter type of this filter.
    • Constructor Detail

      • ViewImageFileFilter

        public ViewImageFileFilter​(int filterType)
        Constructs new filter of given type.
        Parameters:
        filterType - Type of filter (GEN, TECH, etc.)
      • ViewImageFileFilter

        public ViewImageFileFilter​(java.lang.String[] exts)
        Constructs a dynamic filter, with the given extensions.
        Parameters:
        exts - Extensions to accept for dynamic filter.
    • Method Detail

      • getDescription

        public static java.lang.String getDescription​(int filter)
        Returns the description of the given file filter.
        Parameters:
        filter - Filter to check.
        Returns:
        Description of filter.
      • getDescriptions

        public static java.lang.String[] getDescriptions()
        Returns the list of descriptions.
        Returns:
        The list of descriptions.
      • getFilterIndex

        public static int getFilterIndex​(java.lang.String filter)
        DOCUMENT ME!
        Parameters:
        filter - DOCUMENT ME!
        Returns:
        DOCUMENT ME!
      • getShortDescription

        public static java.lang.String getShortDescription​(int filter)
        Returns the dshort escription of the given file filter.
        Parameters:
        filter - Filter to check.
        Returns:
        Short description of filter.
      • matches

        public static boolean matches​(javax.swing.filechooser.FileFilter filter,
                                      int filterType)
        Determines if the given file filter's description matches the description associated with the given filterType.
        Parameters:
        filter - The filter to be tested
        filterType - The filter type to test for a match
        Returns:
        true if and only if the filter's description matches the filterType description.
      • accept

        public boolean accept​(java.io.File f)
        One of the overrides to FileFilter. This function is called for each file in the current directory of the file dialog to test if it is a file with the appropriate extension. If so, it is accepted for display in the file dialog.
        Specified by:
        accept in interface java.io.FileFilter
        Specified by:
        accept in class javax.swing.filechooser.FileFilter
        Parameters:
        f - The file whose name is to be tested for extension.
        Returns:
        true if and only if the file has an appropriate extension.
      • accept

        public boolean accept​(java.lang.String extension)
        Checks if extension matches what is accepted for the filter type. If so, returns true; if not, returns false.
        Parameters:
        extension - Extension of file to check.
        Returns:
        true if extension is in file filter.
      • equals

        public boolean equals​(javax.swing.filechooser.FileFilter filter)
        Determines if this file filter is equal (in value) to another.
        Parameters:
        filter - The filter to be tested for equality
        Returns:
        true if and only if the filter is the same type as this filter.
      • getDescription

        public java.lang.String getDescription()
        One of the overrides to FileFilter. This function is called just to access the description of the filter.
        Specified by:
        getDescription in class javax.swing.filechooser.FileFilter
        Returns:
        The description for the filter.
      • listFiles

        public java.lang.String[] listFiles​(java.io.File file)
        Returns a list of the files in the directory that satisfy the file filter.
        Parameters:
        file - Directory
        Returns:
        List of files in directory that satisfy file filter.
      • setUdefDescription

        public static void setUdefDescription​(java.lang.String desc)
        This sets the udef description becasue as the user edits the file extensions, the description changes
        Parameters:
        desc - Description String
      • setUserDefinedExtensions

        public static void setUserDefinedExtensions()
        This sets the user defined Exts String as well as the Arraay of exts from the Preferences