Changeset 7379


Ignore:
Timestamp:
12/09/10 13:42:46 (9 years ago)
Author:
melissa
Message:

Added better type checking to ScreenReader, so it is now included in readers.txt.

Location:
trunk/components/bio-formats/src/loci/formats
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/bio-formats/src/loci/formats/in/ScreenReader.java

    r7370 r7379  
    3232import loci.common.Location; 
    3333import loci.common.RandomAccessInputStream; 
     34import loci.formats.ClassList; 
    3435import loci.formats.CoreMetadata; 
    3536import loci.formats.FormatException; 
    3637import loci.formats.FormatReader; 
    3738import loci.formats.FormatTools; 
     39import loci.formats.IFormatReader; 
    3840import loci.formats.ImageReader; 
    3941import loci.formats.MetadataTools; 
     
    6062  private ImageReader[][] readers; 
    6163  private boolean[][][] plateMaps; 
     64  private ClassList<IFormatReader> validReaders; 
    6265 
    6366  // -- Constructor -- 
     
    6871    suffixSufficient = false; 
    6972    domains = new String[] {FormatTools.HCS_DOMAIN}; 
     73 
     74    ClassList<IFormatReader> classes = ImageReader.getDefaultReaderClasses(); 
     75    Class<? extends IFormatReader>[] classArray = classes.getClasses(); 
     76    validReaders = new ClassList<IFormatReader>(IFormatReader.class); 
     77    for (Class<? extends IFormatReader> c : classArray) { 
     78      if (!c.equals(ScreenReader.class)) { 
     79        validReaders.addClass(c); 
     80      } 
     81    } 
    7082  } 
    7183 
     
    8092  public boolean isThisType(String filename, boolean open) { 
    8193    if (!open) return super.isThisType(filename, open); // no file system access 
    82     return false; 
     94 
     95    String parent = new Location(filename).getParent(); 
     96    boolean validNames = isValidWellName(filename) && isValidPlateName(parent); 
     97 
     98    ImageReader r = new ImageReader(validReaders); 
     99    boolean validFormat = r.isThisType(filename); 
     100    boolean singleFiles = false; 
     101    try { 
     102      singleFiles = r.isSingleFile(filename); 
     103    } 
     104    catch (FormatException e) { } 
     105    catch (IOException e) { } 
     106 
     107    return validNames && validFormat && singleFiles; 
    83108  } 
    84109 
     
    229254    for (int plate=0; plate<files.length; plate++) { 
    230255      for (int well=0; well<files[plate].length; well++) { 
    231         readers[plate][well] = new ImageReader(); 
     256        readers[plate][well] = new ImageReader(validReaders); 
    232257        readers[plate][well].setId(files[plate][well]); 
    233258        core[nextCore++] = readers[plate][well].getCoreMetadata()[0]; 
  • trunk/components/bio-formats/src/loci/formats/readers.txt

    r7228 r7379  
    2323# available to Bio-Formats, and the order in which they should be used. 
    2424# Please do not edit unless you know what you are doing (see reader-guide.txt). 
     25 
     26# generic reader for HCS data 
     27loci.formats.in.ScreenReader 
    2528 
    2629# readers for compressed/archive files 
Note: See TracChangeset for help on using the changeset viewer.