Java Code Examples for java.awt.geom.Rectangle2D#add()

The following examples show how to use java.awt.geom.Rectangle2D#add() . 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: Polyline.java    From workcraft with MIT License 6 votes vote down vote up
private Rectangle2D getSegmentBoundsWithThreshold(Line2D segment) {
    Point2D pt1 = segment.getP1();
    Point2D pt2 = segment.getP2();

    Rectangle2D bb = new Rectangle2D.Double(pt1.getX(), pt1.getY(), 0, 0);
    bb.add(pt2);
    Point2D lineVec = new Point2D.Double(pt2.getX() - pt1.getX(), pt2.getY() - pt1.getY());

    double mag = lineVec.distance(0, 0);
    if (mag != 0) {
        lineVec.setLocation(lineVec.getY() * VisualConnection.HIT_THRESHOLD / mag,
                -lineVec.getX() * VisualConnection.HIT_THRESHOLD / mag);
        bb.add(pt1.getX() + lineVec.getX(), pt1.getY() + lineVec.getY());
        bb.add(pt2.getX() + lineVec.getX(), pt2.getY() + lineVec.getY());
        bb.add(pt1.getX() - lineVec.getX(), pt1.getY() - lineVec.getY());
        bb.add(pt2.getX() - lineVec.getX(), pt2.getY() - lineVec.getY());
    }
    return bb;
}
 
Example 2
Source File: Order2.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void enlarge(Rectangle2D r) {
    r.add(x0, y0);
    double t = -xcoeff1 / (2 * xcoeff2);
    if (t > 0 && t < 1) {
        r.add(XforT(t), YforT(t));
    }
    r.add(x1, y1);
}
 
Example 3
Source File: Order2.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
public void enlarge(Rectangle2D r) {
    r.add(x0, y0);
    double t = -xcoeff1 / (2 * xcoeff2);
    if (t > 0 && t < 1) {
        r.add(XforT(t), YforT(t));
    }
    r.add(x1, y1);
}
 
Example 4
Source File: AbstractTransition.java    From pumpernickel with MIT License 5 votes vote down vote up
/** Return a rectangle including all the points in the argument. */
protected static Rectangle2D getBounds(Point2D... p) {
	Rectangle2D r = new Rectangle2D.Double(p[0].getX(), p[0].getY(), 0, 0);
	for (int a = 1; a < p.length; a++) {
		r.add(p[a]);
	}
	return r;
}
 
Example 5
Source File: GeometryCollectionShape.java    From jts with GNU Lesser General Public License v2.1 5 votes vote down vote up
public Rectangle2D getBounds2D() {
    Rectangle2D rectangle = null;

    for (Iterator i = shapes.iterator(); i.hasNext();) {
        Shape shape = (Shape) i.next();

        if (rectangle == null) {
            rectangle = shape.getBounds2D();
        } else {
            rectangle.add(shape.getBounds2D());
        }
    }

    return rectangle;
}
 
Example 6
Source File: Order2.java    From mil-sym-android with Apache License 2.0 5 votes vote down vote up
public void enlarge(Rectangle2D r) {
    r.add(x0, y0);
    double t = -xcoeff1 / (2 * xcoeff2);
    if (t > 0 && t < 1) {
        r.add(XforT(t), YforT(t));
    }
    r.add(x1, y1);
}
 
Example 7
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 8
Source File: Order2.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 t = -xcoeff1 / (2 * xcoeff2);
    if (t > 0 && t < 1) {
        r.add(XforT(t), YforT(t));
    }
    r.add(x1, y1);
}
 
Example 9
Source File: Order2X.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
public void enlarge(Rectangle2D r) {
	r.add(x0, y0);
	double t = -xcoeff1 / (2 * xcoeff2);
	if (t > 0 && t < 1) {
		r.add(XforT(t), YforT(t));
	}
	r.add(x1, y1);
}
 
Example 10
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 11
Source File: Order2.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void enlarge(Rectangle2D r) {
    r.add(x0, y0);
    double t = -xcoeff1 / (2 * xcoeff2);
    if (t > 0 && t < 1) {
        r.add(XforT(t), YforT(t));
    }
    r.add(x1, y1);
}
 
Example 12
Source File: TextLine.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return the union of the visual bounds of all the components.
 * This incorporates the path.  It does not include logical
 * bounds (used by carets).
 */
