diff --git a/src/mxgraph/handler/mxEdgeHandler.js b/src/mxgraph/handler/mxEdgeHandler.js index ff766bace..99f2c9ff9 100644 --- a/src/mxgraph/handler/mxEdgeHandler.js +++ b/src/mxgraph/handler/mxEdgeHandler.js @@ -1601,7 +1601,7 @@ class mxEdgeHandler { // Resets the offset inside the geometry to find the offset // from the resulting point geometry.offset = new mxPoint(0, 0); - let pt = this.graph.view.getPoint(edgeState, geometry); + pt = this.graph.view.getPoint(edgeState, geometry); geometry.offset = new mxPoint(Math.round((x - pt.x) / scale), Math.round((y - pt.y) / scale)); } else { let points = edgeState.absolutePoints; diff --git a/src/mxgraph/handler/mxEdgeSegmentHandler.js b/src/mxgraph/handler/mxEdgeSegmentHandler.js index 6a76da64a..7a372f14c 100644 --- a/src/mxgraph/handler/mxEdgeSegmentHandler.js +++ b/src/mxgraph/handler/mxEdgeSegmentHandler.js @@ -3,6 +3,11 @@ * Copyright (c) 2006-2015, Gaudenz Alder * Updated to ES9 syntax by David Morrissey 2021 */ +import mxPoint from "../util/mxPoint"; +import mxConstants from "../util/mxConstants"; +import mxRectangle from "../util/mxRectangle"; +import mxUtils from "../util/mxUtils"; +import mxElbowEdgeHandler from "./mxElbowEdgeHandler"; class mxEdgeSegmentHandler extends mxElbowEdgeHandler { constructor(state) { @@ -22,7 +27,7 @@ class mxEdgeSegmentHandler extends mxElbowEdgeHandler { // Special case for straight edges where we add a virtual middle handle for moving the edge let tol = Math.max(1, this.graph.view.scale); - if (pts.length == 2 || (pts.length == 3 && + if (pts.length === 2 || (pts.length === 3 && (Math.abs(pts[0].x - pts[1].x) < tol && Math.abs(pts[1].x - pts[2].x) < tol || Math.abs(pts[0].y - pts[1].y) < tol && Math.abs(pts[1].y - pts[2].y) < tol))) { let cx = pts[0].x + (pts[pts.length - 1].x - pts[0].x) / 2; @@ -72,7 +77,7 @@ class mxEdgeSegmentHandler extends mxElbowEdgeHandler { } // Replaces single point that intersects with source or target - if (result.length == 1) { + if (result.length === 1) { let source = this.state.getVisibleTerminalState(true); let target = this.state.getVisibleTerminalState(false); let scale = this.state.view.getScale(); @@ -126,13 +131,13 @@ class mxEdgeSegmentHandler extends mxElbowEdgeHandler { let rpts = this.state.absolutePoints; // A straight line is represented by 3 handles - if (result.length == 0 && (Math.round(pts[0].x - pts[pts.length - 1].x) == 0 || - Math.round(pts[0].y - pts[pts.length - 1].y) == 0)) { + if (result.length === 0 && (Math.round(pts[0].x - pts[pts.length - 1].x) === 0 || + Math.round(pts[0].y - pts[pts.length - 1].y) === 0)) { result = [point, point]; } // Handles special case of transitions from straight vertical to routed - else if (pts.length == 5 && result.length == 2 && source != null && target != null && - rpts != null && Math.round(rpts[0].x - rpts[rpts.length - 1].x) == 0) { + else if (pts.length === 5 && result.length === 2 && source != null && target != null && + rpts != null && Math.round(rpts[0].x - rpts[rpts.length - 1].x) === 0) { let view = this.graph.getView(); let scale = view.getScale(); let tr = view.getTranslate(); @@ -196,8 +201,8 @@ class mxEdgeSegmentHandler extends mxElbowEdgeHandler { var pt2 = pts[i]; // Merges adjacent segments only if more than 2 to allow for straight edges - if ((Math.round(pt0.x - pt1.x) != 0 || Math.round(pt1.x - pt2.x) != 0) && - (Math.round(pt0.y - pt1.y) != 0 || Math.round(pt1.y - pt2.y) != 0)) { + if ((Math.round(pt0.x - pt1.x) !== 0 || Math.round(pt1.x - pt2.x) !== 0) && + (Math.round(pt0.y - pt1.y) !== 0 || Math.round(pt1.y - pt2.y) !== 0)) { result.push(this.convertPoint(pt1.clone(), false)); } @@ -275,11 +280,11 @@ class mxEdgeSegmentHandler extends mxElbowEdgeHandler { for (let i = 0; i < pts.length - 1; i++) { bend = this.createVirtualBend(); bends.push(bend); - let horizontal = Math.round(pts[i].x - pts[i + 1].x) == 0; + let horizontal = Math.round(pts[i].x - pts[i + 1].x) === 0; // Special case where dy is 0 as well - if (Math.round(pts[i].y - pts[i + 1].y) == 0 && i < pts.length - 2) { - horizontal = Math.round(pts[i].x - pts[i + 2].x) == 0; + if (Math.round(pts[i].y - pts[i + 1].y) === 0 && i < pts.length - 2) { + horizontal = Math.round(pts[i].x - pts[i + 2].x) === 0; } bend.setCursor((horizontal) ? 'col-resize' : 'row-resize'); @@ -288,7 +293,7 @@ class mxEdgeSegmentHandler extends mxElbowEdgeHandler { } // Target - let bend = this.createHandleShape(pts.length); + bend = this.createHandleShape(pts.length); this.initBend(bend); bend.setCursor(mxConstants.CURSOR_TERMINAL_HANDLE); bends.push(bend); @@ -319,10 +324,10 @@ class mxEdgeSegmentHandler extends mxElbowEdgeHandler { let straight = false; // Puts handle in the center of straight edges - if (pts.length == 4 && Math.round(pts[1].x - pts[2].x) == 0 && Math.round(pts[1].y - pts[2].y) == 0) { + if (pts.length === 4 && Math.round(pts[1].x - pts[2].x) === 0 && Math.round(pts[1].y - pts[2].y) === 0) { straight = true; - if (Math.round(pts[0].y - pts[pts.length - 1].y) == 0) { + if (Math.round(pts[0].y - pts[pts.length - 1].y) === 0) { let cx = pts[0].x + (pts[pts.length - 1].x - pts[0].x) / 2; pts[1] = new mxPoint(cx, pts[1].y); pts[2] = new mxPoint(cx, pts[2].y); @@ -335,7 +340,7 @@ class mxEdgeSegmentHandler extends mxElbowEdgeHandler { for (let i = 0; i < pts.length - 1; i++) { if (this.bends[i + 1] != null) { - var p0 = pts[i]; + let p0 = pts[i]; let pe = pts[i + 1]; let pt = new mxPoint(p0.x + (pe.x - p0.x) / 2, p0.y + (pe.y - p0.y) / 2); let b = this.bends[i + 1].bounds; diff --git a/src/mxgraph/handler/mxVertexHandler.js b/src/mxgraph/handler/mxVertexHandler.js index 7103cced9..e164060e5 100644 --- a/src/mxgraph/handler/mxVertexHandler.js +++ b/src/mxgraph/handler/mxVertexHandler.js @@ -977,8 +977,8 @@ class mxVertexHandler { var c2 = new mxPoint(this.bounds.getCenterX(), this.bounds.getCenterY()); - let dx = c2.x - ct.x; - let dy = c2.y - ct.y; + dx = c2.x - ct.x; + dy = c2.y - ct.y; var dx2 = cos * dx - sin * dy; var dy2 = sin * dx + cos * dy; diff --git a/src/mxgraph/model/mxGeometry.js b/src/mxgraph/model/mxGeometry.js index 356140ead..fadbde144 100644 --- a/src/mxgraph/model/mxGeometry.js +++ b/src/mxgraph/model/mxGeometry.js @@ -4,7 +4,7 @@ * Updated to ES9 syntax by David Morrissey 2021 */ -import mxPoint from "FIXME"; +import mxPoint from "../util/mxPoint"; import mxRectangle from "../util/mxRectangle"; class mxGeometry extends mxRectangle { diff --git a/src/mxgraph/shape/mxText.js b/src/mxgraph/shape/mxText.js index efa75c735..0f42e45a5 100644 --- a/src/mxgraph/shape/mxText.js +++ b/src/mxgraph/shape/mxText.js @@ -930,7 +930,7 @@ class mxText extends mxShape { } // Workaround for rendering offsets - let dy = 0; + dy = 0; style.zoom = s; style.left = Math.round(this.bounds.x + left_fix - w / 2) + 'px'; diff --git a/src/mxgraph/shape/mxTriangle.js b/src/mxgraph/shape/mxTriangle.js index bbc1e8f32..72339b00c 100644 --- a/src/mxgraph/shape/mxTriangle.js +++ b/src/mxgraph/shape/mxTriangle.js @@ -4,7 +4,10 @@ * Updated to ES9 syntax by David Morrissey 2021 */ -import mxPoint from "FIXME"; +import mxPoint from "../util/mxPoint"; +import mxActor from "./mxActor"; +import mxUtils from "../util/mxUtils"; +import mxConstants from "../util/mxConstants"; class mxTriangle extends mxActor { /** diff --git a/src/mxgraph/util/mxUtils.js b/src/mxgraph/util/mxUtils.js index b33e354f7..5c321f9b6 100644 --- a/src/mxgraph/util/mxUtils.js +++ b/src/mxgraph/util/mxUtils.js @@ -5,6 +5,7 @@ */ import mxEffects from "./mxEffects"; import mxXmlRequest from "./mxXmlRequest"; +import mxClient from "../mxClient"; let mxUtils = { /** @@ -95,11 +96,11 @@ let mxUtils = { * medium and thick (2, 4 and 6). */ parseCssNumber: (value) => { - if (value == 'thin') { + if (value === 'thin') { value = '2'; - } else if (value == 'medium') { + } else if (value === 'medium') { value = '4'; - } else if (value == 'thick') { + } else if (value === 'thick') { value = '6'; } diff --git a/src/mxgraph/view/mxCellEditor.js b/src/mxgraph/view/mxCellEditor.js index 2b900bd14..998c8a88d 100644 --- a/src/mxgraph/view/mxCellEditor.js +++ b/src/mxgraph/view/mxCellEditor.js @@ -6,7 +6,7 @@ import mxUtils from "../util/mxUtils" import mxRectangle from "../util/mxRectangle"; -import mxEvent from "FIXME"; +import mxEvent from "../util/mxEvent"; class mxCellEditor { /** diff --git a/src/mxgraph/view/mxCellRenderer.js b/src/mxgraph/view/mxCellRenderer.js index e1fe11b51..f7e7a124e 100644 --- a/src/mxgraph/view/mxCellRenderer.js +++ b/src/mxgraph/view/mxCellRenderer.js @@ -3,25 +3,26 @@ * Copyright (c) 2006-2017, Gaudenz Alder */ -import mxRectangleShape from "FIXME"; -import mxEllipse from "FIXME"; -import mxRhombus from "FIXME"; -import mxCylinder from "FIXME"; -import mxConnector from "FIXME"; -import mxActor from "FIXME"; -import mxTriangle from "FIXME"; -import mxHexagon from "FIXME"; -import mxCloud from "FIXME"; -import mxLine from "FIXME"; -import mxArrow from "FIXME"; -import mxArrowConnector from "FIXME"; -import mxDoubleEllipse from "FIXME"; -import mxSwimlane from "FIXME"; -import mxImageShape from "FIXME"; -import mxLabel from "FIXME"; -import mxText from "FIXME"; -import mxConstants from "FIXME"; +import mxRectangleShape from "../shape/mxRectangleShape"; +import mxEllipse from "../shape/mxEllipse"; +import mxRhombus from "../shape/mxRhombus"; +import mxCylinder from "../shape/mxCylinder"; +import mxConnector from "../shape/mxConnector"; +import mxActor from "../shape/mxActor"; +import mxTriangle from "../shape/mxTriangle"; +import mxHexagon from "../shape/mxHexagon"; +import mxCloud from "../shape/mxCloud"; +import mxLine from "../shape/mxLine"; +import mxArrow from "../shape/mxArrow"; +import mxArrowConnector from "../shape/mxArrowConnector"; +import mxDoubleEllipse from "../shape/mxDoubleEllipse"; +import mxSwimlane from "../shape/mxSwimlane"; +import mxImageShape from "../shape/mxImageShape"; +import mxLabel from "../shape/mxLabel"; +import mxText from "../shape/mxText"; +import mxConstants from "../util/mxConstants"; import mxUtils from "../util/mxUtils"; +import mxRectangle from "../util/mxRectangle"; class mxCellRenderer { /** @@ -840,9 +841,9 @@ class mxCellRenderer { let nextScale = this.getTextScale(state); this.resolveColor(state, 'color', mxConstants.STYLE_FONTCOLOR); - if (forced || state.text.value != value || state.text.isWrapping != wrapping || - state.text.overflow != overflow || state.text.isClipping != clipping || - state.text.scale != nextScale || state.text.dialect != dialect || + if (forced || state.text.value !== value || state.text.isWrapping !== wrapping || + state.text.overflow !== overflow || state.text.isClipping !== clipping || + state.text.scale !== nextScale || state.text.dialect !== dialect || state.text.bounds == null || !state.text.bounds.equals(bounds)) { state.text.dialect = dialect; state.text.value = value; @@ -875,12 +876,12 @@ class mxCellRenderer { let result = false; // Workaround for spacing added to directional spacing - if (stylename == 'spacingTop' || stylename == 'spacingRight' || - stylename == 'spacingBottom' || stylename == 'spacingLeft') { - result = parseFloat(shape[property]) - parseFloat(shape.spacing) != + if (stylename === 'spacingTop' || stylename === 'spacingRight' || + stylename === 'spacingBottom' || stylename === 'spacingLeft') { + result = parseFloat(shape[property]) - parseFloat(shape.spacing) !== (state.style[stylename] || defaultValue); } else { - result = shape[property] != (state.style[stylename] || defaultValue); + result = shape[property] !== (state.style[stylename] || defaultValue); } return result; @@ -987,7 +988,7 @@ class mxCellRenderer { let hpos = mxUtils.getValue(state.style, mxConstants.STYLE_LABEL_POSITION, mxConstants.ALIGN_CENTER); let vpos = mxUtils.getValue(state.style, mxConstants.STYLE_VERTICAL_LABEL_POSITION, mxConstants.ALIGN_MIDDLE); - if (hpos == mxConstants.ALIGN_CENTER && vpos == mxConstants.ALIGN_MIDDLE) { + if (hpos === mxConstants.ALIGN_CENTER && vpos === mxConstants.ALIGN_MIDDLE) { bounds = state.shape.getLabelBounds(bounds); } } @@ -1021,7 +1022,7 @@ class mxCellRenderer { bounds.y -= state.text.margin.y * bounds.height; bounds.x -= state.text.margin.x * bounds.width; - if (!this.legacySpacing || (state.style[mxConstants.STYLE_OVERFLOW] != 'fill' && state.style[mxConstants.STYLE_OVERFLOW] != 'width')) { + if (!this.legacySpacing || (state.style[mxConstants.STYLE_OVERFLOW] !== 'fill' && state.style[mxConstants.STYLE_OVERFLOW] !== 'width')) { let s = state.view.scale; let spacing = state.text.getSpacing(); bounds.x += spacing.x * s; @@ -1031,18 +1032,18 @@ class mxCellRenderer { let vpos = mxUtils.getValue(state.style, mxConstants.STYLE_VERTICAL_LABEL_POSITION, mxConstants.ALIGN_MIDDLE); let lw = mxUtils.getValue(state.style, mxConstants.STYLE_LABEL_WIDTH, null); - bounds.width = Math.max(0, bounds.width - ((hpos == mxConstants.ALIGN_CENTER && lw == null) ? (state.text.spacingLeft * s + state.text.spacingRight * s) : 0)); - bounds.height = Math.max(0, bounds.height - ((vpos == mxConstants.ALIGN_MIDDLE) ? (state.text.spacingTop * s + state.text.spacingBottom * s) : 0)); + bounds.width = Math.max(0, bounds.width - ((hpos === mxConstants.ALIGN_CENTER && lw == null) ? (state.text.spacingLeft * s + state.text.spacingRight * s) : 0)); + bounds.height = Math.max(0, bounds.height - ((vpos === mxConstants.ALIGN_MIDDLE) ? (state.text.spacingTop * s + state.text.spacingBottom * s) : 0)); } let theta = state.text.getTextRotation(); // Only needed if rotated around another center - if (theta != 0 && state != null && state.view.graph.model.isVertex(state.cell)) { + if (theta !== 0 && state != null && state.view.graph.model.isVertex(state.cell)) { let cx = state.getCenterX(); let cy = state.getCenterY(); - if (bounds.x != cx || bounds.y != cy) { + if (bounds.x !== cx || bounds.y !== cy) { let rad = theta * (Math.PI / 180); let pt = mxUtils.getRotatedPoint(new mxPoint(bounds.x, bounds.y), Math.cos(rad), Math.sin(rad), new mxPoint(cx, cy)); @@ -1391,7 +1392,7 @@ class mxCellRenderer { * Returns true if the given shape must be repainted. */ isShapeInvalid = (state, shape) => { - return shape.bounds == null || shape.scale != state.view.scale || + return shape.bounds == null || shape.scale !== state.view.scale || (state.absolutePoints == null && !shape.bounds.equals(state)) || (state.absolutePoints != null && !mxUtils.equalPoints(shape.points, state.absolutePoints)) };