@Implementation protected void quadTo(float x1, float y1, float x2, float y2) { isSimplePath = false; if (!hasPoints()) { moveTo(0, 0); } mPath.quadTo(x1, y1, mLastX = x2, mLastY = y2); }
@Implementation protected void rQuadTo(float dx1, float dy1, float dx2, float dy2) { if (!hasPoints()) { mPath.moveTo(mLastX = 0, mLastY = 0); } dx1 += mLastX; dy1 += mLastY; dx2 += mLastX; dy2 += mLastY; mPath.quadTo(dx1, dy1, mLastX = dx2, mLastY = dy2); }
private static void addQuadBezierTo(final Path2D path, final CTPath2DQuadBezierTo xo) { final CTAdjPoint2D pt1 = xo.getPtArray(0); final CTAdjPoint2D pt2 = xo.getPtArray(1); path.quadTo((Long)pt1.getX(), (Long)pt1.getY(), (Long)pt2.getX(), (Long)pt2.getY()); }
@Override public Path quadraticCurveTo(float cpx, float cpy, float x, float y) { path.quadTo(cpx, cpy, x, y); return this; }
@Override public Path quadraticCurveTo(float cpx, float cpy, float x, float y) { path.quadTo(cpx, cpy, x, y); return this; }
@Override public Path quadraticCurveTo(float cpx, float cpy, float x, float y) { path.quadTo(cpx, cpy, x, y); return this; }
@Override public Path quadraticCurveTo(float cpx, float cpy, float x, float y) { path.quadTo(cpx, cpy, x, y); return this; }
/** * Adds a hemispherical section to the current path. This is used to create * the gap in a scroll bar button or cap into which the scroll bar thumb * will fit. * * @param x the X coordinate of the upper-left corner of the button * or cap * @param y the Y coordinate of the upper-left corner of the button * or cap * @param w the width of the button or cap * @param h the height of the button or cap * @param isAtLeft {@code true} if the gap is at the left end of the button, * {@code false} if it is at the right. */ private void addScrollGapPath(int x, int y, int w, int h, boolean isAtLeft) { final double hHalf = h / 2.0; final double wFull = isAtLeft ? w : 0; final double wHalfOff = isAtLeft ? w - hHalf : hHalf; path.quadTo(x + wHalfOff, y + h, x + wHalfOff, y + hHalf); path.quadTo(x + wHalfOff, y, x + wFull, y); }
/** * {@inheritDoc} */ @Override public void quadraticCurveTo(final double cpx, final double cpy, final double x, final double y) { final Path2D subPath = getCurrentSubPath(); if (subPath != null) { final Point2D cp = transformation_.transform(new Point2D.Double(cpx, cpy), null); final Point2D p = transformation_.transform(new Point2D.Double(x, y), null); subPath.quadTo(cp.getX(), cp.getY(), p.getX(), p.getY()); } }
@Override void paintImage(Graphics2D g, int width, int height, int period) { double dx = 0; double lower = height - 1; double upper = lower - period; Path2D path = new Path2D.Double(); path.moveTo(dx, lower); if (height < 6) { g.setStroke(THIN_STROKE); while (dx < width) { path.lineTo(dx += period, upper); path.lineTo(dx += period, lower); } } else { double size = (double)period / 2; double prev = dx - size / 2; double center = (upper + lower) / 2; while (dx < width) { path.quadTo(prev += size, lower, dx += size, center); path.quadTo(prev += size, upper, dx += size, upper); path.quadTo(prev += size, upper, dx += size, center); path.quadTo(prev += size, lower, dx += size, lower); } } path.lineTo((double)width, lower); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.draw(path); } };
/** * Return a path for a discrete slider thumb's concentric sections. * * @param x the X coordinate of the upper-left corner of the section * @param y the Y coordinate of the upper-left corner of the section * @param w the width of the section * @param h the height of the section * @param size the CornerSize representing the rounding amount for the * section * * @return a path representing the shape. */ public Shape createSliderThumbDiscrete(final int x, final int y, final int w, final int h, final CornerSize size) { final double topArc = size.getRadius(w, h); final double bottomArcH = size == CornerSize.INTERIOR ? 0 : 1; final double bottomArcW = 3; path.reset(); path.moveTo(x, y + topArc); path.quadTo(x, y, x + topArc, y); path.lineTo(x + w - topArc, y); path.quadTo(x + w, y, x + w, y + topArc); path.lineTo(x + w, y + h / 2.0); path.quadTo(x + w - bottomArcW, y + h - bottomArcH, x + w / 2.0, y + h); path.quadTo(x + bottomArcW, y + h - bottomArcH, x, y + h / 2.0); path.closePath(); return path; }
@Implementation protected void rQuadTo(float dx1, float dy1, float dx2, float dy2) { if (!hasPoints()) { mPath.moveTo(mLastX = 0, mLastY = 0); } dx1 += mLastX; dy1 += mLastY; dx2 += mLastX; dy2 += mLastY; mPath.quadTo(dx1, dy1, mLastX = dx2, mLastY = dy2); }
@Implementation protected void quadTo(float x1, float y1, float x2, float y2) { isSimplePath = false; if (!hasPoints()) { moveTo(0, 0); } mPath.quadTo(x1, y1, mLastX = x2, mLastY = y2); }
@Override public void drawTo(Path2D path2d) { path2d.quadTo(c.getXFloat(), c.getYFloat(), p.getXFloat(), p.getYFloat()); }
/** * Add a curved segment, defined by two new points, to this path node by * drawing a Quadratic curve that intersects both the current coordinates and * the specified coordinates <code>(x2,y2)</code>, using the specified point * <code>(x1,y1)</code> as a quadratic parametric control point. All coordinates * are specified in double precision. * * @param x1 x coordinate of the quadratic control point * @param y1 y coordinate of the quadratic control point * @param x2 x coordinate of the final end point * @param y2 y coordinate of the final end point */ public final void quadTo(final double x1, final double y1, final double x2, final double y2) { Path2D oldPath = (Path2D) path.clone(); path.quadTo(x1, y1, x2, y2); updateBoundsFromShape(); firePropertyChange(-1, "path", oldPath, getPath()); }
/** * Add a curved segment, defined by two new points, to this path node by * drawing a Quadratic curve that intersects both the current coordinates and * the specified coordinates <code>(x2,y2)</code>, using the specified point * <code>(x1,y1)</code> as a quadratic parametric control point. All coordinates * are specified in double precision. * * @param x1 x coordinate of the quadratic control point * @param y1 y coordinate of the quadratic control point * @param x2 x coordinate of the final end point * @param y2 y coordinate of the final end point */ public final void quadTo(final double x1, final double y1, final double x2, final double y2) { Path2D oldPath = (Path2D) path.clone(); path.quadTo(x1, y1, x2, y2); updateBoundsFromShape(); firePropertyChange(-1, "path", oldPath, getPath()); }
private static void addQuadBezierTo(final Path2D path, final CTPath2DQuadBezierTo xo) { final CTAdjPoint2D pt1 = xo.getPtArray(0); final CTAdjPoint2D pt2 = xo.getPtArray(1); path.quadTo((Long)pt1.getX(), (Long)pt1.getY(), (Long)pt2.getX(), (Long)pt2.getY()); }
private GeneralPath createRoundBracket(Point2d p1, Point2d p2, Vector2d perp, Point2d midpoint) { Path2D path = new Path2D.Double(); // bracket 1 (cp: control point) path.moveTo(p1.x + perp.x, p1.y + perp.y); Point2d cpb1 = new Point2d(midpoint); cpb1.add(VecmathUtil.negate(perp)); path.quadTo(cpb1.x, cpb1.y, p2.x + perp.x, p2.y + perp.y); return GeneralPath.outlineOf(path, stroke, foreground); }
/** * Transforms the specified shape. The default implementation returns a new shape with * the transform of all control points. * * @param shape the Shape to transform. * @return the transformed shape. * @throws TransformException if a transform failed. */ @Override public Shape createTransformedShape(final Shape shape) throws TransformException { final PathIterator it = shape.getPathIterator(null); final Path2D path = new Path2D.Double(it.getWindingRule()); final double[] b = new double[6]; while (!it.isDone()) { final int mode = it.currentSegment(b); switch (mode) { case PathIterator.SEG_CLOSE: path.closePath(); break; case PathIterator.SEG_MOVETO: transform(b, 0, b, 0, 1); path.moveTo (b[0], b[1]); break; case PathIterator.SEG_LINETO: transform(b, 0, b, 0, 1); path.lineTo (b[0], b[1]); break; case PathIterator.SEG_QUADTO: transform(b, 0, b, 0, 2); path.quadTo (b[0], b[1], b[2], b[3]); break; case PathIterator.SEG_CUBICTO: transform(b, 0, b, 0, 3); path.curveTo(b[0], b[1], b[2], b[3], b[4], b[5]); break; default: throw new AssertionError(mode); } it.next(); } return path; }
/** * Transforms the specified shape. The default implementation returns a new shape with * the transform of all control points. * * @param shape the Shape to transform. * @return the transformed shape. * @throws TransformException if a transform failed. */ @Override public Shape createTransformedShape(final Shape shape) throws TransformException { final PathIterator it = shape.getPathIterator(null); final Path2D path = new Path2D.Double(it.getWindingRule()); final double[] b = new double[6]; while (!it.isDone()) { final int mode = it.currentSegment(b); switch (mode) { case PathIterator.SEG_CLOSE: path.closePath(); break; case PathIterator.SEG_MOVETO: transform(b, 0, b, 0, 1); path.moveTo (b[0], b[1]); break; case PathIterator.SEG_LINETO: transform(b, 0, b, 0, 1); path.lineTo (b[0], b[1]); break; case PathIterator.SEG_QUADTO: transform(b, 0, b, 0, 2); path.quadTo (b[0], b[1], b[2], b[3]); break; case PathIterator.SEG_CUBICTO: transform(b, 0, b, 0, 3); path.curveTo(b[0], b[1], b[2], b[3], b[4], b[5]); break; default: throw new AssertionError(mode); } it.next(); } return path; }