use of ome.xml.model.primitives.NonNegativeInteger in project bioformats by openmicroscopy.
the class CellWorxReader method initFile.
// -- Internal FormatReader API methods --
/* @see loci.formats.FormatReader#initFile(String) */
@Override
protected void initFile(String id) throws FormatException, IOException {
if (!checkSuffix(id, "htd")) {
LOGGER.info("Searching for .htd file");
String base = new Location(id).getAbsolutePath();
base = base.substring(0, base.lastIndexOf("_"));
id = base + ".HTD";
if (!new Location(id).exists()) {
Location parent = new Location(id).getAbsoluteFile().getParentFile();
directoryList = parent.list(true);
for (String f : directoryList) {
if (checkSuffix(f, "htd")) {
id = new Location(parent, f).getAbsolutePath();
LOGGER.info("Found .htd file {}", f);
break;
}
}
}
}
super.initFile(id);
try {
ServiceFactory factory = new ServiceFactory();
service = factory.getInstance(OMEXMLService.class);
} catch (DependencyException exc) {
throw new FormatException("Could not create OME-XML store.", exc);
}
String plateData = DataTools.readFile(id);
String[] lines = plateData.split("\n");
int xWells = 0, yWells = 0;
int xFields = 0, yFields = 0;
String[] wavelengths = null;
int nTimepoints = 1;
// determine dataset dimensions
for (String line : lines) {
int split = line.indexOf("\",");
if (split < 1)
continue;
String key = line.substring(1, split).trim();
String value = line.substring(split + 2).trim();
if (key.equals("XWells")) {
xWells = Integer.parseInt(value);
} else if (key.equals("YWells")) {
yWells = Integer.parseInt(value);
wellFiles = new String[yWells][xWells][];
logFiles = new String[yWells][xWells];
} else if (key.startsWith("WellsSelection")) {
int row = Integer.parseInt(key.substring(14)) - 1;
String[] mapping = value.split(",");
for (int col = 0; col < xWells; col++) {
if (new Boolean(mapping[col].trim()).booleanValue()) {
wellFiles[row][col] = new String[1];
}
}
} else if (key.equals("XSites")) {
xFields = Integer.parseInt(value);
} else if (key.equals("YSites")) {
yFields = Integer.parseInt(value);
fieldMap = new boolean[yFields][xFields];
} else if (key.equals("TimePoints")) {
nTimepoints = Integer.parseInt(value);
} else if (key.startsWith("SiteSelection")) {
int row = Integer.parseInt(key.substring(13)) - 1;
String[] mapping = value.split(",");
for (int col = 0; col < xFields; col++) {
fieldMap[row][col] = new Boolean(mapping[col].trim()).booleanValue();
}
} else if (key.equals("Waves")) {
doChannels = new Boolean(value.toLowerCase());
} else if (key.equals("NWavelengths")) {
wavelengths = new String[Integer.parseInt(value)];
} else if (key.startsWith("WaveName")) {
int index = Integer.parseInt(key.substring(8)) - 1;
wavelengths[index] = value.replaceAll("\"", "");
}
}
for (int row = 0; row < fieldMap.length; row++) {
for (int col = 0; col < fieldMap[row].length; col++) {
if (fieldMap[row][col])
fieldCount++;
}
}
// find pixels files
String plateName = new Location(id).getAbsolutePath();
plateName = plateName.substring(0, plateName.lastIndexOf(".")) + "_";
int wellCount = 0;
for (int row = 0; row < wellFiles.length; row++) {
for (int col = 0; col < wellFiles[row].length; col++) {
if (wellFiles[row][col] != null) {
wellCount++;
char rowLetter = (char) (row + 'A');
String base = plateName + rowLetter + String.format("%02d", col + 1);
wellFiles[row][col][0] = base + ".pnl";
logFiles[row][col] = base + "_scan.log";
if (!new Location(wellFiles[row][col][0]).exists()) {
// using TIFF files instead
wellFiles[row][col] = getTiffFiles(plateName, rowLetter, col, wavelengths.length, nTimepoints);
}
}
}
}
plateLogFile = plateName + "scan.log";
String serialNumber = null;
if (new Location(plateLogFile).exists()) {
String[] f = DataTools.readFile(plateLogFile).split("\n");
for (String line : f) {
if (line.trim().startsWith("Z Map File")) {
String file = line.substring(line.indexOf(':') + 1);
file = file.substring(file.lastIndexOf("/") + 1).trim();
String parent = new Location(id).getAbsoluteFile().getParent();
zMapFile = new Location(parent, file).getAbsolutePath();
} else if (line.trim().startsWith("Scanner SN")) {
serialNumber = line.substring(line.indexOf(':') + 1).trim();
}
}
}
int seriesCount = fieldCount * wellCount;
int planeIndex = 0;
int seriesIndex = 0;
String file = getFile(seriesIndex, planeIndex);
while (!new Location(file).exists()) {
if (planeIndex < nTimepoints * wavelengths.length) {
planeIndex++;
} else if (seriesIndex < seriesCount - 1) {
planeIndex = 0;
seriesIndex++;
} else {
break;
}
file = getFile(seriesIndex, planeIndex);
}
IFormatReader pnl = getReader(file, true);
core.clear();
for (int i = 0; i < seriesCount; i++) {
CoreMetadata ms = new CoreMetadata();
core.add(ms);
setSeries(i);
ms.littleEndian = pnl.isLittleEndian();
ms.sizeX = pnl.getSizeX();
ms.sizeY = pnl.getSizeY();
ms.pixelType = pnl.getPixelType();
ms.sizeZ = 1;
ms.sizeT = nTimepoints;
ms.sizeC = wavelengths.length;
ms.imageCount = getSizeZ() * getSizeC() * getSizeT();
ms.dimensionOrder = "XYCZT";
ms.rgb = false;
ms.interleaved = pnl.isInterleaved();
}
OMEXMLMetadata readerMetadata = (OMEXMLMetadata) pnl.getMetadataStore();
OMEXMLMetadataRoot root = (OMEXMLMetadataRoot) readerMetadata.getRoot();
Instrument instrument = root.getInstrument(0);
List<Image> images = root.copyImageList();
OMEXMLMetadataRoot convertRoot = new OMEXMLMetadataRoot();
convertRoot.addInstrument(instrument);
for (int i = 0; i < core.size() / images.size(); i++) {
for (Image img : images) {
convertRoot.addImage(img);
}
}
OMEXMLMetadata convertMetadata;
try {
convertMetadata = service.createOMEXMLMetadata();
} catch (ServiceException exc) {
throw new FormatException("Could not create OME-XML store.", exc);
}
convertMetadata.setRoot(convertRoot);
pnl.close();
MetadataStore store = makeFilterMetadata();
MetadataConverter.convertMetadata(convertMetadata, store);
MetadataTools.populatePixels(store, this);
String plateID = MetadataTools.createLSID("Plate", 0);
Location plate = new Location(id).getAbsoluteFile();
store.setPlateID(plateID, 0);
plateName = plate.getName();
if (plateName.indexOf('.') > 0) {
plateName = plateName.substring(0, plateName.lastIndexOf('.'));
}
store.setPlateName(plateName, 0);
store.setPlateRows(new PositiveInteger(wellFiles.length), 0);
store.setPlateColumns(new PositiveInteger(wellFiles[0].length), 0);
for (int i = 0; i < core.size(); i++) {
store.setImageID(MetadataTools.createLSID("Image", i), i);
}
String plateAcqID = MetadataTools.createLSID("PlateAcquisition", 0, 0);
store.setPlateAcquisitionID(plateAcqID, 0, 0);
PositiveInteger fieldCount = FormatTools.getMaxFieldCount(fieldMap.length * fieldMap[0].length);
if (fieldCount != null) {
store.setPlateAcquisitionMaximumFieldCount(fieldCount, 0, 0);
}
int nextImage = 0;
for (int row = 0; row < wellFiles.length; row++) {
for (int col = 0; col < wellFiles[row].length; col++) {
int wellIndex = row * wellFiles[row].length + col;
String wellID = MetadataTools.createLSID("Well", 0, wellIndex);
store.setWellID(wellID, 0, wellIndex);
store.setWellColumn(new NonNegativeInteger(col), 0, wellIndex);
store.setWellRow(new NonNegativeInteger(row), 0, wellIndex);
int fieldIndex = 0;
for (int fieldRow = 0; fieldRow < fieldMap.length; fieldRow++) {
for (int fieldCol = 0; fieldCol < fieldMap[fieldRow].length; fieldCol++) {
if (fieldMap[fieldRow][fieldCol] && wellFiles[row][col] != null) {
String wellSampleID = MetadataTools.createLSID("WellSample", 0, wellIndex, fieldIndex);
store.setWellSampleID(wellSampleID, 0, wellIndex, fieldIndex);
String imageID = MetadataTools.createLSID("Image", nextImage);
store.setWellSampleImageRef(imageID, 0, wellIndex, fieldIndex);
store.setWellSampleIndex(new NonNegativeInteger(nextImage), 0, wellIndex, fieldIndex);
store.setPlateAcquisitionWellSampleRef(wellSampleID, 0, 0, nextImage);
String well = (char) (row + 'A') + String.format("%02d", col + 1);
store.setImageName("Well " + well + " Field #" + (fieldIndex + 1), nextImage);
nextImage++;
fieldIndex++;
}
}
}
}
}
if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) {
if (serialNumber != null) {
store.setMicroscopeSerialNumber(serialNumber, 0);
}
for (int well = 0; well < wellCount; well++) {
parseWellLogFile(well, store);
}
if (timestamps.size() > 0) {
store.setPlateAcquisitionStartTime(timestamps.get(0), 0, 0);
store.setPlateAcquisitionEndTime(timestamps.get(timestamps.size() - 1), 0, 0);
}
for (int i = 0; i < core.size(); i++) {
for (int c = 0; c < getSizeC(); c++) {
if (c < wavelengths.length && wavelengths[c] != null) {
store.setChannelName(wavelengths[c], i, c);
}
}
}
}
}
use of ome.xml.model.primitives.NonNegativeInteger in project bioformats by openmicroscopy.
the class CellomicsReader method initFile.
// -- Internal FormatReader API methods --
/* @see loci.formats.FormatReader#initFile(String) */
@Override
protected void initFile(String id) throws FormatException, IOException {
super.initFile(id);
// look for files with similar names
Location baseFile = new Location(id).getAbsoluteFile();
Location parent = baseFile.getParentFile();
ArrayList<String> pixelFiles = new ArrayList<String>();
String plateName = getPlateName(baseFile.getName());
if (plateName != null && isGroupFiles()) {
String[] list = parent.list();
for (String f : list) {
if (plateName.equals(getPlateName(f)) && (checkSuffix(f, "c01") || checkSuffix(f, "dib"))) {
Location loc = new Location(parent, f);
if ((!f.startsWith(".") || !loc.isHidden()) && getChannel(f) >= 0) {
pixelFiles.add(loc.getAbsolutePath());
}
}
}
} else
pixelFiles.add(id);
files = pixelFiles.toArray(new String[pixelFiles.size()]);
int wellRows = 0;
int wellColumns = 0;
int fields = 0;
ArrayList<Integer> uniqueRows = new ArrayList<Integer>();
ArrayList<Integer> uniqueCols = new ArrayList<Integer>();
ArrayList<Integer> uniqueFields = new ArrayList<Integer>();
ArrayList<Integer> uniqueChannels = new ArrayList<Integer>();
for (String f : files) {
int wellRow = getWellRow(f);
int wellCol = getWellColumn(f);
int field = getField(f);
int channel = getChannel(f);
if (!uniqueRows.contains(wellRow))
uniqueRows.add(wellRow);
if (!uniqueCols.contains(wellCol))
uniqueCols.add(wellCol);
if (!uniqueFields.contains(field))
uniqueFields.add(field);
if (!uniqueChannels.contains(channel))
uniqueChannels.add(channel);
}
fields = uniqueFields.size();
wellRows = uniqueRows.size();
wellColumns = uniqueCols.size();
if (fields * wellRows * wellColumns > files.length) {
files = new String[] { id };
}
Arrays.sort(files, new Comparator<String>() {
@Override
public int compare(String f1, String f2) {
int wellRow1 = getWellRow(f1);
int wellCol1 = getWellColumn(f1);
int field1 = getField(f1);
int channel1 = getChannel(f1);
int wellRow2 = getWellRow(f2);
int wellCol2 = getWellColumn(f2);
int field2 = getField(f2);
int channel2 = getChannel(f2);
if (wellRow1 < wellRow2) {
return -1;
} else if (wellRow1 > wellRow2) {
return 1;
}
if (wellCol1 < wellCol2) {
return -1;
} else if (wellCol1 > wellCol2) {
return 1;
}
if (field1 < field2) {
return -1;
} else if (field1 > field2) {
return 1;
}
return channel1 - channel2;
}
});
core.clear();
int seriesCount = files.length;
if (uniqueChannels.size() > 0) {
seriesCount /= uniqueChannels.size();
}
for (int i = 0; i < seriesCount; i++) {
core.add(new CoreMetadata());
}
in = getDecompressedStream(id);
LOGGER.info("Reading header data");
in.order(true);
in.skipBytes(4);
int x = in.readInt();
int y = in.readInt();
int nPlanes = in.readShort();
int nBits = in.readShort();
int compression = in.readInt();
if (x * y * nPlanes * (nBits / 8) + 52 > in.length()) {
throw new UnsupportedCompressionException("Compressed pixel data is not yet supported.");
}
in.skipBytes(4);
int pixelWidth = 0, pixelHeight = 0;
if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) {
pixelWidth = in.readInt();
pixelHeight = in.readInt();
int colorUsed = in.readInt();
int colorImportant = in.readInt();
LOGGER.info("Populating metadata hashtable");
addGlobalMeta("Image width", x);
addGlobalMeta("Image height", y);
addGlobalMeta("Number of planes", nPlanes);
addGlobalMeta("Bits per pixel", nBits);
addGlobalMeta("Compression", compression);
addGlobalMeta("Pixels per meter (X)", pixelWidth);
addGlobalMeta("Pixels per meter (Y)", pixelHeight);
addGlobalMeta("Color used", colorUsed);
addGlobalMeta("Color important", colorImportant);
}
LOGGER.info("Populating core metadata");
for (int i = 0; i < getSeriesCount(); i++) {
CoreMetadata ms = core.get(i);
ms.sizeX = x;
ms.sizeY = y;
ms.sizeZ = nPlanes;
ms.sizeT = 1;
ms.sizeC = uniqueChannels.size();
ms.imageCount = getSizeZ() * getSizeT() * getSizeC();
ms.littleEndian = true;
ms.dimensionOrder = "XYCZT";
ms.pixelType = FormatTools.pixelTypeFromBytes(nBits / 8, false, false);
}
LOGGER.info("Populating metadata store");
MetadataStore store = makeFilterMetadata();
MetadataTools.populatePixels(store, this);
store.setPlateID(MetadataTools.createLSID("Plate", 0), 0);
store.setPlateName(plateName, 0);
store.setPlateRowNamingConvention(NamingConvention.LETTER, 0);
store.setPlateColumnNamingConvention(NamingConvention.NUMBER, 0);
int realRows = wellRows;
int realCols = wellColumns;
if (files.length == 1) {
realRows = 1;
realCols = 1;
} else if (realRows <= 8 && realCols <= 12) {
realRows = 8;
realCols = 12;
} else {
realRows = 16;
realCols = 24;
}
int fieldCntr = 0;
int wellCntr = 0;
int wellIndexPrev = 0;
int wellIndex = 0;
for (int i = 0; i < getSeriesCount(); i++) {
String file = files[i * getSizeC()];
int fieldIndex = getField(file);
int row = getWellRow(file);
int col = getWellColumn(file);
store.setImageName(String.format("Well %s%02d, Field #%02d", new String(Character.toChars(row + 'A')), col, fieldIndex), i);
if (files.length == 1) {
row = 0;
col = 0;
}
if (i > 0 && files.length != 1) {
String prevFile = files[(i - 1) * getSizeC()];
int prevRow = getWellRow(prevFile);
int prevCol = getWellColumn(prevFile);
if (prevRow < realRows && prevCol < realCols) {
wellIndexPrev = prevRow * realCols + prevCol;
}
}
String imageID = MetadataTools.createLSID("Image", i);
store.setImageID(imageID, i);
if (row < realRows && col < realCols) {
wellIndex = row * realCols + col;
if ((wellIndexPrev != wellIndex) || i == 0) {
if (i > 0) {
wellCntr++;
fieldCntr = 0;
} else {
wellIndexPrev = wellIndex;
}
store.setWellID(MetadataTools.createLSID("Well", 0, wellIndex), 0, wellCntr);
store.setWellRow(new NonNegativeInteger(row), 0, wellCntr);
store.setWellColumn(new NonNegativeInteger(col), 0, wellCntr);
}
if (files.length == 1) {
fieldIndex = 0;
}
if (fieldIndex == 0) {
fieldCntr = 0;
}
String wellSampleID = MetadataTools.createLSID("WellSample", 0, wellIndex, fieldIndex);
store.setWellSampleID(wellSampleID, 0, wellCntr, fieldCntr);
store.setWellSampleIndex(new NonNegativeInteger(i), 0, wellCntr, fieldCntr);
store.setWellSampleImageRef(imageID, 0, wellCntr, fieldCntr);
fieldCntr++;
}
}
if (getMetadataOptions().getMetadataLevel() != MetadataLevel.MINIMUM) {
// physical dimensions are stored as pixels per meter - we want them
// in microns per pixel
double width = pixelWidth == 0 ? 0.0 : 1000000.0 / pixelWidth;
double height = pixelHeight == 0 ? 0.0 : 1000000.0 / pixelHeight;
Length sizeX = FormatTools.getPhysicalSizeX(width);
Length sizeY = FormatTools.getPhysicalSizeY(height);
for (int i = 0; i < getSeriesCount(); i++) {
if (sizeX != null) {
store.setPixelsPhysicalSizeX(sizeX, 0);
}
if (sizeY != null) {
store.setPixelsPhysicalSizeY(sizeY, 0);
}
}
}
}
use of ome.xml.model.primitives.NonNegativeInteger in project bioformats by openmicroscopy.
the class FV1000Reader method parseROIFile.
private int parseROIFile(String filename, MetadataStore store, int nextROI, int plane) throws FormatException, IOException {
int[] coordinates = getZCTCoords(plane);
IniList roiFile = null;
try {
roiFile = getIniFile(filename);
} catch (FormatException e) {
LOGGER.debug("Could not parse ROI file {}", filename, e);
return nextROI;
} catch (IOException e) {
LOGGER.debug("Could not parse ROI file {}", filename, e);
return nextROI;
}
boolean validROI = false;
int shape = -1;
int shapeType = -1;
String[] xc = null, yc = null;
int divide = 0;
int fontSize = 0, lineWidth = 0, angle = 0;
String fontName = null, name = null;
for (IniTable table : roiFile) {
String tableName = table.get(IniTable.HEADER_KEY);
if (tableName.equals("ROIBase FileInformation")) {
try {
String roiName = table.get("Name").replaceAll("\"", "");
validROI = Integer.parseInt(roiName) > 1;
} catch (NumberFormatException e) {
validROI = false;
}
if (!validROI)
continue;
} else if (tableName.equals("ROIBase Body")) {
shapeType = Integer.parseInt(table.get("SHAPE"));
divide = Integer.parseInt(table.get("DIVIDE"));
String[] fontAttributes = table.get("FONT").split(",");
fontName = fontAttributes[0];
fontSize = Integer.parseInt(fontAttributes[1]);
Length font = FormatTools.getFontSize(fontSize);
lineWidth = Integer.parseInt(table.get("LINEWIDTH"));
name = table.get("NAME");
angle = Integer.parseInt(table.get("ANGLE"));
xc = table.get("X").split(",");
yc = table.get("Y").split(",");
int x = Integer.parseInt(xc[0]);
int width = xc.length > 1 ? Integer.parseInt(xc[1]) - x : 0;
int y = Integer.parseInt(yc[0]);
int height = yc.length > 1 ? Integer.parseInt(yc[1]) - y : 0;
if (width + x <= getSizeX() && height + y <= getSizeY()) {
shape++;
final Integer zIndex = coordinates[0];
final Integer tIndex = coordinates[2];
if (shape == 0) {
nextROI++;
if (shapeType == POINT || shapeType == GRID || shapeType == RECTANGLE || shapeType == LINE || shapeType == CIRCLE || shapeType == ELLIPSE || shapeType == POLYGON || shapeType == FREE_SHAPE || shapeType == POLYLINE || shapeType == FREE_LINE) {
String roiID = MetadataTools.createLSID("ROI", nextROI);
store.setROIID(roiID, nextROI);
store.setImageROIRef(roiID, 0, nextROI);
}
}
String shapeID = MetadataTools.createLSID("Shape", nextROI, shape);
if (shapeType == POINT) {
store.setPointID(shapeID, nextROI, shape);
store.setPointTheZ(new NonNegativeInteger(zIndex), nextROI, shape);
store.setPointTheT(new NonNegativeInteger(tIndex), nextROI, shape);
if (font != null) {
store.setPointFontSize(font, nextROI, shape);
}
Length l = new Length((double) lineWidth, UNITS.PIXEL);
store.setPointStrokeWidth(l, nextROI, shape);
store.setPointX(new Double(xc[0]), nextROI, shape);
store.setPointY(new Double(yc[0]), nextROI, shape);
} else if (shapeType == GRID || shapeType == RECTANGLE) {
if (shapeType == RECTANGLE)
divide = 1;
width /= divide;
height /= divide;
for (int row = 0; row < divide; row++) {
for (int col = 0; col < divide; col++) {
double realX = x + col * width;
double realY = y + row * height;
shapeID = MetadataTools.createLSID("Shape", nextROI, shape);
store.setRectangleID(shapeID, nextROI, shape);
store.setRectangleX(realX, nextROI, shape);
store.setRectangleY(realY, nextROI, shape);
store.setRectangleWidth((double) width, nextROI, shape);
store.setRectangleHeight((double) height, nextROI, shape);
store.setRectangleTheZ(new NonNegativeInteger(zIndex), nextROI, shape);
store.setRectangleTheT(new NonNegativeInteger(tIndex), nextROI, shape);
if (font != null) {
store.setRectangleFontSize(font, nextROI, shape);
}
Length l = new Length((double) lineWidth, UNITS.PIXEL);
store.setRectangleStrokeWidth(l, nextROI, shape);
double centerX = realX + (width / 2);
double centerY = realY + (height / 2);
store.setRectangleTransform(getRotationTransform(angle), nextROI, shape);
if (row < divide - 1 || col < divide - 1)
shape++;
}
}
} else if (shapeType == LINE) {
store.setLineID(shapeID, nextROI, shape);
store.setLineX1((double) x, nextROI, shape);
store.setLineY1((double) y, nextROI, shape);
store.setLineX2((double) (x + width), nextROI, shape);
store.setLineY2((double) (y + height), nextROI, shape);
store.setLineTheZ(new NonNegativeInteger(zIndex), nextROI, shape);
store.setLineTheT(new NonNegativeInteger(tIndex), nextROI, shape);
if (font != null) {
store.setLineFontSize(font, nextROI, shape);
}
Length l = new Length((double) lineWidth, UNITS.PIXEL);
store.setLineStrokeWidth(l, nextROI, shape);
int centerX = x + (width / 2);
int centerY = y + (height / 2);
store.setLineTransform(getRotationTransform(angle), nextROI, shape);
} else if (shapeType == CIRCLE || shapeType == ELLIPSE) {
double rx = width / 2;
double ry = shapeType == CIRCLE ? rx : height / 2;
store.setEllipseID(shapeID, nextROI, shape);
store.setEllipseX(x + rx, nextROI, shape);
store.setEllipseY(y + ry, nextROI, shape);
store.setEllipseRadiusX(rx, nextROI, shape);
store.setEllipseRadiusY(ry, nextROI, shape);
store.setEllipseTheZ(new NonNegativeInteger(zIndex), nextROI, shape);
store.setEllipseTheT(new NonNegativeInteger(tIndex), nextROI, shape);
if (font != null) {
store.setEllipseFontSize(font, nextROI, shape);
}
Length l = new Length((double) lineWidth, UNITS.PIXEL);
store.setEllipseStrokeWidth(l, nextROI, shape);
store.setEllipseTransform(getRotationTransform(angle), nextROI, shape);
} else if (shapeType == POLYGON || shapeType == FREE_SHAPE || shapeType == POLYLINE || shapeType == FREE_LINE) {
final StringBuilder points = new StringBuilder();
for (int point = 0; point < xc.length; point++) {
points.append(xc[point]);
points.append(",");
points.append(yc[point]);
if (point < xc.length - 1)
points.append(" ");
}
if (shapeType == POLYLINE || shapeType == FREE_LINE) {
store.setPolylineID(shapeID, nextROI, shape);
store.setPolylinePoints(points.toString(), nextROI, shape);
store.setPolylineTransform(getRotationTransform(angle), nextROI, shape);
store.setPolylineTheZ(new NonNegativeInteger(zIndex), nextROI, shape);
store.setPolylineTheT(new NonNegativeInteger(tIndex), nextROI, shape);
if (font != null) {
store.setPolylineFontSize(font, nextROI, shape);
}
Length l = new Length((double) lineWidth, UNITS.PIXEL);
store.setPolylineStrokeWidth(l, nextROI, shape);
} else {
store.setPolygonID(shapeID, nextROI, shape);
store.setPolygonPoints(points.toString(), nextROI, shape);
store.setPolygonTransform(getRotationTransform(angle), nextROI, shape);
store.setPolygonTheZ(new NonNegativeInteger(zIndex), nextROI, shape);
store.setPolygonTheT(new NonNegativeInteger(tIndex), nextROI, shape);
if (font != null) {
store.setPolygonFontSize(font, nextROI, shape);
}
Length l = new Length((double) lineWidth, UNITS.PIXEL);
store.setPolygonStrokeWidth(l, nextROI, shape);
}
} else {
if (shape == 0)
nextROI--;
shape--;
}
}
}
}
return nextROI;
}
use of ome.xml.model.primitives.NonNegativeInteger in project bioformats by openmicroscopy.
the class SPWModelMock method makePlate.
private Plate makePlate() {
Plate plate = new Plate();
plate.setName(PLATE_NAME);
plate.setID(PLATE_ID);
plate.setRows(WELL_ROWS);
plate.setColumns(WELL_COLS);
plate.setRowNamingConvention(WELL_ROW);
plate.setColumnNamingConvention(WELL_COL);
int wellSampleIndex = 0;
for (int row = 0; row < WELL_ROWS.getValue(); row++) {
for (int col = 0; col < WELL_COLS.getValue(); col++) {
Well well = new Well();
well.setID(String.format("Well:%d_%d", row, col));
well.setRow(new NonNegativeInteger(row));
well.setColumn(new NonNegativeInteger(col));
WellSample sample = new WellSample();
sample.setID(String.format("WellSample:%d_%d", row, col));
sample.setIndex(new NonNegativeInteger(wellSampleIndex));
sample.linkImage(ome.getImage(wellSampleIndex));
well.addWellSample(sample);
plate.addWell(well);
wellSampleIndex++;
}
}
return plate;
}
use of ome.xml.model.primitives.NonNegativeInteger in project bioformats by openmicroscopy.
the class IMetadataBasedOMEModelMock method makePlate.
private void makePlate() {
store.setPlateID(InOutCurrentTest.PLATE_ID, 0);
store.setPlateRows(InOutCurrentTest.WELL_ROWS, 0);
store.setPlateColumns(InOutCurrentTest.WELL_COLS, 0);
store.setPlateRowNamingConvention(InOutCurrentTest.WELL_ROW, 0);
store.setPlateColumnNamingConvention(InOutCurrentTest.WELL_COL, 0);
store.setPlateAnnotationRef(InOutCurrentTest.PLATE_ANNOTATION_ID, 0, 0);
store.setTimestampAnnotationID(InOutCurrentTest.PLATE_ANNOTATION_ID, 0);
store.setTimestampAnnotationNamespace(InOutCurrentTest.GENERAL_ANNOTATION_NAMESPACE, 0);
store.setTimestampAnnotationValue(new Timestamp(InOutCurrentTest.PLATE_ANNOTATION_VALUE), 0);
int wellSampleIndex = 0;
int wellCount = 0;
for (int row = 0; row < InOutCurrentTest.WELL_ROWS.getValue(); row++) {
for (int col = 0; col < InOutCurrentTest.WELL_COLS.getValue(); col++) {
store.setWellID(String.format("Well:%d_%d", row, col), 0, wellCount);
store.setWellRow(new NonNegativeInteger(row), 0, wellCount);
store.setWellColumn(new NonNegativeInteger(col), 0, wellCount);
if (row == 0 && col == 0) {
store.setLongAnnotationID(InOutCurrentTest.WELL_ANNOTATION_ID, 0);
store.setLongAnnotationNamespace(InOutCurrentTest.GENERAL_ANNOTATION_NAMESPACE, 0);
store.setLongAnnotationValue(InOutCurrentTest.WELL_ANNOTATION_VALUE, 0);
store.setWellAnnotationRef(InOutCurrentTest.WELL_ANNOTATION_ID, 0, wellCount, 0);
}
store.setWellSampleID(String.format("WellSample:%d_%d", row, col), 0, wellCount, 0);
store.setWellSampleIndex(new NonNegativeInteger(wellSampleIndex), 0, wellCount, 0);
store.setWellSampleImageRef(InOutCurrentTest.IMAGE_ID, 0, wellCount, 0);
wellSampleIndex++;
wellCount++;
}
}
}
Aggregations