Java 类java.awt.geom.QuadCurve2D 实例源码

项目:rapidminer    文件:TabbedPaneUI.java   
/**
 * Creates the shape for a top tab.
 *
 * @param x
 * @param y
 * @param w
 * @param h
 * @param rTop
 * @param addBottom
 *            if {@code false}, the bottom line below the tab will not be added to the shape
 * @return
 */
private static Path2D createTopTabShape(int x, int y, int w, int h, double rTop, boolean addBottom) {
    Path2D path = new Path2D.Double();
    path.append(new Line2D.Double(x, y + h - 1, x, y + rTop), true);

    QuadCurve2D curve = new QuadCurve2D.Double(x, y + rTop, x, y, x + rTop, y);
    path.append(curve, true);

    path.append(new Line2D.Double(x + rTop, y, x + w - rTop, y), true);

    curve = new QuadCurve2D.Double(x + w - rTop, y, x + w, y, x + w, y + rTop);
    path.append(curve, true);

    path.append(new Line2D.Double(x + w, y + rTop, x + w, y + h), true);

    if (addBottom) {
        path.append(new Line2D.Double(x + w, y + h - 1, x, y + h - 1), true);
    }
    return path;
}
项目:rapidminer    文件:TabbedPaneUI.java   
/**
 * Creates the shape for a left tab.
 *
 * @param x
 * @param y
 * @param w
 * @param h
 * @param rLeft
 * @param addSide
 *            if {@code false}, the closing side line right of the tab will not be added to the
 *            shape
 * @return
 */
private static Path2D createLeftTabShape(int x, int y, int w, int h, double rLeft, boolean addSide) {
    Path2D path = new Path2D.Double();
    path.append(new Line2D.Double(x + w, y + h, x + rLeft, y + h), true);

    QuadCurve2D curve = new QuadCurve2D.Double(x + rLeft, y + h, x, y + h, x, y + h - rLeft);
    path.append(curve, true);

    path.append(new Line2D.Double(x, y + h - rLeft, x, y + rLeft), true);

    curve = new QuadCurve2D.Double(x, y + rLeft, x, y, x + rLeft, y);
    path.append(curve, true);

    path.append(new Line2D.Double(x + rLeft, y, x + w, y), true);

    if (addSide) {
        path.append(new Line2D.Double(x + w, y, x + w, y + h - 1), true);
    }
    return path;
}
项目:routerapp    文件:CurvedLineVisel.java   
/**
    * @see ring.gui.vis2.Visel#contains(double, double)
    */
