use of ome.xml.model.MapPair in project bioformats by openmicroscopy.
the class FakeReader method fillAnnotations.
private void fillAnnotations(MetadataStore store, int imageIndex) {
int annotationRefCount = 0;
String annotationID;
for (int i = 0; i < annBool; i++) {
annotationID = ANNOTATION_PREFIX + annotationCount;
store.setBooleanAnnotationID(annotationID, annotationBoolCount);
store.setBooleanAnnotationNamespace(ANNOTATION_NAMESPACE, annotationBoolCount);
store.setBooleanAnnotationValue(ANN_BOOLEAN_VALUE, annotationBoolCount);
store.setImageAnnotationRef(annotationID, imageIndex, annotationRefCount);
annotationBoolCount++;
annotationCount++;
annotationRefCount++;
}
for (int i = 0; i < annComment; i++) {
annotationID = ANNOTATION_PREFIX + annotationCount;
store.setCommentAnnotationID(annotationID, annotationCommentCount);
store.setCommentAnnotationNamespace(ANNOTATION_NAMESPACE, annotationCommentCount);
store.setCommentAnnotationValue(ANN_COMMENT_VALUE + (annotationCount + 1), annotationCommentCount);
store.setImageAnnotationRef(annotationID, imageIndex, annotationRefCount);
annotationCommentCount++;
annotationCount++;
annotationRefCount++;
}
for (int i = 0; i < annDouble; i++) {
annotationID = ANNOTATION_PREFIX + annotationCount;
store.setDoubleAnnotationID(annotationID, annotationDoubleCount);
store.setDoubleAnnotationNamespace(ANNOTATION_NAMESPACE, annotationDoubleCount);
store.setDoubleAnnotationValue(ANN_DOUBLE_VALUE * (annotationCount + 1), annotationDoubleCount);
store.setImageAnnotationRef(annotationID, imageIndex, annotationRefCount);
annotationDoubleCount++;
annotationCount++;
annotationRefCount++;
}
for (int i = 0; i < annLong; i++) {
annotationID = ANNOTATION_PREFIX + annotationCount;
store.setLongAnnotationID(annotationID, annotationLongCount);
store.setLongAnnotationNamespace(ANNOTATION_NAMESPACE, annotationLongCount);
store.setLongAnnotationValue(ANN_LONG_VALUE + annotationCount, annotationLongCount);
store.setImageAnnotationRef(annotationID, imageIndex, annotationRefCount);
annotationLongCount++;
annotationCount++;
annotationRefCount++;
}
for (int i = 0; i < annMap; i++) {
annotationID = ANNOTATION_PREFIX + annotationCount;
store.setMapAnnotationID(annotationID, annotationMapCount);
store.setMapAnnotationNamespace(ANNOTATION_NAMESPACE, annotationMapCount);
List<MapPair> mapValue = new ArrayList<MapPair>();
for (int keyNum = 0; keyNum < 10; keyNum++) {
mapValue.add(new MapPair("keyS" + imageIndex + "N" + keyNum, "val" + (keyNum + 1) * (annotationCount + 1)));
}
store.setMapAnnotationValue(mapValue, annotationMapCount);
store.setImageAnnotationRef(annotationID, imageIndex, annotationRefCount);
annotationMapCount++;
annotationCount++;
annotationRefCount++;
}
for (int i = 0; i < annTag; i++) {
annotationID = ANNOTATION_PREFIX + annotationCount;
store.setTagAnnotationID(annotationID, annotationTagCount);
store.setTagAnnotationNamespace(ANNOTATION_NAMESPACE, annotationTagCount);
store.setTagAnnotationValue(ANN_TAG_VALUE + (annotationCount + 1), annotationTagCount);
store.setImageAnnotationRef(annotationID, imageIndex, annotationRefCount);
annotationTagCount++;
annotationCount++;
annotationRefCount++;
}
for (int i = 0; i < annTerm; i++) {
annotationID = ANNOTATION_PREFIX + annotationCount;
store.setTermAnnotationID(annotationID, annotationTermCount);
store.setTermAnnotationNamespace(ANNOTATION_NAMESPACE, annotationTermCount);
store.setTermAnnotationValue(ANN_TERM_VALUE + (annotationCount + 1), annotationTermCount);
store.setImageAnnotationRef(annotationID, imageIndex, annotationRefCount);
annotationTermCount++;
annotationCount++;
annotationRefCount++;
}
for (int i = 0; i < annTime; i++) {
annotationID = ANNOTATION_PREFIX + annotationCount;
store.setTimestampAnnotationID(annotationID, annotationTimeCount);
store.setTimestampAnnotationNamespace(ANNOTATION_NAMESPACE, annotationTimeCount);
store.setTimestampAnnotationValue(ANN_TIME_VALUE, annotationTimeCount);
store.setImageAnnotationRef(annotationID, imageIndex, annotationRefCount);
annotationTimeCount++;
annotationCount++;
annotationRefCount++;
}
for (int i = 0; i < annXml; i++) {
annotationID = ANNOTATION_PREFIX + annotationCount;
store.setXMLAnnotationID(annotationID, annotationXmlCount);
store.setXMLAnnotationNamespace(ANNOTATION_NAMESPACE, annotationXmlCount);
store.setXMLAnnotationValue(ANN_XML_VALUE_START + (annotationCount + 1) + ANN_XML_VALUE_END, annotationXmlCount);
store.setImageAnnotationRef(annotationID, imageIndex, annotationRefCount);
annotationXmlCount++;
annotationCount++;
annotationRefCount++;
}
}
use of ome.xml.model.MapPair in project bioformats by openmicroscopy.
the class MapAnnotationTest method testMapAnnotationValueContent.
@Test
public void testMapAnnotationValueContent() throws Exception {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder parser = factory.newDocumentBuilder();
Document document = parser.newDocument();
// Produce a valid OME DOM element hierarchy
Element root = ome.asXMLElement(document);
SPWModelMock.postProcess(root, document, false);
OMEModel model = new OMEModelImpl();
ome = new OME(document.getDocumentElement(), model);
model.resolveReferences();
assertNotNull(ome);
assertEquals(ome.getImage(0).getPixels().getID(), "Pixels:0");
assertNotNull(ome.getImage(0).getLinkedAnnotation(0));
MapAnnotation mapAnnotation = (MapAnnotation) ome.getImage(0).getLinkedAnnotation(0);
List<MapPair> dataMap = mapAnnotation.getValue();
assertEquals(6, dataMap.size());
assertEquals("a", dataMap.get(0).getName());
assertEquals("1", dataMap.get(0).getValue());
assertEquals("d", dataMap.get(1).getName());
assertEquals("2", dataMap.get(1).getValue());
assertEquals("c", dataMap.get(2).getName());
assertEquals("3", dataMap.get(2).getValue());
assertEquals("b", dataMap.get(3).getName());
assertEquals("4", dataMap.get(3).getValue());
assertEquals("e", dataMap.get(4).getName());
assertEquals("5", dataMap.get(4).getValue());
assertEquals("c", dataMap.get(5).getName());
assertEquals("6", dataMap.get(5).getValue());
}
use of ome.xml.model.MapPair in project bioformats by openmicroscopy.
the class GenericExcitationMapTest method setUp.
@BeforeClass
public void setUp() throws Exception {
Instrument instrument = new Instrument();
instrument.setID("Instrument:0");
// Add a GenericExcitationSource with an Map
GenericExcitationSource geSource = new GenericExcitationSource();
geSource.setID("LightSource:0");
List<MapPair> dataMap = new ArrayList<MapPair>();
dataMap.add(new MapPair("a", "1"));
dataMap.add(new MapPair("d", "2"));
dataMap.add(new MapPair("c", "3"));
dataMap.add(new MapPair("b", "4"));
dataMap.add(new MapPair("e", "5"));
dataMap.add(new MapPair("c", "6"));
assertEquals(6, dataMap.size());
geSource.setMap(dataMap);
instrument.addLightSource(geSource);
ome.addInstrument(instrument);
// Add an Image/Pixels with a LightSourceSettings reference to the
// GenericExcitationSource on one of its channels.
Image image = new Image();
image.setID("Image:0");
Pixels pixels = new Pixels();
pixels.setID("Pixels:0");
Channel channel = new Channel();
channel.setID("Channel:0");
LightSourceSettings settings = new LightSourceSettings();
settings.setID("LightSource:0");
channel.setLightSourceSettings(settings);
pixels.addChannel(channel);
image.setPixels(pixels);
ome.addImage(image);
}
Aggregations