java.awt.geom.QuadCurve2D Java Examples

The following examples show how to use java.awt.geom.QuadCurve2D. 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: Order3.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #2
Source File: Order3X.java    From pumpernickel with MIT License 6 votes vote down vote up
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;
}
 
Example #3
Source File: Order3.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #4
Source File: Order3.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #5
Source File: Order3.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #6
Source File: Order3.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #7
Source File: TabbedPaneUI.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #8
Source File: TabbedPaneUI.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #9
Source File: Order3.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #10
Source File: Order3.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #11
Source File: Order3.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #12
Source File: Order3.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #13
Source File: Order3.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #14
Source File: Order3.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #15
Source File: Order3.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #16
Source File: TMAbstractEdge.java    From ontopia with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #17
Source File: Order3.java    From HtmlUnit-Android with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #18
Source File: Order3.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
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;
}
 
Example #19
Source File: Order3.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void enlarge(Rectangle2D r) {
    r.add(x0, y0);
    double eqn[] = {xcoeff1, 2 * xcoeff2, 3 * xcoeff3};
    int numroots = QuadCurve2D.solveQuadratic(eqn, eqn);
    for (int i = 0; i < numroots; i++) {
        double t = eqn[i];
        if (t > 0 && t < 1) {
            r.add(XforT(t), YforT(t));
        }
    }
    r.add(x1, y1);
}
 
Example #20
Source File: Order3.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void enlarge(Rectangle2D r) {
    r.add(x0, y0);
    double eqn[] = {xcoeff1, 2 * xcoeff2, 3 * xcoeff3};
    int numroots = QuadCurve2D.solveQuadratic(eqn, eqn);
    for (int i = 0; i < numroots; i++) {
        double t = eqn[i];
        if (t > 0 && t < 1) {
            r.add(XforT(t), YforT(t));
        }
    }
    r.add(x1, y1);
}
 
Example #21
Source File: Order3.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void enlarge(Rectangle2D r) {
    r.add(x0, y0);
    double eqn[] = {xcoeff1, 2 * xcoeff2, 3 * xcoeff3};
    int numroots = QuadCurve2D.solveQuadratic(eqn, eqn);
    for (int i = 0; i < numroots; i++) {
        double t = eqn[i];
        if (t > 0 && t < 1) {
            r.add(XforT(t), YforT(t));
        }
    }
    r.add(x1, y1);
}
 
Example #22
Source File: TMAbstractEdge.java    From ontopia with Apache License 2.0 5 votes vote down vote up
private QuadCurve2D getFromCurve(int index) {
  QuadCurve2D curve = getCurvedLine(index);
  QuadCurve2D result = new QuadCurve2D.Double();
  curve.subdivide(result,null);
  
  return result;
}
 
Example #23
Source File: ShapeUtilities.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * Attempts to replace an arbitrary shape by one of the standard Java2D constructs.
 * For example if the given {@code path} is a {@link Path2D} containing only a single
 * line or a quadratic curve, then this method replaces it by a {@link Line2D} or
 * {@link QuadCurve2D} object respectively.
 *
 * @param  path  the shape to replace by a simpler Java2D construct.
 *         This is generally an instance of {@link Path2D}, but not necessarily.
 * @return a simpler Java construct, or {@code path} if no better construct is proposed.
 */
public static Shape toPrimitive(final Shape path) {
    final PathIterator it = path.getPathIterator(null);
    if (!it.isDone()) {
        final double[] buffer = new double[6];
        if (it.currentSegment(buffer) == PathIterator.SEG_MOVETO) {
            it.next();
            if (!it.isDone()) {
                final double x1 = buffer[0];
                final double y1 = buffer[1];
                final int code = it.currentSegment(buffer);
                it.next();
                if (it.isDone()) {
                    if (isFloat(path)) {
                        switch (code) {
                            case PathIterator.SEG_LINETO:  return new       Line2D.Float((float) x1, (float) y1, (float) buffer[0], (float) buffer[1]);
                            case PathIterator.SEG_QUADTO:  return new  QuadCurve2D.Float((float) x1, (float) y1, (float) buffer[0], (float) buffer[1], (float) buffer[2], (float) buffer[3]);
                            case PathIterator.SEG_CUBICTO: return new CubicCurve2D.Float((float) x1, (float) y1, (float) buffer[0], (float) buffer[1], (float) buffer[2], (float) buffer[3], (float) buffer[4], (float) buffer[5]);
                        }
                    } else {
                        switch (code) {
                            case PathIterator.SEG_LINETO:  return new       Line2D.Double(x1,y1, buffer[0], buffer[1]);
                            case PathIterator.SEG_QUADTO:  return new  QuadCurve2D.Double(x1,y1, buffer[0], buffer[1], buffer[2], buffer[3]);
                            case PathIterator.SEG_CUBICTO: return new CubicCurve2D.Double(x1,y1, buffer[0], buffer[1], buffer[2], buffer[3], buffer[4], buffer[5]);
                        }
                    }
                }
            }
        }
    }
    return path;
}
 