public boolean contains(double x, double y) {
    if (shape instanceof QuadCurve2D) {
        QuadCurve2D curve = (QuadCurve2D) shape;

        return (
            Line2D.ptLineDist(
                curve.getX1(),
                curve.getY1(),
                curve.getCtrlX(),
                curve.getCtrlY(),
                x,
                y
            ) < 5 || Line2D.ptLineDist(
                curve.getX2(),
                curve.getY2(),
                curve.getCtrlX(),
                curve.getCtrlY(),
                x,
                y
            ) < 5
        );
    }
    return shape.contains(new Point2D.Double(x,y));
}
项目:OpenJSharp    文件:Order3.java   
public static int getHorizontalParams(double c0, double cp0,
                                      double cp1, double c1,
                                      double ret[]) {
    if (c0 <= cp0 && cp0 <= cp1 && cp1 <= c1) {
        return 0;
    }
    c1 -= cp1;
    cp1 -= cp0;
    cp0 -= c0;
    ret[0] = cp0;
    ret[1] = (cp1 - cp0) * 2;
    ret[2] = (c1 - cp1 - cp1 + cp0);
    int numroots = QuadCurve2D.solveQuadratic(ret, ret);
    int j = 0;
    for (int i = 0; i < numroots; i++) {
        double t = ret[i];
        // No splits at t==0 and t==1
        if (t > 0 && t < 1) {
            if (j < i) {
                ret[j] = t;
            }
            j++;
        }
    }
    return j;
}
项目:jdk8u-jdk    文件:Order3.java   
public static int getHorizontalParams(double c0, double cp0,
                                      double cp1, double c1,
                                      double ret[]) {
    if (c0 <= cp0 && cp0 <= cp1 && cp1 <= c1) {
        return 0;
    }
    c1 -= cp1;
    cp1 -= cp0;
    cp0 -= c0;
    ret[0] = cp0;
    ret[1] = (cp1 - cp0) * 2;
    ret[2] = (c1 - cp1 - cp1 + cp0);
    int numroots = QuadCurve2D.solveQuadratic(ret, ret);
    int j = 0;
    for (int i = 0; i < numroots; i++) {
        double t = ret[i];
        // No splits at t==0 and t==1
        if (t > 0 && t < 1) {
            if (j < i) {
                ret[j] = t;
            }
            j++;
        }
    }
    return j;
}
项目:openjdk-jdk10    文件:Order3.java   
public static int getHorizontalParams(double c0, double cp0,
                                      double cp1, double c1,
                                      double ret[]) {
    if (c0 <= cp0 && cp0 <= cp1 && cp1 <= c1) {
        return 0;
    }
    c1 -= cp1;
    cp1 -= cp0;
    cp0 -= c0;
    ret[0] = cp0;
    ret[1] = (cp1 - cp0) * 2;
    ret[2] = (c1 - cp1 - cp1 + cp0);
    int numroots = QuadCurve2D.solveQuadratic(ret, ret);
    int j = 0;
    for (int i = 0; i < numroots; i++) {
        double t = ret[i];
        // No splits at t==0 and t==1
        if (t > 0 && t < 1) {
            if (j < i) {
                ret[j] = t;
            }
            j++;
        }
    }
    return j;
}
项目:openjdk9    文件:Order3.java   
public static int getHorizontalParams(double c0, double cp0,
                                      double cp1, double c1,
                                      double ret[]) {
    if (c0 <= cp0 && cp0 <= cp1 && cp1 <= c1) {
        return 0;
    }
    c1 -= cp1;
    cp1 -= cp0;
    cp0 -= c0;
    ret[0] = cp0;
    ret[1] = (cp1 - cp0) * 2;
    ret[2] = (c1 - cp1 - cp1 + cp0);
    int numroots = QuadCurve2D.solveQuadratic(ret, ret);
    int j = 0;
    for (int i = 0; i < numroots; i++) {
        double t = ret[i];
        // No splits at t==0 and t==1
        if (t > 0 && t < 1) {
            if (j < i) {
                ret[j] = t;
            }
            j++;
        }
    }
    return j;
}
项目:PhET    文件:BSWellComboBox.java   
private static ImageIcon createCoulombIcon( Color color ) {
    final int w = 20;
    final int h = 20;
    BufferedImage bi = new BufferedImage( w, h, BufferedImage.TYPE_INT_ARGB );
    Graphics2D g2 = bi.createGraphics();
    g2.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
    QuadCurve2D curve1 = new QuadCurve2D.Double();
    QuadCurve2D curve2 = new QuadCurve2D.Double();
    curve1.setCurve( 0, 4, 8, 5, 7, 16 );
    curve2.setCurve( 10, 16, 11, 5, 17, 4 );
    g2.setStroke( ICON_STROKE );
    g2.setPaint( color );
    g2.draw( curve1 );
    g2.draw( curve2 );
    return new ImageIcon( bi );
}
项目:pumpernickel    文件:Order3X.java   
public static int getHorizontalParams(double c0, double cp0,
            double cp1, double c1,
            double ret[]) {
        if (c0 <= cp0 && cp0 <= cp1 && cp1 <= c1) {
            return 0;
        }
        c1 -= cp1;
        cp1 -= cp0;
        cp0 -= c0;
        ret[0] = cp0;
        ret[1] = (cp1 - cp0) * 2;
        ret[2] = (c1 - cp1 - cp1 + cp0);
        int numroots = QuadCurve2D.solveQuadratic(ret, ret);
        int j = 0;
        for (int i = 0; i < numroots; i++) {
            double t = ret[i];
//          No splits at t==0 and t==1
            if (t > 0 && t < 1) {
                if (j < i) {
                    ret[j] = t;
                }
                j++;
            }
        }
        return j;
    }
项目:Push2Display    文件:Cubic.java   
private void getMinMax(double p1, double p2,
                       double p3, double p4,
                       double [] minMax) {
    if (p4 > p1){
        minMax[0] = p1; minMax[1] = p4;
    } else {
        minMax[0] = p4; minMax[1] = p1;
    }

    double c0 = 3*(p2-p1);
    double c1 = 6*(p3-p2);
    double c2 = 3*(p4-p3);
    double [] eqn = { c0, c1-2*c0, c2-c1+c0 };
    int roots = QuadCurve2D.solveQuadratic(eqn);
    for (int r=0; r<roots; r++) {
        double tv = eqn[r];
        if ((tv <= 0) || (tv >= 1)) continue;
        tv = ((1-tv)*(1-tv)*(1-tv)*p1 +
                3*tv*(1-tv)*(1-tv)*p2 +
                3*tv*tv*(1-tv)*p3 +
                tv*tv*tv*p4);
        if      (tv < minMax[0]) minMax[0] = tv;
        else if (tv > minMax[1]) minMax[1] = tv;
    }
}
项目:jdk8u_jdk    文件:Order3.java   
public static int getHorizontalParams(double c0, double cp0,
                                      double cp1, double c1,
                                      double ret[]) {
    if (c0 <= cp0 && cp0 <= cp1 && cp1 <= c1) {
        return 0;
    }
    c1 -= cp1;
    cp1 -= cp0;
    cp0 -= c0;
    ret[0] = cp0;
    ret[1] = (cp1 - cp0) * 2;
    ret[2] = (c1 - cp1 - cp1 + cp0);
    int numroots = QuadCurve2D.solveQuadratic(ret, ret);
    int j = 0;
    for (int i = 0; i < numroots; i++) {
        double t = ret[i];
        // No splits at t==0 and t==1
        if (t > 0 && t < 1) {
            if (j < i) {
                ret[j] = t;
            }
            j++;
        }
    }
    return j;
}
项目:lookaside_java-1.8.0-openjdk    文件:Order3.java   
public static int getHorizontalParams(double c0, double cp0,
                                      double cp1, double c1,
                                      double ret[]) {
    if (c0 <= cp0 && cp0 <= cp1 && cp1 <= c1) {
        return 0;
    }
    c1 -= cp1;
    cp1 -= cp0;
    cp0 -= c0;
    ret[0] = cp0;
    ret[1] = (cp1 - cp0) * 2;
    ret[2] = (c1 - cp1 - cp1 + cp0);
    int numroots = QuadCurve2D.solveQuadratic(ret, ret);
    int j = 0;
    for (int i = 0; i < numroots; i++) {
        double t = ret[i];
        // No splits at t==0 and t==1
        if (t > 0 && t < 1) {
            if (j < i) {
                ret[j] = t;
            }
            j++;
        }
    }
    return j;
}
项目:javify    文件:J2dBenchmark.java   
/**
 * Draws random quadratic curves within the given dimensions.
 *
 * @param g The Graphics2D object that is used to paint.
 * @param size The size of the canvas.
 */