public Rectangle2D getVisualBounds() {
    Rectangle2D result = null;

    for (int i = 0, n = 0; i < fComponents.length; i++, n += 2) {
        TextLineComponent tlc = fComponents[getComponentLogicalIndex(i)];
        Rectangle2D r = tlc.getVisualBounds();

        Point2D.Float pt = new Point2D.Float(locs[n], locs[n+1]);
        if (lp == null) {
            r.setRect(r.getMinX() + pt.x, r.getMinY() + pt.y,
                      r.getWidth(), r.getHeight());
        } else {
            lp.pathToPoint(pt, false, pt);

            AffineTransform at = tlc.getBaselineTransform();
            if (at != null) {
                AffineTransform tx = AffineTransform.getTranslateInstance
                    (pt.x - at.getTranslateX(), pt.y - at.getTranslateY());
                tx.concatenate(at);
                r = tx.createTransformedShape(r).getBounds2D();
            } else {
                r.setRect(r.getMinX() + pt.x, r.getMinY() + pt.y,
                          r.getWidth(), r.getHeight());
            }
        }

        if (result == null) {
            result = r;
        } else {
            result.add(r);
        }
    }

    if (result == null) {
        result = new Rectangle2D.Float(Float.MAX_VALUE, Float.MAX_VALUE, Float.MIN_VALUE, Float.MIN_VALUE);
    }

    return result;
}
 
Example 13
Source File: Order1.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
public void enlarge(Rectangle2D r) {
    r.add(x0, y0);
    r.add(x1, y1);
}
 
Example 14
Source File: Decoration.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public Rectangle2D getVisualBounds(Label label) {

            Rectangle2D visBounds = label.handleGetVisualBounds();

            if (swapColors || bgPaint != null || strikethrough
                        || stdUnderline != null || imUnderline != null) {

                float minX = 0;
                Rectangle2D lb = label.getLogicalBounds();

                float minY = 0, maxY = 0;

                if (swapColors || bgPaint != null) {

                    minY = (float)lb.getY();
                    maxY = minY + (float)lb.getHeight();
                }

                maxY = Math.max(maxY, getUnderlineMaxY(label.getCoreMetrics()));

                Rectangle2D ab = new Rectangle2D.Float(minX, minY, (float)lb.getWidth(), maxY-minY);
                visBounds.add(ab);
            }

            return visBounds;
        }
 
Example 15
Source File: Order0.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void enlarge(Rectangle2D r) {
    r.add(x, y);
}
 
Example 16
Source File: Order1.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public void enlarge(Rectangle2D r) {
    r.add(x0, y0);
    r.add(x1, y1);
}
 
Example 17
Source File: Decoration.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public Rectangle2D getVisualBounds(Label label) {

            Rectangle2D visBounds = label.handleGetVisualBounds();

            if (swapColors || bgPaint != null || strikethrough
                        || stdUnderline != null || imUnderline != null) {

                float minX = 0;
                Rectangle2D lb = label.getLogicalBounds();

                float minY = 0, maxY = 0;

                if (swapColors || bgPaint != null) {

                    minY = (float)lb.getY();
                    maxY = minY + (float)lb.getHeight();
                }

                maxY = Math.max(maxY, getUnderlineMaxY(label.getCoreMetrics()));

                Rectangle2D ab = new Rectangle2D.Float(minX, minY, (float)lb.getWidth(), maxY-minY);
                visBounds.add(ab);
            }

            return visBounds;
        }
 
Example 18
Source File: Order0.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public void enlarge(Rectangle2D r) {
    r.add(x, y);
}
 
Example 19
Source File: Order0.java    From HtmlUnit-Android with Apache License 2.0 4 votes vote down vote up
public void enlarge(Rectangle2D r) {
    r.add(x, y);
}
 
Example 20
Source File: Decoration.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
public Rectangle2D getVisualBounds(Label label) {

            Rectangle2D visBounds = label.handleGetVisualBounds();

            if (swapColors || bgPaint != null || strikethrough
                        || stdUnderline != null || imUnderline != null) {

                float minX = 0;
                Rectangle2D lb = label.getLogicalBounds();

                float minY = 0, maxY = 0;

                if (swapColors || bgPaint != null) {

                    minY = (float)lb.getY();
                    maxY = minY + (float)lb.getHeight();
                }

                maxY = Math.max(maxY, getUnderlineMaxY(label.getCoreMetrics()));

                Rectangle2D ab = new Rectangle2D.Float(minX, minY, (float)lb.getWidth(), maxY-minY);
                visBounds.add(ab);
            }

            return visBounds;
        }