private double length(CubicCurve2D curve) { return curve.getP1().distance(curve.getP2()); }
public void curveTo(CubicCurve2D curve) { final double flatness = curve.getFlatness(); final double dist = curve.getP1().distance(curve.getP2()); if (flatness > 0.1 && dist > 20) { final CubicCurve2D left = new CubicCurve2D.Double(); final CubicCurve2D right = new CubicCurve2D.Double(); curve.subdivide(left, right); curveTo(left); curveTo(right); return; } lineTo(curve.getP2()); }
public void setRepresentedCubic(CubicCurve2D c) { if(null!=c) { this.p0.setLocation(c.getP1()); this.p1.setLocation(c.getP2()); this.c0.setLocation(c.getCtrlP1()); this.c1.setLocation(c.getCtrlP2()); this.dragGesture(); } }
private double length(CubicCurve2D curve) { return curve.getP1().distance(curve.getP2()); }
@Override public Point2D getEndVector (boolean reverse) { // We use the control points to retrieve tangent vector Point2D vector = reverse ? PointUtil.subtraction(curve.getP1(), curve.getCtrlP1()) : PointUtil.subtraction(curve.getP2(), curve.getCtrlP2()); // Normalize vector = PointUtil.times(vector, 1.0 / PointUtil.length(vector)); return vector; }
final Point2D end = (side == LEFT) ? curve.getP1() : curve.getP2(); pmSlur.setDefaultX(toTenths(end.getX() - current.note.getCenterLeft().x)); pmSlur.setDefaultY(yOf(end, staff));
public void curveTo(CubicCurve2D curve) { final double flatness = curve.getFlatness(); final double dist = curve.getP1().distance(curve.getP2()); if (flatness > 0.1 && dist > 20) { final CubicCurve2D left = new CubicCurve2D.Double(); final CubicCurve2D right = new CubicCurve2D.Double(); curve.subdivide(left, right); curveTo(left); curveTo(right); return; } lineTo(curve.getP2()); }
@Override public boolean check (SlurInter slur) { if ((slur.getHead(LEFT) == null) && (slur.getExtension(LEFT) == null)) { // Check we are in first measure Point2D end = slur.getCurve().getP1(); SystemInfo system = slur.getSig().getSystem(); MeasureStack stack = system.getStackAt(end); if (stack == system.getFirstStack()) { // Check slur ends in first measure half (excluding header area) Staff staff = system.getClosestStaff(end); Measure measure = stack.getMeasureAt(staff); int middle = (staff.getHeaderStop() + measure.getAbscissa(LEFT, staff) + measure.getWidth()) / 2; if (end.getX() < middle) { return true; } } } return false; } };
double pp = thisStaff.pitchPositionOf(PointUtil.rounded(getCurve().getP1()));
p = ShapeUtilities.toPrimitive(path); assertInstanceOf("toPrimitive", CubicCurve2D.class, p); assertEquals("P1", new Point2D.Double(4, 5), ((CubicCurve2D) p).getP1()); assertEquals("CtrlP1", new Point2D.Double(6, 7), ((CubicCurve2D) p).getCtrlP1()); assertEquals("CtrlP2", new Point2D.Double(8, 6), ((CubicCurve2D) p).getCtrlP2());
private void addSecEdges(TreeLayoutData treeLayout, LayoutOptions options) { for (Edge e: graph.getEdges()) { if (!GRAPH_TOOLS.hasEdgeSubtype(e, GRAPH_TOOLS.getSecEdgeSubType())) { continue; } Rectangle2D sourceRect = treeLayout.getRect(e.getSource()); Rectangle2D targetRect = treeLayout.getRect(e.getDestination()); CubicCurve2D curveData = secedgeCurve(treeLayout.getOrientation(), sourceRect, targetRect); T secedgeElem = backend.cubicCurve(curveData, styler.getStroke(e, input), styler.getEdgeColor(e, input)); secedgeElem.setZValue(-2); T arrowElem = backend.arrow(curveData.getP1(), curveData.getCtrlP1(), new Rectangle2D.Double(0, 0, 8, 8), styler.getEdgeColor(e, input)); arrowElem.setZValue(-1); arrowElem.setParentItem(secedgeElem); Point2D labelPos = evaluate(curveData, 0.8); T label = backend.makeLabel( labeler.getLabel(e, input), labelPos, styler.getFont(e), styler.getTextBrush(e), Alignment.CENTERED, styler.getShape(e, input)); label.setParentItem(secedgeElem); secedgeElem.setParentItem(treeLayout.getParentItem()); } }
assertEquals(((QuadCurve2D) expected).getP2(), ((QuadCurve2D) actual).getP2()); } else if ((expected instanceof CubicCurve2D) && (actual instanceof CubicCurve2D)) { assertEquals(((CubicCurve2D) expected).getP1(), ((CubicCurve2D) actual).getP1()); assertEquals(((CubicCurve2D) expected).getCtrlP1(), ((CubicCurve2D) actual).getCtrlP1()); assertEquals(((CubicCurve2D) expected).getCtrlP2(), ((CubicCurve2D) actual).getCtrlP2());