@Override void ensureHandlesUpdated() { if (handles == null) handles = new ArrayList<>(); else handles.clear(); addPointsToMutablePointList(handles, roi.getPolygonPoints()); // If we have a single point, create a second handle (which may be adjusted) if (handles.size() == 1) handles.add(new MutablePoint(handles.get(0).getX(), handles.get(0).getY())); }
@Override public PolygonROI requestNewHandle(double x, double y) { if (activeHandle == null) return roi; // Can only add if there is an active handle - distance to this will be used // Move the active handle if it is very close to the requested region // (removed) // Don't add a handle at almost the sample place as an existing handle if (handles.size() >= 2 && activeHandle == handles.get(handles.size() - 1) && handles.get(handles.size() - 2).distanceSq(x, y) < 4) { return roi; } // // If we have 2 points, which are identical, shift instead of creating // if (handles.size() >= 2 && activeHandle == handles.get(handles.size() - 1) && activeHandle.distanceSq(handles.get(handles.size() - 2)) < 0.000001) { // System.err.println("UPDATING HANDLE"); // return updateActiveHandleLocation(x, y, false); // } activeHandle = new MutablePoint(x, y); handles.add(activeHandle); roi = new PolygonROI(createPoint2List(handles), roi.getC(), roi.getZ(), roi.getT()); // System.out.println("UPDATED HANDLES BY REQUEST: " + handles.size()); return roi; }
@Override void ensureHandlesUpdated() { handles.clear(); handles.add(new MutablePoint(roi.getX1(), roi.getY1())); handles.add(new MutablePoint(roi.getX2(), roi.getY2())); }
/** * Returns true if the current ROI is translatable, and at the end of this call the translation has started. * * @param pathROI * @param x * @param y * @return */ public boolean startTranslation(double x, double y) { if (!(pathROI instanceof TranslatableROI)) return false; pTranslateOrigin = new MutablePoint(x, y); pTranslateCurrent = new MutablePoint(x, y); isTranslating = true; return true; }
@Override public PointsROI requestNewHandle(double x, double y) { activeHandle = new MutablePoint(x, y); handles.add(activeHandle); roi = new PointsROI(createPoint2List(handles), roi.getC(), roi.getZ(), roi.getT()); ensureHandlesUpdated(); activeHandle = grabHandle(x, y, Double.POSITIVE_INFINITY, false); // ensureHandlesUpdated(); // activeHandle = grabHandle(x, y, 1, false); // ensureHandlesUpdated(); // activeHandle = roi.getNearest(x, y, 0.01); return roi; }
BoundedHandleAdjuster(T roi) { this.roi = roi; bounds = new Rect(roi.getBoundsX(), roi.getBoundsY(), roi.getBoundsWidth(), roi.getBoundsHeight()); handles.clear(); for (int i = 0; i < 8; i++) handles.add(new MutablePoint(Double.NaN, Double.NaN)); // updateHandles(); }
static void addPointsToMutablePointList(final List<MutablePoint> mutablePoints, final List<Point2> points) { for (Point2 p : points) { mutablePoints.add(new MutablePoint(p.getX(), p.getY())); } }