public boolean contains(int x, int y) { if (!super.contains(x, y)) return false; if (xSpline != null) { FloatPolygon poly = new FloatPolygon(xSpline, ySpline, splinePoints); return poly.contains(x - this.x, y - this.y); } else if (xpf != null) { FloatPolygon poly = new FloatPolygon(xpf, ypf, nPoints); return poly.contains(x - this.x, y - this.y); } else { Polygon poly = new Polygon(xp, yp, nPoints); return poly.contains(x - this.x, y - this.y); } }
void finishPolygon() { if (xpf != null) { FloatPolygon poly = new FloatPolygon(xpf, ypf, nPoints); Rectangle r = poly.getBounds(); x = r.x; y = r.y; width = r.width; height = r.height; bounds = poly.getFloatBounds(); float xbase = (float) bounds.getX(); float ybase = (float) bounds.getY(); for (int i = 0; i < nPoints; i++) { xpf[i] -= xbase; ypf[i] -= ybase; } } else { Polygon poly = new Polygon(xp, yp, nPoints); Rectangle r = poly.getBounds(); x = r.x; y = r.y; width = r.width; height = r.height; for (int i = 0; i < nPoints; i++) { xp[i] = xp[i] - x; yp[i] = yp[i] - y; } bounds = null; } if (nPoints < 2 || (!(type == FREELINE || type == POLYLINE || type == ANGLE) && (nPoints < 3 || width == 0 || height == 0))) { if (imp != null) imp.deleteRoi(); if (type != POINT) return; } state = NORMAL; if (imp != null && !(type == TRACED_ROI)) imp.draw(x - 5, y - 5, width + 10, height + 10); oldX = x; oldY = y; oldWidth = width; oldHeight = height; if (Recorder.record && userCreated && (type == POLYGON || type == POLYLINE || type == ANGLE || (type == POINT && Recorder.scriptMode() && nPoints == 3))) Recorder.recordRoi(getPolygon(), type); if (type != POINT) modifyRoi(); LineWidthAdjuster.update(); }