Changeset 2482


Ignore:
Timestamp:
03/19/07 11:46:00 (13 years ago)
Author:
curtis
Message:

Fix possible configuration skew problems between constituent readers,
and NullPointerExceptions with configuration accessors.

File:
1 edited

Legend:

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

    r2454 r2482  
    404404  /* @see IFormatReader#setChannelStatCalculationStatus(boolean) */ 
    405405  public void setChannelStatCalculationStatus(boolean on) { 
    406     for (int i=0; i<readers.length; i++) { 
    407       readers[i].setChannelStatCalculationStatus(on); 
     406    if (readers == null) reader.setChannelStatCalculationStatus(on); 
     407    else { 
     408      for (int i=0; i<readers.length; i++) { 
     409        readers[i].setChannelStatCalculationStatus(on); 
     410      } 
    408411    } 
    409412  } 
     
    508511  /* @see IFormatReader#close(boolean) */ 
    509512  public void close(boolean fileOnly) throws FormatException, IOException { 
    510     if (readers != null) { 
     513    if (readers == null) reader.close(fileOnly); 
     514    else { 
    511515      for (int i=0; i<readers.length; i++) readers[i].close(fileOnly); 
    512516    } 
     
    521525  /* @see IFormatReader#close() */ 
    522526  public void close() throws FormatException, IOException { 
    523     if (readers != null) { 
     527    if (readers == null) reader.close(); 
     528    else { 
    524529      for (int i=0; i<readers.length; i++) readers[i].close(); 
    525530    } 
     
    551556  public void setColorTableIgnored(boolean ignore) { 
    552557    reader.setColorTableIgnored(ignore); 
    553     if (readers != null) { 
     558    if (readers == null) reader.setColorTableIgnored(ignore); 
     559    else { 
    554560      for (int i=0; i<readers.length; i++) { 
    555561        readers[i].setColorTableIgnored(ignore); 
     
    565571  /* @see IFormatReader#setNormalized(boolean) */ 
    566572  public void setNormalized(boolean normalize) { 
    567     if (readers != null) { 
     573    if (readers == null) reader.setNormalized(normalize); 
     574    else { 
    568575      for (int i=0; i<readers.length; i++) { 
    569576        readers[i].setNormalized(normalize); 
     
    725732  /* @see IFormatHandler#addStatusListener(StatusListener) */ 
    726733  public void addStatusListener(StatusListener l) { 
    727     for (int i=0; i<readers.length; i++) readers[i].addStatusListener(l); 
     734    if (readers == null) reader.addStatusListener(l); 
     735    else { 
     736      for (int i=0; i<readers.length; i++) readers[i].addStatusListener(l); 
     737    } 
    728738  } 
    729739 
    730740  /* @see IFormatHandler#removeStatusListener(StatusListener) */ 
    731741  public void removeStatusListener(StatusListener l) { 
    732     for (int i=0; i<readers.length; i++) readers[i].removeStatusListener(l); 
     742    if (readers == null) reader.removeStatusListener(l); 
     743    else { 
     744      for (int i=0; i<readers.length; i++) readers[i].removeStatusListener(l); 
     745    } 
    733746  } 
    734747 
     
    795808        } 
    796809        readers[i] = (IFormatReader) r; 
    797         readers[i].setChannelStatCalculationStatus( 
    798           reader.getChannelStatCalculationStatus()); 
    799         readers[i].setColorTableIgnored(reader.isColorTableIgnored()); 
    800         readers[i].setNormalized(reader.isNormalized()); 
    801         readers[i].setMetadataFiltered(reader.isMetadataFiltered()); 
    802810      } 
    803811      catch (InstantiationException exc) { exc.printStackTrace(); } 
     
    806814      catch (InvocationTargetException exc) { exc.printStackTrace(); } 
    807815    } 
     816 
     817    // sync reader configurations with original reader 
     818    boolean channelStatCalculationStatus = 
     819      reader.getChannelStatCalculationStatus(); 
     820    boolean colorTableIgnored = reader.isColorTableIgnored(); 
     821    boolean normalized = reader.isNormalized(); 
     822    boolean metadataFiltered = reader.isMetadataFiltered(); 
     823    StatusListener[] statusListeners = reader.getStatusListeners(); 
     824    for (int i=1; i<readers.length; i++) { 
     825      readers[i].setChannelStatCalculationStatus(channelStatCalculationStatus); 
     826      readers[i].setColorTableIgnored(colorTableIgnored); 
     827      readers[i].setNormalized(normalized); 
     828      readers[i].setMetadataFiltered(metadataFiltered); 
     829      for (int j=0; j<statusListeners.length; j++) { 
     830        readers[i].addStatusListener(statusListeners[j]); 
     831      } 
     832    } 
     833 
    808834    String f0 = files[0]; 
    809835 
Note: See TracChangeset for help on using the changeset viewer.