diff --git a/docs/stashed/Ports.js b/docs/stashed/Ports.js
index 2a10af491..00d7f670f 100644
--- a/docs/stashed/Ports.js
+++ b/docs/stashed/Ports.js
@@ -157,7 +157,7 @@ export default Ports;
// processing wrt the parent label)
return '';
}
- else if (this.isCellCollapsed(cell))
+ else if (cell.isCollapsed())
{
let index = tmp.indexOf('');
diff --git a/docs/stashed/Scrollbars.js b/docs/stashed/Scrollbars.js
index c2bb6e512..b7fc75ead 100644
--- a/docs/stashed/Scrollbars.js
+++ b/docs/stashed/Scrollbars.js
@@ -205,7 +205,7 @@ export default Scrollbars;
// Overrides connectable state
graph.isCellConnectable = function(cell)
{
- return !this.isCellCollapsed(cell);
+ return !cell.isCollapsed();
};
// Enables HTML markup in all labels
@@ -371,7 +371,7 @@ export default Scrollbars;
{
if (cell.isVertex())
{
- if (this.isCellCollapsed(cell))
+ if (cell.isCollapsed())
{
return '
' +
'Customers |
' +
@@ -473,7 +473,7 @@ export default Scrollbars;
{
y = start.getCenterY() - div.scrollTop;
- if (mxUtils.isNode(edge.cell.value) && !this.graph.isCellCollapsed(start.cell))
+ if (mxUtils.isNode(edge.cell.value) && !start.cell.isCollapsed())
{
let attr = (source) ? 'sourceRow' : 'targetRow';
let row = parseInt(edge.cell.value.getAttribute(attr));
diff --git a/docs/stashed/Touch.js b/docs/stashed/Touch.js
index 78840c3e3..478cc86f4 100644
--- a/docs/stashed/Touch.js
+++ b/docs/stashed/Touch.js
@@ -356,7 +356,7 @@ export default Touch;
// Only show connector image on one cell and do not show on containers
if (this.graph.connectionHandler.isEnabled() &&
- this.graph.isCellConnectable(this.state.cell) &&
+ this.state.cell.isConnectable() &&
this.graph.getSelectionCount() == 1)
{
this.connectorImg = mxUtils.createImage(connectorSrc);
diff --git a/docs/stashed/Wires.js b/docs/stashed/Wires.js
index 47d825fca..1d4c318a9 100644
--- a/docs/stashed/Wires.js
+++ b/docs/stashed/Wires.js
@@ -131,7 +131,7 @@ export default MYNAMEHERE;
// incoming/outgoing direction.
graph.getAllConnectionConstraints = function(terminal)
{
- let geo = (terminal != null) ? this.getCellGeometry(terminal.cell) : null;
+ let geo = (terminal != null) ? terminal.cell.getGeometry() : null;
if ((geo != null ? !geo.relative : false) &&
this.getModel().isVertex(terminal.cell) &&
@@ -153,7 +153,7 @@ export default MYNAMEHERE;
}
else
{
- let geo = (cell != null) ? this.graph.getCellGeometry(cell) : null;
+ let geo = (cell != null) ? cell.getGeometry() : null;
return (geo != null) ? geo.relative : false;
}
@@ -510,7 +510,7 @@ export default MYNAMEHERE;
let s = this.scale;
let tr = this.translate;
let orig = edge.origin;
- let geo = this.graph.getCellGeometry(edge.cell);
+ let geo = edge.cell.getGeometry();
pt = geo.getTerminalPoint(source);
// Computes edge-to-edge connection point
diff --git a/docs/stashed/grapheditor/www/js/Actions.js b/docs/stashed/grapheditor/www/js/Actions.js
index aeb5dafe9..e9190dc6d 100644
--- a/docs/stashed/grapheditor/www/js/Actions.js
+++ b/docs/stashed/grapheditor/www/js/Actions.js
@@ -124,7 +124,7 @@ Actions.prototype.init = function()
if (cells.length == 1 && includeEdges)
{
- let geo = graph.getCellGeometry(cells[0]);
+ let geo = cells[0].getGeometry();
if (geo != null)
{
@@ -156,7 +156,7 @@ Actions.prototype.init = function()
if (graph.isEnabled() && cell != null && cell.isVertex())
{
- let geo = graph.getCellGeometry(cell);
+ let geo = cell.getGeometry();
if (geo != null)
{
@@ -179,7 +179,7 @@ Actions.prototype.init = function()
{
if (cells[i].isVertex())
{
- let geo = graph.getCellGeometry(cells[i]);
+ let geo = cells[i].getGeometry();
if (geo != null)
{
@@ -599,7 +599,7 @@ Actions.prototype.init = function()
else
{
let state = graph.view.getState(cell);
- let geo = graph.getCellGeometry(cell);
+ let geo = cell.getGeometry();
if (cell.isVertex() && state != null && state.text != null &&
geo != null && graph.isWrapping(cell))
@@ -1251,15 +1251,15 @@ Actions.prototype.init = function()
let dy = t.y;
let parent = cell.getParent();
- let pgeo = graph.getCellGeometry(parent);
-
+ let pgeo = parent.getGeometry();
+
while (parent.isVertex() && pgeo != null)
{
dx += pgeo.x;
dy += pgeo.y;
parent = parent.getParent();
- pgeo = graph.getCellGeometry(parent);
+ pgeo = parent.getGeometry();
}
let x = Math.round(graph.snap(graph.popupMenuHandler.triggerX / s - dx));
@@ -1297,7 +1297,7 @@ Actions.prototype.init = function()
if (cell.isEdge())
{
- let geo = graph.getCellGeometry(cell);
+ let geo = cell.getGeometry();
if (geo != null)
{
diff --git a/docs/stashed/grapheditor/www/js/Editor.js b/docs/stashed/grapheditor/www/js/Editor.js
index 061ec275c..2d5f12f88 100644
--- a/docs/stashed/grapheditor/www/js/Editor.js
+++ b/docs/stashed/grapheditor/www/js/Editor.js
@@ -2578,7 +2578,7 @@ FilenameDialog.createFileTypes = function(editorUi, nameInput, types)
}
else if (cells[i].isVertex())
{
- let geo = this.graph.getCellGeometry(cells[i]);
+ let geo = cells[i].getGeometry();
if (geo != null && geo.relative)
{
@@ -2691,7 +2691,7 @@ FilenameDialog.createFileTypes = function(editorUi, nameInput, types)
if (immediate)
{
let geo = (cell.isEdge()) ? null :
- this.graph.getCellGeometry(cell);
+ cell.getGeometry();
result = !parent.isEdge() &&
!this.graph.isSiblingSelected(cell) &&
diff --git a/docs/stashed/grapheditor/www/js/EditorUi.js b/docs/stashed/grapheditor/www/js/EditorUi.js
index 6d4dcd2c5..40f5c34c9 100644
--- a/docs/stashed/grapheditor/www/js/EditorUi.js
+++ b/docs/stashed/grapheditor/www/js/EditorUi.js
@@ -1204,14 +1204,14 @@ EditorUi.prototype.installShapePicker = function()
this.graph.connectVertex(state.cell, dir, this.graph.defaultEdgeLength, evt, null, null, mxUtils.bind(this, function(x, y, execute)
{
let temp = graph.getCompositeParent(state.cell);
- let geo = graph.getCellGeometry(temp);
+ let geo = temp.getGeometry();
me.consume();
while (temp != null && graph.model.isVertex(temp) && geo != null && geo.relative)
{
cell = temp;
temp = cell.getParent()
- geo = graph.getCellGeometry(temp);
+ geo = temp.getGeometry();
}
// Asynchronous to avoid direct insert after double tap
@@ -1645,7 +1645,7 @@ EditorUi.prototype.initClipboard = function()
if (state != null)
{
- let geo = graph.getCellGeometry(clones[i]);
+ let geo = clones[i].getGeometry();
if (geo != null && geo.relative && !result[i].isEdge() &&
lookup[mxObjectIdentity.get(result[i].getParent())] == null)
@@ -4595,7 +4595,7 @@ EditorUi.prototype.createKeyHandler = function(editor)
{
if (cells[i].isVertex() && graph.isCellResizable(cells[i]))
{
- let geo = graph.getCellGeometry(cells[i]);
+ let geo = cells[i].getGeometry();
if (geo != null)
{
diff --git a/docs/stashed/grapheditor/www/js/Format.js b/docs/stashed/grapheditor/www/js/Format.js
index 77a973cb4..57635449f 100644
--- a/docs/stashed/grapheditor/www/js/Format.js
+++ b/docs/stashed/grapheditor/www/js/Format.js
@@ -142,7 +142,7 @@ Format.prototype.updateSelectionStateForCell = function(result, cell, cells)
result.cell = result.cell || graph.isTableCell(cell);
result.row = result.row || graph.isTableRow(cell);
result.vertices.push(cell);
- let geo = graph.getCellGeometry(cell);
+ let geo = cell.getGeometry();
if (geo != null)
{
@@ -2426,7 +2426,7 @@ ArrangePanel.prototype.addGeometryHandler = function(input, fn)
{
if (cells[i].isVertex())
{
- let geo = graph.getCellGeometry(cells[i]);
+ let geo = cells[i].getGeometry();
if (geo != null)
{
@@ -2498,7 +2498,7 @@ ArrangePanel.prototype.addEdgeGeometryHandler = function(input, fn)
{
if (cells[i].isEdge())
{
- let geo = graph.getCellGeometry(cells[i]);
+ let geo = cells[i].getGeometry();
if (geo != null)
{
diff --git a/docs/stashed/grapheditor/www/js/Graph.js b/docs/stashed/grapheditor/www/js/Graph.js
index 9448ed7c9..e19a9ff08 100644
--- a/docs/stashed/grapheditor/www/js/Graph.js
+++ b/docs/stashed/grapheditor/www/js/Graph.js
@@ -1885,7 +1885,7 @@ Graph.prototype.init = function(container)
Graph.prototype.isRecursiveVertexResize = function(state)
{
return !this.isSwimlane(state.cell) && state.cell.getChildCount() > 0 &&
- !this.isCellCollapsed(state.cell) && mxUtils.getValue(state.style, 'recursiveResize', '1') == '1' &&
+ !state.cell.isCollapsed() && mxUtils.getValue(state.style, 'recursiveResize', '1') == '1' &&
mxUtils.getValue(state.style, 'childLayout', null) == null;
}
@@ -3120,18 +3120,18 @@ Graph.prototype.connectVertex = function(source, direction, length, evt, forceCl
// Uses connectable parent vertex if one exists
// TODO: Fix using target as parent for swimlane
- if (target != null && !this.isCellConnectable(target) && !this.isSwimlane(target))
+ if (target != null && !target.isConnectable() && !this.isSwimlane(target))
{
let parent = target.getParent();
- if (parent.isVertex() && this.isCellConnectable(parent))
+ if (parent.isVertex() && parent.isConnectable())
{
target = parent;
}
}
if (target == source || target.isEdge() ||
- !this.isCellConnectable(target) &&
+ !target.isConnectable() &&
!this.isSwimlane(target))
{
target = null;
@@ -3152,12 +3152,12 @@ Graph.prototype.connectVertex = function(source, direction, length, evt, forceCl
{
// Handles relative children
let cellToClone = (targetCell != null) ? targetCell : source;
- let geo = this.getCellGeometry(cellToClone);
+ let geo = cellToClone.getGeometry();
while (geo != null && geo.relative)
{
cellToClone = cellToClone.getParent();
- geo = this.getCellGeometry(cellToClone);
+ geo = cellToClone.getGeometry();
}
// Handles composite cells for cloning
@@ -3169,7 +3169,7 @@ Graph.prototype.connectVertex = function(source, direction, length, evt, forceCl
this.addCells([realTarget], source.getParent(), null, null, null, true);
}
- let geo = this.getCellGeometry(realTarget);
+ let geo = realTarget.getGeometry();
if (geo != null)
{
@@ -3398,7 +3398,7 @@ Graph.prototype.getCellStyle = function(cell)
{
let parent = cell.getParent();
- if (parent.isVertex() && this.isCellCollapsed(cell))
+ if (parent.isVertex() && cell.isCollapsed())
{
let layout = this.layoutManager.getLayout(parent);
@@ -3471,7 +3471,7 @@ Graph.prototype.foldCells = function(collapse, recurse, cells, checkFoldable, ev
for (let i = 0; i < cells.length; i++)
{
let state = this.view.getState(cells[i]);
- let geo = this.getCellGeometry(cells[i]);
+ let geo = cells[i].getGeometry();
if (state != null && geo != null)
{
@@ -3529,7 +3529,7 @@ Graph.prototype.moveSiblings = function(state, parent, dx, dy)
if (cells[i] != state.cell)
{
let tmp = this.view.getState(cells[i]);
- let geo = this.getCellGeometry(cells[i]);
+ let geo = cells[i].getGeometry();
if (tmp != null && geo != null)
{
@@ -3563,7 +3563,7 @@ Graph.prototype.resizeParentStacks = function(parent, layout, dx, dy)
while (parent != null && layout != null && layout.constructor == mxStackLayout &&
layout.horizontal == dir && !layout.resizeLast)
{
- let pgeo = this.getCellGeometry(parent);
+ let pgeo = parent.getGeometry();
let pstate = this.view.getState(parent);
if (pstate != null && pgeo != null)
@@ -4480,7 +4480,7 @@ HoverIcons.prototype.repaint = function()
// Cell was deleted
if (this.currentState != null &&
this.currentState.cell.isVertex() &&
- this.graph.isCellConnectable(this.currentState.cell))
+ this.currentState.cell.isConnectable())
{
let bds = mxRectangle.fromRectangle(this.currentState);
@@ -4583,11 +4583,11 @@ HoverIcons.prototype.repaint = function()
bottom = null;
}
- let currentGeo = this.graph.getCellGeometry(this.currentState.cell);
+ let currentGeo = this.currentState.cell.getGeometry();
let checkCollision = mxUtils.bind(this, function(cell, arrow)
{
- let geo = cell.isVertex() && this.graph.getCellGeometry(cell);
+ let geo = cell.isVertex() && cell.getGeometry();
// Ignores collision if vertex is more than 3 times the size of this vertex
if (cell != null && !this.graph.model.isAncestor(cell, this.currentState.cell) &&
@@ -4692,11 +4692,11 @@ HoverIcons.prototype.getState = function(state)
else
{
// Uses connectable parent vertex if child is not connectable
- if (cell.isVertex() && !this.graph.isCellConnectable(cell))
+ if (cell.isVertex() && !cell.isConnectable())
{
- let parent = this.cell.getParent();
+ let parent = cell.getParent();
- if (parent.isVertex() && this.graph.isCellConnectable(parent))
+ if (parent.isVertex() && parent.isConnectable())
{
cell = parent;
}
@@ -4830,7 +4830,7 @@ Graph.prototype.createParent = function(parent, child, childCount, dx, dy)
for (let i = 0; i < childCount; i++)
{
let clone = this.cloneCell(child);
- let geo = this.getCellGeometry(clone)
+ let geo = clone.getGeometry()
if (geo != null)
{
@@ -4976,7 +4976,7 @@ Graph.prototype.setTableRowHeight = function(row, dy, extend)
model.beginUpdate();
try
{
- let rgeo = this.getCellGeometry(row);
+ let rgeo = row.getGeometry();
// Sets height of row
if (rgeo != null)
@@ -4996,7 +4996,7 @@ Graph.prototype.setTableRowHeight = function(row, dy, extend)
if (index < rows.length - 1)
{
let nextRow = rows[index + 1];
- let geo = this.getCellGeometry(nextRow);
+ let geo = nextRow.getGeometry();
if (geo != null)
{
@@ -5010,7 +5010,7 @@ Graph.prototype.setTableRowHeight = function(row, dy, extend)
}
// Updates height of table
- let tgeo = this.getCellGeometry(table);
+ let tgeo = table.getGeometry();
if (tgeo != null)
{
@@ -5065,7 +5065,7 @@ Graph.prototype.setTableColumnWidth = function(col, dx, extend)
row = rows[i];
cells = model.getChildCells(row, true);
let cell = cells[index];
- let geo = this.getCellGeometry(cell);
+ let geo = cell.getGeometry();
if (geo != null)
{
@@ -5078,7 +5078,7 @@ Graph.prototype.setTableColumnWidth = function(col, dx, extend)
if (index < cells.length - 1)
{
cell = cells[index + 1];
- let geo = this.getCellGeometry(cell);
+ let geo = cell.getGeometry();
if (geo != null)
{
@@ -5098,7 +5098,7 @@ Graph.prototype.setTableColumnWidth = function(col, dx, extend)
if (lastColumn || extend)
{
// Updates width of table
- let tgeo = this.getCellGeometry(table);
+ let tgeo = table.getGeometry();
if (tgeo != null)
{
@@ -5151,7 +5151,7 @@ TableLayout.prototype.isHorizontal = function()
TableLayout.prototype.isVertexIgnored = function(vertex)
{
return !vertex.isVertex() ||
- !this.graph.isCellVisible(vertex);
+ !vertex.isVisible();
};
/**
@@ -5167,7 +5167,7 @@ TableLayout.prototype.getSize = function(cells, horizontal)
{
if (!this.isVertexIgnored(cells[i]))
{
- let geo = this.graph.getCellGeometry(cells[i]);
+ let geo = cells[i].getGeometry();
if (geo != null)
{
@@ -5195,7 +5195,7 @@ TableLayout.prototype.getRowLayout = function(row, width)
for (let i = 0; i < cells.length; i++)
{
- let cell = this.graph.getCellGeometry(cells[i]);
+ let cell = cells[i].getGeometry();
if (cell != null)
{
@@ -5228,7 +5228,7 @@ TableLayout.prototype.layoutRow = function(row, positions, height, tw)
for (let i = 0; i < cells.length; i++)
{
- let cell = this.graph.getCellGeometry(cells[i]);
+ let cell = cells[i].getGeometry();
if (cell != null)
{
@@ -5280,7 +5280,7 @@ TableLayout.prototype.execute = function(parent)
if (parent != null)
{
let offset = this.graph.getActualStartSize(parent, true);
- let table = this.graph.getCellGeometry(parent);
+ let table = parent.getGeometry();
let style = this.graph.getCellStyle(parent);
let resizeLastRow = mxUtils.getValue(style,
'resizeLastRow', '0') == '1';
@@ -5303,7 +5303,7 @@ TableLayout.prototype.execute = function(parent)
{
if (resizeLastRow)
{
- let row = this.graph.getCellGeometry(rows[rows.length - 1]);
+ let row = rows[rows.length - 1].getGeometry();
if (row != null)
{
@@ -5319,7 +5319,7 @@ TableLayout.prototype.execute = function(parent)
// Updates row geometries
for (let i = 0; i < rows.length; i++)
{
- let row = this.graph.getCellGeometry(rows[i]);
+ let row = rows[i].getGeometry();
if (row != null)
{
@@ -6520,7 +6520,7 @@ if (typeof mxVertexHandler != 'undefined')
if (state != null)
{
- let geo = this.getCellGeometry(clones[i]);
+ let geo = clones[i].getGeometry();
if (geo != null && geo.relative && !cells[i].isEdge() &&
dict.get(cells[i].getParent()) == null)
@@ -6698,7 +6698,7 @@ if (typeof mxVertexHandler != 'undefined')
if (target != null && this.isTableRow(cells[i]))
{
let parent = cells[i].getParent();
- let row = this.getCellGeometry(cells[i]);
+ let row = cells[i].getGeometry();
if (this.isTable(parent))
{
@@ -6712,7 +6712,7 @@ if (typeof mxVertexHandler != 'undefined')
{
if (!clone)
{
- let table = this.getCellGeometry(parent);
+ let table = parent.getGeometry();
if (table != null)
{
@@ -6722,7 +6722,7 @@ if (typeof mxVertexHandler != 'undefined')
}
}
- let table = this.getCellGeometry(target);
+ let table = target.getGeometry();
if (table != null)
{
@@ -6769,8 +6769,8 @@ if (typeof mxVertexHandler != 'undefined')
for (let j = 0; j < cols.length; j++)
{
- let geo = this.getCellGeometry(cols[j]);
- var geo2 = this.getCellGeometry(sourceCols[j]);
+ let geo = cols[j].getGeometry();
+ var geo2 = sourceCols[j].getGeometry();
if (geo != null && geo2 != null)
{
@@ -7008,7 +7008,7 @@ if (typeof mxVertexHandler != 'undefined')
if (child.isVertex())
{
- let geometry = this.getCellGeometry(child);
+ let geometry = child.getGeometry();
if (geometry != null && !geometry.relative)
{
@@ -7161,7 +7161,7 @@ if (typeof mxVertexHandler != 'undefined')
}
else if (cell.isVertex())
{
- let geo = this.getCellGeometry(cell);
+ let geo = cell.getGeometry();
if (geo != null)
{
@@ -8097,8 +8097,8 @@ if (typeof mxVertexHandler != 'undefined')
// Extends tables
if (this.isTable(parent))
{
- let row = this.getCellGeometry(clones[i]);
- let table = this.getCellGeometry(parent);
+ let row = clones[i].getGeometry();
+ let table = parent.getGeometry();
if (row != null && table != null)
{
@@ -8302,7 +8302,7 @@ if (typeof mxVertexHandler != 'undefined')
for (let i = 1; i < vertices.length - 1; i++)
{
let pstate = this.view.getState(vertices[i].cell.getParent());
- let geo = this.getCellGeometry(vertices[i].cell);
+ let geo = vertices[i].cell.getGeometry();
t0 += dt;
if (geo != null && pstate != null)
@@ -8818,8 +8818,8 @@ if (typeof mxVertexHandler != 'undefined')
if (this.isTable(parent))
{
- let row = this.getCellGeometry(cells[i]);
- let table = this.getCellGeometry(parent);
+ let row = cells[i].getGeometry();
+ let table = parent.getGeometry();
if (row != null && table != null)
{
@@ -8901,13 +8901,13 @@ if (typeof mxVertexHandler != 'undefined')
{
let child = model.getChildCells(rows[i], true)[index];
let clone = model.cloneCell(child, false);
- let geo = this.getCellGeometry(clone);
+ let geo = clone.getGeometry();
clone.value = null;
if (geo != null)
{
dw = geo.width;
- let rowGeo = this.getCellGeometry(rows[i]);
+ let rowGeo = rows[i].getGeometry();
if (rowGeo != null)
{
@@ -8918,7 +8918,7 @@ if (typeof mxVertexHandler != 'undefined')
model.add(rows[i], clone, index + ((before) ? 0 : 1));
}
- let tableGeo = this.getCellGeometry(table);
+ let tableGeo = table.getGeometry();
if (tableGeo != null)
{
@@ -8967,7 +8967,7 @@ if (typeof mxVertexHandler != 'undefined')
row = model.cloneCell(row, false);
row.value = null;
- let rowGeo = this.getCellGeometry(row);
+ let rowGeo = row.getGeometry();
if (rowGeo != null)
{
@@ -8977,7 +8977,7 @@ if (typeof mxVertexHandler != 'undefined')
row.insert(cell);
cell.value = null;
- let geo = this.getCellGeometry(cell);
+ let geo = cell.getGeometry();
if (geo != null)
{
@@ -8987,7 +8987,7 @@ if (typeof mxVertexHandler != 'undefined')
model.add(table, row, index + ((before) ? 0 : 1));
- let tableGeo = this.getCellGeometry(table);
+ let tableGeo = table.getGeometry();
if (tableGeo != null)
{
@@ -9062,7 +9062,7 @@ if (typeof mxVertexHandler != 'undefined')
let child = model.getChildCells(rows[i], true)[index];
model.remove(child);
- let geo = this.getCellGeometry(child);
+ let geo = child.getGeometry();
if (geo != null)
{
@@ -9070,7 +9070,7 @@ if (typeof mxVertexHandler != 'undefined')
}
}
- let tableGeo = this.getCellGeometry(table);
+ let tableGeo = table.getGeometry();
if (tableGeo != null)
{
@@ -9128,14 +9128,14 @@ if (typeof mxVertexHandler != 'undefined')
model.remove(row);
let height = 0;
- let geo = this.getCellGeometry(row);
+ let geo = row.getGeometry();
if (geo != null)
{
height = geo.height;
}
- let tableGeo = this.getCellGeometry(table);
+ let tableGeo = table.getGeometry();
if (tableGeo != null)
{
@@ -9616,8 +9616,8 @@ if (typeof mxVertexHandler != 'undefined')
this.graph.setSelectionCell(cell);
// Enables focus outline for edges and edge labels
- let parent = this.cell.getParent();
- let geo = this.graph.getCellGeometry(cell);
+ let parent = cell.getParent();
+ let geo = cell.getGeometry();
if ((parent.isEdge() && geo != null && geo.relative) ||
cell.isEdge(cell))
@@ -10160,7 +10160,7 @@ if (typeof mxVertexHandler != 'undefined')
if (style['childLayout'] == null)
{
let parent = cell.getParent();
- let geo = (parent != null) ? this.graph.getCellGeometry(parent) : null;
+ let geo = (parent != null) ? parent.getGeometry() : null;
if (geo != null)
{
@@ -10282,7 +10282,7 @@ if (typeof mxVertexHandler != 'undefined')
mxVertexHandler.prototype.isCenteredEvent = function(state, me)
{
return (!(!this.graph.isSwimlane(state.cell) && state.cell.getChildCount() > 0 &&
- !this.graph.isCellCollapsed(state.cell) &&
+ !state.cell.isCollapsed() &&
mxUtils.getValue(state.style, 'recursiveResize', '1') == '1' &&
mxUtils.getValue(state.style, 'childLayout', null) == null) &&
mxEvent.isControlDown(me.getEvent())) ||
@@ -11110,7 +11110,7 @@ if (typeof mxVertexHandler != 'undefined')
if (this.graph.isCellMovable(cells[i]))
{
let tmp = this.graph.view.getState(cells[i]);
- let geo = this.graph.getCellGeometry(cells[i]);
+ let geo = cells[i].getGeometry();
if (tmp != null && geo != null)
{
@@ -11334,7 +11334,7 @@ if (typeof mxVertexHandler != 'undefined')
{
let model = this.graph.getModel();
let parent = cells[0].getParent();
- let geo = this.graph.getCellGeometry(cells[0]);
+ let geo = cells[0].getGeometry();
if (parent.isEdge() && geo != null && geo.relative)
{
@@ -11377,7 +11377,7 @@ if (typeof mxVertexHandler != 'undefined')
{
let model = this.graph.getModel();
let parent = state.cell.getParent();
- let geo = this.graph.getCellGeometry(state.cell);
+ let geo = state.cell.getGeometry();
if (parent.isEdge() && geo != null && geo.relative && state.width < 2 && state.height < 2 && state.text != null && state.text.boundingBox != null)
{
@@ -11398,7 +11398,7 @@ if (typeof mxVertexHandler != 'undefined')
{
let model = this.graph.getModel();
let parent = this.state.cell.getParent();
- let geo = this.graph.getCellGeometry(this.state.cell);
+ let geo = this.state.cell.getGeometry();
// Lets rotation events through
let handle = this.getHandleForEvent(me);
diff --git a/docs/stashed/grapheditor/www/js/Menus.js b/docs/stashed/grapheditor/www/js/Menus.js
index 9f3e579ed..a94d9785b 100644
--- a/docs/stashed/grapheditor/www/js/Menus.js
+++ b/docs/stashed/grapheditor/www/js/Menus.js
@@ -791,7 +791,7 @@ Menus.prototype.edgeStyleChange = function(menu, label, keys, values, sprite, pa
{
if (reset)
{
- let geo = graph.getCellGeometry(cell);
+ let geo = cell.getGeometry();
// Resets all edge points
if (geo != null)
diff --git a/docs/stashed/grapheditor/www/js/Shapes.js b/docs/stashed/grapheditor/www/js/Shapes.js
index dd0862519..a324a71d4 100644
--- a/docs/stashed/grapheditor/www/js/Shapes.js
+++ b/docs/stashed/grapheditor/www/js/Shapes.js
@@ -44,7 +44,7 @@
for (let i = 0; i < cols.length; i++)
{
let clr = (mxUtils.mod(i, 2) == 1) ? evenColColor : oddColColor;
- let geo = graph.getCellGeometry(cols[i]);
+ let geo = cols[i].getGeometry();
if (geo != null && clr != mxConstants.NONE)
{
@@ -75,7 +75,7 @@
for (let i = 0; i < rows.length; i++)
{
let clr = (mxUtils.mod(i, 2) == 1) ? evenRowColor : oddRowColor;
- let geo = graph.getCellGeometry(rows[i]);
+ let geo = rows[i].getGeometry();
if (geo != null && clr != mxConstants.NONE)
{
@@ -193,7 +193,7 @@
{
for (let i = 1; i < rows.length; i++)
{
- let geo = graph.getCellGeometry(rows[i]);
+ let geo = rows[i].getGeometry();
if (geo != null)
{
@@ -213,7 +213,7 @@
// Paints column lines
for (let i = 1; i < cols.length; i++)
{
- let geo = graph.getCellGeometry(cols[i]);
+ let geo = cols[i].getGeometry();
if (geo != null)
{
diff --git a/docs/stashed/grapheditor/www/js/Sidebar.js b/docs/stashed/grapheditor/www/js/Sidebar.js
index 35cd41c4a..eda6492cf 100644
--- a/docs/stashed/grapheditor/www/js/Sidebar.js
+++ b/docs/stashed/grapheditor/www/js/Sidebar.js
@@ -2818,8 +2818,8 @@ Sidebar.prototype.dropAndConnect = function(source, targets, direction, dropCell
graph.model.beginUpdate();
try
{
- let sourceGeo = graph.getCellGeometry(source);
- var geo2 = graph.getCellGeometry(targets[dropCellIndex]);
+ let sourceGeo = source.getGeometry();
+ var geo2 = targets[dropCellIndex].getGeometry();
// Handles special case where target should be ignored for stack layouts
let targetParent = source.getParent();
@@ -2917,7 +2917,7 @@ Sidebar.prototype.dropAndConnect = function(source, targets, direction, dropCell
{
// Adds new outgoing connection to vertex and clears points
graph.model.setTerminal(targets[dropCellIndex], source, true);
- var geo3 = graph.getCellGeometry(targets[dropCellIndex]);
+ var geo3 = targets[dropCellIndex].getGeometry();
geo3.points = null;
if (geo3.getTerminalPoint(false) != null)
@@ -2936,7 +2936,7 @@ Sidebar.prototype.dropAndConnect = function(source, targets, direction, dropCell
}
else
{
- geo2 = graph.getCellGeometry(targets[dropCellIndex]);
+ geo2 = targets[dropCellIndex].getGeometry();
dx = geo.x - Math.round(geo2.x);
dy = geo.y - Math.round(geo2.y);
geo.x = Math.round(geo2.x);
@@ -2984,8 +2984,8 @@ Sidebar.prototype.getDropAndConnectGeometry = function(source, target, direction
let graph = this.editorUi.editor.graph;
let view = graph.view;
let keepSize = targets.length > 1;
- let geo = graph.getCellGeometry(source);
- var geo2 = graph.getCellGeometry(target);
+ let geo = source.getGeometry();
+ var geo2 = target.getGeometry();
if (geo != null && geo2 != null)
{
@@ -3097,7 +3097,7 @@ Sidebar.prototype.getDropAndConnectGeometry = function(source, target, direction
if (target.isEdge() && geo2.getTerminalPoint(true) != null &&
target.getTerminal(false) != null)
{
- let targetGeo = graph.getCellGeometry(target.getTerminal(false));
+ let targetGeo = target.getTerminal(false) && target.getTerminal(false).getGeometry();
if (targetGeo != null)
{
@@ -3371,8 +3371,8 @@ Sidebar.prototype.createDragSource = function(elt, dropHandler, preview, cells,
let index = (currentTargetState.cell.isEdge() || freeSourceEdge == null) ? firstVertex : freeSourceEdge;
let geo = sidebar.getDropAndConnectGeometry(currentTargetState.cell, cells[index], direction, cells);
- var geo2 = (!currentTargetState.cell.isEdge()) ? graph.getCellGeometry(currentTargetState.cell) : null;
- var geo3 = graph.getCellGeometry(cells[index]);
+ var geo2 = (!currentTargetState.cell.isEdge()) ? currentTargetState.cell.getGeometry() : null;
+ var geo3 = cells[index].getGeometry();
let parent = currentTargetState.cell.getParent();
let dx = view.translate.x * view.scale;
let dy = view.translate.y * view.scale;
@@ -3444,13 +3444,13 @@ Sidebar.prototype.createDragSource = function(elt, dropHandler, preview, cells,
}) : null;
// Uses connectable parent vertex if one exists
- if (cell != null && !this.graph.isCellConnectable(cell) &&
+ if (cell != null && !cell.isConnectable() &&
!cell.isEdge())
{
- let parent = this.cell.getParent();
+ let parent = cell.getParent();
if (parent.isVertex() &&
- this.graph.isCellConnectable(parent))
+ parent.isConnectable())
{
cell = parent;
}
@@ -3641,9 +3641,9 @@ Sidebar.prototype.createDragSource = function(elt, dropHandler, preview, cells,
state = currentStyleTarget;
}
- let validTarget = (firstVertex == null || graph.isCellConnectable(cells[firstVertex])) &&
+ let validTarget = (firstVertex == null || cells[firstVertex].isConnectable()) &&
((cell.isEdge() && firstVertex != null) ||
- (cell.isVertex() && graph.isCellConnectable(cell)));
+ (cell.isVertex() && cell.isConnectable()));
// Drop arrows shown after this.dropTargetDelay, hidden after 5 secs, switches arrows after 500ms
if ((currentTargetState != null && timeOnTarget >= 5000) ||
diff --git a/packages/core/src/editor/mxDefaultToolbar.js b/packages/core/src/editor/mxDefaultToolbar.js
index ac7fa0119..d41d77345 100644
--- a/packages/core/src/editor/mxDefaultToolbar.js
+++ b/packages/core/src/editor/mxDefaultToolbar.js
@@ -305,7 +305,7 @@ class mxDefaultToolbar {
target == null ||
target.isEdge() ||
!this.connectOnDrop ||
- !graph.isCellConnectable(target)
+ !target.isConnectable()
) {
while (
target != null &&
@@ -363,7 +363,7 @@ class mxDefaultToolbar {
if (
source != null &&
- graph.isCellConnectable(vertex) &&
+ vertex.isCellConnectable() &&
graph.isEdgeValid(null, source, vertex)
) {
let edge = null;
diff --git a/packages/core/src/handler/mxConnectionHandler.js b/packages/core/src/handler/mxConnectionHandler.js
index ace64b9f5..ddb3b3637 100644
--- a/packages/core/src/handler/mxConnectionHandler.js
+++ b/packages/core/src/handler/mxConnectionHandler.js
@@ -596,12 +596,12 @@ class mxConnectionHandler extends mxEventSource {
}
// Uses connectable parent vertex if one exists
- if (cell != null && !self.graph.isCellConnectable(cell)) {
+ if (cell != null && !cell.isConnectable()) {
const parent = self.cell.getParent();
if (
parent.isVertex() &&
- self.graph.isCellConnectable(parent)
+ parent.isConnectable()
) {
cell = parent;
}
@@ -1206,7 +1206,7 @@ class mxConnectionHandler extends mxEventSource {
// are not equal (due to grid snapping) and there is no hit on shape or highlight
// but ignores cases where parent is used for non-connectable child cells
if (
- this.graph.isCellConnectable(me.getCell()) &&
+ me.getCell().isConnectable() &&
this.marker.getValidState() !== me.getState()
) {
this.marker.highlight.shape.stroke = 'transparent';
@@ -2215,11 +2215,11 @@ class mxConnectionHandler extends mxEventSource {
// createTargetVertex(evt: MouseEvent, source: mxCell): mxCell;
createTargetVertex(evt, source) {
// Uses the first non-relative source
- let geo = this.graph.getCellGeometry(source);
+ let geo = source.getGeometry();
while (geo != null && geo.relative) {
source = source.getParent();
- geo = this.graph.getCellGeometry(source);
+ geo = source.getGeometry();
}
const clone = this.graph.cloneCell(source);
diff --git a/packages/core/src/handler/mxConstraintHandler.js b/packages/core/src/handler/mxConstraintHandler.js
index 42bcd6373..8a877b791 100644
--- a/packages/core/src/handler/mxConstraintHandler.js
+++ b/packages/core/src/handler/mxConstraintHandler.js
@@ -205,18 +205,22 @@ class mxConstraintHandler {
}
// Uses connectable parent vertex if one exists
- if (cell != null && !this.graph.isCellConnectable(cell)) {
- const parent = this.cell.getParent();
+ if (cell != null && !cell.isConnectable()) {
+ const parent = cell.getParent();
if (
parent.isVertex() &&
- this.graph.isCellConnectable(parent)
+ parent.isConnectable()
) {
cell = parent;
}
}
- return this.graph.isCellLocked(cell) ? null : cell;
+ if (cell) {
+ return this.graph.isCellLocked(cell) ? null : cell;
+ } else {
+ return null;
+ }
}
/**
@@ -385,7 +389,7 @@ class mxConstraintHandler {
this.constraints =
state != null &&
!this.isStateIgnored(state, source) &&
- this.graph.isCellConnectable(state.cell)
+ state.cell.isConnectable()
? this.isEnabled()
? this.graph.getAllConnectionConstraints(state, source) || []
: []
diff --git a/packages/core/src/handler/mxEdgeHandler.js b/packages/core/src/handler/mxEdgeHandler.js
index 8c5f2f88d..68c8817cd 100644
--- a/packages/core/src/handler/mxEdgeHandler.js
+++ b/packages/core/src/handler/mxEdgeHandler.js
@@ -601,12 +601,12 @@ class mxEdgeHandler {
}
// Uses connectable parent vertex if one exists
- if (cell != null && !this.graph.isCellConnectable(cell)) {
- const parent = this.cell.getParent();
+ if (cell != null && !cell.isConnectable()) {
+ const parent = cell.getParent();
if (
parent.isVertex() &&
- this.graph.isCellConnectable(parent)
+ parent.isConnectable()
) {
cell = parent;
}
@@ -632,7 +632,7 @@ class mxEdgeHandler {
cell = null;
}
- if (!this.graph.isCellConnectable(cell)) {
+ if (cell && !cell.isConnectable()) {
cell = null;
}
return cell;
@@ -771,7 +771,7 @@ class mxEdgeHandler {
isHandleVisible(index) {
const source = this.state.getVisibleTerminalState(true);
const target = this.state.getVisibleTerminalState(false);
- const geo = this.graph.getCellGeometry(this.state.cell);
+ const geo = this.state.cell.getGeometry();
const edgeStyle =
geo != null
? this.graph.view.getEdgeStyle(this.state, geo.points, source, target)
@@ -1309,7 +1309,7 @@ class mxEdgeHandler {
*/
// getPreviewPoints(pt: mxPoint, me?: mxMouseEvent): mxPoint[];
getPreviewPoints(pt, me) {
- const geometry = this.graph.getCellGeometry(this.state.cell);
+ const geometry = this.state.cell.getGeometry();
let points = geometry.points != null ? geometry.points.slice() : null;
const point = new mxPoint(pt.x, pt.y);
let result = null;
@@ -1523,7 +1523,7 @@ class mxEdgeHandler {
this.marker.highlight.repaint();
} else if (this.marker.hasValidState()) {
this.marker.highlight.shape.stroke =
- this.graph.isCellConnectable(me.getCell()) &&
+ me.getCell().isConnectable() &&
this.marker.getValidState() !== me.getState()
? 'transparent'
: mxConstants.DEFAULT_VALID_COLOR;
@@ -1661,7 +1661,7 @@ class mxEdgeHandler {
} else if (
terminalState != null &&
terminalState !== me.getState() &&
- this.graph.isCellConnectable(me.getCell()) &&
+ me.getCell().isConnectable() &&
this.marker.highlight.shape != null
) {
this.marker.highlight.shape.stroke = 'transparent';
@@ -2149,7 +2149,7 @@ class mxEdgeHandler {
*/
// addPointAt(state: mxCellState, x: number, y: number): void;
addPointAt(state, x, y) {
- let geo = this.graph.getCellGeometry(state.cell);
+ let geo = state.cell.getGeometry();
const pt = new mxPoint(x, y);
if (geo != null) {
@@ -2191,7 +2191,7 @@ class mxEdgeHandler {
// removePoint(state: mxCellState, index: number): void;
removePoint(state, index) {
if (index > 0 && index < this.abspoints.length - 1) {
- let geo = this.graph.getCellGeometry(this.state.cell);
+ let geo = this.state.cell.getGeometry();
if (geo != null && geo.points != null) {
geo = geo.clone();
diff --git a/packages/core/src/handler/mxGraphHandler.js b/packages/core/src/handler/mxGraphHandler.js
index 13dbbf2af..1337289e7 100644
--- a/packages/core/src/handler/mxGraphHandler.js
+++ b/packages/core/src/handler/mxGraphHandler.js
@@ -463,7 +463,7 @@ class mxGraphHandler {
if (immediate) {
const geo = cell.isEdge()
? null
- : this.graph.getCellGeometry(cell);
+ : cell.getGeometry();
return (
!this.graph.isSiblingSelected(cell) &&
@@ -1109,7 +1109,7 @@ class mxGraphHandler {
cell != null &&
this.cells.length === 1 &&
cell.isVertex() &&
- graph.isCellConnectable(cell)
+ cell.isConnectable()
) {
state = graph.getView().getState(cell);
@@ -1339,7 +1339,7 @@ class mxGraphHandler {
const state = states[i][0];
if (state.cell.isEdge()) {
- const geometry = this.graph.getCellGeometry(state.cell);
+ const geometry = state.cell.getGeometry();
const points = [];
if (geometry != null && geometry.points != null) {
@@ -1603,9 +1603,10 @@ class mxGraphHandler {
this.target == null &&
cell != null &&
cell.isVertex() &&
- graph.isCellConnectable(cell) &&
+ cell.isConnectable() &&
graph.isEdgeValid(null, this.cell, cell)
) {
+ alert("CONNECT")
graph.connectionHandler.connect(this.cell, cell, me.getEvent());
} else {
const clone =
@@ -1615,7 +1616,7 @@ class mxGraphHandler {
const { scale } = graph.getView();
const dx = this.roundLength(this.currentDx / scale);
const dy = this.roundLength(this.currentDy / scale);
- const { target } = this;
+ const target = this.target;
if (
target &&
diff --git a/packages/core/src/handler/mxVertexHandler.js b/packages/core/src/handler/mxVertexHandler.js
index 9b73b07d4..2470ebd8d 100644
--- a/packages/core/src/handler/mxVertexHandler.js
+++ b/packages/core/src/handler/mxVertexHandler.js
@@ -1089,7 +1089,7 @@ class mxVertexHandler {
dx = tx;
dy = ty;
- const geo = this.graph.getCellGeometry(this.state.cell);
+ const geo = this.state.cell.getGeometry();
this.unscaledBounds = this.union(
geo,
dx / scale,
@@ -1223,7 +1223,7 @@ class mxVertexHandler {
// Shifts the children according to parent offset
if (
- !this.graph.isCellCollapsed(this.state.cell) &&
+ !this.state.cell.isCollapsed() &&
(dx3 !== 0 || dy3 !== 0)
) {
this.childOffsetX = this.state.x - this.bounds.x + dx5;
@@ -1277,7 +1277,7 @@ class mxVertexHandler {
// Required to store and reset absolute offset for updating label position
this.state.absoluteOffset.x = 0;
this.state.absoluteOffset.y = 0;
- const geo = this.graph.getCellGeometry(this.state.cell);
+ const geo = this.state.cell.getGeometry();
if (geo != null) {
const offset = geo.offset || this.EMPTY_POINT;
@@ -1473,10 +1473,10 @@ class mxVertexHandler {
this.graph.setCellStyles(mxConstants.STYLE_ROTATION, total, [cell]);
}
- let geo = this.graph.getCellGeometry(cell);
+ let geo = cell.getGeometry();
if (geo != null) {
- const pgeo = this.graph.getCellGeometry(parent);
+ const pgeo = parent.getGeometry();
if (pgeo != null && !parent.isEdge()) {
geo = geo.clone();
@@ -1641,7 +1641,7 @@ class mxVertexHandler {
for (let i = 0; i < childCount; i += 1) {
const child = cell.getChildAt(i);
- let geo = this.graph.getCellGeometry(child);
+ let geo = child.getGeometry();
if (geo != null) {
geo = geo.clone();
@@ -1773,7 +1773,7 @@ class mxVertexHandler {
let height = bottom - top;
if (constrained) {
- const geo = this.graph.getCellGeometry(this.state.cell);
+ const geo = this.state.cell.getGeometry();
if (geo != null) {
const aspect = geo.width / geo.height;
diff --git a/packages/core/src/layout/hierarchical/mxHierarchicalLayout.js b/packages/core/src/layout/hierarchical/mxHierarchicalLayout.js
index d8fac467e..cb25152a7 100644
--- a/packages/core/src/layout/hierarchical/mxHierarchicalLayout.js
+++ b/packages/core/src/layout/hierarchical/mxHierarchicalLayout.js
@@ -238,7 +238,7 @@ class mxHierarchicalLayout extends mxGraphLayout {
parent.isVertex() != null &&
this.maintainParentLocation
) {
- const geo = this.graph.getCellGeometry(parent);
+ const geo = parent.getGeometry();
if (geo != null) {
this.parentX = geo.x;
@@ -265,7 +265,7 @@ class mxHierarchicalLayout extends mxGraphLayout {
try {
this.run(parent);
- if (this.resizeParent && !this.graph.isCellCollapsed(parent)) {
+ if (this.resizeParent && !parent.isCollapsed()) {
this.graph.updateGroupBounds(
[parent],
this.parentBorder,
@@ -275,7 +275,7 @@ class mxHierarchicalLayout extends mxGraphLayout {
// Maintaining parent location
if (this.parentX != null && this.parentY != null) {
- let geo = this.graph.getCellGeometry(parent);
+ let geo = parent.getGeometry();
if (geo != null) {
geo = geo.clone();
@@ -314,7 +314,7 @@ class mxHierarchicalLayout extends mxGraphLayout {
for (const i in vertices) {
const cell = vertices[i];
- if (cell.isVertex() && this.graph.isCellVisible(cell)) {
+ if (cell.isVertex() && cell.isVisible()) {
const conns = this.getEdges(cell);
let fanOut = 0;
let fanIn = 0;
@@ -368,7 +368,7 @@ class mxHierarchicalLayout extends mxGraphLayout {
const { model } = this.graph;
let edges = [];
- const isCollapsed = this.graph.isCellCollapsed(cell);
+ const isCollapsed = cell.isCollapsed();
const childCount = cell.getChildCount();
for (let i = 0; i < childCount; i += 1) {
@@ -376,7 +376,7 @@ class mxHierarchicalLayout extends mxGraphLayout {
if (this.isPort(child)) {
edges = edges.concat(model.getEdges(child, true, true));
- } else if (isCollapsed || !this.graph.isCellVisible(child)) {
+ } else if (isCollapsed || !child.isVisible()) {
edges = edges.concat(model.getEdges(child, true, true));
}
}
@@ -577,14 +577,14 @@ class mxHierarchicalLayout extends mxGraphLayout {
if (
cell.isVertex() &&
cell !== this.parent &&
- this.graph.isCellVisible(cell)
+ cell.isVisible()
) {
result[mxObjectIdentity.get(cell)] = cell;
}
if (
this.traverseAncestors ||
- (cell === this.parent && this.graph.isCellVisible(cell))
+ (cell === this.parent && cell.isVisible())
) {
const childCount = cell.getChildCount();
diff --git a/packages/core/src/layout/hierarchical/mxSwimlaneLayout.js b/packages/core/src/layout/hierarchical/mxSwimlaneLayout.js
index 0b9645df6..cd0b1715b 100644
--- a/packages/core/src/layout/hierarchical/mxSwimlaneLayout.js
+++ b/packages/core/src/layout/hierarchical/mxSwimlaneLayout.js
@@ -253,7 +253,7 @@ class mxSwimlaneLayout extends mxGraphLayout {
parent.isVertex() != null &&
this.maintainParentLocation
) {
- const geo = this.graph.getCellGeometry(parent);
+ const geo = parent.getGeometry();
if (geo != null) {
this.parentX = geo.x;
@@ -286,7 +286,7 @@ class mxSwimlaneLayout extends mxGraphLayout {
try {
this.run(parent);
- if (this.resizeParent && !this.graph.isCellCollapsed(parent)) {
+ if (this.resizeParent && !parent.isCollapsed()) {
this.graph.updateGroupBounds(
[parent],
this.parentBorder,
@@ -296,7 +296,7 @@ class mxSwimlaneLayout extends mxGraphLayout {
// Maintaining parent location
if (this.parentX != null && this.parentY != null) {
- let geo = this.graph.getCellGeometry(parent);
+ let geo = parent.getGeometry();
if (geo != null) {
geo = geo.clone();
@@ -337,7 +337,7 @@ class mxSwimlaneLayout extends mxGraphLayout {
for (let i = 0; i < this.swimlanes.length; i += 1) {
const lane = this.swimlanes[i];
- const geo = this.graph.getCellGeometry(lane);
+ const geo = lane.getGeometry();
if (geo != null) {
const children = this.graph.getChildCells(lane);
@@ -371,7 +371,7 @@ class mxSwimlaneLayout extends mxGraphLayout {
for (let i = 0; i < this.swimlanes.length; i += 1) {
const lane = this.swimlanes[i];
- const geo = this.graph.getCellGeometry(lane);
+ const geo = lane.getGeometry();
if (geo != null) {
const children = this.graph.getChildCells(lane);
@@ -429,7 +429,7 @@ class mxSwimlaneLayout extends mxGraphLayout {
if (
cell != null &&
cell.isVertex() &&
- this.graph.isCellVisible(cell) &&
+ cell.isVisible() &&
model.isAncestor(parent, cell)
) {
const conns = this.getEdges(cell);
@@ -490,7 +490,7 @@ class mxSwimlaneLayout extends mxGraphLayout {
const { model } = this.graph;
let edges = [];
- const isCollapsed = this.graph.isCellCollapsed(cell);
+ const isCollapsed = cell.isCollapsed();
const childCount = cell.getChildCount();
for (let i = 0; i < childCount; i += 1) {
@@ -498,7 +498,7 @@ class mxSwimlaneLayout extends mxGraphLayout {
if (this.isPort(child)) {
edges = edges.concat(model.getEdges(child, true, true));
- } else if (isCollapsed || !this.graph.isCellVisible(child)) {
+ } else if (isCollapsed || !child.isVisible()) {
edges = edges.concat(model.getEdges(child, true, true));
}
}
@@ -713,14 +713,14 @@ class mxSwimlaneLayout extends mxGraphLayout {
cell.isVertex() &&
cell !== this.parent &&
cell.getParent() !== this.parent &&
- this.graph.isCellVisible(cell)
+ cell.isVisible()
) {
result[mxObjectIdentity.get(cell)] = cell;
}
if (
this.traverseAncestors ||
- (cell === this.parent && this.graph.isCellVisible(cell))
+ (cell === this.parent && cell.isVisible())
) {
const childCount = cell.getChildCount();
diff --git a/packages/core/src/layout/mxCompactTreeLayout.js b/packages/core/src/layout/mxCompactTreeLayout.js
index bfcae75e4..b4feb9146 100644
--- a/packages/core/src/layout/mxCompactTreeLayout.js
+++ b/packages/core/src/layout/mxCompactTreeLayout.js
@@ -306,7 +306,7 @@ class mxCompactTreeLayout extends mxGraphLayout {
parent.isVertex() != null &&
this.maintainParentLocation
) {
- const geo = this.graph.getCellGeometry(parent);
+ const geo = parent.getGeometry();
if (geo != null) {
this.parentX = geo.x;
@@ -376,7 +376,7 @@ class mxCompactTreeLayout extends mxGraphLayout {
// Maintaining parent location
if (this.parentX != null && this.parentY != null) {
- let geo = this.graph.getCellGeometry(parent);
+ let geo = parent.getGeometry();
if (geo != null) {
geo = geo.clone();
diff --git a/packages/core/src/layout/mxGraphLayout.js b/packages/core/src/layout/mxGraphLayout.js
index f5e36d2c7..99d28e38c 100644
--- a/packages/core/src/layout/mxGraphLayout.js
+++ b/packages/core/src/layout/mxGraphLayout.js
@@ -214,7 +214,7 @@ class mxGraphLayout {
isVertexIgnored(vertex) {
return (
!vertex.isVertex() ||
- !this.graph.isCellVisible(vertex)
+ !vertex.isVisible()
);
}
@@ -230,7 +230,7 @@ class mxGraphLayout {
return (
!edge.isEdge() ||
- !this.graph.isCellVisible(edge) ||
+ !edge.isVisible() ||
edge.getTerminal(true) == null ||
edge.getTerminal(false) == null
);
@@ -424,7 +424,7 @@ class mxGraphLayout {
}
if (this.parent != null) {
- const parent = this.cell.getParent();
+ const parent = cell.getParent();
geo = geo.clone();
if (parent != null && parent !== this.parent) {
diff --git a/packages/core/src/layout/mxStackLayout.js b/packages/core/src/layout/mxStackLayout.js
index 2912f22e2..248f8b432 100644
--- a/packages/core/src/layout/mxStackLayout.js
+++ b/packages/core/src/layout/mxStackLayout.js
@@ -247,8 +247,8 @@ class mxStackLayout extends mxGraphLayout {
if (this.allowGaps) {
cells.sort((c1, c2) => {
- const geo1 = this.graph.getCellGeometry(c1);
- const geo2 = this.graph.getCellGeometry(c2);
+ const geo1 = c1.getGeometry();
+ const geo2 = c2.getGeometry();
return this.horizontal
? geo1.x === geo2.x
@@ -456,7 +456,7 @@ class mxStackLayout extends mxGraphLayout {
this.resizeParent &&
pgeo != null &&
last != null &&
- !this.graph.isCellCollapsed(parent)
+ !parent.isCollapsed()
) {
this.updateParentGeometry(parent, pgeo, last);
} else if (
@@ -496,7 +496,7 @@ class mxStackLayout extends mxGraphLayout {
* geo - The specific geometry of .
*/
setChildGeometry(child, geo) {
- const geo2 = this.graph.getCellGeometry(child);
+ const geo2 = child.getGeometry();
if (
geo2 == null ||
diff --git a/packages/core/src/serialization/mxCodec.js b/packages/core/src/serialization/mxCodec.js
index 317b280a2..7bedba59d 100644
--- a/packages/core/src/serialization/mxCodec.js
+++ b/packages/core/src/serialization/mxCodec.js
@@ -12,7 +12,19 @@ import mxCell from '../view/cell/mxCell';
import mxLog from '../util/gui/mxLog';
import { getFunctionName } from '../util/mxStringUtils';
import { importNode, isNode } from '../util/mxDomUtils';
-import { createXmlDocument } from '../util/mxXmlUtils';
+
+const createXmlDocument = () => {
+ // Put here from '../util/mxXmlUtils' to eliminate circular dependency
+ let doc = null;
+
+ if (document.implementation && document.implementation.createDocument) {
+ doc = document.implementation.createDocument('', '', null);
+ } else if ('ActiveXObject' in window) {
+ doc = mxUtils.createMsXmlDocument();
+ }
+
+ return doc;
+};
/**
* XML codec for JavaScript object graphs. See {@link mxObjectCodec} for a
diff --git a/packages/core/src/serialization/mxGraphViewCodec.js b/packages/core/src/serialization/mxGraphViewCodec.js
index b393540ce..3d6fe91dc 100644
--- a/packages/core/src/serialization/mxGraphViewCodec.js
+++ b/packages/core/src/serialization/mxGraphViewCodec.js
@@ -62,7 +62,7 @@ class mxGraphViewCodec extends mxObjectCodec {
if (parent == null || state != null) {
const childCount = cell.getChildCount();
- const geo = view.graph.getCellGeometry(cell);
+ const geo = cell.getGeometry();
let name = null;
if (parent === model.getRoot()) {
diff --git a/packages/core/src/util/animate/mxMorphing.js b/packages/core/src/util/animate/mxMorphing.js
index 7bef298d2..7baeff68d 100644
--- a/packages/core/src/util/animate/mxMorphing.js
+++ b/packages/core/src/util/animate/mxMorphing.js
@@ -205,14 +205,14 @@ class mxMorphing extends mxAnimation {
let result = null;
if (cell != null) {
- const parent = this.cell.getParent();
- const geo = this.graph.getCellGeometry(cell);
+ const parent = cell.getParent();
+ const geo = cell.getGeometry();
result = this.getOriginForCell(parent);
// TODO: Handle offsets
if (geo != null) {
if (geo.relative) {
- const pgeo = this.graph.getCellGeometry(parent);
+ const pgeo = parent.getGeometry();
if (pgeo != null) {
result.x += geo.x * pgeo.width;
diff --git a/packages/core/src/util/datatypes/style/mxEdgeStyle.js b/packages/core/src/util/datatypes/style/mxEdgeStyle.js
index cb3912f56..4ea242d3e 100644
--- a/packages/core/src/util/datatypes/style/mxEdgeStyle.js
+++ b/packages/core/src/util/datatypes/style/mxEdgeStyle.js
@@ -121,7 +121,7 @@ class mxEdgeStyle {
let isSourceLeft = false;
if (source != null) {
- const sourceGeometry = graph.getCellGeometry(source.cell);
+ const sourceGeometry = source.cell.getGeometry();
if (sourceGeometry.relative) {
isSourceLeft = sourceGeometry.x <= 0.5;
@@ -158,7 +158,7 @@ class mxEdgeStyle {
let isTargetLeft = true;
if (target != null) {
- const targetGeometry = graph.getCellGeometry(target.cell);
+ const targetGeometry = target.cell.getGeometry();
if (targetGeometry.relative) {
isTargetLeft = targetGeometry.x <= 0.5;
diff --git a/packages/core/src/util/gui/mxWindow.js b/packages/core/src/util/gui/mxWindow.js
index ed0b081be..cffa65251 100644
--- a/packages/core/src/util/gui/mxWindow.js
+++ b/packages/core/src/util/gui/mxWindow.js
@@ -15,6 +15,7 @@ import mxConstants from '../mxConstants';
import { br, write } from '../mxDomUtils';
import mxResources from '../mxResources';
import { getClientX, getClientY } from '../mxEventUtils';
+import { htmlEntities } from '../mxStringUtils';
/**
* Basic window inside a document.
diff --git a/packages/core/src/view/cell/mxCell.ts b/packages/core/src/view/cell/mxCell.ts
index 6022e54e5..c1164604e 100644
--- a/packages/core/src/view/cell/mxCell.ts
+++ b/packages/core/src/view/cell/mxCell.ts
@@ -10,6 +10,8 @@ import mxConstants from '../../util/mxConstants';
import mxGeometry from '../../util/datatypes/mxGeometry';
import mxCellOverlay from './mxCellOverlay';
import { clone } from '../../util/mxCloneUtils';
+import mxPoint from "../../util/datatypes/mxPoint";
+import mxCellPath from "./mxCellPath";
/**
* Cells are the elements of the graph model. They represent the state
@@ -707,6 +709,289 @@ class mxCell {
}
return value;
}
+
+ /**
+ * Returns the nearest common ancestor for the specified cells to `this`.
+ *
+ * @param {mxCell} cell2 that specifies the second cell in the tree.
+ */
+ // getNearestCommonAncestor(cell1: mxCell, cell2: mxCell): mxCell;
+ getNearestCommonAncestor(cell2: mxCell | null): mxCell | null {
+
+ // Creates the cell path for the second cell
+ let path = mxCellPath.create(cell2);
+
+ if (path != null && path.length > 0) {
+ // Bubbles through the ancestors of the first
+ // cell to find the nearest common ancestor.
+ let cell: mxCell | null = this;
+ let current: string | null = mxCellPath.create(cell);
+
+ // Inverts arguments
+ if (path.length < current.length) {
+ cell = cell2;
+ const tmp = current;
+ current = path;
+ path = tmp;
+ }
+
+ while (cell != null) {
+ const parent = cell.getParent();
+
+ // Checks if the cell path is equal to the beginning of the given cell path
+ if (
+ path.indexOf(current + mxCellPath.PATH_SEPARATOR) === 0 &&
+ parent != null
+ ) {
+ return cell;
+ }
+
+ current = mxCellPath.getParentPath(current);
+ cell = parent;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns true if the given parent is an ancestor of the given child. Note
+ * returns true if child == parent.
+ *
+ * @param {mxCell} child that specifies the child.
+ */
+ // isAncestor(parent: mxCell, child: mxCell): boolean;
+ isAncestor(child: mxCell | null): boolean {
+
+ while (child != null && child !== this) {
+ child = child.getParent();
+ }
+ return child === this;
+ }
+
+ /**
+ * Returns the child vertices of the given parent.
+ */
+ // getChildVertices(parent: mxCell): Array;
+ getChildVertices() {
+ return this.getChildCells(true, false);
+ }
+
+ /**
+ * Returns the child edges of the given parent.
+ */
+ // getChildEdges(parent: mxCell): Array;
+ getChildEdges(): mxCell[] {
+ return this.getChildCells(false, true);
+ }
+
+ /**
+ * Returns the children of the given cell that are vertices and/or edges
+ * depending on the arguments.
+ *
+ * @param vertices Boolean indicating if child vertices should be returned.
+ * Default is false.
+ * @param edges Boolean indicating if child edges should be returned.
+ * Default is false.
+ */
+ // getChildCells(parent: mxCell, vertices: boolean, edges: boolean): Array;
+ getChildCells(vertices: boolean=false,
+ edges: boolean=false): mxCell[] {
+
+ const childCount = this.getChildCount();
+ const result = [];
+
+ for (let i = 0; i < childCount; i += 1) {
+ const child = this.getChildAt(i);
+
+ if (
+ (!edges && !vertices) ||
+ (edges && child.isEdge()) ||
+ (vertices && child.isVertex())
+ ) {
+ result.push(child);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Returns the number of incoming or outgoing edges, ignoring the given
+ * edge.
+ *
+ * @param outgoing Boolean that specifies if the number of outgoing or
+ * incoming edges should be returned.
+ * @param {mxCell} ignoredEdge that represents an edge to be ignored.
+ */
+ // getDirectedEdgeCount(cell: mxCell, outgoing: boolean, ignoredEdge: boolean): number;
+ getDirectedEdgeCount(outgoing: boolean,
+ ignoredEdge: mxCell | null=null): number {
+ let count = 0;
+ const edgeCount = this.getEdgeCount();
+
+ for (let i = 0; i < edgeCount; i += 1) {
+ const edge = this.getEdgeAt(i);
+ if (edge !== ignoredEdge && edge && edge.getTerminal(outgoing) === this) {
+ count += 1;
+ }
+ }
+ return count;
+ }
+
+ /**
+ * Returns all edges of the given cell without loops.
+ */
+ // getConnections(cell: mxCell): Array;
+ getConnections() {
+ return this.getEdges(true, true, false);
+ }
+
+ /**
+ * Returns the incoming edges of the given cell without loops.
+ */
+ // getIncomingEdges(cell: mxCell): Array;
+ getIncomingEdges(): mxCell[] {
+ return this.getEdges(true, false, false);
+ }
+
+ /**
+ * Returns the outgoing edges of the given cell without loops.
+ */
+ // getOutgoingEdges(cell: mxCell): Array;
+ getOutgoingEdges(): mxCell[] {
+ return this.getEdges(false, true, false);
+ }
+
+ /**
+ * Returns all distinct edges connected to this cell as a new array of
+ * {@link mxCell}. If at least one of incoming or outgoing is true, then loops
+ * are ignored, otherwise if both are false, then all edges connected to
+ * the given cell are returned including loops.
+ *
+ * @param incoming Optional boolean that specifies if incoming edges should be
+ * returned. Default is true.
+ * @param outgoing Optional boolean that specifies if outgoing edges should be
+ * returned. Default is true.
+ * @param includeLoops Optional boolean that specifies if loops should be returned.
+ * Default is true.
+ */
+ // getEdges(cell: mxCell, incoming?: boolean, outgoing?: boolean, includeLoops?: boolean): Array;
+ getEdges(incoming: boolean=true,
+ outgoing: boolean=true,
+ includeLoops: boolean=true) {
+
+ const edgeCount = this.getEdgeCount();
+ const result = [];
+
+ for (let i = 0; i < edgeCount; i += 1) {
+ const edge = this.getEdgeAt(i);
+ const source = edge.getTerminal(true);
+ const target = edge.getTerminal(false);
+
+ if (
+ (includeLoops && source === target) ||
+ (source !== target &&
+ ((incoming && target === this) || (outgoing && source === this)))
+ ) {
+ result.push(edge);
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Returns the absolute, accumulated origin for the children inside the
+ * given parent as an {@link mxPoint}.
+ */
+ // getOrigin(cell: mxCell): mxPoint;
+ getOrigin(): mxPoint {
+ let result = null;
+
+ if (this != null && this.getParent()) {
+ result = (this.getParent()).getOrigin();
+
+ if (!this.isEdge()) {
+ const geo = this.getGeometry();
+
+ if (geo != null) {
+ result.x += geo.x;
+ result.y += geo.y;
+ }
+ }
+ } else {
+ result = new mxPoint();
+ }
+ return result;
+ }
+
+ /**
+ * Returns all descendants of the given cell and the cell itself in an array.
+ */
+ // getDescendants(parent: mxCell): Array;
+ getDescendants(): mxCell[] {
+ return this.filterDescendants(null);
+ }
+
+ /**
+ * Visits all cells recursively and applies the specified filter function
+ * to each cell. If the function returns true then the cell is added
+ * to the resulting array. The parent and result paramters are optional.
+ * If parent is not specified then the recursion starts at {@link root}.
+ *
+ * Example:
+ * The following example extracts all vertices from a given model:
+ * ```javascript
+ * var filter(cell)
+ * {
+ * return model.isVertex(cell);
+ * }
+ * var vertices = model.filterDescendants(filter);
+ * ```
+ *
+ * @param filter JavaScript function that takes an {@link mxCell} as an argument
+ * and returns a boolean.
+ */
+ // filterDescendants(filter: (...args: any) => boolean, parent?: mxCell): Array;
+ filterDescendants(filter: Function | null): mxCell[] {
+ let parent = this;
+
+ // Creates a new array for storing the result
+ let result: mxCell[] = [];
+
+ // Recursion starts at the root of the model
+ parent = parent || this.getRoot();
+
+ // Checks if the filter returns true for the cell
+ // and adds it to the result array
+ if (filter == null || filter(parent)) {
+ result.push(parent);
+ }
+
+ // Visits the children of the cell
+ const childCount = parent.getChildCount();
+ for (let i = 0; i < childCount; i += 1) {
+ const child = parent.getChildAt(i);
+ result = result.concat(child.filterDescendants(filter));
+ }
+
+ return result;
+ }
+
+ /**
+ * Returns the root of the model or the topmost parent of the given cell.
+ */
+ // getRoot(cell?: mxCell): mxCell;
+ getRoot(): mxCell {
+ let root: mxCell = this;
+ let cell: mxCell = this;
+
+ while (cell != null) {
+ root = cell;
+ cell = cell.getParent();
+ }
+ return root;
+ }
}
export default mxCell;
diff --git a/packages/core/src/view/cell/mxCellRenderer.ts b/packages/core/src/view/cell/mxCellRenderer.ts
index 8b9ad0638..2f08f29a2 100644
--- a/packages/core/src/view/cell/mxCellRenderer.ts
+++ b/packages/core/src/view/cell/mxCellRenderer.ts
@@ -717,7 +717,7 @@ class mxCellRenderer {
return (evt: mxEventObject) => {
if (this.forceControlClickHandler || graph.isEnabled()) {
- const collapse = !graph.isCellCollapsed(state.cell);
+ const collapse = !state.cell.isCollapsed();
graph.foldCells(collapse, false, [state.cell], false, evt);
mxEvent.consume(evt);
}
@@ -1150,7 +1150,7 @@ class mxCellRenderer {
bounds.x += spacing.x * scale;
bounds.y += spacing.y * scale;
- const geo = graph.getCellGeometry(state.cell);
+ const geo = state.cell.getGeometry();
if (geo != null) {
bounds.width = Math.max(0, geo.width * scale);
diff --git a/packages/core/src/view/cell/mxCellState.ts b/packages/core/src/view/cell/mxCellState.ts
index 05dc199f6..c184e19ba 100644
--- a/packages/core/src/view/cell/mxCellState.ts
+++ b/packages/core/src/view/cell/mxCellState.ts
@@ -480,6 +480,19 @@ class mxCellState extends mxRectangle {
destroy(): void {
((this.view).graph).cellRenderer.destroy(this);
}
+
+
+ /**
+ * Returns true if the given cell state is a loop.
+ *
+ * @param state {@link mxCellState} that represents a potential loop.
+ */
+ // isLoop(state: mxCellState): boolean;
+ isLoop(): boolean {
+ const src = this.getVisibleTerminalState(true);
+ const trg = this.getVisibleTerminalState(false);
+ return src != null && src == trg;
+ }
}
export default mxCellState;
diff --git a/packages/core/src/view/cell/mxCellStatePreview.ts b/packages/core/src/view/cell/mxCellStatePreview.ts
index db73da212..45a0845b4 100644
--- a/packages/core/src/view/cell/mxCellStatePreview.ts
+++ b/packages/core/src/view/cell/mxCellStatePreview.ts
@@ -179,7 +179,7 @@ class mxCellStatePreview {
state.view.updateCellState(state);
}
- const geo = this.graph.getCellGeometry(state.cell);
+ const geo = (state.cell).getGeometry();
const pState = state.view.getState(state.cell.getParent());
// Moves selection vertices which are relative
diff --git a/packages/core/src/view/cell/mxCells.ts b/packages/core/src/view/cell/mxCells.ts
new file mode 100644
index 000000000..b0cfd8337
--- /dev/null
+++ b/packages/core/src/view/cell/mxCells.ts
@@ -0,0 +1,228 @@
+import mxCell from "./mxCell";
+import mxDictionary from "../../util/datatypes/mxDictionary";
+import mxObjectIdentity from "../../util/datatypes/mxObjectIdentity";
+
+class mxCells extends Array {
+ constructor(...items: mxCell[]) {
+ super(...items);
+ }
+
+ /**
+ * Returns the cells from the given array where the given filter function
+ * returns true.
+ */
+ // filterCells(cells: Array, filter: (...args: any) => boolean): Array;
+ filterCells(filter: Function): mxCell[] {
+ let result = [];
+
+ for (let i = 0; i < this.length; i += 1) {
+ if (filter(this[i])) {
+ result.push(this[i]);
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Returns all opposite vertices wrt terminal for the given edges, only
+ * returning sources and/or targets as specified. The result is returned
+ * as an array of {@link mxCell}.
+ *
+ * @param {mxCell} terminal that specifies the known end of the edges.
+ * @param sources Boolean that specifies if source terminals should be contained
+ * in the result. Default is true.
+ * @param targets Boolean that specifies if target terminals should be contained
+ * in the result. Default is true.
+ */
+ // getOpposites(edges: Array, terminal: mxCell, sources?: boolean, targets?: boolean): Array;
+ getOpposites(terminal: mxCell,
+ sources: boolean=true,
+ targets: boolean=true): mxCell[] {
+
+ const terminals = [];
+
+ for (let i = 0; i < this.length; i += 1) {
+ const source = this[i].getTerminal(true);
+ const target = this[i].getTerminal(false);
+
+ // Checks if the terminal is the source of
+ // the edge and if the target should be
+ // stored in the result
+ if (
+ source === terminal &&
+ target != null &&
+ target !== terminal &&
+ targets
+ ) {
+ terminals.push(target);
+ }
+
+ // Checks if the terminal is the taget of
+ // the edge and if the source should be
+ // stored in the result
+ else if (
+ target === terminal &&
+ source != null &&
+ source !== terminal &&
+ sources
+ ) {
+ terminals.push(source);
+ }
+ }
+ return terminals;
+ }
+
+ /**
+ * Returns the topmost cells of the hierarchy in an array that contains no
+ * descendants for each {@link mxCell} that it contains. Duplicates should be
+ * removed in the cells array to improve performance.
+ */
+ // getTopmostCells(cells: Array): Array;
+ getTopmostCells(): mxCell[] {
+ const dict = new mxDictionary();
+ const tmp = [];
+
+ for (let i = 0; i < this.length; i += 1) {
+ dict.put(this[i], true);
+ }
+
+ for (let i = 0; i < this.length; i += 1) {
+ const cell = this[i];
+ let topmost = true;
+ let parent = cell.getParent();
+
+ while (parent != null) {
+ if (dict.get(parent)) {
+ topmost = false;
+ break;
+ }
+ parent = parent.getParent();
+ }
+
+ if (topmost) {
+ tmp.push(cell);
+ }
+ }
+ return tmp;
+ }
+
+ /**
+ * Returns an array that represents the set (no duplicates) of all parents
+ * for the given array of cells.
+ */
+ // getParents(cells: Array): Array;
+ getParents() {
+ const parents = [];
+ const dict = new mxDictionary();
+
+ for (const cell of this) {
+ const parent = cell.getParent();
+ if (parent != null && !dict.get(parent)) {
+ dict.put(parent, true);
+ parents.push(parent);
+ }
+ }
+ return parents;
+ }
+
+ /**
+ * Returns an array of clones for the given array of {@link mxCell}`.
+ * Depending on the value of includeChildren, a deep clone is created for
+ * each cell. Connections are restored based if the corresponding
+ * cell is contained in the passed in array.
+ *
+ * @param includeChildren Boolean indicating if the cells should be cloned
+ * with all descendants.
+ * @param mapping Optional mapping for existing clones.
+ */
+ // cloneCells(cells: Array, includeChildren?: boolean, mapping?: any): Array;
+ cloneCells(includeChildren: boolean=true,
+ mapping: any={}): mxCell[] {
+
+ const clones: mxCell[] = [];
+
+ for (const cell of this) {
+ clones.push(this.cloneCellImpl(cell, mapping, includeChildren));
+ }
+
+ for (let i = 0; i < clones.length; i += 1) {
+ if (clones[i] != null) {
+ this.restoreClone(clones[i], this[i], mapping);
+ }
+ }
+ return clones;
+ }
+
+ /**
+ * Inner helper method for cloning cells recursively.
+ *
+ * @private
+ */
+ // cloneCellImpl(cell: mxCell, mapping?: any, includeChildren?: boolean): mxCell;
+ cloneCellImpl(cell: mxCell,
+ mapping: any={},
+ includeChildren: boolean): mxCell {
+
+ const ident = mxObjectIdentity.get(cell);
+ let clone = mapping ? mapping[ident] : null;
+
+ if (clone == null) {
+ clone = cell.clone();
+ mapping[ident] = clone;
+
+ if (includeChildren) {
+ const childCount = cell.getChildCount();
+
+ for (let i = 0; i < childCount; i += 1) {
+ const cloneChild = this.cloneCellImpl(
+ cell.getChildAt(i),
+ mapping,
+ true
+ );
+ clone.insert(cloneChild);
+ }
+ }
+ }
+ return clone;
+ }
+
+ /**
+ * Inner helper method for restoring the connections in
+ * a network of cloned cells.
+ *
+ * @private
+ */
+ // restoreClone(clone: mxCell, cell: mxCell, mapping?: any): void;
+ restoreClone(clone: mxCell,
+ cell: mxCell,
+ mapping: any): void {
+
+ const source = cell.getTerminal(true);
+
+ if (source != null) {
+ const tmp = mapping[mxObjectIdentity.get(source)];
+ if (tmp != null) {
+ tmp.insertEdge(clone, true);
+ }
+ }
+
+ const target = cell.getTerminal(false);
+ if (target != null) {
+ const tmp = mapping[mxObjectIdentity.get(target)];
+ if (tmp != null) {
+ tmp.insertEdge(clone, false);
+ }
+ }
+
+ const childCount = clone.getChildCount();
+ for (let i = 0; i < childCount; i += 1) {
+ this.restoreClone(
+ clone.getChildAt(i),
+ cell.getChildAt(i),
+ mapping
+ );
+ }
+ }
+}
+
+export default mxCells;
diff --git a/packages/core/src/view/graph/mxGraph.ts b/packages/core/src/view/graph/mxGraph.ts
index d6c908ad7..4e403f5a8 100644
--- a/packages/core/src/view/graph/mxGraph.ts
+++ b/packages/core/src/view/graph/mxGraph.ts
@@ -188,9 +188,10 @@ class mxGraph extends mxEventSource {
// mouseListeners: any[];
mouseListeners: any[] | null = null;
- /**
+ /*****************************************************************************
* Group: Variables
- */
+ *****************************************************************************/
+
/**
* Holds the state of the mouse button.
*/
@@ -1329,7 +1330,7 @@ class mxGraph extends mxEventSource {
let par = cells[i].getParent();
while (par != null && par !== this.getView().currentRoot) {
- if (this.isCellCollapsed(par) || !par.isVisible()) {
+ if (par.isCollapsed() || !par.isVisible()) {
removed.push(cells[i]);
break;
}
@@ -1373,7 +1374,7 @@ class mxGraph extends mxEventSource {
const newParent = change.child.getParent();
this.getView().invalidate(change.child, true, true);
- if (!this.getModel().contains(newParent) || this.isCellCollapsed(newParent)) {
+ if (!this.getModel().contains(newParent) || newParent.isCollapsed()) {
this.getView().invalidate(change.child, true, true);
this.removeStateForCell(change.child);
@@ -1453,9 +1454,9 @@ class mxGraph extends mxEventSource {
this.getView().removeState(cell);
}
- /**
+ /*****************************************************************************
* Group: Overlays
- */
+ *****************************************************************************/
/**
* Adds an {@link mxCellOverlay} for the specified cell. This method fires an
@@ -1653,9 +1654,9 @@ class mxGraph extends mxEventSource {
return null;
}
- /**
+ /*****************************************************************************
* Group: In-place editing
- */
+ *****************************************************************************/
/**
* Calls {@link startEditingAtCell} using the given cell or the first selection
@@ -1793,20 +1794,17 @@ class mxGraph extends mxEventSource {
value: any,
autoSize: boolean=false): void {
- this.getModel().beginUpdate();
- try {
+ this.batchUpdate(() => {
this.getModel().setValue(cell, value);
if (autoSize) {
this.cellSizeUpdated(cell, false);
}
- } finally {
- this.getModel().endUpdate();
- }
+ });
}
- /**
+ /*****************************************************************************
* Group: Event processing
- */
+ *****************************************************************************/
/**
* Processes an escape keystroke.
@@ -2559,9 +2557,9 @@ class mxGraph extends mxEventSource {
drawPageBreaks(this.verticalPageBreaks);
}
- /**
+ /*****************************************************************************
* Group: Cell styles
- */
+ *****************************************************************************/
/**
* Returns the style for the given cell from the cell state, if one exists,
@@ -2795,9 +2793,9 @@ class mxGraph extends mxEventSource {
}
}
- /**
+ /*****************************************************************************
* Group: Cell alignment and orientation
- */
+ *****************************************************************************/
/**
* Aligns the given cells vertically or horizontally according to the given
@@ -2863,7 +2861,7 @@ class mxGraph extends mxEventSource {
const state = this.getView().getState(cells[i]);
if (state != null) {
- let geo = this.getCellGeometry(cells[i]);
+ let geo = cells[i].getGeometry();
if (geo != null && !cells[i].isEdge()) {
geo = geo.clone();
@@ -2992,9 +2990,9 @@ class mxGraph extends mxEventSource {
return null;
}
- /**
+ /*****************************************************************************
* Group: Order
- */
+ *****************************************************************************/
/**
* Moves the given cells to the front or back. The change is carried out
@@ -3062,9 +3060,9 @@ class mxGraph extends mxEventSource {
}
}
- /**
+ /*****************************************************************************
* Group: Grouping
- */
+ *****************************************************************************/
/**
* Adds the cells into the given group. The change is carried out using
@@ -3105,7 +3103,7 @@ class mxGraph extends mxEventSource {
try {
// Checks if the group has a geometry and
// creates one if one does not exist
- if (this.getCellGeometry(group) == null) {
+ if (group.getGeometry() == null) {
this.getModel().setGeometry(group, new mxGeometry());
}
@@ -3259,7 +3257,7 @@ class mxGraph extends mxEventSource {
// Fix relative child cells
for (let j = 0; j < children.length; j++) {
const state = this.getView().getState(children[j]);
- let geo = this.getCellGeometry(children[j]);
+ let geo = children[j].getGeometry();
if (state != null && geo != null && geo.relative) {
geo = geo.clone();
@@ -3385,7 +3383,7 @@ class mxGraph extends mxEventSource {
this.getModel().beginUpdate();
try {
for (let i = cells.length - 1; i >= 0; i--) {
- let geo = this.getCellGeometry(cells[i]);
+ let geo = cells[i].getGeometry();
if (geo != null) {
const children = this.getChildCells(cells[i]);
@@ -3474,9 +3472,9 @@ class mxGraph extends mxEventSource {
return result;
}
- /**
+ /*****************************************************************************
* Group: Cell cloning, insertion and removal
- */
+ *****************************************************************************/
/**
* Returns the clone for the given cell. Uses {@link cloneCells}.
@@ -4263,7 +4261,7 @@ class mxGraph extends mxEventSource {
// Removes waypoints before/after new cell
const state = this.getView().getState(edge);
- let geo = this.getCellGeometry(newEdge);
+ let geo = newEdge.getGeometry();
if (geo != null && geo.points != null && state != null) {
const t = this.getView().translate;
@@ -4275,7 +4273,7 @@ class mxGraph extends mxEventSource {
);
geo.points = geo.points.slice(0, idx);
- geo = this.getCellGeometry(edge);
+ geo = edge.getGeometry();
if (geo != null && geo.points != null) {
geo = geo.clone();
@@ -4325,9 +4323,9 @@ class mxGraph extends mxEventSource {
return newEdge;
}
- /**
+ /*****************************************************************************
* Group: Cell visibility
- */
+ *****************************************************************************/
/**
* Sets the visible state of the specified cells and all connected edges
@@ -4393,9 +4391,9 @@ class mxGraph extends mxEventSource {
}
}
- /**
+ /*****************************************************************************
* Group: Folding
- */
+ *****************************************************************************/
/**
* Sets the collapsed state of the specified cells and all descendants
@@ -4469,7 +4467,7 @@ class mxGraph extends mxEventSource {
for (let i = 0; i < cells.length; i += 1) {
if (
(!checkFoldable || this.isCellFoldable(cells[i], collapse)) &&
- collapse !== this.isCellCollapsed(cells[i])
+ collapse !== cells[i].isCollapsed()
) {
this.getModel().setCollapsed(cells[i], collapse);
this.swapBounds(cells[i], collapse);
@@ -4629,9 +4627,9 @@ class mxGraph extends mxEventSource {
return edges;
}
- /**
+ /*****************************************************************************
* Group: Cell sizing
- */
+ *****************************************************************************/
/**
* Updates the size of the given cell in the model using {@link cellSizeUpdated}.
@@ -4677,7 +4675,7 @@ class mxGraph extends mxEventSource {
let geo = cell.getGeometry();
if (size != null && geo != null) {
- const collapsed = this.isCellCollapsed(cell);
+ const collapsed = cell.isCollapsed();
geo = geo.clone();
if (this.isSwimlane(cell)) {
@@ -4948,7 +4946,7 @@ class mxGraph extends mxEventSource {
* {
* if (graph.getModel().getChildCount(cells[i]) > 0)
* {
- * var geo = graph.getCellGeometry(cells[i]);
+ * var geo = cells[i].getGeometry();
*
* if (geo != null)
* {
@@ -5183,10 +5181,10 @@ class mxGraph extends mxEventSource {
extendParent(cell: mxCell | null=null): void {
if (cell != null) {
const parent = cell.getParent();
- let p = this.getCellGeometry(parent);
+ let p = parent.getGeometry();
- if (parent != null && p != null && !this.isCellCollapsed(parent)) {
- const geo = this.getCellGeometry(cell);
+ if (parent != null && p != null && !parent.isCollapsed()) {
+ const geo = cell.getGeometry();
if (
geo != null &&
@@ -5204,9 +5202,9 @@ class mxGraph extends mxEventSource {
}
}
- /**
+ /*****************************************************************************
* Group: Cell moving
- */
+ *****************************************************************************/
/**
* Clones and inserts the given cells into the graph using the move
@@ -5298,7 +5296,7 @@ class mxGraph extends mxEventSource {
const checked = [];
for (let i = 0; i < cells.length; i += 1) {
- const geo = this.getCellGeometry(cells[i]);
+ const geo = cells[i].getGeometry();
const parent = cells[i].getParent();
if (
@@ -5351,7 +5349,7 @@ class mxGraph extends mxEventSource {
// Restores parent edge on cloned edge labels
if (clone) {
for (let i = 0; i < cells.length; i += 1) {
- const geo = this.getCellGeometry(cells[i]);
+ const geo = cells[i].getGeometry();
const parent = origCells[i].getParent();
if (
@@ -5589,14 +5587,14 @@ class mxGraph extends mxEventSource {
sizeFirst: boolean=true): void {
if (cell != null) {
- let geo = this.getCellGeometry(cell);
+ let geo = cell.getGeometry();
if (
geo != null &&
(this.isConstrainRelativeChildren() || !geo.relative)
) {
const parent = cell.getParent();
- const pgeo = this.getCellGeometry(parent);
+ const pgeo = (parent).getGeometry();
let max = this.getMaximumGraphBounds();
// Finds parent offset
@@ -5639,7 +5637,7 @@ class mxGraph extends mxEventSource {
if (max != null) {
const cells = [cell];
- if (!this.isCellCollapsed(cell)) {
+ if (!cell.isCollapsed()) {
const desc = this.getModel().getDescendants(cell);
for (let i = 0; i < desc.length; i += 1) {
@@ -5776,9 +5774,9 @@ class mxGraph extends mxEventSource {
return edge;
}
- /**
+ /*****************************************************************************
* Group: Cell connecting and connection constraints
- */
+ *****************************************************************************/
/**
* Returns the constraint used to connect to the outline of the given state.
@@ -6369,9 +6367,9 @@ class mxGraph extends mxEventSource {
}
}
- /**
+ /*****************************************************************************
* Group: Drilldown
- */
+ *****************************************************************************/
/**
* Returns the current root of the displayed cell hierarchy. This is a
@@ -6429,7 +6427,7 @@ class mxGraph extends mxEventSource {
* ```javascript
* graph.isPort = function(cell)
* {
- * var geo = this.getCellGeometry(cell);
+ * var geo = cell.getGeometry();
*
* return (geo != null) ? geo.relative : false;
* };
@@ -6555,9 +6553,9 @@ class mxGraph extends mxEventSource {
return cell != null;
}
- /**
+ /*****************************************************************************
* Group: Graph display
- */
+ *****************************************************************************/
/**
* Returns the bounds of the visible graph. Shortcut to
@@ -6657,7 +6655,7 @@ class mxGraph extends mxEventSource {
for (const cell of cells) {
if (includeEdges || cell.isVertex()) {
// Computes the bounding box for the points in the geometry
- const geo = this.getCellGeometry(cell);
+ const geo = cell.getGeometry();
if (geo != null) {
let bbox = null;
@@ -7390,6 +7388,7 @@ class mxGraph extends mxEventSource {
*/
// getCellGeometry(cell: mxCell): mxGeometry;
getCellGeometry(cell: mxCell): mxGeometry | null {
+ // SLATED FOR DELETION
return cell.getGeometry();
}
@@ -7406,6 +7405,7 @@ class mxGraph extends mxEventSource {
*/
// isCellVisible(cell: mxCell): boolean;
isCellVisible(cell: mxCell): boolean {
+ // SLATED FOR DELETION
return cell.isVisible();
}
@@ -7473,9 +7473,8 @@ class mxGraph extends mxEventSource {
*/
// isLoop(state: mxCellState): boolean;
isLoop(state: mxCellState): boolean {
- const src = state.getVisibleTerminalState(true);
- const trg = state.getVisibleTerminalState(false);
- return src != null && src == trg;
+ // SLATED FOR DELETION
+ return state.isLoop();
}
/**
@@ -7503,7 +7502,7 @@ class mxGraph extends mxEventSource {
* pressed on any other platform.
*/
// isToggleEvent(evt: MouseEvent): boolean;
- isToggleEvent(evt: mxEventObject | mxMouseEvent | mxMouseEvent): boolean {
+ isToggleEvent(evt: mxEventObject | mxMouseEvent): boolean {
return mxClient.IS_MAC
? isMetaDown(evt)
: isControlDown(evt);
@@ -7534,9 +7533,9 @@ class mxGraph extends mxEventSource {
return false;
}
- /**
+ /*****************************************************************************
* Group: Validation
- */
+ *****************************************************************************/
/**
* Displays the given validation error in a dialog. This implementation uses
@@ -7740,7 +7739,7 @@ class mxGraph extends mxEventSource {
let warning = '';
// Adds error for invalid children if collapsed (children invisible)
- if (cell && this.isCellCollapsed(cell) && !isValid) {
+ if (cell && cell.isCollapsed() && !isValid) {
warning += `${mxResources.get(this.containsValidationErrorsResource) ||
this.containsValidationErrorsResource}\n`;
}
@@ -7824,9 +7823,9 @@ class mxGraph extends mxEventSource {
return null;
}
- /**
+ /*****************************************************************************
* Group: Graph appearance
- */
+ *****************************************************************************/
/**
* Returns the {@link backgroundImage} as an {@link mxImage}.
@@ -7857,7 +7856,7 @@ class mxGraph extends mxEventSource {
this.foldingEnabled &&
!state.cell.isEdge()
) {
- const tmp = this.isCellCollapsed(state.cell);
+ const tmp = (state.cell).isCollapsed();
if (this.isCellFoldable(state.cell, !tmp)) {
return tmp ? this.collapsedImage : this.expandedImage;
@@ -7917,7 +7916,7 @@ class mxGraph extends mxEventSource {
*
* if (label != null && this.model.isVertex(cell))
* {
- * var geo = this.getCellGeometry(cell);
+ * var geo = cell.getCellGeometry();
*
* if (geo != null)
* {
@@ -8452,9 +8451,9 @@ class mxGraph extends mxEventSource {
return false;
}
- /**
+ /*****************************************************************************
* Group: Graph behaviour
- */
+ *****************************************************************************/
/**
* Returns {@link resizeContainer}.
@@ -9311,7 +9310,7 @@ class mxGraph extends mxEventSource {
(cell == null && this.allowDanglingEdges) ||
(cell != null &&
(!cell.isEdge() || this.connectableEdges) &&
- this.isCellConnectable(cell))
+ cell.isConnectable())
);
}
@@ -9664,7 +9663,7 @@ class mxGraph extends mxEventSource {
(!cell.isEdge() &&
(this.isSwimlane(cell) ||
(cell.getChildCount() > 0 &&
- !this.isCellCollapsed(cell)))))
+ !cell.isCollapsed()))))
);
}
@@ -9685,7 +9684,7 @@ class mxGraph extends mxEventSource {
target.isEdge() &&
cells != null &&
cells.length == 1 &&
- this.isCellConnectable(cells[0]) &&
+ cells[0].isConnectable() &&
this.getEdgeValidationError(
target,
target.getTerminal(true),
@@ -9775,9 +9774,9 @@ class mxGraph extends mxEventSource {
return !this.getModel().isLayer(cell) && parent == null ? cell : null;
}
- /**
+ /*****************************************************************************
* Group: Cell retrieval
- */
+ *****************************************************************************/
/**
* Returns {@link defaultParent} or {@link mxGraphView.currentRoot} or the first child
@@ -10140,7 +10139,7 @@ class mxGraph extends mxEventSource {
recurse: boolean=false): mxCell[] {
let edges: mxCell[] = [];
- const isCollapsed = this.isCellCollapsed(cell);
+ const isCollapsed = cell.isCollapsed();
const childCount = cell.getChildCount();
for (let i = 0; i < childCount; i += 1) {
@@ -10485,9 +10484,9 @@ class mxGraph extends mxEventSource {
return result;
}
- /**
+ /*****************************************************************************
* Group: Tree and traversal-related
- */
+ *****************************************************************************/
/**
* Returns all children in the given parent which do not have incoming
@@ -10624,9 +10623,9 @@ class mxGraph extends mxEventSource {
}
}
- /**
+ /*****************************************************************************
* Group: Selection
- */
+ *****************************************************************************/
/**
* Returns true if the given cell is selected.
@@ -10969,9 +10968,9 @@ class mxGraph extends mxEventSource {
}
}
- /**
+ /*****************************************************************************
* Group: Selection state
- */
+ *****************************************************************************/
/**
* Creates a new handler for the given cell state. This implementation
@@ -10988,7 +10987,7 @@ class mxGraph extends mxEventSource {
if (state.cell.isEdge()) {
const source = state.getVisibleTerminalState(true);
const target = state.getVisibleTerminalState(false);
- const geo = this.getCellGeometry(state.cell);
+ const geo = (state.cell).getGeometry();
const edgeStyle = this.getView().getEdgeStyle(
state,
@@ -11062,9 +11061,9 @@ class mxGraph extends mxEventSource {
return new mxElbowEdgeHandler(state);
}
- /**
+ /*****************************************************************************
* Group: Graph events
- */
+ *****************************************************************************/
/**
* Adds a listener to the graph event dispatch loop. The listener
diff --git a/packages/core/src/view/graph/mxGraphModel.ts b/packages/core/src/view/graph/mxGraphModel.ts
index 80b54e2ef..3e749ecdc 100644
--- a/packages/core/src/view/graph/mxGraphModel.ts
+++ b/packages/core/src/view/graph/mxGraphModel.ts
@@ -24,6 +24,7 @@ import mxTerminalChange from '../../atomic_changes/mxTerminalChange';
import mxValueChange from '../../atomic_changes/mxValueChange';
import mxVisibleChange from '../../atomic_changes/mxVisibleChange';
import mxGeometry from "../../util/datatypes/mxGeometry";
+import mxCells from "../cell/mxCells";
/**
* Extends {@link mxEventSource} to implement a graph model. The graph model acts as
@@ -339,97 +340,25 @@ class mxGraphModel extends mxEventSource {
return this.cells != null ? this.cells[id] : null;
}
- /**
- * Returns the cells from the given array where the given filter function
- * returns true.
- */
- // filterCells(cells: Array, filter: (...args: any) => boolean): Array;
- filterCells(cells: mxCell[] | null,
+ filterCells(cells: mxCell[],
filter: Function): mxCell[] | null {
-
- let result = null;
- if (cells != null) {
- result = [];
-
- for (let i = 0; i < cells.length; i += 1) {
- if (filter(cells[i])) {
- result.push(cells[i]);
- }
- }
- }
- return result;
+ return new mxCells(...cells).filterCells(filter);
}
- /**
- * Returns all descendants of the given cell and the cell itself in an array.
- *
- * @param {mxCell} parent whose descendants should be returned.
- */
- // getDescendants(parent: mxCell): Array;
getDescendants(parent: mxCell): mxCell[] {
- return this.filterDescendants(null, parent);
+ // SLATED FOR DELETION
+ return parent.getDescendants();
}
- /**
- * Visits all cells recursively and applies the specified filter function
- * to each cell. If the function returns true then the cell is added
- * to the resulting array. The parent and result paramters are optional.
- * If parent is not specified then the recursion starts at {@link root}.
- *
- * Example:
- * The following example extracts all vertices from a given model:
- * ```javascript
- * var filter(cell)
- * {
- * return model.isVertex(cell);
- * }
- * var vertices = model.filterDescendants(filter);
- * ```
- *
- * @param filter JavaScript function that takes an {@link mxCell} as an argument
- * and returns a boolean.
- * @param parent Optional {@link mxCell} that is used as the root of the recursion.
- */
- // filterDescendants(filter: (...args: any) => boolean, parent?: mxCell): Array;
filterDescendants(filter: Function | null,
parent: mxCell): mxCell[] {
- // Creates a new array for storing the result
- let result: mxCell[] = [];
-
- // Recursion starts at the root of the model
- parent = parent || this.getRoot();
-
- // Checks if the filter returns true for the cell
- // and adds it to the result array
- if (filter == null || filter(parent)) {
- result.push(parent);
- }
-
- // Visits the children of the cell
- const childCount = parent.getChildCount();
- for (let i = 0; i < childCount; i += 1) {
- const child = parent.getChildAt(i);
- result = result.concat(this.filterDescendants(filter, child));
- }
-
- return result;
+ // SLATED FOR DELETION
+ return parent.filterDescendants(filter);
}
- /**
- * Returns the root of the model or the topmost parent of the given cell.
- *
- * @param cell Optional {@link mxCell} that specifies the child.
- */
- // getRoot(cell?: mxCell): mxCell;
getRoot(cell: mxCell | null = null): mxCell | null {
- let root = cell || this.root;
- if (cell != null) {
- while (cell != null) {
- root = cell;
- cell = cell.getParent();
- }
- }
- return root;
+ // SLATED FOR DELETION
+ return cell ? cell.getRoot() : this.root;
}
/**
@@ -494,21 +423,10 @@ class mxGraphModel extends mxEventSource {
return this.isRoot(cell.getParent());
}
- /**
- * Returns true if the given parent is an ancestor of the given child. Note
- * returns true if child == parent.
- *
- * @param {mxCell} parent that specifies the parent.
- * @param {mxCell} child that specifies the child.
- */
- // isAncestor(parent: mxCell, child: mxCell): boolean;
isAncestor(parent: mxCell | null,
child: mxCell | null): boolean {
-
- while (child != null && child !== parent) {
- child = child.getParent();
- }
- return child === parent;
+ // SLATED FOR DELETION
+ return parent?.isAncestor(child) || false;
}
/**
@@ -715,8 +633,8 @@ class mxGraphModel extends mxEventSource {
if (this.isAncestor(root, source) && this.isAncestor(root, target)) {
if (source === target) {
cell = source ? source.getParent() : null;
- } else {
- cell = this.getNearestCommonAncestor(source, target);
+ } else if (source) {
+ cell = source.getNearestCommonAncestor(target);
}
if (
@@ -743,75 +661,15 @@ class mxGraphModel extends mxEventSource {
}
}
- /**
- * Returns the absolute, accumulated origin for the children inside the
- * given parent as an {@link mxPoint}.
- */
- // getOrigin(cell: mxCell): mxPoint;
getOrigin(cell: mxCell): mxPoint {
- let result = null;
-
- if (cell != null) {
- result = this.getOrigin(cell.getParent());
-
- if (!cell.isEdge()) {
- const geo = cell.getGeometry();
-
- if (geo != null) {
- result.x += geo.x;
- result.y += geo.y;
- }
- }
- } else {
- result = new mxPoint();
- }
- return result;
+ // SLATED FOR DELETION
+ return cell.getOrigin();
}
- /**
- * Returns the nearest common ancestor for the specified cells.
- *
- * @param {mxCell} cell1 that specifies the first cell in the tree.
- * @param {mxCell} cell2 that specifies the second cell in the tree.
- */
- // getNearestCommonAncestor(cell1: mxCell, cell2: mxCell): mxCell;
- getNearestCommonAncestor(cell1: mxCell | null,
- cell2: mxCell | null): mxCell | null {
-
- // Creates the cell path for the second cell
- let path = mxCellPath.create(cell2);
-
- if (path != null && path.length > 0) {
- // Bubbles through the ancestors of the first
- // cell to find the nearest common ancestor.
- let cell = cell1;
- let current: string | null = mxCellPath.create(cell);
-
- // Inverts arguments
- if (path.length < current.length) {
- cell = cell2;
- const tmp = current;
- current = path;
- path = tmp;
- }
-
- while (cell != null) {
- const parent = cell.getParent();
-
- // Checks if the cell path is equal to the beginning of the given cell path
- if (
- path.indexOf(current + mxCellPath.PATH_SEPARATOR) === 0 &&
- parent != null
- ) {
- return cell;
- }
-
- current = mxCellPath.getParentPath(current);
- cell = parent;
- }
- }
-
- return null;
+ getNearestCommonAncestor(cell1: mxCell,
+ cell2: mxCell): mxCell | null {
+ // SLATED FOR DELETION
+ return cell1.getNearestCommonAncestor(cell2);
}
/**
@@ -927,56 +785,21 @@ class mxGraphModel extends mxEventSource {
return cell.children || [];
}
- /**
- * Returns the child vertices of the given parent.
- *
- * @param {mxCell} cell whose child vertices should be returned.
- */
- // getChildVertices(parent: mxCell): Array;
getChildVertices(parent: mxCell) {
- return this.getChildCells(parent, true, false);
+ // SLATED FOR DELETION
+ return parent.getChildVertices();
}
- /**
- * Returns the child edges of the given parent.
- *
- * @param {mxCell} cell whose child edges should be returned.
- */
- // getChildEdges(parent: mxCell): Array;
getChildEdges(parent: mxCell): mxCell[] {
- return this.getChildCells(parent, false, true);
+ // SLATED FOR DELETION
+ return parent.getChildEdges();
}
- /**
- * Returns the children of the given cell that are vertices and/or edges
- * depending on the arguments.
- *
- * @param {mxCell} cell the represents the parent.
- * @param vertices Boolean indicating if child vertices should be returned.
- * Default is false.
- * @param edges Boolean indicating if child edges should be returned.
- * Default is false.
- */
- // getChildCells(parent: mxCell, vertices: boolean, edges: boolean): Array;
getChildCells(parent: mxCell,
vertices: boolean=false,
edges: boolean=false): mxCell[] {
-
- const childCount = parent.getChildCount();
- const result = [];
-
- for (let i = 0; i < childCount; i += 1) {
- const child = parent.getChildAt(i);
-
- if (
- (!edges && !vertices) ||
- (edges && child.isEdge()) ||
- (vertices && child.isVertex())
- ) {
- result.push(child);
- }
- }
- return result;
+ // SLATED FOR DELETION
+ return parent.getChildCells(vertices, edges);
}
/**
@@ -1088,102 +911,34 @@ class mxGraphModel extends mxEventSource {
return cell.getEdgeAt(index);
}
- /**
- * Returns the number of incoming or outgoing edges, ignoring the given
- * edge.
- *
- * @param {mxCell} cell whose edge count should be returned.
- * @param outgoing Boolean that specifies if the number of outgoing or
- * incoming edges should be returned.
- * @param {mxCell} ignoredEdge that represents an edge to be ignored.
- */
- // getDirectedEdgeCount(cell: mxCell, outgoing: boolean, ignoredEdge: boolean): number;
getDirectedEdgeCount(cell: mxCell,
outgoing: boolean,
ignoredEdge: mxCell | null=null): number {
- let count = 0;
- const edgeCount = cell.getEdgeCount();
-
- for (let i = 0; i < edgeCount; i += 1) {
- const edge = cell.getEdgeAt(i);
- if (edge !== ignoredEdge && edge && edge.getTerminal(outgoing) === cell) {
- count += 1;
- }
- }
- return count;
+ // SLATED FOR DELETION
+ return cell.getDirectedEdgeCount(outgoing, ignoredEdge)
}
- /**
- * Returns all edges of the given cell without loops.
- *
- * @param {mxCell} cell whose edges should be returned.
- *
- */
- // getConnections(cell: mxCell): Array;
getConnections(cell: mxCell) {
- return this.getEdges(cell, true, true, false);
+ // SLATED FOR DELETION
+ return cell.getConnections();
}
- /**
- * Returns the incoming edges of the given cell without loops.
- *
- * @param {mxCell} cell whose incoming edges should be returned.
- *
- */
- // getIncomingEdges(cell: mxCell): Array;
getIncomingEdges(cell: mxCell): mxCell[] {
- return this.getEdges(cell, true, false, false);
+ // SLATED FOR DELETION
+ return cell.getIncomingEdges();
}
- /**
- * Returns the outgoing edges of the given cell without loops.
- *
- * @param {mxCell} cell whose outgoing edges should be returned.
- *
- */
- // getOutgoingEdges(cell: mxCell): Array;
getOutgoingEdges(cell: mxCell): mxCell[] {
- return this.getEdges(cell, false, true, false);
+ // SLATED FOR DELETION
+ return cell.getOutgoingEdges();
}
- /**
- * Returns all distinct edges connected to this cell as a new array of
- * {@link mxCell}. If at least one of incoming or outgoing is true, then loops
- * are ignored, otherwise if both are false, then all edges connected to
- * the given cell are returned including loops.
- *
- * @param {mxCell} cell that specifies the cell.
- * @param incoming Optional boolean that specifies if incoming edges should be
- * returned. Default is true.
- * @param outgoing Optional boolean that specifies if outgoing edges should be
- * returned. Default is true.
- * @param includeLoops Optional boolean that specifies if loops should be returned.
- * Default is true.
- */
- // getEdges(cell: mxCell, incoming?: boolean, outgoing?: boolean, includeLoops?: boolean): Array;
getEdges(cell: mxCell,
incoming: boolean=true,
outgoing: boolean=true,
includeLoops: boolean=true) {
-
- const edgeCount = cell.getEdgeCount();
- const result = [];
-
- for (let i = 0; i < edgeCount; i += 1) {
- const edge = cell.getEdgeAt(i);
- const source = edge.getTerminal(true);
- const target = edge.getTerminal(false);
-
- if (
- (includeLoops && source === target) ||
- (source !== target &&
- ((incoming && target === cell) || (outgoing && source === cell)))
- ) {
- result.push(edge);
- }
- }
-
- return result;
+ // SLATED FOR DELETION
+ return cell.getEdges(incoming, outgoing, includeLoops);
}
/**
@@ -1235,91 +990,17 @@ class mxGraphModel extends mxEventSource {
return result;
}
- /**
- * Returns all opposite vertices wrt terminal for the given edges, only
- * returning sources and/or targets as specified. The result is returned
- * as an array of {@link mxCell}.
- *
- * @param edges Array of {@link mxCell} that contain the edges to be examined.
- * @param {mxCell} terminal that specifies the known end of the edges.
- * @param sources Boolean that specifies if source terminals should be contained
- * in the result. Default is true.
- * @param targets Boolean that specifies if target terminals should be contained
- * in the result. Default is true.
- */
- // getOpposites(edges: Array, terminal: mxCell, sources?: boolean, targets?: boolean): Array;
getOpposites(edges: mxCell[],
terminal: mxCell,
sources: boolean=true,
targets: boolean=true): mxCell[] {
-
- const terminals = [];
-
- for (let i = 0; i < edges.length; i += 1) {
- const source = edges[i].getTerminal(true);
- const target = edges[i].getTerminal(false);
-
- // Checks if the terminal is the source of
- // the edge and if the target should be
- // stored in the result
- if (
- source === terminal &&
- target != null &&
- target !== terminal &&
- targets
- ) {
- terminals.push(target);
- }
-
- // Checks if the terminal is the taget of
- // the edge and if the source should be
- // stored in the result
- else if (
- target === terminal &&
- source != null &&
- source !== terminal &&
- sources
- ) {
- terminals.push(source);
- }
- }
- return terminals;
+ // SLATED FOR DELETION
+ return new mxCells(...edges).getOpposites(terminal, sources, targets);
}
- /**
- * Returns the topmost cells of the hierarchy in an array that contains no
- * descendants for each {@link mxCell} that it contains. Duplicates should be
- * removed in the cells array to improve performance.
- *
- * @param cells Array of {@link mxCell} whose topmost ancestors should be returned.
- */
- // getTopmostCells(cells: Array): Array;
getTopmostCells(cells: mxCell[]): mxCell[] {
- const dict = new mxDictionary();
- const tmp = [];
-
- for (let i = 0; i < cells.length; i += 1) {
- dict.put(cells[i], true);
- }
-
- for (let i = 0; i < cells.length; i += 1) {
- const cell = cells[i];
- let topmost = true;
- let parent = cell.getParent();
-
- while (parent != null) {
- if (dict.get(parent)) {
- topmost = false;
- break;
- }
- parent = parent.getParent();
- }
-
- if (topmost) {
- tmp.push(cell);
- }
- }
- return tmp;
+ // SLATED FOR DELETION
+ return new mxCells(...cells).getTopmostCells();
}
/**
@@ -1818,28 +1499,9 @@ class mxGraphModel extends mxEventSource {
}
}
- /**
- * Returns an array that represents the set (no duplicates) of all parents
- * for the given array of cells.
- *
- * @param cells Array of cells whose parents should be returned.
- */
- // getParents(cells: Array): Array;
- getParents(cells: mxCell[] | null) {
- const parents = [];
-
- if (cells != null) {
- const dict = new mxDictionary();
-
- for (const cell of cells) {
- const parent = cell.getParent();
- if (parent != null && !dict.get(parent)) {
- dict.put(parent, true);
- parents.push(parent);
- }
- }
- }
- return parents;
+ getParents(cells: mxCell[]): mxCell[] {
+ // SLATED FOR DELETION
+ return new mxCells(...cells).getParents();
}
//
@@ -1861,65 +1523,11 @@ class mxGraphModel extends mxEventSource {
return null;
}
- /**
- * Returns an array of clones for the given array of {@link mxCell}`.
- * Depending on the value of includeChildren, a deep clone is created for
- * each cell. Connections are restored based if the corresponding
- * cell is contained in the passed in array.
- *
- * @param cells Array of {@link mxCell}` to be cloned.
- * @param includeChildren Boolean indicating if the cells should be cloned
- * with all descendants.
- * @param mapping Optional mapping for existing clones.
- */
- // cloneCells(cells: Array, includeChildren?: boolean, mapping?: any): Array;
cloneCells(cells: mxCell[],
includeChildren: boolean=true,
mapping: any={}): mxCell[] {
-
- const clones: mxCell[] = [];
-
- for (let i = 0; i < cells.length; i += 1) {
- clones.push(this.cloneCellImpl(cells[i], mapping, includeChildren));
- }
-
- for (let i = 0; i < clones.length; i += 1) {
- if (clones[i] != null) {
- this.restoreClone(clones[i], cells[i], mapping);
- }
- }
- return clones;
- }
-
- /**
- * Inner helper method for cloning cells recursively.
- */
- // cloneCellImpl(cell: mxCell, mapping?: any, includeChildren?: boolean): mxCell;
- cloneCellImpl(cell: mxCell,
- mapping: any={},
- includeChildren: boolean): mxCell {
-
- const ident = mxObjectIdentity.get(cell);
- let clone = mapping ? mapping[ident] : null;
-
- if (clone == null) {
- clone = cell.clone();
- mapping[ident] = clone;
-
- if (includeChildren) {
- const childCount = cell.getChildCount();
-
- for (let i = 0; i < childCount; i += 1) {
- const cloneChild = this.cloneCellImpl(
- cell.getChildAt(i),
- mapping,
- true
- );
- clone.insert(cloneChild);
- }
- }
- }
- return clone;
+ // SLATED FOR DELETION
+ return new mxCells(...cells).cloneCells(includeChildren, mapping)
}
/**
@@ -1931,42 +1539,6 @@ class mxGraphModel extends mxEventSource {
// SLATED FOR DELETION
return cell.clone();
}
-
- /**
- * Inner helper method for restoring the connections in
- * a network of cloned cells.
- */
- // restoreClone(clone: mxCell, cell: mxCell, mapping?: any): void;
- restoreClone(clone: mxCell,
- cell: mxCell,
- mapping: any): void {
-
- const source = cell.getTerminal(true);
-
- if (source != null) {
- const tmp = mapping[mxObjectIdentity.get(source)];
- if (tmp != null) {
- tmp.insertEdge(clone, true);
- }
- }
-
- const target = cell.getTerminal(false);
- if (target != null) {
- const tmp = mapping[mxObjectIdentity.get(target)];
- if (tmp != null) {
- tmp.insertEdge(clone, false);
- }
- }
-
- const childCount = clone.getChildCount();
- for (let i = 0; i < childCount; i += 1) {
- this.restoreClone(
- clone.getChildAt(i),
- cell.getChildAt(i),
- mapping
- );
- }
- }
}
//
diff --git a/packages/core/src/view/graph/mxGraphView.ts b/packages/core/src/view/graph/mxGraphView.ts
index f3ddb5b07..7e47a05a2 100644
--- a/packages/core/src/view/graph/mxGraphView.ts
+++ b/packages/core/src/view/graph/mxGraphView.ts
@@ -859,7 +859,7 @@ class mxGraphView extends mxEventSource {
this.validateCell(
cell.getChildAt(i),
visible &&
- (!this.isCellCollapsed(cell) || cell === this.currentRoot)
+ (!cell.isCollapsed() || cell === this.currentRoot)
);
}
}
@@ -965,7 +965,7 @@ class mxGraphView extends mxEventSource {
origin.y += offset.y;
}
- const geo = (this.graph).getCellGeometry(state.cell);
+ const geo = (state.cell).getGeometry();
if (geo != null) {
if (!state.cell.isEdge()) {
@@ -1020,7 +1020,8 @@ class mxGraphView extends mxEventSource {
*/
// isCellCollapsed(cell: mxCell): boolean;
isCellCollapsed(cell: mxCell): boolean {
- return (this.graph).isCellCollapsed(cell);
+ // SLATED FOR DELETION
+ return cell.isCollapsed();
}
/**
@@ -1293,7 +1294,7 @@ class mxGraphView extends mxEventSource {
const s = this.scale;
const tr = this.translate;
const orig = edge.origin;
- const geo = (this.graph).getCellGeometry(edge.cell);
+ const geo = (edge.cell).getGeometry();
pt = geo.getTerminalPoint(source);
if (pt != null) {
@@ -1837,7 +1838,7 @@ class mxGraphView extends mxEventSource {
let best = result;
while (result != null && result != this.currentRoot) {
- if ((best && !best.isVisible()) || this.isCellCollapsed(result)) {
+ if ((best && !best.isVisible()) || result.isCollapsed()) {
best = result;
}
@@ -2107,7 +2108,7 @@ class mxGraphView extends mxEventSource {
absoluteOffset.y = state.getCenterY();
if (points != null && points.length > 0 && state.segments != null) {
- const geometry = (this.graph).getCellGeometry(state.cell);
+ const geometry = (state.cell).getGeometry();
if (geometry.relative) {
const offset = this.getPoint(state, geometry);
diff --git a/packages/html/stories/Boundary.stories.js b/packages/html/stories/Boundary.stories.js
index 221cc8c54..73d555c36 100644
--- a/packages/html/stories/Boundary.stories.js
+++ b/packages/html/stories/Boundary.stories.js
@@ -22,12 +22,9 @@ const Template = ({ label, ...args }) => {
mxGraph,
mxEvent,
mxRubberband,
- mxConnectionHandler,
- mxConnectionConstraint,
- mxGeometry,
- mxPolyline,
mxPoint,
- mxConstants
+ mxConstants,
+ mxUtils
} = mxgraph;
const container = document.createElement('div');
diff --git a/packages/html/stories/Constituent.stories.js b/packages/html/stories/Constituent.stories.js
index 06bc306dd..f753b9dc4 100644
--- a/packages/html/stories/Constituent.stories.js
+++ b/packages/html/stories/Constituent.stories.js
@@ -43,7 +43,7 @@ const Template = ({ label, ...args }) => {
getInitialCellForEvent(me) {
let cell = super.getInitialCellForEvent(me);
if (this.graph.isPart(cell)) {
- cell = this.cell.getParent();
+ cell = cell.getParent();
}
return cell;
}
diff --git a/packages/html/stories/DynamicLoading.stories.js b/packages/html/stories/DynamicLoading.stories.js
index bd20e8631..f67d1d9d6 100644
--- a/packages/html/stories/DynamicLoading.stories.js
+++ b/packages/html/stories/DynamicLoading.stories.js
@@ -13,6 +13,7 @@ const Template = ({ label, ...args }) => {
const {
mxGraph,
mxText,
+ mxEffects,
mxEvent,
mxConstants,
mxPerimeter,
@@ -108,7 +109,7 @@ const Template = ({ label, ...args }) => {
}
// Merges the response model with the client model
- graph.getModel().mergeChildren(model.getRoot().getChildAt(0), parent);
+ graph.getModel().mergeChildren(graph.getModel().getRoot().getChildAt(0), parent);
// Moves the given cell to the center
let geo = cell.getGeometry();
diff --git a/packages/html/stories/Groups.stories.js b/packages/html/stories/Groups.stories.js
index 8cadac301..31bc83b27 100644
--- a/packages/html/stories/Groups.stories.js
+++ b/packages/html/stories/Groups.stories.js
@@ -64,7 +64,7 @@ const Template = ({ label, ...args }) => {
!this.graph.isValidRoot(parent)
) {
cell = parent;
- parent = this.cell.getParent();
+ parent = cell.getParent();
}
}
diff --git a/packages/html/stories/JsonData.stories.js b/packages/html/stories/JsonData.stories.js
index bea764e75..5ff3498dc 100644
--- a/packages/html/stories/JsonData.stories.js
+++ b/packages/html/stories/JsonData.stories.js
@@ -1,4 +1,5 @@
import mxgraph from '@mxgraph/core';
+import { popup } from '@mxgraph/core/src/util/gui/mxWindow';
import { globalTypes } from '../.storybook/preview';
@@ -89,7 +90,7 @@ const Template = ({ label, ...args }) => {
mxDomHelpers.button('Show JSON', function() {
const encoder = new mxCodec();
const node = encoder.encode(graph.getModel());
- mxWindow.popup(mxUtils.getXml(node), true);
+ popup(mxUtils.getXml(node), true);
})
);
diff --git a/packages/html/stories/LoD.stories.js b/packages/html/stories/LoD.stories.js
index b551d3a00..e4f1d17cd 100644
--- a/packages/html/stories/LoD.stories.js
+++ b/packages/html/stories/LoD.stories.js
@@ -31,8 +31,8 @@ const Template = ({ label, ...args }) => {
graph.centerZoom = false;
// Links level of detail to zoom level but can be independent of zoom
- const isVisible = function(cell) {
- return cell.lod == null || cell.lod / 2 < this.view.scale;
+ const isVisible = function() {
+ return this.lod == null || this.lod / 2 < graph.view.scale;
};
// Gets the default parent for inserting new cells. This
diff --git a/packages/html/stories/PageBreaks.stories.js b/packages/html/stories/PageBreaks.stories.js
index 23d0081f5..613a3e741 100644
--- a/packages/html/stories/PageBreaks.stories.js
+++ b/packages/html/stories/PageBreaks.stories.js
@@ -20,6 +20,7 @@ export default {
const Template = ({ label, ...args }) => {
const {
mxGraph,
+ mxRectangle,
mxRubberband,
mxDomHelpers,
mxEvent
diff --git a/packages/html/stories/Stencils.stories.js b/packages/html/stories/Stencils.stories.js
index acf4cb810..a5b1730dd 100644
--- a/packages/html/stories/Stencils.stories.js
+++ b/packages/html/stories/Stencils.stories.js
@@ -1,4 +1,5 @@
import mxgraph from '@mxgraph/core';
+import { load } from "@mxgraph/core/src/util/network/mxXmlRequest";
import { globalTypes } from '../.storybook/preview';
@@ -23,11 +24,15 @@ const Template = ({ label, ...args }) => {
mxConnectionHandler,
mxDomHelpers,
mxEdgeHandler,
+ mxEvent,
mxPoint,
mxCellHighlight,
mxConstants,
mxVertexHandler,
+ mxRubberband,
mxShape,
+ mxStencil,
+ mxStencilRegistry,
mxCellRenderer,
mxUtils
} = mxgraph;
@@ -120,7 +125,7 @@ const Template = ({ label, ...args }) => {
mxCellRenderer.registerShape('customShape', CustomShape);
// Loads the stencils into the registry
- const req = mxUtils.load('stencils.xml');
+ const req = load('stencils.xml');
const root = req.getDocumentElement();
let shape = root.firstChild;
diff --git a/packages/html/stories/SwimLanes.stories.js b/packages/html/stories/SwimLanes.stories.js
index 6b3f46d2d..a68d4a825 100644
--- a/packages/html/stories/SwimLanes.stories.js
+++ b/packages/html/stories/SwimLanes.stories.js
@@ -224,7 +224,7 @@ const Template = ({ label, ...args }) => {
// TODO super cannot be used here
// let style = super.getStyle();
let style;
- if (this.isCellCollapsed()) {
+ if (this.isCollapsed()) {
if (style != null) {
style += ';';
} else {
@@ -286,7 +286,7 @@ const Template = ({ label, ...args }) => {
};
// Adds cells to the model in a single step
- model.batchUpdate(() => {
+ graph.batchUpdate(() => {
const pool1 = insertVertex({
parent,
value: 'Pool 1',
diff --git a/packages/html/stories/UserObject.stories.js b/packages/html/stories/UserObject.stories.js
index 9a0aadbbc..c92954b5a 100644
--- a/packages/html/stories/UserObject.stories.js
+++ b/packages/html/stories/UserObject.stories.js
@@ -1,4 +1,5 @@
import mxgraph from '@mxgraph/core';
+import { popup } from '@mxgraph/core/src/util/gui/mxWindow';
import { globalTypes } from '../.storybook/preview';
@@ -168,7 +169,7 @@ const Template = ({ label, ...args }) => {
mxDomHelpers.button('View XML', function() {
const encoder = new mxCodec();
const node = encoder.encode(graph.getModel());
- mxWindow.popup(mxUtils.getPrettyXml(node), true);
+ popup(mxUtils.getPrettyXml(node), true);
})
);