PathIterator iterator = ellipse.getPathIterator(null, flatness); double[] coords = new double[6]; ArrayList<Point2D.Double> points = new ArrayList<>();
private Geometry readEllipseObject() throws IOException { try { // ellipse donne les points opposs du rectangle englobant. final Coordinate c1 = readMIFCoordinate(); final Coordinate c2 = readMIFCoordinate(); final Ellipse2D.Double ellipse = new Ellipse2D.Double(Math.max(c1.x, c2.x), Math.max(c1.y, c2.y), Math.abs(c2.x - c1.x), Math.abs(c2.y - c1.y)); final double ecart = Math.min(ellipse.height, ellipse.width) / 20; final PathIterator it = ellipse.getPathIterator(null, ecart); final double[] coord = new double[2]; final List coor = new ArrayList(20); while (!it.isDone()) { it.currentSegment(coord); coor.add(new Coordinate(coord[0], coord[1])); } return geomFactory_.createLinearRing((Coordinate[]) coor.toArray(new Coordinate[coor.size()])); } catch (final Exception e) { throw createExc(e); } } }
private double getRadius() { final double[] COORDINATES = new double[6]; final Point2D.Double P = new Point2D.Double(); double minDistance = Double.MAX_VALUE; final double FLATNESS = 0.005; final java.awt.geom.PathIterator PATH_ITERATOR = ELLIPSE.getPathIterator(null, FLATNESS); while (!PATH_ITERATOR.isDone()) { int segment = PATH_ITERATOR.currentSegment(COORDINATES); switch (segment) { case java.awt.geom.PathIterator.SEG_CLOSE: case java.awt.geom.PathIterator.SEG_MOVETO: case java.awt.geom.PathIterator.SEG_LINETO: break; default: break; } final double DISTANCE = LINE.ptSegDist(COORDINATES[0], COORDINATES[1]); if (DISTANCE < minDistance) { minDistance = DISTANCE; P.x = COORDINATES[0]; P.y = COORDINATES[1]; } PATH_ITERATOR.next(); } return CENTER.distance(P); } }
private double getRadius() { final double[] COORDINATES = new double[6]; final Point2D.Double P = new Point2D.Double(); double minDistance = Double.MAX_VALUE; final double FLATNESS = 0.005; final java.awt.geom.PathIterator PATH_ITERATOR = ELLIPSE.getPathIterator(null, FLATNESS); while (!PATH_ITERATOR.isDone()) { int segment = PATH_ITERATOR.currentSegment(COORDINATES); switch (segment) { case java.awt.geom.PathIterator.SEG_CLOSE: case java.awt.geom.PathIterator.SEG_MOVETO: case java.awt.geom.PathIterator.SEG_LINETO: break; default: break; } final double DISTANCE = LINE.ptSegDist(COORDINATES[0], COORDINATES[1]); if (DISTANCE < minDistance) { minDistance = DISTANCE; P.x = COORDINATES[0]; P.y = COORDINATES[1]; } PATH_ITERATOR.next(); } return CENTER.distance(P); } }
public List<Point> asPoints() { Ellipse2D.Double e2d = (Ellipse2D.Double) asAwtShape(); if (e2d == null) { return null; } PathIterator it = e2d.getPathIterator(new AffineTransform(), 0.1f); List<Point> points = new ArrayList<Point>(); final double[] coords = new double[6]; while (!it.isDone()) { it.currentSegment(coords); SmartPointI pt = new SmartPointI(); pt.setX(rdouble(coords[0])); pt.setY(rdouble(coords[1])); points.add(pt); it.next(); } assert Util.checkNonNull(points) : "Null points in " + this; return points; }
protected PlaceObject3Tag ellipse(EllipseNode node) { // Note that we will apply node.x and node.y as a translation operation // in the PlaceObject3Tag3 Matrix and instead start the shape from the // origin (0.0, 0.0). Ellipse2D.Double ellipse = new Ellipse2D.Double(0.0, 0.0, node.width, node.height); ShapeBuilder builder = new ShapeBuilder(); IShapeIterator iterator = new PathIteratorWrapper(ellipse.getPathIterator(null)); builder.processShape(iterator); Shape shape = builder.build(); return placeDefineShapeTag(node, shape.getShapeRecords(), node.fill, node.stroke, node.createGraphicContext()); }
protected PlaceObject3Tag ellipse(EllipseNode node) { // Note that we will apply node.x and node.y as a translation operation // in the PlaceObject3Tag3 Matrix and instead start the shape from the // origin (0.0, 0.0). Ellipse2D.Double ellipse = new Ellipse2D.Double(0.0, 0.0, node.width, node.height); ShapeBuilder builder = new ShapeBuilder(); IShapeIterator iterator = new PathIteratorWrapper(ellipse.getPathIterator(null)); builder.processShape(iterator); Shape shape = builder.build(); return placeDefineShapeTag(node, shape.getShapeRecords(), node.fill, node.stroke, node.createGraphicContext()); }
protected PlaceObject3Tag ellipse(EllipseNode node) { // Note that we will apply node.x and node.y as a translation operation // in the PlaceObject3Tag3 Matrix and instead start the shape from the // origin (0.0, 0.0). Ellipse2D.Double ellipse = new Ellipse2D.Double(0.0, 0.0, node.width, node.height); ShapeBuilder builder = new ShapeBuilder(); IShapeIterator iterator = new PathIteratorWrapper(ellipse.getPathIterator(null)); builder.processShape(iterator); Shape shape = builder.build(); return placeDefineShapeTag(node, shape.getShapeRecords(), node.fill, node.stroke, node.createGraphicContext()); }