Skip to content

Commit

Permalink
EXTRA refactor event icon management as for activity marker (no defau…
Browse files Browse the repository at this point in the history
…lt function)
  • Loading branch information
tbouffard committed Mar 6, 2024
1 parent d9ef2b6 commit baeb659
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/component/mxgraph/shape/activity-shapes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ export abstract class BaseActivityShape extends mxRectangleShape {
};
paintParameter.canvas.save(); // ensure we can later restore the configuration

// inspired from event-shapes that could be updated to not used "IconPainter.emptyIcon" and not called the function if it is not defined
// refactoring: management of the painter function --> move from "switch" to "map"
// It is inspired from event-shapes
const markerPainter = this.iconPainters.get(marker as ShapeBpmnMarkerKind);
markerPainter?.(paintParameter);

Expand Down
8 changes: 4 additions & 4 deletions src/component/mxgraph/shape/event-shapes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,10 @@ export class EventShape extends mxgraph.mxEllipse {
}

private paintInnerShape(paintParameter: PaintParameter): void {
const paintIcon =
this.iconPainters.get(mxUtils.getValue(this.style, BpmnStyleIdentifier.EVENT_DEFINITION_KIND, ShapeBpmnEventDefinitionKind.NONE)) ??
(() => this.iconPainter.paintEmptyIcon());
paintIcon(paintParameter);
// REFACTOR proceed with the same pattern as for the activity markers
// No need to provide a default function calling "IconPainter.emptyIcon". Do not call the undefined function returned by the Map when there is no entry for the event definition kind.
const paintIcon = this.iconPainters.get(mxUtils.getValue(this.style, BpmnStyleIdentifier.EVENT_DEFINITION_KIND, ShapeBpmnEventDefinitionKind.NONE));
paintIcon?.(paintParameter);
}
}

Expand Down

0 comments on commit baeb659

Please sign in to comment.