Search in sources :

Example 26 with Polygon

use of java.awt.Polygon in project Activiti by Activiti.

the class DefaultProcessDiagramCanvas method drawGateway.

public void drawGateway(GraphicInfo graphicInfo) {
    Polygon rhombus = new Polygon();
    int x = (int) graphicInfo.getX();
    int y = (int) graphicInfo.getY();
    int width = (int) graphicInfo.getWidth();
    int height = (int) graphicInfo.getHeight();
    rhombus.addPoint(x, y + (height / 2));
    rhombus.addPoint(x + (width / 2), y + height);
    rhombus.addPoint(x + width, y + (height / 2));
    rhombus.addPoint(x + (width / 2), y);
    g.draw(rhombus);
}
Also used : Polygon(java.awt.Polygon) Point(java.awt.Point) Paint(java.awt.Paint)

Example 27 with Polygon

use of java.awt.Polygon in project Activiti by Activiti.

the class DefaultProcessDiagramCanvas method drawArrowHead.

public void drawArrowHead(Line2D.Double line, double scaleFactor) {
    int doubleArrowWidth = (int) (2 * ARROW_WIDTH / scaleFactor);
    if (doubleArrowWidth == 0) {
        doubleArrowWidth = 2;
    }
    Polygon arrowHead = new Polygon();
    arrowHead.addPoint(0, 0);
    int arrowHeadPoint = (int) (-ARROW_WIDTH / scaleFactor);
    if (arrowHeadPoint == 0) {
        arrowHeadPoint = -1;
    }
    arrowHead.addPoint(arrowHeadPoint, -doubleArrowWidth);
    arrowHeadPoint = (int) (ARROW_WIDTH / scaleFactor);
    if (arrowHeadPoint == 0) {
        arrowHeadPoint = 1;
    }
    arrowHead.addPoint(arrowHeadPoint, -doubleArrowWidth);
    AffineTransform transformation = new AffineTransform();
    transformation.setToIdentity();
    double angle = Math.atan2(line.y2 - line.y1, line.x2 - line.x1);
    transformation.translate(line.x2, line.y2);
    transformation.rotate((angle - Math.PI / 2d));
    AffineTransform originalTransformation = g.getTransform();
    g.setTransform(transformation);
    g.fill(arrowHead);
    g.setTransform(originalTransformation);
}
Also used : AffineTransform(java.awt.geom.AffineTransform) Polygon(java.awt.Polygon) Point(java.awt.Point) Paint(java.awt.Paint)

Example 28 with Polygon

use of java.awt.Polygon in project android by JetBrains.

the class ConnectionDraw method getTopArrow.

/**
     * Static accessor to the top arrow
     *
     * @return return a Polygon representing a top arrow
     */
public static Polygon getTopArrow() {
    if (sTopArrow == null) {
        sTopArrow = new Polygon();
        sTopArrow.addPoint(0, 0);
        sTopArrow.addPoint(-CONNECTION_ARROW_SIZE, ARROW_SIDE);
        sTopArrow.addPoint(+CONNECTION_ARROW_SIZE, ARROW_SIDE);
    }
    return sTopArrow;
}
Also used : Polygon(java.awt.Polygon)

Example 29 with Polygon

use of java.awt.Polygon in project jdk8u_jdk by JetBrains.

the class BufferedRenderPipe method draw.

public void draw(SunGraphics2D sg2d, Shape s) {
    if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
        if (s instanceof Polygon) {
            if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
                Polygon p = (Polygon) s;
                drawPolygon(sg2d, p.xpoints, p.ypoints, p.npoints);
                return;
            }
        }
        Path2D.Float p2df;
        int transx, transy;
        if (sg2d.transformState <= SunGraphics2D.TRANSFORM_INT_TRANSLATE) {
            if (s instanceof Path2D.Float) {
                p2df = (Path2D.Float) s;
            } else {
                p2df = new Path2D.Float(s);
            }
            transx = sg2d.transX;
            transy = sg2d.transY;
        } else {
            p2df = new Path2D.Float(s, sg2d.transform);
            transx = 0;
            transy = 0;
        }
        drawPath(sg2d, p2df, transx, transy);
    } else if (sg2d.strokeState < SunGraphics2D.STROKE_CUSTOM) {
        ShapeSpanIterator si = LoopPipe.getStrokeSpans(sg2d, s);
        try {
            fillSpans(sg2d, si, 0, 0);
        } finally {
            si.dispose();
        }
    } else {
        fill(sg2d, sg2d.stroke.createStrokedShape(s));
    }
}
Also used : Path2D(java.awt.geom.Path2D) Polygon(java.awt.Polygon)

