Search in sources :

Example 1 with Path2D

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

the class Path2DCopyConstructor method test.

static void test(Path2D p2d, boolean isEmpty) {
    testEqual(new Path2D.Float(p2d), p2d);
    testEqual(new Path2D.Double(p2d), p2d);
    testEqual(new GeneralPath(p2d), p2d);
    testIterator(new Path2D.Float(p2d), p2d);
    testIterator(new Path2D.Double(p2d), p2d);
    testIterator((Path2D) p2d.clone(), p2d);
    testFlattening(new Path2D.Float(p2d), p2d);
    testFlattening(new Path2D.Double(p2d), p2d);
    testFlattening((Path2D) p2d.clone(), p2d);
    testAddMove(new Path2D.Float(p2d));
    testAddMove(new Path2D.Double(p2d));
    testAddMove((Path2D) p2d.clone());
    // These should expect exception if empty
    testAddLine(new Path2D.Float(p2d), isEmpty);
    testAddLine(new Path2D.Double(p2d), isEmpty);
    testAddLine((Path2D) p2d.clone(), isEmpty);
    testAddQuad(new Path2D.Float(p2d), isEmpty);
    testAddQuad(new Path2D.Double(p2d), isEmpty);
    testAddQuad((Path2D) p2d.clone(), isEmpty);
    testAddCubic(new Path2D.Float(p2d), isEmpty);
    testAddCubic(new Path2D.Double(p2d), isEmpty);
    testAddCubic((Path2D) p2d.clone(), isEmpty);
    testAddClose(new Path2D.Float(p2d), isEmpty);
    testAddClose(new Path2D.Double(p2d), isEmpty);
    testAddClose((Path2D) p2d.clone(), isEmpty);
    testGetBounds(new Path2D.Float(p2d), p2d);
    testGetBounds(new Path2D.Double(p2d), p2d);
    testGetBounds((Path2D) p2d.clone(), p2d);
    testTransform(new Path2D.Float(p2d));
    testTransform(new Path2D.Double(p2d));
    testTransform((Path2D) p2d.clone());
    testIntersect(new Path2D.Float(p2d), p2d);
    testIntersect(new Path2D.Double(p2d), p2d);
    testIntersect((Path2D) p2d.clone(), p2d);
    testContains(new Path2D.Float(p2d), p2d);
    testContains(new Path2D.Double(p2d), p2d);
    testContains((Path2D) p2d.clone(), p2d);
    testGetCurrentPoint(new Path2D.Float(p2d), p2d);
    testGetCurrentPoint(new Path2D.Double(p2d), p2d);
    testGetCurrentPoint((Path2D) p2d.clone(), p2d);
}
Also used : GeneralPath(java.awt.geom.GeneralPath) Path2D(java.awt.geom.Path2D)

Example 2 with Path2D

use of java.awt.geom.Path2D in project intellij-community by JetBrains.

the class EditorPainter method getBorderShape.

private static Shape getBorderShape(float x, float y, float width, int height, boolean rounded) {
    if (width <= 0 || height <= 0)
        return null;
    Shape outer = rounded ? new RoundRectangle2D.Float(x, y, width, height, 2, 2) : new Rectangle2D.Float(x, y, width, height);
    if (width <= 2 || height <= 2)
        return outer;
    Shape inner = new Rectangle2D.Float(x + 1, y + 1, width - 2, height - 2);
    Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD);
    path.append(outer, false);
    path.append(inner, false);
    return path;
}
Also used : RoundRectangle2D(java.awt.geom.RoundRectangle2D) Path2D(java.awt.geom.Path2D) Rectangle2D(java.awt.geom.Rectangle2D) RoundRectangle2D(java.awt.geom.RoundRectangle2D)

Example 3 with Path2D

use of java.awt.geom.Path2D in project aima-java by aimacode.

the class GraphicsTransfer2D method transfer.

/**
	 * Transfers a {@link Polyline2D} into its {@link Shape} representative.
	 * @param polyline the polyline to be transferred.
	 * @return the transferred shape.
	 */
private static Shape transfer(Polyline2D polyline) {
    Path2D result = new java.awt.geom.Path2D.Double();
    Point2D[] vertexes = polyline.getVertexes();
    result.moveTo(vertexes[0].getX(), vertexes[0].getY());
    for (int i = 1; i < vertexes.length; i++) {
        result.lineTo(vertexes[i].getX(), vertexes[i].getY());
    }
    if (polyline.isClosed())
        result.closePath();
    return result;
}
Also used : Point2D(aima.core.util.math.geom.shapes.Point2D) Path2D(java.awt.geom.Path2D)

Example 4 with Path2D

use of java.awt.geom.Path2D in project poi by apache.

the class ShapeDebuggerRenderer method drawPath.

@Override
protected Path2D drawPath(XDGFShape shape) {
    Path2D path = super.drawPath(shape);
    if (_debugAcceptor == null || _debugAcceptor.accept(shape)) {
        // show numbers to associate shapes with ids.. doesn't always work
        Font f = _graphics.getFont();
        _graphics.scale(1, -1);
        _graphics.setFont(f.deriveFont(0.05F));
        String shapeId = "" + shape.getID();
        float shapeOffset = -0.1F;
        if (shape.hasMasterShape()) {
            shapeId += " MS:" + shape.getMasterShape().getID();
            shapeOffset -= 0.15F;
        }
        _graphics.drawString(shapeId, shapeOffset, 0);
        _graphics.setFont(f);
        _graphics.scale(1, -1);
    }
    return path;
}
Also used : Path2D(java.awt.geom.Path2D) Font(java.awt.Font)

Example 5 with Path2D

use of java.awt.geom.Path2D in project frostwire by frostwire.

the class SkinTableHeaderPainter method paintBorder.

private void paintBorder(Graphics2D g, int width, int height) {
    Path2D path = new Path2D.Double(Path2D.WIND_EVEN_ODD);
    path.reset();
    path.moveTo(0, height - 1);
    path.lineTo(width - 1, height - 1);
    path.lineTo(width - 1, 0);
    g.setPaint(SkinColors.TABLE_HEADER_BORDER_COLOR);
    g.draw(path);
}
Also used : Path2D(java.awt.geom.Path2D)

Aggregations

Path2D (java.awt.geom.Path2D)101 Area (java.awt.geom.Area)13 Point2D (java.awt.geom.Point2D)12 Rectangle2D (java.awt.geom.Rectangle2D)12 PathIterator (java.awt.geom.PathIterator)8 Point (java.awt.Point)6 AffineTransform (java.awt.geom.AffineTransform)6 Line2D (java.awt.geom.Line2D)6 Graphics2D (java.awt.Graphics2D)5 ArrayList (java.util.ArrayList)5 BasicStroke (java.awt.BasicStroke)4 Color (java.awt.Color)4 Paint (java.awt.Paint)4 Shape (java.awt.Shape)4 GeneralPath (java.awt.geom.GeneralPath)4 RoundRectangle2D (java.awt.geom.RoundRectangle2D)4 RadialGradientPaint (java.awt.RadialGradientPaint)3 Point2D_F64 (georegression.struct.point.Point2D_F64)2 TDoubleArrayList (gnu.trove.TDoubleArrayList)2 Complex (imagingbook.lib.math.Complex)2