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);
}
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);
}
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);
}
}
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);
}
}
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);
}
}
Aggregations