Changeset 6994


Ignore:
Timestamp:
09/28/10 10:44:26 (9 years ago)
Author:
melissa
Message:

Merged GUI tools changes: r6766 and r6774.

Location:
branches/4.2
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/4.2

  • branches/4.2/components/bio-formats/src/loci/formats/gui/ImageViewer.java

    r6525 r6994  
    7070import loci.formats.IFormatWriter; 
    7171import loci.formats.ImageWriter; 
     72import loci.formats.MetadataTools; 
     73import loci.formats.meta.IMetadata; 
    7274import loci.formats.meta.MetadataRetrieve; 
    7375import loci.formats.meta.MetadataStore; 
    7476import loci.formats.services.OMEReaderWriterService; 
    7577import loci.formats.services.OMEXMLService; 
     78 
     79import ome.xml.model.enums.DimensionOrder; 
     80import ome.xml.model.enums.EnumerationException; 
     81import ome.xml.model.enums.PixelType; 
     82import ome.xml.model.enums.handlers.DimensionOrderEnumHandler; 
     83import ome.xml.model.enums.handlers.PixelTypeEnumHandler; 
     84import ome.xml.model.primitives.PositiveInteger; 
    7685 
    7786import org.slf4j.Logger; 
     
    362371      //Location f = new Location(id); 
    363372      //id = f.getAbsolutePath(); 
    364       try { 
    365         myReader.setMetadataStore(omexmlService.createOMEXMLMetadata()); 
    366       } 
    367       catch (ServiceException exc) { 
    368         LOGGER.info("OME metadata unavailable", exc); 
     373      IMetadata meta = null; 
     374      if (omexmlService != null) { 
     375        try { 
     376          meta = omexmlService.createOMEXMLMetadata(); 
     377          myReader.setMetadataStore(meta); 
     378        } 
     379        catch (ServiceException exc) { 
     380          LOGGER.debug("Could not create OME-XML metadata", exc); 
     381        } 
     382      } 
     383      if (meta == null) { 
     384        LOGGER.info("OME metadata unavailable"); 
    369385      } 
    370386      myReader.setId(id); 
     
    407423    wait(true); 
    408424    try { 
     425      if (omeMeta == null) { 
     426        omeMeta = omexmlService.createOMEXMLMetadata(); 
     427        omeMeta.setImageID(MetadataTools.createLSID("Image", 0), 0); 
     428        omeMeta.setPixelsID(MetadataTools.createLSID("Pixels", 0), 0); 
     429        omeMeta.setPixelsBinDataBigEndian(false, 0, 0); 
     430 
     431        String order = "XYCZT"; 
     432        if (in != null) order = in.getDimensionOrder(); 
     433 
     434        omeMeta.setPixelsDimensionOrder((DimensionOrder) 
     435          new DimensionOrderEnumHandler().getEnumeration(order), 0); 
     436        int type = AWTImageTools.getPixelType(images[0]); 
     437        String pixelType = FormatTools.getPixelTypeString(type); 
     438        omeMeta.setPixelsType( 
     439          (PixelType) new PixelTypeEnumHandler().getEnumeration(pixelType), 0); 
     440 
     441        int nBands = images[0].getRaster().getNumBands(); 
     442        int rgbChannelCount = (sizeC * sizeZ * sizeT) / nBands; 
     443        int realChannelCount = sizeC / rgbChannelCount; 
     444 
     445        for (int i=0; i<realChannelCount; i++) { 
     446          omeMeta.setChannelID(MetadataTools.createLSID("Channel", i, 0), i, 0); 
     447          omeMeta.setChannelSamplesPerPixel( 
     448            new PositiveInteger(rgbChannelCount), i, 0); 
     449        } 
     450 
     451        omeMeta.setPixelsSizeX(new PositiveInteger(images[0].getWidth()), 0); 
     452        omeMeta.setPixelsSizeY(new PositiveInteger(images[0].getHeight()), 0); 
     453        omeMeta.setPixelsSizeC(new PositiveInteger(sizeC), 0); 
     454        omeMeta.setPixelsSizeZ(new PositiveInteger(sizeZ), 0); 
     455        omeMeta.setPixelsSizeT(new PositiveInteger(sizeT), 0); 
     456      } 
     457      myWriter.setMetadataRetrieve(omexmlService.asRetrieve(omeMeta)); 
    409458      myWriter.setId(id); 
    410459      boolean stack = myWriter.canDoStacks(); 
     
    416465          progress.setProgress(i); 
    417466          boolean canceled = progress.isCanceled(); 
    418           myWriter.savePlane(i, images[i]); 
     467          myWriter.saveImage(i, images[i]); 
    419468          if (canceled) break; 
    420469        } 
     
    430479    catch (FormatException exc) { LOGGER.info("", exc); } 
    431480    catch (IOException exc) { LOGGER.info("", exc); } 
     481    catch (ServiceException exc) { LOGGER.info("", exc); } 
     482    catch (EnumerationException exc) { LOGGER.info("", exc); } 
    432483    wait(false); 
    433484  } 
  • branches/4.2/components/bio-formats/src/loci/formats/in

  • branches/4.2/components/bio-formats/src/loci/formats/tiff

  • branches/4.2/components/loci-plugins

  • branches/4.2/components/loci-plugins/src/loci/plugins

  • branches/4.2/components/loci-plugins/src/loci/plugins/in/Calibrator.java

  • branches/4.2/components/ome-xml

Note: See TracChangeset for help on using the changeset viewer.