Changeset 6029


Ignore:
Timestamp:
03/16/10 13:29:45 (10 years ago)
Author:
melissa
Message:
  • Prevent an NPE in PhotoshopTiffReader.isThisType(RandomAccessInputStream).
  • Prepend the tag number to DICOM metadata keys.
  • Only prepend a series label to metadata keys in ImageJ if multiple series are being opened.
Location:
trunk/components
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/components/bio-formats/src/loci/formats/in/DicomReader.java

    r6026 r6029  
    834834 
    835835      if (((tag & 0xffff0000) >> 16) != 0x7fe0) { 
     836        key = formatTag(tag) + " " + key; 
    836837        if (metadata.containsKey(key)) { 
    837838          // make sure that values are not overwritten 
     
    11701171      } 
    11711172    } 
     1173  } 
     1174 
     1175  private String formatTag(int tag) { 
     1176    String s = Integer.toHexString(tag); 
     1177    while (s.length() < 8) { 
     1178      s = "0" + s; 
     1179    } 
     1180    return s.substring(0, 4) + "," + s.substring(4); 
    11721181  } 
    11731182 
  • trunk/components/bio-formats/src/loci/formats/in/PhotoshopTiffReader.java

    r6026 r6029  
    8686  public boolean isThisType(RandomAccessInputStream stream) throws IOException { 
    8787    TiffParser tp = new TiffParser(stream); 
    88     return tp.getFirstIFD().containsKey(IMAGE_SOURCE_DATA); 
     88    IFD ifd = tp.getFirstIFD(); 
     89    if (ifd == null) return false; 
     90    return ifd.containsKey(IMAGE_SOURCE_DATA); 
    8991  } 
    9092 
  • trunk/components/loci-plugins/src/loci/plugins/importer/ImporterMetadata.java

    r6022 r6029  
    4646  // -- Constructor -- 
    4747 
    48   public ImporterMetadata(IFormatReader r, ImporterOptions options) { 
     48  public ImporterMetadata(IFormatReader r, ImporterOptions options, 
     49    boolean usePrefix) 
     50  { 
    4951    // merge global metadata 
    5052    putAll(r.getGlobalMetadata()); 
     
    6163 
    6264      // build prefix from image name and/or series number 
    63       String s = options.getOMEMetadata().getImageName(i); 
    64       if ((s == null || s.trim().length() == 0) && seriesCount > 1) { 
    65         StringBuffer sb = new StringBuffer(); 
    66         sb.append("Series "); 
    67         int zeroes = digits - digits(i + 1); 
    68         for (int j=0; j<zeroes; j++) sb.append(0); 
    69         sb.append(i + 1); 
    70         sb.append(" "); 
    71         s = sb.toString(); 
     65      String s = ""; 
     66      if (usePrefix) { 
     67        s = options.getOMEMetadata().getImageName(i); 
     68        if ((s == null || s.trim().length() == 0) && seriesCount > 1) { 
     69          StringBuffer sb = new StringBuffer(); 
     70          sb.append("Series "); 
     71          int zeroes = digits - digits(i + 1); 
     72          for (int j=0; j<zeroes; j++) sb.append(0); 
     73          sb.append(i + 1); 
     74          sb.append(" "); 
     75          s = sb.toString(); 
     76        } 
     77        else s += " "; 
    7278      } 
    73       else s += " "; 
    7479 
    7580      // merge series metadata 
  • trunk/components/loci-plugins/src/loci/plugins/importer/ImporterOptions.java

    r6022 r6029  
    481481  /** Initializes the ImporterMetadata derived value. */ 
    482482  private void initializeMetadata() { 
    483     metadata = new ImporterMetadata(reader.r, this); 
     483    // only prepend a series name prefix to the metadata keys if multiple 
     484    // series are being opened 
     485    int seriesCount = 0; 
     486    for (int i=0; i<series.length; i++) { 
     487      if (series[i]) seriesCount++; 
     488    } 
     489    metadata = new ImporterMetadata(reader.r, this, seriesCount > 1); 
    484490  } 
    485491 
Note: See TracChangeset for help on using the changeset viewer.