java.awt.geom.Path2D#curveTo ( )源码实例Demo

下面列出了java.awt.geom.Path2D#curveTo ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: FlatLaf   文件: FlatOptionPaneQuestionIcon.java
@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;
}
 
源代码2 项目: htmlunit   文件: AwtRenderingBackend.java
/**
 * {@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());
    }
}
 
源代码3 项目: java-swing-tips   文件: MainPanel.java
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;
}
 
源代码4 项目: sis   文件: ShapeUtilitiesTest.java
/**
 * 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());
}
 
源代码5 项目: Digital   文件: Polygon.java
@Override
public void drawTo(Path2D path2d) {
    path2d.curveTo(c1.getXFloat(), c1.getYFloat(),
            c2.getXFloat(), c2.getYFloat(),
            p.getXFloat(), p.getYFloat());
}
 
源代码6 项目: dragonwell8_jdk   文件: Path2DCopyConstructor.java
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;
}
 
源代码7 项目: TencentKona-8   文件: Path2DCopyConstructor.java
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;
}
 
源代码8 项目: TencentKona-8   文件: Path2DGrow.java
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);
}
 
源代码9 项目: jdk8u60   文件: Path2DCopyConstructor.java
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;
}
 
源代码10 项目: jdk8u60   文件: Path2DGrow.java
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);
}
 
源代码11 项目: jdk8u_jdk   文件: Path2DGrow.java
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);
}
 
源代码12 项目: openjdk-jdk8u   文件: Path2DGrow.java
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);
}
 
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;
}
 
源代码14 项目: openjdk-jdk8u-backup   文件: Path2DGrow.java
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);
}
 
源代码15 项目: openjdk-jdk9   文件: Path2DCopyConstructor.java
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;
}
 
源代码16 项目: javaGeom   文件: GeneralPath2D.java
public void updatePath(Path2D path) {
	path.curveTo(p1.x(), p1.y(), p2.x(), p2.y(), p3.x(), p3.y());
}
 
源代码17 项目: jdk8u-jdk   文件: Path2DGrow.java
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);
}
 
源代码18 项目: rcrs-server   文件: ShapeDebugFrame.java
@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);
}
 
源代码19 项目: ET_Redux   文件: ConcordiaGraphPanel.java
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);
}
 
源代码20 项目: jdk8u_jdk   文件: Path2DCopyConstructor.java
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;
}