private void test_drawQuadCurve(Graphics2D g, Dimension size)
{
  int maxTests = testSize;
  int minSize = 10;
  long startTime = System.currentTimeMillis();
  for (int i = 0; i < maxTests; i += 1)
    {
      setRandom(g, size);
      int x1 = (int) (Math.random() * (size.width - minSize));
      int y1 = (int) (Math.random() * (size.height - minSize));
      int xc = (int) (Math.random() * (size.width - minSize));
      int yc = (int) (Math.random() * (size.height - minSize));
      int x2 = (int) (Math.random() * (size.width - minSize));
      int y2 = (int) (Math.random() * (size.height - minSize));

      QuadCurve2D curve = new QuadCurve2D.Double(x1, y1, xc, yc, x2, y2);
      g.draw(curve);
    }
  long endTime = System.currentTimeMillis();
  recordTest("draw(QuadCurve2D.Double) " + maxTests + " times",
             (endTime - startTime));
}
项目:javify    文件:QuadSegment.java   
/**
 * Get the "top" and "bottom" segments of a given segment.
 * First array element is p0 + normal, second is p0 - normal.
 */
public Segment[] getDisplacedSegments(double radius)
{
  this.radius = radius;
  double x0 = P1.getX();
  double y0 = P1.getY();
  double x1 = cp.getX();
  double y1 = cp.getY();
  double x2 = P2.getX();
  double y2 = P2.getY();

  QuadCurve2D left = new QuadCurve2D.Double();
  QuadCurve2D right = new QuadCurve2D.Double();
  QuadCurve2D orig = new QuadCurve2D.Double(x0, y0, x1, y1, x2, y2);
  orig.subdivide(left, right);

  QuadSegment s1 = offsetSubdivided(left, true);
  QuadSegment s2 = offsetSubdivided(left, false);

  s1.add( offsetSubdivided(right, true) );
  s2.add( offsetSubdivided(right, false) );

  return new Segment[]{s1, s2};
}
项目:rapidminer-studio    文件:TabbedPaneUI.java   
/**
 * Creates the shape for a top tab.
 *
 * @param x
 * @param y
 * @param w
 * @param h
 * @param rTop
 * @param addBottom
 *            if {@code false}, the bottom line below the tab will not be added to the shape
 * @return
 */
private static Path2D createTopTabShape(int x, int y, int w, int h, double rTop, boolean addBottom) {
    Path2D path = new Path2D.Double();
    path.append(new Line2D.Double(x, y + h - 1, x, y + rTop), true);

    QuadCurve2D curve = new QuadCurve2D.Double(x, y + rTop, x, y, x + rTop, y);
    path.append(curve, true);

    path.append(new Line2D.Double(x + rTop, y, x + w - rTop, y), true);

    curve = new QuadCurve2D.Double(x + w - rTop, y, x + w, y, x + w, y + rTop);
    path.append(curve, true);

    path.append(new Line2D.Double(x + w, y + rTop, x + w, y + h), true);

    if (addBottom) {
        path.append(new Line2D.Double(x + w, y + h - 1, x, y + h - 1), true);
    }
    return path;
}
项目:rapidminer-studio    文件:TabbedPaneUI.java   
/**
 * Creates the shape for a left tab.
 *
 * @param x
 * @param y
 * @param w
 * @param h
 * @param rLeft
 * @param addSide
 *            if {@code false}, the closing side line right of the tab will not be added to the
 *            shape
 * @return
 */
