Search in sources :

Example 21 with ServiceFactory

use of loci.common.services.ServiceFactory in project bioformats by openmicroscopy.

the class Upgrade201004Test method setUp.

@BeforeMethod
public void setUp() throws Exception {
    ServiceFactory sf = new ServiceFactory();
    service = sf.getInstance(OMEXMLService.class);
    InputStream s = Upgrade201004Test.class.getResourceAsStream(XML_FILE);
    byte[] b = new byte[s.available()];
    s.read(b);
    s.close();
    xml = new String(b);
    metadata = service.createOMEXMLMetadata(xml);
    ome = (OME) metadata.getRoot();
}
Also used : ServiceFactory(loci.common.services.ServiceFactory) InputStream(java.io.InputStream) OMEXMLService(loci.formats.services.OMEXMLService) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 22 with ServiceFactory

use of loci.common.services.ServiceFactory in project bioformats by openmicroscopy.

the class Upgrade201006Test method setUp.

@BeforeMethod
public void setUp() throws Exception {
    ServiceFactory sf = new ServiceFactory();
    service = sf.getInstance(OMEXMLService.class);
    InputStream s = Upgrade201006Test.class.getResourceAsStream(XML_FILE);
    byte[] b = new byte[s.available()];
    s.read(b);
    s.close();
    xml = new String(b);
    metadata = service.createOMEXMLMetadata(xml);
    ome = (OME) metadata.getRoot();
}
Also used : ServiceFactory(loci.common.services.ServiceFactory) InputStream(java.io.InputStream) OMEXMLService(loci.formats.services.OMEXMLService) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 23 with ServiceFactory

use of loci.common.services.ServiceFactory in project bioformats by openmicroscopy.

the class DumpOMEXML method dumpOMEXML.

public static void dumpOMEXML(String path) throws FormatException, IOException, DependencyException, ServiceException {
    ServiceFactory serviceFactory = new ServiceFactory();
    OMEXMLService omexmlService = serviceFactory.getInstance(OMEXMLService.class);
    IMetadata meta = omexmlService.createOMEXMLMetadata();
    ImageReader r = new ImageReader();
    r.setMetadataStore(meta);
    r.setOriginalMetadataPopulated(true);
    r.setId(path);
    r.close();
    String xml = omexmlService.getOMEXML(meta);
    System.out.println(xml);
}
Also used : IMetadata(loci.formats.meta.IMetadata) ServiceFactory(loci.common.services.ServiceFactory) ImageReader(loci.formats.ImageReader) OMEXMLService(loci.formats.services.OMEXMLService)

Example 24 with ServiceFactory

use of loci.common.services.ServiceFactory in project bioformats by openmicroscopy.

the class EditImageName method main.

public static void main(String[] args) throws Exception {
    if (args.length != 1) {
        System.out.println("Usage: java EditImageName file");
        return;
    }
    ImageReader reader = new ImageReader();
    // record metadata to OME-XML format
    ServiceFactory factory = new ServiceFactory();
    OMEXMLService service = factory.getInstance(OMEXMLService.class);
    IMetadata omexmlMeta = service.createOMEXMLMetadata();
    reader.setMetadataStore(omexmlMeta);
    String id = args[0];
    System.out.print("Reading metadata ");
    reader.setId(id);
    System.out.println(" [done]");
    // get image name
    String name = omexmlMeta.getImageName(0);
    System.out.println("Initial Image name = " + name);
    // change image name (reverse it)
    char[] arr = name.toCharArray();
    for (int i = 0; i < arr.length / 2; i++) {
        int i2 = arr.length - i - 1;
        char c = arr[i];
        char c2 = arr[i2];
        arr[i] = c2;
        arr[i2] = c;
    }
    name = new String(arr);
    // save altered name back to OME-XML structure
    omexmlMeta.setImageName(name, 0);
    System.out.println("Updated Image name = " + name);
    // output full OME-XML block
    System.out.println("Full OME-XML dump:");
    String xml = service.getOMEXML(omexmlMeta);
    System.out.println(xml);
}
Also used : IMetadata(loci.formats.meta.IMetadata) ServiceFactory(loci.common.services.ServiceFactory) ImageReader(loci.formats.ImageReader) OMEXMLService(loci.formats.services.OMEXMLService)

Example 25 with ServiceFactory

use of loci.common.services.ServiceFactory in project bioformats by openmicroscopy.

the class FV1000Reader method initPOIService.

private void initPOIService() throws FormatException, IOException {
    try {
        ServiceFactory factory = new ServiceFactory();
        poi = factory.getInstance(POIService.class);
    } catch (DependencyException de) {
        throw new FormatException("POI library not found", de);
    }
    poi.initialize(Location.getMappedId(getCurrentFile()));
}
Also used : ServiceFactory(loci.common.services.ServiceFactory) POIService(loci.formats.services.POIService) DependencyException(loci.common.services.DependencyException) FormatException(loci.formats.FormatException)

Aggregations

ServiceFactory (loci.common.services.ServiceFactory)94 OMEXMLService (loci.formats.services.OMEXMLService)73 DependencyException (loci.common.services.DependencyException)49 FormatException (loci.formats.FormatException)38 IMetadata (loci.formats.meta.IMetadata)35 ServiceException (loci.common.services.ServiceException)30 ImageReader (loci.formats.ImageReader)23 MissingLibraryException (loci.formats.MissingLibraryException)15 BeforeMethod (org.testng.annotations.BeforeMethod)15 MetadataStore (loci.formats.meta.MetadataStore)14 PositiveInteger (ome.xml.model.primitives.PositiveInteger)14 IOException (java.io.IOException)13 CoreMetadata (loci.formats.CoreMetadata)13 Length (ome.units.quantity.Length)12 Location (loci.common.Location)11 OMEXMLMetadata (loci.formats.ome.OMEXMLMetadata)10 InputStream (java.io.InputStream)9 ArrayList (java.util.ArrayList)8 MetadataRetrieve (loci.formats.meta.MetadataRetrieve)8 BeforeClass (org.testng.annotations.BeforeClass)8