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

refactor!: rename values in ShapeBpmnMarkerKind #3147

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
29 changes: 11 additions & 18 deletions src/component/mxgraph/shape/activity-shapes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ export abstract class BaseActivityShape extends mxRectangleShape {
// The actual value is injected at runtime by BpmnCellRenderer
protected iconPainter: IconPainter = undefined;

private markerPainterFunctions = new Map<ShapeBpmnMarkerKind, (paintParameter: PaintParameter) => void>([
[ShapeBpmnMarkerKind.EXPAND, (paintParameter: PaintParameter) => this.iconPainter.paintExpandIcon(paintParameter)],
[ShapeBpmnMarkerKind.LOOP, (paintParameter: PaintParameter) => this.iconPainter.paintLoopIcon(paintParameter)],
[ShapeBpmnMarkerKind.MULTI_INSTANCE_PARALLEL, (paintParameter: PaintParameter) => this.iconPainter.paintParallelMultiInstanceIcon(paintParameter)],
[ShapeBpmnMarkerKind.MULTI_INSTANCE_SEQUENTIAL, (paintParameter: PaintParameter) => this.iconPainter.paintSequentialMultiInstanceIcon(paintParameter)],
]);

constructor() {
super(undefined, undefined, undefined); // the configuration is passed with the styles at runtime
}
Expand All @@ -64,24 +71,10 @@ export abstract class BaseActivityShape extends mxRectangleShape {
setIconOriginFunct: getMarkerIconOriginFunction(orderedMarkers.length, index + 1),
};
paintParameter.canvas.save(); // ensure we can later restore the configuration
switch (marker) {
case ShapeBpmnMarkerKind.LOOP: {
this.iconPainter.paintLoopIcon(paintParameter);
break;
}
case ShapeBpmnMarkerKind.MULTI_INSTANCE_SEQUENTIAL: {
this.iconPainter.paintSequentialMultiInstanceIcon(paintParameter);
break;
}
case ShapeBpmnMarkerKind.MULTI_INSTANCE_PARALLEL: {
this.iconPainter.paintParallelMultiInstanceIcon(paintParameter);
break;
}
case ShapeBpmnMarkerKind.EXPAND: {
this.iconPainter.paintExpandIcon(paintParameter);
break;
}
}

// Paint the marker
this.markerPainterFunctions.get(marker as ShapeBpmnMarkerKind)?.(paintParameter);

// Restore original configuration to avoid side effects if the iconPainter changed the canvas configuration (colors, ....)
paintParameter.canvas.restore();
}
Expand Down
4 changes: 2 additions & 2 deletions src/model/bpmn/internal/shape/kinds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ export enum ShapeBpmnMarkerKind {
COMPENSATION = 'compensation',
EXPAND = 'expand',
LOOP = 'loop',
MULTI_INSTANCE_PARALLEL = 'parallel multi instance',
MULTI_INSTANCE_SEQUENTIAL = 'sequential multi instance',
MULTI_INSTANCE_PARALLEL = 'multi-parallel',
MULTI_INSTANCE_SEQUENTIAL = 'multi-sequential',
}

/**
Expand Down