Package java.awt.geom

Examples of java.awt.geom.QuadCurve2D$Float


  }


  public void test_untransformed(TestHarness harness)
  {
    QuadCurve2D curve;
    PathIterator pit;
    double[] c = new double[6];

    harness.checkPoint("untransformed");
    curve = new QuadCurve2D.Double(1, 2, 3, 4, 5, 6);
    pit = curve.getPathIterator(null);

    harness.check(!pit.isDone());                                   // 1
    harness.check(pit.currentSegment(c), PathIterator.SEG_MOVETO)// 2
    harness.check(c[0], 1.0);                                       // 3
    harness.check(c[1], 2.0);                                       // 4
View Full Code Here


  }


  public void test_transformed(TestHarness harness)
  {
    QuadCurve2D curve;
    PathIterator pit;
    AffineTransform tx;
    double[] c = new double[6];

    harness.checkPoint("transformed");
    tx = new AffineTransform();
    tx.scale(2, 3);
    tx.translate(1, -1);
    curve = new QuadCurve2D.Double(1, 2, 3, 4, 5, 6);
    pit = curve.getPathIterator(tx);

    harness.check(!pit.isDone());                                   // 1
    harness.check(pit.currentSegment(c), PathIterator.SEG_MOVETO)// 2
    harness.check(c[0], 4.0);                                       // 3
    harness.check(c[1], 3.0);                                       // 4
View Full Code Here

  /**
   * Checks whether the zero-argument constructor works as specified.
   */
  public void testZeroArgs()
  {
    QuadCurve2D curve;

    h.checkPoint("noArgs");
    curve = new QuadCurve2D.Float();
    h.check(curve.getX1(), 0);     // 1
    h.check(curve.getY1(), 0);     // 2
    h.check(curve.getCtrlX(), 0)// 3
    h.check(curve.getCtrlY(), 0)// 4
    h.check(curve.getX2(), 0);     // 5
    h.check(curve.getY2(), 0);     // 6
  }
View Full Code Here

                    last_x = coords[2];
                    last_y = coords[3];
                    curve( coords[2], coords[3], coords[0], coords[1] );
                    break;
                case PathIterator.SEG_CUBICTO:
                    QuadCurve2D draw = null;
                    CubicCurve2D curve = new CubicCurve2D.Double(last_x, last_y, coords[0], coords[1], coords[2], coords[3], coords[4], coords[5] );
                    ArrayList curves = convertCubicToQuadric(curve);
                    for (int i = 0; i < curves.size(); i++)
                    {
                        draw = (QuadCurve2D) curves.get(i);
                        curve( draw.getX2(), draw.getY2(), draw.getCtrlX(), draw.getCtrlY() );
                    }
                    last_x = coords[4];
                    last_y = coords[5];
                    line( last_x, last_y );
                    break;
View Full Code Here

        double y2 = v0.getY2() + ((v1.getY2() - v0.getY2()) * fraction);
        double ctrlx = v0.getCtrlX() +
            ((v1.getCtrlX() - v0.getCtrlX()) * fraction);
        double ctrly = v0.getCtrlY() +
            ((v1.getCtrlY() - v0.getCtrlY()) * fraction);
        QuadCurve2D value = (QuadCurve2D)v0.clone();
        value.setCurve(x1, y1, ctrlx, ctrly, x2, y2);
        return value;
    }
View Full Code Here

    Vec2 dir = c2.minus(c1);
    Vec2 norm = new Vec2(dir.y, -dir.x).mult(deviation);
    Vec2 middle = c1.plus(c2).div(2.0f).plus(norm);

    QuadCurve2D curve = new QuadCurve2D.Float(c1.x, c1.y, middle.x, middle.y,
        c2.x, c2.y);
    QuadCurve2D last = new QuadCurve2D.Float();

    // enable GL_LINE_STIPPLE if edge must be dashed
    if (dashed) {
      gl.glEnable(GL2.GL_LINE_STIPPLE);
      gl.glLineStipple(1, (short) 0xf0f0);
    }
    boolean ok = drawCurve(gl, center1, center2, curve, shape1, shape2, last);

    // now disable GL_LINE_STIPPLE if it was enabled
    if (dashed) {
      gl.glDisable(GL2.GL_LINE_STIPPLE);
    }

    if (ok) {
      // draw the head at the last position, trying to orient it so that it
      // follows the last segment of the "line".
      double x1 = last.getP1().getX();
      double y1 = last.getP1().getY();
      double x2 = last.getP2().getX();
      double y2 = last.getP2().getY();

      double slope = (y2 - y1) / (x2 - x1);
      double angle = (float) Math.tanh(slope) - Math.PI / 2.0;
      if (x2 < x1) {
        angle += Math.PI;
      }

      head.setTranslation((float) (last.getP2().getX()), (float) (last.getP2()
          .getY()), 0f);
      head.setScale(8f, 8f, 8f);
      head.setRotation(angle);
      head.fill(gl);
    }

    QuadCurve2D left = new QuadCurve2D.Float();
    QuadCurve2D right = new QuadCurve2D.Float();
    curve.subdivide(left, right);

    return right.getP1(); // new Point2D.Float(middle.x, middle.y);
  }
