diff --git a/dev/ts/shared/main.ts b/dev/ts/shared/main.ts index 8af52ecff2..2987f82d82 100644 --- a/dev/ts/shared/main.ts +++ b/dev/ts/shared/main.ts @@ -244,9 +244,9 @@ function getRendererOptionsFromParameters(config: BpmnVisualizationDemoConfigura // Mapping between query parameter names and RendererOptions boolean properties const rendererParameterMappings: Record> = { 'renderer.ignore.bpmn.colors': 'ignoreBpmnColors', - 'renderer.ignore.label.style': 'ignoreBpmnLabelStyles', - 'renderer.ignore.activity.label.bounds': 'ignoreBpmnActivityLabelBounds', - 'renderer.ignore.task.label.bounds': 'ignoreBpmnTaskLabelBounds', + 'renderer.ignore.label.style': 'ignoreLabelStyles', + 'renderer.ignore.activity.label.bounds': 'ignoreActivityLabelBounds', + 'renderer.ignore.task.label.bounds': 'ignoreTaskLabelBounds', }; // Process renderer parameters diff --git a/src/component/mxgraph/BpmnRenderer.ts b/src/component/mxgraph/BpmnRenderer.ts index 51ae8ceafc..796b39f933 100644 --- a/src/component/mxgraph/BpmnRenderer.ts +++ b/src/component/mxgraph/BpmnRenderer.ts @@ -34,8 +34,8 @@ import StyleComputer from './renderer/StyleComputer'; * @internal */ export class BpmnRenderer { - private readonly ignoreBpmnActivityLabelBounds: boolean; - private readonly ignoreBpmnTaskLabelBounds: boolean; + private readonly ignoreActivityLabelBounds: boolean; + private readonly ignoreTaskLabelBounds: boolean; constructor( readonly graph: BpmnGraph, @@ -43,8 +43,8 @@ export class BpmnRenderer { readonly styleComputer: StyleComputer, rendererOptions: RendererOptions, ) { - this.ignoreBpmnActivityLabelBounds = rendererOptions?.ignoreBpmnActivityLabelBounds ?? false; - this.ignoreBpmnTaskLabelBounds = rendererOptions?.ignoreBpmnTaskLabelBounds ?? false; + this.ignoreActivityLabelBounds = rendererOptions?.ignoreActivityLabelBounds ?? false; + this.ignoreTaskLabelBounds = rendererOptions?.ignoreTaskLabelBounds ?? false; } render(renderedModel: RenderedModel): void { @@ -78,7 +78,7 @@ export class BpmnRenderer { const bpmnElement = shape.bpmnElement; const parent = this.getParent(bpmnElement); const bounds = shape.bounds; - const labelBounds = isLabelBoundsIgnored(shape, this.ignoreBpmnActivityLabelBounds, this.ignoreBpmnTaskLabelBounds) ? undefined : shape.label?.bounds; + const labelBounds = isLabelBoundsIgnored(shape, this.ignoreActivityLabelBounds, this.ignoreTaskLabelBounds) ? undefined : shape.label?.bounds; const style = this.styleComputer.computeStyle(shape, labelBounds); this.insertVertex(parent, bpmnElement.id, bpmnElement.name, bounds, labelBounds, style); @@ -147,12 +147,12 @@ export class BpmnRenderer { /** * @internal */ -export function isLabelBoundsIgnored(shape: Shape, ignoreBpmnActivityLabelBounds: boolean, ignoreBpmnTaskLabelBounds: boolean): boolean { +export function isLabelBoundsIgnored(shape: Shape, ignoreActivityLabelBounds: boolean, ignoreTaskLabelBounds: boolean): boolean { const kind = shape.bpmnElement.kind; return ( ShapeUtil.isPoolOrLane(kind) || // pool/lane label bounds are not managed for now (use hard coded values) - (ignoreBpmnActivityLabelBounds && ShapeUtil.isActivity(kind)) || - (ignoreBpmnTaskLabelBounds && ShapeUtil.isTask(kind)) + (ignoreActivityLabelBounds && ShapeUtil.isActivity(kind)) || + (ignoreTaskLabelBounds && ShapeUtil.isTask(kind)) ); } diff --git a/src/component/mxgraph/renderer/StyleComputer.ts b/src/component/mxgraph/renderer/StyleComputer.ts index d24cb54c42..d44e0704ba 100644 --- a/src/component/mxgraph/renderer/StyleComputer.ts +++ b/src/component/mxgraph/renderer/StyleComputer.ts @@ -39,11 +39,11 @@ import { BpmnStyleIdentifier } from '../style'; */ export default class StyleComputer { private readonly ignoreBpmnColors: boolean; - private readonly ignoreBpmnLabelStyles: boolean; + private readonly ignoreLabelStyles: boolean; constructor(options?: RendererOptions) { this.ignoreBpmnColors = options?.ignoreBpmnColors ?? true; - this.ignoreBpmnLabelStyles = options?.ignoreBpmnLabelStyles ?? false; + this.ignoreLabelStyles = options?.ignoreLabelStyles ?? false; } computeStyle(bpmnCell: Shape | Edge, labelBounds: Bounds): string { @@ -112,7 +112,7 @@ export default class StyleComputer { const styleValues = new Map(); const font = bpmnCell.label?.font; - if (font && !this.ignoreBpmnLabelStyles) { + if (font && !this.ignoreLabelStyles) { styleValues.set(mxConstants.STYLE_FONTFAMILY, font.name); styleValues.set(mxConstants.STYLE_FONTSIZE, font.size); styleValues.set(mxConstants.STYLE_FONTSTYLE, getFontStyleValue(font)); diff --git a/src/component/options.ts b/src/component/options.ts index 254ac94318..d3730bd39b 100644 --- a/src/component/options.ts +++ b/src/component/options.ts @@ -235,7 +235,7 @@ export type RendererOptions = { * @default false * @since 0.48.0 */ - ignoreBpmnActivityLabelBounds?: boolean; + ignoreActivityLabelBounds?: boolean; /** * If set to `false`, support the "BPMN in Color" specification with a fallback with bpmn.io colors. For more details about the support, see * {@link https://github.com/process-analytics/bpmn-visualization-js/pull/2614}. @@ -252,16 +252,16 @@ export type RendererOptions = { * @default false * @since 0.48.0 */ - ignoreBpmnLabelStyles?: boolean; + ignoreLabelStyles?: boolean; /** * If set to `true`, ignore the label bounds configuration defined in the BPMN diagram for tasks only. * This forces the use of default label positioning for tasks instead of the bounds specified in the BPMN source. - * This option is more restrictive than `ignoreBpmnActivityLabelBounds` as it only affects tasks, not sub-processes or call activities. + * This option is more restrictive than {@link ignoreActivityLabelBounds} as it only affects tasks, not sub-processes or call activities. * - * **Note**: When `ignoreBpmnActivityLabelBounds` is `true`, this option is ignored as the more general activity option takes precedence. + * **Note**: When {@link ignoreActivityLabelBounds} is `true`, this option is ignored as the more general activity option takes precedence. * * @default false * @since 0.48.0 */ - ignoreBpmnTaskLabelBounds?: boolean; + ignoreTaskLabelBounds?: boolean; }; diff --git a/test/e2e/bpmn.rendering.ignore.options.test.ts b/test/e2e/bpmn.rendering.ignore.options.test.ts index 0df536c3c8..c12332bf52 100644 --- a/test/e2e/bpmn.rendering.ignore.options.test.ts +++ b/test/e2e/bpmn.rendering.ignore.options.test.ts @@ -159,16 +159,16 @@ describe('BPMN rendering - ignore options', () => { describe('Ignore activity label bounds', () => { const bpmnDiagramName = 'activities.with.wrongly.positioned.labels'; - describe.each([false, true])('ignoreBpmnActivityLabelBounds: %s', (ignoreBpmnActivityLabelBounds: boolean) => { + describe.each([false, true])('ignoreActivityLabelBounds: %s', (ignoreActivityLabelBounds: boolean) => { const imageSnapshotConfigurator = new ImageSnapshotConfigurator(new ImageSnapshotThresholdsActivityLabelBounds(), 'bpmn-rendering-ignore-options'); it(`${bpmnDiagramName}`, async () => { await pageTester.gotoPageAndLoadBpmnDiagram(bpmnDiagramName, { - rendererIgnoreBpmnActivityLabelBounds: ignoreBpmnActivityLabelBounds, + rendererIgnoreActivityLabelBounds: ignoreActivityLabelBounds, }); const image = await page.screenshot({ fullPage: true }); - const config = imageSnapshotConfigurator.getConfig(getConfigName(bpmnDiagramName, ignoreBpmnActivityLabelBounds)); + const config = imageSnapshotConfigurator.getConfig(getConfigName(bpmnDiagramName, ignoreActivityLabelBounds)); expect(image).toMatchImageSnapshot(config); }); }); @@ -177,16 +177,16 @@ describe('BPMN rendering - ignore options', () => { describe('Ignore label styles', () => { const bpmnDiagramName = 'labels.with.font.styles'; - describe.each([false, true])('ignoreBpmnLabelStyles: %s', (ignoreBpmnLabelStyles: boolean) => { + describe.each([false, true])('ignoreLabelStyles: %s', (ignoreLabelStyles: boolean) => { const imageSnapshotConfigurator = new ImageSnapshotConfigurator(new ImageSnapshotThresholdsLabelStyles(), 'bpmn-rendering-ignore-options'); it(`${bpmnDiagramName}`, async () => { await pageTester.gotoPageAndLoadBpmnDiagram(bpmnDiagramName, { - rendererIgnoreBpmnLabelStyles: ignoreBpmnLabelStyles, + rendererIgnoreLabelStyles: ignoreLabelStyles, }); const image = await page.screenshot({ fullPage: true }); - const config = imageSnapshotConfigurator.getConfig(getConfigName(bpmnDiagramName, ignoreBpmnLabelStyles)); + const config = imageSnapshotConfigurator.getConfig(getConfigName(bpmnDiagramName, ignoreLabelStyles)); expect(image).toMatchImageSnapshot(config); }); }); diff --git a/test/shared/visu/bpmn-page-utils.ts b/test/shared/visu/bpmn-page-utils.ts index 1bcf699265..03d3c279ca 100644 --- a/test/shared/visu/bpmn-page-utils.ts +++ b/test/shared/visu/bpmn-page-utils.ts @@ -143,8 +143,8 @@ export interface PageOptions { bpmnElementIdToCollapse?: string; poolIdsToFilter?: string | string[]; rendererIgnoreBpmnColors?: boolean; - rendererIgnoreBpmnLabelStyles?: boolean; - rendererIgnoreBpmnActivityLabelBounds?: boolean; + rendererIgnoreLabelStyles?: boolean; + rendererIgnoreActivityLabelBounds?: boolean; } export interface Point { @@ -258,9 +258,8 @@ export class PageTester { otherPageOptions?.poolIdsToFilter && (url += `&bpmn.filter.pool.ids=${otherPageOptions.poolIdsToFilter}`); // renderer options otherPageOptions?.rendererIgnoreBpmnColors !== undefined && (url += `&renderer.ignore.bpmn.colors=${otherPageOptions.rendererIgnoreBpmnColors}`); - otherPageOptions?.rendererIgnoreBpmnLabelStyles !== undefined && (url += `&renderer.ignore.label.style=${otherPageOptions.rendererIgnoreBpmnLabelStyles}`); - otherPageOptions?.rendererIgnoreBpmnActivityLabelBounds !== undefined && - (url += `&renderer.ignore.activity.label.bounds=${otherPageOptions.rendererIgnoreBpmnActivityLabelBounds}`); + otherPageOptions?.rendererIgnoreLabelStyles !== undefined && (url += `&renderer.ignore.label.style=${otherPageOptions.rendererIgnoreLabelStyles}`); + otherPageOptions?.rendererIgnoreActivityLabelBounds !== undefined && (url += `&renderer.ignore.activity.label.bounds=${otherPageOptions.rendererIgnoreActivityLabelBounds}`); return url; } diff --git a/test/unit/component/mxgraph/BpmnRenderer.test.ts b/test/unit/component/mxgraph/BpmnRenderer.test.ts index 5702be6ae2..87c5957ff0 100644 --- a/test/unit/component/mxgraph/BpmnRenderer.test.ts +++ b/test/unit/component/mxgraph/BpmnRenderer.test.ts @@ -39,8 +39,8 @@ describe('isLabelBoundsIgnored', () => { }); }); - describe('with ignoreBpmnActivityLabelBounds option', () => { - describe.each([true, false])('with ignoreBpmnTaskLabelBounds option set to %s', (ignoreBpmnTaskLabelBounds: boolean) => { + describe('with ignoreActivityLabelBounds option', () => { + describe.each([true, false])('with ignoreTaskLabelBounds option set to %s', (ignoreTaskLabelBounds: boolean) => { test.each([ [ShapeBpmnElementKind.POOL, true], [ShapeBpmnElementKind.LANE, true], @@ -54,12 +54,12 @@ describe('isLabelBoundsIgnored', () => { [ShapeBpmnElementKind.GATEWAY_PARALLEL, false], ])('should ignore %s label bounds? %s', (kind, expected) => { const shape = new Shape('id', new ShapeBpmnElement('id', 'name', kind)); - expect(isLabelBoundsIgnored(shape, true, ignoreBpmnTaskLabelBounds)).toBe(expected); + expect(isLabelBoundsIgnored(shape, true, ignoreTaskLabelBounds)).toBe(expected); }); }); }); - describe('with ignoreBpmnTaskLabelBounds option', () => { + describe('with ignoreTaskLabelBounds option', () => { test.each([ [ShapeBpmnElementKind.POOL, true], [ShapeBpmnElementKind.LANE, true], diff --git a/test/unit/component/mxgraph/renderer/StyleComputer.test.ts b/test/unit/component/mxgraph/renderer/StyleComputer.test.ts index 46c2d6a144..0c26f4e98d 100644 --- a/test/unit/component/mxgraph/renderer/StyleComputer.test.ts +++ b/test/unit/component/mxgraph/renderer/StyleComputer.test.ts @@ -479,10 +479,10 @@ describe('Style Computer', () => { ); }); - describe('compute style - ignore BPMN label styles', () => { - describe.each([[undefined], [false], [true]])(`Ignore BPMN label styles (renderer option): %s`, (ignoreBpmnLabelStyles: boolean) => { - const styleComputer = new StyleComputer(ignoreBpmnLabelStyles === undefined ? {} : { ignoreBpmnLabelStyles }); - const expectFontStyles = !(ignoreBpmnLabelStyles ?? false); + describe('compute style - ignore label styles', () => { + describe.each([[undefined], [false], [true]])(`Ignore label styles (renderer option): %s`, (ignoreLabelStyles: boolean) => { + const styleComputer = new StyleComputer(ignoreLabelStyles === undefined ? {} : { ignoreLabelStyles }); + const expectFontStyles = !(ignoreLabelStyles ?? false); function computeStyleWithIgnoreLabelStyles(element: Shape | Edge): string { return styleComputer.computeStyle(element, element.label?.bounds);