Skip to content

Commit 25c0f0f

Browse files
committed
refactor: remove reference to "mx" in classes, types and JSDoc
There is no need to prefix our own elements by "mx" when we extend the mxGraph code. This makes the code easier to read, and eventually, prepare the switch to maxGraph. These changes only apply to bpmn-visualization internals, there is no impact for end users.
1 parent d45aa2d commit 25c0f0f

13 files changed

Lines changed: 42 additions & 42 deletions

File tree

src/component/mxgraph/BpmnCellRenderer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type { IconPainter } from './shape/render';
1818
import type { mxCellState, mxImageShape, mxShape } from 'mxgraph';
1919

2020
import { mxgraph, mxRectangle } from './initializer';
21-
import { MxGraphCustomOverlay } from './overlay/custom-overlay';
21+
import { CustomCellOverlay } from './overlay/custom-overlay';
2222
import { OverlayBadgeShape } from './overlay/shapes';
2323
import { overrideCreateSvgCanvas } from './shape/utils';
2424

@@ -45,7 +45,7 @@ export class BpmnCellRenderer extends mxgraph.mxCellRenderer {
4545
let overlayShape: mxShape;
4646

4747
// START bpmn-visualization CUSTOMIZATION
48-
if (currentOverlay instanceof MxGraphCustomOverlay) {
48+
if (currentOverlay instanceof CustomCellOverlay) {
4949
overlayShape = new OverlayBadgeShape(currentOverlay.label, new mxRectangle(0, 0, 0, 0), currentOverlay.style);
5050
} else {
5151
overlayShape = new mxgraph.mxImageShape(new mxRectangle(0, 0, 0, 0), currentOverlay.image.src);

src/component/mxgraph/BpmnGraph.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class BpmnGraph extends mxgraph.mxGraph {
5151
*
5252
* @param callbackFunction the update to be made in the transaction.
5353
*
54-
* @experimental subject to change, may move to a subclass of `mxGraphModel`
54+
* @experimental subject to change, may move to a subclass of {@link mxGraphModel}
5555
* @alpha
5656
*/
5757
batchUpdate(callbackFunction: () => void): void {

src/component/mxgraph/GraphConfigurator.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { registerEdgeMarkers, registerShapes } from './config/register-style-def
1919
import { StyleConfigurator } from './config/StyleConfigurator';
2020

2121
/**
22-
* Configure the BpmnMxGraph graph that can be used by the lib
22+
* Configure the {@link BpmnGraph} graph that can be used by the lib
2323
* <ul>
2424
* <li>styles
2525
* <li>shapes
@@ -52,8 +52,8 @@ export default class GraphConfigurator {
5252
this.graph.setConstrainChildren(false);
5353
this.graph.setExtendParents(false);
5454

55-
// Disable folding for container mxCell (pool, lane, sub process, call activity) because we don't need it.
56-
// This also prevents requesting unavailable images (see #185) as we don't override BpmnMxGraph folding default images.
55+
// Disable folding for container cells (pool, lane, sub process, call activity) because we don't need it.
56+
// This also prevents requesting unavailable images (see #185) as we don't override BpmnGraph folding default images.
5757
this.graph.foldingEnabled = false;
5858
}
5959
}

src/component/mxgraph/overlay/converter.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import type { MxGraphCustomOverlayOptions, MxGraphCustomOverlayPosition, MxGraphCustomOverlayStyle } from './custom-overlay';
17+
import type { CustomCellOverlayOptions, CustomCellOverlayPosition, CustomCellOverlayStyle } from './custom-overlay';
1818
import type { Overlay, OverlayFont, OverlayPosition, OverlayFill, OverlayStroke } from '../../registry';
1919

2020
import { StyleDefault } from '../style';
2121

22-
const overlayPositions = new Map<OverlayPosition, MxGraphCustomOverlayPosition>([
22+
const overlayPositions = new Map<OverlayPosition, CustomCellOverlayPosition>([
2323
// Edge
2424
['start', { horizontalAlign: 'left', verticalAlign: 'top' }],
2525
['middle', { horizontalAlign: 'center', verticalAlign: 'top' }],
@@ -35,30 +35,30 @@ const overlayPositions = new Map<OverlayPosition, MxGraphCustomOverlayPosition>(
3535
['middle-right', { horizontalAlign: 'right', verticalAlign: 'middle' }],
3636
]);
3737

38-
const convertPosition = (overlay: Overlay): MxGraphCustomOverlayPosition => overlayPositions.get(overlay.position);
38+
const convertPosition = (overlay: Overlay): CustomCellOverlayPosition => overlayPositions.get(overlay.position);
3939

40-
const convertFill = (convertedStyle: MxGraphCustomOverlayStyle, apiFill: OverlayFill): void => {
40+
const convertFill = (convertedStyle: CustomCellOverlayStyle, apiFill: OverlayFill): void => {
4141
if (apiFill) {
4242
convertedStyle.fill.color = apiFill.color ?? convertedStyle.fill.color;
4343
convertedStyle.fill.opacity = apiFill.opacity ?? convertedStyle.fill.opacity;
4444
}
4545
};
4646

47-
const convertStroke = (convertedStyle: MxGraphCustomOverlayStyle, apiStroke: OverlayStroke): void => {
47+
const convertStroke = (convertedStyle: CustomCellOverlayStyle, apiStroke: OverlayStroke): void => {
4848
if (apiStroke) {
4949
convertedStyle.stroke.color = apiStroke.color ?? convertedStyle.stroke.color;
5050
convertedStyle.stroke.width = apiStroke.width ?? convertedStyle.stroke.width;
5151
}
5252
};
5353

54-
const convertFont = (convertedStyle: MxGraphCustomOverlayStyle, apiFont: OverlayFont): void => {
54+
const convertFont = (convertedStyle: CustomCellOverlayStyle, apiFont: OverlayFont): void => {
5555
if (apiFont) {
5656
convertedStyle.font.color = apiFont.color ?? convertedStyle.font.color;
5757
convertedStyle.font.size = apiFont.size ?? convertedStyle.font.size;
5858
}
5959
};
6060

61-
const convertStyle = (overlay: Overlay): MxGraphCustomOverlayStyle => {
61+
const convertStyle = (overlay: Overlay): CustomCellOverlayStyle => {
6262
// recompute the style at each call to ensure we consider default changes that could occur after lib initialization
6363
const defaultStyle = {
6464
fill: { color: StyleDefault.DEFAULT_OVERLAY_FILL_COLOR.valueOf(), opacity: StyleDefault.DEFAULT_OVERLAY_FILL_OPACITY.valueOf() },
@@ -67,7 +67,7 @@ const convertStyle = (overlay: Overlay): MxGraphCustomOverlayStyle => {
6767
};
6868

6969
const style = overlay.style;
70-
const convertedStyle = { ...defaultStyle } as MxGraphCustomOverlayStyle;
70+
const convertedStyle = { ...defaultStyle } as CustomCellOverlayStyle;
7171
if (!style) {
7272
return convertedStyle;
7373
}
@@ -80,7 +80,7 @@ const convertStyle = (overlay: Overlay): MxGraphCustomOverlayStyle => {
8080
};
8181

8282
export class OverlayConverter {
83-
convert(overlay: Overlay): MxGraphCustomOverlayOptions {
83+
convert(overlay: Overlay): CustomCellOverlayOptions {
8484
const position = convertPosition(overlay);
8585
const style = convertStyle(overlay);
8686
return { position, style };

src/component/mxgraph/overlay/custom-overlay.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ import { mxgraph, mxConstants, mxPoint, mxRectangle } from '../initializer';
2222
export type VerticalAlignType = 'bottom' | 'middle' | 'top';
2323
export type HorizontalAlignType = 'left' | 'center' | 'right';
2424

25-
export interface MxGraphCustomOverlayOptions {
26-
position: MxGraphCustomOverlayPosition;
27-
style: MxGraphCustomOverlayStyle;
25+
export interface CustomCellOverlayOptions {
26+
position: CustomCellOverlayPosition;
27+
style: CustomCellOverlayStyle;
2828
}
2929

30-
export interface MxGraphCustomOverlayPosition {
30+
export interface CustomCellOverlayPosition {
3131
horizontalAlign?: HorizontalAlignType;
3232
verticalAlign?: VerticalAlignType;
3333
}
3434

35-
export type MxGraphCustomOverlayStyle = Required<OverlayStyle>;
35+
export type CustomCellOverlayStyle = Required<OverlayStyle>;
3636

37-
export class MxGraphCustomOverlay extends mxgraph.mxCellOverlay {
38-
readonly style: MxGraphCustomOverlayStyle;
37+
export class CustomCellOverlay extends mxgraph.mxCellOverlay {
38+
readonly style: CustomCellOverlayStyle;
3939

4040
constructor(
4141
public label: string,
42-
options: MxGraphCustomOverlayOptions,
42+
options: CustomCellOverlayOptions,
4343
) {
4444
super(null, '', options.position.horizontalAlign, options.position.verticalAlign, null, 'default');
4545
this.style = options.style;

src/component/mxgraph/overlay/shapes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import type { MxGraphCustomOverlayStyle } from './custom-overlay';
17+
import type { CustomCellOverlayStyle } from './custom-overlay';
1818
import type { mxRectangle } from 'mxgraph';
1919

2020
import { mxgraph } from '../initializer';
2121

2222
export class OverlayBadgeShape extends mxgraph.mxText {
23-
constructor(value: string, bounds: mxRectangle, style: MxGraphCustomOverlayStyle) {
23+
constructor(value: string, bounds: mxRectangle, style: CustomCellOverlayStyle) {
2424
super(
2525
value,
2626
bounds,

src/component/mxgraph/overlay/updater.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import type { BpmnGraph } from '../BpmnGraph';
2020
import { ensureIsArray } from '../../helpers/array-utils';
2121

2222
import { OverlayConverter } from './converter';
23-
import { MxGraphCustomOverlay } from './custom-overlay';
23+
import { CustomCellOverlay } from './custom-overlay';
2424

2525
export function createNewOverlaysUpdater(graph: BpmnGraph): OverlaysUpdater {
2626
return new OverlaysUpdater(graph, new OverlayConverter());
@@ -38,7 +38,7 @@ export class OverlaysUpdater {
3838
return;
3939
}
4040
for (const overlay of ensureIsArray(overlays)) {
41-
const bpmnOverlay = new MxGraphCustomOverlay(overlay.label, this.overlayConverter.convert(overlay));
41+
const bpmnOverlay = new CustomCellOverlay(overlay.label, this.overlayConverter.convert(overlay));
4242
this.graph.addCellOverlay(cell, bpmnOverlay);
4343
}
4444
}

src/component/mxgraph/renderer/CoordinatesTranslator.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ export default class CoordinatesTranslator {
3737
return new mxPoint(relativeX, relativeY);
3838
}
3939

40-
// Returns the translation to be applied to a cell whose mxGeometry x and y values are expressed with absolute coordinates
41-
// (i.e related to the graph default parent) you want to assign as parent to the cell passed as argument of this function.
40+
// Returns the translation to be applied to a cell whose Geometry x and y values are expressed with absolute coordinates
41+
// (i.e. related to the graph default parent) you want to assign as parent to the cell passed as argument of this function.
4242
// That way, you will be able to express the cell coordinates as relative to its parent cell.
4343
//
4444
// This implementation is taken from the example described in the documentation of mxgraph#getTranslateForRoot (4.1.1)
@@ -60,10 +60,10 @@ export default class CoordinatesTranslator {
6060
}
6161

6262
/**
63-
* Compute the center of the provided `mxCell` for absolute geometry: this is the center point of a segment whose edges
64-
* are the terminal points of the mxCell geometry points. Returns `undefined` if the 2 terminal points are not available.
63+
* Compute the center of the provided `Cell` for absolute geometry: this is the center point of a segment whose edges
64+
* are the terminal points of the Cell geometry points. Returns `undefined` if the 2 terminal points are not available.
6565
*
66-
* The center coordinates are given in the same referential as the `mxCell`, so relative to its parent.
66+
* The center coordinates are given in the same referential as the `Cell`, so relative to its parent.
6767
*/
6868
computeEdgeCenter(edge: mxCell): mxPointType {
6969
const points: mxPointType[] = edge.geometry.points;

src/component/mxgraph/renderer/style-utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { BpmnStyleIdentifier } from '../style/identifiers';
2323
/**
2424
* Compute the all class names associated to a cell in a hyphen case form.
2525
*
26-
* @param cell the `mxCell` related to the BPMN element.
26+
* @param cell the `Cell` related to the BPMN element.
2727
* @param isLabel the boolean that indicates if class must be computed for label.
2828
* @internal
2929
*/
@@ -34,7 +34,7 @@ export function computeAllBpmnClassNamesOfCell(cell: mxCell, isLabel: boolean):
3434
/**
3535
* Compute the all class names associated to a given bpmn element in a hyphen case form.
3636
*
37-
* @param style the part of the mxCell style related to a {@link BpmnElementKind}. Message flow icon is a special case, as it is not related to `BpmnElementKind`.
37+
* @param style the part of the Cell style related to a {@link BpmnElementKind}. Message flow icon is a special case, as it is not related to `BpmnElementKind`.
3838
* @param isLabel the boolean that indicates if class must be computed for label.
3939
* @internal exported for testing purpose
4040
*/

src/component/mxgraph/shape/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const overrideCreateSvgCanvas = function (shape: mxShape): void {
3131
const originalPointerEvents = this.pointerEvents;
3232
// Fix for issue https://github.com/process-analytics/bpmn-visualization-js/issues/920
3333
// This sets the "pointer-events" style property to "none" to avoid capturing the click.
34-
// This cannot be generalized for all mxgraph use cases. For instance, in an editor mode, we should be able to edit the text by clicking on it.
34+
// This cannot be generalized for all mxGraph use cases. For instance, in an editor mode, we should be able to edit the text by clicking on it.
3535
this.pointerEvents = false;
3636

3737
const textCss = originalCanvasGetTextCss.bind(this)();

0 commit comments

Comments
 (0)