View Full Code Here

  /**
   * Divide the given curve in two half, and call drawCurve on each part.
   */
  public boolean divideAndDraw(GL2 gl, Point2D center1, Point2D center2,
      QuadCurve2D curve, GLEntity shape1, GLEntity shape2, QuadCurve2D last) {
    QuadCurve2D left = new QuadCurve2D.Float();
    QuadCurve2D right = new QuadCurve2D.Float();
    curve.subdivide(left, right);
    boolean resL = drawCurve(gl, center1, center2, left, shape1, shape2, last);
    boolean resR = drawCurve(gl, center1, center2, right, shape1, shape2, last);
    return resL || resR;
  }
View Full Code Here

      y = (panelH) / 2.0 - STATUS_RAD;
      ctrly = y - STATUS_RAD / 2.0;
      gap = 2 * ELEMS_GAP;
    }
    ctrlx = (x1 + x2) / 2;
    QuadCurve2D prova;
    switch (frame) {
      case 1:
        prova = new QuadCurve2D.Double(x1, y, ctrlx, ctrly, x2, y);
        prova.subdivide(prova, null);
        prova.subdivide(prova, null);
        break;

      case 2:
        prova = new QuadCurve2D.Double(x1, y, ctrlx, ctrly, x2, y);
        prova.subdivide(prova, null);
        break;
      case 3:
        prova = new QuadCurve2D.Double(x1, y, ctrlx, ctrly, x2, y);
        prova.subdivide(null, prova);
        prova.subdivide(null, prova);
        break;

      default:
        prova = new QuadCurve2D.Double(x1, y, ctrlx, ctrly, x2, y);
        prova.subdivide(prova, null);
        break;
    }
    Point2D p = prova.getP2();
    transitionE = new Ellipse2D.Double(p.getX() - ELEMS_GAP, p.getY() - gap, 2 * ELEMS_GAP, 2 * ELEMS_GAP);
    g2d.fill(transitionE);
    g2d.setPaint(b);
    g2d.draw(transitionE);
    g2d.setColor(oldc);
 
View Full Code Here

                g2.draw(new Line2D.Double(linkX, linkY, elbowX, elbowY));
                g2.draw(new Line2D.Double(anchorX, anchorY, elbowX, elbowY));
                g2.draw(new Line2D.Double(anchorX, anchorY, targetX, targetY));
            }
            else if (style.equals(PieLabelLinkStyle.QUAD_CURVE)) {
                QuadCurve2D q = new QuadCurve2D.Float();
                q.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY);
                g2.draw(q);
                g2.draw(new Line2D.Double(elbowX, elbowY, linkX, linkY));
            }
            else if (style.equals(PieLabelLinkStyle.CUBIC_CURVE)) {
                CubicCurve2D c = new CubicCurve2D .Float();
View Full Code Here

                g2.draw(new Line2D.Double(linkX, linkY, elbowX, elbowY));
                g2.draw(new Line2D.Double(anchorX, anchorY, elbowX, elbowY));
                g2.draw(new Line2D.Double(anchorX, anchorY, targetX, targetY));
            }
            else if (style.equals(PieLabelLinkStyle.QUAD_CURVE)) {
                QuadCurve2D q = new QuadCurve2D.Float();
                q.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY);
                g2.draw(q);
                g2.draw(new Line2D.Double(elbowX, elbowY, linkX, linkY));
            }
            else if (style.equals(PieLabelLinkStyle.CUBIC_CURVE)) {
                CubicCurve2D c = new CubicCurve2D .Float();
View Full Code Here

TOP

Related Classes of java.awt.geom.QuadCurve2D$Float

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.