private static Path2D createLeftTabShape(int x, int y, int w, int h, double rLeft, boolean addSide) {
    Path2D path = new Path2D.Double();
    path.append(new Line2D.Double(x + w, y + h, x + rLeft, y + h), true);

    QuadCurve2D curve = new QuadCurve2D.Double(x + rLeft, y + h, x, y + h, x, y + h - rLeft);
    path.append(curve, true);

    path.append(new Line2D.Double(x, y + h - rLeft, x, y + rLeft), true);

    curve = new QuadCurve2D.Double(x, y + rLeft, x, y, x + rLeft, y);
    path.append(curve, true);

    path.append(new Line2D.Double(x + rLeft, y, x + w, y), true);

    if (addSide) {
        path.append(new Line2D.Double(x + w, y, x + w, y + h - 1), true);
    }
    return path;
}
项目:paintmultimedia    文件:Curva1Dibujable.java   
/**
 * Implementacion del metodo abstracto de la clase padre. Dibuja la figura
 * en el grafico pasado como parametro.
 *
 * @param g Graphics donde se desea dibujar la figura.
 */
@Override
public void dibujar(Graphics g) {
    Graphics2D g2 = (Graphics2D) g;

    //Variable que nos sirve para reestablecer la forma original posteriormente
    AffineTransform actual = g2.getTransform();

    //Aplicamos la transformacion del objeto si la tiene
    if (!this.transformaciones.isIdentity()) {
        g2.transform(this.transformaciones);
    }

    QuadCurve2D quad = new QuadCurve2D.Double(this.puntoInicial.x, this.puntoInicial.y, this.ptoControl.x, this.ptoControl.y, this.puntoFinal.x, this.puntoFinal.y);

    g2.setStroke(this.cg.getEstiloLinea());

    //Dibujamos la linea
    g2.setColor(this.cg.getColorLinea());
    g2.draw(quad);

    //Recuperamos la forma original que tenia antes de la transformacion
    g2.setTransform(actual);
}
项目:jvm-stm    文件:J2dBenchmark.java   
/**
 * Draws random quadratic curves within the given dimensions.
 * 
 * @param g The Graphics2D object that is used to paint.
 * @param size The size of the canvas.
 */
private void test_drawQuadCurve(Graphics2D g, Dimension size)
{
  int maxTests = testSize;
  int minSize = 10;
  long startTime = System.currentTimeMillis();
  for (int i = 0; i < maxTests; i += 1)
    {
      setRandom(g, size);
      int x1 = (int) (Math.random() * (size.width - minSize));
      int y1 = (int) (Math.random() * (size.height - minSize));
      int xc = (int) (Math.random() * (size.width - minSize));
      int yc = (int) (Math.random() * (size.height - minSize));
      int x2 = (int) (Math.random() * (size.width - minSize));
      int y2 = (int) (Math.random() * (size.height - minSize));

      QuadCurve2D curve = new QuadCurve2D.Double(x1, y1, xc, yc, x2, y2);
      g.draw(curve);
    }
  long endTime = System.currentTimeMillis();
  recordTest("draw(QuadCurve2D.Double) " + maxTests + " times",
             (endTime - startTime));
}
项目:jvm-stm    文件:QuadSegment.java   
/**
 * Get the "top" and "bottom" segments of a given segment.
 * First array element is p0 + normal, second is p0 - normal.
 */
