Search in sources :

Example 16 with GeneralPath

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

the class GradientSliderUI method paintThumbs.

@Override
protected void paintThumbs(Graphics2D g) {
    if (slider.isEnabled() == false) {
        return;
    }
    if (hTriangle == null) {
        hTriangle = new GeneralPath();
        hTriangle.moveTo(0, 0);
        hTriangle.lineTo(TRIANGLE_SIZE, TRIANGLE_SIZE);
        hTriangle.lineTo(-TRIANGLE_SIZE, TRIANGLE_SIZE);
        hTriangle.lineTo(0, 0);
        hTriangle.closePath();
        vTriangle = new GeneralPath();
        vTriangle.moveTo(0, 0);
        vTriangle.lineTo(TRIANGLE_SIZE, TRIANGLE_SIZE);
        vTriangle.lineTo(TRIANGLE_SIZE, -TRIANGLE_SIZE);
        vTriangle.lineTo(0, 0);
        vTriangle.closePath();
    }
    AffineTransform t = new AffineTransform();
    int dx = trackRect.x + trackRect.width;
    int dy = trackRect.y + trackRect.height;
    dy -= trackRect.height / 6;
    dx -= trackRect.width / 6;
    int selected = slider.getSelectedThumb(false);
    float[] f = slider.getThumbPositions();
    int orientation = slider.getOrientation();
    Shape shape;
    Composite oldComposite = g.getComposite();
    g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, indication));
    for (int a = 0; a < thumbPositions.length; a++) {
        if (f[a] >= 0 && f[a] <= 1 && a != selected) {
            if (orientation == GradientSlider.HORIZONTAL) {
                dx = thumbPositions[a];
                shape = hTriangle;
            } else {
                dy = thumbPositions[a];
                shape = vTriangle;
            }
            t.setToTranslation(dx, dy);
            g.transform(t);
            float brightness = Math.max(0, thumbIndications[a] * .6f);
            g.setColor(new Color((int) (255 * brightness), (int) (255 * brightness), (int) (255 * brightness)));
            g.fill(shape);
            g.translate(-.5f, -.5f);
            g.setColor(new Color(255, 255, 255));
            g.draw(shape);
            g.translate(.5f, .5f);
            t.setToTranslation(-dx, -dy);
            g.transform(t);
        }
    }
    g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, indication));
    if (selected != -1 && f[selected] >= 0 && f[selected] <= 1) {
        if (orientation == GradientSlider.HORIZONTAL) {
            dx = thumbPositions[selected];
            shape = hTriangle;
        } else {
            dy = thumbPositions[selected];
            shape = vTriangle;
        }
        t.setToTranslation(dx, dy);
        g.transform(t);
        g.setColor(new Color(255, 255, 255));
        g.fill(shape);
        g.translate(-.5f, -.5f);
        g.setColor(new Color(0, 0, 0));
        g.draw(shape);
        g.translate(.5f, .5f);
        t.setToTranslation(-dx, -dy);
        g.transform(t);
    }
    g.setComposite(oldComposite);
}
Also used : Shape(java.awt.Shape) GeneralPath(java.awt.geom.GeneralPath) Composite(java.awt.Composite) AlphaComposite(java.awt.AlphaComposite) Color(java.awt.Color) AffineTransform(java.awt.geom.AffineTransform) TexturePaint(java.awt.TexturePaint)

Example 17 with GeneralPath

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

the class EquationDisplay method drawEquation.

private void drawEquation(Graphics2D g2, AbstractEquation equation) {
    float x = 0.0f;
    float y = (float) yPositionToPixel(equation.compute(xPixelToPosition(0.0)));
    GeneralPath path = new GeneralPath();
    path.moveTo(x, y);
    for (x = 0.0f; x < getWidth(); x += 1.0f) {
        double position = xPixelToPosition(x);
        y = (float) yPositionToPixel(equation.compute(position));
        path.lineTo(x, y);
    }
    g2.draw(path);
}
Also used : GeneralPath(java.awt.geom.GeneralPath)

Example 18 with GeneralPath

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

the class Path2DGrow method testEmptyGeneralPath.

static void testEmptyGeneralPath() {
    echo("\n - Test(GeneralPath[0]) ---");
    test(() -> new GeneralPath(Path2D.WIND_NON_ZERO, 0));
}
Also used : GeneralPath(java.awt.geom.GeneralPath)

Example 19 with GeneralPath

use of java.awt.geom.GeneralPath 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 20 with GeneralPath

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

the class Path2DCopyConstructor method testEmptyGeneralPath.

static void testEmptyGeneralPath() {
    log("\n - Test(GeneralPath[0]) ---");
    test(() -> new GeneralPath(Path2D.WIND_NON_ZERO, 0));
}
Also used : GeneralPath(java.awt.geom.GeneralPath)

Aggregations

GeneralPath (java.awt.geom.GeneralPath)84 AffineTransform (java.awt.geom.AffineTransform)14 PathIterator (java.awt.geom.PathIterator)14 Rectangle2D (java.awt.geom.Rectangle2D)8 Graphics2D (java.awt.Graphics2D)6 Point (java.awt.Point)6 Paint (java.awt.Paint)5 Color (java.awt.Color)4 Area (java.awt.geom.Area)4 Shape (java.awt.Shape)3 Point2D (java.awt.geom.Point2D)3 LayoutPathImpl (sun.font.LayoutPathImpl)3 BasicStroke (java.awt.BasicStroke)2 GradientPaint (java.awt.GradientPaint)2 RoundRectangle2D (java.awt.geom.RoundRectangle2D)2 JBColor (com.intellij.ui.JBColor)1 PdfContentByte (com.itextpdf.text.pdf.PdfContentByte)1 PdfGState (com.itextpdf.text.pdf.PdfGState)1 AlphaComposite (java.awt.AlphaComposite)1 Composite (java.awt.Composite)1