Search in sources :

Example 91 with Path2D

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

the class HeapState method paintComponent.

@Override
protected void paintComponent(Graphics g) {
    super.paintComponent(g);
    if (heapState == null) {
        return;
    }
    final int height = getHeight() - 1;
    final int width = getWidth();
    final long now = System.currentTimeMillis();
    final int maxDataSize = Math.round(heapState.getMaxHeapInBytes() / TEN_MB) * TEN_MB + TEN_MB;
    final Graphics2D graphics2D = (Graphics2D) g;
    graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    graphics2D.setColor(getForegroundColor());
    graphics2D.setStroke(GRAPH_STROKE);
    Path2D path = null;
    for (HeapSample sample : heapState.getSamples()) {
        final double x = width - (((double) (now - sample.getSampleTime())) / ((double) heapState.getMaxSampleSizeMs()) * width);
        // TODO(pq): consider a Y offset or scaling.
        final double y = (double) height * sample.getBytes() / maxDataSize;
        if (path == null) {
            path = new Path2D.Double();
            path.moveTo(x, height - y + 1);
        } else {
            path.lineTo(x, height - y + 1);
        }
    }
    graphics2D.draw(path);
}
Also used : Path2D(java.awt.geom.Path2D) HeapSample(io.flutter.perf.HeapMonitor.HeapSample)

Example 92 with Path2D

use of java.awt.geom.Path2D in project cytoscape-impl by cytoscape.

the class GraphicsUtilities method starShape.

private static Shape starShape(int sides, double x, double y, double width, double height) {
    Path2D poly = new Path2D.Double(Path2D.WIND_EVEN_ODD, sides);
    width = width / 2;
    height = height / 2;
    x = x + width;
    y = y + height;
    int nPoints = sides * 2;
    Point2D.Double[] points = new Point2D.Double[nPoints];
    for (int i = 0; i < sides; i++) {
        double x1 = circleX(sides, i, false) * width + x;
        double y1 = circleY(sides, i, false) * height + y;
        double x2 = circleX(sides, (i + 2) % sides, false) * width + x;
        double y2 = circleY(sides, (i + 2) % sides, false) * height + y;
        points[i * 2] = new Point2D.Double(x1, y1);
        points[(i * 2 + 4) % nPoints] = new Point2D.Double(x2, y2);
    }
    // Fill in the intersection points
    for (int i = 0; i < nPoints; i = i + 2) {
        int p1 = i;
        int p2 = (i + 4) % nPoints;
        int p3 = (i + 2) % nPoints;
        int p4 = (p3 + nPoints - 4) % nPoints;
        points[(i + 1) % nPoints] = findIntersection(points[p1], points[p2], points[p3], points[p4]);
    }
    // Now, add the points
    poly.moveTo(points[0].getX(), points[0].getY());
    for (int i = 1; i < nPoints; i++) {
        poly.lineTo(points[i].getX(), points[i].getY());
    }
    poly.closePath();
    return poly;
}
Also used : Point2D(java.awt.geom.Point2D) Path2D(java.awt.geom.Path2D) RadialGradientPaint(java.awt.RadialGradientPaint) MultipleGradientPaint(java.awt.MultipleGradientPaint) LinearGradientPaint(java.awt.LinearGradientPaint) Paint(java.awt.Paint)

Example 93 with Path2D

use of java.awt.geom.Path2D in project cytoscape-impl by cytoscape.

the class GraphicsUtilities method openArrow.

// Create a shape with a 30 degree arrow
static Shape openArrow(double size) {
    Path2D path = new Path2D.Double();
    path.moveTo(-size * 1.7, -size / 2.0);
    path.lineTo(0.0, 0.0);
    path.lineTo(-size * 1.7, size / 2.0);
    return path;
}
Also used : Path2D(java.awt.geom.Path2D)

Example 94 with Path2D

use of java.awt.geom.Path2D in project cytoscape-impl by cytoscape.

the class GraphicsUtilities method concaveArrow.

// Create a shape with a 30 degree arrow
static Shape concaveArrow(double size) {
    Path2D path = new Path2D.Double();
    path.moveTo(-size, 0.0);
    path.lineTo(-size * 1.7, -size / 2.0);
    path.lineTo(0.0, 0.0);
    path.lineTo(-size * 1.7, size / 2.0);
    path.closePath();
    return path;
}
Also used : Path2D(java.awt.geom.Path2D)

Example 95 with Path2D

use of java.awt.geom.Path2D in project cytoscape-impl by cytoscape.

the class GraphicsUtilities method parallelogramShape.

private static Shape parallelogramShape(double x, double y, double width, double height) {
    Path2D poly = new Path2D.Double(Path2D.WIND_EVEN_ODD, 4);
    double xMax = x + width;
    double yMax = y + height;
    poly.moveTo(x, y);
    poly.lineTo(((2.0f * xMax) + x) / 3.0f, y);
    poly.lineTo(xMax, yMax);
    poly.lineTo(((2.0f * x) + xMax) / 3.0f, yMax);
    poly.closePath();
    return poly;
}
Also used : 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