Java Code Examples for java.awt.geom.Path2D#curveTo()
The following examples show how to use
java.awt.geom.Path2D#curveTo() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FlatOptionPaneQuestionIcon.java From FlatLaf with Apache License 2.0 | 6 votes |
@Override protected Shape createInside() { Path2D q = new Path2D.Float(); q.moveTo( 14, 20 ); q.lineTo( 18, 20 ); q.curveTo( 18, 16, 23, 16, 23, 12 ); q.curveTo( 23, 8, 20, 6, 16, 6 ); q.curveTo( 12, 6, 9, 8, 9, 12 ); q.curveTo( 9, 12, 13, 12, 13, 12 ); q.curveTo( 13, 10, 14, 9, 16, 9 ); q.curveTo( 18, 9, 19, 10, 19, 12 ); q.curveTo( 19, 15, 14, 15, 14, 20 ); q.closePath(); Path2D inside = new Path2D.Float( Path2D.WIND_EVEN_ODD ); inside.append( new Rectangle2D.Float( 14, 22, 4, 4 ), false ); inside.append( q, false ); return inside; }
Example 2
Source File: AwtRenderingBackend.java From htmlunit with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} */ @Override public void bezierCurveTo(final double cp1x, final double cp1y, final double cp2x, final double cp2y, final double x, final double y) { if (LOG.isDebugEnabled()) { LOG.debug("[" + id_ + "] bezierCurveTo()"); } final Path2D subPath = getCurrentSubPath(); if (subPath != null) { final Point2D cp1 = transformation_.transform(new Point2D.Double(cp1x, cp1y), null); final Point2D cp2 = transformation_.transform(new Point2D.Double(cp2x, cp2y), null); final Point2D p = transformation_.transform(new Point2D.Double(x, y), null); subPath.curveTo(cp1.getX(), cp1.getY(), cp2.getX(), cp2.getY(), p.getX(), p.getY()); } }
Example 3
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
private static Area getOuterShape(Shape shape) { Area area = new Area(); Path2D path = new Path2D.Double(); PathIterator pi = shape.getPathIterator(null); double[] coords = new double[6]; while (!pi.isDone()) { int pathSegmentType = pi.currentSegment(coords); switch (pathSegmentType) { case PathIterator.SEG_MOVETO: path.moveTo(coords[0], coords[1]); break; case PathIterator.SEG_LINETO: path.lineTo(coords[0], coords[1]); break; case PathIterator.SEG_QUADTO: path.quadTo(coords[0], coords[1], coords[2], coords[3]); break; case PathIterator.SEG_CUBICTO: path.curveTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]); break; case PathIterator.SEG_CLOSE: path.closePath(); area.add(createArea(path)); path.reset(); break; default: System.err.println("Unexpected value! " + pathSegmentType); break; } pi.next(); } return area; }
Example 4
Source File: ShapeUtilitiesTest.java From sis with Apache License 2.0 | 5 votes |
/** * Tests {@link ShapeUtilities#toPrimitive(Shape)}. */ @Test public void testToPrimitive() { final Path2D path = new Path2D.Double(); path.moveTo(4, 5); path.lineTo(7, 9); Shape p = ShapeUtilities.toPrimitive(path); assertInstanceOf("toPrimitive", Line2D.class, p); assertEquals("P1", new Point2D.Double(4, 5), ((Line2D) p).getP1()); assertEquals("P2", new Point2D.Double(7, 9), ((Line2D) p).getP2()); path.reset(); path.moveTo(4, 5); path.quadTo(6, 7, 8, 5); p = ShapeUtilities.toPrimitive(path); assertInstanceOf("toPrimitive", QuadCurve2D.class, p); assertEquals("P1", new Point2D.Double(4, 5), ((QuadCurve2D) p).getP1()); assertEquals("CtrlPt", new Point2D.Double(6, 7), ((QuadCurve2D) p).getCtrlPt()); assertEquals("P2", new Point2D.Double(8, 5), ((QuadCurve2D) p).getP2()); path.reset(); path.moveTo(4, 5); path.curveTo(6, 7, 8, 6, 9, 4); 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()); assertEquals("P2", new Point2D.Double(9, 4), ((CubicCurve2D) p).getP2()); }
Example 5
Source File: Path2DCopyConstructor.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
static Path2D addCubics(Path2D p2d) { for (int i = 0; i < 10; i++) { p2d.curveTo(1.1 * i, 1.2 * i, 1.3 * i, 1.4 * i, 1.5 * i, 1.6 * i); } return p2d; }
Example 6
Source File: Polygon.java From Digital with GNU General Public License v3.0 | 4 votes |
@Override public void drawTo(Path2D path2d) { path2d.curveTo(c1.getXFloat(), c1.getYFloat(), c2.getXFloat(), c2.getYFloat(), p.getXFloat(), p.getYFloat()); }
Example 7
Source File: ConcordiaGraphPanel.java From ET_Redux with Apache License 2.0 | 4 votes |
private void drawConcordiaLineSegments( Graphics2D g2d,// ConcordiaLine myConcordiaLine, String concordiaErrorStyle, Color concordiaLineColor, float concordiaLineWeight) { // draw the concordia segments ParametricCurveSegmentI myWorkingSeg = myConcordiaLine.getStartSeg(); ParametricCurveSegmentI myWorkingSegSaved = myWorkingSeg; Path2D curvedP = new Path2D.Double(Path2D.WIND_NON_ZERO); // start at bottom left of concordia curvedP.moveTo( (float) mapX(myWorkingSeg.minX()), (float) mapY(myWorkingSeg.minY())); curvedP.curveTo(// (float) mapX(myWorkingSeg.minX()), (float) mapY(myWorkingSeg.minY()), (float) mapX(myWorkingSeg.controlX()), (float) mapY(myWorkingSeg.controlY()), (float) mapX(myWorkingSeg.maxX()), (float) mapY(myWorkingSeg.maxY())); myWorkingSegSaved = myWorkingSeg; myWorkingSeg = myWorkingSeg.getRightSeg(); while ((myWorkingSeg != null) && (myWorkingSeg.getLeftSeg() != null)) { // stops traversal to fake upper envelope curvedP.curveTo(// mapX(myWorkingSeg.minX()), // mapY(myWorkingSeg.minY()), // mapX(myWorkingSeg.controlX()), // mapY(myWorkingSeg.controlY()), // mapX(myWorkingSeg.maxX()), // mapY(myWorkingSeg.maxY())); myWorkingSegSaved = myWorkingSeg; myWorkingSeg = myWorkingSeg.getRightSeg(); } if (isShowConcordiaErrorBars()) {// && getConcordiaFlavor().equalsIgnoreCase( "C" ) ) { Path2D errorEnvelope = myConcordiaLine.getUpperUnctEnvelope(); errorEnvelope.append(myConcordiaLine.getLowerUnctEnvelope(), true); errorEnvelope.closePath(); if (concordiaErrorStyle.equalsIgnoreCase("shaded")) { g2d.setColor(ReduxConstants.myNotEditingGreyColor); g2d.fill(errorEnvelope); } else { g2d.setColor(Color.BLACK); g2d.setStroke(new BasicStroke( 1f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1f, new float[]{2f}, 0f)); g2d.draw(errorEnvelope); } } // may 2010 new curved line g2d.setColor(concordiaLineColor); g2d.setStroke(new BasicStroke(concordiaLineWeight)); g2d.draw(curvedP); }
Example 8
Source File: ShapeDebugFrame.java From rcrs-server with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public Shape paint(Graphics2D g, ScreenTransform transform) { if (shape == null || (shape instanceof Area && ((Area)shape).isEmpty())) { return null; } Path2D path = new Path2D.Double(); PathIterator pi = shape.getPathIterator(null); // CHECKSTYLE:OFF:MagicNumber double[] d = new double[6]; while (!pi.isDone()) { int type = pi.currentSegment(d); switch (type) { case PathIterator.SEG_MOVETO: path.moveTo(transform.xToScreen(d[0]), transform.yToScreen(d[1])); break; case PathIterator.SEG_LINETO: path.lineTo(transform.xToScreen(d[0]), transform.yToScreen(d[1])); break; case PathIterator.SEG_CLOSE: path.closePath(); break; case PathIterator.SEG_QUADTO: path.quadTo(transform.xToScreen(d[0]), transform.yToScreen(d[1]), transform.xToScreen(d[2]), transform.yToScreen(d[3])); break; case PathIterator.SEG_CUBICTO: path.curveTo(transform.xToScreen(d[0]), transform.yToScreen(d[1]), transform.xToScreen(d[2]), transform.yToScreen(d[3]), transform.xToScreen(d[4]), transform.yToScreen(d[5])); break; default: throw new RuntimeException("Unexpected PathIterator constant: " + type); } pi.next(); } // CHECKSTYLE:ON:MagicNumber g.setColor(colour); if (fill) { g.fill(path); } else { g.draw(path); } return path.createTransformedShape(null); }
Example 9
Source File: Path2DGrow.java From jdk8u-jdk with GNU General Public License v2.0 | 4 votes |
static void addCubic(Path2D p2d, int i) { p2d.curveTo(1.1 * i, 1.2 * i, 1.3 * i, 1.4 * i, 1.5 * i, 1.6 * i); }
Example 10
Source File: GeneralPath2D.java From javaGeom with GNU Lesser General Public License v3.0 | 4 votes |
public void updatePath(Path2D path) { path.curveTo(p1.x(), p1.y(), p2.x(), p2.y(), p3.x(), p3.y()); }
Example 11
Source File: Path2DCopyConstructor.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
static Path2D addCubics(Path2D p2d) { for (int i = 0; i < 10; i++) { p2d.curveTo(1.1 * i, 1.2 * i, 1.3 * i, 1.4 * i, 1.5 * i, 1.6 * i); } return p2d; }
Example 12
Source File: Path2DGrow.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
static void addCubic(Path2D p2d, int i) { p2d.curveTo(1.1 * i, 1.2 * i, 1.3 * i, 1.4 * i, 1.5 * i, 1.6 * i); }
Example 13
Source File: Path2DCopyConstructor.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 4 votes |
static Path2D addCubics(Path2D p2d) { for (int i = 0; i < 10; i++) { p2d.curveTo(1.1 * i, 1.2 * i, 1.3 * i, 1.4 * i, 1.5 * i, 1.6 * i); } return p2d; }
Example 14
Source File: Path2DGrow.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
static void addCubic(Path2D p2d, int i) { p2d.curveTo(1.1 * i, 1.2 * i, 1.3 * i, 1.4 * i, 1.5 * i, 1.6 * i); }
Example 15
Source File: Path2DGrow.java From jdk8u_jdk with GNU General Public License v2.0 | 4 votes |
static void addCubic(Path2D p2d, int i) { p2d.curveTo(1.1 * i, 1.2 * i, 1.3 * i, 1.4 * i, 1.5 * i, 1.6 * i); }
Example 16
Source File: Path2DGrow.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
static void addCubic(Path2D p2d, int i) { p2d.curveTo(1.1 * i, 1.2 * i, 1.3 * i, 1.4 * i, 1.5 * i, 1.6 * i); }
Example 17
Source File: Path2DCopyConstructor.java From jdk8u60 with GNU General Public License v2.0 | 4 votes |
static Path2D addCubics(Path2D p2d) { for (int i = 0; i < 10; i++) { p2d.curveTo(1.1 * i, 1.2 * i, 1.3 * i, 1.4 * i, 1.5 * i, 1.6 * i); } return p2d; }
Example 18
Source File: Path2DGrow.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
static void addCubic(Path2D p2d, int i) { p2d.curveTo(1.1 * i, 1.2 * i, 1.3 * i, 1.4 * i, 1.5 * i, 1.6 * i); }
Example 19
Source File: Path2DCopyConstructor.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
static Path2D addCubics(Path2D p2d) { for (int i = 0; i < 10; i++) { p2d.curveTo(1.1 * i, 1.2 * i, 1.3 * i, 1.4 * i, 1.5 * i, 1.6 * i); } return p2d; }
Example 20
Source File: Path2DCopyConstructor.java From dragonwell8_jdk with GNU General Public License v2.0 | 4 votes |
static Path2D addCubics(Path2D p2d) { for (int i = 0; i < 10; i++) { p2d.curveTo(1.1 * i, 1.2 * i, 1.3 * i, 1.4 * i, 1.5 * i, 1.6 * i); } return p2d; }