Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEAT] Render all Cancel Events #789

Merged
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 @@ -318,13 +318,13 @@ The event definition can be defined on the event or on the definitions.
|icon:check-circle-o[]
|The stroke & icon width may be adjusted

|Cancel Interrupting Boundary Event
|
|

|Conditional Interrupting Boundary Event
|
|

|Cancel Interrupting Boundary Event
|icon:check-circle-o[]
|The stroke & icon width may be adjusted
|===


Expand Down Expand Up @@ -385,8 +385,8 @@ The event definition can be defined on the event or on the definitions.
|The icon width may be adjusted

|Cancel End Event
|
|
|icon:check-circle-o[]
|The icon width may be adjusted
|===


Expand Down
11 changes: 7 additions & 4 deletions src/component/mxgraph/shape/event-shapes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ abstract class EventShape extends mxEllipse {
ShapeBpmnEventKind.COMPENSATION,
(paintParameter: PaintParameter) => this.iconPainter.paintCompensationIcon({ ...paintParameter, ratioFromParent: 0.7, icon: { ...paintParameter.icon, strokeWidth: 1.5 } }),
],
[
ShapeBpmnEventKind.CANCEL,
(paintParameter: PaintParameter) =>
this.iconPainter.paintXCrossIcon({ ...paintParameter, ratioFromParent: 0.39, setIconOrigin: (canvas: BpmnCanvas) => canvas.setIconOriginToShapeTopLeftProportionally(9) }),
],
]);

protected withFilledIcon = false;
Expand All @@ -72,12 +77,10 @@ abstract class EventShape extends mxEllipse {
}

// This will be removed after implementation of all supported events
// eslint-disable-next-line @typescript-eslint/no-unused-vars
private markNonFullyRenderedEvents(c: mxAbstractCanvas2D): void {
const eventKind = StyleUtils.getBpmnEventKind(this.style);
if (eventKind == ShapeBpmnEventKind.CANCEL) {
c.setFillColor('deeppink');
c.setFillAlpha(0.3);
} else if (eventKind == ShapeBpmnEventKind.CONDITIONAL) {
if (eventKind == ShapeBpmnEventKind.CONDITIONAL) {
c.setFillColor('chartreuse');
c.setFillAlpha(0.3);
}
Expand Down
6 changes: 5 additions & 1 deletion src/component/mxgraph/shape/gateway-shapes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ export class ExclusiveGatewayShape extends GatewayShape {
}

protected paintInnerShape(paintParameter: PaintParameter): void {
this.iconPainter.paintXCrossIcon({ ...paintParameter, setIconOrigin: (canvas: BpmnCanvas) => canvas.setIconOriginToShapeTopLeftProportionally(4) });
this.iconPainter.paintXCrossIcon({
...paintParameter,
icon: { ...paintParameter.icon, isFilled: true },
Copy link
Member

Choose a reason for hiding this comment

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

👍

setIconOrigin: (canvas: BpmnCanvas) => canvas.setIconOriginToShapeTopLeftProportionally(4),
});
}
}

Expand Down
42 changes: 21 additions & 21 deletions src/component/mxgraph/shape/render/IconPainter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,32 @@ export default class IconPainter {
canvas.fillAndStroke();
}

private static drawCrossIcon(canvas: BpmnCanvas): void {
canvas.begin();
canvas.moveTo(0.38, 0);
canvas.lineTo(0.62, 0);
canvas.lineTo(0.62, 0.38);
canvas.lineTo(1, 0.38);
canvas.lineTo(1, 0.62);
canvas.lineTo(0.62, 0.62);
canvas.lineTo(0.62, 1);
canvas.lineTo(0.38, 1);
canvas.lineTo(0.38, 0.62);
canvas.lineTo(0, 0.62);
canvas.lineTo(0, 0.38);
canvas.lineTo(0.38, 0.38);
canvas.close();
}

/**
* This icon is used by `exclusive gateway`.
*/
public paintXCrossIcon({ c, ratioFromParent, setIconOrigin, shape, icon }: PaintParameter): void {
const canvas = this.newBpmnCanvas({ c, ratioFromParent, setIconOrigin, shape, icon: { ...icon, isFilled: true } }, { height: 0.5, width: 0.5 });
public paintXCrossIcon(paintParameter: PaintParameter): void {
const canvas = this.newBpmnCanvas(paintParameter, { height: 0.5, width: 0.5 });

IconPainter.drawCrossIcon(canvas);
const rotationCenterX = shape.w / 4;
Copy link
Member

Choose a reason for hiding this comment

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

If someone change the ratioFromParent (the size of the icon from the size of the shape), we always want to rotate the icon with the same value.

Can you revert this change, please ?

Copy link
Member

Choose a reason for hiding this comment

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

Forget my previous comment.
I'm not sur to understand how it's works, but everthing is OK.

Thank you very much for having integrate my comments 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's the calculation of coordinates of rotation center.
Previously it was hardcoded to 1/4th cause of initial size of icon (half-size of shape) => center of rotation was on 1/4th of shape, but must be proportional to the ratioFromParent.
BTW, the default ratioFromParent is equals to 0.25 ;)

const rotationCenterY = shape.h / 4;
const rotationCenterX = paintParameter.shape.w * paintParameter.ratioFromParent;
const rotationCenterY = paintParameter.shape.h * paintParameter.ratioFromParent;
canvas.rotate(45, false, false, rotationCenterX, rotationCenterY);
canvas.fillAndStroke();
}
Expand All @@ -334,23 +351,6 @@ export default class IconPainter {
canvas.fillAndStroke();
}

private static drawCrossIcon(canvas: BpmnCanvas): void {
canvas.begin();
canvas.moveTo(0.38, 0);
canvas.lineTo(0.62, 0);
canvas.lineTo(0.62, 0.38);
canvas.lineTo(1, 0.38);
canvas.lineTo(1, 0.62);
canvas.lineTo(0.62, 0.62);
canvas.lineTo(0.62, 1);
canvas.lineTo(0.38, 1);
canvas.lineTo(0.38, 0.62);
canvas.lineTo(0, 0.62);
canvas.lineTo(0, 0.38);
canvas.lineTo(0.38, 0.38);
canvas.close();
}

/**
* This icon is used by `user task`.
*/
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.