本文整理汇总了Java中java.awt.geom.GeneralPath.getCurrentPoint方法的典型用法代码示例。如果您正苦于以下问题:Java GeneralPath.getCurrentPoint方法的具体用法?Java GeneralPath.getCurrentPoint怎么用?Java GeneralPath.getCurrentPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.geom.GeneralPath
的用法示例。
在下文中一共展示了GeneralPath.getCurrentPoint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: coArcTo
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
private static void coArcTo(GeneralPath p, double x2, double y2, double x3, double y3) {
Point2D p1 = p.getCurrentPoint();
double x1 = p1.getX();
double y1 = p1.getY();
boolean xe = (x1 == x2 && x2 == x3);
boolean ye = (y1 == y2 && y2 == y3);
if (xe && ye) return;
if (xe || ye) { p.lineTo(x3, y3); return; }
double d = arcHK(x1, y1, x2, y2, x3, y3);
double h = arcH(x1, y1, x2, y2, x3, y3) / d;
double k = arcK(x1, y1, x2, y2, x3, y3) / d;
if (Double.isNaN(h) || Double.isInfinite(h)) { p.lineTo(x3, y3); return; }
if (Double.isNaN(k) || Double.isInfinite(k)) { p.lineTo(x3, y3); return; }
double r = Math.hypot(k - y1, x1 - h);
double a1 = Math.toDegrees(Math.atan2(k - y1, x1 - h));
double a2 = Math.toDegrees(Math.atan2(k - y2, x2 - h));
double a3 = Math.toDegrees(Math.atan2(k - y3, x3 - h));
Arc2D.Double arc = new Arc2D.Double();
arc.x = h - r;
arc.y = k - r;
arc.width = r + r;
arc.height = r + r;
arc.start = a1;
if ((a1 <= a2 && a2 <= a3) || (a3 <= a2 && a2 <= a1)) {
arc.extent = a3 - a1;
} else if (a3 <= a1) {
arc.extent = a3 - a1 + 360;
} else {
arc.extent = a3 - a1 - 360;
}
p.append(arc, true);
}
示例2: arcTo
import java.awt.geom.GeneralPath; //导入方法依赖的package包/类
private static void arcTo(
GeneralPath p, double rx, double ry, double a,
boolean large, boolean sweep, double x, double y
) {
Point2D p0 = p.getCurrentPoint();
double x0 = p0.getX();
double y0 = p0.getY();
if (x0 == x && y0 == y) return;
if (rx == 0 || ry == 0) { p.lineTo(x, y); return; }
double dx2 = (x0 - x) / 2;
double dy2 = (y0 - y) / 2;
a = Math.toRadians(a % 360);
double ca = Math.cos(a);
double sa = Math.sin(a);
double x1 = sa * dy2 + ca * dx2;
double y1 = ca * dy2 - sa * dx2;
rx = Math.abs(rx);
ry = Math.abs(ry);
double Prx = rx * rx;
double Pry = ry * ry;
double Px1 = x1 * x1;
double Py1 = y1 * y1;
double rc = Px1/Prx + Py1/Pry;
if (rc > 1) {
rx = Math.sqrt(rc) * rx;
ry = Math.sqrt(rc) * ry;
Prx = rx * rx;
Pry = ry * ry;
}
double s = (large == sweep) ? -1 : 1;
double sq = ((Prx*Pry)-(Prx*Py1)-(Pry*Px1)) / ((Prx*Py1)+(Pry*Px1));
if (sq < 0) sq = 0;
double m = s * Math.sqrt(sq);
double cx1 = m * ((rx * y1) / ry);
double cy1 = m * -((ry * x1) / rx);
double sx2 = (x0 + x) / 2;
double sy2 = (y0 + y) / 2;
double cx = sx2 + ca * cx1 - sa * cy1;
double cy = sy2 + sa * cx1 + ca * cy1;
double ux = (x1 - cx1) / rx;
double uy = (y1 - cy1) / ry;
double vx = (-x1 -cx1) / rx;
double vy = (-y1 -cy1) / ry;
double sn = Math.sqrt(ux*ux + uy*uy);
double sp = ux;
double ss = (uy < 0) ? -1 : 1;
double as = Math.toDegrees(ss * Math.acos(sp / sn));
double en = Math.sqrt((ux*ux + uy*uy) * (vx*vx + vy*vy));
double ep = ux * vx + uy * vy;
double es = (ux * vy - uy * vx < 0) ? -1 : 1;
double ae = Math.toDegrees(es * Math.acos(ep / en));
if (!sweep && ae > 0) ae -= 360;
if (sweep && ae < 0) ae += 360;
ae %= 360;
as %= 360;
Arc2D.Double arc = new Arc2D.Double();
arc.x = cx - rx;
arc.y = cy - ry;
arc.width = rx * 2;
arc.height = ry * 2;
arc.start = -as;
arc.extent = -ae;
double acx = arc.getCenterX();
double acy = arc.getCenterY();
AffineTransform t = AffineTransform.getRotateInstance(a, acx, acy);
p.append(t.createTransformedShape(arc), true);
}