public static PathObject readPointsObjectFromString(String s) { List<Point2> pointsList = new ArrayList<>(); Scanner scanner = new Scanner(s); String name = scanner.nextLine().split("\t")[1].trim(); Integer color = Integer.getInteger(scanner.nextLine().split("\t")[1]); // Skip the coordinate count line... int count = Integer.parseInt(scanner.nextLine().split("\t")[1]); while (scanner.hasNextLine()) { String line = scanner.nextLine().trim(); if (line.length() == 0) break; String[] splits = line.split("\t"); double x = Double.parseDouble(splits[0]); double y = Double.parseDouble(splits[1]); pointsList.add(new Point2(x, y)); } scanner.close(); // if (name != null && name.length() > 0) // points.setName(name); if (count != pointsList.size()) logger.warn("Warning: {} points expected, {} points found", count, pointsList.size()); PointsROI points = new PointsROI(pointsList); PathAnnotationObject pathObject = new PathAnnotationObject(points); if (name != null && name.length() > 0 && !"null".equals(name)) pathObject.setName(name); pathObject.setColorRGB(color); return pathObject; }
public static PathObject simplifyShapeAnnotation(PathAnnotationObject pathObject, final double altitudeThreshold) { PathShape pathROI = (PathShape)pathObject.getROI(); PathObject pathObjectNew = null; if (pathROI instanceof PolygonROI) { PolygonROI polygonROI = (PolygonROI)pathROI; polygonROI = ShapeSimplifier.simplifyPolygon(polygonROI, altitudeThreshold); pathObjectNew = new PathAnnotationObject(polygonROI, pathObject.getPathClass(), pathObject.getMeasurementList()); } else { pathROI = ShapeSimplifierAwt.simplifyShape(pathROI, altitudeThreshold); pathObjectNew = new PathAnnotationObject(pathROI, pathObject.getPathClass(), pathObject.getMeasurementList()); } return pathObjectNew; }
@Override public int compare(PathObject o1, PathObject o2) { PathAnnotationObject p1 = (PathAnnotationObject)o1; PathAnnotationObject p2 = (PathAnnotationObject)o2; int comp = 0; if (p1.hasROI()) { if (p2.hasROI()) { comp = Double.compare(p1.getROI().getCentroidY(), p2.getROI().getCentroidY()); if (comp == 0) comp = Double.compare(p1.getROI().getCentroidX(), p2.getROI().getCentroidX()); if (comp == 0) comp = p1.getROI().toString().compareTo(p2.getROI().toString()); } } if (comp == 0) return Integer.compare(o1.hashCode(), o2.hashCode()); else return comp; } });
private PathObject createTile(ROI pathROI, ParameterList params, ImageServer<?> server) throws InterruptedException { return Boolean.TRUE.equals(params.getBooleanParameterValue("makeAnnotations")) ? new PathAnnotationObject(pathROI) : new PathTileObject(pathROI); }
else pathROINew = PathROIToolsAwt.getShapeROI(new Area(path), -1, 0, 0); pathSingleAnnotation = new PathAnnotationObject(pathROINew, pathClass); if (!deleteTiles) pathSingleAnnotation.addPathObjects(tiles); PathAnnotationObject annotation = new PathAnnotationObject(shape, pathClass); if (!deleteTiles) annotation.addPathObjects(children); pathAnnotations.add(annotation);
((PathAnnotationObject)pathObject).setLocked(true); else if (pathObject instanceof TMACoreObject) ((TMACoreObject)pathObject).setLocked(true);
areaTemp.subtract(areaNew); PathShape shapeNew = PathROIToolsAwt.getShapeROI(areaTemp, shapeMask.getC(), shapeMask.getZ(), shapeMask.getT()); annotationNew = new PathAnnotationObject(shapeNew, temp.getPathClass()); } else if (op == PathROIToolsAwt.CombineOp.INTERSECT) { areaTemp.intersect(areaNew); PathShape shapeNew = PathROIToolsAwt.getShapeROI(areaTemp, shapeMask.getC(), shapeMask.getZ(), shapeMask.getT()); annotationNew = new PathAnnotationObject(shapeNew, temp.getPathClass()); } else { PathROIToolsAwt.combineAreas(areaNew, areaTemp, op); objectsToAdd.add(new PathAnnotationObject(shapeNew, pathObject.getPathClass()));
PathAnnotationObject annotation2 = new PathAnnotationObject(roi2, pathObject.getPathClass()); annotation2.setName(pathObject.getName()); annotation2.setColorRGB(pathObject.getColorRGB());
public static void createSelectAllObject(final boolean setSelected) { ImageData<?> imageData = getCurrentImageData(); if (imageData == null) return; ImageServer<?> server = imageData.getServer(); PathObject pathObject = new PathAnnotationObject(new RectangleROI(0, 0, server.getWidth(), server.getHeight(), 0, 0, 0)); imageData.getHierarchy().addPathObject(pathObject, false); if (setSelected) imageData.getHierarchy().getSelectionModel().setSelectedObject(pathObject); }