本文整理汇总了Java中java.awt.geom.QuadCurve2D.subdivide方法的典型用法代码示例。如果您正苦于以下问题:Java QuadCurve2D.subdivide方法的具体用法?Java QuadCurve2D.subdivide怎么用?Java QuadCurve2D.subdivide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.geom.QuadCurve2D
的用法示例。
在下文中一共展示了QuadCurve2D.subdivide方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDisplacedSegments
import java.awt.geom.QuadCurve2D; //导入方法依赖的package包/类
/**
* Get the "top" and "bottom" segments of a given segment.
* First array element is p0 + normal, second is p0 - normal.
*/
public Segment[] getDisplacedSegments(double radius)
{
this.radius = radius;
double x0 = P1.getX();
double y0 = P1.getY();
double x1 = cp.getX();
double y1 = cp.getY();
double x2 = P2.getX();
double y2 = P2.getY();
QuadCurve2D left = new QuadCurve2D.Double();
QuadCurve2D right = new QuadCurve2D.Double();
QuadCurve2D orig = new QuadCurve2D.Double(x0, y0, x1, y1, x2, y2);
orig.subdivide(left, right);
QuadSegment s1 = offsetSubdivided(left, true);
QuadSegment s2 = offsetSubdivided(left, false);
s1.add( offsetSubdivided(right, true) );
s2.add( offsetSubdivided(right, false) );
return new Segment[]{s1, s2};
}
示例2: divideAndDraw
import java.awt.geom.QuadCurve2D; //导入方法依赖的package包/类
/**
* Divide the given curve in two half, and call drawCurve on each part.
*/
public boolean divideAndDraw(GL2 gl, Point2D center1, Point2D center2,
QuadCurve2D curve, GLEntity shape1, GLEntity shape2, QuadCurve2D last) {
QuadCurve2D left = new QuadCurve2D.Float();
QuadCurve2D right = new QuadCurve2D.Float();
curve.subdivide(left, right);
boolean resL = drawCurve(gl, center1, center2, left, shape1, shape2, last);
boolean resR = drawCurve(gl, center1, center2, right, shape1, shape2, last);
return resL || resR;
}
示例3: getFromCurve
import java.awt.geom.QuadCurve2D; //导入方法依赖的package包/类
private QuadCurve2D getFromCurve(int index) {
QuadCurve2D curve = getCurvedLine(index);
QuadCurve2D result = new QuadCurve2D.Double();
curve.subdivide(result,null);
return result;
}
示例4: animateTransition3
import java.awt.geom.QuadCurve2D; //导入方法依赖的package包/类
private void animateTransition3(int from, int to, boolean bold, Graphics2D g2d, Color b, Color f) {
Color oldc = g2d.getColor();
g2d.setColor(f);
//arrow = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
double gap, x1, x2, y, ctrlx, ctrly;
if (bold) {
g2d.setStroke(strokeB);
}
if (from > to) {
x2 = to * (4 * STATUS_RAD + 2 * ELEMS_GAP) + START_GAP + STATUS_RAD * 2;//+ ELEMS_GAP;
x1 = from * (4 * STATUS_RAD + 2 * ELEMS_GAP) + START_GAP;// - ELEMS_GAP;
y = (panelH) / 2.0 + STATUS_RAD;
ctrly = y + STATUS_RAD;
gap = ELEMS_GAP;
} else {
x1 = from * (4 * STATUS_RAD + 2 * ELEMS_GAP) + START_GAP + STATUS_RAD * 2;//+ ELEMS_GAP;
x2 = to * (4 * STATUS_RAD + 2 * ELEMS_GAP) + START_GAP;// - ELEMS_GAP;
y = (panelH) / 2.0 - STATUS_RAD;
ctrly = y - STATUS_RAD / 2.0;
gap = 2 * ELEMS_GAP;
}
ctrlx = (x1 + x2) / 2;
QuadCurve2D prova;
switch (frame) {
case 1:
prova = new QuadCurve2D.Double(x1, y, ctrlx, ctrly, x2, y);
prova.subdivide(prova, null);
prova.subdivide(prova, null);
break;
case 2:
prova = new QuadCurve2D.Double(x1, y, ctrlx, ctrly, x2, y);
prova.subdivide(prova, null);
break;
case 3:
prova = new QuadCurve2D.Double(x1, y, ctrlx, ctrly, x2, y);
prova.subdivide(null, prova);
prova.subdivide(null, prova);
break;
default:
prova = new QuadCurve2D.Double(x1, y, ctrlx, ctrly, x2, y);
prova.subdivide(prova, null);
break;
}
Point2D p = prova.getP2();
transitionE = new Ellipse2D.Double(p.getX() - ELEMS_GAP, p.getY() - gap, 2 * ELEMS_GAP, 2 * ELEMS_GAP);
g2d.fill(transitionE);
g2d.setPaint(b);
g2d.draw(transitionE);
g2d.setColor(oldc);
g2d.setStroke(stroke);
}
示例5: linkShapes
import java.awt.geom.QuadCurve2D; //导入方法依赖的package包/类
/**
* Links the two given shapes (and their centers) with this arrow. Shapes are
* used to determine if points are inside the shapes, or outside. This is
* useful to draw an arrow that starts and end at the edge of the shape, and
* not in the middle of the shape.
*
* @param gl GL object where to draw this shape.
* @param center1 origin point of the arrow
* @param center2 target point for this arrow
* @param shape1 shape at the starting point
* @param shape2
* @param deviation
* @return
*/
public Point2D linkShapes(GL2 gl, Point2D center1, Point2D center2,
GLEntity shape1, GLEntity shape2, float deviation) {
Vec2 c1 = new Vec2(center1);
Vec2 c2 = new Vec2(center2);
Vec2 dir = c2.minus(c1);
Vec2 norm = new Vec2(dir.y, -dir.x).mult(deviation);
Vec2 middle = c1.plus(c2).div(2.0f).plus(norm);
QuadCurve2D curve = new QuadCurve2D.Float(c1.x, c1.y, middle.x, middle.y,
c2.x, c2.y);
QuadCurve2D last = new QuadCurve2D.Float();
// enable GL_LINE_STIPPLE if edge must be dashed
if (dashed) {
gl.glEnable(GL2.GL_LINE_STIPPLE);
gl.glLineStipple(1, (short) 0xf0f0);
}
boolean ok = drawCurve(gl, center1, center2, curve, shape1, shape2, last);
// now disable GL_LINE_STIPPLE if it was enabled
if (dashed) {
gl.glDisable(GL2.GL_LINE_STIPPLE);
}
if (ok) {
// draw the head at the last position, trying to orient it so that it
// follows the last segment of the "line".
double x1 = last.getP1().getX();
double y1 = last.getP1().getY();
double x2 = last.getP2().getX();
double y2 = last.getP2().getY();
double slope = (y2 - y1) / (x2 - x1);
double angle = (float) Math.tanh(slope) - Math.PI / 2.0;
if (x2 < x1) {
angle += Math.PI;
}
head.setTranslation((float) (last.getP2().getX()), (float) (last.getP2()
.getY()), 0f);
head.setScale(8f, 8f, 8f);
head.setRotation(angle);
head.fill(gl);
}
QuadCurve2D left = new QuadCurve2D.Float();
QuadCurve2D right = new QuadCurve2D.Float();
curve.subdivide(left, right);
return right.getP1(); // new Point2D.Float(middle.x, middle.y);
}
示例6: getToCurve
import java.awt.geom.QuadCurve2D; //导入方法依赖的package包/类
private QuadCurve2D getToCurve(int index) {
QuadCurve2D curve = getCurvedLine(index);
QuadCurve2D result = new QuadCurve2D.Double();
curve.subdivide(null,result);
return result;
}
示例7: getMiddleOf
import java.awt.geom.QuadCurve2D; //导入方法依赖的package包/类
private Point getMiddleOf(QuadCurve2D curve) {
QuadCurve2D result = new QuadCurve2D.Double();
curve.subdivide(result,null);
return new Point((int)result.getP2().getX(), (int)result.getP2().getY());
}