Changeset 2674


Ignore:
Timestamp:
04/25/07 12:11:34 (13 years ago)
Author:
melissa
Message:
  • Added "void setId(String, boolean)" to IFormatReader.
  • Added thumbnail dimensions to CoreMetadata.
  • Fixed compile errors.
Location:
trunk/loci/formats
Files:
9 edited

Legend:

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

    r2673 r2674  
    3030public class CoreMetadata { 
    3131  public int[] sizeX, sizeY, sizeZ, sizeC, sizeT, pixelType, imageCount; 
     32  public int[] thumbSizeX, thumbSizeY;  
    3233  public int[][] cLengths; 
    3334  public String[][] cTypes; 
     
    4243    sizeC = new int[series]; 
    4344    sizeT = new int[series]; 
     45    thumbSizeX = new int[series]; 
     46    thumbSizeY = new int[series]; 
    4447    pixelType = new int[series]; 
    4548    imageCount = new int[series]; 
  • trunk/loci/formats/FileStitcher.java

    r2672 r2674  
    225225  public void setId(String id) throws FormatException, IOException { 
    226226    if (!id.equals(currentId)) initFile(id); 
     227  } 
     228 
     229  /* @see IFormatReader#setId(String, boolean) */ 
     230  public void setId(String id, boolean force) 
     231    throws FormatException, IOException 
     232  { 
     233    if (!id.equals(currentId) || force) initFile(id); 
    227234  } 
    228235 
  • trunk/loci/formats/FormatReader.java

    r2673 r2674  
    190190  /* @see IFormatReader#setId(String) */ 
    191191  public void setId(String id) throws FormatException, IOException { 
    192     if (!id.equals(currentId)) initFile(id); 
     192    setId(id, false);  
     193  } 
     194 
     195  /* @see IFormatReader#setId(String, boolean) */ 
     196  public void setId(String id, boolean force)  
     197    throws FormatException, IOException 
     198  { 
     199    if (!id.equals(currentId) || force) initFile(id); 
    193200  } 
    194201 
     
    257264  /* @see IFormatReader#getThumbSizeX() */ 
    258265  public int getThumbSizeX() { 
    259     int sx = getSizeX(); 
    260     int sy = getSizeY(); 
    261     return sx > sy ? THUMBNAIL_DIMENSION : sx * THUMBNAIL_DIMENSION / sy; 
     266    if (core.thumbSizeX[series] == 0) {  
     267      int sx = getSizeX(); 
     268      int sy = getSizeY(); 
     269      core.thumbSizeX[series] = 
     270        sx > sy ? THUMBNAIL_DIMENSION : sx * THUMBNAIL_DIMENSION / sy; 
     271    }  
     272    return core.thumbSizeX[series];  
    262273  } 
    263274 
    264275  /* @see IFormatReader#getThumbSizeY() */ 
    265276  public int getThumbSizeY() { 
    266     int sx = getSizeX(); 
    267     int sy = getSizeY(); 
    268     return sy > sx ? THUMBNAIL_DIMENSION : sy * THUMBNAIL_DIMENSION / sx; 
     277    if (core.thumbSizeY[series] == 0) {  
     278      int sx = getSizeX(); 
     279      int sy = getSizeY(); 
     280      core.thumbSizeY[series] = 
     281        sy > sx ? THUMBNAIL_DIMENSION : sy * THUMBNAIL_DIMENSION / sx; 
     282    }  
     283    return core.thumbSizeY[series];  
    269284  } 
    270285 
  • trunk/loci/formats/IFormatReader.java

    r2672 r2674  
    3737  /** Sets the current file name. */ 
    3838  void setId(String id) throws FormatException, IOException; 
     39 
     40  /**  
     41   * Sets the current file name.   
     42   * If 'force' is set, the reader will be re-initialized no matter what. 
     43   */ 
     44  void setId(String id, boolean force) throws FormatException, IOException; 
    3945 
    4046  /** Determines the number of images in the current file. */ 
  • trunk/loci/formats/ImageReader.java

    r2672 r2674  
    168168  } 
    169169 
     170  /* @see IFormatReader#setId(String, boolean) */ 
     171  public void setId(String id, boolean force) 
     172    throws FormatException, IOException 
     173  { 
     174    getReader(id).setId(id, force); 
     175  } 
     176 
    170177  /* @see IFormatReader#getImageCount() */ 
    171178  public int getImageCount() { 
  • trunk/loci/formats/ReaderWrapper.java

    r2672 r2674  
    6868  } 
    6969 
     70  public void setId(String id, boolean force) 
     71    throws FormatException, IOException 
     72  { 
     73    reader.setId(id, force); 
     74  } 
     75 
    7076  public int getImageCount() { 
    7177    return reader.getImageCount(); 
  • trunk/loci/formats/in/LegacyQTReader.java

    r2672 r2674  
    108108      } 
    109109      catch (ReflectException e) { 
    110         throw new IOException("Close movie failed", e); 
     110        throw new IOException("Close movie failed"); 
    111111      } 
    112112    } 
     
    125125    } 
    126126    catch (ReflectException e) { 
    127       throw new IOException("Close movie failed", e); 
     127      throw new IOException("Close movie failed"); 
    128128    } 
    129129    currentId = null; 
  • trunk/loci/formats/in/OIFReader.java

    r2673 r2674  
    124124    thumbReader.setId(thumbId); 
    125125    return thumbReader.openImage(0); 
    126   } 
    127  
    128   /* @see loci.formats.IFormatReader#getThumbSizeX() */ 
    129   public int getThumbSizeX() { 
    130     // TODO: populate thumbnail width in initFile instead of here! 
    131     try { 
    132       return openThumbImage(0).getWidth(); 
    133     } 
    134     catch (FormatException exc) { return -1; } 
    135     catch (IOException exc) { return -1; } 
    136   } 
    137  
    138   /* @see loci.formats.IFormatReader#getThumbSizeY() */ 
    139   public int getThumbSizeY() { 
    140     // TODO: populate thumbnail height in initFile instead of here! 
    141     try { 
    142       return openThumbImage(0).getHeight(); 
    143     } 
    144     catch (FormatException exc) { return -1; } 
    145     catch (IOException exc) { return -1; } 
    146126  } 
    147127 
     
    369349    } 
    370350 
     351    BufferedImage thumbImage = openThumbImage(0); 
     352    core.thumbSizeX[0] = thumbImage.getWidth(); 
     353    core.thumbSizeY[0] = thumbImage.getHeight(); 
     354 
    371355    // The metadata store we're working with. 
    372356    MetadataStore store = getMetadataStore(); 
  • trunk/loci/formats/in/ZeissLSMReader.java

    r2672 r2674  
    8989  } 
    9090 
    91   /* @see loci.formats.IFormatReader#getThumbSizeX() */ 
    92   public int getThumbSizeX() { 
    93     if (ifds.length == 1) return super.getThumbSizeX(); 
    94     // TODO: populate thumbnail width in initFile instead of here! 
    95     try { 
    96       return TiffTools.getIFDIntValue(ifds[1], TiffTools.IMAGE_WIDTH, false, 1); 
    97     } 
    98     catch (FormatException exc) { return -1; } 
    99   } 
    100  
    101   /* @see loci.formats.IFormatReader#getThumbSizeY() */ 
    102   public int getThumbSizeY() { 
    103     if (ifds.length == 1) return super.getThumbSizeY(); 
    104     // TODO: populate thumbnail height in initFile instead of here! 
    105     try { 
    106       return TiffTools.getIFDIntValue(ifds[1], 
    107         TiffTools.IMAGE_LENGTH, false, 1); 
    108     } 
    109     catch (FormatException exc) { return -1; } 
    110   } 
    111  
    11291  /* @see loci.formats.IFormatReader#openImage(int) */ 
    11392  public BufferedImage openImage(int no) throws FormatException, IOException { 
     
    224203    initMetadata(); 
    225204    ifds = TiffTools.getIFDs(in); 
     205  
     206    if (ifds.length > 1) { 
     207      core.thumbSizeX[0] = TiffTools.getIFDIntValue(ifds[1],  
     208        TiffTools.IMAGE_WIDTH, false, 1); 
     209      core.thumbSizeY[0] = TiffTools.getIFDIntValue(ifds[1],  
     210        TiffTools.IMAGE_LENGTH, false, 1); 
     211    }  
    226212  } 
    227213 
Note: See TracChangeset for help on using the changeset viewer.