當前位置: 首頁>>代碼示例>>Java>>正文


Java GeneralPath.getCurrentPoint方法代碼示例

本文整理匯總了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);
}
 
開發者ID:kreativekorp,項目名稱:vexillo,代碼行數:33,代碼來源:Symbol.java

示例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);
}
 
開發者ID:kreativekorp,項目名稱:vexillo,代碼行數:68,代碼來源:Symbol.java


注:本文中的java.awt.geom.GeneralPath.getCurrentPoint方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。