Changeset 2699


Ignore:
Timestamp:
04/27/07 13:10:57 (13 years ago)
Author:
curtis
Message:

Fix up testRead so that status messages are not echoed during pixel read phase.
Instead, a single semicolon is echoed any time a new batch of status messages
comes in. This is useful for file stitching, so that calls to constituent image
readers during pixel reads now show up as semicolons instead of message spam.

File:
1 edited

Legend:

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

    r2696 r2699  
    230230    } 
    231231 
     232    System.out.println("Initializing reader"); 
    232233    if (stitch) { 
    233234      reader = new FileStitcher(reader, true); 
     
    240241    if (minmax) reader = minMaxCalc = new MinMaxCalculator(reader); 
    241242 
    242     System.out.println("Initializing reader"); 
    243     reader.addStatusListener(new StatusListener() { 
    244       public void statusUpdated(StatusEvent e) { 
    245         System.out.println("\t" + e.getStatusMessage()); 
    246       } 
    247     }); 
    248      
    249     reader.close();  
     243    StatusEchoer status = new StatusEchoer(); 
     244    reader.addStatusListener(status); 
     245 
     246    reader.close(); 
    250247    reader.setNormalized(normalize); 
    251248    reader.setMetadataFiltered(true); 
     
    409406      System.out.println(); 
    410407      System.out.print("Reading" + s + " pixel data "); 
     408      status.setVerbose(false); 
    411409      long s1 = System.currentTimeMillis(); 
    412410      int num = reader.getImageCount(); 
     
    423421      boolean mismatch = false; 
    424422      for (int i=start; i<=end; i++) { 
     423        status.setEchoNext(true); 
    425424        if (!fastBlit) { 
    426425          images[i - start] = thumbs ? 
     
    944943   * Asserts that the current file is either null, nor not, according to the 
    945944   * given flag. If the assertion fails, an IllegalStateException is thrown. 
    946    * @param currentId File name to test.  
     945   * @param currentId File name to test. 
    947946   * @param notNull True iff id should be non-null. 
    948947   * @param depth How far back in the stack the calling method is; this name 
     
    974973  } 
    975974 
     975  // -- Helper classes -- 
     976 
     977  /** Used by testRead to echo status messages to the console. */ 
     978  private static class StatusEchoer implements StatusListener { 
     979    private boolean verbose = true; 
     980    private boolean next = true; 
     981 
     982    public void setVerbose(boolean value) { verbose = value; } 
     983    public void setEchoNext(boolean value) { next = value; } 
     984 
     985    public void statusUpdated(StatusEvent e) { 
     986      if (verbose) System.out.println("\t" + e.getStatusMessage()); 
     987      else if (next) { 
     988        System.out.print(";"); 
     989        next = false; 
     990      } 
     991    } 
     992  } 
     993 
    976994} 
Note: See TracChangeset for help on using the changeset viewer.