Skip to content

Commit

Permalink
iconPainter corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
aibcmars committed Oct 21, 2020
1 parent 7fbc4fb commit df29611
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 40 deletions.
10 changes: 1 addition & 9 deletions src/component/mxgraph/shape/event-shapes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,7 @@ abstract class EventShape extends mxEllipse {
[
ShapeBpmnEventKind.CANCEL,
(paintParameter: PaintParameter) =>
this.iconPainter.paintCancelCrossIcon({
...paintParameter,
setIconOrigin: (canvas: BpmnCanvas) => canvas.setIconOriginToShapeTopLeft(2, 8),
ratioFromParent: 0.445,
icon: {
...paintParameter.icon,
strokeWidth: StyleDefault.STROKE_WIDTH_THIN.valueOf(),
},
}),
this.iconPainter.paintXCrossIcon({ ...paintParameter, ratioFromParent: 0.39, setIconOrigin: (canvas: BpmnCanvas) => canvas.setIconOriginToShapeTopLeftProportionally(9) }),
],
]);

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

/**
* This icon is used by `cancel events`.
*/
public paintCancelCrossIcon({ c, ratioFromParent, setIconOrigin, shape, icon }: PaintParameter): void {
const canvas = this.newBpmnCanvas({ c, ratioFromParent, setIconOrigin, shape, icon }, { height: 0.5, width: 0.5 });

IconPainter.drawCrossIcon(canvas, 0.09, true);
const rotationCenterX = shape.w / 4;
const rotationCenterY = shape.h / 4;
canvas.rotate(45, false, false, rotationCenterX, rotationCenterY);
canvas.fillAndStroke();
}

private static drawCrossIcon(canvas: BpmnCanvas, thickness: number, roundedEdge: boolean): void {
private static drawCrossIcon(canvas: BpmnCanvas): void {
canvas.begin();
canvas.moveTo(0.5 - thickness, 0);
roundedEdge ? canvas.arcTo(0.5, 0.5, 0, 0, 1, 0.5 + thickness, 0) : canvas.lineTo(0.5 + thickness, 0);
canvas.lineTo(0.5 + thickness, 0.5 - thickness);
canvas.lineTo(1, 0.5 - thickness);
roundedEdge ? canvas.arcTo(0.5, 0.5, 0, 0, 1, 1, 0.5 + thickness) : canvas.lineTo(1, 0.5 + thickness);
canvas.lineTo(0.5 + thickness, 0.5 + thickness);
canvas.lineTo(0.5 + thickness, 1);
roundedEdge ? canvas.arcTo(0.5, 0.5, 0, 0, 1, 0.5 - thickness, 1) : canvas.lineTo(0.5 - thickness, 1);
canvas.lineTo(0.5 - thickness, 0.5 + thickness);
canvas.lineTo(0, 0.5 + thickness);
roundedEdge ? canvas.arcTo(0.5, 0.5, 0, 0, 1, 0, 0.5 - thickness) : canvas.lineTo(0, 0.5 - thickness);
canvas.lineTo(0.5 - thickness, 0.5 - thickness);
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 });
const canvas = this.newBpmnCanvas({ c, ratioFromParent, setIconOrigin, shape, icon: { ...icon } }, { height: 0.5, width: 0.5 });

IconPainter.drawCrossIcon(canvas, 0.12, false);
const rotationCenterX = shape.w / 4;
const rotationCenterY = shape.h / 4;
IconPainter.drawCrossIcon(canvas);
const rotationCenterX = shape.w * ratioFromParent;
const rotationCenterY = shape.h * ratioFromParent;
canvas.rotate(45, false, false, rotationCenterX, rotationCenterY);
canvas.fillAndStroke();
}
Expand All @@ -360,7 +347,7 @@ export default class IconPainter {
public paintPlusCrossIcon({ 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 });

IconPainter.drawCrossIcon(canvas, 0.12, false);
IconPainter.drawCrossIcon(canvas);
canvas.fillAndStroke();
}

Expand Down

0 comments on commit df29611

Please sign in to comment.