Changeset 2414


Ignore:
Timestamp:
03/08/07 10:40:12 (13 years ago)
Author:
melissa
Message:

Print a warning if a method that doesn't take the 'id' parameter is called on
an initialized reader. Also removed a bunch of unnecessary calls to
setColorTableIgnored in various readers.

Location:
trunk/loci/formats
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/FileStitcher.java

    r2385 r2414  
    100100  /** Component lengths for each axis type. */ 
    101101  private int[][] lenZ, lenC, lenT; 
    102  
    103   /** Whether or not we're doing channel stat calculation (no by default). */ 
    104   protected boolean enableChannelStatCalculation = false; 
    105  
    106   /** Whether or not to ignore color tables, if present. */ 
    107   protected boolean ignoreColorTable = false; 
    108  
    109   /** Whether or not to normalize float data. */ 
    110   protected boolean normalizeData = false; 
    111102 
    112103  // -- Constructors -- 
     
    413404  /* @see IFormatReader#setChannelStatCalculationStatus(boolean) */ 
    414405  public void setChannelStatCalculationStatus(boolean on) { 
    415     enableChannelStatCalculation = on; 
     406    for (int i=0; i<readers.length; i++) { 
     407      readers[i].setChannelStatCalculationStatus(on); 
     408    } 
    416409  } 
    417410 
    418411  /* @see IFormatReader#getChannelStatCalculationStatus */ 
    419412  public boolean getChannelStatCalculationStatus() { 
    420     return enableChannelStatCalculation; 
     413    return readers[0].getChannelStatCalculationStatus(); 
    421414  } 
    422415 
     
    557550  /* @see IFormatReader#setColorTableIgnored(boolean) */ 
    558551  public void setColorTableIgnored(boolean ignore) { 
    559     ignoreColorTable = ignore; 
    560552    reader.setColorTableIgnored(ignore); 
    561553    if (readers != null) { 
     
    567559 
    568560  /* @see IFormatReader#isColorTableIgnored() */ 
    569   public boolean isColorTableIgnored() { return ignoreColorTable; } 
     561  public boolean isColorTableIgnored() {  
     562    return readers[0].isColorTableIgnored();  
     563  } 
    570564 
    571565  /* @see IFormatReader#setNormalized(boolean) */ 
    572566  public void setNormalized(boolean normalize) { 
    573     normalizeData = normalize; 
     567    if (readers != null) {  
     568      for (int i=0; i<readers.length; i++) { 
     569        readers[i].setNormalized(normalize); 
     570      } 
     571    } 
    574572  } 
    575573 
    576574  /* @see IFormatReader#isNormalized() */ 
    577   public boolean isNormalized() { return normalizeData; } 
     575  public boolean isNormalized() { return readers[0].isNormalized(); } 
    578576 
    579577  /* @see IFormatReader#getUsedFiles() */ 
     
    780778        } 
    781779        readers[i] = (IFormatReader) r; 
     780        readers[i].setChannelStatCalculationStatus( 
     781          reader.getChannelStatCalculationStatus());  
     782        readers[i].setColorTableIgnored(reader.isColorTableIgnored()); 
     783        readers[i].setNormalized(reader.isNormalized()); 
     784        readers[i].setMetadataFiltered(reader.isMetadataFiltered()); 
    782785      } 
    783786      catch (InstantiationException exc) { exc.printStackTrace(); } 
     
    935938 
    936939    // configure the reader, in case we haven't done this one yet 
    937     readers[fno].setChannelStatCalculationStatus(enableChannelStatCalculation); 
    938940    readers[fno].setSeries(files[fno], reader.getSeries(files[0])); 
    939     readers[fno].setColorTableIgnored(ignoreColorTable); 
    940941    readers[fno].swapDimensions(files[fno], order[sno]); 
    941942 
  • trunk/loci/formats/FormatReader.java

    r2382 r2414  
    439439  /* @see IFormatReader#setChannelStatCalculationStatus(boolean) */ 
    440440  public void setChannelStatCalculationStatus(boolean on) { 
     441    if (currentId != null) {  
     442      System.err.println( 
     443        "Warning: setChannelStatCalculation called with open file.");  
     444    } 
    441445    enableChannelStatCalculation = on; 
    442446  } 
     
    514518  /* @see IFormatReader#setColorTableIgnored(boolean) */ 
    515519  public void setColorTableIgnored(boolean ignore) { 
     520    if (currentId != null) {  
     521      System.err.println( 
     522        "Warning: setColorTableIgnored called with open file."); 
     523      Exception e = new Exception(); 
     524      e.printStackTrace(); 
     525    } 
    516526    ignoreColorTable = ignore; 
    517527  } 
     
    524534  /* @see IFormatReader#setNormalized(boolean) */ 
    525535  public void setNormalized(boolean normalize) { 
     536    if (currentId != null) {  
     537      System.err.println("Warning: setNormalized called with open file.");  
     538    } 
    526539    normalizeData = normalize; 
    527540  } 
     
    608621  /* @see IFormatReader#setMetadataFiltered(boolean) */ 
    609622  public void setMetadataFiltered(boolean filter) { 
     623    if (currentId != null) {  
     624      System.err.println("Warning: setMetadataFiltered called with open file.");  
     625    } 
    610626    filterMetadata = filter; 
    611627  } 
     
    618634  /* @see IFormatReader#setMetadataStore(MetadataStore) */ 
    619635  public void setMetadataStore(MetadataStore store) { 
     636    if (currentId != null) {  
     637      System.err.println("Warning: setMetadataStore called with open file.");  
     638    } 
    620639    metadataStore = store; 
    621640  } 
  • trunk/loci/formats/TiffTools.java

    r2377 r2414  
    14061406    int[] validBits = getIFDIntArray(ifd, VALID_BITS, false); 
    14071407 
    1408     if (photoInterp == RGB_PALETTE || photoInterp == CFA_ARRAY) { 
     1408    if (!ignore && (photoInterp == RGB_PALETTE || photoInterp == CFA_ARRAY)) { 
    14091409      samplesPerPixel = 3; 
    14101410    } 
     
    14561456      } 
    14571457    } 
     1458    if (samplesPerPixel == 1) { 
     1459      return ImageTools.makeImage(samples[0], (int) imageWidth,  
     1460        (int) imageLength, 1, false, validBits); 
     1461    } 
     1462     
    14581463    if (samples.length == 2) { 
    14591464      byte[][] s = new byte[3][samples[0].length]; 
  • trunk/loci/formats/in/LeicaReader.java

    r2386 r2414  
    140140      initFile(id); 
    141141    } 
    142     tiff[series][0].setColorTableIgnored(isColorTableIgnored()); 
    143142    return tiff[series][0].isRGB((String) files[series].get(0)); 
    144143  } 
     
    168167      throw new FormatException("Invalid image number: " + no); 
    169168    } 
    170     tiff[series][no].setColorTableIgnored(ignoreColorTable); 
    171169    byte[] b = tiff[series][no].openBytes((String) files[series].get(no), 0); 
    172170    tiff[series][no].close(); 
     
    203201    } 
    204202 
    205     tiff[series][no].setColorTableIgnored(ignoreColorTable); 
    206203    BufferedImage b = 
    207204      tiff[series][no].openImage((String) files[series].get(no), 0); 
     
    599596        for (int j=0; j<tiff[i].length; j++) { 
    600597          tiff[i][j] = new TiffReader(); 
     598          tiff[i][j].setColorTableIgnored(isColorTableIgnored());  
    601599        } 
    602600      } 
  • trunk/loci/formats/in/OIFReader.java

    r2377 r2414  
    104104      initFile(id); 
    105105    } 
    106     tiffReader[0].setColorTableIgnored(ignoreColorTable); 
    107106    return tiffReader[0].isRGB((String) tiffs.get(0)); 
    108107  } 
     
    148147      initFile(id); 
    149148    } 
    150     tiffReader[no].setColorTableIgnored(ignoreColorTable); 
    151149    byte[] b = tiffReader[no].openBytes((String) tiffs.get(no), 0); 
    152150    tiffReader[no].close(); 
     
    165163    } 
    166164      
    167     tiffReader[no].setColorTableIgnored(ignoreColorTable); 
    168165    tiffReader[no].openBytes((String) tiffs.get(no), 0, buf); 
    169166    tiffReader[no].close(); 
     
    184181    } 
    185182 
    186     tiffReader[no].setColorTableIgnored(ignoreColorTable); 
    187183    BufferedImage b = tiffReader[no].openImage((String) tiffs.get(no), 0); 
    188184    ColorModel cm = ImageTools.makeColorModel(b.getRaster().getNumBands(), 
     
    213209    thumbId = dir + id.substring(id.lastIndexOf(File.separator) + 1, 
    214210      id.lastIndexOf(".")) + "_Thumb.bmp"; 
    215     thumbReader.setColorTableIgnored(ignoreColorTable); 
    216211    return thumbReader.openImage(thumbId, 0); 
    217212  } 
     
    332327 
    333328    thumbReader = new BMPReader(); 
     329    thumbReader.setColorTableIgnored(isColorTableIgnored()); 
    334330    numImages = filenames.size(); 
    335331    tiffs = new Vector(numImages); 
    336332 
    337333    tiffReader = new TiffReader[numImages]; 
    338     for (int i=0; i<numImages; i++) tiffReader[i] = new TiffReader(); 
     334    for (int i=0; i<numImages; i++) { 
     335      tiffReader[i] = new TiffReader(); 
     336      tiffReader[i].setColorTableIgnored(isColorTableIgnored()); 
     337    } 
    339338 
    340339    // open each INI file (.pty extension) 
  • trunk/loci/formats/in/PerkinElmerReader.java

    r2371 r2414  
    8686    } 
    8787    if (isTiff) { 
    88       tiff[0].setColorTableIgnored(ignoreColorTable); 
    8988      return tiff[0].isRGB(files[0]); 
    9089    } 
     
    114113    } 
    115114    if (isTiff) { 
    116       tiff[no / channels].setColorTableIgnored(ignoreColorTable); 
    117115      return tiff[no / channels].openBytes(files[no / channels], 0); 
    118116    } 
     
    140138    } 
    141139    if (isTiff) { 
    142       tiff[no / channels].setColorTableIgnored(ignoreColorTable); 
    143140      return tiff[no / channels].openImage(files[no / channels], 0); 
    144141    } 
     
    383380 
    384381    tiff = new TiffReader[numImages]; 
    385     for (int i=0; i<tiff.length; i++) tiff[i] = new TiffReader(); 
     382    for (int i=0; i<tiff.length; i++) { 
     383      tiff[i] = new TiffReader(); 
     384      tiff[i].setColorTableIgnored(isColorTableIgnored()); 
     385    } 
    386386 
    387387    // highly questionable metadata parsing 
Note: See TracChangeset for help on using the changeset viewer.