Example #24
Source File: ShapeUtilitiesTest.java    From sis with Apache License 2.0 5 votes vote down vote up
/**
 * Invokes {@code ShapeUtilities.fitParabol(x1, y1, px, py, x2, y2, horizontal)},
 * then verifies that the control point of the returned curve is equals to {@code (cx, cy)}.
 */
private static void assertParabolEquals(final double cx, final double cy,
                                        final double x1, final double y1,
                                        final double px, final double py,
                                        final double x2, final double y2,
                                        final boolean horizontal)
{
    final QuadCurve2D p = ShapeUtilities.fitParabol(x1, y1, px, py, x2, y2, horizontal);
    assertPointEquals(x1, y1, p.getP1());
    assertPointEquals(x2, y2, p.getP2());
    assertPointEquals(cx, cy, p.getCtrlPt());
}
 
Example #25
Source File: Order3.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void enlarge(Rectangle2D r) {
    r.add(x0, y0);
    double eqn[] = {xcoeff1, 2 * xcoeff2, 3 * xcoeff3};
    int numroots = QuadCurve2D.solveQuadratic(eqn, eqn);
    for (int i = 0; i < numroots; i++) {
        double t = eqn[i];
        if (t > 0 && t < 1) {
            r.add(XforT(t), YforT(t));
        }
    }
    r.add(x1, y1);
}
 
Example #26
Source File: Order3.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public double nextVertical(double t0, double t1) {
    double eqn[] = {xcoeff1, 2 * xcoeff2, 3 * xcoeff3};
    int numroots = QuadCurve2D.solveQuadratic(eqn, eqn);
    for (int i = 0; i < numroots; i++) {
        if (eqn[i] > t0 && eqn[i] < t1) {
            t1 = eqn[i];
        }
    }
    return t1;
}
 
Example #27
Source File: Order3.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public double nextVertical(double t0, double t1) {
    double eqn[] = {xcoeff1, 2 * xcoeff2, 3 * xcoeff3};
    int numroots = QuadCurve2D.solveQuadratic(eqn, eqn);
    for (int i = 0; i < numroots; i++) {
        if (eqn[i] > t0 && eqn[i] < t1) {
            t1 = eqn[i];
        }
    }
    return t1;
}
 
Example #28
Source File: Order3.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public double nextVertical(double t0, double t1) {
    double eqn[] = {xcoeff1, 2 * xcoeff2, 3 * xcoeff3};
    int numroots = QuadCurve2D.solveQuadratic(eqn, eqn);
    for (int i = 0; i < numroots; i++) {
        if (eqn[i] > t0 && eqn[i] < t1) {
            t1 = eqn[i];
        }
    }
    return t1;
}
 
Example #29
Source File: Order3.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public double nextVertical(double t0, double t1) {
    double eqn[] = {xcoeff1, 2 * xcoeff2, 3 * xcoeff3};
    int numroots = QuadCurve2D.solveQuadratic(eqn, eqn);
    for (int i = 0; i < numroots; i++) {
        if (eqn[i] > t0 && eqn[i] < t1) {
            t1 = eqn[i];
        }
    }
    return t1;
}
 
Example #30
Source File: Order3.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void enlarge(Rectangle2D r) {
    r.add(x0, y0);
    double eqn[] = {xcoeff1, 2 * xcoeff2, 3 * xcoeff3};
    int numroots = QuadCurve2D.solveQuadratic(eqn, eqn);
    for (int i = 0; i < numroots; i++) {
        double t = eqn[i];
        if (t > 0 && t < 1) {
            r.add(XforT(t), YforT(t));
        }
    }
    r.add(x1, y1);
}