public Segment[] getDisplacedSegments(double radius)
{
  this.radius = radius;
  double x0 = P1.getX();
  double y0 = P1.getY();
  double x1 = cp.getX();
  double y1 = cp.getY();
  double x2 = P2.getX();
  double y2 = P2.getY();

  QuadCurve2D left = new QuadCurve2D.Double();
  QuadCurve2D right = new QuadCurve2D.Double();
  QuadCurve2D orig = new QuadCurve2D.Double(x0, y0, x1, y1, x2, y2);
  orig.subdivide(left, right);

  QuadSegment s1 = offsetSubdivided(left, true);
  QuadSegment s2 = offsetSubdivided(left, false);

  s1.add( offsetSubdivided(right, true) );
  s2.add( offsetSubdivided(right, false) );

  return new Segment[]{s1, s2};
}
项目:Push2Display    文件:Cubic.java   
private void getMinMax(double p1, double p2,
                       double p3, double p4,
                       double [] minMax) {
    if (p4 > p1){
        minMax[0] = p1; minMax[1] = p4;
    } else {
        minMax[0] = p4; minMax[1] = p1;
    }

    double c0 = 3*(p2-p1);
    double c1 = 6*(p3-p2);
    double c2 = 3*(p4-p3);
    double [] eqn = { c0, c1-2*c0, c2-c1+c0 };
    int roots = QuadCurve2D.solveQuadratic(eqn);
    for (int r=0; r<roots; r++) {
        double tv = eqn[r];
        if ((tv <= 0) || (tv >= 1)) continue;
        tv = ((1-tv)*(1-tv)*(1-tv)*p1 +
                3*tv*(1-tv)*(1-tv)*p2 +
                3*tv*tv*(1-tv)*p3 +
                tv*tv*tv*p4);
        if      (tv < minMax[0]) minMax[0] = tv;
        else if (tv > minMax[1]) minMax[1] = tv;
    }
}
项目:infobip-open-jdk-8    文件:Order3.java   
public static int getHorizontalParams(double c0, double cp0,
                                      double cp1, double c1,
                                      double ret[]) {
    if (c0 <= cp0 && cp0 <= cp1 && cp1 <= c1) {
        return 0;
    }
    c1 -= cp1;
    cp1 -= cp0;
    cp0 -= c0;
    ret[0] = cp0;
    ret[1] = (cp1 - cp0) * 2;
    ret[2] = (c1 - cp1 - cp1 + cp0);
    int numroots = QuadCurve2D.solveQuadratic(ret, ret);
    int j = 0;
    for (int i = 0; i < numroots; i++) {
        double t = ret[i];
        // No splits at t==0 and t==1
        if (t > 0 && t < 1) {
            if (j < i) {
                ret[j] = t;
            }
            j++;
        }
    }
    return j;
}
项目:jdk8u-dev-jdk    文件:Order3.java   
public static int getHorizontalParams(double c0, double cp0,
                                      double cp1, double c1,
                                      double ret[]) {
    if (c0 <= cp0 && cp0 <= cp1 && cp1 <= c1) {
        return 0;
    }
    c1 -= cp1;
    cp1 -= cp0;
    cp0 -= c0;
    ret[0] = cp0;
    ret[1] = (cp1 - cp0) * 2;
    ret[2] = (c1 - cp1 - cp1 + cp0);
    int numroots = QuadCurve2D.solveQuadratic(ret, ret);
    int j = 0;
    for (int i = 0; i < numroots; i++) {
        double t = ret[i];
        // No splits at t==0 and t==1
        if (t > 0 && t < 1) {
            if (j < i) {
                ret[j] = t;
            }
            j++;
        }
    }
    return j;
}
项目:ontopia    文件:TMAbstractEdge.java   
protected QuadCurve2D getCurvedLine(int index) {
  double x1 = from.drawx;
  double x2 = to.drawx;
  double y1 = from.drawy;
  double y2 = to.drawy;
  double midx = calculateMidPointBetween(x1, x2);
  double midy = calculateMidPointBetween(y1, y2);

  int weight = index / 2;
  if (index % 2 == 1) {
    weight++;
    weight = -weight;
  }
  Dimension offset = calculateOffset(x1, x2, y1, y2, LOADING * weight);
  QuadCurve2D curve = new QuadCurve2D.Double(x1, y1,
      midx-offset.width, midy+offset.height,
      x2, y2);
  return curve;
}
项目:feathers-sdk    文件:Cubic.java   
private void getMinMax(double p1, double p2,
                       double p3, double p4,
                       double [] minMax) {
    if (p4 > p1){
        minMax[0] = p1; minMax[1] = p4;
    } else {
        minMax[0] = p4; minMax[1] = p1;
    }

    double c0 = 3*(p2-p1);
    double c1 = 6*(p3-p2);
    double c2 = 3*(p4-p3);
    double [] eqn = { c0, c1-2*c0, c2-c1+c0 };
    int roots = QuadCurve2D.solveQuadratic(eqn);
    for (int r=0; r<roots; r++) {
        double tv = eqn[r];
        if ((tv <= 0) || (tv >= 1)) continue;
        tv = ((1-tv)*(1-tv)*(1-tv)*p1 +
                3*tv*(1-tv)*(1-tv)*p2 +
                3*tv*tv*(1-tv)*p3 +
                tv*tv*tv*p4);
        if      (tv < minMax[0]) minMax[0] = tv;
        else if (tv > minMax[1]) minMax[1] = tv;
    }
}
项目:jdk7-jdk    文件:Order3.java   
public static int getHorizontalParams(double c0, double cp0,
                                      double cp1, double c1,
                                      double ret[]) {
    if (c0 <= cp0 && cp0 <= cp1 && cp1 <= c1) {
        return 0;
    }
    c1 -= cp1;
    cp1 -= cp0;
    cp0 -= c0;
    ret[0] = cp0;
    ret[1] = (cp1 - cp0) * 2;
    ret[2] = (c1 - cp1 - cp1 + cp0);
    int numroots = QuadCurve2D.solveQuadratic(ret, ret);
    int j = 0;
    for (int i = 0; i < numroots; i++) {
        double t = ret[i];
        // No splits at t==0 and t==1
        if (t > 0 && t < 1) {
            if (j < i) {
                ret[j] = t;
            }
            j++;
        }
    }
    return j;
}
项目:openjdk-source-code-learn    文件:Order3.java   
public static int getHorizontalParams(double c0, double cp0,
                                      double cp1, double c1,
                                      double ret[]) {
    if (c0 <= cp0 && cp0 <= cp1 && cp1 <= c1) {
        return 0;
    }
    c1 -= cp1;
    cp1 -= cp0;
    cp0 -= c0;
    ret[0] = cp0;
    ret[1] = (cp1 - cp0) * 2;
    ret[2] = (c1 - cp1 - cp1 + cp0);
    int numroots = QuadCurve2D.solveQuadratic(ret, ret);
    int j = 0;
    for (int i = 0; i < numroots; i++) {
        double t = ret[i];
        // No splits at t==0 and t==1
        if (t > 0 && t < 1) {
            if (j < i) {
                ret[j] = t;
            }
            j++;
        }
    }
    return j;
}
项目:OLD-OpenJDK8    文件:Order3.java   
public static int getHorizontalParams(double c0, double cp0,
                                      double cp1, double c1,
                                      double ret[]) {
    if (c0 <= cp0 && cp0 <= cp1 && cp1 <= c1) {
        return 0;
    }
    c1 -= cp1;
    cp1 -= cp0;
    cp0 -= c0;
    ret[0] = cp0;
    ret[1] = (cp1 - cp0) * 2;
    ret[2] = (c1 - cp1 - cp1 + cp0);
    int numroots = QuadCurve2D.solveQuadratic(ret, ret);
    int j = 0;
    for (int i = 0; i < numroots; i++) {
        double t = ret[i];
        // No splits at t==0 and t==1
        if (t > 0 && t < 1) {
            if (j < i) {
                ret[j] = t;
            }
            j++;
        }
    }
    return j;
}
项目:freemind_1.0.0_20140624_214725    文件:CloudView.java   
private void paintClouds(Graphics2D g, Graphics2D gstroke, double x0,
        double y0, double x1, double y1, double distanceToConvexHull) {
    // System.out.println("double=" + x0+ ", double=" + y0+ ", double=" +
    // x1+ ", double=" + y1);
    double x2, y2, dx, dy;
    dx = x1 - x0;
    dy = y1 - y0;
    double length = Math.sqrt(dx * dx + dy * dy);
    // nothing to do for length zero.
    if (length == 0f)
        return;
    double dxn, dyn;
    dxn = dx / length;
    dyn = dy / length;
    x2 = x0 + .5f * dx - distanceToConvexHull * dyn;
    y2 = y0 + .5f * dy + distanceToConvexHull * dxn;
    // System.out.println("Line from " + x0+ ", " +y0+ ", " +x2+ ", " +y2+
    // ", " +x1+ ", " +y1+".");
    Shape shape = new QuadCurve2D.Double(x0, y0, x2, y2, x1, y1);
    g.fill(shape);
    gstroke.draw(shape);
}
项目:freemind_1.0.0_20140624_214725    文件:PathBBox.java   
private static int findCubicZeros(double zeros[], double cur, double cp0,
        double cp1, double end) {
    // The polynomial form of the Cubic is:
    // eqn[0] = cur;
    // eqn[1] = (cp0 - cur) * 3.0;
    // eqn[2] = (cp1 - cp0 - cp0 + cur) * 3.0;
    // eqn[3] = end + (cp0 - cp1) * 3.0 - cur;
    // Since we want the derivative, we can calculate it in one step:
    zeros[0] = (cp0 - cur) * 3.0;
    zeros[1] = (cp1 - cp0 - cp0 + cur) * 6.0;
    zeros[2] = (end + (cp0 - cp1) * 3.0 - cur) * 3.0;
    int num = QuadCurve2D.solveQuadratic(zeros);
    int ret = 0;
    for (int i = 0; i < num; i++) {
        double t = zeros[i];
        if (t > 0 && t < 1) {
            zeros[ret] = t;
            ret++;
        }
    }
    return ret;
}
项目:JamVM-PH    文件:J2dBenchmark.java   
/**
 * Draws random quadratic curves within the given dimensions.
 * 
 * @param g The Graphics2D object that is used to paint.
 * @param size The size of the canvas.
 */
