Search in sources :

Example 46 with Stroke

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

the class DefaultProcessDiagramCanvas method drawInclusiveGateway.

public void drawInclusiveGateway(GraphicInfo graphicInfo, double scaleFactor) {
    // rhombus
    drawGateway(graphicInfo);
    int x = (int) graphicInfo.getX();
    int y = (int) graphicInfo.getY();
    int width = (int) graphicInfo.getWidth();
    int height = (int) graphicInfo.getHeight();
    int diameter = width / 2;
    if (scaleFactor == 1.0) {
        // circle inside rhombus
        Stroke orginalStroke = g.getStroke();
        g.setStroke(GATEWAY_TYPE_STROKE);
        Ellipse2D.Double circle = new Ellipse2D.Double(((width - diameter) / 2) + x, ((height - diameter) / 2) + y, diameter, diameter);
        g.draw(circle);
        g.setStroke(orginalStroke);
    }
}
Also used : Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) Point(java.awt.Point) Paint(java.awt.Paint) Ellipse2D(java.awt.geom.Ellipse2D)

Example 47 with Stroke

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

the class DefaultProcessDiagramCanvas method drawMultiInstanceMarker.

public void drawMultiInstanceMarker(boolean sequential, int x, int y, int width, int height) {
    int rectangleWidth = MARKER_WIDTH;
    int rectangleHeight = MARKER_WIDTH;
    int lineX = x + (width - rectangleWidth) / 2;
    int lineY = y + height - rectangleHeight - 3;
    Stroke orginalStroke = g.getStroke();
    g.setStroke(MULTI_INSTANCE_STROKE);
    if (sequential) {
        g.draw(new Line2D.Double(lineX, lineY, lineX + rectangleWidth, lineY));
        g.draw(new Line2D.Double(lineX, lineY + rectangleHeight / 2, lineX + rectangleWidth, lineY + rectangleHeight / 2));
        g.draw(new Line2D.Double(lineX, lineY + rectangleHeight, lineX + rectangleWidth, lineY + rectangleHeight));
    } else {
        g.draw(new Line2D.Double(lineX, lineY, lineX, lineY + rectangleHeight));
        g.draw(new Line2D.Double(lineX + rectangleWidth / 2, lineY, lineX + rectangleWidth / 2, lineY + rectangleHeight));
        g.draw(new Line2D.Double(lineX + rectangleWidth, lineY, lineX + rectangleWidth, lineY + rectangleHeight));
    }
    g.setStroke(orginalStroke);
}
Also used : Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) Line2D(java.awt.geom.Line2D) Point(java.awt.Point) Paint(java.awt.Paint)

Example 48 with Stroke

use of java.awt.Stroke in project android_frameworks_base by ResurrectionRemix.

the class Paint_Delegate method nGetFillPath.

@LayoutlibDelegate
static /*package*/
boolean nGetFillPath(long native_object, long src, long dst) {
    Paint_Delegate paint = sManager.getDelegate(native_object);
    if (paint == null) {
        return false;
    }
    Path_Delegate srcPath = Path_Delegate.getDelegate(src);
    if (srcPath == null) {
        return true;
    }
    Path_Delegate dstPath = Path_Delegate.getDelegate(dst);
    if (dstPath == null) {
        return true;
    }
    Stroke stroke = paint.getJavaStroke();
    Shape strokeShape = stroke.createStrokedShape(srcPath.getJavaShape());
    dstPath.setJavaShape(strokeShape);
    // FIXME figure out the return value?
    return true;
}
Also used : Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) Shape(java.awt.Shape) LayoutlibDelegate(com.android.tools.layoutlib.annotations.LayoutlibDelegate)

Example 49 with Stroke

use of java.awt.Stroke in project ChatGameFontificator by GlitchCog.

the class ColorSwatch method paint.

@Override
public void paint(Graphics g) {
    super.paint(g);
    if (isSelected()) {
        Graphics2D g2d = (Graphics2D) g;
        g2d.setPaint(Color.BLACK);
        Stroke stroke = new BasicStroke(BORDER_THICKNESS, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f, new float[] { 3, 3, 3, 3 }, dashTimer.getOffset());
        g2d.setStroke(stroke);
        final int halfThickness = Math.max(1, BORDER_THICKNESS / 2);
        g2d.drawRect(halfThickness, halfThickness, getWidth() - BORDER_THICKNESS, getHeight() - BORDER_THICKNESS);
    }
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) Graphics2D(java.awt.Graphics2D)

Example 50 with Stroke

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

