Changeset 3169 for trunk


Ignore:
Timestamp:
09/17/07 16:27:52 (12 years ago)
Author:
curtis
Message:

Update code to use most recent API.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/utils/EditImageName.java

    r3121 r3169  
    44 
    55import loci.formats.ImageReader; 
     6import loci.formats.MetadataTools; 
    67import loci.formats.ome.OMEXMLMetadata; 
    7 import org.openmicroscopy.xml.ImageNode; 
    8 import org.openmicroscopy.xml.OMENode; 
    98 
    109/** Edits the given file's image name (but does not save back to disk). */ 
     
    2221    System.out.print("Reading metadata "); 
    2322    reader.setId(id);  
    24     OMEXMLMetadata store = (OMEXMLMetadata) reader.getMetadataStore(); 
     23    OMEXMLMetadata omexmlMeta = (OMEXMLMetadata) reader.getMetadataStore(); 
    2524    System.out.println(" [done]"); 
    26     // get OME root node 
    27     OMENode ome = (OMENode) store.getRoot(); 
    28     // get first Image node 
    29     ImageNode image = (ImageNode) ome.getImages().get(0); 
    30     // get Image name 
    31     String name = image.getName(); 
     25 
     26    // get image name 
     27    Integer zero = new Integer(0); 
     28    String name = omexmlMeta.getImageName(zero); 
    3229    System.out.println("Initial Image name = " + name); 
    33     // change Image name (reverse it) 
     30    // change image name (reverse it) 
    3431    char[] arr = name.toCharArray(); 
    3532    for (int i=0; i<arr.length/2; i++) { 
     
    4239    name = new String(arr); 
    4340    // save altered name back to OME-XML structure 
    44     image.setName(name); 
     41    omexmlMeta.setImage(name, null, null, zero); 
    4542    System.out.println("Updated Image name = " + name); 
    4643    // output full OME-XML block 
    4744    System.out.println("Full OME-XML dump:"); 
    48     System.out.println(ome.writeOME(false)); 
     45    System.out.println(MetadataTools.getOMEXML(omexmlMeta)); 
    4946  } 
    5047 
Note: See TracChangeset for help on using the changeset viewer.