minMax.manage(x + coord[0], y + coord[1]); } else if (type == USegmentType.SEG_CUBICTO) { p.curveTo(x + coord[0], y + coord[1], x + coord[2], y + coord[3], x + coord[4], y + coord[5]); minMax.manage(x + coord[4], y + coord[5]); hasBezier = true;
public static Path2D loopArrow(double angle, double radius, double x, double y, double arrowHeight) { Path2D.Double path = new Path2D.Double(); double angleSin = Math.sin(angle); double angleCos = Math.cos(angle); double angleToSin = Math.sin(angle + FIFTEEN); double angleToCos = Math.cos(angle + FIFTEEN); path.moveTo(x + radius * angleCos, y + radius * angleSin); path.lineTo(x + angleCos * radius * LINE_RADIUS, y + angleSin * radius * LINE_RADIUS); path.curveTo( x + angleCos * radius * CURVE_RADIUS, y + angleSin * radius * CURVE_RADIUS, x + angleToCos * radius * CURVE_RADIUS, y + angleToSin * radius * CURVE_RADIUS, x + angleToCos * radius * LINE_RADIUS, y + angleToSin * radius * LINE_RADIUS); path.lineTo(x + (radius + arrowHeight / 2) * angleToCos, y + (radius + arrowHeight / 2) * angleToSin); return path; }
private static void connectPoints(Graphics2D g, double x1, double y1, double x2, double y2, float c) { if (c == 0) { Line2D.Double line = new Line2D.Double(x1, y1, x2, y2); g.draw(line); } else { Path2D.Double path = new Path2D.Double(); path.moveTo(x1, y1); double dx = x2 - x1; double dy = y2 - y1; // center point double cx = x1 + dx / 2.0; double cy = y1 + dy / 2.0; // calculate only one Bezier control point, // and use it for both. // The normal vector is -dy, dx. double ctrlX = cx - dy * c; double ctrlY = cy + dx * c; path.curveTo(ctrlX, ctrlY, ctrlX, ctrlY, x2, y2); g.draw(path); } }
bx2 = bx3 - (x3 - x1) / 6.0; by2 = (bx2 - bx3) * bdy3 + by3; path.curveTo(bx1, by1, bx2, by2, bx3, by3); bx2 = bx3 - (x3 - x1) / 6.0; by2 = (bx2 - bx3) * bdy3 + by3; path.curveTo(bx1, by1, bx2, by2, bx3, by3); bx2 = bx3 - (x3 - x1) / 6.0; by2 = (bx2 - bx3) * bdy3 + by3; path.curveTo(bx1, by1, bx2, by2, bx3, by3); }else{//have current, previous, but not two before or next path.lineTo(scaledX[i], scaledY[i]);
bx2 = bx3 - (x3 - x1) / 6.0; by2 = (bx2 - bx3) * bdy3 + by3; path.curveTo(bx1, by1, bx2, by2, bx3, by3); bx2 = bx3 - (x3 - x1) / 6.0; by2 = (bx2 - bx3) * bdy3 + by3; path.curveTo(bx1, by1, bx2, by2, bx3, by3); bx2 = bx3 - (x3 - x1) / 6.0; by2 = (bx2 - bx3) * bdy3 + by3; path.curveTo(bx1, by1, bx2, by2, bx3, by3); }else{//have current, previous, but not two before or next path.lineTo(scaledX[i], scaledY[i]);
bx2 = bx3 - (x3 - x1) / 6.0; by2 = (bx2 - bx3) * bdy3 + by3; path.curveTo(bx1, by1, bx2, by2, bx3, by3); bx2 = bx3 - (x3 - x1) / 6.0; by2 = (bx2 - bx3) * bdy3 + by3; path.curveTo(bx1, by1, bx2, by2, bx3, by3); bx2 = bx3 - (x3 - x1) / 6.0; by2 = (bx2 - bx3) * bdy3 + by3; path.curveTo(bx1, by1, bx2, by2, bx3, by3); }else{//have current, previous, but not two before or next path.lineTo(scaledX[i], scaledY[i]);
path.curveTo(21, 60, 21, 43, 17, 37); //left vert path.curveTo(30, 43, 100, 43, 120, 37); //top horiz path.curveTo(115, 45, 115, 57, 117, 62); //right vert path.curveTo(105, 53, 60, 57, 17, 63); //bottom horiz right path.curveTo(37, 85, 35, 79, 35, 77); //left vert path.curveTo(45, 79, 45, 79, 100, 79); //top left horiz path.curveTo(96, 85, 98, 92, 98, 98);//right vert path.curveTo(89, 93, 79, 94, 32, 97);//bottom right horiz path.curveTo(48, 110, 46, 70, 37, 55); //left vert path.curveTo(62, 55, 62, 55, 60, 55); //top horiz path.curveTo(68, 80, 68, 100, 63, 130); //right vert path.curveTo(60, 127, 50, 127, 40, 130);//bottom horiz g.setRenderingHint( RenderingHints.KEY_ANTIALIASING,
double x3 = xyPoints[0]; double y3 = xyPoints[1]; path.curveTo(x1, y1, x2, y2, x3, y3); break;
minMax.manage(x + coord[0], y + coord[1]); } else if (type == USegmentType.SEG_CUBICTO) { p.curveTo(x + coord[0], y + coord[1], x + coord[2], y + coord[3], x + coord[4], y + coord[5]); minMax.manage(x + coord[4], y + coord[5]); hasBezier = true;
n2 = calcIntersection( pair.second[2], pair.second[3], n2, n3 ); n3 = calcIntersection( pair.second[4], pair.second[5], n3, normals.peek() ); path.curveTo( n1[0], n1[1], n2[0], n2[1], n3[0], n3[1] ); break; case SEG_LINETO:
p.moveTo((roundrect.x + aw), (float) roundrect.y); p.lineTo((roundrect.x + roundrect.width - aw), (float) roundrect.y); p.curveTo((roundrect.x + roundrect.width - aw * acv), (float) roundrect.y, // (roundrect.x + roundrect.width), (float)(roundrect.y + ah * acv), // (roundrect.x + roundrect.width), (roundrect.y + ah)); p.lineTo((roundrect.x + roundrect.width), (roundrect.y + roundrect.height - ah)); p.curveTo( p.curveTo((roundrect.x + aw*acv), (roundrect.y + roundrect.height),// p.curveTo((roundrect.x), (roundrect.y + ah*acv),// (roundrect.x + aw*acv), (float)(roundrect.y),// (float)(roundrect.x + aw), (float)(roundrect.y));
@Override public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) { if (getDel()) return; double w = parent.getWidth(); double h = parent.getHeight(); path.curveTo(getA() * w, getB() * h, getC() * w, getD() * h, getX() * w, getY() * h); } }
@Override public void execute(Path2D.Double path, Context ctx){ double x1 = ctx.getValue(arg1); double y1 = ctx.getValue(arg2); double x2 = ctx.getValue(arg3); double y2 = ctx.getValue(arg4); double x3 = ctx.getValue(arg5); double y3 = ctx.getValue(arg6); path.curveTo(x1, y1, x2, y2, x3, y3); } }
Path2D.Double path1 = new Path2D.Double(); path1.moveTo(x1, y1); path1.curveTo(x0, y0, x2, y2, x4, y4); g.draw(path1);
@Override public void addToPath(java.awt.geom.Path2D.Double path, XDGFShape parent) { if (getDel()) return; double w = parent.getWidth(); double h = parent.getHeight(); path.curveTo(getA() * w, getB() * h, getC() * w, getD() * h, getX() * w, getY() * h); } }
@Override public void execute(Path2D.Double path, Context ctx){ double x1 = ctx.getValue(arg1); double y1 = ctx.getValue(arg2); double x2 = ctx.getValue(arg3); double y2 = ctx.getValue(arg4); double x3 = ctx.getValue(arg5); double y3 = ctx.getValue(arg6); path.curveTo(x1, y1, x2, y2, x3, y3); } }