-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathindex.js
175 lines (138 loc) · 8.21 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
const bpmn = getCustomColorsBpmnDiagram();
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// default colors
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const bpmnVisualization = new bpmnvisu.BpmnVisualization({ container: 'bpmn-container-default' });
bpmnVisualization.load(bpmn);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// shared config
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class BpmnVisualizationCustomizedColors extends bpmnvisu.BpmnVisualization {
constructor(containerId) {
super({ container: containerId });
this.configureStyle();
}
configureStyle() {
// do nothing by default
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// custom default font color
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class BpmnVisualizationCustomDefaultFontColor extends BpmnVisualizationCustomizedColors {
configureStyle() {
const styleSheet = this.graph.getStylesheet(); // mxStylesheet parameter
const defaultFontColor = 'DeepPink';
// edge
styleSheet.getDefaultEdgeStyle()[StyleIdentifiers.STYLE_FONTCOLOR] = defaultFontColor;
// vertex
styleSheet.getDefaultVertexStyle()[StyleIdentifiers.STYLE_FONTCOLOR] = defaultFontColor;
}
}
const bpmnVisualizationCustomDefaultFontColor = new BpmnVisualizationCustomDefaultFontColor('bpmn-container-custom-font-color');
bpmnVisualizationCustomDefaultFontColor.load(bpmn);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// custom default fill and stroke colors
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class BpmnVisualizationCustomDefaultFillAndStrokeColors extends BpmnVisualizationCustomizedColors {
configureStyle() {
const styleSheet = this.graph.getStylesheet(); // mxStylesheet parameter
// edge
styleSheet.getDefaultEdgeStyle()[StyleIdentifiers.STYLE_STROKECOLOR] = 'Orange';
// vertex
const defaultVertexStyle = styleSheet.getDefaultVertexStyle();
defaultVertexStyle[StyleIdentifiers.STYLE_FILLCOLOR] = 'LemonChiffon';
defaultVertexStyle[StyleIdentifiers.STYLE_STROKECOLOR] = 'Orange';
}
}
const bpmnVisualizationCustomDefaultColors = new BpmnVisualizationCustomDefaultFillAndStrokeColors('bpmn-container-custom-default-colors');
bpmnVisualizationCustomDefaultColors.load(bpmn);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// custom colors for User Task
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class BpmnVisualizationCustomColorsUserTask extends BpmnVisualizationCustomizedColors {
configureStyle() {
const styleSheet = this.graph.getStylesheet(); // mxStylesheet parameter
const style = styleSheet.styles[bpmnvisu.ShapeBpmnElementKind.TASK_USER];
style[StyleIdentifiers.STYLE_FILLCOLOR] = '#adadec';
style[StyleIdentifiers.STYLE_STROKECOLOR] = 'DarkBlue';
}
}
const bpmnVisualizationCustomColorsUserTask = new BpmnVisualizationCustomColorsUserTask('bpmn-container-custom-colors-user-task');
bpmnVisualizationCustomColorsUserTask.load(bpmn);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// custom fill and stroke colors specific to Event elements
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// mxStylesheet parameter
const configureStyleOfEvents = styleSheet => {
const startEventStyle = styleSheet.styles[bpmnvisu.ShapeBpmnElementKind.EVENT_START];
startEventStyle[StyleIdentifiers.STYLE_FILLCOLOR] = '#d6eea5';
startEventStyle[StyleIdentifiers.STYLE_STROKECOLOR] = '#8dc125';
[bpmnvisu.ShapeBpmnElementKind.EVENT_INTERMEDIATE_CATCH, bpmnvisu.ShapeBpmnElementKind.EVENT_INTERMEDIATE_THROW].forEach(kind => {
const intermediateEventStyle = styleSheet.styles[kind];
intermediateEventStyle[StyleIdentifiers.STYLE_STROKECOLOR] = '#7307df';
intermediateEventStyle[StyleIdentifiers.STYLE_FILLCOLOR] = 'white'; // ensure reset if the style is redefined before
})
const boundaryEventStyle = styleSheet.styles[bpmnvisu.ShapeBpmnElementKind.EVENT_BOUNDARY];
boundaryEventStyle[StyleIdentifiers.STYLE_FILLCOLOR] = 'LightGoldenrodYellow';
boundaryEventStyle[StyleIdentifiers.STYLE_STROKECOLOR] = 'DarkOrange';
const endEventStyle = styleSheet.styles[bpmnvisu.ShapeBpmnElementKind.EVENT_END];
endEventStyle[StyleIdentifiers.STYLE_FILLCOLOR] = 'Pink';
endEventStyle[StyleIdentifiers.STYLE_STROKECOLOR] = 'FireBrick';
}
class BpmnVisualizationCustomEventColors extends BpmnVisualizationCustomizedColors {
configureStyle() {
configureStyleOfEvents(this.graph.getStylesheet());
}
}
const bpmnVisualizationEventCustomColors = new BpmnVisualizationCustomEventColors('bpmn-container-custom-events-colors');
bpmnVisualizationEventCustomColors.load(bpmn);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// custom fill and stroke colors depending on BPMN element kinds
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// mxStylesheet parameter
const configureStyleByKind = styleSheet => {
bpmnvisu.ShapeUtil.eventKinds().forEach(kind => {
const style = styleSheet.styles[kind];
style[StyleIdentifiers.STYLE_FILLCOLOR] = 'Pink';
style[StyleIdentifiers.STYLE_STROKECOLOR] = 'FireBrick';
});
bpmnvisu.ShapeUtil.taskKinds().forEach(kind => {
const style = styleSheet.styles[kind];
style[StyleIdentifiers.STYLE_GRADIENT_DIRECTION] = Directions.DIRECTION_EAST;
style[StyleIdentifiers.STYLE_GRADIENTCOLOR] = 'White';
style[StyleIdentifiers.STYLE_FILLCOLOR] = 'Lavender';
style[StyleIdentifiers.STYLE_STROKECOLOR] = 'DarkBlue';
});
bpmnvisu.ShapeUtil.gatewayKinds().forEach(kind => {
const style = styleSheet.styles[kind];
style[StyleIdentifiers.STYLE_FILLCOLOR] = 'LightGoldenrodYellow';
style[StyleIdentifiers.STYLE_STROKECOLOR] = 'DarkOrange';
});
const poolStyle = styleSheet.styles[bpmnvisu.ShapeBpmnElementKind.POOL];
poolStyle[StyleIdentifiers.STYLE_FILLCOLOR] = '#303742';
poolStyle[StyleIdentifiers.STYLE_GRADIENT_DIRECTION] = Directions.DIRECTION_SOUTH;
poolStyle[StyleIdentifiers.STYLE_GRADIENTCOLOR] = '#6b7cb4';
// for more details about font, see the custom-fonts example
poolStyle[StyleIdentifiers.STYLE_FONTCOLOR] = 'White';
poolStyle[StyleIdentifiers.STYLE_FONTSTYLE] = FontStyle.FONT_BOLD + FontStyle.FONT_ITALIC;
}
class BpmnVisualizationCustomColors extends BpmnVisualizationCustomizedColors {
configureStyle() {
configureStyleByKind(this.graph.getStylesheet());
}
}
const bpmnVisualizationCustomColors = new BpmnVisualizationCustomColors('bpmn-container-custom-colors');
bpmnVisualizationCustomColors.load(bpmn);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// custom fill and stroke colors depending on BPMN element kinds and specific styles for some elements
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
class BpmnVisualizationCustomColorsMixed extends BpmnVisualizationCustomizedColors {
configureStyle() {
const styleSheet = this.graph.getStylesheet();
configureStyleByKind(styleSheet);
configureStyleOfEvents(styleSheet);
}
}
const bpmnVisualizationCustomColorsMixed = new BpmnVisualizationCustomColorsMixed('bpmn-container-custom-colors-mixed');
bpmnVisualizationCustomColorsMixed.load(bpmn);