fixes to imports and syntax errors

development
mcyph 2021-03-21 16:11:23 +11:00
parent 1f778c7869
commit 48097e7892
9 changed files with 67 additions and 57 deletions

View File

@ -1601,7 +1601,7 @@ class mxEdgeHandler {
// Resets the offset inside the geometry to find the offset // Resets the offset inside the geometry to find the offset
// from the resulting point // from the resulting point
geometry.offset = new mxPoint(0, 0); 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)); geometry.offset = new mxPoint(Math.round((x - pt.x) / scale), Math.round((y - pt.y) / scale));
} else { } else {
let points = edgeState.absolutePoints; let points = edgeState.absolutePoints;

View File

@ -3,6 +3,11 @@
* Copyright (c) 2006-2015, Gaudenz Alder * Copyright (c) 2006-2015, Gaudenz Alder
* Updated to ES9 syntax by David Morrissey 2021 * 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 { class mxEdgeSegmentHandler extends mxElbowEdgeHandler {
constructor(state) { 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 // 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); 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].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))) { 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; 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 // Replaces single point that intersects with source or target
if (result.length == 1) { if (result.length === 1) {
let source = this.state.getVisibleTerminalState(true); let source = this.state.getVisibleTerminalState(true);
let target = this.state.getVisibleTerminalState(false); let target = this.state.getVisibleTerminalState(false);
let scale = this.state.view.getScale(); let scale = this.state.view.getScale();
@ -126,13 +131,13 @@ class mxEdgeSegmentHandler extends mxElbowEdgeHandler {
let rpts = this.state.absolutePoints; let rpts = this.state.absolutePoints;
// A straight line is represented by 3 handles // A straight line is represented by 3 handles
if (result.length == 0 && (Math.round(pts[0].x - pts[pts.length - 1].x) == 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)) { Math.round(pts[0].y - pts[pts.length - 1].y) === 0)) {
result = [point, point]; result = [point, point];
} }
// Handles special case of transitions from straight vertical to routed // Handles special case of transitions from straight vertical to routed
else if (pts.length == 5 && result.length == 2 && source != null && target != null && 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) { rpts != null && Math.round(rpts[0].x - rpts[rpts.length - 1].x) === 0) {
let view = this.graph.getView(); let view = this.graph.getView();
let scale = view.getScale(); let scale = view.getScale();
let tr = view.getTranslate(); let tr = view.getTranslate();
@ -196,8 +201,8 @@ class mxEdgeSegmentHandler extends mxElbowEdgeHandler {
var pt2 = pts[i]; var pt2 = pts[i];
// Merges adjacent segments only if more than 2 to allow for straight edges // 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) && 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)) { (Math.round(pt0.y - pt1.y) !== 0 || Math.round(pt1.y - pt2.y) !== 0)) {
result.push(this.convertPoint(pt1.clone(), false)); result.push(this.convertPoint(pt1.clone(), false));
} }
@ -275,11 +280,11 @@ class mxEdgeSegmentHandler extends mxElbowEdgeHandler {
for (let i = 0; i < pts.length - 1; i++) { for (let i = 0; i < pts.length - 1; i++) {
bend = this.createVirtualBend(); bend = this.createVirtualBend();
bends.push(bend); 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 // Special case where dy is 0 as well
if (Math.round(pts[i].y - pts[i + 1].y) == 0 && i < pts.length - 2) { 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; horizontal = Math.round(pts[i].x - pts[i + 2].x) === 0;
} }
bend.setCursor((horizontal) ? 'col-resize' : 'row-resize'); bend.setCursor((horizontal) ? 'col-resize' : 'row-resize');
@ -288,7 +293,7 @@ class mxEdgeSegmentHandler extends mxElbowEdgeHandler {
} }
// Target // Target
let bend = this.createHandleShape(pts.length); bend = this.createHandleShape(pts.length);
this.initBend(bend); this.initBend(bend);
bend.setCursor(mxConstants.CURSOR_TERMINAL_HANDLE); bend.setCursor(mxConstants.CURSOR_TERMINAL_HANDLE);
bends.push(bend); bends.push(bend);
@ -319,10 +324,10 @@ class mxEdgeSegmentHandler extends mxElbowEdgeHandler {
let straight = false; let straight = false;
// Puts handle in the center of straight edges // 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; 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; let cx = pts[0].x + (pts[pts.length - 1].x - pts[0].x) / 2;
pts[1] = new mxPoint(cx, pts[1].y); pts[1] = new mxPoint(cx, pts[1].y);
pts[2] = new mxPoint(cx, pts[2].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++) { for (let i = 0; i < pts.length - 1; i++) {
if (this.bends[i + 1] != null) { if (this.bends[i + 1] != null) {
var p0 = pts[i]; let p0 = pts[i];
let pe = pts[i + 1]; let pe = pts[i + 1];
let pt = new mxPoint(p0.x + (pe.x - p0.x) / 2, p0.y + (pe.y - p0.y) / 2); 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; let b = this.bends[i + 1].bounds;

View File

@ -977,8 +977,8 @@ class mxVertexHandler {
var c2 = new mxPoint(this.bounds.getCenterX(), this.bounds.getCenterY()); var c2 = new mxPoint(this.bounds.getCenterX(), this.bounds.getCenterY());
let dx = c2.x - ct.x; dx = c2.x - ct.x;
let dy = c2.y - ct.y; dy = c2.y - ct.y;
var dx2 = cos * dx - sin * dy; var dx2 = cos * dx - sin * dy;
var dy2 = sin * dx + cos * dy; var dy2 = sin * dx + cos * dy;

View File

@ -4,7 +4,7 @@
* Updated to ES9 syntax by David Morrissey 2021 * Updated to ES9 syntax by David Morrissey 2021
*/ */
import mxPoint from "FIXME"; import mxPoint from "../util/mxPoint";
import mxRectangle from "../util/mxRectangle"; import mxRectangle from "../util/mxRectangle";
class mxGeometry extends mxRectangle { class mxGeometry extends mxRectangle {

View File

@ -930,7 +930,7 @@ class mxText extends mxShape {
} }
// Workaround for rendering offsets // Workaround for rendering offsets
let dy = 0; dy = 0;
style.zoom = s; style.zoom = s;
style.left = Math.round(this.bounds.x + left_fix - w / 2) + 'px'; style.left = Math.round(this.bounds.x + left_fix - w / 2) + 'px';

View File

@ -4,7 +4,10 @@
* Updated to ES9 syntax by David Morrissey 2021 * 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 { class mxTriangle extends mxActor {
/** /**

View File

@ -5,6 +5,7 @@
*/ */
import mxEffects from "./mxEffects"; import mxEffects from "./mxEffects";
import mxXmlRequest from "./mxXmlRequest"; import mxXmlRequest from "./mxXmlRequest";
import mxClient from "../mxClient";
let mxUtils = { let mxUtils = {
/** /**
@ -95,11 +96,11 @@ let mxUtils = {
* medium and thick (2, 4 and 6). * medium and thick (2, 4 and 6).
*/ */
parseCssNumber: (value) => { parseCssNumber: (value) => {
if (value == 'thin') { if (value === 'thin') {
value = '2'; value = '2';
} else if (value == 'medium') { } else if (value === 'medium') {
value = '4'; value = '4';
} else if (value == 'thick') { } else if (value === 'thick') {
value = '6'; value = '6';
} }

View File

@ -6,7 +6,7 @@
import mxUtils from "../util/mxUtils" import mxUtils from "../util/mxUtils"
import mxRectangle from "../util/mxRectangle"; import mxRectangle from "../util/mxRectangle";
import mxEvent from "FIXME"; import mxEvent from "../util/mxEvent";
class mxCellEditor { class mxCellEditor {
/** /**

View File

@ -3,25 +3,26 @@
* Copyright (c) 2006-2017, Gaudenz Alder * Copyright (c) 2006-2017, Gaudenz Alder
*/ */
import mxRectangleShape from "FIXME"; import mxRectangleShape from "../shape/mxRectangleShape";
import mxEllipse from "FIXME"; import mxEllipse from "../shape/mxEllipse";
import mxRhombus from "FIXME"; import mxRhombus from "../shape/mxRhombus";
import mxCylinder from "FIXME"; import mxCylinder from "../shape/mxCylinder";
import mxConnector from "FIXME"; import mxConnector from "../shape/mxConnector";
import mxActor from "FIXME"; import mxActor from "../shape/mxActor";
import mxTriangle from "FIXME"; import mxTriangle from "../shape/mxTriangle";
import mxHexagon from "FIXME"; import mxHexagon from "../shape/mxHexagon";
import mxCloud from "FIXME"; import mxCloud from "../shape/mxCloud";
import mxLine from "FIXME"; import mxLine from "../shape/mxLine";
import mxArrow from "FIXME"; import mxArrow from "../shape/mxArrow";
import mxArrowConnector from "FIXME"; import mxArrowConnector from "../shape/mxArrowConnector";
import mxDoubleEllipse from "FIXME"; import mxDoubleEllipse from "../shape/mxDoubleEllipse";
import mxSwimlane from "FIXME"; import mxSwimlane from "../shape/mxSwimlane";
import mxImageShape from "FIXME"; import mxImageShape from "../shape/mxImageShape";
import mxLabel from "FIXME"; import mxLabel from "../shape/mxLabel";
import mxText from "FIXME"; import mxText from "../shape/mxText";
import mxConstants from "FIXME"; import mxConstants from "../util/mxConstants";
import mxUtils from "../util/mxUtils"; import mxUtils from "../util/mxUtils";
import mxRectangle from "../util/mxRectangle";
class mxCellRenderer { class mxCellRenderer {
/** /**
@ -840,9 +841,9 @@ class mxCellRenderer {
let nextScale = this.getTextScale(state); let nextScale = this.getTextScale(state);
this.resolveColor(state, 'color', mxConstants.STYLE_FONTCOLOR); this.resolveColor(state, 'color', mxConstants.STYLE_FONTCOLOR);
if (forced || state.text.value != value || state.text.isWrapping != wrapping || if (forced || state.text.value !== value || state.text.isWrapping !== wrapping ||
state.text.overflow != overflow || state.text.isClipping != clipping || state.text.overflow !== overflow || state.text.isClipping !== clipping ||
state.text.scale != nextScale || state.text.dialect != dialect || state.text.scale !== nextScale || state.text.dialect !== dialect ||
state.text.bounds == null || !state.text.bounds.equals(bounds)) { state.text.bounds == null || !state.text.bounds.equals(bounds)) {
state.text.dialect = dialect; state.text.dialect = dialect;
state.text.value = value; state.text.value = value;
@ -875,12 +876,12 @@ class mxCellRenderer {
let result = false; let result = false;
// Workaround for spacing added to directional spacing // Workaround for spacing added to directional spacing
if (stylename == 'spacingTop' || stylename == 'spacingRight' || if (stylename === 'spacingTop' || stylename === 'spacingRight' ||
stylename == 'spacingBottom' || stylename == 'spacingLeft') { stylename === 'spacingBottom' || stylename === 'spacingLeft') {
result = parseFloat(shape[property]) - parseFloat(shape.spacing) != result = parseFloat(shape[property]) - parseFloat(shape.spacing) !==
(state.style[stylename] || defaultValue); (state.style[stylename] || defaultValue);
} else { } else {
result = shape[property] != (state.style[stylename] || defaultValue); result = shape[property] !== (state.style[stylename] || defaultValue);
} }
return result; return result;
@ -987,7 +988,7 @@ class mxCellRenderer {
let hpos = mxUtils.getValue(state.style, mxConstants.STYLE_LABEL_POSITION, mxConstants.ALIGN_CENTER); 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); 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); bounds = state.shape.getLabelBounds(bounds);
} }
} }
@ -1021,7 +1022,7 @@ class mxCellRenderer {
bounds.y -= state.text.margin.y * bounds.height; bounds.y -= state.text.margin.y * bounds.height;
bounds.x -= state.text.margin.x * bounds.width; 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 s = state.view.scale;
let spacing = state.text.getSpacing(); let spacing = state.text.getSpacing();
bounds.x += spacing.x * s; 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 vpos = mxUtils.getValue(state.style, mxConstants.STYLE_VERTICAL_LABEL_POSITION, mxConstants.ALIGN_MIDDLE);
let lw = mxUtils.getValue(state.style, mxConstants.STYLE_LABEL_WIDTH, null); 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.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.height = Math.max(0, bounds.height - ((vpos === mxConstants.ALIGN_MIDDLE) ? (state.text.spacingTop * s + state.text.spacingBottom * s) : 0));
} }
let theta = state.text.getTextRotation(); let theta = state.text.getTextRotation();
// Only needed if rotated around another center // 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 cx = state.getCenterX();
let cy = state.getCenterY(); 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 rad = theta * (Math.PI / 180);
let pt = mxUtils.getRotatedPoint(new mxPoint(bounds.x, bounds.y), let pt = mxUtils.getRotatedPoint(new mxPoint(bounds.x, bounds.y),
Math.cos(rad), Math.sin(rad), new mxPoint(cx, cy)); 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. * Returns true if the given shape must be repainted.
*/ */
isShapeInvalid = (state, shape) => { 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 && !shape.bounds.equals(state)) ||
(state.absolutePoints != null && !mxUtils.equalPoints(shape.points, state.absolutePoints)) (state.absolutePoints != null && !mxUtils.equalPoints(shape.points, state.absolutePoints))
}; };