int getGradientSteps(Shape gradientShape) { Rectangle rect = gradientShape.getBounds(); int lower = 1; int upper = (int)(Math.max(rect.getWidth(),rect.getHeight())/2.0); while (lower < upper-1) { int mid = lower + (upper - lower) / 2; BasicStroke bs = new BasicStroke(mid, capStyle, joinStyle); Area area = new Area(bs.createStrokedShape(gradientShape)); if (area.isSingular()) { upper = mid; } else { lower = mid; } } return upper; }
public static Area findSmallest(Area area) { if (area.isSingular()) { System.out.println("Is singular"); return null;
/** * Return true if this area node is comprised of a single closed subpath. This * method returns true if the path contains 0 or 1 subpaths, or false if the path * contains more than 1 subpath. The subpaths are counted by the number of * <code>SEG_MOVETO</code> segments that appear in the path. * * @return true if this area node is comprised of a single closed subpath */ public boolean isSingular() { return area.isSingular(); }
/** * Return true if this area node is comprised of a single closed subpath. This * method returns true if the path contains 0 or 1 subpaths, or false if the path * contains more than 1 subpath. The subpaths are counted by the number of * <code>SEG_MOVETO</code> segments that appear in the path. * * @return true if this area node is comprised of a single closed subpath */ public boolean isSingular() { return area.isSingular(); }
int getGradientSteps(Shape gradientShape) { Rectangle rect = gradientShape.getBounds(); int lower = 1; int upper = (int)(Math.max(rect.getWidth(),rect.getHeight())/2.0); while (lower < upper-1) { int mid = lower + (upper - lower) / 2; BasicStroke bs = new BasicStroke(mid, capStyle, joinStyle); Area area = new Area(bs.createStrokedShape(gradientShape)); if (area.isSingular()) { upper = mid; } else { lower = mid; } } return upper; }
/** Interpolate areas only if they are made of a single shape each. * Assumes that areas are in the same coordinate system. * @throws Exception */ static public final Area[] singularInterpolation(final Area a1, final Area a2, final int nInterpolates) throws Exception { if (!a1.isSingular() || !a2.isSingular()) { return null; } final VectorString2D vs1 = M.asVectorString2D(M.getPolygons(a1).iterator().next(), 0); final VectorString2D vs2 = M.asVectorString2D(M.getPolygons(a2).iterator().next(), 1); final Editions ed = new Editions(vs1, vs2, Math.min(vs1.getAverageDelta(), vs2.getAverageDelta()), true); final double[][][] d = SkinMaker.getMorphedPerimeters(vs1, vs2, nInterpolates, ed); final Area[] a = new Area[d.length]; for (int i=0; i<d.length; i++) { final double[] x = d[i][0]; final double[] y = d[i][1]; final int[] xi = new int[x.length]; final int[] yi = new int[y.length]; for (int k=0; k<x.length; k++) { xi[k] = (int) x[k]; yi[k] = (int) y[k]; } a[i] = new Area(new Polygon(xi, yi, xi.length)); } return a; }
g.setColor(Color.black); ((Graphics2D)g).fill(p); System.out.println(a.isSingular());
if (!always_use_distance_map && first.isSingular() && last.isSingular()) { as = AreaUtils.singularInterpolation(first, last, chain.size()); } else {
PathShape pathShape = (PathShape)pathSingleAnnotation.getROI(); Area area = PathROIToolsAwt.getArea(pathShape); if (area.isSingular()) { pathAnnotations.add(pathSingleAnnotation);
else if (area.isSingular() && (area.isPolygonal() || flatness > 0)) { Path2D path = new Path2D.Float(area); List<Point2> points = flatness > 0 ? AWTAreaROI.getLinearPathPoints(path, path.getPathIterator(null, flatness)) : AWTAreaROI.getLinearPathPoints(path, path.getPathIterator(null));
compound.intersect(a); if (!compound.isSingular()) { Polygon polygon = M.findPath(compound, x_p_w, y_p_w); if (null != polygon) {