Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/bpmn-support.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ The default rendering uses `white` as fill color and `black` as stroke color.
|Comments

|Abstract Task
|icon:flask[]
|Rounded corner and stroke color are subject to change
|icon:check-circle[]
|

|Service Task
|
|
|icon:flask[]
|Stroke color and icon are subject to change

|User Task
|
|
|icon:flask[]
|Stroke color and icon are subject to change
|===


Expand Down
2 changes: 2 additions & 0 deletions src/component/mxgraph/ShapeConfigurator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { MxGraphFactoryService } from '../../service/MxGraphFactoryService';
import { mxgraph } from 'ts-mxgraph';
import { ShapeBpmnElementKind } from '../../model/bpmn/shape/ShapeBpmnElementKind';
import { EndEventShape, StartEventShape } from './shape/event-shapes';
import { TaskShape } from './shape/task-shapes';

export default class ShapeConfigurator {
private mxClient: typeof mxgraph.mxClient = MxGraphFactoryService.getMxGraphProperty('mxClient');
Expand All @@ -31,6 +32,7 @@ export default class ShapeConfigurator {
private registerShapes(): void {
this.mxCellRenderer.registerShape(ShapeBpmnElementKind.EVENT_END, EndEventShape);
this.mxCellRenderer.registerShape(ShapeBpmnElementKind.EVENT_START, StartEventShape);
this.mxCellRenderer.registerShape(ShapeBpmnElementKind.TASK, TaskShape);
}

private initMxShapePrototype(isFF: boolean): void {
Expand Down
7 changes: 5 additions & 2 deletions src/component/mxgraph/StyleConfigurator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export default class StyleConfigurator {
constructor(private graph: mxgraph.mxGraph) {}

public configureStyles(): void {
this.mxConstants.RECTANGLE_ROUNDING_FACTOR = 0.1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 nice


this.configureDefaultVertexStyle();
this.configurePoolStyle();
this.configureLaneStyle();
Expand Down Expand Up @@ -125,8 +127,9 @@ export default class StyleConfigurator {
}

private configureTaskStyle(): void {
const style = this.mxUtils.clone(this.getStylesheet().getCellStyle(ShapeBpmnElementKind.TASK_USER), this.getDefaultVertexStyle());
style[this.mxConstants.STYLE_STROKECOLOR] = '#663399';
const style = this.cloneDefaultVertexStyle();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ I guess we will generalize styling for other tasks when implementing rendering for user or service task

Copy link
Contributor Author

@csouchet csouchet Apr 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I started the refactoring in the Service Task's PR #208 😉

style[this.mxConstants.STYLE_SHAPE] = ShapeBpmnElementKind.TASK;
style[this.mxConstants.STYLE_VERTICAL_ALIGN] = 'middle';
this.putCellStyle(ShapeBpmnElementKind.TASK, style);
}

Expand Down
31 changes: 31 additions & 0 deletions src/component/mxgraph/shape/task-shapes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* Copyright 2020 Bonitasoft S.A.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { MxGraphFactoryService } from '../../../service/MxGraphFactoryService';
import { mxgraph } from 'ts-mxgraph';
import { StyleConstant } from '../StyleConfigurator';

const mxRectangleShape: typeof mxgraph.mxRectangleShape = MxGraphFactoryService.getMxGraphProperty('mxRectangleShape');

export class TaskShape extends mxRectangleShape {
isRounded: boolean;

protected constructor(bounds: mxgraph.mxRectangle, fill: string, stroke: string, strokewidth: number = StyleConstant.STROKE_WIDTH_THIN) {
super(bounds, fill, stroke, strokewidth);

this.isRounded = true;
}
}
1 change: 1 addition & 0 deletions src/service/MxGraphFactoryService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ type MxGraphProperty =
| 'mxClient'
| 'mxConstants'
| 'mxEllipse'
| 'mxRectangleShape'
| 'mxGeometry'
| 'mxGraph'
| 'mxGraphModel'
Expand Down
9 changes: 5 additions & 4 deletions test/e2e/View.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('BPMN Visualization JS', () => {
<semantic:startEvent name="Timer Start Event" id="startEvent_2_timer">
<semantic:timerEventDefinition/>
</semantic:startEvent>
<semantic:task completionQuantity="1" isForCompensation="false" startQuantity="1" name="Task 1" id="_ec59e164-68b4-4f94-98de-ffb1c58a84af">
<semantic:task completionQuantity="1" isForCompensation="false" startQuantity="1" name="Task 1" id="task_1">
<semantic:incoming>_e16564d7-0c4c-413e-95f6-f668a3f851fb</semantic:incoming>
<semantic:outgoing>_d77dd5ec-e4e7-420e-bbe7-8ac9cd1df599</semantic:outgoing>
</semantic:task>
Expand All @@ -60,8 +60,8 @@ describe('BPMN Visualization JS', () => {
<semantic:incoming>_8e8fe679-eb3b-4c43-a4d6-891e7087ff80</semantic:incoming>
<semantic:terminateEventDefinition/>
</semantic:endEvent>
<semantic:sequenceFlow sourceRef="startEvent_1" targetRef="_ec59e164-68b4-4f94-98de-ffb1c58a84af" name="" id="_e16564d7-0c4c-413e-95f6-f668a3f851fb"/>
<semantic:sequenceFlow sourceRef="_ec59e164-68b4-4f94-98de-ffb1c58a84af" targetRef="_820c21c0-45f3-473b-813f-06381cc637cd" name="" id="_d77dd5ec-e4e7-420e-bbe7-8ac9cd1df599"/>
<semantic:sequenceFlow sourceRef="startEvent_1" targetRef="task_1" name="" id="_e16564d7-0c4c-413e-95f6-f668a3f851fb"/>
<semantic:sequenceFlow sourceRef="task_1" targetRef="_820c21c0-45f3-473b-813f-06381cc637cd" name="" id="_d77dd5ec-e4e7-420e-bbe7-8ac9cd1df599"/>
<semantic:sequenceFlow sourceRef="_820c21c0-45f3-473b-813f-06381cc637cd" targetRef="_e70a6fcb-913c-4a7b-a65d-e83adc73d69c" name="" id="_2aa47410-1b0e-4f8b-ad54-d6f798080cb4"/>
<semantic:sequenceFlow sourceRef="_e70a6fcb-913c-4a7b-a65d-e83adc73d69c" targetRef="endEvent_1" name="" id="_8e8fe679-eb3b-4c43-a4d6-891e7087ff80"/>
</semantic:process>
Expand All @@ -76,7 +76,7 @@ describe('BPMN Visualization JS', () => {
<bpmndi:BPMNShape bpmnElement="startEvent_2_timer" id="shape_startEvent_2_timer">
<dc:Bounds height="30.0" width="30.0" x="186.0" y="536.0"/>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="_ec59e164-68b4-4f94-98de-ffb1c58a84af" id="S1373649849859__ec59e164-68b4-4f94-98de-ffb1c58a84af">
<bpmndi:BPMNShape bpmnElement="task_1" id="shape_task_1">
<dc:Bounds height="68.0" width="83.0" x="258.0" y="317.0"/>
<bpmndi:BPMNLabel labelStyle="LS1373649849858">
<dc:Bounds height="12.804751171875008" width="72.48293963254594" x="263.3333333333333" y="344.5818763825664"/>
Expand Down Expand Up @@ -169,6 +169,7 @@ describe('BPMN Visualization JS', () => {
expectModelContainsBpmnEvent('startEvent_1', ShapeBpmnElementKind.EVENT_START, ShapeBpmnEventKind.NONE);
expectModelContainsBpmnEvent('startEvent_2_timer', ShapeBpmnElementKind.EVENT_START, ShapeBpmnEventKind.TIMER);
expectModelContainsBpmnEvent('endEvent_1', ShapeBpmnElementKind.EVENT_END, ShapeBpmnEventKind.TERMINATE);
expectModelContainsCell('task_1', ShapeBpmnElementKind.TASK);
});

function expectModelContainsCellWithGeometry(cellId: string, parentId: string, geometry: mxgraph.mxGeometry): void {
Expand Down