Search in sources :

Example 51 with Path2D

use of java.awt.geom.Path2D in project BoofCV by lessthanoptimal.

the class VisualizeShapes method fillPolygon.

public static void fillPolygon(Polygon2D_F64 polygon, double scale, Graphics2D g2) {
    BoofSwingUtil.antialiasing(g2);
    Path2D path = new Path2D.Double();
    Point2D_F64 p = polygon.get(0);
    path.moveTo(p.x * scale, p.y * scale);
    for (int i = 1; i <= polygon.size(); i++) {
        p = polygon.get(i % polygon.size());
        path.lineTo(p.x * scale, p.y * scale);
    }
    g2.fill(path);
}
Also used : Point2D_F64(georegression.struct.point.Point2D_F64) Path2D(java.awt.geom.Path2D)

Example 52 with Path2D

use of java.awt.geom.Path2D in project imagingbook-common by imagingbook.

the class FourierDescriptor method makeFourierPairsReconstruction.

/**
 * Reconstructs the shape obtained from FD-pairs 0,...,Mp as a polygon (path).
 *
 * @param Mp number of Fourier coefficient pairs
 * @return reconstructed shape
 */
public Path2D makeFourierPairsReconstruction(int Mp) {
    int M = G.length;
    Mp = Math.min(Mp, M / 2);
    int recPoints = Math.max(minReconstructionSamples, G.length * 3);
    Path2D path = new Path2D.Float();
    for (int i = 0; i < recPoints; i++) {
        double t = (double) i / recPoints;
        // assumes that coefficient 0 is never scaled
        Complex pt = new Complex(getCoefficient(0));
        // calculate a particular reconstruction point
        for (int m = 1; m <= Mp; m++) {
            Complex ep = getEllipsePoint(getCoefficient(-m), getCoefficient(m), m, t);
            pt = pt.add(ep.multiply(reconstructionScale));
        }
        double xt = pt.re;
        double yt = pt.im;
        if (i == 0) {
            path.moveTo(xt, yt);
        } else {
            path.lineTo(xt, yt);
        }
    }
    path.closePath();
    return path;
}
Also used : Path2D(java.awt.geom.Path2D) Complex(imagingbook.lib.math.Complex)

Example 53 with Path2D

use of java.awt.geom.Path2D in project imagingbook-common by imagingbook.

the class FourierDescriptor method makeEllipse.

// -----------------------------------------------------------------------
public Path2D makeEllipse(Complex G1, Complex G2, int m, double xOffset, double yOffset) {
    Path2D path = new Path2D.Float();
    int recPoints = Math.max(minReconstructionSamples, G.length * 3);
    for (int i = 0; i < recPoints; i++) {
        double t = (double) i / recPoints;
        Complex p1 = this.getEllipsePoint(G1, G2, m, t);
        double xt = p1.re;
        double yt = p1.im;
        if (i == 0) {
            path.moveTo(xt + xOffset, yt + yOffset);
        } else {
            path.lineTo(xt + xOffset, yt + yOffset);
        }
    }
    path.closePath();
    return path;
}
Also used : Path2D(java.awt.geom.Path2D) Complex(imagingbook.lib.math.Complex)

Example 54 with Path2D

use of java.awt.geom.Path2D in project imagingbook-common by imagingbook.

the class HoughLineOverlay method markPoint.

public void markPoint(double xc, double yc, Color color) {
    double markerSize = 2.0;
    Path2D path = new Path2D.Double();
    path.moveTo(xc - markerSize, yc);
    path.lineTo(xc + markerSize, yc);
    path.moveTo(xc, yc - markerSize);
    path.lineTo(xc, yc + markerSize);
    ShapeRoi cross = new ShapeRoi(path);
    cross.setStrokeWidth(0.3);
    cross.setStrokeColor(color);
    this.addRoi(cross, true);
}
Also used : ShapeRoi(ij.gui.ShapeRoi) Path2D(java.awt.geom.Path2D)

Example 55 with Path2D

use of java.awt.geom.Path2D in project imagingbook-common by imagingbook.

the class SiftOverlay method makeRoi.

@Override
public Roi makeRoi(SiftDescriptor sd) {
    double x = sd.getX();
    double y = sd.getY();
    double scale = featureScale * sd.getScale();
    double orient = sd.getOrientation() + DisplayAngleOffset;
    double sin = Math.sin(orient);
    double cos = Math.cos(orient);
    Path2D poly = new Path2D.Double();
    poly.moveTo(x + (sin - cos) * scale, y - (sin + cos) * scale);
    poly.lineTo(x + (sin + cos) * scale, y + (sin - cos) * scale);
    poly.lineTo(x, y);
    poly.lineTo(x - (sin - cos) * scale, y + (sin + cos) * scale);
    poly.lineTo(x - (sin + cos) * scale, y - (sin - cos) * scale);
    poly.closePath();
    return new ShapeRoi(poly);
}
Also used : ShapeRoi(ij.gui.ShapeRoi) Path2D(java.awt.geom.Path2D)

Aggregations

Path2D (java.awt.geom.Path2D)126 Point2D (java.awt.geom.Point2D)20 Area (java.awt.geom.Area)16 Rectangle2D (java.awt.geom.Rectangle2D)13 Shape (java.awt.Shape)9 Point (java.awt.Point)8 Line2D (java.awt.geom.Line2D)8 PathIterator (java.awt.geom.PathIterator)8 ArrayList (java.util.ArrayList)8 AffineTransform (java.awt.geom.AffineTransform)7 GeneralPath (java.awt.geom.GeneralPath)7 Color (java.awt.Color)6 Graphics2D (java.awt.Graphics2D)6 Paint (java.awt.Paint)6 ShapeRoi (ij.gui.ShapeRoi)5 BasicStroke (java.awt.BasicStroke)4 RadialGradientPaint (java.awt.RadialGradientPaint)4 Point2D_F64 (georegression.struct.point.Point2D_F64)3 RoundRectangle2D (java.awt.geom.RoundRectangle2D)3 Vector2D (de.gurkenlabs.litiengine.util.geom.Vector2D)2