Changeset 3222


Ignore:
Timestamp:
10/03/07 15:58:48 (12 years ago)
Author:
curtis
Message:

Allow null IFormatReader, and add corresponding setImages signature.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/gui/ImageViewer.java

    r3108 r3222  
    272272 
    273273  /** Sets the viewer to display the given images. */ 
     274  public void setImages(BufferedImage[] img) { setImages(null, img); } 
     275 
     276  /** 
     277   * Sets the viewer to display the given images, obtaining 
     278   * corresponding core metadata from the specified format reader. 
     279   */ 
    274280  public void setImages(IFormatReader reader, BufferedImage[] img) { 
    275     filename = reader.getCurrentFile(); 
     281    filename = reader == null ? null : reader.getCurrentFile(); 
    276282    in = reader; 
    277283    images = img; 
    278284 
    279     sizeZ = reader.getSizeZ(); 
    280     sizeT = reader.getSizeT(); 
    281     sizeC = reader.getEffectiveSizeC(); 
    282     //if (reader.isRGB(id)) sizeC = (sizeC + 2) / 3; // adjust for RGB 
     285    if (reader == null) { 
     286      sizeZ = sizeC = 1; 
     287      sizeT = img.length; 
     288    } 
     289    else { 
     290      sizeZ = reader.getSizeZ(); 
     291      sizeT = reader.getSizeT(); 
     292      sizeC = reader.getEffectiveSizeC(); 
     293    } 
    283294 
    284295    fileSave.setEnabled(true); 
     
    311322      sb.append(" "); 
    312323    } 
    313     String format = reader.getFormat(); 
     324    String format = reader == null ? null : reader.getFormat(); 
    314325    if (format != null) { 
    315326      sb.append("("); 
     
    410421      // update Z, T and C sliders 
    411422      int ndx = getImageIndex(); 
    412       int[] zct = {-1, -1, -1}; 
    413       zct = in.getZCTCoords(ndx); 
     423      int[] zct = in == null ? new int[] {-1, -1, -1} : in.getZCTCoords(ndx); 
    414424      if (zct[0] >= 0) { 
    415425        zSlider.removeChangeListener(this); 
     
    430440    else { 
    431441      // update N slider 
    432       int ndx = in.getIndex(getZ(), getC(), getT()); 
     442      int ndx = in == null ? -1 : in.getIndex(getZ(), getC(), getT()); 
    433443      if (ndx >= 0) { 
    434444        nSlider.removeChangeListener(this); 
Note: See TracChangeset for help on using the changeset viewer.