reorganize directory structure and converting to typescript

development
mcyph 2021-04-02 13:08:03 +11:00
parent 589a75cdb5
commit 16ae8bb743
122 changed files with 1304 additions and 1241 deletions

View File

@ -1,3 +1,6 @@
{ {
"extends": "@ijsto" "extends": "@ijsto",
"rules": {
"newIsCap": false
}
} }

View File

@ -60,5 +60,5 @@ class mxCellAttributeChange {
} }
export default mxCellAttributeChange; export default mxCellAttributeChange;
import("../../io/mxGenericChangeCodec"); import("../io/mxGenericChangeCodec");

View File

@ -93,5 +93,5 @@ class mxChildChange {
} }
export default mxChildChange; export default mxChildChange;
import("../../io/mxChildChangeCodec"); import("../io/mxChildChangeCodec");

View File

@ -34,5 +34,5 @@ class mxCollapseChange {
} }
export default mxCollapseChange; export default mxCollapseChange;
import("../../io/mxGenericChangeCodec"); import("../io/mxGenericChangeCodec");

View File

@ -34,5 +34,5 @@ class mxGeometryChange {
} }
export default mxGeometryChange; export default mxGeometryChange;
import("../../io/mxGenericChangeCodec"); import("../io/mxGenericChangeCodec");

View File

@ -28,5 +28,5 @@ class mxRootChange {
} }
export default mxRootChange; export default mxRootChange;
import("../../io/mxRootChangeCodec"); import("../io/mxRootChangeCodec");

View File

@ -31,5 +31,5 @@ class mxStyleChange {
} }
export default mxStyleChange; export default mxStyleChange;
import("../../io/mxGenericChangeCodec"); import("../io/mxGenericChangeCodec");

View File

@ -36,5 +36,5 @@ class mxTerminalChange {
} }
export default mxTerminalChange; export default mxTerminalChange;
import("../../io/mxTerminalChangeCodec"); import("../io/mxTerminalChangeCodec");

View File

@ -31,5 +31,5 @@ class mxValueChange {
} }
export default mxValueChange; export default mxValueChange;
import("../../io/mxGenericChangeCodec"); import("../io/mxGenericChangeCodec");

View File

@ -34,5 +34,5 @@ class mxVisibleChange {
} }
export default mxVisibleChange; export default mxVisibleChange;
import("../../io/mxGenericChangeCodec"); import("../io/mxGenericChangeCodec");

View File

@ -6,7 +6,7 @@
import mxClient from '../mxClient'; import mxClient from '../mxClient';
import mxToolbar from '../util/gui/mxToolbar'; import mxToolbar from '../util/gui/mxToolbar';
import mxGeometry from '../model/mxGeometry'; import mxGeometry from '../util/datatypes/mxGeometry';
import mxUtils from '../util/mxUtils'; import mxUtils from '../util/mxUtils';
import mxEvent from '../util/event/mxEvent'; import mxEvent from '../util/event/mxEvent';

View File

@ -18,17 +18,17 @@ import mxCodec from '../io/mxCodec';
import mxWindow from '../util/gui/mxWindow'; import mxWindow from '../util/gui/mxWindow';
import mxForm from '../util/gui/mxForm'; import mxForm from '../util/gui/mxForm';
import mxOutline from '../view/graph/mxOutline'; import mxOutline from '../view/graph/mxOutline';
import mxCell from '../model/mxCell'; import mxCell from '../view/cell/mxCell';
import mxGeometry from '../model/mxGeometry'; import mxGeometry from '../util/datatypes/mxGeometry';
import mxConstants from '../util/mxConstants'; import mxConstants from '../util/mxConstants';
import mxGraph from '../view/graph/mxGraph'; import mxGraph from '../view/graph/mxGraph';
import mxSwimlaneManager from '../view/graph/mxSwimlaneManager'; import mxSwimlaneManager from '../view/graph/mxSwimlaneManager';
import mxLayoutManager from '../view/graph/mxLayoutManager'; import mxLayoutManager from '../view/graph/mxLayoutManager';
import mxRubberband from '../handler/mxRubberband'; import mxRubberband from '../handler/mxRubberband';
import mxEvent from '../util/event/mxEvent'; import mxEvent from '../util/event/mxEvent';
import mxRootChange from '../model/atomic_changes/mxRootChange'; import mxRootChange from '../atomic_changes/mxRootChange';
import mxValueChange from '../model/atomic_changes/mxValueChange'; import mxValueChange from '../atomic_changes/mxValueChange';
import mxCellAttributeChange from '../model/atomic_changes/mxCellAttributeChange'; import mxCellAttributeChange from '../atomic_changes/mxCellAttributeChange';
import mxPrintPreview from '../view/graph/mxPrintPreview'; import mxPrintPreview from '../view/graph/mxPrintPreview';
import mxClipboard from '../util/storage/mxClipboard'; import mxClipboard from '../util/storage/mxClipboard';
import mxLog from '../util/gui/mxLog'; import mxLog from '../util/gui/mxLog';

View File

