Search in sources :

Example 1 with CubicCurve2D

use of java.awt.geom.CubicCurve2D in project jdk8u_jdk by JetBrains.

the class ContainsTest method main.

public static void main(String[] args) throws Exception {
    CubicCurve2D c = new CubicCurve2D.Double(0, 0, 4, -4, -2, -4, 2, 0);
    Rectangle2D r = new Rectangle2D.Double(0.75, -2.5, 0.5, 2);
    if (c.contains(r)) {
        throw new Exception("The rectangle should not be contained in the curve");
    }
}
Also used : Rectangle2D(java.awt.geom.Rectangle2D) CubicCurve2D(java.awt.geom.CubicCurve2D)

Example 2 with CubicCurve2D

use of java.awt.geom.CubicCurve2D in project jdk8u_jdk by JetBrains.

the class IntersectsTest method main.

public static void main(String[] args) throws Exception {
    CubicCurve2D c = new CubicCurve2D.Double(50.0, 300.0, 150.0, 166.6666717529297, 238.0, 456.66668701171875, 350.0, 300.0);
    Rectangle2D r = new Rectangle2D.Double(260, 300, 10, 10);
    if (!c.intersects(r)) {
        throw new Exception("The rectangle is contained. " + "intersects(Rectangle2D) should return true");
    }
}
Also used : Rectangle2D(java.awt.geom.Rectangle2D) CubicCurve2D(java.awt.geom.CubicCurve2D)

Example 3 with CubicCurve2D

use of java.awt.geom.CubicCurve2D in project gephi by gephi.

the class SplineDisplay method paintSpline.

private void paintSpline(Graphics2D g2) {
    CubicCurve2D spline = new CubicCurve2D.Double(xPositionToPixel(0.0), yPositionToPixel(0.0), xPositionToPixel(control1.getX()), yPositionToPixel(control1.getY()), xPositionToPixel(control2.getX()), yPositionToPixel(control2.getY()), xPositionToPixel(1.0), yPositionToPixel(1.0));
    g2.setColor(new Color(0.0f, 0.3f, 0.0f, 1.0f));
    g2.draw(spline);
}
Also used : Color(java.awt.Color) CubicCurve2D(java.awt.geom.CubicCurve2D)

Example 4 with CubicCurve2D

use of java.awt.geom.CubicCurve2D in project antlr4 by antlr.

the class TreeViewer method paintEdges.

protected void paintEdges(Graphics g, Tree parent) {
    if (!getTree().isLeaf(parent)) {
        BasicStroke stroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
        ((Graphics2D) g).setStroke(stroke);
        Rectangle2D.Double parentBounds = getBoundsOfNode(parent);
        double x1 = parentBounds.getCenterX();
        double y1 = parentBounds.getMaxY();
        for (Tree child : getTree().getChildren(parent)) {
            Rectangle2D.Double childBounds = getBoundsOfNode(child);
            double x2 = childBounds.getCenterX();
            double y2 = childBounds.getMinY();
            if (getUseCurvedEdges()) {
                CubicCurve2D c = new CubicCurve2D.Double();
                double ctrlx1 = x1;
                double ctrly1 = (y1 + y2) / 2;
                double ctrlx2 = x2;
                double ctrly2 = y1;
                c.setCurve(x1, y1, ctrlx1, ctrly1, ctrlx2, ctrly2, x2, y2);
                ((Graphics2D) g).draw(c);
            } else {
                g.drawLine((int) x1, (int) y1, (int) x2, (int) y2);
            }
            paintEdges(g, child);
        }
    }
}
Also used : Rectangle2D(java.awt.geom.Rectangle2D) Tree(org.antlr.v4.runtime.tree.Tree) CubicCurve2D(java.awt.geom.CubicCurve2D)

Aggregations

CubicCurve2D (java.awt.geom.CubicCurve2D)4 Rectangle2D (java.awt.geom.Rectangle2D)3 Color (java.awt.Color)1 Tree (org.antlr.v4.runtime.tree.Tree)1