Skip to content

Commit 9a4f830

Browse files
committed
Add Task final render
1 parent 49f21e6 commit 9a4f830

File tree

4 files changed

+39
-2
lines changed

4 files changed

+39
-2
lines changed

src/component/mxgraph/ShapeConfigurator.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { MxGraphFactoryService } from '../../service/MxGraphFactoryService';
1717
import { mxgraph } from 'ts-mxgraph';
1818
import { ShapeBpmnElementKind } from '../../model/bpmn/shape/ShapeBpmnElementKind';
1919
import { EndEventShape, StartEventShape } from './shape/event-shapes';
20+
import { TaskShape } from './shape/task-shapes';
2021

2122
export default class ShapeConfigurator {
2223
private mxClient: typeof mxgraph.mxClient = MxGraphFactoryService.getMxGraphProperty('mxClient');
@@ -31,6 +32,7 @@ export default class ShapeConfigurator {
3132
private registerShapes(): void {
3233
this.mxCellRenderer.registerShape(ShapeBpmnElementKind.EVENT_END, EndEventShape);
3334
this.mxCellRenderer.registerShape(ShapeBpmnElementKind.EVENT_START, StartEventShape);
35+
this.mxCellRenderer.registerShape(ShapeBpmnElementKind.TASK, TaskShape);
3436
}
3537

3638
private initMxShapePrototype(isFF: boolean): void {

src/component/mxgraph/StyleConfigurator.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,9 @@ export default class StyleConfigurator {
125125
}
126126

127127
private configureTaskStyle(): void {
128-
const style = this.mxUtils.clone(this.getStylesheet().getCellStyle(ShapeBpmnElementKind.TASK_USER), this.getDefaultVertexStyle());
129-
style[this.mxConstants.STYLE_STROKECOLOR] = '#663399';
128+
const style = this.cloneDefaultVertexStyle();
129+
style[this.mxConstants.STYLE_SHAPE] = ShapeBpmnElementKind.TASK;
130+
style[this.mxConstants.STYLE_VERTICAL_ALIGN] = 'middle';
130131
this.putCellStyle(ShapeBpmnElementKind.TASK, style);
131132
}
132133

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
* Copyright 2020 Bonitasoft S.A.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import { MxGraphFactoryService } from '../../../service/MxGraphFactoryService';
18+
import { mxgraph } from 'ts-mxgraph';
19+
import { StyleConstant } from '../StyleConfigurator';
20+
21+
const mxRectangleShape: typeof mxgraph.mxRectangleShape = MxGraphFactoryService.getMxGraphProperty('mxRectangleShape');
22+
const mxUtils: typeof mxgraph.mxUtils = MxGraphFactoryService.getMxGraphProperty('mxUtils');
23+
const mxConstants: typeof mxgraph.mxConstants = MxGraphFactoryService.getMxGraphProperty('mxConstants');
24+
25+
export class TaskShape extends mxRectangleShape {
26+
isRounded: boolean;
27+
28+
protected constructor(bounds: mxgraph.mxRectangle, fill: string, stroke: string, strokewidth: number = StyleConstant.STROKE_WIDTH_THIN) {
29+
super(bounds, fill, stroke, strokewidth);
30+
31+
this.isRounded = true;
32+
}
33+
}

src/service/MxGraphFactoryService.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ type MxGraphProperty =
2020
| 'mxClient'
2121
| 'mxConstants'
2222
| 'mxEllipse'
23+
| 'mxRectangleShape'
2324
| 'mxGeometry'
2425
| 'mxGraph'
2526
| 'mxGraphModel'

0 commit comments

Comments
 (0)