private void resetLastPointFromPath() { Point2D last = mPath.getCurrentPoint(); mLastX = (float) last.getX(); mLastY = (float) last.getY(); } }
/** * Fills the given {@link RectF} with the path bounds. * * @param bounds the RectF to be filled. */ public void fillBounds(RectF bounds) { Rectangle2D rect = mPath.getBounds2D(); bounds.left = (float) rect.getMinX(); bounds.right = (float) rect.getMaxX(); bounds.top = (float) rect.getMinY(); bounds.bottom = (float) rect.getMaxY(); }
private boolean hasPoints() { return !mPath.getPathIterator(null).isDone(); }
public Point2D getTranslated(Point2D p) { if (p == null) { return null; } return new Point2D.Double(p.getX() + dx, p.getY() + dy); }
private Point2D putOnCircle(Point2D p) { p = at.transform(p, null); final double coef = p.distance(new Point2D.Double()) / radius; p = new Point2D.Double(p.getX() / coef, p.getY() / coef); return at2.transform(p, null); }
@Override public Point2D getPoint2D(Point2D srcPt, Point2D dstPt) { if (dstPt == null) dstPt = new Point2D.Double(); dstPt.setLocation(srcPt.getX(), srcPt.getY()); return dstPt; }
@Implementation protected void offset(float dx, float dy) { GeneralPath newPath = new GeneralPath(); PathIterator iterator = mPath.getPathIterator(new AffineTransform(0, 0, dx, 0, 0, dy)); newPath.append(iterator, false /*connect*/); mPath = newPath; }
protected AffineTransform getAffineTransform() { // the AffineTransform constructor takes the value in a different order // for a matrix [ 0 1 2 ] // [ 3 4 5 ] // the order is 0, 3, 1, 4, 2, 5... return new AffineTransform( simpleMatrix.mValues[0], simpleMatrix.mValues[3], simpleMatrix.mValues[1], simpleMatrix.mValues[4], simpleMatrix.mValues[2], simpleMatrix.mValues[5]); }
private static Line2D symetric(Line2D line) { final double x1 = line.getX1(); final double y1 = line.getY1(); final double x2 = line.getX2(); final double y2 = line.getY2(); final double dx = x2 - x1; final double dy = y2 - y1; return new Line2D.Double(x1, y1, x1 - dx, y1 - dy); }
public static Point2D.Double getCenter(Line2D.Double l) { final double x = (l.getX1() + l.getX2()) / 2; final double y = (l.getY1() + l.getY2()) / 2; return new Point2D.Double(x, y); }
@Override public Rectangle2D getBounds2D() { return new Rectangle2D.Double(x, y, width, height); }
@Implementation protected void addCircle(float x, float y, float radius, Path.Direction dir) { mPath.append(new Ellipse2D.Float(x - radius, y - radius, radius * 2, radius * 2), false); }
@Implementation(minSdk = LOLLIPOP) protected void addRoundRect( float left, float top, float right, float bottom, float rx, float ry, Path.Direction dir) { mPath.append( new RoundRectangle2D.Float(left, top, right - left, bottom - top, rx * 2, ry * 2), false); }
@Implementation(minSdk = LOLLIPOP) protected void addArc( float left, float top, float right, float bottom, float startAngle, float sweepAngle) { mPath.append( new Arc2D.Float( left, top, right - left, bottom - top, -startAngle, -sweepAngle, Arc2D.OPEN), false); }
private Point2D mirror(Point2D center, Point2D pt) { final double x = 2 * center.getX() - pt.getX(); final double y = 2 * center.getY() - pt.getY(); return new Point2D.Double(x, y); }
@Implementation(minSdk = LOLLIPOP) protected void addOval(float left, float top, float right, float bottom, Path.Direction dir) { mPath.append(new Ellipse2D.Float(left, top, right - left, bottom - top), false); }
public ExtremityCircleCross(Point2D p1) { this.px = p1.getX() - radius; this.py = p1.getY() - radius; this.dest = new Point2D.Double(p1.getX(), p1.getY()); }
public ExtremityCircleConnect(Point2D p1, double ortho) { this.px = p1.getX() - radius; this.py = p1.getY() - radius; this.dest = new Point2D.Double(p1.getX(), p1.getY()); this.ortho = ortho; }