Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { p.add(new MapPair(((Element) child).getAttribute("K"), child.getTextContent()));
public static List<NamedValue> convertMapPairs(List<ome.xml.model.MapPair> map) { if (map == null) { return null; } final List<NamedValue> nvl = new ArrayList<NamedValue>(map.size()); for (final ome.xml.model.MapPair nv : map) { if (nv == null) { nvl.add(null); } else { final String name = nv.getName(); final String value = nv.getValue(); nvl.add(new NamedValue(name, value)); } } return nvl; }
protected Element asXMLElement(Document document, Element GenericExcitationSource_element) { // Creating XML block for GenericExcitationSource if (GenericExcitationSource_element == null) { GenericExcitationSource_element = document.createElementNS(NAMESPACE, "GenericExcitationSource"); } if (map != null) { // Element property Map which is complex (has // sub-elements) Element map_child = document.createElementNS(NAMESPACE, "Map"); for (MapPair entry: map) { Element pair = document.createElementNS(NAMESPACE, "M"); pair.setAttribute("K", entry.getName()); pair.setTextContent(entry.getValue()); map_child.appendChild(pair); } GenericExcitationSource_element.appendChild(map_child); } return super.asXMLElement(document, GenericExcitationSource_element); } }
Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { p.add(new MapPair(((Element) child).getAttribute("K"), child.getTextContent()));
Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { p.add(new MapPair(((Element) child).getAttribute("K"), child.getTextContent()));
Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { p.add(new MapPair(((Element) child).getAttribute("K"), child.getTextContent()));
@Override public String dumpXML() { // insert resolution data as an annotation // TODO: doesn't allow for updating resolutions if (!written) { int annIndex = 0; try { annIndex = getMapAnnotationCount(); } catch (NullPointerException e) { // just means there are no other map annotations } for (int i=0; i<resolutions.size(); i++) { List<MapPair> resAnnotation = new ArrayList<MapPair>(); for (int r=1; r<resolutions.get(i).size(); r++) { resAnnotation.add( new MapPair(String.valueOf(r), resolutions.get(i).get(r).toString())); } String mapId = "Annotation:Resolution:" + i; setMapAnnotationID(mapId, annIndex); setMapAnnotationNamespace(NAMESPACE, annIndex); setMapAnnotationValue(resAnnotation, annIndex); annIndex++; } written = true; } return super.dumpXML(); }
@Override public void setRoot(MetadataRoot root) { super.setRoot(root); // look for resolution data annotation int mapCount = 0; try { mapCount = getMapAnnotationCount(); } catch (NullPointerException e) { // no map annotations } for (int i=0; i<mapCount; i++) { if (NAMESPACE.equals(getMapAnnotationNamespace(i))) { List<MapPair> resAnnotation = getMapAnnotationValue(i); List<Resolution> r = new ArrayList<Resolution>(); r.add(new Resolution()); for (MapPair p : resAnnotation) { int index = Integer.parseInt(p.getName()); if (index == r.size()) { r.add(new Resolution(p.getValue())); } else LOGGER.warn("Out of order"); } resolutions.add(r); written = true; } } }
@Override public String dumpXML() { // insert resolution data as an annotation // TODO: doesn't allow for updating resolutions if (!written) { int annIndex = 0; try { annIndex = getMapAnnotationCount(); } catch (NullPointerException e) { // just means there are no other map annotations } for (int i=0; i<resolutions.size(); i++) { List<MapPair> resAnnotation = new ArrayList<MapPair>(); for (int r=1; r<resolutions.get(i).size(); r++) { resAnnotation.add( new MapPair(String.valueOf(r), resolutions.get(i).get(r).toString())); } String mapId = "Annotation:Resolution:" + i; setMapAnnotationID(mapId, annIndex); setMapAnnotationNamespace(NAMESPACE, annIndex); setMapAnnotationValue(resAnnotation, annIndex); annIndex++; } written = true; } return super.dumpXML(); }
@Override public void setRoot(MetadataRoot root) { super.setRoot(root); // look for resolution data annotation int mapCount = 0; try { mapCount = getMapAnnotationCount(); } catch (NullPointerException e) { // no map annotations } for (int i=0; i<mapCount; i++) { if (NAMESPACE.equals(getMapAnnotationNamespace(i))) { List<MapPair> resAnnotation = getMapAnnotationValue(i); List<Resolution> r = new ArrayList<Resolution>(); r.add(new Resolution()); for (MapPair p : resAnnotation) { int index = Integer.parseInt(p.getName()); if (index == r.size()) { r.add(new Resolution(p.getValue())); } else LOGGER.warn("Out of order"); } resolutions.add(r); written = true; } } }
Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { p.add(new MapPair(((Element) child).getAttribute("K"), child.getTextContent()));
Node child = children.item(i); if (child.getNodeType() == Node.ELEMENT_NODE) { p.add(new MapPair(((Element) child).getAttribute("K"), child.getTextContent()));
@BeforeClass public void setUp() throws Exception { // Add an Image/Pixels Image image = new Image(); image.setID("Image:0"); Pixels pixels = new Pixels(); pixels.setID("Pixels:0"); image.setPixels(pixels); // Add an ImagingEnvironment with an Map ImagingEnvironment imagingEnvironment = new ImagingEnvironment(); List<MapPair> map = new ArrayList<MapPair>(); map.add(new MapPair("a", "1")); map.add(new MapPair("d", "2")); map.add(new MapPair("c", "3")); map.add(new MapPair("b", "4")); map.add(new MapPair("e", "5")); map.add(new MapPair("c", "6")); assertEquals(6, map.size()); imagingEnvironment.setMap(map); image.setImagingEnvironment(imagingEnvironment); ome.addImage(image); }
@BeforeClass public void setUp() throws Exception { // Add an Image/Pixels Image image = new Image(); image.setID("Image:0"); Pixels pixels = new Pixels(); pixels.setID("Pixels:0"); image.setPixels(pixels); // Add a Map Annotation List<MapPair> map = new ArrayList<MapPair>(); map.add(new MapPair("a", "1")); map.add(new MapPair("d", "2")); map.add(new MapPair("c", "3")); map.add(new MapPair("b", "4")); map.add(new MapPair("e", "5")); map.add(new MapPair("c", "6")); MapAnnotation mapAnnotation = new MapAnnotation(); mapAnnotation.setID("Annotation:0"); mapAnnotation.setValue(map); StructuredAnnotations structuredAnnotations = new StructuredAnnotations(); structuredAnnotations.addMapAnnotation(mapAnnotation); ome.setStructuredAnnotations(structuredAnnotations ); image.linkAnnotation(mapAnnotation); ome.addImage(image); }