眼前多少难甘事,自古男儿当自强。这篇文章主要讲述flowable 设置流程跟踪高亮线的颜色相关的知识,希望能为你提供帮助。
背景:在实际情况下,很多人对这个红色的高亮有意见,所以这里我把我的修改颜色的代码分享出来效果如下:
文章图片
1、定义 MyDefaultProcessDiagramCanvas
public class MyDefaultProcessDiagramCanvas extends DefaultProcessDiagramCanvas
//设置高亮线的颜色这里我设置成绿色
protected static Color HIGHLIGHT_SEQUENCEFLOW_COLOR = Color.GREEN;
public MyDefaultProcessDiagramCanvas(int width, int height, int minX, int minY, String imageType, String activityFontName, String labelFontName, String annotationFontName, ClassLoader customClassLoader)
super(width, height, minX, minY, imageType, activityFontName, labelFontName, annotationFontName, customClassLoader);
public MyDefaultProcessDiagramCanvas(int width, int height, int minX, int minY, String imageType)
super(width, height, minX, minY, imageType);
/**
* 画线颜色设置
*/
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_SEQUENCEFLOW_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 == AssociationDirection.ONE || associationDirection == 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 == 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);
/**
* 高亮节点设置
*/
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);
2、定义一个 MyDefaultProcessDiagramGenerator
这里只是修改一下名称 把
DefaultProcessDiagramGenerator的代码搬进去即可然后把
DefaultProcessDiagramCanvas 改成 MyDefaultProcessDiagramCanvas 即可
public class MyDefaultProcessDiagramGenerator implements ProcessDiagramGenerator
3、生成图片
@Service
public class FlowProcessDiagramGenerator extends MyDefaultProcessDiagramGenerator
private static final String IMAGE_TYPE = "png";
@Value("$flowable.activityFontName")
private String activityFontName;
@Value("$flowable.labelFontName")
private String labelFontName;
@Value("$flowable.annotationFontName")
private String annotationFontName;
/**
* 生成图片流
*
* @param bpmnModel模型
* @param highLightedActivities 活动节点
* @param highLightedFlows高亮线
* @return
*/
public InputStream generateDiagram(BpmnModel bpmnModel, List< String> highLightedActivities, List< String> highLightedFlows)
return generateDiagram(bpmnModel, IMAGE_TYPE, highLightedActivities,
highLightedFlows, activityFontName, labelFontName, annotationFontName,
null, 1.0, true);
【flowable 设置流程跟踪高亮线的颜色】
推荐阅读
- 14.flowable 已办任务列表查询
- #yyds干货盘点#算法给小码农链式二叉树-----一根草可斩星辰
- JDBC与数据库连接池#yyds干货盘点#
- flowable 任务监听器
- flowable中动态调用dubbo接口
- #yyds干货盘点#equals方法通用约定
- Springboot自动装配详解#yyds干货盘点#
- flowable设计器自定义自己的人员选择器
- #yyds干货盘点# Java参数传递的前世今生