the class WPathGraphics method draw.

/**
     * Strokes the outline of a Shape using the settings of the current
     * graphics state.  The rendering attributes applied include the
     * clip, transform, paint or color, composite and stroke attributes.
     * @param s The shape to be drawn.
     * @see #setStroke
     * @see #setPaint
     * @see java.awt.Graphics#setColor
     * @see #transform
     * @see #setTransform
     * @see #clip
     * @see #setClip
     * @see #setComposite
     */
@Override
public void draw(Shape s) {
    Stroke stroke = getStroke();
    /* If the line being drawn is thinner than can be
         * rendered, then change the line width, stroke
         * the shape, and then set the line width back.
         * We can only do this for BasicStroke's.
         */
    if (stroke instanceof BasicStroke) {
        BasicStroke lineStroke;
        BasicStroke minLineStroke = null;
        float deviceLineWidth;
        float lineWidth;
        AffineTransform deviceTransform;
        Point2D.Float penSize;
        /* Get the requested line width in user space.
             */
        lineStroke = (BasicStroke) stroke;
        lineWidth = lineStroke.getLineWidth();
        penSize = new Point2D.Float(lineWidth, lineWidth);
        /* Compute the line width in device coordinates.
             * Work on a point in case there is asymetric scaling
             * between user and device space.
             * Take the absolute value in case there is negative
             * scaling in effect.
             */
        deviceTransform = getTransform();
        deviceTransform.deltaTransform(penSize, penSize);
        deviceLineWidth = Math.min(Math.abs(penSize.x), Math.abs(penSize.y));
        /* If the requested line is too thin then map our
             * minimum line width back to user space and set
             * a new BasicStroke.
             */
        if (deviceLineWidth < MIN_DEVICE_LINEWIDTH) {
            Point2D.Float minPenSize = new Point2D.Float(MIN_DEVICE_LINEWIDTH, MIN_DEVICE_LINEWIDTH);
            try {
                AffineTransform inverse;
                float minLineWidth;
                /* Convert the minimum line width from device
                     * space to user space.
                     */
                inverse = deviceTransform.createInverse();
                inverse.deltaTransform(minPenSize, minPenSize);
                minLineWidth = Math.max(Math.abs(minPenSize.x), Math.abs(minPenSize.y));
                /* Use all of the parameters from the current
                     * stroke but change the line width to our
                     * calculated minimum.
                     */
                minLineStroke = new BasicStroke(minLineWidth, lineStroke.getEndCap(), lineStroke.getLineJoin(), lineStroke.getMiterLimit(), lineStroke.getDashArray(), lineStroke.getDashPhase());
                setStroke(minLineStroke);
            } catch (NoninvertibleTransformException e) {
            /* If we can't invert the matrix there is something
                     * very wrong so don't worry about the minor matter
                     * of a minimum line width.
                     */
            }
        }
        super.draw(s);
        /* If we changed the stroke, put back the old
             * stroke in order to maintain a minimum line
             * width.
             */
        if (minLineStroke != null) {
            setStroke(lineStroke);
        }
    /* The stroke in effect was not a BasicStroke so we
         * will not try to enforce a minimum line width.
         */
    } else {
        super.draw(s);
    }
}
Also used : BasicStroke(java.awt.BasicStroke) NoninvertibleTransformException(java.awt.geom.NoninvertibleTransformException) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) Point2D(java.awt.geom.Point2D) AffineTransform(java.awt.geom.AffineTransform)

Aggregations

Stroke (java.awt.Stroke)83 BasicStroke (java.awt.BasicStroke)74 Paint (java.awt.Paint)36 Color (java.awt.Color)34 Graphics2D (java.awt.Graphics2D)30 Point (java.awt.Point)23 GradientPaint (java.awt.GradientPaint)11 Shape (java.awt.Shape)11 Line2D (java.awt.geom.Line2D)11 Point2D (java.awt.geom.Point2D)11 Ellipse2D (java.awt.geom.Ellipse2D)9 Rectangle (java.awt.Rectangle)8 RoundRectangle2D (java.awt.geom.RoundRectangle2D)7 LayoutlibDelegate (com.android.tools.layoutlib.annotations.LayoutlibDelegate)6 Font (java.awt.Font)6 RadialGradientPaint (java.awt.RadialGradientPaint)6 AffineTransform (java.awt.geom.AffineTransform)6 Arc2D (java.awt.geom.Arc2D)5 Rectangle2D (java.awt.geom.Rectangle2D)5 GeneralPath (java.awt.geom.GeneralPath)4