本文整理匯總了Java中java.awt.geom.QuadCurve2D.getCtrlPt方法的典型用法代碼示例。如果您正苦於以下問題:Java QuadCurve2D.getCtrlPt方法的具體用法?Java QuadCurve2D.getCtrlPt怎麽用?Java QuadCurve2D.getCtrlPt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.awt.geom.QuadCurve2D
的用法示例。
在下文中一共展示了QuadCurve2D.getCtrlPt方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: QuadSegment
import java.awt.geom.QuadCurve2D; //導入方法依賴的package包/類
public QuadSegment(QuadCurve2D curve)
{
super();
P1 = curve.getP1();
P2 = curve.getP2();
this.cp = curve.getCtrlPt();
}
示例2: offsetSubdivided
import java.awt.geom.QuadCurve2D; //導入方法依賴的package包/類
private QuadSegment offsetSubdivided(QuadCurve2D curve, boolean plus)
{
double[] n1 = normal(curve.getX1(), curve.getY1(),
curve.getCtrlX(), curve.getCtrlY());
double[] n2 = normal(curve.getCtrlX(), curve.getCtrlY(),
curve.getX2(), curve.getY2());
Point2D cp;
QuadSegment s;
if(!plus)
{
n1[0] = -n1[0];
n1[1] = -n1[1];
n2[0] = -n2[0];
n2[1] = -n2[1];
}
// Handle special cases where the control point is equal to an end point
// or end points are equal (ie, straight lines)
if (curve.getP1().equals(curve.getCtrlPt()))
{
cp = curve.getCtrlPt();
cp.setLocation(cp.getX() + n2[0], cp.getY() + n2[1]);
n1[0] = n2[0];
n1[1] = n2[1];
}
else if (curve.getP2().equals(curve.getCtrlPt()))
{
cp = curve.getCtrlPt();
cp.setLocation(cp.getX() + n1[0], cp.getY() + n1[1]);
n2[0] = n1[0];
n2[1] = n1[1];
}
else if (curve.getP1().equals(curve.getP2()))
{
cp = curve.getCtrlPt();
double deltaX = curve.getX1() - curve.getCtrlX();
double deltaY = curve.getY1() - curve.getCtrlY();
double length = Math.sqrt((deltaX * deltaX) + (deltaY * deltaY));
double ratio = radius / length;
deltaX *= ratio;
deltaY *= ratio;
if (plus)
cp.setLocation(cp.getX() + deltaX, cp.getY() + deltaY);
else
cp.setLocation(cp.getX() - deltaX, cp.getY() - deltaY);
}
else if (n1[0] == n2[0] && n1[1] == n2[1])
{
cp = curve.getCtrlPt();
cp.setLocation(cp.getX() + n1[0], cp.getY() + n1[1]);
}
else
{
cp = lineIntersection(curve.getX1() + n1[0],
curve.getY1() + n1[1],
curve.getCtrlX() + n1[0],
curve.getCtrlY() + n1[1],
curve.getCtrlX() + n2[0],
curve.getCtrlY() + n2[1],
curve.getX2() + n2[0],
curve.getY2() + n2[1], true);
}
s = new QuadSegment(curve.getX1() + n1[0], curve.getY1() + n1[1],
cp.getX(), cp.getY(),
curve.getX2() + n2[0], curve.getY2() + n2[1]);
return s;
}
示例3: offsetSubdivided
import java.awt.geom.QuadCurve2D; //導入方法依賴的package包/類
private QuadSegment offsetSubdivided(QuadCurve2D curve, boolean plus)
{
double[] n1 = normal(curve.getX1(), curve.getY1(),
curve.getCtrlX(), curve.getCtrlY());
double[] n2 = normal(curve.getCtrlX(), curve.getCtrlY(),
curve.getX2(), curve.getY2());
Point2D cp;
QuadSegment s;
if(!plus)
{
n1[0] = -n1[0];
n1[1] = -n1[1];
n2[0] = -n2[0];
n2[1] = -n2[1];
}
// Handle special cases where the control point is equal to an end point
// or end points are equal (ie, straight lines)
if (curve.getP1().equals(curve.getCtrlPt()))
{
cp = curve.getCtrlPt();
cp.setLocation(cp.getX() + n2[0], cp.getY() + n2[1]);
n1[0] = n2[0];
n1[1] = n2[1];
}
else if (curve.getP2().equals(curve.getCtrlPt()))
{
cp = curve.getCtrlPt();
cp.setLocation(cp.getX() + n1[0], cp.getY() + n1[1]);
n2[0] = n1[0];
n2[1] = n1[1];
}
else if (curve.getP1().equals(curve.getP2()))
{
cp = curve.getCtrlPt();
double deltaX = curve.getX1() - curve.getCtrlX();
double deltaY = curve.getY1() - curve.getCtrlY();
double length = Math.sqrt((deltaX * deltaX) + (deltaY * deltaY));
double ratio = radius / length;
deltaX *= ratio;
deltaY *= ratio;
if (plus)
cp.setLocation(cp.getX() + deltaX, cp.getY() + deltaY);
else
cp.setLocation(cp.getX() - deltaX, cp.getY() - deltaY);
}
else if (n1[0] == n2[0] && n1[1] == n2[1])
{
cp = curve.getCtrlPt();
cp.setLocation(cp.getX() + n1[0], cp.getY() + n1[1]);
}
else
{
cp = lineIntersection(curve.getX1() + n1[0],
curve.getY1() + n1[1],
curve.getCtrlX() + n1[0],
curve.getCtrlY() + n1[1],
curve.getCtrlX() + n2[0],
curve.getCtrlY() + n2[1],
curve.getX2() + n2[0],
curve.getY2() + n2[1], true);
}
s = new QuadSegment(curve.getX1() + n1[0], curve.getY1() + n1[1],
cp.getX(), cp.getY(),
curve.getX2() + n2[0], curve.getY2() + n2[1]);
return s;
}