private void test_drawQuadCurve(Graphics2D g, Dimension size)
{
  int maxTests = testSize;
  int minSize = 10;
  long startTime = System.currentTimeMillis();
  for (int i = 0; i < maxTests; i += 1)
    {
      setRandom(g, size);
      int x1 = (int) (Math.random() * (size.width - minSize));
      int y1 = (int) (Math.random() * (size.height - minSize));
      int xc = (int) (Math.random() * (size.width - minSize));
      int yc = (int) (Math.random() * (size.height - minSize));
      int x2 = (int) (Math.random() * (size.width - minSize));
      int y2 = (int) (Math.random() * (size.height - minSize));

      QuadCurve2D curve = new QuadCurve2D.Double(x1, y1, xc, yc, x2, y2);
      g.draw(curve);
    }
  long endTime = System.currentTimeMillis();
  recordTest("draw(QuadCurve2D.Double) " + maxTests + " times",
             (endTime - startTime));
}
项目:JamVM-PH    文件:QuadSegment.java   
/**
 * Get the "top" and "bottom" segments of a given segment.
 * First array element is p0 + normal, second is p0 - normal.
 */
public Segment[] getDisplacedSegments(double radius)
{
  this.radius = radius;
  double x0 = P1.getX();
  double y0 = P1.getY();
  double x1 = cp.getX();
  double y1 = cp.getY();
  double x2 = P2.getX();
  double y2 = P2.getY();

  QuadCurve2D left = new QuadCurve2D.Double();
  QuadCurve2D right = new QuadCurve2D.Double();
  QuadCurve2D orig = new QuadCurve2D.Double(x0, y0, x1, y1, x2, y2);
  orig.subdivide(left, right);

  QuadSegment s1 = offsetSubdivided(left, true);
  QuadSegment s2 = offsetSubdivided(left, false);

  s1.add( offsetSubdivided(right, true) );
  s2.add( offsetSubdivided(right, false) );

  return new Segment[]{s1, s2};
}
项目:billie    文件:Java2dFactory.java   
@Override
void paint(Graphics2D g) {
    Point prevCtrl = pointList.get(0);
    Point currCtrl = pointList.get(1);
    Point pt1 = new Point((prevCtrl.x+currCtrl.x)/2, (prevCtrl.y+currCtrl.y)/2);
    g.drawLine(prevCtrl.x, prevCtrl.y, pt1.x, pt1.y);
    if (pointList.size()>2) for (int i = 2; i < pointList.size(); i++) {
        Point nextCtrl = pointList.get(i);
        Point pt2 = new Point((currCtrl.x+nextCtrl.x)/2, (currCtrl.y+nextCtrl.y)/2);
        QuadCurve2D.Double s = new QuadCurve2D.Double(pt1.x, pt1.y, currCtrl.x, currCtrl.y, pt2.x, pt2.y);
        g.draw(s);
        currCtrl = nextCtrl;
        pt1 = pt2;
    }
    g.drawLine(pt1.x, pt1.y, currCtrl.x, currCtrl.y);
}
项目:billie    文件:Java2dFactory.java   
@Override
java.awt.Rectangle calculateBounds(Graphics2D g) {
    Point prevCtrl = pointList.get(0);
    Point currCtrl = pointList.get(1);
    Point pt1 = new Point((prevCtrl.x+currCtrl.x)/2, (prevCtrl.y+currCtrl.y)/2);
    java.awt.Rectangle bounds = new java.awt.Rectangle();
    bounds.add(prevCtrl);
    bounds.add(currCtrl);
    if (pointList.size()>2) for (int i = 2; i < pointList.size(); i++) {
        Point nextCtrl = pointList.get(i);
        Point pt2 = new Point((currCtrl.x+nextCtrl.x)/2, (currCtrl.y+nextCtrl.y)/2);
        QuadCurve2D.Double s = new QuadCurve2D.Double(pt1.x, pt1.y, currCtrl.x, currCtrl.y, pt2.x, pt2.y);
        bounds = bounds.union(s.getBounds());
        currCtrl = nextCtrl;
        pt1 = pt2;
    }
    bounds.add(pt1);
    bounds.add(currCtrl);
    return bounds;
}
项目:openjdk-jdk7u-jdk    文件:Order3.java   
public static int getHorizontalParams(double c0, double cp0,
                                      double cp1, double c1,
                                      double ret[]) {
    if (c0 <= cp0 && cp0 <= cp1 && cp1 <= c1) {
        return 0;
    }
    c1 -= cp1;
    cp1 -= cp0;
    cp0 -= c0;
    ret[0] = cp0;
    ret[1] = (cp1 - cp0) * 2;
    ret[2] = (c1 - cp1 - cp1 + cp0);
    int numroots = QuadCurve2D.solveQuadratic(ret, ret);
    int j = 0;
    for (int i = 0; i < numroots; i++) {
        double t = ret[i];
        // No splits at t==0 and t==1
        if (t > 0 && t < 1) {
            if (j < i) {
                ret[j] = t;
            }
            j++;
        }
    }
    return j;
}
项目:classpath    文件:J2dBenchmark.java   
/**
 * Draws random quadratic curves within the given dimensions.
 *
 * @param g The Graphics2D object that is used to paint.
 * @param size The size of the canvas.
 */
