Changeset 1294


Ignore:
Timestamp:
08/18/06 13:28:35 (14 years ago)
Author:
curtis
Message:

Whitespace and formatting.

Location:
trunk/loci/formats
Files:
6 edited

Legend:

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

    r1284 r1294  
    3333 
    3434/** Abstract superclass of all biological file format readers. */ 
    35 public abstract class FormatReader extends FormatHandler implements IFormatReader { 
     35public abstract class FormatReader extends FormatHandler 
     36  implements IFormatReader 
     37{ 
    3638 
    3739  // -- Constants -- 
     
    420422    if (id == null) { 
    421423      String className = reader.getClass().getName(); 
    422       System.out.println("To test read a file in " + reader.getFormat() + " format, run:"); 
     424      System.out.println("To test read a file in " + 
     425        reader.getFormat() + " format, run:"); 
    423426      System.out.println("  java " + className + " [-nopix]"); 
    424427      System.out.println("    [-merge] [-stitch] [-separate] [-omexml] file"); 
  • trunk/loci/formats/IFormatReader.java

    r1264 r1294  
    134134   */ 
    135135  Hashtable getMetadata(String id) throws FormatException, IOException; 
    136    
     136 
    137137  /** 
    138138   * Sets the default metadata store for this reader. 
  • trunk/loci/formats/ImageReader.java

    r1264 r1294  
    5151  /** List of reader classes. */ 
    5252  private static Class[] readerClasses; 
    53    
     53 
    5454  /** Name of current file. */ 
    5555  private String currentId; 
    56    
     56 
    5757  /** Valid suffixes for this file format. */ 
    5858  private String[] suffixes; 
    59    
     59 
    6060  // -- Static initializer -- 
    6161 
     
    433433    return suffixes; 
    434434  } 
    435    
     435 
    436436  /** 
    437437   * Checks if the given string is a valid filename for any supported format. 
     
    457457    throw new FormatException("Unknown file format: " + id); 
    458458  } 
    459    
     459 
    460460  /** 
    461461   * Retrieves the reader that the ImageReader proxy is currently using or the 
    462462   * valid reader for a given file. 
    463    *  
     463   * 
    464464   * @param id path to a file. 
    465465   * @return the current active reader unless <i>id</i> is not the current 
     
    475475    return currentReader(); 
    476476  } 
    477    
     477 
    478478  /** 
    479479   * Retrieves the reader that the ImageReader proxy is currently using. 
    480    *  
     480   * 
    481481   * @return the current active reader. 
    482482   */ 
  • trunk/loci/formats/TiffIFDEntry.java

    r1282 r1294  
     1// 
     2// TiffIFDEntry.java 
     3// 
     4 
     5/* 
     6LOCI Bio-Formats package for reading and converting biological file formats. 
     7Copyright (C) 2005-@year@ Melissa Linkert, Curtis Rueden, Chris Allan 
     8and Eric Kjellman. 
     9 
     10This program is free software; you can redistribute it and/or modify 
     11it under the terms of the GNU Library General Public License as published by 
     12the Free Software Foundation; either version 2 of the License, or 
     13(at your option) any later version. 
     14 
     15This program is distributed in the hope that it will be useful, 
     16but WITHOUT ANY WARRANTY; without even the implied warranty of 
     17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
     18GNU Library General Public License for more details. 
     19 
     20You should have received a copy of the GNU Library General Public License 
     21along with this program; if not, write to the Free Software 
     22Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
     23*/ 
     24 
    125package loci.formats; 
    226 
     
    933 */ 
    1034public class TiffIFDEntry { 
    11         /** The <i>Tag</i> that identifies the field. */ 
    12         private int tag; 
    13          
    14         /** The field <i>Type</i>. */ 
    15         private int type; 
    16          
    17         /** The number of values, <i>Count</i> of the indicated <i>Type</i>. */ 
    18         private int valueCount; 
    19          
    20         /** 
    21          * The <i>Value Offset</i>, the file offset (in bytes) of the <i>Value</i> 
    22          * for the field. 
    23          */ 
    24         private int valueOffset; 
    25          
    26         public TiffIFDEntry (int tag, int type, int valueCount, int valueOffset) 
    27         { 
    28                 this.tag = tag; 
    29                 this.type = type; 
    30                 this.valueCount = valueCount; 
    31                 this.valueOffset = valueOffset; 
    32         } 
    3335 
    34         /** 
    35          * Retrieves the entry's <i>Tag<i> value. 
    36          * @return the entry's <i>Tag<i> value. 
    37          */ 
    38         public int getTag() { 
    39                 return tag; 
    40         } 
     36  /** The <i>Tag</i> that identifies the field. */ 
     37  private int tag; 
    4138 
    42         /** 
    43          * Retrieves the entry's <i>Type<i> value. 
    44          * @return the entry's <i>Type<i> value. 
    45          */ 
    46         public int getType() { 
    47                 return type; 
    48         } 
     39  /** The field <i>Type</i>. */ 
     40  private int type; 
    4941 
    50         /** 
    51          * Retrieves the entry's <i>ValueCount<i> value. 
    52          * @return the entry's <i>ValueCount<i> value. 
    53          */ 
    54         public int getValueCount() { 
    55                 return valueCount; 
    56         } 
     42  /** The number of values, <i>Count</i> of the indicated <i>Type</i>. */ 
     43  private int valueCount; 
    5744 
    58         /** 
    59          * Retrieves the entry's <i>ValueOffset<i> value. 
    60          * @return the entry's <i>ValueOffset<i> value. 
    61          */ 
    62         public int getValueOffset() { 
    63                 return valueOffset; 
    64         } 
     45  /** 
     46   * The <i>Value Offset</i>, the file offset (in bytes) of the <i>Value</i> 
     47   * for the field. 
     48   */ 
     49  private int valueOffset; 
     50 
     51  public TiffIFDEntry (int tag, int type, int valueCount, int valueOffset) { 
     52    this.tag = tag; 
     53    this.type = type; 
     54    this.valueCount = valueCount; 
     55    this.valueOffset = valueOffset; 
     56  } 
     57 
     58  /** 
     59   * Retrieves the entry's <i>Tag</i> value. 
     60   * @return the entry's <i>Tag</i> value. 
     61   */ 
     62  public int getTag() { return tag; } 
     63 
     64  /** 
     65   * Retrieves the entry's <i>Type</i> value. 
     66   * @return the entry's <i>Type</i> value. 
     67   */ 
     68  public int getType() { return type; } 
     69 
     70  /** 
     71   * Retrieves the entry's <i>ValueCount</i> value. 
     72   * @return the entry's <i>ValueCount</i> value. 
     73   */ 
     74  public int getValueCount() { return valueCount; } 
     75 
     76  /** 
     77   * Retrieves the entry's <i>ValueOffset</i> value. 
     78   * @return the entry's <i>ValueOffset</i> value. 
     79   */ 
     80  public int getValueOffset() { return valueOffset; } 
     81 
    6582} 
  • trunk/loci/formats/TiffTools.java

    r1282 r1294  
    4242 
    4343  public static final boolean DEBUG = false; 
    44    
     44 
    4545  /** The number of bytes in each IFD entry. */ 
    4646  public static final int BYTES_PER_ENTRY = 12; 
     
    291291    return getIFD(in, 0, globalOffset, offset); 
    292292  } 
    293    
     293 
    294294  /** 
    295295   * Retrieve a given entry from the first IFD in a stream. 
    296    *  
     296   * 
    297297   * @param in the stream to retrieve the entry from. 
    298298   * @param tag the tag of the entry to be retrieved. 
     
    302302   */ 
    303303  public static TiffIFDEntry getFirstIFDEntry (RandomAccessStream in, int tag) 
    304         throws IOException 
    305   { 
    306           // First lets re-position the file pointer by checking the TIFF header 
    307           Boolean result = checkHeader(in, 0); 
    308           if (result == null) return null; 
    309  
    310           // Get the offset of the first IFD 
    311           long offset = getFirstOffset(in); 
    312            
    313           // The following loosly resembles the logic of getIFD()... 
    314           in.seek(offset); 
    315           int numEntries = in.readShort(); 
    316           if (numEntries < 0) numEntries += 65536; 
    317            
    318           for (int i = 0; i < numEntries; i++) { 
    319               in.seek(offset // The beginning of the IFD 
    320                           + 2    // The width of the initial numEntries field 
    321                           + (BYTES_PER_ENTRY * i)); 
    322                
    323               int entryTag = in.readShort(); 
    324               if (entryTag < 0) entryTag += 65536; 
    325                
    326               // Skip this tag unless it matches the one we want 
    327               if (entryTag != tag) continue; 
    328                
    329               // Parse the entry's "Type" 
    330               int entryType = in.readShort(); 
    331               if (entryType < 0) entryType += 65536; 
    332                
    333               // Parse the entry's "ValueCount" 
    334               int valueCount = in.readInt(); 
    335               if (valueCount < 0) 
    336                   throw new RuntimeException( 
    337                                   "Count of '" + valueCount + "' unexpected."); 
    338  
    339               // Parse the entry's "ValueOffset" 
    340               int valueOffset = in.readInt(); 
    341                
    342               return new TiffIFDEntry(entryTag, entryType, valueCount, valueOffset); 
    343           } 
    344           throw new UnknownTagException(); 
     304    throws IOException 
     305  { 
     306    // First lets re-position the file pointer by checking the TIFF header 
     307    Boolean result = checkHeader(in, 0); 
     308    if (result == null) return null; 
     309 
     310    // Get the offset of the first IFD 
     311    long offset = getFirstOffset(in); 
     312 
     313    // The following loosly resembles the logic of getIFD()... 
     314    in.seek(offset); 
     315    int numEntries = in.readShort(); 
     316    if (numEntries < 0) numEntries += 65536; 
     317 
     318    for (int i = 0; i < numEntries; i++) { 
     319      in.seek(offset + // The beginning of the IFD 
     320        2 + // The width of the initial numEntries field 
     321        (BYTES_PER_ENTRY * i)); 
     322 
     323      int entryTag = in.readShort(); 
     324      if (entryTag < 0) entryTag += 65536; 
     325 
     326      // Skip this tag unless it matches the one we want 
     327      if (entryTag != tag) continue; 
     328 
     329      // Parse the entry's "Type" 
     330      int entryType = in.readShort(); 
     331      if (entryType < 0) entryType += 65536; 
     332 
     333      // Parse the entry's "ValueCount" 
     334      int valueCount = in.readInt(); 
     335      if (valueCount < 0) 
     336        throw new RuntimeException( 
     337            "Count of '" + valueCount + "' unexpected."); 
     338 
     339      // Parse the entry's "ValueOffset" 
     340      int valueOffset = in.readInt(); 
     341 
     342      return new TiffIFDEntry(entryTag, entryType, valueCount, valueOffset); 
     343    } 
     344    throw new UnknownTagException(); 
    345345  } 
    346346 
     
    965965    int[] colorMap = getIFDIntArray(ifd, COLOR_MAP, false); 
    966966    int predictor = getIFDIntValue(ifd, PREDICTOR, false, 1); 
    967      
     967 
    968968    // If the subsequent color maps are empty, use the first IFD's color map 
    969969    if (colorMap == null) 
  • trunk/loci/formats/UnknownTagException.java

    r1282 r1294  
    33/** 
    44 * Thrown when a given entry does not have a particular tag. 
    5  *  
     5 * 
    66 * @author Chris Allan callan at blackcat.ca 
    77 */ 
Note: See TracChangeset for help on using the changeset viewer.