背景:在實際情況下,很多人對這個紅色的高亮有意見,所以這里我把我的修改顏色的代碼分享出來,希望對大家有幫助。(如果有問題可以加QQ群:633168411 里面很多高手,人也都非常善良)
效果如下:
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 设置流程跟踪高亮线的颜色的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。