Changeset 6445


Ignore:
Timestamp:
06/02/10 13:38:28 (9 years ago)
Author:
curtis
Message:

Fix getCoreMetadata with ReaderWrapper implementations.

Location:
trunk/components/bio-formats/src/loci/formats
Files:
4 edited

Legend:

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

    r6422 r6445  
    3131 * For indexed color data representing true color, factors out 
    3232 * the indices, replacing them with the color table values directly. 
    33  *  
     33 * 
    3434 * For all other data (either non-indexed, or indexed with 
    3535 * "false color" tables), does nothing. 
  • trunk/components/bio-formats/src/loci/formats/CoreMetadata.java

    r6141 r6445  
    3434 */ 
    3535public class CoreMetadata { 
     36 
     37  // -- Fields -- 
     38 
    3639  // TODO 
    3740  // 
    38   // We may also want to consider refactoring the FormatReader getter methods 
     41  // We may want to consider refactoring the FormatReader getter methods 
    3942  // that populate missing CoreMetadata fields on the fly 
    4043  // (getChannelDimLengths, getChannelDimTypes, getThumbSizeX, getThumbSizeY) 
     
    135138  public boolean thumbnail; 
    136139 
     140  // -- Constructors -- 
     141 
    137142  public CoreMetadata() { 
    138143    seriesMetadata = new Hashtable<String, Object>(); 
    139144  } 
    140145 
     146  public CoreMetadata(IFormatReader r, int seriesNo) { 
     147    int series = r.getSeries(); 
     148    r.setSeries(seriesNo); 
     149    sizeX = r.getSizeX(); 
     150    sizeY = r.getSizeY(); 
     151    sizeZ = r.getSizeZ(); 
     152    sizeC = r.getSizeC(); 
     153    sizeT = r.getSizeT(); 
     154    thumbSizeX = r.getThumbSizeX(); 
     155    thumbSizeY = r.getThumbSizeY(); 
     156    pixelType = r.getPixelType(); 
     157    bitsPerPixel = r.getBitsPerPixel(); 
     158    imageCount = r.getImageCount(); 
     159    cLengths = r.getChannelDimLengths(); 
     160    cTypes = r.getChannelDimTypes(); 
     161    dimensionOrder = r.getDimensionOrder(); 
     162    orderCertain = r.isOrderCertain(); 
     163    rgb = r.isRGB(); 
     164    littleEndian = r.isLittleEndian(); 
     165    interleaved = r.isInterleaved(); 
     166    indexed = r.isIndexed(); 
     167    falseColor = r.isFalseColor(); 
     168    metadataComplete = r.isMetadataComplete(); 
     169    seriesMetadata = r.getSeriesMetadata(); 
     170    thumbnail = r.isThumbnailSeries(); 
     171    r.setSeries(series); 
     172  } 
     173 
     174  // -- Object methods -- 
     175 
     176  public String toString() { 
     177    StringBuilder sb = new StringBuilder(); 
     178    sb.append(super.toString() + ":"); 
     179    sb.append("\n\tsizeX = " + sizeX); 
     180    sb.append("\n\tsizeY = " + sizeY); 
     181    sb.append("\n\tsizeZ = " + sizeZ); 
     182    sb.append("\n\tsizeC = " + sizeC); 
     183    sb.append("\n\tsizeT = " + sizeT); 
     184    sb.append("\n\tthumbSizeX = " + thumbSizeX); 
     185    sb.append("\n\tthumbSizeY = " + thumbSizeY); 
     186    sb.append("\n\tpixelType = " + FormatTools.getPixelTypeString(pixelType)); 
     187    sb.append("\n\tbitsPerPixel = " + bitsPerPixel); 
     188    sb.append("\n\timageCount = " + imageCount); 
     189    sb.append("\n\tcLengths ="); 
     190    if (cLengths == null) sb.append(" null"); 
     191    else for (int i=0; i<cLengths.length; i++) sb.append(" " + cLengths[i]); 
     192    sb.append("\n\tcTypes ="); 
     193    if (cTypes == null) sb.append(" null"); 
     194    else for (int i=0; i<cTypes.length; i++) sb.append(" " + cTypes[i]); 
     195    sb.append("\n\tdimensionOrder = " + dimensionOrder); 
     196    sb.append("\n\torderCertain = " + orderCertain); 
     197    sb.append("\n\trgb = " + rgb); 
     198    sb.append("\n\tlittleEndian = " + littleEndian); 
     199    sb.append("\n\tinterleaved = " + interleaved); 
     200    sb.append("\n\tindexed = " + indexed); 
     201    sb.append("\n\tfalseColor = " + falseColor); 
     202    sb.append("\n\tmetadataComplete = " + metadataComplete); 
     203    sb.append("\n\tseriesMetadata = " + seriesMetadata.size() + " keys"); 
     204    sb.append("\n\tthumbnail = " + thumbnail); 
     205    return sb.toString(); 
     206  } 
     207 
    141208} 
  • trunk/components/bio-formats/src/loci/formats/DimensionSwapper.java

    r6262 r6445  
    4646    return new DimensionSwapper(r); 
    4747  } 
     48 
     49  // -- Fields -- 
     50 
     51  /** Core metadata associated with this dimension swapper. */ 
     52  private CoreMetadata[] core; 
    4853 
    4954  // -- Constructors -- 
     
    105110    int[] dims = new int[5]; 
    106111 
     112    System.out.println("---> swapDims: old order = " + oldOrder + ", new order = " + order);//TEMP 
    107113    int oldX = oldOrder.indexOf("X"); 
    108114    int oldY = oldOrder.indexOf("Y"); 
     
    123129 
    124130    int series = getSeries(); 
    125     CoreMetadata[] core = getCoreMetadata(); 
    126131 
    127132    core[series].sizeX = dims[newX]; 
     
    163168  public String getInputOrder() { 
    164169    FormatTools.assertId(getCurrentFile(), true, 2); 
    165     return getCoreMetadata()[getSeries()].dimensionOrder; 
     170    System.out.println("---> HERE WE ARE IN getInputOrder... series=" + getSeries() + ", core=" + core[getSeries()]);//TEMP 
     171    return core[getSeries()].dimensionOrder; 
    166172  } 
    167173 
     
    171177  public int getSizeX() { 
    172178    FormatTools.assertId(getCurrentFile(), true, 2); 
    173     return getCoreMetadata()[getSeries()].sizeX; 
     179    return core[getSeries()].sizeX; 
    174180  } 
    175181 
     
    177183  public int getSizeY() { 
    178184    FormatTools.assertId(getCurrentFile(), true, 2); 
    179     return getCoreMetadata()[getSeries()].sizeY; 
     185    return core[getSeries()].sizeY; 
    180186  } 
    181187 
     
    183189  public int getSizeZ() { 
    184190    FormatTools.assertId(getCurrentFile(), true, 2); 
    185     return getCoreMetadata()[getSeries()].sizeZ; 
     191    return core[getSeries()].sizeZ; 
    186192  } 
    187193 
     
    189195  public int getSizeC() { 
    190196    FormatTools.assertId(getCurrentFile(), true, 2); 
    191     return getCoreMetadata()[getSeries()].sizeC; 
     197    return core[getSeries()].sizeC; 
    192198  } 
    193199 
     
    195201  public int getSizeT() { 
    196202    FormatTools.assertId(getCurrentFile(), true, 2); 
    197     return getCoreMetadata()[getSeries()].sizeT; 
     203    return core[getSeries()].sizeT; 
    198204  } 
    199205 
     
    201207  public int[] getChannelDimLengths() { 
    202208    FormatTools.assertId(getCurrentFile(), true, 2); 
    203     int[] cLengths = getCoreMetadata()[getSeries()].cLengths; 
     209    int[] cLengths = core[getSeries()].cLengths; 
    204210    return cLengths == null ? super.getChannelDimLengths() : cLengths; 
    205211  } 
     
    208214  public String[] getChannelDimTypes() { 
    209215    FormatTools.assertId(getCurrentFile(), true, 2); 
    210     String[] cTypes = getCoreMetadata()[getSeries()].cTypes; 
     216    String[] cTypes = core[getSeries()].cTypes; 
    211217    return cTypes == null ? super.getChannelDimTypes() : cTypes; 
    212218  } 
     
    215221  public String getDimensionOrder() { 
    216222    FormatTools.assertId(getCurrentFile(), true, 2); 
    217     if (outputOrder[getSeries()] != null) return outputOrder[getSeries()]; 
     223    String outOrder = outputOrder[getSeries()]; 
     224    if (outOrder != null) return outOrder; 
    218225    return getInputOrder(); 
    219226  } 
     
    258265  public int getIndex(int z, int c, int t) { 
    259266    return FormatTools.getIndex(this, z, c, t); 
     267  } 
     268 
     269  /* @see IFormatReader#getCoreMetadata() */ 
     270  @Override 
     271  public CoreMetadata[] getCoreMetadata() { 
     272    FormatTools.assertId(getCurrentFile(), true, 2); 
     273    return core; 
    260274  } 
    261275 
     
    270284    { 
    271285      outputOrder = new String[getSeriesCount()]; 
     286 
     287      // NB: Create our own copy of the CoreMetadata, 
     288      // which we can manipulate safely. 
     289      core = copyCoreMetadata(reader); 
     290      System.out.println("----> core metadata copied... dimOrder=" + core[0].dimensionOrder);//TEMP 
     291      System.out.println("----> wrapped reader's dimOrder=" + reader.getDimensionOrder());//TEMP 
    272292    } 
    273293  } 
  • trunk/components/bio-formats/src/loci/formats/ReaderWrapper.java

    r6301 r6445  
    353353  public boolean isNormalized() { return reader.isNormalized(); } 
    354354 
    355   /** @deprecated */ 
    356   public void setMetadataCollected(boolean collect) { 
    357     reader.setMetadataCollected(collect); 
    358   } 
    359  
    360   /** @deprecated */ 
    361   public boolean isMetadataCollected() { return reader.isMetadataCollected(); } 
    362  
    363355  public void setOriginalMetadataPopulated(boolean populate) { 
    364356    reader.setOriginalMetadataPopulated(populate); 
     
    415407  } 
    416408 
    417   /** @deprecated */ 
    418   public Hashtable<String, Object> getMetadata() { 
    419     return reader.getMetadata(); 
    420   } 
    421  
    422409  public CoreMetadata[] getCoreMetadata() { 
    423     return reader.getCoreMetadata(); 
     410    //return reader.getCoreMetadata(); 
     411 
     412    // NB: Be sure all CoreMetadata values are returned correctly, 
     413    // regardless of any method overrides. 
     414    return copyCoreMetadata(this); 
    424415  } 
    425416 
     
    539530  } 
    540531 
     532  // -- Deprecated methods -- 
     533 
     534 
     535  /** @deprecated */ 
     536  public void setMetadataCollected(boolean collect) { 
     537    reader.setMetadataCollected(collect); 
     538  } 
     539 
     540  /** @deprecated */ 
     541  public boolean isMetadataCollected() { return reader.isMetadataCollected(); } 
     542 
     543  /** @deprecated */ 
     544  public Hashtable<String, Object> getMetadata() { 
     545    return reader.getMetadata(); 
     546  } 
     547 
     548  // -- Helper methods -- 
     549 
     550  /** Creates a copy of the core metadata matching to the given reader state. */ 
     551  protected CoreMetadata[] copyCoreMetadata(IFormatReader r) { 
     552    CoreMetadata[] core = new CoreMetadata[r.getSeriesCount()]; 
     553    for (int s=0; s<core.length; s++) core[s] = new CoreMetadata(r, s); 
     554    return core; 
     555  } 
     556 
    541557} 
Note: See TracChangeset for help on using the changeset viewer.