Search in sources :

Example 31 with GeneralPath

use of java.awt.geom.GeneralPath in project beast-mcmc by beast-dev.

the class DensityEstimatePlot method paintData.

/**
     * Paint data series
     */
protected void paintData(Graphics2D g2, Variate.N xData, Variate.N yData) {
    int n = xData.getCount();
    float x = (float) transformX(((Number) xData.get(0)).doubleValue());
    float y = (float) transformY(((Number) yData.get(0)).doubleValue());
    GeneralPath path = new GeneralPath();
    path.moveTo(x, y);
    for (int i = 1; i < n; i++) {
        x = (float) transformX(((Number) xData.get(i)).doubleValue());
        y = (float) transformY(((Number) yData.get(i)).doubleValue());
        path.lineTo(x, y);
    }
    if (solid) {
        path.closePath();
        Paint fillPaint = new Color(((Color) linePaint).getRed(), ((Color) linePaint).getGreen(), ((Color) linePaint).getBlue(), 32);
        g2.setPaint(fillPaint);
        g2.fill(path);
    }
    g2.setStroke(lineStroke);
    g2.setPaint(linePaint);
    g2.draw(path);
}
Also used : GeneralPath(java.awt.geom.GeneralPath)

Example 32 with GeneralPath

use of java.awt.geom.GeneralPath in project beast-mcmc by beast-dev.

the class ErrorBarPlot method paintData.

/**
     * Paint data series
     */
protected void paintData(Graphics2D g2, Variate.N xData, Variate.N yData) {
    g2.setPaint(linePaint);
    g2.setStroke(lineStroke);
    int n = xData.getCount();
    for (int i = 0; i < n; i++) {
        GeneralPath path = new GeneralPath();
        double x0 = ((Number) xData.get(i)).doubleValue();
        double y0 = ((Number) yData.get(i)).doubleValue();
        double e = ((Number) errorData.get(i)).doubleValue() / 2;
        float fx = (float) transformX(x0);
        float fy = (float) transformY(y0);
        if (!Double.isInfinite(fx) && !Double.isInfinite(fy) && !Double.isNaN(fx) && !Double.isNaN(fy)) {
            if (orientation == Orientation.HORIZONTAL) {
                float fx1 = (float) transformX(x0 - e);
                float fx2 = (float) transformX(x0 + e);
                path.moveTo(fx, fy);
                path.lineTo(fx1, fy);
                path.moveTo(fx, fy);
                path.lineTo(fx2, fy);
            } else if (orientation == Orientation.VERTICAL) {
                float fy1 = (float) transformY(y0 - e);
                float fy2 = (float) transformY(y0 + e);
                path.moveTo(fx, fy);
                path.lineTo(fx, fy1);
                path.moveTo(fx, fy);
                path.lineTo(fx, fy2);
            }
        }
        g2.draw(path);
    }
}
Also used : GeneralPath(java.awt.geom.GeneralPath)

Example 33 with GeneralPath

use of java.awt.geom.GeneralPath in project android_frameworks_base by crdroidandroid.

the class Path_Delegate method offset.

/**
     * Offset the path by (dx,dy), returning true on success
     *
     * @param dx  The amount in the X direction to offset the entire path
     * @param dy  The amount in the Y direction to offset the entire path
     */
public void offset(float dx, float dy) {
    GeneralPath newPath = new GeneralPath();
    PathIterator iterator = mPath.getPathIterator(new AffineTransform(0, 0, dx, 0, 0, dy));
    newPath.append(iterator, false);
    mPath = newPath;
}
Also used : GeneralPath(java.awt.geom.GeneralPath) PathIterator(java.awt.geom.PathIterator) AffineTransform(java.awt.geom.AffineTransform)

Example 34 with GeneralPath

use of java.awt.geom.GeneralPath in project processdash by dtuma.

the class TooltipLineXYLineAndShapeRenderer method getTooltipArea.