private void test_drawQuadCurve(Graphics2D g, Dimension size)
{
  int maxTests = testSize;
  int minSize = 10;
  long startTime = System.currentTimeMillis();
  for (int i = 0; i < maxTests; i += 1)
    {
      setRandom(g, size);
      int x1 = (int) (Math.random() * (size.width - minSize));
      int y1 = (int) (Math.random() * (size.height - minSize));
      int xc = (int) (Math.random() * (size.width - minSize));
      int yc = (int) (Math.random() * (size.height - minSize));
      int x2 = (int) (Math.random() * (size.width - minSize));
      int y2 = (int) (Math.random() * (size.height - minSize));

      QuadCurve2D curve = new QuadCurve2D.Double(x1, y1, xc, yc, x2, y2);
      g.draw(curve);
    }
  long endTime = System.currentTimeMillis();
  recordTest("draw(QuadCurve2D.Double) " + maxTests + " times",
             (endTime - startTime));
}
项目:classpath    文件:QuadSegment.java   
/**
 * Get the "top" and "bottom" segments of a given segment.
 * First array element is p0 + normal, second is p0 - normal.
 */
public Segment[] getDisplacedSegments(double radius)
{
  this.radius = radius;
  double x0 = P1.getX();
  double y0 = P1.getY();
  double x1 = cp.getX();
  double y1 = cp.getY();
  double x2 = P2.getX();
  double y2 = P2.getY();

  QuadCurve2D left = new QuadCurve2D.Double();
  QuadCurve2D right = new QuadCurve2D.Double();
  QuadCurve2D orig = new QuadCurve2D.Double(x0, y0, x1, y1, x2, y2);
  orig.subdivide(left, right);

  QuadSegment s1 = offsetSubdivided(left, true);
  QuadSegment s2 = offsetSubdivided(left, false);

  s1.add( offsetSubdivided(right, true) );
  s2.add( offsetSubdivided(right, false) );

  return new Segment[]{s1, s2};
}
项目:openjdk-icedtea7    文件:Order3.java   
public static int getHorizontalParams(double c0, double cp0,
                                      double cp1, double c1,
                                      double ret[]) {
    if (c0 <= cp0 && cp0 <= cp1 && cp1 <= c1) {
        return 0;
    }
    c1 -= cp1;
    cp1 -= cp0;
    cp0 -= c0;
    ret[0] = cp0;
    ret[1] = (cp1 - cp0) * 2;
    ret[2] = (c1 - cp1 - cp1 + cp0);
    int numroots = QuadCurve2D.solveQuadratic(ret, ret);
    int j = 0;
    for (int i = 0; i < numroots; i++) {
        double t = ret[i];
        // No splits at t==0 and t==1
        if (t > 0 && t < 1) {
            if (j < i) {
                ret[j] = t;
            }
            j++;
        }
    }
    return j;
}
项目:zgrnbviewer    文件:QDCElement.java   
@Override
void addCamera(int verifIndex) {
    if (pc != null) {
        if (verifIndex == pc.length) {
            QuadCurve2D[] ta = pc;
            pc = new QuadCurve2D[ta.length + 1];
            System.arraycopy(ta, 0, pc, 0, ta.length);
            pc[pc.length - 1] = new QuadCurve2D.Double();
            ta = lpc;
            lpc = new QuadCurve2D[ta.length + 1];
            System.arraycopy(ta, 0, lpc, 0, ta.length);
            lpc[lpc.length - 1] = new QuadCurve2D.Double();
        } else {
            System.err.println("DPath:Error while adding camera " + verifIndex);
        }
    } else {
        if (verifIndex == 0) {
            pc = new QuadCurve2D[1];
            pc[0] = new QuadCurve2D.Double();
            lpc = new QuadCurve2D[1];
            lpc[0] = new QuadCurve2D.Double();
        } else {
            System.err.println("DPath:Error while adding camera " + verifIndex);
        }
    }
}
项目:freemind    文件:CloudView.java   
private void paintClouds(Graphics2D g, Graphics2D gstroke, double x0,
        double y0, double x1, double y1, double distanceToConvexHull) {
    // System.out.println("double=" + x0+ ", double=" + y0+ ", double=" +
    // x1+ ", double=" + y1);
    double x2, y2, dx, dy;
    dx = x1 - x0;
    dy = y1 - y0;
    double length = Math.sqrt(dx * dx + dy * dy);
    // nothing to do for length zero.
    if (length == 0f)
        return;
    double dxn, dyn;
    dxn = dx / length;
    dyn = dy / length;
    x2 = x0 + .5f * dx - distanceToConvexHull * dyn;
    y2 = y0 + .5f * dy + distanceToConvexHull * dxn;
    // System.out.println("Line from " + x0+ ", " +y0+ ", " +x2+ ", " +y2+
    // ", " +x1+ ", " +y1+".");
    Shape shape = new QuadCurve2D.Double(x0, y0, x2, y2, x1, y1);
    g.fill(shape);
    gstroke.draw(shape);
}
项目:freemind    文件:PathBBox.java   
private static int findCubicZeros(double zeros[], double cur, double cp0,
        double cp1, double end) {
    // The polynomial form of the Cubic is:
    // eqn[0] = cur;
    // eqn[1] = (cp0 - cur) * 3.0;
    // eqn[2] = (cp1 - cp0 - cp0 + cur) * 3.0;
    // eqn[3] = end + (cp0 - cp1) * 3.0 - cur;
    // Since we want the derivative, we can calculate it in one step:
    zeros[0] = (cp0 - cur) * 3.0;
    zeros[1] = (cp1 - cp0 - cp0 + cur) * 6.0;
    zeros[2] = (end + (cp0 - cp1) * 3.0 - cur) * 3.0;
    int num = QuadCurve2D.solveQuadratic(zeros);
    int ret = 0;
    for (int i = 0; i < num; i++) {
        double t = zeros[i];
        if (t > 0 && t < 1) {
            zeros[ret] = t;
            ret++;
        }
    }
    return ret;
}