Example 30 with Polygon

use of java.awt.Polygon in project jdk8u_jdk by JetBrains.

the class GraphicsTests method initContext.

public void initContext(TestEnvironment env, Context ctx) {
    ctx.graphics = env.getGraphics();
    int w = env.getWidth();
    int h = env.getHeight();
    ctx.size = env.getIntValue(sizeList);
    ctx.outdim = getOutputSize(ctx.size, ctx.size);
    ctx.pixscale = 1.0;
    if (hasGraphics2D) {
        Graphics2D g2d = (Graphics2D) ctx.graphics;
        AlphaComposite ac = (AlphaComposite) env.getModifier(compRules);
        if (env.isEnabled(doExtraAlpha)) {
            ac = AlphaComposite.getInstance(ac.getRule(), 0.125f);
        }
        g2d.setComposite(ac);
        if (env.isEnabled(doXor)) {
            g2d.setXORMode(Color.white);
        }
        if (env.isEnabled(doClipping)) {
            Polygon p = new Polygon();
            p.addPoint(0, 0);
            p.addPoint(w, 0);
            p.addPoint(0, h);
            p.addPoint(w, h);
            p.addPoint(0, 0);
            g2d.clip(p);
        }
        Transform tx = (Transform) env.getModifier(transforms);
        Dimension envdim = new Dimension(w, h);
        tx.init(g2d, ctx, envdim);
        w = envdim.width;
        h = envdim.height;
        g2d.setRenderingHint(RenderingHints.KEY_RENDERING, env.getModifier(renderHint));
    }
    switch(env.getIntValue(animList)) {
        case 0:
            ctx.animate = false;
            ctx.maxX = 3;
            ctx.maxY = 1;
            ctx.orgX = (w - ctx.outdim.width) / 2;
            ctx.orgY = (h - ctx.outdim.height) / 2;
            break;
        case 1:
            ctx.animate = true;
            ctx.maxX = Math.max(Math.min(32, w - ctx.outdim.width), 3);
            ctx.maxY = 1;
            ctx.orgX = (w - ctx.outdim.width - ctx.maxX) / 2;
            ctx.orgY = (h - ctx.outdim.height) / 2;
            break;
        case 2:
            ctx.animate = true;
            ctx.maxX = (w - ctx.outdim.width) + 1;
            ctx.maxY = (h - ctx.outdim.height) + 1;
            ctx.maxX = adjustWidth(ctx.maxX, ctx.maxY);
            ctx.maxX = Math.max(ctx.maxX, 3);
            ctx.maxY = Math.max(ctx.maxY, 1);
            // ctx.orgX = ctx.orgY = 0;
            break;
    }
    ctx.initX = ctx.maxX / 2;
    ctx.initY = ctx.maxY / 2;
}
Also used : AlphaComposite(java.awt.AlphaComposite) Dimension(java.awt.Dimension) Polygon(java.awt.Polygon) AffineTransform(java.awt.geom.AffineTransform) Graphics2D(java.awt.Graphics2D)

Aggregations

Polygon (java.awt.Polygon)39 Point (java.awt.Point)15 Graphics2D (java.awt.Graphics2D)11 Color (java.awt.Color)6 Rectangle (java.awt.Rectangle)6 GridPoint (doc.GridPoint)5 BasicStroke (java.awt.BasicStroke)5 Font (java.awt.Font)5 Paint (java.awt.Paint)5 FontMetrics (java.awt.FontMetrics)4 AffineTransform (java.awt.geom.AffineTransform)4 GradientPaint (java.awt.GradientPaint)2 Shape (java.awt.Shape)2 ShapeSpanIterator (sun.java2d.pipe.ShapeSpanIterator)2 BasePoint (gdsc.core.match.BasePoint)1 PolygonRoi (ij.gui.PolygonRoi)1 Roi (ij.gui.Roi)1 AlphaComposite (java.awt.AlphaComposite)1 Component (java.awt.Component)1 Dimension (java.awt.Dimension)1