Changeset 1810


Ignore:
Timestamp:
11/17/06 10:55:19 (14 years ago)
Author:
curtis
Message:
  • Add getIgnoreColorTable method, to match setIgnoreColorTable.
  • Remove a bunch of redundant javadoc.
  • Only create one blank image for FileStitcher padding, and use it repeatedly.
  • Move ImageReader.getBytesPerPixel utility method to FormatReader.
  • Use FormatReader.getBytesPerPixel method in FileStitcher.
Location:
trunk/loci/formats
Files:
8 edited

Legend:

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

    r1806 r1810  
    6464  /** Reader used for each file. */ 
    6565  private IFormatReader[] readers; 
     66 
     67  /** Blank image to use when image counts are not consistent between files. */ 
     68  private BufferedImage blank; 
    6669 
    6770  /** Image dimensions. */ 
     
    316319      return readers[fno].openImage(files[fno], ino); 
    317320    } 
    318     // inserting a blank image may not be the best way to handle files with 
    319     // different image counts, but we need to do something 
    320     return ImageTools.blankImage(width, height, 
    321       readers[fno].getSizeC(files[fno]), readers[fno].getPixelType(files[fno])); 
    322  
    323     //CTR TODO - come up with an API for Chris, for setting the axes for the 
    324     //various blocks (pretty easy -- just setAxisType(int num, int type) or 
    325     //something similar), and also the internal ordering within each file, 
    326     //but make it intelligible (only show the internal dimensions that actually 
    327     //have size > 1). Similar to the current VisBio API? 
     321    // return a blank image to cover for the fact that 
     322    // this file does not contain enough image planes 
     323    if (blank == null) { 
     324      blank = ImageTools.blankImage(width, height, 
     325        sizeC, getPixelType(currentId)); 
     326    } 
     327    return blank; 
    328328  } 
    329329 
     
    338338    } 
    339339 
    340     int bytes = 0; 
    341     switch (readers[fno].getPixelType(files[fno])) { 
    342       case FormatReader.INT8: 
    343       case FormatReader.UINT8: bytes = 1; break; 
    344       case FormatReader.INT16: 
    345       case FormatReader.UINT16: bytes = 2; break; 
    346       case FormatReader.INT32: 
    347       case FormatReader.UINT32: 
    348       case FormatReader.FLOAT: bytes = 4; break; 
    349       case FormatReader.DOUBLE: bytes = 8; break; 
    350     } 
    351     return new byte[width * height * bytes * readers[fno].getSizeC(files[fno])]; 
     340    // return a blank image to cover for the fact that 
     341    // this file does not contain enough image planes 
     342    int bytes = FormatReader.getBytesPerPixel(getPixelType(currentId)); 
     343    return new byte[width * height * bytes * sizeC]; 
    352344  } 
    353345 
     
    385377    } 
    386378    readers = null; 
     379    blank = null; 
    387380    currentId = null; 
    388381  } 
     
    410403    ignoreColorTable = ignore; 
    411404  } 
     405 
     406  /* @see IFormatReader#getIgnoreColorTable() */ 
     407  public boolean getIgnoreColorTable() { return ignoreColorTable; } 
    412408 
    413409  /* @see IFormatReader#setNormalize(boolean) */ 
     
    680676    // populate metadata store 
    681677    String f0 = files[0]; 
    682     int pixelType = reader.getPixelType(f0); 
     678    int pixelType = getPixelType(currentId); 
    683679    boolean little = reader.isLittleEndian(f0); 
    684680    MetadataStore s = reader.getMetadataStore(f0); 
  • trunk/loci/formats/FormatReader.java

    r1806 r1810  
    168168  // -- IFormatReader API methods -- 
    169169 
    170   /** Checks if the given block is a valid header for this file format. */ 
     170  /* @see IFormatReader#isThisType(byte[]) */ 
    171171  public abstract boolean isThisType(byte[] block); 
    172172 
    173   /** Determines the number of images in the given file. */ 
     173  /* @see IFormatReader#getImageCount(String) */ 
    174174  public abstract int getImageCount(String id) 
    175175    throws FormatException, IOException; 
    176176 
    177   /** Checks if the images in the file are RGB. */ 
     177  /* @see IFormatReader#isRGB(String) */ 
    178178  public abstract boolean isRGB(String id) 
    179179    throws FormatException, IOException; 
    180180 
    181   /** Get the size of the X dimension. */ 
     181  /* @see IFormatReader#getSizeX(String) */ 
    182182  public int getSizeX(String id) throws FormatException, IOException { 
    183183    if (!id.equals(currentId)) initFile(id); 
     
    185185  } 
    186186 
    187   /** Get the size of the Y dimension. */ 
     187  /* @see IFormatReader#getSizeY(String) */ 
    188188  public int getSizeY(String id) throws FormatException, IOException { 
    189189    if (!id.equals(currentId)) initFile(id); 
     
    191191  } 
    192192 
    193   /** Get the size of the Z dimension. */ 
     193  /* @see IFormatReader#getSizeZ(String) */ 
    194194  public int getSizeZ(String id) throws FormatException, IOException { 
    195195    if (!id.equals(currentId)) initFile(id); 
     
    197197  } 
    198198 
    199   /** Get the size of the C dimension. */ 
     199  /* @see IFormatReader#getSizeC(String) */ 
    200200  public int getSizeC(String id) throws FormatException, IOException { 
    201201    if (!id.equals(currentId)) initFile(id); 
     
    203203  } 
    204204 
    205   /** Get the size of the T dimension. */ 
     205  /* @see IFormatReader#getSizeT(String) */ 
    206206  public int getSizeT(String id) throws FormatException, IOException { 
    207207    if (!id.equals(currentId)) initFile(id); 
     
    229229  } 
    230230 
    231   /** Get the size of the X dimension for the thumbnail. */ 
     231  /* @see IFormatReader#getThumbSizeX(String) */ 
    232232  public int getThumbSizeX(String id) throws FormatException, IOException { 
    233233    return THUMBNAIL_DIMENSION; 
    234234  } 
    235235 
    236   /** Get the size of the Y dimension for the thumbnail. */ 
     236  /* @see IFormatReader#getThumbSizeY(String) */ 
    237237  public int getThumbSizeY(String id) throws FormatException, IOException { 
    238238    return THUMBNAIL_DIMENSION; 
     
    267267  } 
    268268 
    269   /** Returns whether or not the channels are interleaved. */ 
     269  /* @see IFormatReader#isInterleaved(String) */ 
    270270  public abstract boolean isInterleaved(String id) 
    271271    throws FormatException, IOException; 
    272272 
    273   /** Obtains the specified image from the given file. */ 
     273  /* @see IFormatReader#openImage(String, int) */ 
    274274  public abstract BufferedImage openImage(String id, int no) 
    275275    throws FormatException, IOException; 
    276276 
    277   /** 
    278    * Obtains the specified image from the given file as a byte array. 
    279    */ 
     277  /* @see IFormatReader#openBytes(String, int) */ 
    280278  public abstract byte[] openBytes(String id, int no) 
    281279    throws FormatException, IOException; 
    282280 
    283   /* @see FormatReader#openBytes(String, int, byte[]) */ 
     281  /* @see IFormatReader#openBytes(String, int, byte[]) */ 
    284282  public byte[] openBytes(String id, int no, byte[] buf) 
    285283    throws FormatException, IOException 
     
    289287  } 
    290288 
    291   /** Obtains a thumbnail for the specified image from the given file. */ 
     289  /* @see IFormatReader#openThumbImage(String, int) */ 
    292290  public BufferedImage openThumbImage(String id, int no) 
    293291    throws FormatException, IOException 
     
    297295  } 
    298296 
    299   /** 
    300    * Obtains a thumbnail for the specified image from the given file, 
    301    * as a byte array.  We assume that the thumbnail has the same number of 
    302    * channels as the original image.  If there is more than one channel, then 
    303    * the resulting byte array will be of the format "RRR...BBB...GGG...". 
    304    */ 
     297  /* @see IFormatReader#openThumbBytes(String, int) */ 
    305298  public byte[] openThumbBytes(String id, int no) 
    306299    throws FormatException, IOException 
     
    316309  } 
    317310 
    318   /** Closes the currently open file. */ 
     311  /* @see IFormatReader#close() */ 
    319312  public abstract void close() throws FormatException, IOException; 
    320313 
    321   /** Return the number of series in this file. */ 
     314  /* @see IFormatReader#getSeriesCount(String) */ 
    322315  public int getSeriesCount(String id) throws FormatException, IOException { 
    323316    if (!id.equals(currentId)) initFile(id); 
     
    325318  } 
    326319 
    327   /** Activates the specified series. */ 
     320  /* @see IFormatReader#setSeries(String, int) */ 
    328321  public void setSeries(String id, int no) throws FormatException, IOException { 
    329322    if (no < 0 || no >= getSeriesCount(id)) { 
     
    333326  } 
    334327 
    335   /** Returns the currently active series. */ 
     328  /* @see IFormatReader#getSeries(String) */ 
    336329  public int getSeries(String id) throws FormatException, IOException { 
    337330    if (!id.equals(currentId)) initFile(id); 
     
    339332  } 
    340333 
    341   /** Specify whether or not to ignore color tables, if present. */ 
     334  /* @see IFormatReader#setIgnoreColorTable(boolean) */ 
    342335  public void setIgnoreColorTable(boolean ignore) { 
    343336    ignoreColorTable = ignore; 
    344337  } 
    345338 
    346   /** Specify whether or not to normalize float data. */ 
     339  /* @see IFormatReader#getIgnoreColorTable() */ 
     340  public boolean getIgnoreColorTable() { 
     341    return ignoreColorTable; 
     342  } 
     343 
     344  /* @see IFormatReader#setNormalize(boolean) */ 
    347345  public void setNormalize(boolean normalize) { 
    348346    normalizeData = normalize; 
    349347  } 
    350348 
    351   /** Return true if we should normalize float data. */ 
    352   public boolean getNormalize() { return normalizeData; } 
    353  
    354   /** 
    355    * Swaps the dimensions according to the given dimension order.  If the given 
    356    * order is identical to the file's native order, then nothing happens. 
    357    */ 
     349  /* @see IFormatReader#getNormalize() */ 
     350  public boolean getNormalize() { 
     351    return normalizeData; 
     352  } 
     353 
     354  /* @see IFormatReader#swapDimensions(String, String) */ 
    358355  public void swapDimensions(String id, String order) 
    359356    throws FormatException, IOException 
     
    389386  } 
    390387 
    391   /** 
    392    * Gets the rasterized index corresponding 
    393    * to the given Z, C and T coordinates. 
    394    */ 
     388  /* @see IFormatReader#getIndex(String, int, int, int) */ 
    395389  public int getIndex(String id, int z, int c, int t) 
    396390    throws FormatException, IOException 
     
    399393  } 
    400394 
    401   /** 
    402    * Gets the Z, C and T coordinates corresponding 
    403    * to the given rasterized index value. 
    404    */ 
     395  /* @see IFormatReader#getZCTCoords(String, int) */ 
    405396  public int[] getZCTCoords(String id, int index) 
    406397    throws FormatException, IOException 
     
    409400  } 
    410401 
    411   /** 
    412    * Obtains the specified metadata field's value for the given file. 
    413    * 
    414    * @param field the name associated with the metadata field 
    415    * @return the value, or null if the field doesn't exist 
    416    */ 
     402  /* @see IFormatReader#getMetadataValue(String, String) */ 
    417403  public Object getMetadataValue(String id, String field) 
    418404    throws FormatException, IOException 
     
    422408  } 
    423409 
    424   /** 
    425    * Obtains the hashtable containing the metadata field/value pairs from 
    426    * the given file. 
    427    * 
    428    * @param id the filename 
    429    * @return the hashtable containing all metadata from the file 
    430    */ 
     410  /* @see IFormatReader#getMetadata */ 
    431411  public Hashtable getMetadata(String id) throws FormatException, IOException { 
    432412    if (!id.equals(currentId)) initFile(id); 
     
    434414  } 
    435415 
    436   /** 
    437    * Sets the default metadata store for this reader. 
    438    * 
    439    * @param store a metadata store implementation. 
    440    */ 
    441   public void setMetadataStore(MetadataStore store) { metadataStore = store; } 
    442  
    443   /** 
    444    * Retrieves the current metadata store for this reader. You can be 
    445    * assured that this method will <b>never</b> return a <code>null</code> 
    446    * metadata store. 
    447    * @return a metadata store implementation. 
    448    */ 
     416  /* @see IFormatReader#setMetadataStore(MetadataStore) */ 
     417  public void setMetadataStore(MetadataStore store) { 
     418    metadataStore = store; 
     419  } 
     420 
     421  /* @see IFormatReader#getMetadataStore(String) */ 
    449422  public MetadataStore getMetadataStore(String id) 
    450423    throws FormatException, IOException 
     
    454427  } 
    455428 
    456   /** 
    457    * Retrieves the current metadata store's root object. It is guaranteed that 
    458    * all file parsing has been performed by the reader prior to retrieval. 
    459    * Requests for a full populated root object should be made using this method. 
    460    * @param id a fully qualified path to the file. 
    461    * @return current metadata store's root object fully populated. 
    462    * @throws IOException if there is an IO error when reading the file specified 
    463    * by <code>path</code>. 
    464    * @throws FormatException if the file specified by <code>path</code> is of an 
    465    * unsupported type. 
    466    */ 
     429  /* @see IFormatReader#getMetadataStoreRoot(String) */ 
    467430  public Object getMetadataStoreRoot(String id) 
    468431    throws FormatException, IOException 
     
    952915  } 
    953916 
     917  /** 
     918   * Retrieves how many bytes per pixel the current plane or section has. 
     919   * @param type the pixel type as retrieved from 
     920   *   {@link IFormatReader#getPixelType(String)}. 
     921   * @return the number of bytes per pixel. 
     922   * @see IFormatReader#getPixelType(String) 
     923   */ 
     924  public static int getBytesPerPixel(int type) { 
     925    switch (type) { 
     926      case FormatReader.INT8: 
     927      case FormatReader.UINT8: 
     928        return 1; 
     929      case FormatReader.INT16: 
     930      case FormatReader.UINT16: 
     931        return 2; 
     932      case FormatReader.INT32: 
     933      case FormatReader.UINT32: 
     934      case FormatReader.FLOAT: 
     935        return 4; 
     936      case FormatReader.DOUBLE: 
     937        return 8; 
     938    } 
     939    throw new RuntimeException("Unknown type with id: '" + type + "'"); 
     940  } 
     941 
    954942} 
  • trunk/loci/formats/IFormatReader.java

    r1806 r1810  
    182182  int getSeries(String id) throws FormatException, IOException; 
    183183 
    184   /** Specify whether or not to ignore color tables, if present. */ 
     184  /** Specifies whether or not to ignore color tables, if present. */ 
    185185  void setIgnoreColorTable(boolean ignore); 
    186186 
    187   /** Specify whether or not to normalize float data. */ 
     187  /** Returns true if we should ignore color tables, if present. */ 
     188  boolean getIgnoreColorTable(); 
     189 
     190  /** Specifies whether or not to normalize float data. */ 
    188191  void setNormalize(boolean normalize); 
    189192 
    190   /** Return true if we should normalize float data. */ 
     193  /** Returns true if we should normalize float data. */ 
    191194  boolean getNormalize(); 
    192195 
     
    254257   * @return current metadata store's root object fully populated. 
    255258   * @throws IOException if there is an IO error when reading the file specified 
    256    * by <code>path</code>. 
     259   *   by <code>path</code>. 
    257260   * @throws FormatException if the file specified by <code>path</code> is of an 
    258    * unsupported type. 
     261   *   unsupported type. 
    259262   */ 
    260263  Object getMetadataStoreRoot(String id) throws FormatException, IOException; 
  • trunk/loci/formats/ImageReader.java

    r1809 r1810  
    3636/** 
    3737 * ImageReader is the master file format reader for all supported formats. 
     38 * It uses one instance of each reader subclass (specified in readers.txt) 
     39 * to identify file formats and read data. 
    3840 * 
    3941 * @author Curtis Rueden ctrueden at wisc.edu 
     
    184186  // -- IFormatReader API methods -- 
    185187 
    186   /** Checks if the given block is a valid header for an image file. */ 
     188  /* @see IFormatReader.isThisType(byte[]) */ 
    187189  public boolean isThisType(byte[] block) { 
    188190    for (int i=0; i<readers.length; i++) { 
     
    192194  } 
    193195 
    194   /** Determines the number of images in the given image file. */ 
     196  /* @see IFormatReader.getImageCount(String) */ 
    195197  public int getImageCount(String id) throws FormatException, IOException { 
    196198    return getReader(id).getImageCount(id); 
    197199  } 
    198200 
    199   /** Checks if the images in the file are RGB. */ 
     201  /* @see IFormatReader.isRGB(String) */ 
    200202  public boolean isRGB(String id) throws FormatException, IOException { 
    201203    return getReader(id).isRGB(id); 
    202204  } 
    203205 
    204   /** Get the size of the X dimension. */ 
     206  /* @see IFormatReader.getSizeX(String) */ 
    205207  public int getSizeX(String id) throws FormatException, IOException { 
    206208    return getReader(id).getSizeX(id); 
    207209  } 
    208210 
    209   /** Get the size of the Y dimension. */ 
     211  /* @see IFormatReader.getSizeY(String) */ 
    210212  public int getSizeY(String id) throws FormatException, IOException { 
    211213    return getReader(id).getSizeY(id); 
    212214  } 
    213215 
    214   /** Get the size of the Z dimension. */ 
     216  /* @see IFormatReader.getSizeZ(String) */ 
    215217  public int getSizeZ(String id) throws FormatException, IOException { 
    216218    return getReader(id).getSizeZ(id); 
    217219  } 
    218220 
    219   /** Get the size of the C dimension. */ 
     221  /* @see IFormatReader.getSizeC(String) */ 
    220222  public int getSizeC(String id) throws FormatException, IOException { 
    221223    return getReader(id).getSizeC(id); 
    222224  } 
    223225 
    224   /** Get the size of the T dimension. */ 
     226  /* @see IFormatReader.getSizeT(String) */ 
    225227  public int getSizeT(String id) throws FormatException, IOException { 
    226228    return getReader(id).getSizeT(id); 
     
    246248  } 
    247249 
    248   /** Get the size of the X dimension for the thumbnail. */ 
     250  /* @see IFormatReader#getThumbSizeX(String) */ 
    249251  public int getThumbSizeX(String id) throws FormatException, IOException { 
    250252    return getReader(id).getThumbSizeX(id); 
    251253  } 
    252254 
    253   /** Get the size of the Y dimension for the thumbnail. */ 
     255  /* @see IFormatReader#getThumbSizeY(String) */ 
    254256  public int getThumbSizeY(String id) throws FormatException, IOException { 
    255257    return getReader(id).getThumbSizeY(id); 
    256258  } 
    257259 
    258   /** Return true if the data is in little-endian format. */ 
     260  /* @see IFormatReader#isLittleEndian(String) */ 
    259261  public boolean isLittleEndian(String id) throws FormatException, IOException { 
    260262    return getReader(id).isLittleEndian(id); 
     
    286288  } 
    287289 
    288   /** Returns whether or not the channels are interleaved. */ 
     290  /* @see IFormatReader#isInterleaved(String) */ 
    289291  public boolean isInterleaved(String id) throws FormatException, IOException { 
    290292    return getReader(id).isInterleaved(id); 
    291293  } 
    292294 
    293   /** Obtains the specified image from the given image file. */ 
     295  /* @see IFormatReader#openImage(String, int) */ 
    294296  public BufferedImage openImage(String id, int no) 
    295297    throws FormatException, IOException 
     
    298300  } 
    299301 
    300   /** Obtains the specified image from the given image file as a byte array. */ 
     302  /* @see IFormatReader#openBytes(String, int) */ 
    301303  public byte[] openBytes(String id, int no) 
    302304    throws FormatException, IOException 
     
    312314  } 
    313315 
    314   /** Obtains a thumbnail for the specified image from the given file. */ 
     316  /* @see IFormatReader#openThumbImage(String, int) */ 
    315317  public BufferedImage openThumbImage(String id, int no) 
    316318    throws FormatException, IOException 
     
    319321  } 
    320322 
    321   /** 
    322    * Obtains a thumbnail for the specified image from the given file, 
    323    * as a byte array.  We assume that the thumbnail has the same number of 
    324    * channels as the original image.  If there is more than one channel, then 
    325    * the resulting byte array will be of the format "RRR...BBB...GGG...". 
    326    */ 
     323  /* @see IFormatReader#openThumbBytes(String, int) */ 
    327324  public byte[] openThumbBytes(String id, int no) 
    328325    throws FormatException, IOException 
     
    331328  } 
    332329 
    333   /** Closes any open files. */ 
     330  /* @see IFormatReader#close() */ 
    334331  public void close() throws FormatException, IOException { 
    335332    for (int i=0; i<readers.length; i++) readers[i].close(); 
    336333  } 
    337334 
    338   /** Gets the number of series in the file. */ 
     335  /* @see IFormatReader#getSeriesCount(String) */ 
    339336  public int getSeriesCount(String id) throws FormatException, IOException { 
    340337    return getReader(id).getSeriesCount(id); 
    341338  } 
    342339 
    343   /** Activates the specified series. */ 
     340  /* @see IFormatReader#setSeries(String, int) */ 
    344341  public void setSeries(String id, int no) throws FormatException, IOException { 
    345342    getReader(id).setSeries(id, no); 
    346343  } 
    347344 
    348   /** Gets the currently active series. */ 
     345  /* @see IFormatReader#getSeries(String) */ 
    349346  public int getSeries(String id) throws FormatException, IOException { 
    350347    return getReader(id).getSeries(id); 
     
    356353  } 
    357354 
     355  /* @see IFormatReader#getIgnoreColorTable() */ 
     356  public boolean getIgnoreColorTable() { 
     357    return readers[0].getIgnoreColorTable(); 
     358  } 
     359 
    358360  /* @see IFormatReader#setNormalize(boolean) */ 
    359361  public void setNormalize(boolean normalize) { 
     
    362364 
    363365  /* @see IFormatReader#getNormalize() */ 
    364   public boolean getNormalize() { return readers[0].getNormalize(); } 
    365  
    366   /** 
    367    * Swaps the dimensions according to the given dimension order.  If the given 
    368    * order is identical to the file's native order, then nothing happens. 
    369    */ 
     366  public boolean getNormalize() { 
     367    return readers[0].getNormalize(); 
     368  } 
     369 
     370  /* @see IFormatReader#swapDimensions(String, String) */ 
    370371  public void swapDimensions(String id, String order) 
    371372    throws FormatException, IOException 
     
    374375  } 
    375376 
    376   /* 
    377    * @see IFormatReader#getIndex(String, int, int, int) 
    378    */ 
     377  /* @see IFormatReader#getIndex(String, int, int, int) */ 
    379378  public int getIndex(String id, int z, int c, int t) 
    380379    throws FormatException, IOException 
     
    390389  } 
    391390 
    392   /** 
    393    * Obtains the specified metadata field's value for the given file. 
    394    * 
    395    * @param field the name associated with the metadata field 
    396    * @return the value, or null if the field doesn't exist 
    397    */ 
     391  /* @see IFormatReader#getMetadataValue(String, String) */ 
    398392  public Object getMetadataValue(String id, String field) 
    399393    throws FormatException, IOException 
     
    402396  } 
    403397 
    404   /** 
    405    * Obtains the hashtable containing the metadata field/value pairs from 
    406    * the given file. 
    407    * 
    408    * @param id the filename 
    409    * @return the hashtable containing all metadata from the file 
    410    */ 
     398  /* @see IFormatReader#getMetadata(String) */ 
    411399  public Hashtable getMetadata(String id) throws FormatException, IOException { 
    412400    return getReader(id).getMetadata(id); 
     
    434422  } 
    435423 
    436   /** 
    437    * A utility method for test reading a file from the command line, 
    438    * and displaying the results in a simple display. 
    439    */ 
     424  /* @see IFormatReader#testRead(String[]) */ 
    440425  public boolean testRead(String[] args) throws FormatException, IOException { 
    441426    if (args.length == 0) { 
     
    452437  // -- IFormatHandler API methods -- 
    453438 
    454   /** 
    455    * Checks if the given string is a valid filename for any supported format. 
    456    */ 
     439  /* @see IFormatHandler#isThisType(String) */ 
    457440  public boolean isThisType(String name) { 
    458441    // NB: Unlike individual format readers, ImageReader defaults to *not* 
     
    462445  } 
    463446 
    464   /** 
    465    * Checks if the given string is a valid filename for any supported format. 
    466    * @param open If true, and the file extension is insufficient to determine 
    467    *   the file type, the (existing) file is opened for further analysis. 
    468    */ 
     447  /* @see IFormatHandler#isThisType(String, boolean) */ 
    469448  public boolean isThisType(String name, boolean open) { 
    470449    for (int i=0; i<readers.length; i++) { 
     
    534513  } 
    535514 
    536   // -- Utility methods -- 
    537  
    538   /** 
    539    * Retrieves how many bytes per pixel the current plane or section has. 
    540    * @param type the pixel type as retrieved from 
    541    *   {@link IFormatReader#getPixelType(String)}. 
    542    * @return the number of bytes per pixel. 
    543    * @see IFormatReader#getPixelType(String) 
    544    */ 
    545   public static int getBytesPerPixel(int type) { 
    546     switch (type) { 
    547       case FormatReader.INT8: 
    548       case FormatReader.UINT8: 
    549         return 1; 
    550       case FormatReader.INT16: 
    551       case FormatReader.UINT16: 
    552         return 2; 
    553       case FormatReader.INT32: 
    554       case FormatReader.UINT32: 
    555       case FormatReader.FLOAT: 
    556         return 4; 
    557       case FormatReader.DOUBLE: 
    558         return 8; 
    559     } 
    560     throw new RuntimeException("Unknown type with id: '" + type + "'"); 
    561   } 
    562  
    563515  // -- Main method -- 
    564516 
  • trunk/loci/formats/ImageWriter.java

    r1786 r1810  
    3535 
    3636/** 
    37  * ImageWriter is master file format writer for all supported formats. 
     37 * ImageWriter is the master file format writer for all supported formats. 
     38 * It uses one instance of each writer subclass (specified in writers.txt) 
     39 * to identify file formats based on extension and write data. 
    3840 * 
    3941 * @author Curtis Rueden ctrueden at wisc.edu 
     
    180182  // -- IFormatWriter API methods -- 
    181183 
    182   /** 
    183    * Saves the given image to the specified (possibly already open) file. 
    184    * If this image is the last one in the file, the last flag must be set. 
    185    */ 
     184  /* @see IFormatWriter#save(String, Image, boolean) */ 
    186185  public void save(String id, Image image, boolean last) 
    187186    throws FormatException, IOException 
     
    190189  } 
    191190 
    192   /** Reports whether the writer can save multiple images to a single file. */ 
     191  /* @see IFormatWriter#canDoStacks(String) */ 
    193192  public boolean canDoStacks(String id) throws FormatException { 
    194193    return getWriter(id).canDoStacks(id); 
    195194  } 
    196195 
    197   /** Sets the color model. */ 
     196  /* @see IFormatWriter#setColorModel(ColorModel) */ 
    198197  public void setColorModel(ColorModel cm) { 
    199198    for (int i=0; i<writers.length; i++) writers[i].setColorModel(cm); 
    200199  } 
    201200 
    202   /** Gets the color model. */ 
     201  /* @see IFormatWriter#getColorModel() */ 
    203202  public ColorModel getColorModel() { 
    204203    // NB: all writers should have the same color model 
     
    206205  } 
    207206 
    208   /** Sets the frames per second to use when writing. */ 
     207  /* @see IFormatWriter#setFramesPerSecond(int) */ 
    209208  public void setFramesPerSecond(int rate) { 
    210209    for (int i=0; i<writers.length; i++) writers[i].setFramesPerSecond(rate); 
    211210  } 
    212211 
    213   /** Gets the frames per second to use when writing. */ 
     212  /* @see IFormatWriter#getFramesPerSecond() */ 
    214213  public int getFramesPerSecond() { 
    215214    // NB: all writers should have the same frames per second 
     
    217216  } 
    218217 
    219   /** Gets the available compression types. */ 
     218  /* @see IFormatWriter#getCompressionTypes() */ 
    220219  public String[] getCompressionTypes() { 
    221220    if (compressionTypes == null) { 
     
    232231  } 
    233232 
    234   /** Sets the current compression type. */ 
     233  /* @see IFormatWriter#setCompression(String) */ 
    235234  public void setCompression(String compress) throws FormatException { 
    236235    boolean ok = false; 
     
    248247  } 
    249248 
    250   /** A utility method for converting a file from the command line. */ 
     249  /* @see IFormatWriter#testConvert(String[]) */ 
    251250  public boolean testConvert(String[] args) 
    252251    throws FormatException, IOException 
     
    262261  // -- IFormatHandler API methods -- 
    263262 
    264   /** Checks if the given string is a valid filename for this file format. */ 
     263  /* @see IFormatHandler#isThisType(String) */ 
    265264  public boolean isThisType(String name) { 
    266265    // NB: Unlike individual format writers, ImageWriter defaults to *not* 
     
    270269  } 
    271270 
    272   /** 
    273    * Checks if the given string is a valid filename for any supported format. 
    274    * @param open If true, and the file extension is insufficient to determine 
    275    *   the file type, the (existing) file is opened for further analysis. 
    276    */ 
     271  /* @see IFormatHandler#isThisType(String, boolean) */ 
    277272  public boolean isThisType(String name, boolean open) { 
    278273    for (int i=0; i<writers.length; i++) { 
     
    282277  } 
    283278 
    284   /** Gets the name of this file format. */ 
     279  /* @see IFormatHandler#getFormat() */ 
    285280  public String getFormat() { return "image"; } 
    286281 
    287   /** Gets the default file suffixes for this file format. */ 
     282  /* @see IFormatHandler#getSuffixes() */ 
    288283  public String[] getSuffixes() { 
    289284    if (suffixes == null) { 
     
    300295  } 
    301296 
    302   /** Gets file filters for this file format, for use with a JFileChooser. */ 
     297  /* @see IFormatHandler#getFileFilters() */ 
    303298  public FileFilter[] getFileFilters() { 
    304299    if (filters == null) { 
     
    313308  } 
    314309 
    315   /** Gets a JFileChooser that recognizes accepted file types. */ 
     310  /* @see IFormatHandler#getFileChooser() */ 
    316311  public JFileChooser getFileChooser() { 
    317312    if (chooser == null) { 
  • trunk/loci/formats/ReaderWrapper.java

    r1806 r1810  
    194194  } 
    195195 
     196  public boolean getIgnoreColorTable() { 
     197    return reader.getIgnoreColorTable(); 
     198  } 
     199 
    196200  public void setNormalize(boolean normalize) { 
    197201    reader.setNormalize(normalize); 
  • trunk/loci/formats/in/BaseTiffReader.java

    r1806 r1810  
    3030import java.nio.ShortBuffer; 
    3131import java.util.Hashtable; 
    32 import loci.formats.DataTools; 
    33 import loci.formats.FormatException; 
    34 import loci.formats.FormatReader; 
    35 import loci.formats.ImageReader; 
    36 import loci.formats.MetadataStore; 
    37 import loci.formats.RandomAccessStream; 
    38 import loci.formats.TiffRational; 
    39 import loci.formats.TiffTools; 
     32import loci.formats.*; 
    4033 
    4134/** 
     
    769762    } 
    770763 
    771     int bytesPerPixel = ImageReader.getBytesPerPixel(getPixelType(id)); 
     764    int bytesPerPixel = FormatReader.getBytesPerPixel(getPixelType(id)); 
    772765    byte[] buf = new byte[getSizeX(id) * getSizeY(id) * getSizeC(id) * 
    773766      bytesPerPixel]; 
  • trunk/loci/formats/in/Plane2D.java

    r1511 r1810  
    2828import java.nio.ByteOrder; 
    2929import loci.formats.FormatReader; 
    30 import loci.formats.ImageReader; 
    3130 
    3231/** 
     
    7170      ByteOrder.LITTLE_ENDIAN : ByteOrder.BIG_ENDIAN); 
    7271 
    73     this.bytesPerPixel = ImageReader.getBytesPerPixel(type); 
     72    this.bytesPerPixel = FormatReader.getBytesPerPixel(type); 
    7473  } 
    7574 
Note: See TracChangeset for help on using the changeset viewer.