Search in sources :

Example 16 with Stroke

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

the class DefaultProcessDiagramCanvas method drawConnection.

public void drawConnection(int[] xPoints, int[] yPoints, boolean conditional, boolean isDefault, String connectionType, AssociationDirection associationDirection, boolean highLighted, double scaleFactor) {
    Paint originalPaint = g.getPaint();
    Stroke originalStroke = g.getStroke();
    g.setPaint(CONNECTION_COLOR);
    if (connectionType.equals("association")) {
        g.setStroke(ASSOCIATION_STROKE);
    } else if (highLighted) {
        g.setPaint(HIGHLIGHT_COLOR);
        g.setStroke(HIGHLIGHT_FLOW_STROKE);
    }
    for (int i = 1; i < xPoints.length; i++) {
        Integer sourceX = xPoints[i - 1];
        Integer sourceY = yPoints[i - 1];
        Integer targetX = xPoints[i];
        Integer targetY = yPoints[i];
        Line2D.Double line = new Line2D.Double(sourceX, sourceY, targetX, targetY);
        g.draw(line);
    }
    if (isDefault) {
        Line2D.Double line = new Line2D.Double(xPoints[0], yPoints[0], xPoints[1], yPoints[1]);
        drawDefaultSequenceFlowIndicator(line, scaleFactor);
    }
    if (conditional) {
        Line2D.Double line = new Line2D.Double(xPoints[0], yPoints[0], xPoints[1], yPoints[1]);
        drawConditionalSequenceFlowIndicator(line, scaleFactor);
    }
    if (associationDirection.equals(AssociationDirection.ONE) || associationDirection.equals(AssociationDirection.BOTH)) {
        Line2D.Double line = new Line2D.Double(xPoints[xPoints.length - 2], yPoints[xPoints.length - 2], xPoints[xPoints.length - 1], yPoints[xPoints.length - 1]);
        drawArrowHead(line, scaleFactor);
    }
    if (associationDirection.equals(AssociationDirection.BOTH)) {
        Line2D.Double line = new Line2D.Double(xPoints[1], yPoints[1], xPoints[0], yPoints[0]);
        drawArrowHead(line, scaleFactor);
    }
    g.setPaint(originalPaint);
    g.setStroke(originalStroke);
}
Also used : Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) Paint(java.awt.Paint) Line2D(java.awt.geom.Line2D) Point(java.awt.Point) Paint(java.awt.Paint)

Example 17 with Stroke

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

the class DefaultProcessDiagramCanvas method drawTextAnnotation.

public void drawTextAnnotation(String text, GraphicInfo graphicInfo) {
    int x = (int) graphicInfo.getX();
    int y = (int) graphicInfo.getY();
    int width = (int) graphicInfo.getWidth();
    int height = (int) graphicInfo.getHeight();
    Font originalFont = g.getFont();
    Stroke originalStroke = g.getStroke();
    g.setFont(ANNOTATION_FONT);
    Path2D path = new Path2D.Double();
    x += .5;
    int lineLength = 18;
    path.moveTo(x + lineLength, y);
    path.lineTo(x, y);
    path.lineTo(x, y + height);
    path.lineTo(x + lineLength, y + height);
    path.lineTo(x + lineLength, y + height - 1);
    path.lineTo(x + 1, y + height - 1);
    path.lineTo(x + 1, y + 1);
    path.lineTo(x + lineLength, y + 1);
    path.closePath();
    g.draw(path);
    int boxWidth = width - (2 * ANNOTATION_TEXT_PADDING);
    int boxHeight = height - (2 * ANNOTATION_TEXT_PADDING);
    int boxX = x + width / 2 - boxWidth / 2;
    int boxY = y + height / 2 - boxHeight / 2;
    if (text != null && text.isEmpty() == false) {
        drawMultilineAnnotationText(text, boxX, boxY, boxWidth, boxHeight);
    }
    // restore originals
    g.setFont(originalFont);
    g.setStroke(originalStroke);
}
Also used : Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) Path2D(java.awt.geom.Path2D) Point(java.awt.Point) Paint(java.awt.Paint) Font(java.awt.Font)

Example 18 with Stroke

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

the class DefaultProcessDiagramCanvas method drawParallelGateway.

public void drawParallelGateway(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();
    if (scaleFactor == 1.0) {
        // plus inside rhombus
        Stroke orginalStroke = g.getStroke();
        g.setStroke(GATEWAY_TYPE_STROKE);
        // horizontal
        Line2D.Double line = new Line2D.Double(x + 10, y + height / 2, x + width - 10, y + height / 2);
        g.draw(line);
        // vertical
        line = new Line2D.Double(x + width / 2, y + height - 10, x + width / 2, y + 10);
        g.draw(line);
        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 19 with Stroke

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

the class DefaultProcessDiagramCanvas method drawExclusiveGateway.

public void drawExclusiveGateway(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 quarterWidth = width / 4;
    int quarterHeight = height / 4;
    if (scaleFactor == 1.0) {
        // X inside rhombus
        Stroke orginalStroke = g.getStroke();
        g.setStroke(GATEWAY_TYPE_STROKE);
        Line2D.Double line = new Line2D.Double(x + quarterWidth + 3, y + quarterHeight + 3, x + 3 * quarterWidth - 3, y + 3 * quarterHeight - 3);
        g.draw(line);
        line = new Line2D.Double(x + quarterWidth + 3, y + 3 * quarterHeight - 3, x + 3 * quarterWidth - 3, y + quarterHeight + 3);
        g.draw(line);
        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 20 with Stroke

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

the class DefaultProcessDiagramCanvas method drawExpandedSubProcess.

public void drawExpandedSubProcess(String name, GraphicInfo graphicInfo, Boolean isTriggeredByEvent, double scaleFactor) {
    RoundRectangle2D rect = new RoundRectangle2D.Double(graphicInfo.getX(), graphicInfo.getY(), graphicInfo.getWidth(), graphicInfo.getHeight(), 8, 8);
    // Use different stroke (dashed)
    if (isTriggeredByEvent) {
        Stroke originalStroke = g.getStroke();
        g.setStroke(EVENT_SUBPROCESS_STROKE);
        g.draw(rect);
        g.setStroke(originalStroke);
    } else {
        Paint originalPaint = g.getPaint();
        g.setPaint(SUBPROCESS_BOX_COLOR);
        g.fill(rect);
        g.setPaint(SUBPROCESS_BORDER_COLOR);
        g.draw(rect);
        g.setPaint(originalPaint);
    }
    if (scaleFactor == 1.0 && name != null && !name.isEmpty()) {
        String text = fitTextToWidth(name, (int) graphicInfo.getWidth());
        g.drawString(text, (int) graphicInfo.getX() + 10, (int) graphicInfo.getY() + 15);
    }
}
Also used : Stroke(java.awt.Stroke) BasicStroke(java.awt.BasicStroke) RoundRectangle2D(java.awt.geom.RoundRectangle2D) Paint(java.awt.Paint) AttributedString(java.text.AttributedString)

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