@ -6,29 +6,40 @@
import mxConstants from '../util/mxConstants'; import mxConstants from '../util/mxConstants';
import mxEvent from '../util/event/mxEvent'; import mxEvent from '../util/event/mxEvent';
import mxRectangle from '../util/datatypes/mxRectangle'; import mxRectangle from '../util/datatypes/mxRectangle';
import mxCellState from "../view/cell/mxCellState";
import mxGraph from "../view/graph/mxGraph";
import mxShape from "../shape/mxShape";
class mxCellHighlight { class mxCellHighlight {
// TODO: Document me!!
highlightColor: string | null;
strokeWidth: number | null;
dashed: boolean | null;
opacity: number | null;
repaintHandler: Function | null;
shape: mxShape | null;
/** /**
* Variable: keepOnTop * Variable: keepOnTop
* *
* Specifies if the highlights should appear on top of everything * Specifies if the highlights should appear on top of everything
* else in the overlay pane. Default is false. * else in the overlay pane. Default is false.
*/ */
keepOnTop = false; keepOnTop: boolean = false;
/** /**
* Variable: graph * Variable: graph
* *
* Reference to the enclosing <mxGraph>. * Reference to the enclosing <mxGraph>.
*/ */
graph = null; graph: mxGraph | null = null;
/** /**
* Variable: state * Variable: state
* *
* Reference to the <mxCellState>. * Reference to the <mxCellState>.
*/ */
state = null; state: mxCellState | null = null;
/** /**
* Variable: spacing * Variable: spacing
@ -36,7 +47,7 @@ class mxCellHighlight {
* Specifies the spacing between the highlight for vertices and the vertex. * Specifies the spacing between the highlight for vertices and the vertex.
* Default is 2. * Default is 2.
*/ */
spacing = 2; spacing: number = 2;
/** /**
* Variable: resetHandler * Variable: resetHandler
@ -44,7 +55,7 @@ class mxCellHighlight {
* Holds the handler that automatically invokes reset if the highlight * Holds the handler that automatically invokes reset if the highlight
* should be hidden. * should be hidden.
*/ */
resetHandler = null; resetHandler: Function | null = null;
/** /**
* Class: mxCellHighlight * Class: mxCellHighlight
@ -60,16 +71,16 @@ class mxCellHighlight {
* *
* Constructs a cell highlight. * Constructs a cell highlight.
*/ */
constructor(graph, highlightColor, strokeWidth, dashed) { constructor(graph: mxGraph | null=null,
highlightColor: string=mxConstants.DEFAULT_VALID_COLOR,
strokeWidth: number=mxConstants.HIGHLIGHT_STROKEWIDTH,
dashed: boolean=false) {
if (graph != null) { if (graph != null) {
this.graph = graph; this.graph = graph;
this.highlightColor = this.highlightColor = highlightColor;
highlightColor != null this.strokeWidth = strokeWidth;
? highlightColor this.dashed = dashed;
: mxConstants.DEFAULT_VALID_COLOR;
this.strokeWidth =
strokeWidth != null ? strokeWidth : mxConstants.HIGHLIGHT_STROKEWIDTH;
this.dashed = dashed != null ? dashed : false;
this.opacity = mxConstants.HIGHLIGHT_OPACITY; this.opacity = mxConstants.HIGHLIGHT_OPACITY;
// Updates the marker if the graph changes // Updates the marker if the graph changes
@ -113,7 +124,7 @@ class mxCellHighlight {
* *
* color - String that represents the new highlight color. * color - String that represents the new highlight color.
*/ */
setHighlightColor(color) { setHighlightColor(color: string): void {
this.highlightColor = color; this.highlightColor = color;
if (this.shape != null) { if (this.shape != null) {
@ -126,7 +137,7 @@ class mxCellHighlight {
* *
* Creates and returns the highlight shape for the given state. * Creates and returns the highlight shape for the given state.
*/ */
drawHighlight() { drawHighlight(): void {
this.shape = this.createShape(); this.shape = this.createShape();
this.repaint(); this.repaint();
@ -146,7 +157,7 @@ class mxCellHighlight {
* *
* Creates and returns the highlight shape for the given state. * Creates and returns the highlight shape for the given state.
*/ */
createShape() { createShape(): mxShape {
const shape = this.graph.cellRenderer.createShape(this.state); const shape = this.graph.cellRenderer.createShape(this.state);
shape.svgStrokeTolerance = this.graph.tolerance; shape.svgStrokeTolerance = this.graph.tolerance;
@ -175,7 +186,7 @@ class mxCellHighlight {
* *
* Returns the stroke width. * Returns the stroke width.
*/ */
getStrokeWidth(state) { getStrokeWidth(state: mxCellState | null=null): number {
return this.strokeWidth; return this.strokeWidth;
} }
@ -184,7 +195,7 @@ class mxCellHighlight {
* *
* Updates the highlight after a change of the model or view. * Updates the highlight after a change of the model or view.
*/ */
repaint() { repaint(): void {
if (this.state != null && this.shape != null) { if (this.state != null && this.shape != null) {
this.shape.scale = this.state.view.scale; this.shape.scale = this.state.view.scale;
@ -220,7 +231,7 @@ class mxCellHighlight {
* *
* Resets the state of the cell marker. * Resets the state of the cell marker.
*/ */
hide() { hide(): void {
this.highlight(null); this.highlight(null);
} }
@ -229,7 +240,7 @@ class mxCellHighlight {
* *
* Marks the <markedState> and fires a <mark> event. * Marks the <markedState> and fires a <mark> event.
*/ */
highlight(state) { highlight(state: mxCellState): void {
if (this.state !== state) { if (this.state !== state) {
if (this.shape != null) { if (this.shape != null) {
this.shape.destroy(); this.shape.destroy();
@ -237,7 +248,6 @@ class mxCellHighlight {
} }
this.state = state; this.state = state;
if (this.state != null) { if (this.state != null) {
this.drawHighlight(); this.drawHighlight();
} }
@ -249,22 +259,21 @@ class mxCellHighlight {
* *
* Returns true if this highlight is at the given position. * Returns true if this highlight is at the given position.
*/ */
isHighlightAt(x, y) { isHighlightAt(x: number,
let hit = false; y: number): boolean {
let hit = false;
if (this.shape != null && document.elementFromPoint != null) { if (this.shape != null && document.elementFromPoint != null) {
let elt = document.elementFromPoint(x, y); let elt: Node & ParentNode = document.elementFromPoint(x, y);
while (elt != null) { while (elt != null) {
if (elt === this.shape.node) { if (elt === this.shape.node) {
hit = true; hit = true;
break; break;
} }
elt = elt.parentNode; elt = elt.parentNode;
} }
} }
return hit; return hit;
} }
@ -273,7 +282,7 @@ class mxCellHighlight {
* *
* Destroys the handler and all its resources and DOM nodes. * Destroys the handler and all its resources and DOM nodes.
*/ */
destroy() { destroy(): void {
this.graph.getView().removeListener(this.resetHandler); this.graph.getView().removeListener(this.resetHandler);
this.graph.getView().removeListener(this.repaintHandler); this.graph.getView().removeListener(this.repaintHandler);
this.graph.getModel().removeListener(this.repaintHandler); this.graph.getModel().removeListener(this.repaintHandler);

View File

@ -2,8 +2,8 @@
* Copyright (c) 2006-2016, JGraph Ltd * Copyright (c) 2006-2016, JGraph Ltd
* Copyright (c) 2006-2016, Gaudenz Alder * Copyright (c) 2006-2016, Gaudenz Alder
*/ */
import mxGeometry from '../model/mxGeometry'; import mxGeometry from '../util/datatypes/mxGeometry';
import mxCell from '../model/mxCell'; import mxCell from '../view/cell/mxCell';
import mxPoint from '../util/datatypes/mxPoint'; import mxPoint from '../util/datatypes/mxPoint';
import mxEventObject from '../util/event/mxEventObject'; import mxEventObject from '../util/event/mxEventObject';
import mxEvent from '../util/event/mxEvent'; import mxEvent from '../util/event/mxEvent';

View File

@ -4,7 +4,7 @@
* Updated to ES9 syntax by David Morrissey 2021 * Updated to ES9 syntax by David Morrissey 2021
*/ */
import mxCell from '../model/mxCell'; import mxCell from '../view/cell/mxCell';
import mxObjectCodec from './mxObjectCodec'; import mxObjectCodec from './mxObjectCodec';
import mxCodecRegistry from './mxCodecRegistry'; import mxCodecRegistry from './mxCodecRegistry';
import mxUtils from "../util/mxUtils"; import mxUtils from "../util/mxUtils";

View File

@ -4,7 +4,7 @@
* Updated to ES9 syntax by David Morrissey 2021 * Updated to ES9 syntax by David Morrissey 2021
*/ */
import mxChildChange from '../model/atomic_changes/mxChildChange'; import mxChildChange from '../atomic_changes/mxChildChange';
import mxObjectCodec from './mxObjectCodec'; import mxObjectCodec from './mxObjectCodec';
import mxCodecRegistry from './mxCodecRegistry'; import mxCodecRegistry from './mxCodecRegistry';
import mxUtils from '../util/mxUtils'; import mxUtils from '../util/mxUtils';

View File

@ -5,10 +5,10 @@
*/ */
import mxUtils from '../util/mxUtils'; import mxUtils from '../util/mxUtils';
import mxCellPath from '../model/mxCellPath'; import mxCellPath from '../view/cell/mxCellPath';
import mxCodecRegistry from "./mxCodecRegistry"; import mxCodecRegistry from "./mxCodecRegistry";
import mxConstants from "../util/mxConstants"; import mxConstants from "../util/mxConstants";
import mxCell from "../model/mxCell"; import mxCell from "../view/cell/mxCell";
import mxLog from "../util/gui/mxLog"; import mxLog from "../util/gui/mxLog";
class mxCodec { class mxCodec {

View File

@ -5,12 +5,12 @@
*/ */
import mxObjectCodec from './mxObjectCodec'; import mxObjectCodec from './mxObjectCodec';
import mxValueChange from '../model/atomic_changes/mxValueChange'; import mxValueChange from '../atomic_changes/mxValueChange';
import mxStyleChange from '../model/atomic_changes/mxStyleChange'; import mxStyleChange from '../atomic_changes/mxStyleChange';
import mxGeometryChange from '../model/atomic_changes/mxGeometryChange'; import mxGeometryChange from '../atomic_changes/mxGeometryChange';
import mxCollapseChange from '../model/atomic_changes/mxCollapseChange'; import mxCollapseChange from '../atomic_changes/mxCollapseChange';
import mxVisibleChange from '../model/atomic_changes/mxVisibleChange'; import mxVisibleChange from '../atomic_changes/mxVisibleChange';
import mxCellAttributeChange from '../model/atomic_changes/mxCellAttributeChange'; import mxCellAttributeChange from '../atomic_changes/mxCellAttributeChange';
import mxCodecRegistry from './mxCodecRegistry'; import mxCodecRegistry from './mxCodecRegistry';
import mxUtils from "../util/mxUtils"; import mxUtils from "../util/mxUtils";

View File

@ -4,7 +4,7 @@
* Updated to ES9 syntax by David Morrissey 2021 * Updated to ES9 syntax by David Morrissey 2021
*/ */
import mxGraphModel from '../model/mxGraphModel'; import mxGraphModel from '../view/graph/mxGraphModel';
import mxObjectCodec from './mxObjectCodec'; import mxObjectCodec from './mxObjectCodec';
import mxCodecRegistry from './mxCodecRegistry'; import mxCodecRegistry from './mxCodecRegistry';

View File

@ -6,7 +6,7 @@
import mxObjectIdentity from "../util/datatypes/mxObjectIdentity"; import mxObjectIdentity from "../util/datatypes/mxObjectIdentity";
import mxLog from "../util/gui/mxLog"; import mxLog from "../util/gui/mxLog";
import mxGeometry from "../model/mxGeometry"; import mxGeometry from "../util/datatypes/mxGeometry";
import mxPoint from "../util/datatypes/mxPoint"; import mxPoint from "../util/datatypes/mxPoint";
import mxConstants from "../util/mxConstants"; import mxConstants from "../util/mxConstants";
import mxUtils from "../util/mxUtils"; import mxUtils from "../util/mxUtils";

View File

@ -4,7 +4,7 @@
* Updated to ES9 syntax by David Morrissey 2021 * Updated to ES9 syntax by David Morrissey 2021
*/ */
import mxRootChange from '../model/atomic_changes/mxRootChange'; import mxRootChange from '../atomic_changes/mxRootChange';
import mxCodecRegistry from './mxCodecRegistry'; import mxCodecRegistry from './mxCodecRegistry';
import mxConstants from "../util/mxConstants"; import mxConstants from "../util/mxConstants";
import mxObjectCodec from "./mxObjectCodec"; import mxObjectCodec from "./mxObjectCodec";

View File

@ -5,7 +5,7 @@
*/ */
import mxObjectCodec from './mxObjectCodec'; import mxObjectCodec from './mxObjectCodec';
import mxTerminalChange from '../model/atomic_changes/mxTerminalChange'; import mxTerminalChange from '../atomic_changes/mxTerminalChange';
import mxCodecRegistry from "./mxCodecRegistry"; import mxCodecRegistry from "./mxCodecRegistry";
class mxTerminalChangeCodec extends mxObjectCodec { class mxTerminalChangeCodec extends mxObjectCodec {

View File

@ -6,7 +6,7 @@
import mxUtils from '../../../util/mxUtils'; import mxUtils from '../../../util/mxUtils';
import mxGraphHierarchyNode from './mxGraphHierarchyNode'; import mxGraphHierarchyNode from './mxGraphHierarchyNode';
import mxGraphHierarchyEdge from './mxGraphHierarchyEdge'; import mxGraphHierarchyEdge from './mxGraphHierarchyEdge';
import mxCellPath from '../../../model/mxCellPath'; import mxCellPath from '../../../view/cell/mxCellPath';
class mxSwimlaneModel { class mxSwimlaneModel {
/** /**

View File

@ -5,7 +5,7 @@
*/ */
import mxHierarchicalLayoutStage from './mxHierarchicalLayoutStage'; import mxHierarchicalLayoutStage from './mxHierarchicalLayoutStage';
import mxUtils from '../../../util/mxUtils'; import mxUtils from '../../../util/mxUtils';
import mxCellPath from '../../../model/mxCellPath'; import mxCellPath from '../../../view/cell/mxCellPath';
class mxSwimlaneOrdering extends mxHierarchicalLayoutStage { class mxSwimlaneOrdering extends mxHierarchicalLayoutStage {
/** /**

View File

@ -7,7 +7,7 @@
import mxDictionary from '../util/datatypes/mxDictionary'; import mxDictionary from '../util/datatypes/mxDictionary';
import mxPoint from '../util/datatypes/mxPoint'; import mxPoint from '../util/datatypes/mxPoint';
import mxGraphLayout from './mxGraphLayout'; import mxGraphLayout from './mxGraphLayout';
import mxCellPath from "../model/mxCellPath"; import mxCellPath from "../view/cell/mxCellPath";
import mxRectangle from "../util/datatypes/mxRectangle"; import mxRectangle from "../util/datatypes/mxRectangle";
import mxUtils from "../util/mxUtils"; import mxUtils from "../util/mxUtils";
import WeightedCellSorter from "./WeightedCellSorter"; import WeightedCellSorter from "./WeightedCellSorter";

View File

@ -6,7 +6,7 @@
import mxDictionary from '../util/datatypes/mxDictionary'; import mxDictionary from '../util/datatypes/mxDictionary';
import mxRectangle from '../util/datatypes/mxRectangle'; import mxRectangle from '../util/datatypes/mxRectangle';
import mxGeometry from '../model/mxGeometry'; import mxGeometry from '../util/datatypes/mxGeometry';
import mxPoint from '../util/datatypes/mxPoint'; import mxPoint from '../util/datatypes/mxPoint';
import mxConstants from '../util/mxConstants'; import mxConstants from '../util/mxConstants';

View File

@ -10,6 +10,7 @@ import mxPoint from '../util/datatypes/mxPoint';
import mxSvgCanvas2D from '../util/canvas/mxSvgCanvas2D'; import mxSvgCanvas2D from '../util/canvas/mxSvgCanvas2D';
import mxEvent from '../util/event/mxEvent'; import mxEvent from '../util/event/mxEvent';
import mxClient from '../mxClient'; import mxClient from '../mxClient';
import mxCellState from "../view/cell/mxCellState";
const toBool = i => { const toBool = i => {
if (i === 0) return false; if (i === 0) return false;
@ -22,69 +23,92 @@ const toBool = i => {
}; };
class mxShape { class mxShape {
// TODO: Document me!!
fill: string | null;
gradient: string | null;
gradientDirection: string | null;
opacity: number | null;
fillOpacity: number | null;
strokeOpacity: number | null;
stroke: string | null;
strokewidth: number | null;
spacing: number | null;
startSize: number | null;
endSize: number | null;
startArrow: FIXME;
endArrow: FIXME;
rotation: string;
direction: string;
flipH: boolean;
flipV: boolean;
isShadow: boolean;
isDashed: boolean;
isRounded: boolean;
glass: number;
/** /**
* Variable: dialect * Variable: dialect
* *
* Holds the dialect in which the shape is to be painted. * Holds the dialect in which the shape is to be painted.
* This can be one of the DIALECT constants in <mxConstants>. * This can be one of the DIALECT constants in <mxConstants>.
*/ */
dialect = null; dialect: string | null = null;
/** /**
* Variable: scale * Variable: scale
* *
* Holds the scale in which the shape is being painted. * Holds the scale in which the shape is being painted.
*/ */
scale = 1; scale: number = 1;
/** /**
* Variable: antiAlias * Variable: antiAlias
* *
* Rendering hint for configuring the canvas. * Rendering hint for configuring the canvas.
*/ */
antiAlias = true; antiAlias: boolean = true;
/** /**
* Variable: minSvgStrokeWidth * Variable: minSvgStrokeWidth
* *
* Minimum stroke width for SVG output. * Minimum stroke width for SVG output.
*/ */
minSvgStrokeWidth = 1; minSvgStrokeWidth: number = 1;
/** /**
* Variable: bounds * Variable: bounds
* *
* Holds the <mxRectangle> that specifies the bounds of this shape. * Holds the <mxRectangle> that specifies the bounds of this shape.
*/ */
bounds = null; bounds: mxRectangle | null = null;
/** /**
* Variable: points * Variable: points
* *
* Holds the array of <mxPoints> that specify the points of this shape. * Holds the array of <mxPoints> that specify the points of this shape.
*/ */
points = null; points: mxPoint[] | null = null;
/** /**
* Variable: node * Variable: node
* *
* Holds the outermost DOM node that represents this shape. * Holds the outermost DOM node that represents this shape.
*/ */
node = null; node: HTMLElement | null = null;
/** /**
* Variable: state * Variable: state
* *
* Optional reference to the corresponding <mxCellState>. * Optional reference to the corresponding <mxCellState>.
*/ */
state = null; state: mxCellState | null = null;
/** /**
* Variable: style * Variable: style
* *
* Optional reference to the style of the corresponding <mxCellState>. * Optional reference to the style of the corresponding <mxCellState>.
*/ */
style = null; style: FIXME = null;
/** /**
* Variable: boundingBox * Variable: boundingBox
@ -92,14 +116,14 @@ class mxShape {
* Contains the bounding box of the shape, that is, the smallest rectangle * Contains the bounding box of the shape, that is, the smallest rectangle
* that includes all pixels of the shape. * that includes all pixels of the shape.
*/ */
boundingBox = null; boundingBox: mxRectangle | null = null;
/** /**
* Variable: stencil * Variable: stencil
* *
* Holds the <mxStencil> that defines the shape. * Holds the <mxStencil> that defines the shape.
*/ */
stencil = null; stencil: mxStencil | null = null;
/** /**
* Variable: svgStrokeTolerance * Variable: svgStrokeTolerance
@ -107,21 +131,21 @@ class mxShape {
* Event-tolerance for SVG strokes (in px). Default is 8. This is only passed * Event-tolerance for SVG strokes (in px). Default is 8. This is only passed
* to the canvas in <createSvgCanvas> if <pointerEvents> is true. * to the canvas in <createSvgCanvas> if <pointerEvents> is true.
*/ */
svgStrokeTolerance = 8; svgStrokeTolerance: number = 8;
/** /**
* Variable: pointerEvents * Variable: pointerEvents
* *
* Specifies if pointer events should be handled. Default is true. * Specifies if pointer events should be handled. Default is true.
*/ */
pointerEvents = true; pointerEvents: boolean = true;
/** /**
* Variable: svgPointerEvents * Variable: svgPointerEvents
* *
* Specifies if pointer events should be handled. Default is true. * Specifies if pointer events should be handled. Default is 'all', meaning they will be.
*/ */
svgPointerEvents = 'all'; svgPointerEvents: string = 'all';
/** /**
* Variable: shapePointerEvents * Variable: shapePointerEvents
@ -129,7 +153,7 @@ class mxShape {
* Specifies if pointer events outside of shape should be handled. Default * Specifies if pointer events outside of shape should be handled. Default
* is false. * is false.
*/ */
shapePointerEvents = false; shapePointerEvents: boolean = false;
/** /**
* Variable: stencilPointerEvents * Variable: stencilPointerEvents
@ -137,7 +161,7 @@ class mxShape {
* Specifies if pointer events outside of stencils should be handled. Default * Specifies if pointer events outside of stencils should be handled. Default
* is false. Set this to true for backwards compatibility with the 1.x branch. * is false. Set this to true for backwards compatibility with the 1.x branch.
*/ */
stencilPointerEvents = false; stencilPointerEvents: boolean = false;
/** /**
* Variable: outline * Variable: outline
@ -147,14 +171,14 @@ class mxShape {
* not be painted for outlines. Default is false. This should be set before * not be painted for outlines. Default is false. This should be set before
* calling <apply>. * calling <apply>.
*/ */
outline = false; outline: boolean = false;
/** /**
* Variable: visible * Variable: visible
* *
* Specifies if the shape is visible. Default is true. * Specifies if the shape is visible. Default is true.
*/ */
visible = true; visible: boolean = true;
/** /**
* Variable: useSvgBoundingBox * Variable: useSvgBoundingBox
@ -162,7 +186,7 @@ class mxShape {
* Allows to use the SVG bounding box in SVG. Default is false for performance * Allows to use the SVG bounding box in SVG. Default is false for performance
* reasons. * reasons.
*/ */
useSvgBoundingBox = true; useSvgBoundingBox: boolean = true;
/** /**
* Class: mxShape * Class: mxShape
@ -222,7 +246,7 @@ class mxShape {
* *
* Constructs a new shape. * Constructs a new shape.
*/ */
constructor(stencil) { constructor(stencil: mxStencil) {
if (stencil !== mxConstants.DO_NOTHING) { if (stencil !== mxConstants.DO_NOTHING) {
this.stencil = stencil; this.stencil = stencil;
} }
@ -238,7 +262,7 @@ class mxShape {
* *
* container - DOM node that will contain the shape. * container - DOM node that will contain the shape.
*/ */
init(container) { init(container: HTMLElement | null=null) {
if (this.node == null) { if (this.node == null) {
this.node = this.create(container); this.node = this.create(container);
@ -357,13 +381,7 @@ class mxShape {
if (this.visible && this.checkBounds()) { if (this.visible && this.checkBounds()) {
this.node.style.visibility = 'visible'; this.node.style.visibility = 'visible';
this.clear(); this.clear();
this.redrawShape();
if (this.node.nodeName === 'DIV') {
this.redrawHtmlShape();
} else {
this.redrawShape();
}
this.updateBoundingBox(); this.updateBoundingBox();
} else { } else {
this.node.style.visibility = 'hidden'; this.node.style.visibility = 'hidden';
@ -565,7 +583,6 @@ class mxShape {
canvas.setDashed = () => {}; canvas.setDashed = () => {};
canvas.text = () => {}; canvas.text = () => {};
} }
return canvas; return canvas;
} }
@ -598,137 +615,6 @@ class mxShape {
return canvas; return canvas;
} }
/**
* Function: redrawHtml
*
* Allow optimization by replacing VML with HTML.
*/
redrawHtmlShape() {
// LATER: Refactor methods
this.updateHtmlBounds(this.node);
this.updateHtmlFilters(this.node);
this.updateHtmlColors(this.node);
}
/**
* Function: updateHtmlFilters
*
* Allow optimization by replacing VML with HTML.
*/
updateHtmlFilters(node) {
let f = '';
if (this.opacity < 100) {
f += `alpha(opacity=${this.opacity})`;
}
if (this.isShadow) {
// FIXME: Cannot implement shadow transparency with filter
f +=
`${'progid:DXImageTransform.Microsoft.dropShadow (' +
"OffX='"}${Math.round(mxConstants.SHADOW_OFFSET_X * this.scale)}', ` +
`OffY='${Math.round(mxConstants.SHADOW_OFFSET_Y * this.scale)}', ` +
`Color='${mxConstants.VML_SHADOWCOLOR}')`;
}
if (
this.fill != null &&
this.fill !== mxConstants.NONE &&
this.gradient &&
this.gradient !== mxConstants.NONE
) {
let start = this.fill;
let end = this.gradient;
let type = '0';
const lookup = { east: 0, south: 1, west: 2, north: 3 };
let dir = this.direction != null ? lookup[this.direction] : 0;
if (this.gradientDirection != null) {
dir = mxUtils.mod(dir + lookup[this.gradientDirection] - 1, 4);
}
if (dir === 1) {
type = '1';
const tmp = start;
start = end;
end = tmp;
} else if (dir === 2) {
const tmp = start;
start = end;
end = tmp;
} else if (dir === 3) {
type = '1';
}
f += `${'progid:DXImageTransform.Microsoft.gradient(' +
"startColorStr='"}${start}', endColorStr='${end}', gradientType='${type}')`;
}
node.style.filter = f;
}
/**
* Function: updateHtmlColors
*
* Allow optimization by replacing VML with HTML.
*/
updateHtmlColors(node) {
let color = this.stroke;
if (color != null && color !== mxConstants.NONE) {
node.style.borderColor = color;
if (this.isDashed) {
node.style.borderStyle = 'dashed';
} else if (this.strokewidth > 0) {
node.style.borderStyle = 'solid';
}
node.style.borderWidth = `${Math.max(
1,
Math.ceil(this.strokewidth * this.scale)
)}px`;
} else {
node.style.borderWidth = '0px';
}
color = this.outline ? null : this.fill;
if (color != null && color !== mxConstants.NONE) {
node.style.backgroundColor = color;
node.style.backgroundImage = 'none';
} else if (this.pointerEvents) {
node.style.backgroundColor = 'transparent';
} else if (document.documentMode === 8) {
mxUtils.addTransparentBackgroundFilter(node);
} else {
this.setTransparentBackgroundImage(node);
}
}
/**
* Function: updateHtmlBounds
*
* Allow optimization by replacing VML with HTML.
*/
updateHtmlBounds(node) {
let sw =
document.documentMode >= 9 ? 0 : Math.ceil(this.strokewidth * this.scale);
node.style.borderWidth = `${Math.max(1, sw)}px`;
node.style.overflow = 'hidden';
node.style.left = `${Math.round(this.bounds.x - sw / 2)}px`;
node.style.top = `${Math.round(this.bounds.y - sw / 2)}px`;
if (document.compatMode === 'CSS1Compat') {
sw = -sw;
}
node.style.width = `${Math.round(Math.max(0, this.bounds.width + sw))}px`;
node.style.height = `${Math.round(Math.max(0, this.bounds.height + sw))}px`;
}
/** /**
* Function: destroyCanvas * Function: destroyCanvas
* *
@ -1373,13 +1259,11 @@ class mxShape {
* *
* cursor - The cursor to be used. * cursor - The cursor to be used.
*/ */
setCursor(cursor) { setCursor(cursor: string | null=null) {
if (cursor == null) { if (cursor == null) {
cursor = ''; cursor = '';
} }
this.cursor = cursor; this.cursor = cursor;
if (this.node != null) { if (this.node != null) {
this.node.style.cursor = cursor; this.node.style.cursor = cursor;
} }
@ -1390,7 +1274,7 @@ class mxShape {
* *
* Returns the current cursor. * Returns the current cursor.
*/ */
getCursor() { getCursor(): string {
return this.cursor; return this.cursor;
} }
@ -1399,7 +1283,11 @@ class mxShape {
* *
* Hook for subclassers. * Hook for subclassers.
*/ */
isRoundable() { isRoundable(c: mxAbstractCanvas2D,
x: number,
y: number,
w: number,
h: number): boolean {
return false; return false;
} }
@ -1457,7 +1345,6 @@ class mxShape {
*/ */
createBoundingBox() { createBoundingBox() {
const bb = this.bounds.clone(); const bb = this.bounds.clone();
if ( if (
(this.stencil != null && (this.stencil != null &&
(this.direction === mxConstants.DIRECTION_NORTH || (this.direction === mxConstants.DIRECTION_NORTH ||
@ -1466,7 +1353,6 @@ class mxShape {
) { ) {
bb.rotate90(); bb.rotate90();
} }
return bb; return bb;
} }

View File

@ -4,6 +4,7 @@
* Updated to ES9 syntax by David Morrissey 2021 * Updated to ES9 syntax by David Morrissey 2021
*/ */
import mxActor from '../mxActor'; import mxActor from '../mxActor';
import mxAbstractCanvas2D from "../../util/canvas/mxAbstractCanvas2D";
class mxCloud extends mxActor { class mxCloud extends mxActor {
/** /**
@ -40,7 +41,12 @@ class mxCloud extends mxActor {
* *
* Draws the path for this shape. * Draws the path for this shape.
*/ */
redrawPath(c, x, y, w, h) { redrawPath(c: mxAbstractCanvas2D,
x: number,
y: number,
w: number,
h: number) {
c.moveTo(0.25 * w, 0.25 * h); c.moveTo(0.25 * w, 0.25 * h);
c.curveTo(0.05 * w, 0.25 * h, 0, 0.5 * h, 0.16 * w, 0.55 * h); c.curveTo(0.05 * w, 0.25 * h, 0, 0.5 * h, 0.16 * w, 0.55 * h);
c.curveTo(0, 0.66 * h, 0.18 * w, 0.9 * h, 0.31 * w, 0.8 * h); c.curveTo(0, 0.66 * h, 0.18 * w, 0.9 * h, 0.31 * w, 0.8 * h);

View File

@ -6,6 +6,7 @@
import mxShape from '../mxShape'; import mxShape from '../mxShape';
import mxConstants from '../../util/mxConstants'; import mxConstants from '../../util/mxConstants';
import mxUtils from '../../util/mxUtils'; import mxUtils from '../../util/mxUtils';
import mxAbstractCanvas2D from "../../util/canvas/mxAbstractCanvas2D";
class mxCylinder extends mxShape { class mxCylinder extends mxShape {
/** /**
@ -58,7 +59,11 @@ class mxCylinder extends mxShape {
* *
* Redirects to redrawPath for subclasses to work. * Redirects to redrawPath for subclasses to work.
*/ */
paintVertexShape(c, x, y, w, h) { paintVertexShape(c: mxAbstractCanvas2D,
x: number,
y: number,
w: number,
h: number) {
c.translate(x, y); c.translate(x, y);
c.begin(); c.begin();
this.redrawPath(c, x, y, w, h, false); this.redrawPath(c, x, y, w, h, false);
@ -90,7 +95,12 @@ class mxCylinder extends mxShape {
* *
* Draws the path for this shape. * Draws the path for this shape.
*/ */
redrawPath(c, x, y, w, h, isForeground) { redrawPath(c: mxAbstractCanvas2D,
x: number,
y: number,
w: number,
h: number,
isForeground: boolean=false) {
const dy = this.getCylinderSize(x, y, w, h); const dy = this.getCylinderSize(x, y, w, h);
if ( if (

View File

@ -8,6 +8,7 @@ import mxRectangle from '../../util/datatypes/mxRectangle';
import mxShape from '../mxShape'; import mxShape from '../mxShape';
import mxConstants from '../../util/mxConstants'; import mxConstants from '../../util/mxConstants';
import mxUtils from '../../util/mxUtils'; import mxUtils from '../../util/mxUtils';
import mxAbstractCanvas2D from "../../util/canvas/mxAbstractCanvas2D";
class mxDoubleEllipse extends mxShape { class mxDoubleEllipse extends mxShape {
/** /**
@ -64,7 +65,12 @@ class mxDoubleEllipse extends mxShape {
* *
* Paints the background. * Paints the background.
*/ */
paintBackground(c, x, y, w, h) { paintBackground(c: mxAbstractCanvas2D,
x: number,
y: number,
w: number,
h: number) {
c.ellipse(x, y, w, h); c.ellipse(x, y, w, h);
c.fillAndStroke(); c.fillAndStroke();
} }
@ -74,7 +80,12 @@ class mxDoubleEllipse extends mxShape {
* *
* Paints the foreground. * Paints the foreground.
*/ */
paintForeground(c, x, y, w, h) { paintForeground(c: mxAbstractCanvas2D,
x: number,
y: number,
w: number,
h: number) {
if (!this.outline) { if (!this.outline) {
const margin = mxUtils.getValue( const margin = mxUtils.getValue(
this.style, this.style,

View File

@ -4,6 +4,7 @@
* Updated to ES9 syntax by David Morrissey 2021 * Updated to ES9 syntax by David Morrissey 2021
*/ */
import mxShape from '../mxShape'; import mxShape from '../mxShape';
import mxAbstractCanvas2D from "../../util/canvas/mxAbstractCanvas2D";
class mxEllipse extends mxShape { class mxEllipse extends mxShape {
/** /**
@ -39,7 +40,11 @@ class mxEllipse extends mxShape {
* *
* Paints the ellipse shape. * Paints the ellipse shape.
*/ */
paintVertexShape(c, x, y, w, h) { paintVertexShape(c: mxAbstractCanvas2D,
x: number,
y: number,
w: number,
h: number) {
c.ellipse(x, y, w, h); c.ellipse(x, y, w, h);
c.fillAndStroke(); c.fillAndStroke();
} }

View File

@ -7,6 +7,7 @@ import mxActor from '../mxActor';
import mxPoint from '../../util/datatypes/mxPoint'; import mxPoint from '../../util/datatypes/mxPoint';
import mxUtils from '../../util/mxUtils'; import mxUtils from '../../util/mxUtils';
import mxConstants from '../../util/mxConstants'; import mxConstants from '../../util/mxConstants';
import mxAbstractCanvas2D from "../../util/canvas/mxAbstractCanvas2D";
class mxHexagon extends mxActor { class mxHexagon extends mxActor {
/** /**
@ -27,7 +28,12 @@ class mxHexagon extends mxActor {
* *
* Draws the path for this shape. * Draws the path for this shape.
*/ */
redrawPath(c, x, y, w, h) { redrawPath(c: mxAbstractCanvas2D,
x: number,
y: number,
w: number,
h: number) {
const arcSize = const arcSize =
mxUtils.getValue( mxUtils.getValue(
this.style, this.style,

View File

@ -7,8 +7,14 @@
import mxUtils from '../../util/mxUtils'; import mxUtils from '../../util/mxUtils';
import mxConstants from '../../util/mxConstants'; import mxConstants from '../../util/mxConstants';
import mxRectangleShape from './mxRectangleShape'; import mxRectangleShape from './mxRectangleShape';
import mxAbstractCanvas2D from "../../util/canvas/mxAbstractCanvas2D";
import mxRectangle from '../../util/datatypes/mxRectangle';
class mxImageShape extends mxRectangleShape { class mxImageShape extends mxRectangleShape {
// TODO: Document me!!
shadow: boolean;
image: string;
/** /**
* Variable: preserveImageAspect * Variable: preserveImageAspect
* *
@ -37,7 +43,12 @@ class mxImageShape extends mxRectangleShape {
* strokewidth - Optional integer that defines the stroke width. Default is * strokewidth - Optional integer that defines the stroke width. Default is
* 0. This is stored in <strokewidth>. * 0. This is stored in <strokewidth>.
*/ */
constructor(bounds, image, fill, stroke, strokewidth) { constructor(bounds: mxRectangle,
image: string,
fill: string,
stroke: string,
strokewidth: number=0) {
super(); super();
this.bounds = bounds; this.bounds = bounds;
this.image = image; this.image = image;
@ -112,7 +123,6 @@ class mxImageShape extends mxRectangleShape {
createHtml() { createHtml() {
const node = document.createElement('div'); const node = document.createElement('div');
node.style.position = 'absolute'; node.style.position = 'absolute';
return node; return node;
} }
@ -121,7 +131,11 @@ class mxImageShape extends mxRectangleShape {
* *
* Disables inherited roundable support. * Disables inherited roundable support.
*/ */
isRoundable(c, x, y, w, h) { isRoundable(c: mxAbstractCanvas2D,
x: number,
y: number,
w: number,
h: number) {
return false; return false;
} }
@ -130,7 +144,11 @@ class mxImageShape extends mxRectangleShape {
* *
* Generic background painting implementation. * Generic background painting implementation.
*/ */
paintVertexShape(c, x, y, w, h) { paintVertexShape(c: mxAbstractCanvas2D,
x: number,
y: number,
w: number,
h: number) {
if (this.image != null) { if (this.image != null) {
const fill = mxUtils.getValue( const fill = mxUtils.getValue(
this.style, this.style,

View File

@ -7,6 +7,8 @@
import mxConstants from '../../util/mxConstants'; import mxConstants from '../../util/mxConstants';
import mxUtils from '../../util/mxUtils'; import mxUtils from '../../util/mxUtils';
import mxShape from '../mxShape'; import mxShape from '../mxShape';
import mxAbstractCanvas2D from "../../util/canvas/mxAbstractCanvas2D";
import mxRectangle from '../../util/datatypes/mxRectangle';
class mxRectangleShape extends mxShape { class mxRectangleShape extends mxShape {
/** /**
@ -29,7 +31,10 @@ class mxRectangleShape extends mxShape {
* strokewidth - Optional integer that defines the stroke width. Default is * strokewidth - Optional integer that defines the stroke width. Default is
* 1. This is stored in <strokewidth>. * 1. This is stored in <strokewidth>.
*/ */
constructor(bounds, fill, stroke, strokewidth) { constructor(bounds: mxRectangle,
fill: string,
stroke: string,
strokewidth: number) {
super(); super();
this.bounds = bounds; this.bounds = bounds;
this.fill = fill; this.fill = fill;
@ -42,7 +47,7 @@ class mxRectangleShape extends mxShape {
* *
* Returns true for non-rounded, non-rotated shapes with no glass gradient. * Returns true for non-rounded, non-rotated shapes with no glass gradient.
*/ */
isHtmlAllowed() { isHtmlAllowed(): boolean {
let events = true; let events = true;
if (this.style != null) { if (this.style != null) {
@ -64,7 +69,11 @@ class mxRectangleShape extends mxShape {
* *
* Generic background painting implementation. * Generic background painting implementation.
*/ */
paintBackground(c, x, y, w, h) { paintBackground(c: mxAbstractCanvas2D,
x: number,
y: number,
w: number,
h: number): void {
let events = true; let events = true;
if (this.style != null) { if (this.style != null) {
@ -124,7 +133,11 @@ class mxRectangleShape extends mxShape {
* *
* Adds roundable support. * Adds roundable support.
*/ */
isRoundable(c, x, y, w, h) { isRoundable(c: mxAbstractCanvas2D,
x: number,
y: number,
w: number,
h: number): boolean {
return true; return true;
} }
@ -133,7 +146,11 @@ class mxRectangleShape extends mxShape {
* *
* Generic background painting implementation. * Generic background painting implementation.
*/ */
paintForeground(c, x, y, w, h) { paintForeground(c: mxAbstractCanvas2D,
x: number,
y: number,
w: number,
h: number): void {
if ( if (
this.glass && this.glass &&
!this.outline && !this.outline &&

View File

@ -7,6 +7,8 @@ import mxShape from '../mxShape';
import mxPoint from '../../util/datatypes/mxPoint'; import mxPoint from '../../util/datatypes/mxPoint';
import mxUtils from "../../util/mxUtils"; import mxUtils from "../../util/mxUtils";
import mxConstants from "../../util/mxConstants"; import mxConstants from "../../util/mxConstants";
import mxRectangle from "../../util/datatypes/mxRectangle";
import mxAbstractCanvas2D from "../../util/canvas/mxAbstractCanvas2D";
class mxRhombus extends mxShape { class mxRhombus extends mxShape {
/** /**
@ -29,12 +31,15 @@ class mxRhombus extends mxShape {
* strokewidth - Optional integer that defines the stroke width. Default is * strokewidth - Optional integer that defines the stroke width. Default is
* 1. This is stored in <strokewidth>. * 1. This is stored in <strokewidth>.
*/ */
constructor(bounds, fill, stroke, strokewidth) { constructor(bounds: mxRectangle,
fill: string,
stroke: string,
strokewidth: number=1) {
super(); super();
this.bounds = bounds; this.bounds = bounds;
this.fill = fill; this.fill = fill;
this.stroke = stroke; this.stroke = stroke;
this.strokewidth = strokewidth != null ? strokewidth : 1; this.strokewidth = strokewidth;
} }
/** /**
@ -42,7 +47,7 @@ class mxRhombus extends mxShape {
* *
* Adds roundable support. * Adds roundable support.
*/ */
isRoundable() { isRoundable(): boolean {
return true; return true;
} }
@ -51,7 +56,12 @@ class mxRhombus extends mxShape {
* *
* Generic painting implementation. * Generic painting implementation.
*/ */
paintVertexShape(c, x, y, w, h) { paintVertexShape(c: mxAbstractCanvas2D,
x: number,
y: number,
w: number,
h: number) {
const hw = w / 2; const hw = w / 2;
const hh = h / 2; const hh = h / 2;

View File

@ -4,12 +4,12 @@
* Updated to ES9 syntax by David Morrissey 2021 * Updated to ES9 syntax by David Morrissey 2021
*/ */
import mxConnectionConstraint from '../view/connection/mxConnectionConstraint'; import mxConnectionConstraint from '../../view/connection/mxConnectionConstraint';
import mxRectangle from '../util/datatypes/mxRectangle'; import mxRectangle from '../../util/datatypes/mxRectangle';
import mxShape from './mxShape'; import mxShape from '../mxShape';
import mxResources from "../util/mxResources"; import mxResources from "../../util/mxResources";
import mxUtils from "../util/mxUtils"; import mxUtils from "../../util/mxUtils";
import mxConstants from "../util/mxConstants"; import mxConstants from "../../util/mxConstants";
import mxStencilRegistry from "./mxStencilRegistry"; import mxStencilRegistry from "./mxStencilRegistry";
class mxStencil extends mxShape { class mxStencil extends mxShape {

View File

@ -4,9 +4,9 @@
* Updated to ES9 syntax by David Morrissey 2021 * Updated to ES9 syntax by David Morrissey 2021
*/ */
import mxPoint from '../util/datatypes/mxPoint'; import mxPoint from './mxPoint';
import mxRectangle from '../util/datatypes/mxRectangle'; import mxRectangle from './mxRectangle';
import mxUtils from '../util/mxUtils'; import mxUtils from '../mxUtils';
class mxGeometry extends mxRectangle { class mxGeometry extends mxRectangle {
/** /**

View File

@ -10,7 +10,7 @@ import mxConstants from './mxConstants';
import mxObjectIdentity from './datatypes/mxObjectIdentity'; import mxObjectIdentity from './datatypes/mxObjectIdentity';
import mxPoint from './datatypes/mxPoint'; import mxPoint from './datatypes/mxPoint';
import mxDictionary from './datatypes/mxDictionary'; import mxDictionary from './datatypes/mxDictionary';
import mxCellPath from '../model/mxCellPath'; import mxCellPath from '../view/cell/mxCellPath';
import mxRectangle from './datatypes/mxRectangle'; import mxRectangle from './datatypes/mxRectangle';
import mxTemporaryCellStates from '../view/cell/mxTemporaryCellStates'; import mxTemporaryCellStates from '../view/cell/mxTemporaryCellStates';
import mxCodec from '../io/mxCodec'; import mxCodec from '../io/mxCodec';

View File

@ -4,34 +4,40 @@
* Updated to ES9 syntax by David Morrissey 2021 * Updated to ES9 syntax by David Morrissey 2021
*/ */
import mxUtils from '../util/mxUtils'; import mxUtils from '../../util/mxUtils';
import mxConstants from '../util/mxConstants'; import mxConstants from '../../util/mxConstants';
import mxGeometry from "../../util/datatypes/mxGeometry";
import mxCellOverlay from "./mxCellOverlay";
class mxCell { class mxCell {
// TODO: Document me! // TODO: Document me!
// used by invalidate() of mxGraphView // used by invalidate() of mxGraphView
invalidating: boolean = false; invalidating: boolean = false;
onInit: Function | null = null;
// used by addCellOverlay() of mxGraph
overlays: mxCellOverlay[] | null = null;
/** /**
* Variable: id * Variable: id
* *
* Holds the Id. Default is null. * Holds the Id. Default is null.
*/ */
id = null; id: number | null = null;
/** /**
* Variable: value * Variable: value
* *
* Holds the user object. Default is null. * Holds the user object. Default is null.
*/ */
value = null; value: any = null;
/** /**
* Variable: geometry * Variable: geometry
* *
* Holds the <mxGeometry>. Default is null. * Holds the <mxGeometry>. Default is null.
*/ */
geometry = null; geometry: mxGeometry | null = null;
/** /**
* Variable: style * Variable: style
@ -39,77 +45,77 @@ class mxCell {
* Holds the style as a string of the form [(stylename|key=value);]. Default is * Holds the style as a string of the form [(stylename|key=value);]. Default is
* null. * null.
*/ */
style = null; style: string | null = null;
/** /**
* Variable: vertex * Variable: vertex
* *
* Specifies whether the cell is a vertex. Default is false. * Specifies whether the cell is a vertex. Default is false.
*/ */
vertex = false; vertex: boolean = false;
/** /**
* Variable: edge * Variable: edge
* *
* Specifies whether the cell is an edge. Default is false. * Specifies whether the cell is an edge. Default is false.
*/ */
edge = false; edge: boolean = false;
/** /**
* Variable: connectable * Variable: connectable
* *
* Specifies whether the cell is connectable. Default is true. * Specifies whether the cell is connectable. Default is true.
*/ */
connectable = true; connectable: boolean = true;
/** /**
* Variable: visible * Variable: visible
* *
* Specifies whether the cell is visible. Default is true. * Specifies whether the cell is visible. Default is true.
*/ */
visible = true; visible: boolean = true;
/** /**
* Variable: collapsed * Variable: collapsed
* *
* Specifies whether the cell is collapsed. Default is false. * Specifies whether the cell is collapsed. Default is false.
*/ */
collapsed = false; collapsed: boolean = false;
/** /**
* Variable: parent * Variable: parent
* *
* Reference to the parent cell. * Reference to the parent cell.
*/ */
parent = null; parent: mxCell | null = null;
/** /**
* Variable: source * Variable: source
* *
* Reference to the source terminal. * Reference to the source terminal.
*/ */
source = null; source: mxCell | null = null;
/** /**
* Variable: target * Variable: target
* *
* Reference to the target terminal. * Reference to the target terminal.
*/ */
target = null; target: mxCell | null = null;
/** /**
* Variable: children * Variable: children
* *
* Holds the child cells. * Holds the child cells.
*/ */
children = null; children: mxCell[] | null = null;
/** /**
* Variable: edges * Variable: edges
* *
* Holds the edges. * Holds the edges.
*/ */
edges = null; edges: mxCell[] | null = null;
/** /**
* Variable: mxTransient * Variable: mxTransient
@ -120,7 +126,7 @@ class mxCell {
* to mark transient fields since transient modifiers are not supported by * to mark transient fields since transient modifiers are not supported by
* the language. * the language.
*/ */
mxTransient = [ mxTransient: string[] = [
'id', 'id',
'value', 'value',
'parent', 'parent',
@ -192,7 +198,12 @@ class mxCell {
* geometry - Optional <mxGeometry> that specifies the geometry. * geometry - Optional <mxGeometry> that specifies the geometry.
* style - Optional formatted string that defines the style. * style - Optional formatted string that defines the style.
*/ */
constructor(value, geometry, style) { //onInit: Function | null;
constructor(value: any=null,
geometry: mxGeometry=null,
style: string=null) {
this.value = value; this.value = value;
this.setGeometry(geometry); this.setGeometry(geometry);
this.setStyle(style); this.setStyle(style);
@ -207,7 +218,7 @@ class mxCell {
* *
* Returns the Id of the cell as a string. * Returns the Id of the cell as a string.
*/ */
getId() { getId(): number {
return this.id; return this.id;
} }
@ -216,7 +227,7 @@ class mxCell {
* *
* Sets the Id of the cell to the given string. * Sets the Id of the cell to the given string.
*/ */
setId(id) { setId(id: number): void {
this.id = id; this.id = id;
} }
@ -226,7 +237,7 @@ class mxCell {
* Returns the user object of the cell. The user * Returns the user object of the cell. The user
* object is stored in <value>. * object is stored in <value>.
*/ */
getValue() { getValue(): any {
return this.value; return this.value;
} }
@ -236,7 +247,7 @@ class mxCell {
* Sets the user object of the cell. The user object * Sets the user object of the cell. The user object
* is stored in <value>. * is stored in <value>.
*/ */
setValue(value) { setValue(value: number): void {
this.value = value; this.value = value;
} }
@ -248,10 +259,9 @@ class mxCell {
* replaces the user object with the given value and * replaces the user object with the given value and
* returns the old user object. * returns the old user object.
*/ */
valueChanged(newValue) { valueChanged(newValue: any): any {
const previous = this.getValue(); const previous = this.getValue();
this.setValue(newValue); this.setValue(newValue);
return previous; return previous;
} }
@ -260,7 +270,7 @@ class mxCell {
* *
* Returns the <mxGeometry> that describes the <geometry>. * Returns the <mxGeometry> that describes the <geometry>.
*/ */
getGeometry() { getGeometry(): mxGeometry | null {
return this.geometry; return this.geometry;
} }
@ -269,7 +279,7 @@ class mxCell {
* *
* Sets the <mxGeometry> to be used as the <geometry>. * Sets the <mxGeometry> to be used as the <geometry>.
*/ */
setGeometry(geometry) { setGeometry(geometry: mxGeometry): void {
this.geometry = geometry; this.geometry = geometry;
} }
@ -278,7 +288,7 @@ class mxCell {
* *
* Returns a string that describes the <style>. * Returns a string that describes the <style>.
*/ */
getStyle() { getStyle(): string {
return this.style; return this.style;
} }
@ -287,7 +297,7 @@ class mxCell {
* *
* Sets the string to be used as the <style>. * Sets the string to be used as the <style>.
*/ */
setStyle(style) { setStyle(style: string): void {
this.style = style; this.style = style;
} }
@ -296,7 +306,7 @@ class mxCell {
* *
* Returns true if the cell is a vertex. * Returns true if the cell is a vertex.
*/ */
isVertex() { isVertex(): boolean {
return !!this.vertex; return !!this.vertex;
} }
@ -310,7 +320,7 @@ class mxCell {
* *
* vertex - Boolean that specifies if the cell is a vertex. * vertex - Boolean that specifies if the cell is a vertex.
*/ */
setVertex(vertex) { setVertex(vertex: boolean) {
this.vertex = vertex; this.vertex = vertex;
} }
@ -319,7 +329,7 @@ class mxCell {
* *
* Returns true if the cell is an edge. * Returns true if the cell is an edge.
*/ */
isEdge() { isEdge(): boolean {
return !!this.edge; return !!this.edge;
} }
@ -342,7 +352,7 @@ class mxCell {
* *
* Returns true if the cell is connectable. * Returns true if the cell is connectable.
*/ */
isConnectable() { isConnectable(): boolean {
return !!this.connectable; return !!this.connectable;
} }
@ -355,7 +365,7 @@ class mxCell {
* *
* connectable - Boolean that specifies the new connectable state. * connectable - Boolean that specifies the new connectable state.
*/ */
setConnectable(connectable) { setConnectable(connectable: boolean) {
this.connectable = connectable; this.connectable = connectable;
} }
@ -364,7 +374,7 @@ class mxCell {
* *
* Returns true if the cell is visibile. * Returns true if the cell is visibile.
*/ */
isVisible() { isVisible(): boolean {
return !!this.visible; return !!this.visible;
} }
@ -377,7 +387,7 @@ class mxCell {
* *
* visible - Boolean that specifies the new visible state. * visible - Boolean that specifies the new visible state.
*/ */
setVisible(visible) { setVisible(visible: boolean): void {
this.visible = visible; this.visible = visible;
} }
@ -386,7 +396,7 @@ class mxCell {
* *
* Returns true if the cell is collapsed. * Returns true if the cell is collapsed.
*/ */
isCollapsed() { isCollapsed(): boolean {
return !!this.collapsed; return !!this.collapsed;
} }
@ -399,7 +409,7 @@ class mxCell {
* *
* collapsed - Boolean that specifies the new collapsed state. * collapsed - Boolean that specifies the new collapsed state.
*/ */
setCollapsed(collapsed) { setCollapsed(collapsed: boolean): void {
this.collapsed = collapsed; this.collapsed = collapsed;
} }
@ -408,7 +418,7 @@ class mxCell {
* *
* Returns the cell's parent. * Returns the cell's parent.
*/ */
getParent() { getParent(): mxCell | null {
return this.parent; return this.parent;
} }
@ -421,7 +431,7 @@ class mxCell {
* *
* parent - <mxCell> that represents the new parent. * parent - <mxCell> that represents the new parent.
*/ */
setParent(parent) { setParent(parent: mxCell): void {
this.parent = parent; this.parent = parent;
} }
@ -435,7 +445,7 @@ class mxCell {
* source - Boolean that specifies if the source terminal should be * source - Boolean that specifies if the source terminal should be
* returned. * returned.
*/ */
getTerminal(source) { getTerminal(source: boolean=false): mxCell | null {
return source ? this.source : this.target; return source ? this.source : this.target;
} }
@ -528,7 +538,6 @@ class mxCell {
this.children.splice(index, 0, child); this.children.splice(index, 0, child);
} }
} }
return child; return child;
} }
@ -544,7 +553,7 @@ class mxCell {
* index - Integer that specifies the index of the child to be * index - Integer that specifies the index of the child to be
* removed. * removed.
*/ */
remove(index) { remove(index: number): mxCell | null {
let child = null; let child = null;
if (this.children != null && index >= 0) { if (this.children != null && index >= 0) {
child = this.getChildAt(index); child = this.getChildAt(index);
@ -627,11 +636,9 @@ class mxCell {
if (this.edges == null) { if (this.edges == null) {
this.edges = []; this.edges = [];
} }
this.edges.push(edge); this.edges.push(edge);
} }
} }
return edge; return edge;
} }
@ -674,7 +681,6 @@ class mxCell {
*/ */
removeFromTerminal(isSource) { removeFromTerminal(isSource) {
const terminal = this.getTerminal(isSource); const terminal = this.getTerminal(isSource);
if (terminal != null) { if (terminal != null) {
terminal.removeEdge(this, isSource); terminal.removeEdge(this, isSource);
} }
@ -692,7 +698,6 @@ class mxCell {
*/ */
hasAttribute(name) { hasAttribute(name) {
const userObject = this.getValue(); const userObject = this.getValue();
return userObject != null && return userObject != null &&
userObject.nodeType === mxConstants.NODETYPE_ELEMENT && userObject.nodeType === mxConstants.NODETYPE_ELEMENT &&
userObject.hasAttribute userObject.hasAttribute
@ -714,12 +719,10 @@ class mxCell {
*/ */
getAttribute(name, defaultValue) { getAttribute(name, defaultValue) {
const userObject = this.getValue(); const userObject = this.getValue();
const val = const val =
userObject != null && userObject.nodeType === mxConstants.NODETYPE_ELEMENT userObject != null && userObject.nodeType === mxConstants.NODETYPE_ELEMENT
? userObject.getAttribute(name) ? userObject.getAttribute(name)
: null; : null;
return val != null ? val : defaultValue; return val != null ? val : defaultValue;
} }
@ -733,9 +736,10 @@ class mxCell {
* name - Name of the attribute whose value should be set. * name - Name of the attribute whose value should be set.
* value - New value of the attribute. * value - New value of the attribute.
*/ */
setAttribute(name, value) { setAttribute(name: string,
const userObject = this.getValue(); value: any): void {
const userObject = this.getValue();
if ( if (
userObject != null && userObject != null &&
userObject.nodeType === mxConstants.NODETYPE_ELEMENT userObject.nodeType === mxConstants.NODETYPE_ELEMENT
@ -751,10 +755,9 @@ class mxCell {
* the user object. All fields in <mxTransient> are ignored * the user object. All fields in <mxTransient> are ignored
* during the cloning. * during the cloning.
*/ */
clone() { clone(): mxCell {
const clone = mxUtils.clone(this, this.mxTransient); const clone = mxUtils.clone(this, this.mxTransient);
clone.setValue(this.cloneValue()); clone.setValue(this.cloneValue());
return clone; return clone;
} }
@ -763,9 +766,8 @@ class mxCell {
* *
* Returns a clone of the cell's user object. * Returns a clone of the cell's user object.
*/ */
cloneValue() { cloneValue(): any {
let value = this.getValue(); let value = this.getValue();
if (value != null) { if (value != null) {
if (typeof value.clone === 'function') { if (typeof value.clone === 'function') {
value = value.clone(); value = value.clone();
@ -773,10 +775,9 @@ class mxCell {
value = value.cloneNode(true); value = value.cloneNode(true);
} }
} }
return value; return value;
} }
} }
export default mxCell; export default mxCell;
import("../io/mxCellCodec"); import("../../io/mxCellCodec");

View File

@ -11,7 +11,7 @@ import mxClient from '../../mxClient';
import mxConstants from '../../util/mxConstants'; import mxConstants from '../../util/mxConstants';
import mxText from '../../shape/mxText'; import mxText from '../../shape/mxText';
import mxGraph from '../graph/mxGraph'; import mxGraph from '../graph/mxGraph';
import mxCell from '../../model/mxCell'; import mxCell from './mxCell';
import mxMouseEvent from '../../util/event/mxMouseEvent'; import mxMouseEvent from '../../util/event/mxMouseEvent';
import mxCellState from './mxCellState'; import mxCellState from './mxCellState';
@ -341,7 +341,7 @@ class mxCellEditor {
* *
* Returns the current editing value. * Returns the current editing value.
*/ */
getCurrentValue(state) { getCurrentValue(state: mxCellState) {
return mxUtils.extractTextWithWhitespace(this.textarea.childNodes); return mxUtils.extractTextWithWhitespace(this.textarea.childNodes);
} }

View File

@ -164,7 +164,7 @@ class mxCellOverlay extends mxEventSource {
* state - <mxCellState> that represents the current state of the * state - <mxCellState> that represents the current state of the
* associated cell. * associated cell.
*/ */
getBounds(state) { getBounds(state: mxCellState) {
const isEdge = state.view.graph.getModel().isEdge(state.cell); const isEdge = state.view.graph.getModel().isEdge(state.cell);
const s = state.view.scale; const s = state.view.scale;
let pt = null; let pt = null;

View File

@ -3,34 +3,36 @@
* Copyright (c) 2006-2017, Gaudenz Alder * Copyright (c) 2006-2017, Gaudenz Alder
*/ */
import mxRectangleShape from '../../shape/mxRectangleShape'; import mxRectangleShape from '../../shape/node/mxRectangleShape';
import mxEllipse from '../../shape/mxEllipse'; import mxEllipse from '../../shape/node/mxEllipse';
import mxRhombus from '../../shape/mxRhombus'; import mxRhombus from '../../shape/node/mxRhombus';
import mxCylinder from '../../shape/mxCylinder'; import mxCylinder from '../../shape/node/mxCylinder';
import mxConnector from '../../shape/mxConnector'; import mxConnector from '../../shape/edge/mxConnector';
import mxActor from '../../shape/mxActor'; import mxActor from '../../shape/mxActor';
import mxTriangle from '../../shape/mxTriangle'; import mxTriangle from '../../shape/mxTriangle';
import mxHexagon from '../../shape/mxHexagon'; import mxHexagon from '../../shape/node/mxHexagon';
import mxCloud from '../../shape/mxCloud'; import mxCloud from '../../shape/node/mxCloud';
import mxLine from '../../shape/mxLine'; import mxLine from '../../shape/edge/mxLine';
import mxArrow from '../../shape/mxArrow'; import mxArrow from '../../shape/edge/mxArrow';
import mxArrowConnector from '../../shape/mxArrowConnector'; import mxArrowConnector from '../../shape/edge/mxArrowConnector';
import mxDoubleEllipse from '../../shape/mxDoubleEllipse'; import mxDoubleEllipse from '../../shape/node/mxDoubleEllipse';
import mxSwimlane from '../../shape/mxSwimlane'; import mxSwimlane from '../../shape/mxSwimlane';
import mxImageShape from '../../shape/mxImageShape'; import mxImageShape from '../../shape/node/mxImageShape';
import mxLabel from '../../shape/mxLabel'; import mxLabel from '../../shape/mxLabel';
import mxText from '../../shape/mxText'; import mxText from '../../shape/mxText';
import mxConstants from '../../util/mxConstants'; import mxConstants from '../../util/mxConstants';
import mxUtils from '../../util/mxUtils'; import mxUtils from '../../util/mxUtils';
import mxRectangle from '../../util/mxRectangle'; import mxRectangle from '../../util/datatypes/mxRectangle';
import mxStencilRegistry from '../../shape/mxStencilRegistry'; import mxStencilRegistry from '../../shape/node/mxStencilRegistry';
import mxEvent from '../../util/mxEvent'; import mxEvent from '../../util/event/mxEvent';
import mxClient from '../../mxClient'; import mxClient from '../../mxClient';
import mxMouseEvent from '../../util/mxMouseEvent'; import mxMouseEvent from '../../util/event/mxMouseEvent';
import mxDictionary from '../../util/mxDictionary'; import mxDictionary from '../../util/datatypes/mxDictionary';
import mxEventObject from '../../util/mxEventObject'; import mxEventObject from '../../util/event/mxEventObject';
import mxPoint from '../../util/mxPoint'; import mxPoint from '../../util/datatypes/mxPoint';
import mxShape from '../../shape/mxShape'; import mxShape from '../../shape/mxShape';
import mxCellState from "./mxCellState";
import mxCell from "./mxCell";
class mxCellRenderer { class mxCellRenderer {
/** /**
@ -47,21 +49,21 @@ class mxCellRenderer {
* *
* Defines the default shape for edges. Default is <mxConnector>. * Defines the default shape for edges. Default is <mxConnector>.
*/ */
defaultEdgeShape = mxConnector; defaultEdgeShape: mxShape = mxConnector;
/** /**
* Variable: defaultVertexShape * Variable: defaultVertexShape
* *
* Defines the default shape for vertices. Default is <mxRectangleShape>. * Defines the default shape for vertices. Default is <mxRectangleShape>.
*/ */
defaultVertexShape = mxRectangleShape; defaultVertexShape: mxShape = mxRectangleShape;
/** /**
* Variable: defaultTextShape * Variable: defaultTextShape
* *
* Defines the default shape for labels. Default is <mxText>. * Defines the default shape for labels. Default is <mxText>.
*/ */
defaultTextShape = mxText; defaultTextShape: mxShape = mxText;
/** /**
* Variable: legacyControlPosition * Variable: legacyControlPosition
@ -69,7 +71,7 @@ class mxCellRenderer {
* Specifies if the folding icon should ignore the horizontal * Specifies if the folding icon should ignore the horizontal
* orientation of a swimlane. Default is true. * orientation of a swimlane. Default is true.
*/ */
legacyControlPosition = true; legacyControlPosition: boolean = true;
/** /**
* Variable: legacySpacing * Variable: legacySpacing
@ -77,21 +79,21 @@ class mxCellRenderer {
* Specifies if spacing and label position should be ignored if overflow is * Specifies if spacing and label position should be ignored if overflow is
* fill or width. Default is true for backwards compatiblity. * fill or width. Default is true for backwards compatiblity.
*/ */
legacySpacing = true; legacySpacing: boolean = true;
/** /**
* Variable: antiAlias * Variable: antiAlias
* *
* Anti-aliasing option for new shapes. Default is true. * Anti-aliasing option for new shapes. Default is true.
*/ */
antiAlias = true; antiAlias: boolean = true;
/** /**
* Variable: minSvgStrokeWidth * Variable: minSvgStrokeWidth
* *
* Minimum stroke width for SVG output. * Minimum stroke width for SVG output.
*/ */
minSvgStrokeWidth = 1; minSvgStrokeWidth: number = 1;
/** /**
* Variable: forceControlClickHandler * Variable: forceControlClickHandler
@ -99,7 +101,7 @@ class mxCellRenderer {
* Specifies if the enabled state of the graph should be ignored in the control * Specifies if the enabled state of the graph should be ignored in the control
* click handler (to allow folding in disabled graphs). Default is false. * click handler (to allow folding in disabled graphs). Default is false.
*/ */
forceControlClickHandler = false; forceControlClickHandler: boolean = false;
/** /**
* Class: mxCellRenderer * Class: mxCellRenderer
@ -164,7 +166,7 @@ class mxCellRenderer {
* *
* state - <mxCellState> for which the shape should be initialized. * state - <mxCellState> for which the shape should be initialized.
*/ */
initializeShape(state) { initializeShape(state: mxCellState) {
state.shape.dialect = state.view.graph.dialect; state.shape.dialect = state.view.graph.dialect;
this.configureShape(state); this.configureShape(state);
state.shape.init(state.view.getDrawPane()); state.shape.init(state.view.getDrawPane());
@ -179,7 +181,7 @@ class mxCellRenderer {
* *
* state - <mxCellState> for which the shape should be created. * state - <mxCellState> for which the shape should be created.
*/ */
createShape(state) { createShape(state: mxCellState): mxShape {
let shape = null; let shape = null;
if (state.style != null) { if (state.style != null) {
@ -188,7 +190,6 @@ class mxCellRenderer {
const stencil = mxStencilRegistry.getStencil( const stencil = mxStencilRegistry.getStencil(
state.style[mxConstants.STYLE_SHAPE] state.style[mxConstants.STYLE_SHAPE]
); );
if (stencil != null) { if (stencil != null) {
shape = new mxShape(stencil); shape = new mxShape(stencil);
} else { } else {
@ -196,7 +197,6 @@ class mxCellRenderer {
shape = new ctor(); shape = new ctor();
} }
} }
return shape; return shape;
} }
@ -209,7 +209,7 @@ class mxCellRenderer {
* *
* state - <mxCellState> for which the indicator shape should be created. * state - <mxCellState> for which the indicator shape should be created.
*/ */
createIndicatorShape(state) { createIndicatorShape(state: mxCellState): mxShape {
state.shape.indicatorShape = this.getShape( state.shape.indicatorShape = this.getShape(
state.view.graph.getIndicatorShape(state) state.view.graph.getIndicatorShape(state)
); );
@ -220,7 +220,7 @@ class mxCellRenderer {
* *
* Returns the shape for the given name from <defaultShapes>. * Returns the shape for the given name from <defaultShapes>.
*/ */
getShape(name) { getShape(name: string): mxShape {
return name != null ? mxCellRenderer.defaultShapes[name] : null; return name != null ? mxCellRenderer.defaultShapes[name] : null;
} }
@ -229,7 +229,7 @@ class mxCellRenderer {
* *
* Returns the constructor to be used for creating the shape. * Returns the constructor to be used for creating the shape.
*/ */
getShapeConstructor(state) { getShapeConstructor(state: mxCellState) {
let ctor = this.getShape(state.style[mxConstants.STYLE_SHAPE]); let ctor = this.getShape(state.style[mxConstants.STYLE_SHAPE]);
if (ctor == null) { if (ctor == null) {
@ -250,7 +250,7 @@ class mxCellRenderer {
* *
* state - <mxCellState> for which the shape should be configured. * state - <mxCellState> for which the shape should be configured.
*/ */
configureShape(state) { configureShape(state: mxCellState) {
state.shape.apply(state); state.shape.apply(state);
state.shape.image = state.view.graph.getImage(state); state.shape.image = state.view.graph.getImage(state);
state.shape.indicatorColor = state.view.graph.getIndicatorColor(state); state.shape.indicatorColor = state.view.graph.getIndicatorColor(state);
@ -274,7 +274,7 @@ class mxCellRenderer {
* This implementation resolves these keywords on the fill, stroke * This implementation resolves these keywords on the fill, stroke
* and gradient color keys. * and gradient color keys.
*/ */
postConfigureShape(state) { postConfigureShape(state: mxCellState) {
if (state.shape != null) { if (state.shape != null) {
this.resolveColor( this.resolveColor(
state, state,
@ -294,7 +294,7 @@ class mxCellRenderer {
* Checks if the style of the given <mxCellState> contains 'inherit', * Checks if the style of the given <mxCellState> contains 'inherit',
* 'indicated' or 'swimlane' for colors that support those keywords. * 'indicated' or 'swimlane' for colors that support those keywords.
*/ */
checkPlaceholderStyles(state) { checkPlaceholderStyles(state: mxCellState) {
// LATER: Check if the color has actually changed // LATER: Check if the color has actually changed
if (state.style != null) { if (state.style != null) {
const values = ['inherit', 'swimlane', 'indicated']; const values = ['inherit', 'swimlane', 'indicated'];
@ -311,7 +311,6 @@ class mxCellRenderer {
} }
} }
} }
return false; return false;
} }
@ -389,7 +388,7 @@ class mxCellRenderer {
* *
* state - <mxCellState> for which the label should be created. * state - <mxCellState> for which the label should be created.
*/ */
getLabelValue(state) { getLabelValue(state: mxCellState) {
return state.view.graph.getLabel(state.cell); return state.view.graph.getLabel(state.cell);
} }
@ -540,7 +539,7 @@ class mxCellRenderer {
* *
* state - <mxCellState> for which the overlay should be created. * state - <mxCellState> for which the overlay should be created.
*/ */
createCellOverlays(state) { createCellOverlays(state: mxCellState) {
const { graph } = state.view; const { graph } = state.view;
const overlays = graph.getCellOverlays(state.cell); const overlays = graph.getCellOverlays(state.cell);
let dict = null; let dict = null;
@ -580,7 +579,6 @@ class mxCellRenderer {
shape.destroy(); shape.destroy();
}); });
} }
state.overlays = dict; state.overlays = dict;
} }
@ -645,7 +643,7 @@ class mxCellRenderer {
* *
* state - <mxCellState> for which the control should be created. * state - <mxCellState> for which the control should be created.
*/ */
createControl(state) { createControl(state: mxCellState) {
const { graph } = state.view; const { graph } = state.view;
const image = graph.getFoldingImage(state); const image = graph.getFoldingImage(state);
@ -678,16 +676,16 @@ class mxCellRenderer {
* *
* state - <mxCellState> whose control click handler should be returned. * state - <mxCellState> whose control click handler should be returned.
*/ */
createControlClickHandler(state) { createControlClickHandler(state: mxCellState): Function {
const { graph } = state.view; const { graph } = state.view;
return mxUtils.bind(this, function(evt) { return evt => {
if (this.forceControlClickHandler || graph.isEnabled()) { if (this.forceControlClickHandler || graph.isEnabled()) {
const collapse = !graph.isCellCollapsed(state.cell); const collapse = !graph.isCellCollapsed(state.cell);
graph.foldCells(collapse, false, [state.cell], null, evt); graph.foldCells(collapse, false, [state.cell], null, evt);
mxEvent.consume(evt); mxEvent.consume(evt);
} }
}); };
} }
/** /**
@ -702,7 +700,11 @@ class mxCellRenderer {
* handleEvents - Boolean indicating if mousedown and mousemove should fire events via the graph. * handleEvents - Boolean indicating if mousedown and mousemove should fire events via the graph.
* clickHandler - Optional function to implement clicks on the control. * clickHandler - Optional function to implement clicks on the control.
*/ */
initControl(state, control, handleEvents, clickHandler) { initControl(state,
control,
handleEvents,
clickHandler) {
const { graph } = state.view; const { graph } = state.view;
// In the special case where the label is in HTML and the display is SVG the image // In the special case where the label is in HTML and the display is SVG the image
@ -821,7 +823,7 @@ class mxCellRenderer {
* *
* state - <mxCellState> for which the event listeners should be isntalled. * state - <mxCellState> for which the event listeners should be isntalled.
*/ */
installListeners(state) { installListeners(state: mxCellState) {
const { graph } = state.view; const { graph } = state.view;
// Workaround for touch devices routing all events for a mouse // Workaround for touch devices routing all events for a mouse
@ -849,14 +851,14 @@ class mxCellRenderer {
mxEvent.addGestureListeners( mxEvent.addGestureListeners(
state.shape.node, state.shape.node,
mxUtils.bind(this, evt => { evt => {
if (this.isShapeEvent(state, evt)) { if (this.isShapeEvent(state, evt)) {
graph.fireMouseEvent( graph.fireMouseEvent(
mxEvent.MOUSE_DOWN, mxEvent.MOUSE_DOWN,
new mxMouseEvent(evt, state) new mxMouseEvent(evt, state)
); );
} }
}), },
mxUtils.bind(this, evt => { mxUtils.bind(this, evt => {
if (this.isShapeEvent(state, evt)) { if (this.isShapeEvent(state, evt)) {
graph.fireMouseEvent( graph.fireMouseEvent(
@ -865,14 +867,14 @@ class mxCellRenderer {
); );
} }
}), }),
mxUtils.bind(this, evt => { evt => {
if (this.isShapeEvent(state, evt)) { if (this.isShapeEvent(state, evt)) {
graph.fireMouseEvent( graph.fireMouseEvent(
mxEvent.MOUSE_UP, mxEvent.MOUSE_UP,
new mxMouseEvent(evt, getState(evt)) new mxMouseEvent(evt, getState(evt))
); );
} }
}) }
); );
// Uses double click timeout in mxGraph for quirks mode // Uses double click timeout in mxGraph for quirks mode
@ -880,12 +882,12 @@ class mxCellRenderer {
mxEvent.addListener( mxEvent.addListener(
state.shape.node, state.shape.node,
'dblclick', 'dblclick',
mxUtils.bind(this, evt => { evt => {
if (this.isShapeEvent(state, evt)) { if (this.isShapeEvent(state, evt)) {
graph.dblClick(evt, state.cell); graph.dblClick(evt, state.cell);
mxEvent.consume(evt); mxEvent.consume(evt);
} }
}) }
); );
} }
} }
@ -995,7 +997,7 @@ class mxCellRenderer {
* state - <mxCellState> whose label should be checked. * state - <mxCellState> whose label should be checked.
* shape - <mxText> shape to be checked. * shape - <mxText> shape to be checked.
*/ */
isTextShapeInvalid(state, shape) { isTextShapeInvalid(state: mxCellState, shape) {
function check(property, stylename, defaultValue) { function check(property, stylename, defaultValue) {
let result = false; let result = false;
@ -1057,7 +1059,7 @@ class mxCellRenderer {
* *
* shape - <mxText> shape to be redrawn. * shape - <mxText> shape to be redrawn.
*/ */
redrawLabelShape(shape) { redrawLabelShape(shape: mxShape): void {
shape.redraw(); shape.redraw();
} }
@ -1070,7 +1072,7 @@ class mxCellRenderer {
* *
* state - <mxCellState> whose label scale should be returned. * state - <mxCellState> whose label scale should be returned.
*/ */
getTextScale(state) { getTextScale(state: mxCellState): number {
return state.view.scale; return state.view.scale;
} }
@ -1083,7 +1085,7 @@ class mxCellRenderer {
* *
* state - <mxCellState> whose label bounds should be returned. * state - <mxCellState> whose label bounds should be returned.
*/ */
getLabelBounds(state) { getLabelBounds(state: mxCellState): mxRectangle {
const { graph } = state.view; const { graph } = state.view;
const { scale } = state.view; const { scale } = state.view;
const isEdge = graph.getModel().isEdge(state.cell); const isEdge = graph.getModel().isEdge(state.cell);
@ -1160,7 +1162,6 @@ class mxCellRenderer {
if (lw != null) { if (lw != null) {
bounds.width = parseFloat(lw) * scale; bounds.width = parseFloat(lw) * scale;
} }
if (!isEdge) { if (!isEdge) {
this.rotateLabelBounds(state, bounds); this.rotateLabelBounds(state, bounds);
} }
@ -1179,7 +1180,9 @@ class mxCellRenderer {
* state - <mxCellState> whose label bounds should be rotated. * state - <mxCellState> whose label bounds should be rotated.
* bounds - <mxRectangle> the rectangle to be rotated. * bounds - <mxRectangle> the rectangle to be rotated.
*/ */
rotateLabelBounds(state, bounds) { rotateLabelBounds(state: mxCellState,
bounds: mxRectangle) {
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;
@ -1489,7 +1492,9 @@ class mxCellRenderer {
* *
* state - <mxCellState> whose shapes should be returned. * state - <mxCellState> whose shapes should be returned.
*/ */
getShapesForState(state) { getShapesForState(state: mxCellState): [mxShape | null,
mxText | null,
mxShape | null] {
return [state.shape, state.text, state.control]; return [state.shape, state.text, state.control];
} }
@ -1509,10 +1514,13 @@ class mxCellRenderer {
* be drawn into the DOM. If this is false then redraw and/or reconfigure * be drawn into the DOM. If this is false then redraw and/or reconfigure
* will not be called on the shape. * will not be called on the shape.
*/ */
redraw(state, force, rendering) { redraw(state: mxCellState,
force: boolean=false,
rendering: boolean=true): void {
const shapeChanged = this.redrawShape(state, force, rendering); const shapeChanged = this.redrawShape(state, force, rendering);
if (state.shape != null && (rendering == null || rendering)) { if (state.shape != null && rendering) {
this.redrawLabel(state, shapeChanged); this.redrawLabel(state, shapeChanged);
this.redrawCellOverlays(state, shapeChanged); this.redrawCellOverlays(state, shapeChanged);
this.redrawControl(state, shapeChanged); this.redrawControl(state, shapeChanged);
@ -1528,7 +1536,10 @@ class mxCellRenderer {
* *
* state - <mxCellState> whose label should be redrawn. * state - <mxCellState> whose label should be redrawn.
*/ */
redrawShape(state, force, rendering) { redrawShape(state: mxCellState,
force: boolean=false,
rendering: boolean=true): boolean {
const { model } = state.view.graph; const { model } = state.view.graph;
let shapeChanged = false; let shapeChanged = false;
@ -1638,7 +1649,7 @@ class mxCellRenderer {
* *
* Invokes redraw on the shape of the given state. * Invokes redraw on the shape of the given state.
*/ */
doRedrawShape(state) { doRedrawShape(state: mxCellState) {
state.shape.redraw(); state.shape.redraw();
} }
@ -1666,7 +1677,7 @@ class mxCellRenderer {
* *
* state - <mxCellState> for which the shapes should be destroyed. * state - <mxCellState> for which the shapes should be destroyed.
*/ */
destroy(state) { destroy(state: mxCellState) {
if (state.shape != null) { if (state.shape != null) {
if (state.text != null) { if (state.text != null) {
state.text.destroy(); state.text.destroy();

View File

@ -7,21 +7,30 @@
import mxPoint from '../../util/datatypes/mxPoint'; import mxPoint from '../../util/datatypes/mxPoint';
import mxRectangle from '../../util/datatypes/mxRectangle'; import mxRectangle from '../../util/datatypes/mxRectangle';
import mxConstants from '../../util/mxConstants'; import mxConstants from '../../util/mxConstants';
import mxCell from "./mxCell";
import mxGraphView from "../graph/mxGraphView";
import mxShape from "../../shape/mxShape";
import mxText from "../../shape/mxText";
class mxCellState extends mxRectangle { class mxCellState extends mxRectangle {
// TODO: Document me!!
cellBounds: mxRectangle;
paintBounds: mxRectangle;
boundingBox: mxRectangle;
/** /**
* Variable: view * Variable: view
* *
* Reference to the enclosing <mxGraphView>. * Reference to the enclosing <mxGraphView>.
*/ */
view = null; view: mxGraphView | null = null;
/** /**
* Variable: cell * Variable: cell
* *
* Reference to the <mxCell> that is represented by this state. * Reference to the <mxCell> that is represented by this state.
*/ */
cell = null; cell: mxCell | null = null;
/** /**
* Variable: style * Variable: style
@ -29,21 +38,21 @@ class mxCellState extends mxRectangle {
* Contains an array of key, value pairs that represent the style of the * Contains an array of key, value pairs that represent the style of the
* cell. * cell.
*/ */
style = null; style: any | null = null; // TODO: Important - make the style type more strictly typed to allow for typescript checking of individual properties!!!
/** /**
* Variable: invalidStyle * Variable: invalidStyle
* *
* Specifies if the style is invalid. Default is false. * Specifies if the style is invalid. Default is false.
*/ */
invalidStyle = false; invalidStyle: boolean = false;
/** /**
* Variable: invalid * Variable: invalid
* *
* Specifies if the state is invalid. Default is true. * Specifies if the state is invalid. Default is true.
*/ */
invalid = true; invalid: boolean = true;
/** /**
* Variable: origin * Variable: origin
@ -51,7 +60,7 @@ class mxCellState extends mxRectangle {
* <mxPoint> that holds the origin for all child cells. Default is a new * <mxPoint> that holds the origin for all child cells. Default is a new
* empty <mxPoint>. * empty <mxPoint>.
*/ */
origin = null; origin: mxPoint | null = null;
/** /**
* Variable: absolutePoints * Variable: absolutePoints
@ -59,7 +68,7 @@ class mxCellState extends mxRectangle {
* Holds an array of <mxPoints> that represent the absolute points of an * Holds an array of <mxPoints> that represent the absolute points of an
* edge. * edge.
*/ */
absolutePoints = null; absolutePoints: mxPoint[] | null = null;
/** /**
* Variable: absoluteOffset * Variable: absoluteOffset
@ -68,35 +77,35 @@ class mxCellState extends mxRectangle {
* absolute coordinates of the label position. For vertices, this is the * absolute coordinates of the label position. For vertices, this is the
* offset of the label relative to the top, left corner of the vertex. * offset of the label relative to the top, left corner of the vertex.
*/ */
absoluteOffset = null; absoluteOffset: mxPoint | null = null;
/** /**
* Variable: visibleSourceState * Variable: visibleSourceState
* *
* Caches the visible source terminal state. * Caches the visible source terminal state.
*/ */
visibleSourceState = null; visibleSourceState: mxCellState | null = null;
/** /**
* Variable: visibleTargetState * Variable: visibleTargetState
* *
* Caches the visible target terminal state. * Caches the visible target terminal state.
*/ */
visibleTargetState = null; visibleTargetState: mxCellState | null = null;
/** /**
* Variable: terminalDistance * Variable: terminalDistance
* *
* Caches the distance between the end points for an edge. * Caches the distance between the end points for an edge.
*/ */
terminalDistance = 0; terminalDistance: number = 0;
/** /**
* Variable: length * Variable: length
* *
* Caches the length of an edge. * Caches the length of an edge.
*/ */
length = 0; length: number = 0;
/** /**
* Variable: segments * Variable: segments
@ -104,14 +113,14 @@ class mxCellState extends mxRectangle {
* Array of numbers that represent the cached length of each segment of the * Array of numbers that represent the cached length of each segment of the
* edge. * edge.
*/ */
segments = null; segments: number[] | null = null;
/** /**
* Variable: shape * Variable: shape
* *
* Holds the <mxShape> that represents the cell graphically. * Holds the <mxShape> that represents the cell graphically.
*/ */
shape = null; shape: mxShape | null = null;
/** /**
* Variable: text * Variable: text
@ -119,21 +128,21 @@ class mxCellState extends mxRectangle {
* Holds the <mxText> that represents the label of the cell. Thi smay be * Holds the <mxText> that represents the label of the cell. Thi smay be
* null if the cell has no label. * null if the cell has no label.
*/ */
text = null; text: mxText | null = null;
/** /**
* Variable: unscaledWidth * Variable: unscaledWidth
* *
* Holds the unscaled width of the state. * Holds the unscaled width of the state.
*/ */
unscaledWidth = null; unscaledWidth: number | null = null;
/** /**
* Variable: unscaledHeight * Variable: unscaledHeight
* *
* Holds the unscaled height of the state. * Holds the unscaled height of the state.
*/ */
unscaledHeight = null; unscaledHeight: number | null = null;
/** /**
* Class: mxCellState * Class: mxCellState
@ -160,7 +169,9 @@ class mxCellState extends mxRectangle {
* cell - <mxCell> that this state represents. * cell - <mxCell> that this state represents.
* style - Array of key, value pairs that constitute the style. * style - Array of key, value pairs that constitute the style.
*/ */
constructor(view, cell, style) { constructor(view: mxGraphView,
cell: mxCell,
style: {}) {
super(mxConstants.DO_NOTHING); super(mxConstants.DO_NOTHING);
this.view = view; this.view = view;
@ -182,13 +193,10 @@ class mxCellState extends mxRectangle {
* border - Optional border to be added around the perimeter bounds. * border - Optional border to be added around the perimeter bounds.
* bounds - Optional <mxRectangle> to be used as the initial bounds. * bounds - Optional <mxRectangle> to be used as the initial bounds.
*/ */
getPerimeterBounds(border, bounds) { getPerimeterBounds(border: number=0,
border = border || 0; bounds: mxRectangle=new mxRectangle(
bounds = this.x, this.y, this.width, this.height
bounds != null )): mxRectangle {
? bounds
: new mxRectangle(this.x, this.y, this.width, this.height);
if ( if (
this.shape != null && this.shape != null &&
this.shape.stencil != null && this.shape.stencil != null &&
@ -211,7 +219,6 @@ class mxCellState extends mxRectangle {
if (border !== 0) { if (border !== 0) {
bounds.grow(border); bounds.grow(border);
} }
return bounds; return bounds;
} }
@ -226,7 +233,8 @@ class mxCellState extends mxRectangle {
* isSource - Boolean that specifies if the first or last point should * isSource - Boolean that specifies if the first or last point should
* be assigned. * be assigned.
*/ */
setAbsoluteTerminalPoint(point, isSource) { setAbsoluteTerminalPoint(point: mxPoint,
isSource: boolean=false): void {
if (isSource) { if (isSource) {
if (this.absolutePoints == null) { if (this.absolutePoints == null) {
this.absolutePoints = []; this.absolutePoints = [];
@ -253,11 +261,10 @@ class mxCellState extends mxRectangle {
* *
* Sets the given cursor on the shape and text shape. * Sets the given cursor on the shape and text shape.
*/ */
setCursor(cursor) { setCursor(cursor: string): void {
if (this.shape != null) { if (this.shape != null) {
this.shape.setCursor(cursor); this.shape.setCursor(cursor);
} }
if (this.text != null) { if (this.text != null) {
this.text.setCursor(cursor); this.text.setCursor(cursor);
} }
@ -273,9 +280,8 @@ class mxCellState extends mxRectangle {
* source - Boolean that specifies if the source or target cell should be * source - Boolean that specifies if the source or target cell should be
* returned. * returned.
*/ */
getVisibleTerminal(source) { getVisibleTerminal(source: boolean=false): mxCell | null {
const tmp = this.getVisibleTerminalState(source); const tmp = this.getVisibleTerminalState(source);
return tmp != null ? tmp.cell : null; return tmp != null ? tmp.cell : null;
} }
@ -289,7 +295,7 @@ class mxCellState extends mxRectangle {
* source - Boolean that specifies if the source or target state should be * source - Boolean that specifies if the source or target state should be
* returned. * returned.
*/ */
getVisibleTerminalState(source) { getVisibleTerminalState(source: boolean=false): mxCellState | null {
return source ? this.visibleSourceState : this.visibleTargetState; return source ? this.visibleSourceState : this.visibleTargetState;
} }
@ -303,7 +309,8 @@ class mxCellState extends mxRectangle {
* terminalState - <mxCellState> that represents the terminal. * terminalState - <mxCellState> that represents the terminal.
* source - Boolean that specifies if the source or target state should be set. * source - Boolean that specifies if the source or target state should be set.
*/ */
setVisibleTerminalState(terminalState, source) { setVisibleTerminalState(terminalState: mxCellState,
source: boolean=false): void {
if (source) { if (source) {
this.visibleSourceState = terminalState; this.visibleSourceState = terminalState;
} else { } else {
@ -316,7 +323,7 @@ class mxCellState extends mxRectangle {
* *
* Returns the unscaled, untranslated bounds. * Returns the unscaled, untranslated bounds.
*/ */
getCellBounds() { getCellBounds(): mxRectangle {
return this.cellBounds; return this.cellBounds;
} }
@ -327,7 +334,7 @@ class mxCellState extends mxRectangle {
* <getCellBounds> but with a 90 degree rotation if the shape's * <getCellBounds> but with a 90 degree rotation if the shape's
* isPaintBoundsInverted returns true. * isPaintBoundsInverted returns true.
*/ */
getPaintBounds() { getPaintBounds(): mxRectangle {
return this.paintBounds; return this.paintBounds;
} }
@ -336,7 +343,7 @@ class mxCellState extends mxRectangle {
* *
* Updates the cellBounds and paintBounds. * Updates the cellBounds and paintBounds.
*/ */
updateCachedBounds() { updateCachedBounds(): void {
const tr = this.view.translate; const tr = this.view.translate;
const s = this.view.scale; const s = this.view.scale;
this.cellBounds = new mxRectangle( this.cellBounds = new mxRectangle(
@ -357,7 +364,7 @@ class mxCellState extends mxRectangle {
* *
* Copies all fields from the given state to this state. * Copies all fields from the given state to this state.
*/ */
setState(state) { setState(state: mxCellState): void {
this.view = state.view; this.view = state.view;
this.cell = state.cell; this.cell = state.cell;
this.style = state.style; this.style = state.style;
@ -381,7 +388,7 @@ class mxCellState extends mxRectangle {
* *
* Returns a clone of this <mxPoint>. * Returns a clone of this <mxPoint>.
*/ */
clone() { clone(): mxCellState {
const clone = new mxCellState(this.view, this.cell, this.style); const clone = new mxCellState(this.view, this.cell, this.style);
// Clones the absolute points // Clones the absolute points
@ -423,7 +430,7 @@ class mxCellState extends mxRectangle {
* *
* Destroys the state and all associated resources. * Destroys the state and all associated resources.
*/ */
destroy() { destroy(): void {
this.view.graph.cellRenderer.destroy(this); this.view.graph.cellRenderer.destroy(this);
} }
} }

View File

@ -11,34 +11,30 @@
import mxRectangle from '../../util/datatypes/mxRectangle'; import mxRectangle from '../../util/datatypes/mxRectangle';
import mxDictionary from '../../util/datatypes/mxDictionary'; import mxDictionary from '../../util/datatypes/mxDictionary';
import mxGraphView from "../graph/mxGraphView"; import mxGraphView from "../graph/mxGraphView";
import mxCell from "../../model/mxCell"; import mxCell from "./mxCell";
import mxCellState from "./mxCellState";
class mxTemporaryCellStates { class mxTemporaryCellStates {
oldValidateCellState: Function | null;
oldDoRedrawShape: Function | null;
/** /**
* Variable: view * Variable: view
*
* Holds the width of the rectangle. Default is 0.
*/ */
view: mxGraphView | null = null; view: mxGraphView | null = null;
/** /**
* Variable: oldStates * Variable: oldStates
*
* Holds the height of the rectangle. Default is 0.
*/ */
oldStates: number = 0; oldStates: mxCellState | null = null;
/** /**
* Variable: oldBounds * Variable: oldBounds
*
* Holds the height of the rectangle. Default is 0.
*/ */
oldBounds: number = 0; oldBounds: mxRectangle | null = null;
/** /**
* Variable: oldScale * Variable: oldScale
*
* Holds the height of the rectangle. Default is 0.
*/ */
oldScale: number = 0; oldScale: number = 0;
@ -117,7 +113,7 @@ class mxTemporaryCellStates {
* *
* Returns the top, left corner as a new <mxPoint>. * Returns the top, left corner as a new <mxPoint>.
*/ */
destroy() { destroy(): void {
this.view.setScale(this.oldScale); this.view.setScale(this.oldScale);
this.view.setStates(this.oldStates); this.view.setStates(this.oldStates);
this.view.setGraphBounds(this.oldBounds); this.view.setGraphBounds(this.oldBounds);

View File

@ -1,9 +1,9 @@
import mxGraphView from "./mxGraphView"; import mxGraphView from "./mxGraphView";
import mxEventObject from "../../util/event/mxEventObject"; import mxEventObject from "../../util/event/mxEventObject";
import mxPoint from "../../util/datatypes/mxPoint"; import mxPoint from "../../util/datatypes/mxPoint";
import mxCell from "../../model/mxCell"; import mxCell from "../cell/mxCell";
import mxEvent from "../../util/event/mxEvent"; import mxEvent from "../../util/event/mxEvent";
import mxGraphModel from "../../model/mxGraphModel"; import mxGraphModel from "./mxGraphModel";
class mxCurrentRootChange { class mxCurrentRootChange {
view: mxGraphView; view: mxGraphView;

View File

@ -33,19 +33,19 @@ import mxEdgeSegmentHandler from '../../handler/mxEdgeSegmentHandler';
import mxElbowEdgeHandler from '../../handler/mxElbowEdgeHandler'; import mxElbowEdgeHandler from '../../handler/mxElbowEdgeHandler';
import mxMouseEvent from '../../util/event/mxMouseEvent'; import mxMouseEvent from '../../util/event/mxMouseEvent';
import mxResources from '../../util/mxResources'; import mxResources from '../../util/mxResources';
import mxGeometry from '../../model/mxGeometry'; import mxGeometry from '../../util/datatypes/mxGeometry';
import mxCell from '../../model/mxCell'; import mxCell from '../cell/mxCell';
import mxGraphModel from '../../model/mxGraphModel'; import mxGraphModel from './mxGraphModel';
import mxStylesheet from '../style/mxStylesheet'; import mxStylesheet from '../style/mxStylesheet';
import mxConstants from '../../util/mxConstants'; import mxConstants from '../../util/mxConstants';
import mxMultiplicity from "../connection/mxMultiplicity"; import mxMultiplicity from "../connection/mxMultiplicity";
import mxChildChange from '../../model/atomic_changes/mxChildChange'; import mxChildChange from '../../atomic_changes/mxChildChange';
import mxGeometryChange from '../../model/atomic_changes/mxGeometryChange'; import mxGeometryChange from '../../atomic_changes/mxGeometryChange';
import mxRootChange from '../../model/atomic_changes/mxRootChange'; import mxRootChange from '../../atomic_changes/mxRootChange';
import mxStyleChange from '../../model/atomic_changes/mxStyleChange'; import mxStyleChange from '../../atomic_changes/mxStyleChange';
import mxTerminalChange from '../../model/atomic_changes/mxTerminalChange'; import mxTerminalChange from '../../atomic_changes/mxTerminalChange';
import mxValueChange from '../../model/atomic_changes/mxValueChange'; import mxValueChange from '../../atomic_changes/mxValueChange';
import mxPolyline from '../../shape/edge/mxPolyline'; import mxPolyline from '../../shape/edge/mxPolyline';
import mxCellState from '../cell/mxCellState'; import mxCellState from '../cell/mxCellState';
@ -60,6 +60,21 @@ class mxGraph extends mxEventSource {
connectionHandler: mxConnectionHandler | null = null; connectionHandler: mxConnectionHandler | null = null;
graphHandler: mxGraphHandler | null = null; graphHandler: mxGraphHandler | null = null;
graphModelChangeListener: Function | null = null; graphModelChangeListener: Function | null = null;
shiftPreview1: HTMLElement | null;
shiftPreview2: HTMLElement | null;
panningManager: mxPanningManager | null;
lastTouchEvent: mxMouseEvent | null;
doubleClickCounter: number | null;
lastTouchCell: mxCell | null;
fireDoubleClick: boolean | null;
tapAndHoldThread: number | null;
lastMouseX: number;
lastMouseY: number;
isMouseTrigger: boolean;
ignoreMouseEvents: boolean;
mouseMoveRedirect: Function;
mouseUpRedirect: Function;
lastEvent: any; // FIXME: Check if this can be more specific - DOM events or mxEventObjects!
/** /**
* Variable: mouseListeners * Variable: mouseListeners
@ -2146,16 +2161,15 @@ class mxGraph extends mxEventSource {
* cell - <mxCell> to add the overlay for. * cell - <mxCell> to add the overlay for.
* overlay - <mxCellOverlay> to be added for the cell. * overlay - <mxCellOverlay> to be added for the cell.
*/ */
addCellOverlay(cell, overlay) { addCellOverlay(cell: mxCell,
overlay: mxCellOverlay): mxCellOverlay {
if (cell.overlays == null) { if (cell.overlays == null) {
cell.overlays = []; cell.overlays = [];
} }
cell.overlays.push(overlay); cell.overlays.push(overlay);
// Immediately update the cell display if the state exists
const state = this.view.getState(cell); const state = this.view.getState(cell);
// Immediately updates the cell display if the state exists
if (state != null) { if (state != null) {
this.cellRenderer.redraw(state); this.cellRenderer.redraw(state);
} }
@ -2163,7 +2177,6 @@ class mxGraph extends mxEventSource {
this.fireEvent( this.fireEvent(
new mxEventObject(mxEvent.ADD_OVERLAY, 'cell', cell, 'overlay', overlay) new mxEventObject(mxEvent.ADD_OVERLAY, 'cell', cell, 'overlay', overlay)
); );
return overlay; return overlay;
} }
@ -2412,7 +2425,8 @@ class mxGraph extends mxEventSource {
* cell - <mxCell> for which the initial editing value should be returned. * cell - <mxCell> for which the initial editing value should be returned.
* evt - Optional mouse event that triggered the editor. * evt - Optional mouse event that triggered the editor.
*/ */
getEditingValue(cell, evt) { getEditingValue(cell: mxCell,
evt: mxEventObject): string {
return this.convertValueToString(cell); return this.convertValueToString(cell);
} }
@ -2424,9 +2438,9 @@ class mxGraph extends mxEventSource {
* Parameters: * Parameters:
* *
* cancel - Boolean that specifies if the current editing value * cancel - Boolean that specifies if the current editing value
* should be stored. * shouldn't be stored.
*/ */
stopEditing(cancel) { stopEditing(cancel: boolean=false): void {
this.cellEditor.stopEditing(cancel); this.cellEditor.stopEditing(cancel);
this.fireEvent( this.fireEvent(
new mxEventObject(mxEvent.EDITING_STOPPED, 'cancel', cancel) new mxEventObject(mxEvent.EDITING_STOPPED, 'cancel', cancel)
@ -2447,8 +2461,8 @@ class mxGraph extends mxEventSource {
* evt - Optional event that triggered the change. * evt - Optional event that triggered the change.
*/ */
labelChanged(cell: mxCell, labelChanged(cell: mxCell,
value, value: any,
evt: mxEvent) { evt: mxEventObject): mxCell {
this.model.beginUpdate(); this.model.beginUpdate();
try { try {
@ -2466,7 +2480,6 @@ class mxGraph extends mxEventSource {
} finally { } finally {
this.model.endUpdate(); this.model.endUpdate();
} }
return cell; return cell;
} }
@ -2501,11 +2514,13 @@ class mxGraph extends mxEventSource {
* value - New label to be assigned. * value - New label to be assigned.
* autoSize - Boolean that specifies if <cellSizeUpdated> should be called. * autoSize - Boolean that specifies if <cellSizeUpdated> should be called.
*/ */
cellLabelChanged(cell, value, autoSize) { cellLabelChanged(cell: mxCell,
value: any,
autoSize: boolean=false) {
this.model.beginUpdate(); this.model.beginUpdate();
try { try {
this.model.setValue(cell, value); this.model.setValue(cell, value);
if (autoSize) { if (autoSize) {
this.cellSizeUpdated(cell, false); this.cellSizeUpdated(cell, false);
} }
@ -2702,7 +2717,9 @@ class mxGraph extends mxEventSource {
* evt - Mouseevent that represents the doubleclick. * evt - Mouseevent that represents the doubleclick.
* cell - Optional <mxCell> under the mousepointer. * cell - Optional <mxCell> under the mousepointer.
*/ */
dblClick(evt, cell) { dblClick(evt: mxMouseEvent,
cell: mxCell | null=null): void {
const mxe = new mxEventObject( const mxe = new mxEventObject(
mxEvent.DOUBLE_CLICK, mxEvent.DOUBLE_CLICK,
'event', 'event',
@ -2736,7 +2753,7 @@ class mxGraph extends mxEventSource {
* me - <mxMouseEvent> that represents the touch event. * me - <mxMouseEvent> that represents the touch event.
* state - Optional <mxCellState> that is associated with the event. * state - Optional <mxCellState> that is associated with the event.
*/ */
tapAndHold(me) { tapAndHold(me: mxMouseEvent): void {
const evt = me.getEvent(); const evt = me.getEvent();
const mxe = new mxEventObject( const mxe = new mxEventObject(
mxEvent.TAP_AND_HOLD, mxEvent.TAP_AND_HOLD,
@ -2795,13 +2812,16 @@ class mxGraph extends mxEventSource {
* Scrolls the graph to the given point, extending the graph container if * Scrolls the graph to the given point, extending the graph container if
* specified. * specified.
*/ */
scrollPointToVisible(x, y, extend, border) { scrollPointToVisible(x: number,
y: number,
extend: boolean,
border: number=20) {
if ( if (
!this.timerAutoScroll && !this.timerAutoScroll &&
(this.ignoreScrollbars || mxUtils.hasScrollbars(this.container)) (this.ignoreScrollbars || mxUtils.hasScrollbars(this.container))
) { ) {
const c = this.container; const c = this.container;
border = border != null ? border : 20;
if ( if (
x >= c.scrollLeft && x >= c.scrollLeft &&
@ -2878,7 +2898,6 @@ class mxGraph extends mxEventSource {
if (this.panningManager == null) { if (this.panningManager == null) {
this.panningManager = this.createPanningManager(); this.panningManager = this.createPanningManager();
} }
this.panningManager.panTo(x + this.panDx, y + this.panDy); this.panningManager.panTo(x + this.panDx, y + this.panDy);
} }
} }
@ -3311,7 +3330,7 @@ class mxGraph extends mxEventSource {
* cell - <mxCell> whose style should be returned as an array. * cell - <mxCell> whose style should be returned as an array.
* ignoreState - Optional boolean that specifies if the cell state should be ignored. * ignoreState - Optional boolean that specifies if the cell state should be ignored.
*/ */
getCurrentCellStyle(cell, ignoreState) { getCurrentCellStyle(cell, ignoreState: boolean=false) {
const state = ignoreState ? null : this.view.getState(cell); const state = ignoreState ? null : this.view.getState(cell);
return state != null ? state.style : this.getCellStyle(cell); return state != null ? state.style : this.getCellStyle(cell);
@ -4708,13 +4727,13 @@ class mxGraph extends mxEventSource {
* <mxEvent.CELLS_ADDED> while the transaction is in progress. * <mxEvent.CELLS_ADDED> while the transaction is in progress.
*/ */
cellsAdded( cellsAdded(
cells, cells: mxCell[] | null=null,
parent, parent: mxCell | null=null,
index, index: number | null=null,
source, source: mxCell | null=null,
target, target: mxCell | null=null,
absolute, absolute: boolean=false,
constrain, constrain: boolean=false,
extend extend
) { ) {
if (cells != null && parent != null && index != null) { if (cells != null && parent != null && index != null) {
@ -4802,18 +4821,12 @@ class mxGraph extends mxEventSource {
this.fireEvent( this.fireEvent(
new mxEventObject( new mxEventObject(
mxEvent.CELLS_ADDED, mxEvent.CELLS_ADDED,
'cells', 'cells', cells,
cells, 'parent', parent,
'parent', 'index', index,
parent, 'source', source,
'index', 'target', target,
index, 'absolute', absolute
'source',
source,
'target',
target,
'absolute',
absolute
) )
); );
} finally { } finally {
@ -4833,8 +4846,8 @@ class mxGraph extends mxEventSource {
* recurse - Optional boolean which specifies if all descendants should be * recurse - Optional boolean which specifies if all descendants should be
* autosized. Default is true. * autosized. Default is true.
*/ */
autoSizeCell(cell, recurse) { autoSizeCell(cell: mxCell,
recurse = recurse != null ? recurse : true; recurse: boolean=true) {
if (recurse) { if (recurse) {
const childCount = this.model.getChildCount(cell); const childCount = this.model.getChildCount(cell);
@ -5451,8 +5464,8 @@ class mxGraph extends mxEventSource {
* *
* cell - <mxCell> whose size should be updated. * cell - <mxCell> whose size should be updated.
*/ */
updateCellSize(cell, ignoreChildren) { updateCellSize(cell: mxCell,
ignoreChildren = ignoreChildren != null ? ignoreChildren : false; ignoreChildren: boolean=false) {
this.model.beginUpdate(); this.model.beginUpdate();
try { try {
@ -5460,16 +5473,13 @@ class mxGraph extends mxEventSource {
this.fireEvent( this.fireEvent(
new mxEventObject( new mxEventObject(
mxEvent.UPDATE_CELL_SIZE, mxEvent.UPDATE_CELL_SIZE,
'cell', 'cell', cell,
cell, 'ignoreChildren', ignoreChildren
'ignoreChildren',
ignoreChildren
) )
); );
} finally { } finally {
this.model.endUpdate(); this.model.endUpdate();
} }
return cell; return cell;
} }
@ -6413,8 +6423,8 @@ class mxGraph extends mxEventSource {
* cells - <mxCell> which should be constrained. * cells - <mxCell> which should be constrained.
* sizeFirst - Specifies if the size should be changed first. Default is true. * sizeFirst - Specifies if the size should be changed first. Default is true.
*/ */
constrainChild(cell, sizeFirst) { constrainChild(cell: mxCell,
sizeFirst = sizeFirst != null ? sizeFirst : true; sizeFirst: boolean=true) {
if (cell != null) { if (cell != null) {
let geo = this.getCellGeometry(cell); let geo = this.getCellGeometry(cell);
@ -7669,11 +7679,10 @@ class mxGraph extends mxEventSource {
* *
* value - Numeric value to be snapped to the grid. * value - Numeric value to be snapped to the grid.
*/ */
snap(value) { snap(value: number): number {
if (this.gridEnabled) { if (this.gridEnabled) {
value = Math.round(value / this.gridSize) * this.gridSize; value = Math.round(value / this.gridSize) * this.gridSize;
} }
return value; return value;
} }
@ -7682,7 +7691,12 @@ class mxGraph extends mxEventSource {
* *
* Snaps the given delta with the given scaled bounds. * Snaps the given delta with the given scaled bounds.
*/ */
snapDelta(delta, bounds, ignoreGrid, ignoreHorizontal, ignoreVertical) { snapDelta(delta,
bounds,
ignoreGrid,
ignoreHorizontal,
ignoreVertical) {
const t = this.view.translate; const t = this.view.translate;
const s = this.view.scale; const s = this.view.scale;
@ -7731,7 +7745,6 @@ class mxGraph extends mxEventSource {
} }
} }
} }
return delta; return delta;
} }
@ -7890,7 +7903,8 @@ class mxGraph extends mxEventSource {
* Zooms the graph to the given scale with an optional boolean center * Zooms the graph to the given scale with an optional boolean center
* argument, which is passd to <zoom>. * argument, which is passd to <zoom>.
*/ */
zoomTo(scale, center) { zoomTo(scale: number,
center: boolean=false) {
this.zoom(scale / this.view.scale, center); this.zoom(scale / this.view.scale, center);
} }
@ -7962,8 +7976,9 @@ class mxGraph extends mxEventSource {
* argument that keeps the graph scrolled to the center. If the center argument * argument that keeps the graph scrolled to the center. If the center argument
* is omitted, then <centerZoom> will be used as its value. * is omitted, then <centerZoom> will be used as its value.
*/ */
zoom(factor, center) { zoom(factor: number,
center = center != null ? center : this.centerZoom; center: boolean=this.centerZoom): void {
const scale = Math.round(this.view.scale * factor * 100) / 100; const scale = Math.round(this.view.scale * factor * 100) / 100;
const state = this.view.getState(this.getSelectionCell()); const state = this.view.getState(this.getSelectionCell());
factor = scale / this.view.scale; factor = scale / this.view.scale;
@ -8050,7 +8065,7 @@ class mxGraph extends mxEventSource {
* rect - The un-scaled and un-translated rectangluar region that should be just visible * rect - The un-scaled and un-translated rectangluar region that should be just visible
* after the operation * after the operation
*/ */
zoomToRect(rect) { zoomToRect(rect: mxRectangle): void {
const scaleX = this.container.clientWidth / rect.width; const scaleX = this.container.clientWidth / rect.width;
const scaleY = this.container.clientHeight / rect.height; const scaleY = this.container.clientHeight / rect.height;
const aspectFactor = scaleX / scaleY; const aspectFactor = scaleX / scaleY;
@ -8370,7 +8385,7 @@ class mxGraph extends mxEventSource {
* *
* state - <mxCellState> that represents a potential loop. * state - <mxCellState> that represents a potential loop.
*/ */
isLoop(state) { isLoop(state: mxCellState) {
const src = state.getVisibleTerminalState(true); const src = state.getVisibleTerminalState(true);
const trg = state.getVisibleTerminalState(false); const trg = state.getVisibleTerminalState(false);
@ -8773,7 +8788,7 @@ class mxGraph extends mxEventSource {
* Returns the <mxImage> used to display the collapsed state of * Returns the <mxImage> used to display the collapsed state of
* the specified cell state. This returns null for all edges. * the specified cell state. This returns null for all edges.
*/ */
getFoldingImage(state) { getFoldingImage(state: mxCellState) {
if ( if (
state != null && state != null &&
this.foldingEnabled && this.foldingEnabled &&
@ -9150,7 +9165,9 @@ class mxGraph extends mxEventSource {
* swimlane - <mxCell> whose start size should be returned. * swimlane - <mxCell> whose start size should be returned.
* ignoreState - Optional boolean that specifies if cell state should be ignored. * ignoreState - Optional boolean that specifies if cell state should be ignored.
*/ */
getStartSize(swimlane, ignoreState) { getStartSize(swimlane: mxCell,
ignoreState: boolean=false) {
const result = new mxRectangle(); const result = new mxRectangle();
const style = this.getCurrentCellStyle(swimlane, ignoreState); const style = this.getCurrentCellStyle(swimlane, ignoreState);
const size = parseInt( const size = parseInt(
@ -9264,7 +9281,7 @@ class mxGraph extends mxEventSource {
* *
* state - <mxCellState> whose image URL should be returned. * state - <mxCellState> whose image URL should be returned.
*/ */
getImage(state) { getImage(state: mxCellState) {
return state != null && state.style != null return state != null && state.style != null
? state.style[mxConstants.STYLE_IMAGE] ? state.style[mxConstants.STYLE_IMAGE]
: null; : null;
@ -9279,7 +9296,7 @@ class mxGraph extends mxEventSource {
* *
* state - <mxCellState> to check. * state - <mxCellState> to check.
*/ */
isTransparentState(state) { isTransparentState(state: mxCellState) {
let result = false; let result = false;
if (state != null) { if (state != null) {
const stroke = mxUtils.getValue( const stroke = mxUtils.getValue(
@ -9312,7 +9329,7 @@ class mxGraph extends mxEventSource {
* state - <mxCellState> whose vertical alignment should be * state - <mxCellState> whose vertical alignment should be
* returned. * returned.
*/ */
getVerticalAlign(state) { getVerticalAlign(state: mxCellState) {
return state != null && state.style != null return state != null && state.style != null
? state.style[mxConstants.STYLE_VERTICAL_ALIGN] || ? state.style[mxConstants.STYLE_VERTICAL_ALIGN] ||
mxConstants.ALIGN_MIDDLE mxConstants.ALIGN_MIDDLE
@ -9331,7 +9348,7 @@ class mxGraph extends mxEventSource {
* state - <mxCellState> whose indicator color should be * state - <mxCellState> whose indicator color should be
* returned. * returned.
*/ */
getIndicatorColor(state) { getIndicatorColor(state: mxCellState) {
return state != null && state.style != null return state != null && state.style != null
? state.style[mxConstants.STYLE_INDICATOR_COLOR] ? state.style[mxConstants.STYLE_INDICATOR_COLOR]
: null; : null;
@ -9349,7 +9366,7 @@ class mxGraph extends mxEventSource {
* state - <mxCellState> whose indicator gradient color should be * state - <mxCellState> whose indicator gradient color should be
* returned. * returned.
*/ */
getIndicatorGradientColor(state) { getIndicatorGradientColor(state: mxCellState) {
return state != null && state.style != null return state != null && state.style != null
? state.style[mxConstants.STYLE_INDICATOR_GRADIENTCOLOR] ? state.style[mxConstants.STYLE_INDICATOR_GRADIENTCOLOR]
: null; : null;
@ -9366,7 +9383,7 @@ class mxGraph extends mxEventSource {
* *
* state - <mxCellState> whose indicator shape should be returned. * state - <mxCellState> whose indicator shape should be returned.
*/ */
getIndicatorShape(state) { getIndicatorShape(state: mxCellState) {
return state != null && state.style != null return state != null && state.style != null
? state.style[mxConstants.STYLE_INDICATOR_SHAPE] ? state.style[mxConstants.STYLE_INDICATOR_SHAPE]
: null; : null;
@ -9383,7 +9400,7 @@ class mxGraph extends mxEventSource {
* *
* state - <mxCellState> whose indicator image should be returned. * state - <mxCellState> whose indicator image should be returned.
*/ */
getIndicatorImage(state) { getIndicatorImage(state: mxCellState) {
return state != null && state.style != null return state != null && state.style != null
? state.style[mxConstants.STYLE_INDICATOR_IMAGE] ? state.style[mxConstants.STYLE_INDICATOR_IMAGE]
: null; : null;
@ -9423,7 +9440,7 @@ class mxGraph extends mxEventSource {
* cell - <mxCell> to be checked. * cell - <mxCell> to be checked.
* ignoreState - Optional boolean that specifies if the cell state should be ignored. * ignoreState - Optional boolean that specifies if the cell state should be ignored.
*/ */
isSwimlane(cell, ignoreState) { isSwimlane(cell, ignoreState: boolean=false) {
if ( if (
cell != null && cell != null &&
this.model.getParent(cell) !== this.model.getRoot() && this.model.getParent(cell) !== this.model.getRoot() &&
@ -9576,7 +9593,8 @@ class mxGraph extends mxEventSource {
* *
* cell - <mxCell> whose locked state should be returned. * cell - <mxCell> whose locked state should be returned.
*/ */
isCellsLocked() { isCellsLocked(): boolean {
// FIXME: Clarify the parameters!!! ========================================================================================
return this.cellsLocked; return this.cellsLocked;
} }
@ -9590,7 +9608,7 @@ class mxGraph extends mxEventSource {
* *
* value - Boolean that defines the new value for <cellsLocked>. * value - Boolean that defines the new value for <cellsLocked>.
*/ */
setCellsLocked(value) { setCellsLocked(value: boolean) {
this.cellsLocked = value; this.cellsLocked = value;
} }
@ -9631,7 +9649,7 @@ class mxGraph extends mxEventSource {
* Returns <cellsCloneable>, that is, if the graph allows cloning of cells * Returns <cellsCloneable>, that is, if the graph allows cloning of cells
* by using control-drag. * by using control-drag.
*/ */
isCellsCloneable() { isCellsCloneable(): boolean {
return this.cellsCloneable; return this.cellsCloneable;
} }
@ -9646,7 +9664,7 @@ class mxGraph extends mxEventSource {
* *
* value - Boolean indicating if the graph should be cloneable. * value - Boolean indicating if the graph should be cloneable.
*/ */
setCellsCloneable(value) { setCellsCloneable(value): void {
this.cellsCloneable = value; this.cellsCloneable = value;
} }
@ -9655,7 +9673,7 @@ class mxGraph extends mxEventSource {
* *
* Returns the cells which may be exported in the given array of cells. * Returns the cells which may be exported in the given array of cells.
*/ */
getExportableCells(cells: mxCell[]) { getExportableCells(cells: mxCell[]): mxCell[] {
return this.model.filterCells( return this.model.filterCells(
cells, cells,
mxUtils.bind(this, cell => { mxUtils.bind(this, cell => {
@ -9674,7 +9692,7 @@ class mxGraph extends mxEventSource {
* *
* cell - <mxCell> that represents the cell to be exported. * cell - <mxCell> that represents the cell to be exported.
*/ */
canExportCell(cell: mxCell) { canExportCell(cell: mxCell | null=null): boolean {
return this.exportEnabled; return this.exportEnabled;
} }
@ -9683,7 +9701,7 @@ class mxGraph extends mxEventSource {
* *
* Returns the cells which may be imported in the given array of cells. * Returns the cells which may be imported in the given array of cells.
*/ */
getImportableCells(cells: mxCell[]) { getImportableCells(cells: mxCell[]): mxCell[] {
return this.model.filterCells( return this.model.filterCells(
cells, cells,
mxUtils.bind(this, cell => { mxUtils.bind(this, cell => {
@ -9702,7 +9720,7 @@ class mxGraph extends mxEventSource {
* *
* cell - <mxCell> that represents the cell to be imported. * cell - <mxCell> that represents the cell to be imported.
*/ */
canImportCell(cell: mxCell) { canImportCell(cell: mxCell | null=null): boolean {
return this.importEnabled; return this.importEnabled;
} }
@ -10698,7 +10716,7 @@ class mxGraph extends mxEventSource {
* *
* state - <mxCellState> that is being resized. * state - <mxCellState> that is being resized.
*/ */
isRecursiveResize(state) { isRecursiveResize(state: mxCellState) {
return this.recursiveResize; return this.recursiveResize;
} }
@ -10933,7 +10951,11 @@ class mxGraph extends mxEventSource {
* cell - <mxCell> that is under the mousepointer. * cell - <mxCell> that is under the mousepointer.
* clone - Optional boolean to indicate of cells will be cloned. * clone - Optional boolean to indicate of cells will be cloned.
*/ */
getDropTarget(cells, evt, cell, clone) { getDropTarget(cells: mxCell[],
evt: mxMouseEvent,
cell: mxCell | null=null,
clone: boolean=false): mxCell | null {
if (!this.isSwimlaneNesting()) { if (!this.isSwimlaneNesting()) {
for (let i = 0; i < cells.length; i += 1) { for (let i = 0; i < cells.length; i += 1) {
if (this.isSwimlane(cells[i])) { if (this.isSwimlane(cells[i])) {
@ -10976,9 +10998,8 @@ class mxGraph extends mxEventSource {
} }
// Checks if parent is dropped into child if not cloning // Checks if parent is dropped into child if not cloning
if (clone == null || !clone) { if (!clone) {
let parent = cell; let parent = cell;
while (parent != null && mxUtils.indexOf(cells, parent) < 0) { while (parent != null && mxUtils.indexOf(cells, parent) < 0) {
parent = this.model.getParent(parent); parent = this.model.getParent(parent);
} }
@ -11010,7 +11031,6 @@ class mxGraph extends mxEventSource {
parent = this.model.getChildAt(root, 0); parent = this.model.getChildAt(root, 0);
} }
} }
return parent; return parent;
} }
@ -11020,7 +11040,7 @@ class mxGraph extends mxEventSource {
* Sets the <defaultParent> to the given cell. Set this to null to return * Sets the <defaultParent> to the given cell. Set this to null to return
* the first child of the root in getDefaultParent. * the first child of the root in getDefaultParent.
*/ */
setDefaultParent(cell: mxCell) { setDefaultParent(cell: mxCell): void {
this.defaultParent = cell; this.defaultParent = cell;
} }
@ -11034,11 +11054,10 @@ class mxGraph extends mxEventSource {
* *
* cell - <mxCell> for which the ancestor swimlane should be returned. * cell - <mxCell> for which the ancestor swimlane should be returned.
*/ */
getSwimlane(cell: mxCell) { getSwimlane(cell: mxCell): void {
while (cell != null && !this.isSwimlane(cell)) { while (cell != null && !this.isSwimlane(cell)) {
cell = this.model.getParent(cell); cell = this.model.getParent(cell);
} }
return cell; return cell;
} }
@ -11055,7 +11074,10 @@ class mxGraph extends mxEventSource {
* parent - <mxCell> that should be used as the root of the recursion. * parent - <mxCell> that should be used as the root of the recursion.
* Default is <defaultParent>. * Default is <defaultParent>.
*/ */
getSwimlaneAt(x, y, parent) { getSwimlaneAt(x: number,
y: number,
parent) {
if (parent == null) { if (parent == null) {
parent = this.getCurrentRoot(); parent = this.getCurrentRoot();
@ -11086,7 +11108,6 @@ class mxGraph extends mxEventSource {
} }
} }
} }
return null; return null;
} }
@ -11372,11 +11393,12 @@ class mxGraph extends mxEventSource {
* need be an ancestral parent, true, or the direct parent, false. * need be an ancestral parent, true, or the direct parent, false.
* Default is false * Default is false
*/ */
getEdges(cell, parent, incoming, outgoing, includeLoops, recurse) { getEdges(cell: mxCell,
incoming = incoming != null ? incoming : true; parent,
outgoing = outgoing != null ? outgoing : true; incoming: boolean=true,
includeLoops = includeLoops != null ? includeLoops : true; outgoing: boolean=true,
recurse = recurse != null ? recurse : false; includeLoops: boolean=true,
recurse: boolean=false) {
let edges = []; let edges = [];
const isCollapsed = this.isCellCollapsed(cell); const isCollapsed = this.isCellCollapsed(cell);
@ -11437,7 +11459,10 @@ class mxGraph extends mxEventSource {
* parent - <mxCell> the possible parent cell * parent - <mxCell> the possible parent cell
* recurse - boolean whether or not to recurse the child ancestors * recurse - boolean whether or not to recurse the child ancestors
*/ */
isValidAncestor(cell, parent, recurse) { isValidAncestor(cell: mxCell,
parent: mxCell,
recurse: boolean=false): boolean {
return recurse return recurse
? this.model.isAncestor(parent, cell) ? this.model.isAncestor(parent, cell)
: this.model.getParent(cell) == parent; : this.model.getParent(cell) == parent;
@ -12355,7 +12380,7 @@ class mxGraph extends mxEventSource {
* *
* state - <mxCellState> to create the handler for. * state - <mxCellState> to create the handler for.
*/ */
createEdgeSegmentHandler(state) { createEdgeSegmentHandler(state: mxCellState) {
return new mxEdgeSegmentHandler(state); return new mxEdgeSegmentHandler(state);
} }
@ -12368,7 +12393,7 @@ class mxGraph extends mxEventSource {
* *
* state - <mxCellState> to create the handler for. * state - <mxCellState> to create the handler for.
*/ */
createElbowEdgeHandler(state) { createElbowEdgeHandler(state: mxCellState) {
return new mxElbowEdgeHandler(state); return new mxElbowEdgeHandler(state);
} }
@ -12519,18 +12544,18 @@ class mxGraph extends mxEventSource {
) { ) {
this.eventSource = me.getSource(); this.eventSource = me.getSource();
this.mouseMoveRedirect = mxUtils.bind(this, evt => { this.mouseMoveRedirect = evt => {
this.fireMouseEvent( this.fireMouseEvent(
mxEvent.MOUSE_MOVE, mxEvent.MOUSE_MOVE,
new mxMouseEvent(evt, this.getStateForTouchEvent(evt)) new mxMouseEvent(evt, this.getStateForTouchEvent(evt))
); );
}); };
this.mouseUpRedirect = mxUtils.bind(this, evt => { this.mouseUpRedirect = evt => {
this.fireMouseEvent( this.fireMouseEvent(
mxEvent.MOUSE_UP, mxEvent.MOUSE_UP,
new mxMouseEvent(evt, this.getStateForTouchEvent(evt)) new mxMouseEvent(evt, this.getStateForTouchEvent(evt))
); );
}); };
mxEvent.addGestureListeners( mxEvent.addGestureListeners(
this.eventSource, this.eventSource,
@ -12651,7 +12676,7 @@ class mxGraph extends mxEventSource {
* *
* <mxCellState> - State whose event source should be returned. * <mxCellState> - State whose event source should be returned.
*/ */
getEventState(state) { getEventState(state: mxCellState) {
return state; return state;
} }
@ -12669,12 +12694,14 @@ class mxGraph extends mxEventSource {
* me - <mxMouseEvent> to be fired. * me - <mxMouseEvent> to be fired.
* sender - Optional sender argument. Default is this. * sender - Optional sender argument. Default is this.
*/ */
fireMouseEvent(evtName, me, sender) { fireMouseEvent(evtName: string,
me: mxMouseEvent,
sender: any=this) {
if (this.isEventSourceIgnored(evtName, me)) { if (this.isEventSourceIgnored(evtName, me)) {
if (this.tooltipHandler != null) { if (this.tooltipHandler != null) {
this.tooltipHandler.hide(); this.tooltipHandler.hide();
} }
return; return;
} }

View File

@ -3,25 +3,25 @@
* Copyright (c) 2006-2018, Gaudenz Alder * Copyright (c) 2006-2018, Gaudenz Alder
* Updated to ES9 syntax by David Morrissey 2021 * Updated to ES9 syntax by David Morrissey 2021
*/ */
import mxEventSource from '../util/event/mxEventSource'; import mxEventSource from '../../util/event/mxEventSource';
import mxUndoableEdit from '../util/undo/mxUndoableEdit'; import mxUndoableEdit from '../../util/undo/mxUndoableEdit';
import mxCellPath from './mxCellPath'; import mxCellPath from '../cell/mxCellPath';
import mxDictionary from '../util/datatypes/mxDictionary'; import mxDictionary from '../../util/datatypes/mxDictionary';
import mxObjectIdentity from '../util/datatypes/mxObjectIdentity'; import mxObjectIdentity from '../../util/datatypes/mxObjectIdentity';
import mxCell from './mxCell'; import mxCell from '../cell/mxCell';
import mxUtils from '../util/mxUtils'; import mxUtils from '../../util/mxUtils';
import mxEventObject from '../util/event/mxEventObject'; import mxEventObject from '../../util/event/mxEventObject';
import mxEvent from '../util/event/mxEvent'; import mxEvent from '../../util/event/mxEvent';
import mxPoint from '../util/datatypes/mxPoint'; import mxPoint from '../../util/datatypes/mxPoint';
import mxChildChange from './atomic_changes/mxChildChange'; import mxChildChange from '../../atomic_changes/mxChildChange';
import mxCollapseChange from './atomic_changes/mxCollapseChange'; import mxCollapseChange from '../../atomic_changes/mxCollapseChange';
import mxGeometryChange from './atomic_changes/mxGeometryChange'; import mxGeometryChange from '../../atomic_changes/mxGeometryChange';
import mxRootChange from './atomic_changes/mxRootChange'; import mxRootChange from '../../atomic_changes/mxRootChange';
import mxStyleChange from './atomic_changes/mxStyleChange'; import mxStyleChange from '../../atomic_changes/mxStyleChange';
import mxTerminalChange from './atomic_changes/mxTerminalChange'; import mxTerminalChange from '../../atomic_changes/mxTerminalChange';
import mxValueChange from './atomic_changes/mxValueChange'; import mxValueChange from '../../atomic_changes/mxValueChange';
import mxVisibleChange from './atomic_changes/mxVisibleChange'; import mxVisibleChange from '../../atomic_changes/mxVisibleChange';
class mxGraphModel extends mxEventSource { class mxGraphModel extends mxEventSource {
/** /**
@ -458,16 +458,14 @@ class mxGraphModel extends mxEventSource {
* *
* cell - Optional <mxCell> that specifies the child. * cell - Optional <mxCell> that specifies the child.
*/ */
getRoot(cell) { getRoot(cell: mxCell | null=null): mxCell {
let root = cell || this.root; let root = cell || this.root;
if (cell != null) { if (cell != null) {
while (cell != null) { while (cell != null) {
root = cell; root = cell;
cell = this.getParent(cell); cell = this.getParent(cell);
} }
} }
return root; return root;
} }
@ -587,7 +585,7 @@ class mxGraphModel extends mxEventSource {
* *
* cell - <mxCell> whose parent should be returned. * cell - <mxCell> whose parent should be returned.
*/ */
getParent(cell) { getParent(cell: mxCell): mxCell {
return cell != null ? cell.getParent() : null; return cell != null ? cell.getParent() : null;
} }
@ -2165,5 +2163,5 @@ class mxGraphModel extends mxEventSource {
// Atomic changes // Atomic changes
// //
export default mxGraphModel; export default mxGraphModel;
import("../io/mxModelCodec"); import("../../io/mxModelCodec");

View File

@ -11,7 +11,8 @@ import mxClient from '../../mxClient';
import mxUtils from '../../util/mxUtils'; import mxUtils from '../../util/mxUtils';
import mxSelectionChange from './mxSelectionChange'; import mxSelectionChange from './mxSelectionChange';
import mxEvent from '../../util/event/mxEvent'; import mxEvent from '../../util/event/mxEvent';
import mxCell from "../../model/mxCell"; import mxCell from "../cell/mxCell";
import mxGraph from "./mxGraph";
class mxGraphSelectionModel extends mxEventSource { class mxGraphSelectionModel extends mxEventSource {
/** /**
@ -21,7 +22,7 @@ class mxGraphSelectionModel extends mxEventSource {
* If the resource for this key does not exist then the value is used as * If the resource for this key does not exist then the value is used as
* the status message. Default is 'done'. * the status message. Default is 'done'.
*/ */
doneResource = mxClient.language !== 'none' ? 'done' : ''; doneResource: string = mxClient.language !== 'none' ? 'done' : '';
/** /**
* Variable: updatingSelectionResource * Variable: updatingSelectionResource
@ -30,7 +31,7 @@ class mxGraphSelectionModel extends mxEventSource {
* being updated. If the resource for this key does not exist then the * being updated. If the resource for this key does not exist then the
* value is used as the status message. Default is 'updatingSelection'. * value is used as the status message. Default is 'updatingSelection'.
*/ */
updatingSelectionResource = updatingSelectionResource: string =
mxClient.language !== 'none' ? 'updatingSelection' : ''; mxClient.language !== 'none' ? 'updatingSelection' : '';
/** /**
@ -38,7 +39,7 @@ class mxGraphSelectionModel extends mxEventSource {
* *
* Reference to the enclosing <mxGraph>. * Reference to the enclosing <mxGraph>.
*/ */
graph = null; graph: mxGraph | null = null;
/** /**
* Variable: singleSelection * Variable: singleSelection
@ -46,7 +47,7 @@ class mxGraphSelectionModel extends mxEventSource {
* Specifies if only one selected item at a time is allowed. * Specifies if only one selected item at a time is allowed.
* Default is false. * Default is false.
*/ */
singleSelection = false; singleSelection: boolean = false;
/** /**
* Class: mxGraphSelectionModel * Class: mxGraphSelectionModel
@ -87,7 +88,7 @@ class mxGraphSelectionModel extends mxEventSource {
* *
* graph - Reference to the enclosing <mxGraph>. * graph - Reference to the enclosing <mxGraph>.
*/ */
constructor(graph) { constructor(graph: mxGraph) {
super(); super();
this.graph = graph; this.graph = graph;
@ -99,7 +100,7 @@ class mxGraphSelectionModel extends mxEventSource {
* *
* Returns <singleSelection> as a boolean. * Returns <singleSelection> as a boolean.
*/ */
isSingleSelection() { isSingleSelection(): boolean {
return this.singleSelection; return this.singleSelection;
} }
@ -113,7 +114,7 @@ class mxGraphSelectionModel extends mxEventSource {
* singleSelection - Boolean that specifies the new value for * singleSelection - Boolean that specifies the new value for
* <singleSelection>. * <singleSelection>.
*/ */
setSingleSelection(singleSelection) { setSingleSelection(singleSelection: boolean): void {
this.singleSelection = singleSelection; this.singleSelection = singleSelection;
} }
@ -122,11 +123,10 @@ class mxGraphSelectionModel extends mxEventSource {
* *
* Returns true if the given <mxCell> is selected. * Returns true if the given <mxCell> is selected.
*/ */
isSelected(cell) { isSelected(cell: mxCell): boolean {
if (cell != null) { if (cell != null) {
return mxUtils.indexOf(this.cells, cell) >= 0; return mxUtils.indexOf(this.cells, cell) >= 0;
} }
return false; return false;
} }
@ -135,7 +135,7 @@ class mxGraphSelectionModel extends mxEventSource {
* *
* Returns true if no cells are currently selected. * Returns true if no cells are currently selected.
*/ */
isEmpty() { isEmpty(): boolean {
return this.cells.length === 0; return this.cells.length === 0;
} }
@ -145,7 +145,7 @@ class mxGraphSelectionModel extends mxEventSource {
* Clears the selection and fires a <change> event if the selection was not * Clears the selection and fires a <change> event if the selection was not
* empty. * empty.
*/ */
clear() { clear(): void {
this.changeSelection(null, this.cells); this.changeSelection(null, this.cells);
} }
@ -158,7 +158,7 @@ class mxGraphSelectionModel extends mxEventSource {
* *
* cell - <mxCell> to be selected. * cell - <mxCell> to be selected.
*/ */
setCell(cell) { setCell(cell: mxCell): void {
if (cell != null) { if (cell != null) {
this.setCells([cell]); this.setCells([cell]);
} }
@ -173,20 +173,18 @@ class mxGraphSelectionModel extends mxEventSource {
* *
* cells - Array of <mxCells> to be selected. * cells - Array of <mxCells> to be selected.
*/ */
setCells(cells) { setCells(cells: mxCell[]): void {
if (cells != null) { if (cells != null) {
if (this.singleSelection) { if (this.singleSelection) {
cells = [this.getFirstSelectableCell(cells)]; cells = [this.getFirstSelectableCell(cells)];
} }
const tmp = []; const tmp = [];
for (let i = 0; i < cells.length; i += 1) { for (let i = 0; i < cells.length; i += 1) {
if (this.graph.isCellSelectable(cells[i])) { if (this.graph.isCellSelectable(cells[i])) {
tmp.push(cells[i]); tmp.push(cells[i]);
} }
} }
this.changeSelection(tmp, this.cells); this.changeSelection(tmp, this.cells);
} }
} }
@ -196,7 +194,7 @@ class mxGraphSelectionModel extends mxEventSource {
* *
* Returns the first selectable cell in the given array of cells. * Returns the first selectable cell in the given array of cells.
*/ */
getFirstSelectableCell(cells) { getFirstSelectableCell(cells: mxCell[]): mxCell | null {
if (cells != null) { if (cells != null) {
for (let i = 0; i < cells.length; i += 1) { for (let i = 0; i < cells.length; i += 1) {
if (this.graph.isCellSelectable(cells[i])) { if (this.graph.isCellSelectable(cells[i])) {
@ -204,7 +202,6 @@ class mxGraphSelectionModel extends mxEventSource {
} }
} }
} }
return null; return null;
} }
@ -217,7 +214,7 @@ class mxGraphSelectionModel extends mxEventSource {
* *
* cell - <mxCell> to add to the selection. * cell - <mxCell> to add to the selection.
*/ */
addCell(cell) { addCell(cell: mxCell | null=null): void {
if (cell != null) { if (cell != null) {
this.addCells([cell]); this.addCells([cell]);
} }
@ -233,17 +230,15 @@ class mxGraphSelectionModel extends mxEventSource {
* *
* cells - Array of <mxCells> to add to the selection. * cells - Array of <mxCells> to add to the selection.
*/ */
addCells(cells) { addCells(cells: mxCell[]): void {
if (cells != null) { if (cells != null) {
let remove = null; let remove = null;
if (this.singleSelection) { if (this.singleSelection) {
remove = this.cells; remove = this.cells;
cells = [this.getFirstSelectableCell(cells)]; cells = [this.getFirstSelectableCell(cells)];
} }
const tmp = []; const tmp = [];
for (let i = 0; i < cells.length; i += 1) { for (let i = 0; i < cells.length; i += 1) {
if ( if (
!this.isSelected(cells[i]) && !this.isSelected(cells[i]) &&
@ -267,7 +262,7 @@ class mxGraphSelectionModel extends mxEventSource {
* *
* cell - <mxCell> to remove from the selection. * cell - <mxCell> to remove from the selection.
*/ */
removeCell(cell) { removeCell(cell: mxCell | null=null): void {
if (cell != null) { if (cell != null) {
this.removeCells([cell]); this.removeCells([cell]);
} }
@ -276,16 +271,14 @@ class mxGraphSelectionModel extends mxEventSource {
/** /**
* Function: removeCells * Function: removeCells
*/ */
removeCells(cells) { removeCells(cells: mxCell[] | null=null): void {
if (cells != null) { if (cells != null) {
const tmp = []; const tmp = [];
for (let i = 0; i < cells.length; i += 1) { for (let i = 0; i < cells.length; i += 1) {
if (this.isSelected(cells[i])) { if (this.isSelected(cells[i])) {
tmp.push(cells[i]); tmp.push(cells[i]);
} }
} }
this.changeSelection(null, tmp); this.changeSelection(null, tmp);
} }
} }
@ -301,7 +294,7 @@ class mxGraphSelectionModel extends mxEventSource {
* remove - Array of <mxCell> to remove from the selection. * remove - Array of <mxCell> to remove from the selection.
*/ */
changeSelection(added: mxCell[], changeSelection(added: mxCell[],
removed: mxCell[]) { removed: mxCell[]): void {
if ( if (
(added != null && added.length > 0 && added[0] != null) || (added != null && added.length > 0 && added[0] != null) ||
(removed != null && removed.length > 0 && removed[0] != null) (removed != null && removed.length > 0 && removed[0] != null)
@ -324,7 +317,7 @@ class mxGraphSelectionModel extends mxEventSource {
* *
* cell - <mxCell> to add to the selection. * cell - <mxCell> to add to the selection.
*/ */
cellAdded(cell) { cellAdded(cell: mxCell): void {
if (cell != null && !this.isSelected(cell)) { if (cell != null && !this.isSelected(cell)) {
this.cells.push(cell); this.cells.push(cell);
} }
@ -340,10 +333,9 @@ class mxGraphSelectionModel extends mxEventSource {
* *
* cell - <mxCell> to remove from the selection. * cell - <mxCell> to remove from the selection.
*/ */
cellRemoved(cell) { cellRemoved(cell: mxCell): void {
if (cell != null) { if (cell != null) {
const index = mxUtils.indexOf(this.cells, cell); const index = mxUtils.indexOf(this.cells, cell);
if (index >= 0) { if (index >= 0) {
this.cells.splice(index, 1); this.cells.splice(index, 1);
} }

View File

@ -22,10 +22,11 @@ import mxImageShape from '../../shape/node/mxImageShape';
import mxMouseEvent from '../../util/event/mxMouseEvent'; import mxMouseEvent from '../../util/event/mxMouseEvent';
import mxStyleRegistry from '../style/mxStyleRegistry'; import mxStyleRegistry from '../style/mxStyleRegistry';
import mxGraph from "./mxGraph"; import mxGraph from "./mxGraph";
import mxCell from '../../model/mxCell'; import mxCell from '../cell/mxCell';
import mxImage from '../../util/image/mxImage'; import mxImage from '../../util/image/mxImage';
import mxCurrentRootChange from "./mxCurrentRootChange"; import mxCurrentRootChange from "./mxCurrentRootChange";
import mxGraphModel from '../../model/mxGraphModel'; import mxGraphModel from './mxGraphModel';
import mxShape from '../../shape/mxShape';
const validateBool = x => { const validateBool = x => {
if (x === true || x === false) { if (x === true || x === false) {
@ -45,6 +46,10 @@ const validateString = x => {
} }
class mxGraphView extends mxEventSource { class mxGraphView extends mxEventSource {
// TODO: Document me!
backgroundImage: mxImageShape | null;
backgroundPageShape: mxShape | null;
EMPTY_POINT = new mxPoint(); EMPTY_POINT = new mxPoint();
_canvas: HTMLElement; _canvas: HTMLElement;
@ -492,7 +497,7 @@ class mxGraphView extends mxEventSource {
* *
* cells - Array of <mxCells> whose bounds should be returned. * cells - Array of <mxCells> whose bounds should be returned.
*/ */
getBounds(cells: [mxCell]): [mxRectangle] { getBounds(cells: mxCell[]): mxRectangle {
let result = null; let result = null;
if (cells != null && cells.length > 0) { if (cells != null && cells.length > 0) {
@ -713,7 +718,7 @@ class mxGraphView extends mxEventSource {
* cell - Optional <mxCell> to be used as the root of the validation. * cell - Optional <mxCell> to be used as the root of the validation.
* Default is <currentRoot> or the root of the model. * Default is <currentRoot> or the root of the model.
*/ */
validate(cell) { validate(cell: mxCell | null=null) {
const t0 = mxLog.enter('mxGraphView.validate'); const t0 = mxLog.enter('mxGraphView.validate');
window.status = window.status =
mxResources.get(this.updatingDocumentResource) || mxResources.get(this.updatingDocumentResource) ||
@ -1007,8 +1012,8 @@ class mxGraphView extends mxEventSource {
* visible - Optional boolean indicating if the cell should be visible. Default * visible - Optional boolean indicating if the cell should be visible. Default
* is true. * is true.
*/ */
validateCell(cell, visible) { validateCell(cell: mxCell,
visible = visible != null ? visible : true; visible: boolean=true) {
if (cell != null) { if (cell != null) {
visible = visible && this.graph.isCellVisible(cell); visible = visible && this.graph.isCellVisible(cell);
@ -1029,7 +1034,6 @@ class mxGraphView extends mxEventSource {
} }
} }
} }
return cell; return cell;
} }
@ -1100,7 +1104,6 @@ class mxGraphView extends mxEventSource {
} }
} }
} }
return state; return state;
} }
@ -1113,7 +1116,7 @@ class mxGraphView extends mxEventSource {
* *
* state - <mxCellState> to be updated. * state - <mxCellState> to be updated.
*/ */
updateCellState(state) { updateCellState(state: mxCellState) {
state.absoluteOffset.x = 0; state.absoluteOffset.x = 0;
state.absoluteOffset.y = 0; state.absoluteOffset.y = 0;
state.origin.x = 0; state.origin.x = 0;
@ -1277,7 +1280,7 @@ class mxGraphView extends mxEventSource {
* *
* state - <mxCellState> whose absolute offset should be updated. * state - <mxCellState> whose absolute offset should be updated.
*/ */
updateVertexLabelOffset(state) { updateVertexLabelOffset(state: mxCellState) {
const h = mxUtils.getValue( const h = mxUtils.getValue(
state.style, state.style,
mxConstants.STYLE_LABEL_POSITION, mxConstants.STYLE_LABEL_POSITION,
@ -1363,7 +1366,7 @@ class mxGraphView extends mxEventSource {
* *
* state - <mxCellState> that represents the cell state. * state - <mxCellState> that represents the cell state.
*/ */
stateValidated(state) { stateValidated(state: mxCellState) {
const fg = const fg =
(this.graph.getModel().isEdge(state.cell) && (this.graph.getModel().isEdge(state.cell) &&
this.graph.keepEdgesInForeground) || this.graph.keepEdgesInForeground) ||
@ -1482,7 +1485,7 @@ class mxGraphView extends mxEventSource {
* *
* edge - <mxCellState> whose bounds should be updated. * edge - <mxCellState> whose bounds should be updated.
*/ */
updateBoundsFromStencil(state) { updateBoundsFromStencil(state: mxCellState) {
let previous = null; let previous = null;
if ( if (
@ -1854,7 +1857,7 @@ class mxGraphView extends mxEventSource {
* *
* Returns the x-coordinate of the center point for automatic routing. * Returns the x-coordinate of the center point for automatic routing.
*/ */
getRoutingCenterX(state) { getRoutingCenterX(state: mxCellState) {
const f = const f =
state.style != null state.style != null
? parseFloat(state.style[mxConstants.STYLE_ROUTING_CENTER_X]) || 0 ? parseFloat(state.style[mxConstants.STYLE_ROUTING_CENTER_X]) || 0
@ -1867,7 +1870,7 @@ class mxGraphView extends mxEventSource {
* *
* Returns the y-coordinate of the center point for automatic routing. * Returns the y-coordinate of the center point for automatic routing.
*/ */
getRoutingCenterY(state) { getRoutingCenterY(state: mxCellState) {
const f = const f =
state.style != null state.style != null
? parseFloat(state.style[mxConstants.STYLE_ROUTING_CENTER_Y]) || 0 ? parseFloat(state.style[mxConstants.STYLE_ROUTING_CENTER_Y]) || 0
@ -1933,7 +1936,7 @@ class mxGraphView extends mxEventSource {
* *
* Returns the perimeter function for the given state. * Returns the perimeter function for the given state.
*/ */
getPerimeterFunction(state) { getPerimeterFunction(state: mxCellState) {
let perimeter = state.style[mxConstants.STYLE_PERIMETER]; let perimeter = state.style[mxConstants.STYLE_PERIMETER];
// Converts string values to objects // Converts string values to objects
@ -2031,7 +2034,7 @@ class mxGraphView extends mxEventSource {
* *
* state - <mxCellState> whose bounds should be updated. * state - <mxCellState> whose bounds should be updated.
*/ */
updateEdgeBounds(state) { updateEdgeBounds(state: mxCellState) {
const points = state.absolutePoints; const points = state.absolutePoints;
const p0 = points[0]; const p0 = points[0];
const pe = points[points.length - 1]; const pe = points[points.length - 1];
@ -2268,7 +2271,7 @@ class mxGraphView extends mxEventSource {
* *
* state - <mxCellState> whose absolute offset should be updated. * state - <mxCellState> whose absolute offset should be updated.
*/ */
updateEdgeLabelOffset(state) { updateEdgeLabelOffset(state: mxCellState) {
const points = state.absolutePoints; const points = state.absolutePoints;
state.absoluteOffset.x = state.getCenterX(); state.absoluteOffset.x = state.getCenterX();

View File

@ -7,13 +7,14 @@
import mxEventSource from '../../util/event/mxEventSource'; import mxEventSource from '../../util/event/mxEventSource';
import mxEvent from '../../util/event/mxEvent'; import mxEvent from '../../util/event/mxEvent';
import mxUtils from '../../util/mxUtils'; import mxUtils from '../../util/mxUtils';
import mxRootChange from '../../model/atomic_changes/mxRootChange'; import mxRootChange from '../../atomic_changes/mxRootChange';
import mxChildChange from '../../model/atomic_changes/mxChildChange'; import mxChildChange from '../../atomic_changes/mxChildChange';
import mxTerminalChange from '../../model/atomic_changes/mxTerminalChange'; import mxTerminalChange from '../../atomic_changes/mxTerminalChange';
import mxGeometryChange from '../../model/atomic_changes/mxGeometryChange'; import mxGeometryChange from '../../atomic_changes/mxGeometryChange';
import mxVisibleChange from '../../model/atomic_changes/mxVisibleChange'; import mxVisibleChange from '../../atomic_changes/mxVisibleChange';
import mxStyleChange from '../../model/atomic_changes/mxStyleChange'; import mxStyleChange from '../../atomic_changes/mxStyleChange';
import mxEventObject from '../../util/event/mxEventObject'; import mxEventObject from '../../util/event/mxEventObject';
import mxCell from "../cell/mxCell";
class mxLayoutManager extends mxEventSource { class mxLayoutManager extends mxEventSource {
/** /**
@ -361,8 +362,8 @@ class mxLayoutManager extends mxEventSource {
* *
* Adds all ancestors of the given cell that have a layout. * Adds all ancestors of the given cell that have a layout.
*/ */
addAncestorsWithLayout(cell, result) { addAncestorsWithLayout(cell: mxCell,
result = result != null ? result : []; result: mxCell[]=[]): mxCell[] {
if (cell != null) { if (cell != null) {
const layout = this.hasLayout(cell); const layout = this.hasLayout(cell);
@ -385,8 +386,8 @@ class mxLayoutManager extends mxEventSource {
* *
* Adds all descendants of the given cell that have a layout. * Adds all descendants of the given cell that have a layout.
*/ */
addDescendantsWithLayout(cell, result) { addDescendantsWithLayout(cell: mxCell,
result = result != null ? result : []; result: any[]=[]): any[] {
if (cell != null && this.hasLayout(cell)) { if (cell != null && this.hasLayout(cell)) {
const model = this.getGraph().getModel(); const model = this.getGraph().getModel();
@ -400,7 +401,6 @@ class mxLayoutManager extends mxEventSource {
} }
} }
} }
return result; return result;
} }
@ -412,7 +412,7 @@ class mxLayoutManager extends mxEventSource {
* <mxEvent.BEGIN_UPDATE>, in the second phase layouts for parent cells are * <mxEvent.BEGIN_UPDATE>, in the second phase layouts for parent cells are
* executed before layouts for child cells with <mxEvent.END_UPDATE>. * executed before layouts for child cells with <mxEvent.END_UPDATE>.
*/ */
executeLayoutForCells(cells) { executeLayoutForCells(cells: mxCell[]): void {
const sorted = mxUtils.sortCells(cells, false); const sorted = mxUtils.sortCells(cells, false);
this.layoutCells(sorted, true); this.layoutCells(sorted, true);
this.layoutCells(sorted.reverse(), false); this.layoutCells(sorted.reverse(), false);
@ -423,7 +423,9 @@ class mxLayoutManager extends mxEventSource {
* *
* Executes all layouts which have been scheduled during the changes. * Executes all layouts which have been scheduled during the changes.
*/ */
layoutCells(cells, bubble) { layoutCells(cells: mxCell[],
bubble: boolean=false): void {
if (cells.length > 0) { if (cells.length > 0) {
// Invokes the layouts while removing duplicates // Invokes the layouts while removing duplicates
const model = this.getGraph().getModel(); const model = this.getGraph().getModel();
@ -451,12 +453,12 @@ class mxLayoutManager extends mxEventSource {
* *
* Executes the given layout on the given parent. * Executes the given layout on the given parent.
*/ */
executeLayout(cell, bubble) { executeLayout(cell: mxCell,
bubble: boolean=false): void {
const layout = this.getLayout( const layout = this.getLayout(
cell, cell,
bubble ? mxEvent.BEGIN_UPDATE : mxEvent.END_UPDATE bubble ? mxEvent.BEGIN_UPDATE : mxEvent.END_UPDATE
); );
if (layout != null) { if (layout != null) {
layout.execute(cell); layout.execute(cell);
} }
@ -467,7 +469,7 @@ class mxLayoutManager extends mxEventSource {
* *
* Removes all handlers from the <graph> and deletes the reference to it. * Removes all handlers from the <graph> and deletes the reference to it.
*/ */
destroy() { destroy(): void {
this.setGraph(null); this.setGraph(null);
} }
} }

View File

@ -3,10 +3,10 @@ import mxResources from '../../util/mxResources';
import mxLog from '../../util/gui/mxLog'; import mxLog from '../../util/gui/mxLog';
import mxEvent from '../../util/event/mxEvent'; import mxEvent from '../../util/event/mxEvent';
import mxGraphSelectionModel from "./mxGraphSelectionModel"; import mxGraphSelectionModel from "./mxGraphSelectionModel";
import mxCell from '../../model/mxCell'; import mxCell from '../cell/mxCell';
class mxSelectionChange { class mxSelectionChange {
selectionModel: mxGraphSelectionModel selectionModel: mxGraphSelectionModel;
added: mxCell[]; added: mxCell[];
removed: mxCell[]; removed: mxCell[];

View File

@ -93,7 +93,7 @@ const mxPerimeter = {
RectanglePerimeter(bounds: mxRectangle, RectanglePerimeter(bounds: mxRectangle,
vertex: mxCellState, vertex: mxCellState,
next: mxPoint, next: mxPoint,
orthogonal: boolean=false) { orthogonal: boolean=false): mxPoint {
const cx = bounds.getCenterX(); const cx = bounds.getCenterX();
const cy = bounds.getCenterY(); const cy = bounds.getCenterY();
@ -154,7 +154,7 @@ const mxPerimeter = {
EllipsePerimeter(bounds: mxRectangle, EllipsePerimeter(bounds: mxRectangle,
vertex: mxCellState, vertex: mxCellState,
next: mxPoint, next: mxPoint,
orthogonal: boolean=false) { orthogonal: boolean=false): mxPoint {
const { x } = bounds; const { x } = bounds;
const { y } = bounds; const { y } = bounds;
const a = bounds.width / 2; const a = bounds.width / 2;
@ -166,8 +166,8 @@ const mxPerimeter = {
// Calculates straight line equation through // Calculates straight line equation through
// point and ellipse center y = d * x + h // point and ellipse center y = d * x + h
const dx = parseInt(px - cx); const dx = parseInt(String(px - cx));
const dy = parseInt(py - cy); const dy = parseInt(String(py - cy));
if (dx === 0 && dy !== 0) { if (dx === 0 && dy !== 0) {
return new mxPoint(cx, cy + (b * dy) / Math.abs(dy)); return new mxPoint(cx, cy + (b * dy) / Math.abs(dy));
@ -240,7 +240,7 @@ const mxPerimeter = {
RhombusPerimeter(bounds: mxRectangle, RhombusPerimeter(bounds: mxRectangle,
vertex: mxCellState, vertex: mxCellState,
next: mxPoint, next: mxPoint,
orthogonal: boolean=false) { orthogonal: boolean=false): mxPoint {
const { x } = bounds; const { x } = bounds;
const { y } = bounds; const { y } = bounds;
const w = bounds.width; const w = bounds.width;
@ -300,7 +300,7 @@ const mxPerimeter = {
TrianglePerimeter(bounds: mxRectangle, TrianglePerimeter(bounds: mxRectangle,
vertex: mxCellState, vertex: mxCellState,
next: mxPoint, next: mxPoint,
orthogonal: boolean=false) { orthogonal: boolean=false): mxPoint {
const direction = const direction =
vertex != null ? vertex.style[mxConstants.STYLE_DIRECTION] : null; vertex != null ? vertex.style[mxConstants.STYLE_DIRECTION] : null;
const vertical = const vertical =
@ -430,7 +430,6 @@ const mxPerimeter = {
if (result == null) { if (result == null) {
result = new mxPoint(cx, cy); result = new mxPoint(cx, cy);
} }
return result; return result;
}, },
@ -443,7 +442,7 @@ const mxPerimeter = {
HexagonPerimeter(bounds: mxRectangle, HexagonPerimeter(bounds: mxRectangle,
vertex: mxCellState, vertex: mxCellState,
next: mxPoint, next: mxPoint,
orthogonal: boolean=false) { orthogonal: boolean=false): mxPoint {
const { x } = bounds; const { x } = bounds;
const { y } = bounds; const { y } = bounds;
@ -743,7 +742,6 @@ const mxPerimeter = {
if (result == null) { if (result == null) {
return new mxPoint(cx, cy); return new mxPoint(cx, cy);
} }
return result; return result;
}, },
}; };

View File

@ -0,0 +1,27 @@
class ExampleBase {
props: object;
constructor(props: object) {
this.props = props;
}
appendToElement(element): HTMLElement {
const html: string = this.getHTML();
const cont: HTMLElement =
document.createElement('div');
cont.innerHTML = html;
this.afterHTMLSet()
element.appendChild(cont);
return cont;
}
getHTML(): void {
throw new Error("Not implemented");
}
afterHTMLSet(): void {
throw new Error("Not implemented");
}
}
export default ExampleBase;

View File

@ -1,272 +0,0 @@
/**
* Copyright (c) 2006-2013, JGraph Ltd
* Converted to ES9 syntax/React by David Morrissey 2021
*/
import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxRectangle from '../../mxgraph/util/mxRectangle';
import mxUtils from '../../mxgraph/util/mxUtils';
import mxPoint from '../../mxgraph/util/mxPoint';
class ExtendCanvas extends React.Component {
constructor(props) {
super(props);
}
render() {
// A container for the graph
return (
<>
<h1>Extend canvas</h1>
This example demonstrates implementing an infinite canvas with
scrollbars.
<div
ref={el => {
this.el = el;
}}
style={{
position: 'relative',
overflow: 'auto',
height: '241px',
background: "url('editors/images/grid.gif')",
cursor: 'default',
}}
/>
</>
);
}
componentDidMount() {
// Disables the built-in context menu
mxEvent.disableContextMenu(this.el);
/**
* Specifies the size of the size for "tiles" to be used for a graph with
* scrollbars but no visible background page. A good value is large
* enough to reduce the number of repaints that is caused for auto-
* translation, which depends on this value, and small enough to give
* a small empty buffer around the graph. Default is 400x400.
*/
const scrollTileSize = new mxRectangle(0, 0, 400, 400);
class MyCustomGraph extends mxGraph {
/**
* Returns the padding for pages in page view with scrollbars.
*/
getPagePadding() {
return new mxPoint(
Math.max(0, Math.round(this.container.offsetWidth - 34)),
Math.max(0, Math.round(this.container.offsetHeight - 34))
);
}
/**
* Returns the size of the page format scaled with the page size.
*/
getPageSize() {
return this.pageVisible
? new mxRectangle(
0,
0,
this.pageFormat.width * this.pageScale,
this.pageFormat.height * this.pageScale
)
: scrollTileSize;
}
/**
* Returns a rectangle describing the position and count of the
* background pages, where x and y are the position of the top,
* left page and width and height are the vertical and horizontal
* page count.
*/
getPageLayout() {
const size = this.pageVisible
? this.getPageSize()
: scrollTileSize;
const bounds = this.getGraphBounds();
if (bounds.width === 0 || bounds.height === 0) {
return new mxRectangle(0, 0, 1, 1);
}
// Computes untransformed graph bounds
const x = Math.ceil(bounds.x / this.view.scale - this.view.translate.x);
const y = Math.ceil(bounds.y / this.view.scale - this.view.translate.y);
const w = Math.floor(bounds.width / this.view.scale);
const h = Math.floor(bounds.height / this.view.scale);
const x0 = Math.floor(x / size.width);
const y0 = Math.floor(y / size.height);
const w0 = Math.ceil((x + w) / size.width) - x0;
const h0 = Math.ceil((y + h) / size.height) - y0;
return new mxRectangle(x0, y0, w0, h0);
}
getPreferredPageSize(bounds, width, height) {
const pages = this.getPageLayout();
const size = this.getPageSize();
return new mxRectangle(
0,
0,
pages.width * size.width,
pages.height * size.height
);
}
sizeDidChange() {
if (this.container != null && mxUtils.hasScrollbars(this.container)) {
const pages = this.getPageLayout();
const pad = this.getPagePadding();
const size = this.getPageSize();
// Updates the minimum graph size
const minw = Math.ceil(
(2 * pad.x) / this.view.scale + pages.width * size.width
);
const minh = Math.ceil(
(2 * pad.y) / this.view.scale + pages.height * size.height
);
const min = this.minimumGraphSize;
// LATER: Fix flicker of scrollbar size in IE quirks mode
// after delayed call in window.resize event handler
if (min == null || min.width !== minw || min.height !== minh) {
this.minimumGraphSize = new mxRectangle(0, 0, minw, minh);
}
// Updates auto-translate to include padding and graph size
const dx = pad.x / this.view.scale - pages.x * size.width;
const dy = pad.y / this.view.scale - pages.y * size.height;
if (
!this.autoTranslate &&
(this.view.translate.x !== dx || this.view.translate.y !== dy)
) {
this.autoTranslate = true;
this.view.x0 = pages.x;
this.view.y0 = pages.y;
// NOTE: THIS INVOKES THIS METHOD AGAIN. UNFORTUNATELY THERE IS NO WAY AROUND THIS SINCE THE
// BOUNDS ARE KNOWN AFTER THE VALIDATION AND SETTING THE TRANSLATE TRIGGERS A REVALIDATION.
// SHOULD MOVE TRANSLATE/SCALE TO VIEW.
const tx = this.view.translate.x;
const ty = this.view.translate.y;
this.view.setTranslate(dx, dy);
this.container.scrollLeft += (dx - tx) * this.view.scale;
this.container.scrollTop += (dy - ty) * this.view.scale;
this.autoTranslate = false;
return;
}
super.sizeDidChange();
}
}
}
// Creates the graph inside the given container
const graph = this.graph = new MyCustomGraph(this.el);
graph.panningHandler.ignoreCell = true;
graph.setPanning(true);
// Fits the number of background pages to the graph
graph.view.getBackgroundPageBounds = function() {
const layout = this.graph.getPageLayout();
const page = this.graph.getPageSize();
return new mxRectangle(
this.scale * (this.translate.x + layout.x * page.width),
this.scale * (this.translate.y + layout.y * page.height),
this.scale * layout.width * page.width,
this.scale * layout.height * page.height
);
};
/**
* Guesses autoTranslate to avoid another repaint (see below).
* Works if only the scale of the graph changes or if pages
* are visible and the visible pages do not change.
*/
const graphViewValidate = graph.view.validate;
graph.view.validate = function() {
if (
this.graph.container != null &&
mxUtils.hasScrollbars(this.graph.container)
) {
const pad = this.graph.getPagePadding();
const size = this.graph.getPageSize();
// Updating scrollbars here causes flickering in quirks and is not needed
// if zoom method is always used to set the current scale on the graph.
const tx = this.translate.x;
const ty = this.translate.y;
this.translate.x = pad.x / this.scale - (this.x0 || 0) * size.width;
this.translate.y = pad.y / this.scale - (this.y0 || 0) * size.height;
}
graphViewValidate.apply(this, arguments);
};
// Enables rubberband selection
new mxRubberband(graph);
// Gets the default parent for inserting new cells. This
// is normally the first child of the root (ie. layer 0).
const parent = graph.getDefaultParent();
// Adds cells to the model in a single step
graph.batchUpdate(() => {
const v1 = graph.insertVertex({
parent,
value: 'Hello,',
position: [20, 20],
size: [80, 30],
});
const v2 = graph.insertVertex({
parent,
value: 'World!',
position: [200, 150],
size: [80, 30],
});
const e1 = graph.insertEdge({
parent,
source: v1,
target: v2,
});
});
// Sets initial scrollbar positions
window.setTimeout(() => {
const bounds = graph.getGraphBounds();
const width = Math.max(
bounds.width,
scrollTileSize.width * graph.view.scale
);
const height = Math.max(
bounds.height,
scrollTileSize.height * graph.view.scale
);
graph.container.scrollTop = Math.floor(
Math.max(
0,
bounds.y - Math.max(20, (graph.container.clientHeight - height) / 4)
)
);
graph.container.scrollLeft = Math.floor(
Math.max(
0,
bounds.x - Math.max(0, (graph.container.clientWidth - width) / 2)
)
);
}, 0);
}
}
export default ExtendCanvas;

View File

@ -0,0 +1,282 @@
/**
* Copyright (c) 2006-2013, JGraph Ltd
* Converted to ES9 syntax/React by David Morrissey 2021
*/
import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxGraphView from '../../mxgraph/view/graph/mxGraphView'
import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxRectangle from '../../mxgraph/util/datatypes/mxRectangle';
import mxUtils from '../../mxgraph/util/mxUtils';
import mxPoint from '../../mxgraph/util/datatypes/mxPoint';
import mxCell from '../../mxgraph/view/cell/mxCell';
import ExampleBase from "./ExampleBase";
/**
* Specifies the size of the size for "tiles" to be used for a graph with
* scrollbars but no visible background page. A good value is large
* enough to reduce the number of repaints that is caused for auto-
* translation, which depends on this value, and small enough to give
* a small empty buffer around the graph. Default is 400x400.
*/
const scrollTileSize = new mxRectangle(0, 0, 400, 400);
class ExtendCanvas extends ExampleBase {
constructor(props) {
super(props);
}
getHTML() {
// A container for the graph
return `
<h1>Extend canvas</h1>
This example demonstrates implementing an infinite canvas with
scrollbars.
<div id="el"
style="position: relative;
overflow: auto;
height: 241px;
background: url('editors/images/grid.gif');
cursor: default"
/>
`;
}
afterHTMLSet(): void {
// Executed after the HTML has been set
const el = document.getElementById("el");
el.id = '';
// Disables the built-in context menu
mxEvent.disableContextMenu(el);
// Creates the graph inside the given container
const graph: MyCustomGraph = new MyCustomGraph(el);
graph.panningHandler.ignoreCell = true;
graph.setPanning(true);
// Enables rubberband selection
new mxRubberband(graph);
// Gets the default parent for inserting new cells. This
// is normally the first child of the root (ie. layer 0).
const parent = graph.getDefaultParent();
// Adds cells to the model in a single step
graph.batchUpdate(() => {
const v1: mxCell = graph.insertVertex({
parent,
value: 'Hello,',
position: [20, 20],
size: [80, 30],
});
const v2: mxCell = graph.insertVertex({
parent,
value: 'World!',
position: [200, 150],
size: [80, 30],
});
const e1: mxCell = graph.insertEdge({
parent,
source: v1,
target: v2,
});
});
// Sets initial scrollbar positions
window.setTimeout(() => {
const bounds: mxRectangle = graph.getGraphBounds();
const width: number = Math.max(
bounds.width,
scrollTileSize.width * graph.view.scale
);
const height: number = Math.max(
bounds.height,
scrollTileSize.height * graph.view.scale
);
graph.container.scrollTop = Math.floor(
Math.max(
0,
bounds.y - Math.max(20, (graph.container.clientHeight - height) / 4)
)
);
graph.container.scrollLeft = Math.floor(
Math.max(
0,
bounds.x - Math.max(0, (graph.container.clientWidth - width) / 2)
)
);
}, 0);
}
}
class MyCustomGraph extends mxGraph {
autoTranslate: boolean;
createGraphView(): mxGraphView {
return new MyCustomGraphView(this);
}
/**
* Returns the padding for pages in page view with scrollbars.
*/
getPagePadding(): mxPoint {
return new mxPoint(
Math.max(0, Math.round(this.container.offsetWidth - 34)),
Math.max(0, Math.round(this.container.offsetHeight - 34))
);
}
/**
* Returns the size of the page format scaled with the page size.
*/
getPageSize(): mxRectangle {
return this.pageVisible
? new mxRectangle(
0,
0,
this.pageFormat.width * this.pageScale,
this.pageFormat.height * this.pageScale
)
: scrollTileSize;
}
/**
* Returns a rectangle describing the position and count of the
* background pages, where x and y are the position of the top,
* left page and width and height are the vertical and horizontal
* page count.
*/
getPageLayout(): mxRectangle {
const size: mxRectangle = this.pageVisible
? this.getPageSize()
: scrollTileSize;
const bounds = this.getGraphBounds();
if (bounds.width === 0 || bounds.height === 0) {
return new mxRectangle(0, 0, 1, 1);
}
// Computes untransformed graph bounds
const x: number = Math.ceil(bounds.x / this.view.scale - this.view.translate.x);
const y: number = Math.ceil(bounds.y / this.view.scale - this.view.translate.y);
const w: number = Math.floor(bounds.width / this.view.scale);
const h: number = Math.floor(bounds.height / this.view.scale);
const x0: number = Math.floor(x / size.width);
const y0: number = Math.floor(y / size.height);
const w0: number = Math.ceil((x + w) / size.width) - x0;
const h0: number = Math.ceil((y + h) / size.height) - y0;
return new mxRectangle(x0, y0, w0, h0);
}
getPreferredPageSize(bounds, width, height): mxRectangle {
const pages: mxRectangle = this.getPageLayout();
const size: mxRectangle = this.getPageSize();
return new mxRectangle(
0,
0,
pages.width * size.width,
pages.height * size.height
);
}
sizeDidChange(): mxRectangle {
if (this.container != null && mxUtils.hasScrollbars(this.container)) {
const pages: mxRectangle = this.getPageLayout();
const pad: mxPoint = this.getPagePadding();
const size: mxRectangle = this.getPageSize();
// Updates the minimum graph size
const minw: number = Math.ceil(
(2 * pad.x) / this.view.scale + pages.width * size.width
);
const minh: number = Math.ceil(
(2 * pad.y) / this.view.scale + pages.height * size.height
);
const min: number = this.minimumGraphSize;
// LATER: Fix flicker of scrollbar size in IE quirks mode
// after delayed call in window.resize event handler
if (min == null || min.width !== minw || min.height !== minh) {
this.minimumGraphSize = new mxRectangle(0, 0, minw, minh);
}
// Updates auto-translate to include padding and graph size
const dx: number = pad.x / this.view.scale - pages.x * size.width;
const dy: number = pad.y / this.view.scale - pages.y * size.height;
if (
!this.autoTranslate &&
(this.view.translate.x !== dx || this.view.translate.y !== dy)
) {
this.autoTranslate = true;
this.view.x0 = pages.x;
this.view.y0 = pages.y;
// NOTE: THIS INVOKES THIS METHOD AGAIN. UNFORTUNATELY THERE IS NO WAY AROUND THIS SINCE THE
// BOUNDS ARE KNOWN AFTER THE VALIDATION AND SETTING THE TRANSLATE TRIGGERS A REVALIDATION.
// SHOULD MOVE TRANSLATE/SCALE TO VIEW.
const tx: number = this.view.translate.x;
const ty: number = this.view.translate.y;
this.view.setTranslate(dx, dy);
this.container.scrollLeft += (dx - tx) * this.view.scale;
this.container.scrollTop += (dy - ty) * this.view.scale;
this.autoTranslate = false;
return;
}
super.sizeDidChange();
}
}
}
class MyCustomGraphView extends mxGraphView {
/**
* Fits the number of background pages to the graph
*/
getBackgroundPageBounds(): mxRectangle {
const layout: mxRectangle = this.graph.getPageLayout();
const page: mxRectangle = this.graph.getPageSize();
return new mxRectangle(
this.scale * (this.translate.x + layout.x * page.width),
this.scale * (this.translate.y + layout.y * page.height),
this.scale * layout.width * page.width,
this.scale * layout.height * page.height
);
}
/**
* Guesses autoTranslate to avoid another repaint (see below).
* Works if only the scale of the graph changes or if pages
* are visible and the visible pages do not change.
*/
validate(): void {
if (
this.graph.container != null &&
mxUtils.hasScrollbars(this.graph.container)
) {
const pad: mxPoint = this.graph.getPagePadding();
const size: mxRectangle = this.graph.getPageSize();
// Updating scrollbars here causes flickering in quirks and is not needed
// if zoom method is always used to set the current scale on the graph.
//const tx = this.translate.x;
//const ty = this.translate.y;
this.translate.x = pad.x / this.scale - (this.x0 || 0) * size.width;
this.translate.y = pad.y / this.scale - (this.y0 || 0) * size.height;
}
super.validate();
};
}
export default ExtendCanvas;

View File

@ -4,13 +4,13 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxPoint from '../../mxgraph/util/mxPoint'; import mxPoint from '../../mxgraph/util/datatypes/mxPoint';
import mxLog from '../../mxgraph/util/mxLog'; import mxLog from '../../mxgraph/util/gui/mxLog';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
import mxGraphView from '../../mxgraph/view/mxGraphView'; import mxGraphView from '../../mxgraph/view/graph/mxGraphView';
class Grid extends React.Component { class Grid extends React.Component {
constructor(props) { constructor(props) {

View File

@ -4,8 +4,8 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
class HelloWorld extends React.Component { class HelloWorld extends React.Component {

View File

@ -9,7 +9,7 @@
*/ */
import React from 'react'; import React from 'react';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
import mxCodec from '../../mxgraph/io/mxCodec'; import mxCodec from '../../mxgraph/io/mxCodec';

View File

@ -4,109 +4,22 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxShape from '../../mxgraph/shape/mxShape'; import mxShape from '../../mxgraph/shape/mxShape';
import mxConnectionConstraint from '../../mxgraph/view/mxConnectionConstraint'; import mxConnectionConstraint from '../../mxgraph/view/connection/mxConnectionConstraint';
import mxPoint from '../../mxgraph/util/mxPoint'; import mxPoint from '../../mxgraph/util/datatypes/mxPoint';
import mxPolyline from '../../mxgraph/shape/mxPolyline'; import mxPolyline from '../../mxgraph/shape/edge/mxPolyline';
import mxCellState from '../../mxgraph/view/mxCellState'; import mxCellState from '../../mxgraph/view/cell/mxCellState';
import mxGeometry from "../../mxgraph/util/datatypes/mxGeometry";
import mxConnectionHandler from "../../mxgraph/handler/mxConnectionHandler";
class Anchors extends React.Component { class Anchors extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
} }
componentDidMount() {
// Overridden to define per-shape connection points
mxGraph.prototype.getAllConnectionConstraints = function(terminal, source) {
if (terminal != null && terminal.shape != null) {
if (terminal.shape.stencil != null) {
if (terminal.shape.stencil.constraints != null) {
return terminal.shape.stencil.constraints;
}
} else if (terminal.shape.constraints != null) {
return terminal.shape.constraints;
}
}
return null;
};
// Defines the default constraints for all shapes
mxShape.prototype.constraints = [
new mxConnectionConstraint(new mxPoint(0.25, 0), true),
new mxConnectionConstraint(new mxPoint(0.5, 0), true),
new mxConnectionConstraint(new mxPoint(0.75, 0), true),
new mxConnectionConstraint(new mxPoint(0, 0.25), true),
new mxConnectionConstraint(new mxPoint(0, 0.5), true),
new mxConnectionConstraint(new mxPoint(0, 0.75), true),
new mxConnectionConstraint(new mxPoint(1, 0.25), true),
new mxConnectionConstraint(new mxPoint(1, 0.5), true),
new mxConnectionConstraint(new mxPoint(1, 0.75), true),
new mxConnectionConstraint(new mxPoint(0.25, 1), true),
new mxConnectionConstraint(new mxPoint(0.5, 1), true),
new mxConnectionConstraint(new mxPoint(0.75, 1), true),
];
// Edges have no connection points
mxPolyline.prototype.constraints = null;
// Disables the built-in context menu
mxEvent.disableContextMenu(this.el);
// Creates the graph inside the given this.el
const graph = new mxGraph(this.el);
graph.setConnectable(true);
// Enables connect preview for the default edge style
graph.connectionHandler.createEdgeState = function(me) {
const edge = graph.createEdge(null, null, null, null, null);
return new mxCellState(
this.graph.view,
edge,
this.graph.getCellStyle(edge)
);
};
// Specifies the default edge style
graph.getStylesheet().getDefaultEdgeStyle().edgeStyle =
'orthogonalEdgeStyle';
// Enables rubberband selection
new mxRubberband(graph);
// Gets the default parent for inserting new cells. This
// is normally the first child of the root (ie. layer 0).
const parent = graph.getDefaultParent();
// Adds cells to the model in a single step
graph.getModel().beginUpdate();
try {
const v1 = graph.insertVertex({
parent,
value: 'Hello,',
position: [20, 20],
size: [80, 30],
});
const v2 = graph.insertVertex({
parent,
value: 'World!',
position: [200, 150],
size: [80, 30],
});
const e1 = graph.insertEdge({
parent,
value: '',
position: v1,
size: v2,
});
} finally {
// Updates the display
graph.getModel().endUpdate();
}
}
render() { render() {
// A container for the graph // A container for the graph
return ( return (
@ -129,6 +42,103 @@ class Anchors extends React.Component {
</> </>
); );
}; };
componentDidMount() {
// Disables the built-in context menu
mxEvent.disableContextMenu(this.el);
class MyCustomConnectionHandler extends mxConnectionHandler {
// Enables connect preview for the default edge style
createEdgeState(me) {
const edge = graph.createEdge(null, null, null, null, null);
return new mxCellState(
this.graph.view,
edge,
this.graph.getCellStyle(edge)
);
}
}
class MyCustomGraph extends mxGraph {
getAllConnectionConstraints(terminal, source) {
// Overridden to define per-shape connection points
if (terminal != null && terminal.shape != null) {
if (terminal.shape.stencil != null) {
if (terminal.shape.stencil.constraints != null) {
return terminal.shape.stencil.constraints;
}
} else if (terminal.shape.constraints != null) {
return terminal.shape.constraints;
}
}
return null;
}
createConnectionHandler() {
return new MyCustomConnectionHandler(this);
}
}
class MyCustomGeometryClass extends mxGeometry {
// Defines the default constraints for the vertices
constraints = [
new mxConnectionConstraint(new mxPoint(0.25, 0), true),
new mxConnectionConstraint(new mxPoint(0.5, 0), true),
new mxConnectionConstraint(new mxPoint(0.75, 0), true),
new mxConnectionConstraint(new mxPoint(0, 0.25), true),
new mxConnectionConstraint(new mxPoint(0, 0.5), true),
new mxConnectionConstraint(new mxPoint(0, 0.75), true),
new mxConnectionConstraint(new mxPoint(1, 0.25), true),
new mxConnectionConstraint(new mxPoint(1, 0.5), true),
new mxConnectionConstraint(new mxPoint(1, 0.75), true),
new mxConnectionConstraint(new mxPoint(0.25, 1), true),
new mxConnectionConstraint(new mxPoint(0.5, 1), true),
new mxConnectionConstraint(new mxPoint(0.75, 1), true),
];
}
// Edges have no connection points
mxPolyline.prototype.constraints = null;
// Creates the graph inside the given this.el
const graph = new MyCustomGraph(this.el);
graph.setConnectable(true);
// Specifies the default edge style
graph.getStylesheet().getDefaultEdgeStyle().edgeStyle =
'orthogonalEdgeStyle';
// Enables rubberband selection
new mxRubberband(graph);
// Gets the default parent for inserting new cells. This
// is normally the first child of the root (ie. layer 0).
const parent = graph.getDefaultParent();
// Adds cells to the model in a single step
graph.batchUpdate(() => {
const v1 = graph.insertVertex({
parent,
value: 'Hello,',
position: [20, 20],
size: [80, 30],
geometryClass: MyCustomGeometryClass,
});
const v2 = graph.insertVertex({
parent,
value: 'World!',
position: [200, 150],
size: [80, 30],
geometryClass: MyCustomGeometryClass,
});
const e1 = graph.insertEdge({
parent,
value: '',
position: v1,
size: v2,
});
});
}
} }
export default Anchors; export default Anchors;

View File

@ -4,8 +4,8 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
class EdgeTolerance extends React.Component { class EdgeTolerance extends React.Component {

View File

@ -4,15 +4,15 @@
*/ */
import React from 'react'; import React from 'react';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
import mxConstraintHandler from '../../mxgraph/handler/mxConstraintHandler'; import mxConstraintHandler from '../../mxgraph/handler/mxConstraintHandler';
import mxConnectionHandler from '../../mxgraph/handler/mxConnectionHandler'; import mxConnectionHandler from '../../mxgraph/handler/mxConnectionHandler';
import mxEdgeHandler from '../../mxgraph/handler/mxEdgeHandler'; import mxEdgeHandler from '../../mxgraph/handler/mxEdgeHandler';
import mxConnectionConstraint from '../../mxgraph/view/mxConnectionConstraint'; import mxConnectionConstraint from '../../mxgraph/view/connection/mxConnectionConstraint';
import mxPoint from '../../mxgraph/util/mxPoint'; import mxPoint from '../../mxgraph/util/datatypes/mxPoint';
import mxCellState from '../../mxgraph/view/mxCellState'; import mxCellState from '../../mxgraph/view/cell/mxCellState';
class FixedPoints extends React.Component { class FixedPoints extends React.Component {
constructor(props) { constructor(props) {

View File

@ -4,12 +4,12 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxConstants from '../../mxgraph/util/mxConstants'; import mxConstants from '../../mxgraph/util/mxConstants';
import mxEdgeStyle from '../../mxgraph/view/mxEdgeStyle'; import mxEdgeStyle from '../../mxgraph/view/style/mxEdgeStyle';
import mxPoint from '../../mxgraph/util/mxPoint'; import mxPoint from '../../mxgraph/util/datatypes/mxPoint';
import mxCodec from '../../mxgraph/io/mxCodec'; import mxCodec from '../../mxgraph/io/mxCodec';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';

View File

@ -4,16 +4,16 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxGraphHandler from '../../mxgraph/handler/mxGraphHandler'; import mxGraphHandler from '../../mxgraph/handler/mxGraphHandler';
import mxGuide from '../../mxgraph/util/mxGuide'; import mxGuide from '../../mxgraph/util/mxGuide';
import mxEdgeHandler from '../../mxgraph/handler/mxEdgeHandler'; import mxEdgeHandler from '../../mxgraph/handler/mxEdgeHandler';
import mxConnectionHandler from '../../mxgraph/handler/mxConnectionHandler'; import mxConnectionHandler from '../../mxgraph/handler/mxConnectionHandler';
import mxGraphView from '../../mxgraph/view/mxGraphView'; import mxGraphView from '../../mxgraph/view/graph/mxGraphView';
import mxPoint from '../../mxgraph/util/mxPoint'; import mxPoint from '../../mxgraph/util/datatypes/mxPoint';
import mxCellState from '../../mxgraph/view/mxCellState'; import mxCellState from '../../mxgraph/view/cell/mxCellState';
class Orthogonal extends React.Component { class Orthogonal extends React.Component {
constructor(props) { constructor(props) {

View File

@ -4,16 +4,16 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxConstraintHandler from '../../mxgraph/handler/mxConstraintHandler'; import mxConstraintHandler from '../../mxgraph/handler/mxConstraintHandler';
import mxImage from '../../mxgraph/util/mxImage'; import mxImage from '../../mxgraph/util/image/mxImage';
import mxShape from '../../mxgraph/shape/mxShape'; import mxShape from '../../mxgraph/shape/mxShape';
import mxTriangle from '../../mxgraph/shape/mxTriangle'; import mxTriangle from '../../mxgraph/shape/mxTriangle';
import mxEdgeHandler from '../../mxgraph/handler/mxEdgeHandler'; import mxEdgeHandler from '../../mxgraph/handler/mxEdgeHandler';
import mxConnectionConstraint from '../../mxgraph/view/mxConnectionConstraint'; import mxConnectionConstraint from '../../mxgraph/view/connection/mxConnectionConstraint';
import mxPoint from '../../mxgraph/util/mxPoint'; import mxPoint from '../../mxgraph/util/datatypes/mxPoint';
import mxConstants from '../../mxgraph/util/mxConstants'; import mxConstants from '../../mxgraph/util/mxConstants';
class PortRefs extends React.Component { class PortRefs extends React.Component {

View File

@ -4,14 +4,14 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
import mxClipboard from '../../mxgraph/util/mxClipboard'; import mxClipboard from '../../mxgraph/util/storage/mxClipboard';
import mxClient from '../../mxgraph/mxClient'; import mxClient from '../../mxgraph/mxClient';
import mxCodec from '../../mxgraph/io/mxCodec'; import mxCodec from '../../mxgraph/io/mxCodec';
import mxGraphModel from '../../mxgraph/model/mxGraphModel'; import mxGraphModel from '../../mxgraph/view/graph/mxGraphModel';
class Clipboard extends React.Component { class Clipboard extends React.Component {
constructor(props) { constructor(props) {

View File

@ -4,13 +4,13 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxCell from '../../mxgraph/model/mxCell'; import mxCell from '../../mxgraph/view/cell/mxCell';
import mxGeometry from '../../mxgraph/model/mxGeometry'; import mxGeometry from '../../mxgraph/util/datatypes/mxGeometry';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
import mxDragSource from '../../mxgraph/util/mxDragSource'; import mxDragSource from '../../mxgraph/util/drag_pan/mxDragSource';
import mxGraphHandler from '../../mxgraph/handler/mxGraphHandler'; import mxGraphHandler from '../../mxgraph/handler/mxGraphHandler';
import mxGuide from '../../mxgraph/util/mxGuide'; import mxGuide from '../../mxgraph/util/mxGuide';
import mxEdgeHandler from '../../mxgraph/handler/mxEdgeHandler'; import mxEdgeHandler from '../../mxgraph/handler/mxEdgeHandler';

View File

@ -4,8 +4,8 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
import mxClient from '../../mxgraph/mxClient'; import mxClient from '../../mxgraph/mxClient';

View File

@ -4,8 +4,8 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
import mxKeyHandler from '../../mxgraph/handler/mxKeyHandler'; import mxKeyHandler from '../../mxgraph/handler/mxKeyHandler';

View File

@ -4,8 +4,8 @@
*/ */
import React from 'react'; import React from 'react';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxPoint from '../../mxgraph/util/mxPoint'; import mxPoint from '../../mxgraph/util/datatypes/mxPoint';
class Animation extends React.Component { class Animation extends React.Component {
constructor(props) { constructor(props) {

View File

@ -4,10 +4,10 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxMorphing from '../../mxgraph/util/mxMorphing'; import mxMorphing from '../../mxgraph/util/animate/mxMorphing';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
class Morph extends React.Component { class Morph extends React.Component {

View File

@ -4,11 +4,11 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxCellTracker from '../../mxgraph/handler/mxCellTracker'; import mxCellTracker from '../../mxgraph/handler/mxCellTracker';
import mxCellOverlay from '../../mxgraph/view/mxCellOverlay'; import mxCellOverlay from '../../mxgraph/view/cell/mxCellOverlay';
import mxImage from '../../mxgraph/util/mxImage'; import mxImage from '../../mxgraph/util/image/mxImage';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
class Overlays extends React.Component { class Overlays extends React.Component {

View File

@ -4,11 +4,11 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxConstants from '../../mxgraph/util/mxConstants'; import mxConstants from '../../mxgraph/util/mxConstants';
import mxPoint from '../../mxgraph/util/mxPoint'; import mxPoint from '../../mxgraph/util/datatypes/mxPoint';
import mxGraphHandler from '../../mxgraph/handler/mxGraphHandler'; import mxGraphHandler from '../../mxgraph/handler/mxGraphHandler';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';

View File

@ -4,17 +4,17 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
import mxConstants from '../../mxgraph/util/mxConstants'; import mxConstants from '../../mxgraph/util/mxConstants';
import mxEdgeStyle from '../../mxgraph/view/mxEdgeStyle'; import mxEdgeStyle from '../../mxgraph/view/style/mxEdgeStyle';
import mxKeyHandler from '../../mxgraph/handler/mxKeyHandler'; import mxKeyHandler from '../../mxgraph/handler/mxKeyHandler';
import mxLayoutManager from '../../mxgraph/view/mxLayoutManager'; import mxLayoutManager from '../../mxgraph/view/graph/mxLayoutManager';
import mxParallelEdgeLayout from '../../mxgraph/layout/mxParallelEdgeLayout'; import mxParallelEdgeLayout from '../../mxgraph/layout/mxParallelEdgeLayout';
import mxConnectionHandler from '../../mxgraph/handler/mxConnectionHandler'; import mxConnectionHandler from '../../mxgraph/handler/mxConnectionHandler';
import mxImage from '../../mxgraph/util/mxImage'; import mxImage from '../../mxgraph/util/image/mxImage';
import mxClient from '../../mxgraph/mxClient'; import mxClient from '../../mxgraph/mxClient';
class Events extends React.Component { class Events extends React.Component {

View File

@ -4,8 +4,8 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxVertexHandler from '../../mxgraph/handler/mxVertexHandler'; import mxVertexHandler from '../../mxgraph/handler/mxVertexHandler';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';

View File

@ -4,14 +4,14 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
import mxRectangle from '../../mxgraph/util/mxRectangle'; import mxRectangle from '../../mxgraph/util/datatypes/mxRectangle';
import mxCellRenderer from '../../mxgraph/view/mxCellRenderer'; import mxCellRenderer from '../../mxgraph/view/cell/mxCellRenderer';
import mxImageShape from '../../mxgraph/shape/mxImageShape'; import mxImageShape from '../../mxgraph/shape/node/mxImageShape';
import mxImage from '../../mxgraph/util/mxImage'; import mxImage from '../../mxgraph/util/image/mxImage';
class Control extends React.Component { class Control extends React.Component {
constructor(props) { constructor(props) {

View File

@ -4,12 +4,12 @@
*/ */
import React from 'react'; import React from 'react';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
import mxConstants from '../../mxgraph/util/mxConstants'; import mxConstants from '../../mxgraph/util/mxConstants';
import mxLabel from '../../mxgraph/shape/mxLabel'; import mxLabel from '../../mxgraph/shape/mxLabel';
import mxRectangle from '../../mxgraph/util/mxRectangle'; import mxRectangle from '../../mxgraph/util/datatypes/mxRectangle';
class FixedIcon extends React.Component { class FixedIcon extends React.Component {
constructor(props) { constructor(props) {

View File

@ -4,13 +4,13 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxConnectionHandler from '../../mxgraph/handler/mxConnectionHandler'; import mxConnectionHandler from '../../mxgraph/handler/mxConnectionHandler';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
import mxRectangle from '../../mxgraph/util/mxRectangle'; import mxRectangle from '../../mxgraph/util/datatypes/mxRectangle';
import mxImage from '../../mxgraph/util/mxImage'; import mxImage from '../../mxgraph/util/image/mxImage';
class HoverIcons extends React.Component { class HoverIcons extends React.Component {
constructor(props) { constructor(props) {

View File

@ -4,14 +4,14 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxConstants from '../../mxgraph/util/mxConstants'; import mxConstants from '../../mxgraph/util/mxConstants';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
import mxRectangle from '../../mxgraph/util/mxRectangle'; import mxRectangle from '../../mxgraph/util/datatypes/mxRectangle';
import mxImage from '../../mxgraph/util/mxImage'; import mxImage from '../../mxgraph/util/image/mxImage';
import mxPerimeter from '../../mxgraph/view/mxPerimeter'; import mxPerimeter from '../../mxgraph/view/style/mxPerimeter';
class Images extends React.Component { class Images extends React.Component {
constructor(props) { constructor(props) {

View File

@ -4,9 +4,9 @@
*/ */
import React from 'react'; import React from 'react';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxConstants from '../../mxgraph/util/mxConstants'; import mxConstants from '../../mxgraph/util/mxConstants';
import mxEdgeStyle from '../../mxgraph/view/mxEdgeStyle'; import mxEdgeStyle from '../../mxgraph/view/style/mxEdgeStyle';
import mxKeyHandler from '../../mxgraph/handler/mxKeyHandler'; import mxKeyHandler from '../../mxgraph/handler/mxKeyHandler';
class Indicators extends React.Component { class Indicators extends React.Component {

View File

@ -4,14 +4,14 @@
*/ */
import React from 'react'; import React from 'react';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxPoint from '../../mxgraph/util/mxPoint'; import mxPoint from '../../mxgraph/util/datatypes/mxPoint';
import mxCellRenderer from '../../mxgraph/view/mxCellRenderer'; import mxCellRenderer from '../../mxgraph/view/cell/mxCellRenderer';
import mxEdgeHandler from '../../mxgraph/handler/mxEdgeHandler'; import mxEdgeHandler from '../../mxgraph/handler/mxEdgeHandler';
import mxGraphHandler from '../../mxgraph/handler/mxGraphHandler'; import mxGraphHandler from '../../mxgraph/handler/mxGraphHandler';
import mxCylinder from '../../mxgraph/shape/mxCylinder'; import mxCylinder from '../../mxgraph/shape/node/mxCylinder';
import mxMarker from '../../mxgraph/shape/mxMarker'; import mxMarker from '../../mxgraph/shape/edge/mxMarker';
import mxArrow from '../../mxgraph/shape/mxArrow'; import mxArrow from '../../mxgraph/shape/edge/mxArrow';
class Markers extends React.Component { class Markers extends React.Component {
constructor(props) { constructor(props) {

View File

@ -4,7 +4,7 @@
*/ */
import React from 'react'; import React from 'react';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
class LabelPosition extends React.Component { class LabelPosition extends React.Component {
constructor(props) { constructor(props) {

View File

@ -4,11 +4,11 @@
*/ */
import React from 'react'; import React from 'react';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxKeyHandler from '../../mxgraph/handler/mxKeyHandler'; import mxKeyHandler from '../../mxgraph/handler/mxKeyHandler';
import mxConstants from '../../mxgraph/util/mxConstants'; import mxConstants from '../../mxgraph/util/mxConstants';
import mxRectangle from '../../mxgraph/util/mxRectangle'; import mxRectangle from '../../mxgraph/util/datatypes/mxRectangle';
class Labels extends React.Component { class Labels extends React.Component {
constructor(props) { constructor(props) {

View File

@ -4,11 +4,11 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
import mxGraphView from '../../mxgraph/view/mxGraphView'; import mxGraphView from '../../mxgraph/view/graph/mxGraphView';
class Perimeter extends React.Component { class Perimeter extends React.Component {
constructor(props) { constructor(props) {

View File

@ -4,12 +4,12 @@
*/ */
import React from 'react'; import React from 'react';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
import mxPoint from '../../mxgraph/util/mxPoint'; import mxPoint from '../../mxgraph/util/datatypes/mxPoint';
import mxRectangle from '../../mxgraph/util/mxRectangle'; import mxRectangle from '../../mxgraph/util/datatypes/mxRectangle';
import mxConstants from '../../mxgraph/util/mxConstants'; import mxConstants from '../../mxgraph/util/mxConstants';
import mxRectangleShape from '../../mxgraph/shape/mxRectangleShape'; import mxRectangleShape from '../../mxgraph/shape/node/mxRectangleShape';
import mxText from '../../mxgraph/shape/mxText'; import mxText from '../../mxgraph/shape/mxText';
class SecondLabel extends React.Component { class SecondLabel extends React.Component {

View File

@ -4,7 +4,7 @@
*/ */
import React from 'react'; import React from 'react';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
class Wrapping extends React.Component { class Wrapping extends React.Component {
constructor(props) { constructor(props) {

View File

@ -4,19 +4,19 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxClient from '../../mxgraph/mxClient'; import mxClient from '../../mxgraph/mxClient';
import mxMorphing from '../../mxgraph/util/mxMorphing'; import mxMorphing from '../../mxgraph/util/animate/mxMorphing';
import mxEdgeHandler from '../../mxgraph/handler/mxEdgeHandler'; import mxEdgeHandler from '../../mxgraph/handler/mxEdgeHandler';
import mxHierarchicalLayout from '../../mxgraph/layout/hierarchical/mxHierarchicalLayout'; import mxHierarchicalLayout from '../../mxgraph/layout/hierarchical/mxHierarchicalLayout';
import mxConstants from '../../mxgraph/util/mxConstants'; import mxConstants from '../../mxgraph/util/mxConstants';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
import mxCellOverlay from '../../mxgraph/view/mxCellOverlay'; import mxCellOverlay from '../../mxgraph/view/cell/mxCellOverlay';
import mxImage from '../../mxgraph/util/mxImage'; import mxImage from '../../mxgraph/util/image/mxImage';
import mxEventObject from '../../mxgraph/util/mxEventObject'; import mxEventObject from '../../mxgraph/util/event/mxEventObject';
import mxCellRenderer from '../../mxgraph/view/mxCellRenderer'; import mxCellRenderer from '../../mxgraph/view/cell/mxCellRenderer';
class AutoLayout extends React.Component { class AutoLayout extends React.Component {
constructor(props) { constructor(props) {

View File

@ -4,9 +4,9 @@
*/ */
import React from 'react'; import React from 'react';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRectangle from '../../mxgraph/util/mxRectangle'; import mxRectangle from '../../mxgraph/util/datatypes/mxRectangle';
import mxGraphModel from '../../mxgraph/model/mxGraphModel'; import mxGraphModel from '../../mxgraph/view/graph/mxGraphModel';
class Collapse extends React.Component { class Collapse extends React.Component {
constructor(props) { constructor(props) {

View File

@ -4,8 +4,8 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxGraphHandler from '../../mxgraph/handler/mxGraphHandler'; import mxGraphHandler from '../../mxgraph/handler/mxGraphHandler';

View File

@ -4,10 +4,10 @@
*/ */
import React from 'react'; import React from 'react';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxConstants from '../../mxgraph/util/mxConstants'; import mxConstants from '../../mxgraph/util/mxConstants';
import mxEdgeStyle from '../../mxgraph/view/mxEdgeStyle'; import mxEdgeStyle from '../../mxgraph/view/style/mxEdgeStyle';
import mxLayoutManager from '../../mxgraph/view/mxLayoutManager'; import mxLayoutManager from '../../mxgraph/view/graph/mxLayoutManager';
import mxStackLayout from '../../mxgraph/layout/mxStackLayout'; import mxStackLayout from '../../mxgraph/layout/mxStackLayout';
class Folding extends React.Component { class Folding extends React.Component {

View File

@ -4,7 +4,7 @@
*/ */
import React from 'react'; import React from 'react';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxGraphHandler from '../../mxgraph/handler/mxGraphHandler'; import mxGraphHandler from '../../mxgraph/handler/mxGraphHandler';
import mxPopupMenuHandler from '../../mxgraph/handler/mxPopupMenuHandler'; import mxPopupMenuHandler from '../../mxgraph/handler/mxPopupMenuHandler';

View File

@ -4,15 +4,15 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
import mxVertexHandler from '../../mxgraph/handler/mxVertexHandler'; import mxVertexHandler from '../../mxgraph/handler/mxVertexHandler';
import mxCellRenderer from '../../mxgraph/view/mxCellRenderer'; import mxCellRenderer from '../../mxgraph/view/cell/mxCellRenderer';
import mxRectangle from '../../mxgraph/util/mxRectangle'; import mxRectangle from '../../mxgraph/util/datatypes/mxRectangle';
import mxCylinder from '../../mxgraph/shape/mxCylinder'; import mxCylinder from '../../mxgraph/shape/node/mxCylinder';
import mxPoint from '../../mxgraph/util/mxPoint'; import mxPoint from '../../mxgraph/util/datatypes/mxPoint';
import mxHandle from '../../mxgraph/handler/mxHandle'; import mxHandle from '../../mxgraph/handler/mxHandle';
class Handles extends React.Component { class Handles extends React.Component {

View File

@ -4,13 +4,13 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxHierarchicalLayout from '../../mxgraph/layout/hierarchical/mxHierarchicalLayout'; import mxHierarchicalLayout from '../../mxgraph/layout/hierarchical/mxHierarchicalLayout';
import mxFastOrganicLayout from '../../mxgraph/layout/mxFastOrganicLayout'; import mxFastOrganicLayout from '../../mxgraph/layout/mxFastOrganicLayout';
import mxConstants from '../../mxgraph/util/mxConstants'; import mxConstants from '../../mxgraph/util/mxConstants';
import mxPerimeter from '../../mxgraph/view/mxPerimeter'; import mxPerimeter from '../../mxgraph/view/style/mxPerimeter';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
class HierarchicalLayout extends React.Component { class HierarchicalLayout extends React.Component {

View File

@ -4,10 +4,10 @@
*/ */
import React from 'react'; import React from 'react';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxCell from '../../mxgraph/model/mxCell'; import mxCell from '../../mxgraph/view/cell/mxCell';
import mxGraphModel from '../../mxgraph/model/mxGraphModel'; import mxGraphModel from '../../mxgraph/view/graph/mxGraphModel';
import mxPoint from '../../mxgraph/util/mxPoint'; import mxPoint from '../../mxgraph/util/datatypes/mxPoint';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
class Layers extends React.Component { class Layers extends React.Component {

View File

@ -7,23 +7,23 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxPrintPreview from '../../mxgraph/view/mxPrintPreview'; import mxPrintPreview from '../../mxgraph/view/graph/mxPrintPreview';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
import mxCellOverlay from '../../mxgraph/view/mxCellOverlay'; import mxCellOverlay from '../../mxgraph/view/cell/mxCellOverlay';
import mxImage from '../../mxgraph/util/mxImage'; import mxImage from '../../mxgraph/util/image/mxImage';
import mxPoint from '../../mxgraph/util/mxPoint'; import mxPoint from '../../mxgraph/util/datatypes/mxPoint';
import mxConstants from '../../mxgraph/util/mxConstants'; import mxConstants from '../../mxgraph/util/mxConstants';
import mxWindow from '../../mxgraph/util/mxWindow'; import mxWindow from '../../mxgraph/util/gui/mxWindow';
import mxToolbar from '../../mxgraph/util/mxToolbar'; import mxToolbar from '../../mxgraph/util/gui/mxToolbar';
import mxLayoutManager from '../../mxgraph/view/mxLayoutManager'; import mxLayoutManager from '../../mxgraph/view/graph/mxLayoutManager';
import mxEdgeStyle from '../../mxgraph/view/mxEdgeStyle'; import mxEdgeStyle from '../../mxgraph/view/style/mxEdgeStyle';
import mxCompactTreeLayout from '../../mxgraph/layout/mxCompactTreeLayout'; import mxCompactTreeLayout from '../../mxgraph/layout/mxCompactTreeLayout';
import mxKeyHandler from '../../mxgraph/handler/mxKeyHandler'; import mxKeyHandler from '../../mxgraph/handler/mxKeyHandler';
import mxClient from '../../mxgraph/mxClient'; import mxClient from '../../mxgraph/mxClient';
import mxOutline from '../../mxgraph/view/mxOutline'; import mxOutline from '../../mxgraph/view/graph/mxOutline';
class OrgChart extends React.Component { class OrgChart extends React.Component {
constructor(props) { constructor(props) {

View File

@ -4,9 +4,9 @@
*/ */
import React from 'react'; import React from 'react';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxPerimeter from '../../mxgraph/view/mxPerimeter'; import mxPerimeter from '../../mxgraph/view/style/mxPerimeter';
import mxConstants from '../../mxgraph/util/mxConstants'; import mxConstants from '../../mxgraph/util/mxConstants';
import mxRadialTreeLayout from '../../mxgraph/layout/mxRadialTreeLayout'; import mxRadialTreeLayout from '../../mxgraph/layout/mxRadialTreeLayout';

View File

@ -4,21 +4,21 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxRubberband from '../../mxgraph/handler/mxRubberband'; import mxRubberband from '../../mxgraph/handler/mxRubberband';
import mxPoint from '../../mxgraph/util/mxPoint'; import mxPoint from '../../mxgraph/util/datatypes/mxPoint';
import mxStackLayout from '../../mxgraph/layout/mxStackLayout'; import mxStackLayout from '../../mxgraph/layout/mxStackLayout';
import mxSwimlaneManager from '../../mxgraph/view/mxSwimlaneManager'; import mxSwimlaneManager from '../../mxgraph/view/graph/mxSwimlaneManager';
import mxGraphModel from '../../mxgraph/model/mxGraphModel'; import mxGraphModel from '../../mxgraph/view/graph/mxGraphModel';
import mxConstants from '../../mxgraph/util/mxConstants'; import mxConstants from '../../mxgraph/util/mxConstants';
import mxPerimeter from '../../mxgraph/view/mxPerimeter'; import mxPerimeter from '../../mxgraph/view/style/mxPerimeter';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
import mxEditor from '../../mxgraph/editor/mxEditor'; import mxEditor from '../../mxgraph/editor/mxEditor';
import mxConnectionHandler from '../../mxgraph/handler/mxConnectionHandler'; import mxConnectionHandler from '../../mxgraph/handler/mxConnectionHandler';
import mxImage from '../../mxgraph/util/mxImage'; import mxImage from '../../mxgraph/util/image/mxImage';
import mxLayoutManager from '../../mxgraph/view/mxLayoutManager'; import mxLayoutManager from '../../mxgraph/view/graph/mxLayoutManager';
import mxEdgeStyle from '../../mxgraph/view/mxEdgeStyle'; import mxEdgeStyle from '../../mxgraph/view/style/mxEdgeStyle';
class SwimLanes extends React.Component { class SwimLanes extends React.Component {
constructor(props) { constructor(props) {

View File

@ -4,20 +4,20 @@
*/ */
import React from 'react'; import React from 'react';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxPoint from '../../mxgraph/util/mxPoint'; import mxPoint from '../../mxgraph/util/datatypes/mxPoint';
import mxGraphView from '../../mxgraph/view/mxGraphView'; import mxGraphView from '../../mxgraph/view/graph/mxGraphView';
import mxCellRenderer from '../../mxgraph/view/mxCellRenderer'; import mxCellRenderer from '../../mxgraph/view/cell/mxCellRenderer';
import mxCylinder from '../../mxgraph/shape/mxCylinder'; import mxCylinder from '../../mxgraph/shape/node/mxCylinder';
import mxImage from '../../mxgraph/util/mxImage'; import mxImage from '../../mxgraph/util/image/mxImage';
import mxConstants from '../../mxgraph/util/mxConstants'; import mxConstants from '../../mxgraph/util/mxConstants';
import mxKeyHandler from '../../mxgraph/handler/mxKeyHandler'; import mxKeyHandler from '../../mxgraph/handler/mxKeyHandler';
import mxCompactTreeLayout from '../../mxgraph/layout/mxCompactTreeLayout'; import mxCompactTreeLayout from '../../mxgraph/layout/mxCompactTreeLayout';
import mxLayoutManager from '../../mxgraph/view/mxLayoutManager'; import mxLayoutManager from '../../mxgraph/view/graph/mxLayoutManager';
import mxRectangle from '../../mxgraph/util/mxRectangle'; import mxRectangle from '../../mxgraph/util/datatypes/mxRectangle';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
import mxClient from '../../mxgraph/mxClient'; import mxClient from '../../mxgraph/mxClient';
import mxEdgeStyle from '../../mxgraph/view/mxEdgeStyle'; import mxEdgeStyle from '../../mxgraph/view/style/mxEdgeStyle';
class Tree extends React.Component { class Tree extends React.Component {
constructor(props) { constructor(props) {

View File

@ -4,14 +4,14 @@
*/ */
import React from 'react'; import React from 'react';
import mxEvent from '../../mxgraph/util/mxEvent'; import mxEvent from '../../mxgraph/util/event/mxEvent';
import mxGraph from '../../mxgraph/view/mxGraph'; import mxGraph from '../../mxgraph/view/graph/mxGraph';
import mxText from '../../mxgraph/shape/mxText'; import mxText from '../../mxgraph/shape/mxText';
import mxUtils from '../../mxgraph/util/mxUtils'; import mxUtils from '../../mxgraph/util/mxUtils';
import mxConstants from '../../mxgraph/util/mxConstants'; import mxConstants from '../../mxgraph/util/mxConstants';
import mxCodec from '../../mxgraph/io/mxCodec'; import mxCodec from '../../mxgraph/io/mxCodec';
import mxEffects from '../../mxgraph/util/mxEffects'; import mxEffects from '../../mxgraph/util/animate/mxEffects';
import mxPerimeter from '../../mxgraph/view/mxPerimeter'; import mxPerimeter from '../../mxgraph/view/style/mxPerimeter';
class DynamicLoading extends React.Component { class DynamicLoading extends React.Component {
constructor(props) { constructor(props) {

Some files were not shown because too many files have changed in this diff Show More