From 9e9281fa8295f41d5b1e48a3a4033341c0895aef Mon Sep 17 00:00:00 2001 From: mcyph <20507948+mcyph@users.noreply.github.com> Date: Sun, 21 Mar 2021 19:59:52 +1100 Subject: [PATCH] fixed import and init errors --- src/mxgraph/handler/mxRubberband.js | 11 ++++-- src/mxgraph/shape/mxShape.js | 11 +++--- src/mxgraph/shape/mxSwimlane.js | 7 +--- src/mxgraph/util/mxAbstractCanvas2D.js | 35 ++++++++++---------- src/mxgraph/util/mxConstants.js | 12 +++---- src/mxgraph/util/mxPoint.js | 15 ++++----- src/mxgraph/util/mxRectangle.js | 24 +++++++++----- src/mxgraph/view/mxCellRenderer.js | 2 ++ src/mxgraph/view/mxCellState.js | 10 +++--- src/mxgraph/view/mxGraph.js | 8 +++++ src/mxgraph/view/mxGraphView.js | 46 ++++---------------------- 11 files changed, 80 insertions(+), 101 deletions(-) diff --git a/src/mxgraph/handler/mxRubberband.js b/src/mxgraph/handler/mxRubberband.js index bba9f53a0..ce9637f53 100644 --- a/src/mxgraph/handler/mxRubberband.js +++ b/src/mxgraph/handler/mxRubberband.js @@ -3,6 +3,13 @@ * Copyright (c) 2006-2016, Gaudenz Alder */ +import mxUtils from "../util/mxUtils"; +import mxEvent from "../util/mxEvent"; +import mxPoint from "../util/mxPoint"; +import mxMouseEvent from "../util/mxMouseEvent"; +import mxClient from "../mxClient"; +import mxRectangle from "../util/mxRectangle"; + class mxRubberband { /** * Variable: defaultOpacity @@ -81,7 +88,7 @@ class mxRubberband { let evtName = evt.getProperty('eventName'); let me = evt.getProperty('event'); - if (evtName == mxEvent.MOUSE_DOWN && this.isForceRubberbandEvent(me)) { + if (evtName === mxEvent.MOUSE_DOWN && this.isForceRubberbandEvent(me)) { let offset = mxUtils.getOffset(this.graph.container); let origin = mxUtils.getScrollOrigin(this.graph.container); origin.x -= offset.x; @@ -260,7 +267,7 @@ class mxRubberband { * Returns true if this handler is active. */ isActive = (sender, me) => { - return this.div != null && this.div.style.display != 'none'; + return this.div != null && this.div.style.display !== 'none'; }; /** diff --git a/src/mxgraph/shape/mxShape.js b/src/mxgraph/shape/mxShape.js index 19d2ceca9..3974b802c 100644 --- a/src/mxgraph/shape/mxShape.js +++ b/src/mxgraph/shape/mxShape.js @@ -217,13 +217,10 @@ class mxShape { * * Constructs a new shape. */ - constructor(...args) { - this._constructor(...args); - }; - - _constructor = (stencil) => { - this.stencil = stencil; - this.initStyles(); + constructor(stencil) { + if (stencil !== mxConstants.DO_NOTHING) { + this.stencil = stencil; + } }; /** diff --git a/src/mxgraph/shape/mxSwimlane.js b/src/mxgraph/shape/mxSwimlane.js index 89441228f..7da395d83 100644 --- a/src/mxgraph/shape/mxSwimlane.js +++ b/src/mxgraph/shape/mxSwimlane.js @@ -42,18 +42,13 @@ class mxSwimlane extends mxShape { * 1. This is stored in . */ constructor(bounds, fill, stroke, strokewidth) { - super(); + super(mxConstants.DO_NOTHING); this.bounds = bounds; this.fill = fill; this.stroke = stroke; this.strokewidth = (strokewidth != null) ? strokewidth : 1; }; - _constructor = () => { - // explicitly do nothing in - // overridden constructor in mxShape - }; - /** * Function: isRoundable * diff --git a/src/mxgraph/util/mxAbstractCanvas2D.js b/src/mxgraph/util/mxAbstractCanvas2D.js index a441643fd..8565bfec6 100644 --- a/src/mxgraph/util/mxAbstractCanvas2D.js +++ b/src/mxgraph/util/mxAbstractCanvas2D.js @@ -109,9 +109,8 @@ class mxAbstractCanvas2D { * * Holds the to convert image URLs. */ - this.converter = this.createUrlConverter(); - - this.reset(); + this.converter = this.mxAbstractCanvas2createUrlConverter(); + this.mxAbstractCanvas2reset(); }; /** @@ -129,7 +128,7 @@ class mxAbstractCanvas2D { * Resets the state of this canvas. */ mxAbstractCanvas2reset = () => { - this.state = this.createState(); + this.state = this.mxAbstractCanvas2createState(); this.states = []; }; @@ -201,8 +200,8 @@ class mxAbstractCanvas2D { this.lastX = args[i - 1]; this.lastY = args[i]; - this.path.push(this.format((this.lastX + s.dx) * s.scale)); - this.path.push(this.format((this.lastY + s.dy) * s.scale)); + this.path.push(this.mxAbstractCanvas2format((this.lastX + s.dx) * s.scale)); + this.path.push(this.mxAbstractCanvas2format((this.lastY + s.dy) * s.scale)); } } } @@ -312,7 +311,7 @@ class mxAbstractCanvas2D { * Sets the current fill color. */ mxAbstractCanvas2setFillColor = (value) => { - if (value == mxConstants.NONE) { + if (value === mxConstants.NONE) { value = null; } @@ -340,7 +339,7 @@ class mxAbstractCanvas2D { * Sets the current stroke color. */ mxAbstractCanvas2setStrokeColor = (value) => { - if (value == mxConstants.NONE) { + if (value === mxConstants.NONE) { value = null; } @@ -408,7 +407,7 @@ class mxAbstractCanvas2D { * Sets the current font color. */ mxAbstractCanvas2setFontColor = (value) => { - if (value == mxConstants.NONE) { + if (value === mxConstants.NONE) { value = null; } @@ -421,7 +420,7 @@ class mxAbstractCanvas2D { * Sets the current font background color. */ mxAbstractCanvas2setFontBackgroundColor = (value) => { - if (value == mxConstants.NONE) { + if (value === mxConstants.NONE) { value = null; } @@ -434,7 +433,7 @@ class mxAbstractCanvas2D { * Sets the current font border color. */ mxAbstractCanvas2setFontBorderColor = (value) => { - if (value == mxConstants.NONE) { + if (value === mxConstants.NONE) { value = null; } @@ -487,7 +486,7 @@ class mxAbstractCanvas2D { * Enables or disables and configures the current shadow. */ mxAbstractCanvas2setShadowColor = (value) => { - if (value == mxConstants.NONE) { + if (value === mxConstants.NONE) { value = null; } @@ -530,7 +529,7 @@ class mxAbstractCanvas2D { * Moves the current path the given coordinates. */ mxAbstractCanvas2moveTo = (x, y) => { - this.addOp(this.moveOp, x, y); + this.mxAbstractCanvas2addOp(this.mxAbstractCanvas2moveOp, x, y); }; /** @@ -539,7 +538,7 @@ class mxAbstractCanvas2D { * Draws a line to the given coordinates. Uses moveTo with the op argument. */ mxAbstractCanvas2lineTo = (x, y) => { - this.addOp(this.lineOp, x, y); + this.mxAbstractCanvas2addOp(this.mxAbstractCanvas2lineOp, x, y); }; /** @@ -548,7 +547,7 @@ class mxAbstractCanvas2D { * Adds a quadratic curve to the current path. */ mxAbstractCanvas2quadTo = (x1, y1, x2, y2) => { - this.addOp(this.quadOp, x1, y1, x2, y2); + this.mxAbstractCanvas2addOp(this.mxAbstractCanvas2quadOp, x1, y1, x2, y2); }; /** @@ -557,7 +556,7 @@ class mxAbstractCanvas2D { * Adds a bezier curve to the current path. */ mxAbstractCanvas2curveTo = (x1, y1, x2, y2, x3, y3) => { - this.addOp(this.curveOp, x1, y1, x2, y2, x3, y3); + this.mxAbstractCanvas2addOp(this.mxAbstractCanvas2curveOp, x1, y1, x2, y2, x3, y3); }; /** @@ -571,7 +570,7 @@ class mxAbstractCanvas2D { if (curves != null) { for (let i = 0; i < curves.length; i += 6) { - this.curveTo(curves[i], curves[i + 1], curves[i + 2], + this.mxAbstractCanvas2curveTo(curves[i], curves[i + 1], curves[i + 2], curves[i + 3], curves[i + 4], curves[i + 5]); } } @@ -583,7 +582,7 @@ class mxAbstractCanvas2D { * Closes the current path. */ mxAbstractCanvas2close = (x1, y1, x2, y2, x3, y3) => { - this.addOp(this.closeOp); + this.mxAbstractCanvas2addOp(this.mxAbstractCanvas2closeOp); }; /** diff --git a/src/mxgraph/util/mxConstants.js b/src/mxgraph/util/mxConstants.js index bb8431ff9..aa55fde94 100644 --- a/src/mxgraph/util/mxConstants.js +++ b/src/mxgraph/util/mxConstants.js @@ -4,9 +4,9 @@ * Updated to ES9 syntax by David Morrissey 2021 */ -import mxRectangle from "./mxRectangle"; - let mxConstants = { + DO_NOTHING: {}, + /** * Class: mxConstants * @@ -677,7 +677,7 @@ let mxConstants = { * Defines the rectangle for the A4 portrait page format. The dimensions * of this page format are 826x1169 pixels. */ - PAGE_FORMAT_A4_PORTRAIT: new mxRectangle(0, 0, 827, 1169), + PAGE_FORMAT_A4_PORTRAIT: [0, 0, 827, 1169], /** * Variable: PAGE_FORMAT_A4_PORTRAIT @@ -685,7 +685,7 @@ let mxConstants = { * Defines the rectangle for the A4 portrait page format. The dimensions * of this page format are 826x1169 pixels. */ - PAGE_FORMAT_A4_LANDSCAPE: new mxRectangle(0, 0, 1169, 827), + PAGE_FORMAT_A4_LANDSCAPE: [0, 0, 1169, 827], /** * Variable: PAGE_FORMAT_LETTER_PORTRAIT @@ -693,7 +693,7 @@ let mxConstants = { * Defines the rectangle for the Letter portrait page format. The * dimensions of this page format are 850x1100 pixels. */ - PAGE_FORMAT_LETTER_PORTRAIT: new mxRectangle(0, 0, 850, 1100), + PAGE_FORMAT_LETTER_PORTRAIT: [0, 0, 850, 1100], /** * Variable: PAGE_FORMAT_LETTER_PORTRAIT @@ -701,7 +701,7 @@ let mxConstants = { * Defines the rectangle for the Letter portrait page format. The dimensions * of this page format are 850x1100 pixels. */ - PAGE_FORMAT_LETTER_LANDSCAPE: new mxRectangle(0, 0, 1100, 850), + PAGE_FORMAT_LETTER_LANDSCAPE: [0, 0, 1100, 850], /** * Variable: NONE diff --git a/src/mxgraph/util/mxPoint.js b/src/mxgraph/util/mxPoint.js index bdf4e60d5..211ebb16f 100644 --- a/src/mxgraph/util/mxPoint.js +++ b/src/mxgraph/util/mxPoint.js @@ -5,6 +5,7 @@ */ import mxUtils from "../util/mxUtils"; +import mxConstants from "./mxConstants"; class mxPoint { /** @@ -30,17 +31,13 @@ class mxPoint { * Constructs a new point for the optional x and y coordinates. If no * coordinates are given, then the default values for and are used. */ - constructor(...args) { - // forward to this._constructor to allow not calling - // the constructor from mxRectangle/mxCellState - this._constructor(...args); + constructor(x, y) { + if (x !== mxConstants.DO_NOTHING) { + this.x = (x != null) ? x : 0; + this.y = (y != null) ? y : 0; + } }; - _constructor(x, y) { - this.x = (x != null) ? x : 0; - this.y = (y != null) ? y : 0; - } - /** * Function: equals * diff --git a/src/mxgraph/util/mxRectangle.js b/src/mxgraph/util/mxRectangle.js index eacb27063..387dac63a 100644 --- a/src/mxgraph/util/mxRectangle.js +++ b/src/mxgraph/util/mxRectangle.js @@ -16,6 +16,7 @@ */ import mxPoint from "./mxPoint"; +import mxConstants from "./mxConstants"; class mxRectangle extends mxPoint { /** @@ -31,15 +32,15 @@ class mxRectangle extends mxPoint { */ height = null; - constructor(...args) { - super(...args); - }; + constructor(x, y, width, height) { + super(mxConstants.DO_NOTHING); - _constructor(x, y, width, height) { - // replace super of mxPoint - this.width = (width != null) ? width : 0; - this.height = (height != null) ? height : 0; - } + if (x !== mxConstants.DO_NOTHING) { + // replace super of mxPoint + this.width = (width != null) ? width : 0; + this.height = (height != null) ? height : 0; + } + }; /** * Function: fromRectangle @@ -169,4 +170,11 @@ class mxRectangle extends mxPoint { }; } +// HACK: Prevent dependency problems with mxConstants +// importing mxRectangle and vice-versa +mxConstants.PAGE_FORMAT_A4_PORTRAIT = new mxRectangle(...mxConstants.PAGE_FORMAT_A4_PORTRAIT); +mxConstants.PAGE_FORMAT_A4_LANDSCAPE = new mxRectangle(...mxConstants.PAGE_FORMAT_A4_LANDSCAPE); +mxConstants.PAGE_FORMAT_LETTER_PORTRAIT = new mxRectangle(...mxConstants.PAGE_FORMAT_LETTER_PORTRAIT); +mxConstants.PAGE_FORMAT_LETTER_LANDSCAPE = new mxRectangle(...mxConstants.PAGE_FORMAT_LETTER_LANDSCAPE); + export default mxRectangle; diff --git a/src/mxgraph/view/mxCellRenderer.js b/src/mxgraph/view/mxCellRenderer.js index f7e7a124e..aa8022da2 100644 --- a/src/mxgraph/view/mxCellRenderer.js +++ b/src/mxgraph/view/mxCellRenderer.js @@ -23,6 +23,8 @@ import mxText from "../shape/mxText"; import mxConstants from "../util/mxConstants"; import mxUtils from "../util/mxUtils"; import mxRectangle from "../util/mxRectangle"; +import mxStencilRegistry from "../shape/mxStencilRegistry"; +import mxEvent from "../util/mxEvent"; class mxCellRenderer { /** diff --git a/src/mxgraph/view/mxCellState.js b/src/mxgraph/view/mxCellState.js index a8c759f8a..4cd3434b7 100644 --- a/src/mxgraph/view/mxCellState.js +++ b/src/mxgraph/view/mxCellState.js @@ -6,6 +6,7 @@ import mxPoint from "../util/mxPoint"; import mxRectangle from "../util/mxRectangle"; +import mxConstants from "../util/mxConstants"; class mxCellState extends mxRectangle { /** @@ -159,19 +160,16 @@ class mxCellState extends mxRectangle { * cell - that this state represents. * style - Array of key, value pairs that constitute the style. */ - constructor(...args) { - super(...args) - } + constructor(view, cell, style) { + super(mxConstants.DO_NOTHING) - _constructor(view, cell, style) { - // replace super of mxPoint/mxRectangle this.view = view; this.cell = cell; this.style = (style != null) ? style : {}; this.origin = new mxPoint(); this.absoluteOffset = new mxPoint(); - }; + } /** * Function: getPerimeterBounds diff --git a/src/mxgraph/view/mxGraph.js b/src/mxgraph/view/mxGraph.js index 67da38837..46a9a8a7a 100644 --- a/src/mxgraph/view/mxGraph.js +++ b/src/mxgraph/view/mxGraph.js @@ -39,6 +39,14 @@ import mxCell from "../model/mxCell"; import mxGraphModel from "../model/mxGraphModel"; import mxStylesheet from "./mxStylesheet"; +import mxChildChange from "../model/atomic_changes/mxChildChange"; +import mxGeometryChange from "../model/atomic_changes/mxGeometryChange"; +import mxRootChange from "../model/atomic_changes/mxRootChange"; +import mxStyleChange from "../model/atomic_changes/mxStyleChange"; +import mxTerminalChange from "../model/atomic_changes/mxTerminalChange"; +import mxValueChange from "../model/atomic_changes/mxValueChange"; + + class mxGraph extends mxEventSource { /** * Variable: mouseListeners diff --git a/src/mxgraph/view/mxGraphView.js b/src/mxgraph/view/mxGraphView.js index a3fe69733..90a3ce4e6 100644 --- a/src/mxgraph/view/mxGraphView.js +++ b/src/mxgraph/view/mxGraphView.js @@ -17,6 +17,9 @@ import mxUtils from "../util/mxUtils"; import mxLog from "../util/mxLog"; import mxResources from "../util/mxResources"; import mxCellState from "./mxCellState"; +import mxUndoableEdit from "../util/mxUndoableEdit"; +import mxImageShape from "../shape/mxImageShape"; +import mxMouseEvent from "../util/mxMouseEvent"; class mxGraphView extends mxEventSource { EMPTY_POINT = new mxPoint(); @@ -52,14 +55,6 @@ class mxGraphView extends mxEventSource { * graph container. Default is true. */ captureDocumentGesture = true; - /** - * Variable: optimizeVmlReflows - * - * Specifies if the should be hidden while rendering in IE8 standards - * mode and quirks mode. This will significantly improve rendering performance. - * Default is true. - */ - optimizeVmlReflows = true; /** * Variable: rendering * @@ -820,7 +815,8 @@ class mxGraphView extends mxEventSource { state.setVisibleTerminalState(this.validateCellState(this.getVisibleTerminal(cell, true), false), true); state.setVisibleTerminalState(this.validateCellState(this.getVisibleTerminal(cell, false), false), false); - + + alert(state); this.updateCellState(state); // Repaint happens immediately after the cell is validated @@ -860,6 +856,8 @@ class mxGraphView extends mxEventSource { * state - to be updated. */ updateCellState = (state) => { + alert("STATE:"+state); + alert(state.absoluteOffset) state.absoluteOffset.x = 0; state.absoluteOffset.y = 0; state.origin.x = 0; @@ -2208,8 +2206,6 @@ class mxGraphView extends mxEventSource { if (graph.dialect == mxConstants.DIALECT_SVG) { this.createSvg(); - } else if (graph.dialect == mxConstants.DIALECT_VML) { - this.createVml(); } else { this.createHtml(); } @@ -2415,34 +2411,6 @@ class mxGraphView extends mxEventSource { return pane; }; - /** - * Function: createVml - * - * Creates the DOM nodes for the VML display. - */ - createVml = () => { - let container = this.graph.container; - - if (container != null) { - let width = container.offsetWidth; - let height = container.offsetHeight; - this.canvas = this.createVmlPane(width, height); - this.canvas.style.overflow = 'hidden'; - - this.backgroundPane = this.createVmlPane(width, height); - this.drawPane = this.createVmlPane(width, height); - this.overlayPane = this.createVmlPane(width, height); - this.decoratorPane = this.createVmlPane(width, height); - - this.canvas.appendChild(this.backgroundPane); - this.canvas.appendChild(this.drawPane); - this.canvas.appendChild(this.overlayPane); - this.canvas.appendChild(this.decoratorPane); - - container.appendChild(this.canvas); - } - }; - /** * Function: createSvg *