/**
     * Creates and returns a polygon that has the same shape as the line passed
     *  as a parameter, but ticker so it can be used as a mouse-over tooltip area
     */
private Shape getTooltipArea(Line2D line, int series) {
    GeneralPath area = new GeneralPath();
    float areaWidth = getAreaWidth(series);
    area.moveTo((float) line.getX1(), (float) (line.getY1() + areaWidth / 2));
    area.lineTo((float) line.getX2(), (float) (line.getY2() + areaWidth / 2));
    area.lineTo((float) line.getX2(), (float) (line.getY2() - areaWidth / 2));
    area.lineTo((float) line.getX1(), (float) (line.getY1() - areaWidth / 2));
    area.closePath();
    return area;
}
Also used : GeneralPath(java.awt.geom.GeneralPath)

Example 35 with GeneralPath

use of java.awt.geom.GeneralPath in project beast-mcmc by beast-dev.

the class VisualizeBrownianBridge2D method paintComponent.

public void paintComponent(Graphics g) {
    System.out.println("entering paintComponent()");
    computeScales();
    Graphics2D g2d = (Graphics2D) g;
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2d.setStroke(new BasicStroke(1.5f));
    System.out.println("Painting shapes");
    for (Shape s : shapes) {
        System.out.print(".");
        System.out.flush();
        GeneralPath path = new GeneralPath(s);
        path.transform(getFullTransform());
        g2d.setPaint(shapeColor);
        g2d.fill(path);
    }
    AffineTransform transform = getFullTransform();
    for (int r = 0; r < getTrials(); r++) {
        Color c = new Color((float) Math.random(), (float) Math.random(), (float) Math.random());
        for (int s = 0; s < start.length; s++) {
            List<SpaceTime> points = null;
            g2d.setPaint(c);
            int topLevelRejects = -1;
            while (points == null) {
                topLevelRejects += 1;
                points = MultivariateBrownianBridge.divideConquerBrownianBridge(mnd, start[s], end[s], getMaxDepth(), getMaxTries(), rejector);
            }
            GeneralPath path = new GeneralPath();
            path.moveTo((float) points.get(0).getX(0), (float) points.get(0).getX(1));
            //System.out.println(points.get(0));
            for (int i = 1; i < points.size(); i++) {
                path.lineTo((float) points.get(i).getX(0), (float) points.get(i).getX(1));
            //System.out.println(points.get(i));
            }
            path.transform(getFullTransform());
            g2d.draw(path);
            g2d.setPaint(Color.black);
            SpaceTime.paintDot(start[s], 3, transform, g2d);
            SpaceTime.paintDot(end[s], 3, transform, g2d);
        }
    }
    System.out.println("leaving paintComponent()");
}
Also used : GeneralPath(java.awt.geom.GeneralPath) AffineTransform(java.awt.geom.AffineTransform)

Aggregations

GeneralPath (java.awt.geom.GeneralPath)96 Point (java.awt.Point)14 AffineTransform (java.awt.geom.AffineTransform)14 PathIterator (java.awt.geom.PathIterator)14 Graphics2D (java.awt.Graphics2D)8 Rectangle2D (java.awt.geom.Rectangle2D)8 Color (java.awt.Color)7 Paint (java.awt.Paint)7 BasicStroke (java.awt.BasicStroke)6 Point2D (java.awt.geom.Point2D)6 Stroke (java.awt.Stroke)5 Area (java.awt.geom.Area)4 Shape (java.awt.Shape)3 CubicCurve2D (java.awt.geom.CubicCurve2D)3 LayoutPathImpl (sun.font.LayoutPathImpl)3 GradientPaint (java.awt.GradientPaint)2 Rectangle (java.awt.Rectangle)2 Line2D (java.awt.geom.Line2D)2 RoundRectangle2D (java.awt.geom.RoundRectangle2D)2 JBColor (com.intellij.ui.JBColor)1