Search in sources :

Example 11 with Stroke

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

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 12 with Stroke

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

the class DefaultProcessDiagramCanvas method drawHighLight.

public void drawHighLight(int x, int y, int width, int height) {
    Paint originalPaint = g.getPaint();
    Stroke originalStroke = g.getStroke();
    g.setPaint(HIGHLIGHT_COLOR);
    g.setStroke(THICK_TASK_BORDER_STROKE);
    RoundRectangle2D rect = new RoundRectangle2D.Double(x, y, width, height, 20, 20);
    g.draw(rect);
    g.setPaint(originalPaint);
    g.setStroke(originalStroke);
}
Also used : Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) RoundRectangle2D(java.awt.geom.RoundRectangle2D) Paint(java.awt.Paint)

Example 13 with Stroke

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

the class DefaultProcessDiagramCanvas method drawTask.

protected void drawTask(String name, GraphicInfo graphicInfo, boolean thickBorder) {
    Paint originalPaint = g.getPaint();
    int x = (int) graphicInfo.getX();
    int y = (int) graphicInfo.getY();
    int width = (int) graphicInfo.getWidth();
    int height = (int) graphicInfo.getHeight();
    // Create a new gradient paint for every task box, gradient depends on x and y and is not relative
    g.setPaint(TASK_BOX_COLOR);
    int arcR = 6;
    if (thickBorder)
        arcR = 3;
    // shape
    RoundRectangle2D rect = new RoundRectangle2D.Double(x, y, width, height, arcR, arcR);
    g.fill(rect);
    g.setPaint(TASK_BORDER_COLOR);
    if (thickBorder) {
        Stroke originalStroke = g.getStroke();
        g.setStroke(THICK_TASK_BORDER_STROKE);
        g.draw(rect);
        g.setStroke(originalStroke);
    } else {
        g.draw(rect);
    }
    g.setPaint(originalPaint);
    // text
    if (name != null && name.length() > 0) {
        int boxWidth = width - (2 * TEXT_PADDING);
        int boxHeight = height - 16 - ICON_PADDING - ICON_PADDING - MARKER_WIDTH - 2 - 2;
        int boxX = x + width / 2 - boxWidth / 2;
        int boxY = y + height / 2 - boxHeight / 2 + ICON_PADDING + ICON_PADDING - 2 - 2;
        drawMultilineCentredText(name, boxX, boxY, boxWidth, boxHeight);
    }
}
Also used : Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) RoundRectangle2D(java.awt.geom.RoundRectangle2D) Paint(java.awt.Paint) Point(java.awt.Point) Paint(java.awt.Paint)

Example 14 with Stroke

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

the class DefaultProcessDiagramCanvas method drawCatchingEvent.

public void drawCatchingEvent(GraphicInfo graphicInfo, boolean isInterrupting, BufferedImage image, String eventType, double scaleFactor) {
    // event circles
    Ellipse2D outerCircle = new Ellipse2D.Double(graphicInfo.getX(), graphicInfo.getY(), graphicInfo.getWidth(), graphicInfo.getHeight());
    int innerCircleSize = (int) (4 / scaleFactor);
    if (innerCircleSize == 0) {
        innerCircleSize = 1;
    }
    int innerCircleX = (int) graphicInfo.getX() + innerCircleSize;
    int innerCircleY = (int) graphicInfo.getY() + innerCircleSize;
    int innerCircleWidth = (int) graphicInfo.getWidth() - (2 * innerCircleSize);
    int innerCircleHeight = (int) graphicInfo.getHeight() - (2 * innerCircleSize);
    Ellipse2D innerCircle = new Ellipse2D.Double(innerCircleX, innerCircleY, innerCircleWidth, innerCircleHeight);
    Paint originalPaint = g.getPaint();
    Stroke originalStroke = g.getStroke();
    g.setPaint(EVENT_COLOR);
    g.fill(outerCircle);
    g.setPaint(EVENT_BORDER_COLOR);
    if (isInterrupting == false)
        g.setStroke(NON_INTERRUPTING_EVENT_STROKE);
    g.draw(outerCircle);
    g.setStroke(originalStroke);
    g.setPaint(originalPaint);
    g.draw(innerCircle);
    if (image != null) {
        // calculate coordinates to center image
        int imageX = (int) (graphicInfo.getX() + (graphicInfo.getWidth() / 2) - (image.getWidth() / 2 * scaleFactor));
        int imageY = (int) (graphicInfo.getY() + (graphicInfo.getHeight() / 2) - (image.getHeight() / 2 * scaleFactor));
        if (scaleFactor == 1.0 && "timer".equals(eventType)) {
            // move image one pixel to center timer image
            imageX++;
            imageY++;
        }
        g.drawImage(image, imageX, imageY, (int) (image.getWidth() / scaleFactor), (int) (image.getHeight() / scaleFactor), null);
    }
}
Also used : Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) Paint(java.awt.Paint) Ellipse2D(java.awt.geom.Ellipse2D) Point(java.awt.Point) Paint(java.awt.Paint)

Example 15 with Stroke

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

the class DefaultProcessDiagramCanvas method drawNoneEndEvent.

public void drawNoneEndEvent(GraphicInfo graphicInfo, double scaleFactor) {
    Paint originalPaint = g.getPaint();
    Stroke originalStroke = g.getStroke();
    g.setPaint(EVENT_COLOR);
    Ellipse2D circle = new Ellipse2D.Double(graphicInfo.getX(), graphicInfo.getY(), graphicInfo.getWidth(), graphicInfo.getHeight());
    g.fill(circle);
    g.setPaint(EVENT_BORDER_COLOR);
    if (scaleFactor == 1.0) {
        g.setStroke(END_EVENT_STROKE);
    } else {
        g.setStroke(new BasicStroke(2.0f));
    }
    g.draw(circle);
    g.setStroke(originalStroke);
    g.setPaint(originalPaint);
}
Also used : BasicStroke(java.awt.BasicStroke) Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) Paint(java.awt.Paint) Ellipse2D(java.awt.geom.Ellipse2D)

Aggregations

Stroke (java.awt.Stroke)43 BasicStroke (java.awt.BasicStroke)41 Paint (java.awt.Paint)18 Point (java.awt.Point)11 Shape (java.awt.Shape)11 Color (java.awt.Color)7 Line2D (java.awt.geom.Line2D)7 LayoutlibDelegate (com.android.tools.layoutlib.annotations.LayoutlibDelegate)6 Graphics2D (java.awt.Graphics2D)6 AffineTransform (java.awt.geom.AffineTransform)5 Ellipse2D (java.awt.geom.Ellipse2D)4 Point2D (java.awt.geom.Point2D)4 Font (java.awt.Font)3 GradientPaint (java.awt.GradientPaint)3 Rectangle (java.awt.Rectangle)3 RoundRectangle2D (java.awt.geom.RoundRectangle2D)3 Dimension (java.awt.Dimension)2 AxisChart (org.jCharts.axisChart.AxisChart)2 AxisChartDataSet (org.jCharts.chartData.AxisChartDataSet)2 DataSeries (org.jCharts.chartData.DataSeries)2