Merge pull request #24 from mcyph/master

Made calls go directly to mxCell rather than through mxGraphModel in many cases
development
Junsik Shim 2021-04-24 21:26:03 +09:00 committed by GitHub
commit def8468d64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
83 changed files with 1542 additions and 1496 deletions

View File

@ -201,7 +201,7 @@ export default Ports;
cell != null &&
this.isCellEditable(cell))
{
if (this.model.isEdge(cell) ||
if (cell.isEdge() ||
!this.isHtmlLabel(cell))
{
this.startEditingAtCell(cell);

View File

@ -158,13 +158,13 @@ export default MYNAMEHERE;
graph.isHtmlLabel = function(cell)
{
return !this.isSwimlane(cell) &&
!this.model.isEdge(cell);
!cell.isEdge();
};
// Edges are not editable
graph.isCellEditable = function(cell)
{
return !this.model.isEdge(cell);
return !cell.isEdge();
};
// Returns the name field of the user object for the label
@ -185,10 +185,10 @@ export default MYNAMEHERE;
{
return 'Type: '+state.cell.value.type;
}
else if (this.model.isEdge(state.cell))
else if (state.cell.isEdge())
{
let source = this.model.getTerminal(state.cell, true);
let parent = this.model.getParent(source);
let source = state.cell.getTerminal(true);
let parent = source.getParent();
return parent.value.name+'.'+source.value.name;
}
@ -241,10 +241,10 @@ export default MYNAMEHERE;
{
let cell = cells[i];
if (this.model.isEdge(cell))
if (cell.isEdge())
{
let terminal = this.model.getTerminal(cell, true);
let parent = this.model.getParent(terminal);
let terminal = cell.getTerminal(true);
let parent = terminal.getParent();
this.model.remove(terminal);
}
}
@ -296,11 +296,11 @@ export default MYNAMEHERE;
{
// Finds the primary key child of the target table
let primaryKey = null;
let childCount = this.model.getChildCount(target);
let childCount = target.getChildCount();
for (var i=0; i < childCount; i++)
{
let child = this.model.getChildAt(target, i);
let child = target.getChildAt(i);
if (child.value.primaryKey)
{
@ -557,17 +557,17 @@ export default MYNAMEHERE;
pt.x -= pstate.x;
pt.y -= pstate.y;
let columnCount = graph.model.getChildCount(parent)+1;
let columnCount = parent.getChildCount()+1;
name = mxUtils.prompt('Enter name for new column', 'COLUMN'+columnCount);
}
else
{
let tableCount = 0;
let childCount = graph.model.getChildCount(parent);
let childCount = parent.getChildCount();
for (var i=0; i<childCount; i++)
{
if (!graph.model.isEdge(graph.model.getChildAt(parent, i)))
if (!parent.getChildAt(i).isEdge())
{
tableCount++;
}
@ -634,7 +634,7 @@ export default MYNAMEHERE;
}
else
{
let parent = graph.getModel().getParent(cell);
let parent = cell.getParent();
if (graph.isSwimlane(parent))
{
@ -786,7 +786,7 @@ export default MYNAMEHERE;
}
form.addButtons(okFunction, cancelFunction);
let parent = graph.model.getParent(cell);
let parent = cell.getParent();
let name = parent.value.name + '.' + cell.value.name;
wnd = showModalWindow(name, form.table, 240, 240);
};
@ -795,23 +795,23 @@ export default MYNAMEHERE;
{
let sql = [];
let parent = graph.getDefaultParent();
let childCount = graph.model.getChildCount(parent);
let childCount = parent.getChildCount();
for (var i=0; i<childCount; i++)
{
let child = graph.model.getChildAt(parent, i);
let child = parent.getChildAt(i);
if (!graph.model.isEdge(child))
if (!child.isEdge())
{
sql.push('CREATE TABLE IF NOT EXISTS '+child.value.name+' (');
let columnCount = graph.model.getChildCount(child);
let columnCount = child.getChildCount();
if (columnCount > 0)
{
for (var j=0; j<columnCount; j++)
{
let column = graph.model.getChildAt(child, j).value;
let column = child.getChildAt(j).value;
sql.push('\n '+column.name+' '+column.type);

View File

@ -199,7 +199,7 @@ export default Scrollbars;
// Override folding to allow for tables
graph.isCellFoldable = function(cell, collapse)
{
return this.getModel().isVertex(cell);
return cell.isVertex();
};
// Overrides connectable state
@ -229,7 +229,7 @@ export default Scrollbars;
let graph = state.view.graph;
let model = graph.model;
if (model.isVertex(state.cell) && state.text != null)
if (state.cell.isVertex() && state.text != null)
{
// Scrollbars are on the div
let s = graph.view.scale;
@ -244,13 +244,13 @@ export default Scrollbars;
let updateEdges = mxUtils.bind(this, function()
{
let edgeCount = model.getEdgeCount(state.cell);
let edgeCount = state.cell.getEdgeCount();
// Only updates edges to avoid update in DOM order
// for text label which would reset the scrollbar
for (let i = 0; i < edgeCount; i++)
{
let edge = model.getEdgeAt(state.cell, i);
let edge = state.cell.getEdgeAt(i);
graph.view.invalidate(edge, true, false);
graph.view.validate(edge);
}
@ -357,7 +357,7 @@ export default Scrollbars;
let edge = this.createEdge(relation);
let style = this.graph.getCellStyle(edge);
let state = new mxCellState(this.graph.view, edge, style);
let state = new mxCell(this.graph.view, edge, style);
// Stores the source row in the handler
this.sourceRowNode = this.currentRowNode;
@ -369,7 +369,7 @@ export default Scrollbars;
// short markup for collapsed cells.
graph.getLabel = function(cell)
{
if (this.getModel().isVertex(cell))
if (cell.isVertex())
{
if (this.isCellCollapsed(cell))
{

View File

@ -113,7 +113,7 @@ Actions.prototype.init = function()
for (let i = 0; i < cells.length && includeEdges; i++)
{
includeEdges = includeEdges && graph.model.isEdge(cells[i]);
includeEdges = includeEdges && cells[i].isEdge();
}
let t = graph.view.translate;
@ -154,7 +154,7 @@ Actions.prototype.init = function()
{
let cell = graph.getSelectionCell();
if (graph.isEnabled() && cell != null && graph.getModel().isVertex(cell))
if (graph.isEnabled() && cell != null && cell.isVertex())
{
let geo = graph.getCellGeometry(cell);
@ -177,7 +177,7 @@ Actions.prototype.init = function()
for (let i = 0; i < cells.length; i++)
{
if (graph.getModel().isVertex(cells[i]))
if (cells[i].isVertex())
{
let geo = graph.getCellGeometry(cells[i]);
@ -346,8 +346,8 @@ Actions.prototype.init = function()
{
if (graph.model.contains(cells[i]))
{
if (graph.model.getChildCount(cells[i]) == 0 &&
graph.model.isVertex(cells[i]))
if (cells[i].getChildCount() == 0 &&
cells[i].isVertex())
{
graph.setCellStyles('container', '0', [cells[i]]);
}
@ -592,7 +592,7 @@ Actions.prototype.init = function()
{
let cell = cells[i];
if (graph.getModel().getChildCount(cell))
if (cell.getChildCount())
{
graph.updateGroupBounds([cell], 20);
}
@ -601,7 +601,7 @@ Actions.prototype.init = function()
let state = graph.view.getState(cell);
let geo = graph.getCellGeometry(cell);
if (graph.getModel().isVertex(cell) && state != null && state.text != null &&
if (cell.isVertex() && state != null && state.text != null &&
geo != null && graph.isWrapping(cell))
{
geo = geo.clone();
@ -1046,7 +1046,7 @@ Actions.prototype.init = function()
for (let i = 0; i < cells.length; i++)
{
if (graph.model.getChildCount(cells[i]) == 0)
if (cells[i].getChildCount() == 0)
{
graph.autoSizeCell(cells[i], false);
}
@ -1210,7 +1210,7 @@ Actions.prototype.init = function()
let model = graph.getModel();
let dlg = new TextareaDialog(this.editorUi, mxResources.get('editStyle') + ':',
model.getStyle(cells[0]) || '', function(newValue)
cells[0].getStyle() || '', function(newValue)
{
if (newValue != null)
{
@ -1239,7 +1239,7 @@ Actions.prototype.init = function()
{
let cell = graph.getSelectionCell();
if (cell != null && graph.getModel().isEdge(cell))
if (cell != null && cell.isEdge())
{
let handler = editor.graph.selectionCellsHandler.getHandler(cell);
@ -1250,15 +1250,15 @@ Actions.prototype.init = function()
let dx = t.x;
let dy = t.y;
let parent = graph.getModel().getParent(cell);
let parent = cell.getParent();
let pgeo = graph.getCellGeometry(parent);
while (graph.getModel().isVertex(parent) && pgeo != null)
while (parent.isVertex() && pgeo != null)
{
dx += pgeo.x;
dy += pgeo.y;
parent = graph.getModel().getParent(parent);
parent = parent.getParent();
pgeo = graph.getCellGeometry(parent);
}
@ -1295,7 +1295,7 @@ Actions.prototype.init = function()
{
let cell = cells[i];
if (graph.getModel().isEdge(cell))
if (cell.isEdge())
{
let geo = graph.getCellGeometry(cell);
@ -1403,7 +1403,7 @@ Actions.prototype.init = function()
if (w != null && h != null)
{
let cell = cells[0];
let geo = graph.getModel().getGeometry(cell);
let geo = cell.getGeometry();
if (geo != null)
{

View File

@ -651,7 +651,7 @@ let EditDiagramDialog = function(editorUi)
let codec = new mxCodec(doc);
codec.decode(doc.documentElement, model);
let children = model.getChildren(model.getChildAt(model.getRoot(), 0));
let children = model.getRoot().getChildAt(0).getChildren();
editorUi.editor.graph.setSelectionCells(editorUi.editor.graph.importCells(children));
// LATER: Why is hideDialog between begin-/endUpdate faster?
@ -1262,7 +1262,7 @@ let EditDataDialog = function(ui, cell)
let div = document.createElement('div');
let graph = ui.editor.graph;
let value = graph.getModel().getValue(cell);
let value = cell.getValue();
// Converts the value to an XML node
if (!mxUtils.isNode(value))
@ -1378,7 +1378,7 @@ let EditDataDialog = function(ui, cell)
};
let temp = [];
let isLayer = graph.getModel().getParent(cell) == graph.getModel().getRoot();
let isLayer = cell.getParent() == graph.getModel().getRoot();
for (let i = 0; i < attrs.length; i++)
{
@ -1584,7 +1584,7 @@ let EditDataDialog = function(ui, cell)
let buttons = document.createElement('div');
buttons.style.cssText = 'position:absolute;left:30px;right:30px;text-align:right;bottom:30px;height:40px;'
if (ui.editor.graph.getModel().isVertex(cell) || ui.editor.graph.getModel().isEdge(cell))
if (cell.isVertex() || cell.isEdge())
{
let replace = document.createElement('span');
replace.style.marginRight = '10px';
@ -1660,7 +1660,7 @@ EditDataDialog.getDisplayIdForCell = function(ui, cell)
{
let id = null;
if (ui.editor.graph.getModel().getParent(cell) != null)
if (ui.editor.cell.getParent() != null)
{
id = cell.getId();
}
@ -2028,14 +2028,14 @@ let LayersWindow = function(editorUi, x, y, w, h)
graph.removeCells([selectionLayer], false);
// Creates default layer if no layer exists
if (graph.model.getChildCount(graph.model.root) == 0)
if (graph.model.root.getChildCount() == 0)
{
graph.model.add(graph.model.root, new mxCell());
graph.setDefaultParent(null);
}
else if (index > 0 && index <= graph.model.getChildCount(graph.model.root))
else if (index > 0 && index <= graph.model.root.getChildCount())
{
graph.setDefaultParent(graph.model.getChildAt(graph.model.root, index - 1));
graph.setDefaultParent(graph.model.root.getChildAt(index - 1));
}
else
{
@ -2085,7 +2085,7 @@ let LayersWindow = function(editorUi, x, y, w, h)
menu.addCheckmark(item, Editor.checkmarkImage);
}
}))(graph.model.getChildAt(graph.model.root, i));
}))(graph.model.root.getChildAt(i));
}
}), offset.x, offset.y + insertLink.offsetHeight, evt);
}
@ -2201,7 +2201,7 @@ let LayersWindow = function(editorUi, x, y, w, h)
function refresh()
{
layerCount = graph.model.getChildCount(graph.model.root)
layerCount = graph.model.root.getChildCount()
listDiv.innerHTML = '';
function addLayer(index, label, child, defaultParent)
@ -2319,7 +2319,7 @@ let LayersWindow = function(editorUi, x, y, w, h)
inp.style.marginTop = '4px';
left.appendChild(inp);
if (graph.model.isVisible(child))
if (child.isVisible())
{
inp.setAttribute('checked', 'checked');
inp.defaultChecked = true;
@ -2327,7 +2327,7 @@ let LayersWindow = function(editorUi, x, y, w, h)
mxEvent.addListener(inp, 'click', function(evt)
{
graph.model.setVisible(child, !graph.model.isVisible(child));
graph.model.setVisible(child, !child.isVisible());
mxEvent.consume(evt);
});
@ -2451,7 +2451,7 @@ let LayersWindow = function(editorUi, x, y, w, h)
{
addLayer(i, graph.convertValueToString(child) ||
mxResources.get('background'), child, child);
}))(graph.model.getChildAt(graph.model.root, i));
}))(graph.model.root.getChildAt(i));
}
let label = graph.convertValueToString(selectionLayer) || mxResources.get('background');

View File

@ -2576,7 +2576,7 @@ FilenameDialog.createFileTypes = function(editorUi, nameInput, types)
{
return false;
}
else if (this.graph.getModel().isVertex(cells[i]))
else if (cells[i].isVertex())
{
let geo = this.graph.getCellGeometry(cells[i]);
@ -2686,14 +2686,14 @@ FilenameDialog.createFileTypes = function(editorUi, nameInput, types)
mxGraphHandler.prototype.isPropagateSelectionCell = function(cell, immediate, me)
{
let result = false;
let parent = this.graph.model.getParent(cell)
let parent = cell.getParent()
if (immediate)
{
let geo = (this.graph.model.isEdge(cell)) ? null :
let geo = (cell.isEdge()) ? null :
this.graph.getCellGeometry(cell);
result = !this.graph.model.isEdge(parent) &&
result = !parent.isEdge() &&
!this.graph.isSiblingSelected(cell) &&
((geo != null && geo.relative) ||
!this.graph.isContainer(parent) ||
@ -2709,7 +2709,7 @@ FilenameDialog.createFileTypes = function(editorUi, nameInput, types)
if (!this.graph.isTable(table))
{
table = this.graph.model.getParent(table);
table = table.getParent();
}
result = !this.graph.selectionCellsHandler.isHandled(table) ||
@ -2729,11 +2729,11 @@ FilenameDialog.createFileTypes = function(editorUi, nameInput, types)
{
let cell = me.getCell();
let model = this.graph.getModel();
let parent = model.getParent(cell);
let parent = cell.getParent();
let state = this.graph.view.getState(parent);
let selected = this.graph.isCellSelected(cell);
while (state != null && (model.isVertex(parent) || model.isEdge(parent)))
while (state != null && (parent.isVertex() || parent.isEdge()))
{
let temp = this.graph.isCellSelected(parent);
selected = selected || temp;
@ -2744,7 +2744,7 @@ FilenameDialog.createFileTypes = function(editorUi, nameInput, types)
cell = parent;
}
parent = model.getParent(parent);
parent = parent.getParent();
}
return cell;

View File

@ -458,7 +458,7 @@ EditorUi = function(editor, container, lightbox)
}
// Handles special case for value "none"
let cellStyle = graph.getModel().getStyle(state.cell);
let cellStyle = state.cell ? state.cell.getStyle() : null;
let tokens = (cellStyle != null) ? cellStyle.split(';') : [];
for (let i = 0; i < tokens.length; i++)
@ -480,7 +480,7 @@ EditorUi = function(editor, container, lightbox)
}
// Resets current style
if (graph.getModel().isEdge(state.cell))
if (state.cell.isEdge())
{
graph.currentEdgeStyle = {};
}
@ -564,7 +564,7 @@ EditorUi = function(editor, container, lightbox)
else
{
// Removes styles defined in the cell style from the styles to be applied
let cellStyle = model.getStyle(cell);
let cellStyle = cell.getStyle();
let tokens = (cellStyle != null) ? cellStyle.split(';') : [];
appliedStyles = styles.slice();
@ -606,9 +606,9 @@ EditorUi = function(editor, container, lightbox)
}
// Applies the current style to the cell
let edge = model.isEdge(cell);
let edge = cell.isEdge();
let current = (edge) ? graph.currentEdgeStyle : graph.currentVertexStyle;
let newStyle = model.getStyle(cell);
let newStyle = cell.getStyle();
for (let j = 0; j < appliedStyles.length; j++)
{
@ -669,8 +669,8 @@ EditorUi = function(editor, container, lightbox)
{
for (let i = 0; i < cells.length; i++)
{
vertex = graph.getModel().isVertex(cells[i]) || vertex;
edge = graph.getModel().isEdge(cells[i]) || edge;
vertex = cells[i].isVertex() || vertex;
edge = cells[i].isEdge() || edge;
if (edge && vertex)
{
@ -868,7 +868,7 @@ EditorUi = function(editor, container, lightbox)
let cells = evt.getProperty('cells');
let parent = evt.getProperty('parent');
if (graph.getModel().isLayer(parent) && !graph.isCellVisible(parent) && cells != null && cells.length > 0)
if (graph.getModel().isLayer(parent) && !parent.isVisible() && cells != null && cells.length > 0)
{
graph.getModel().setVisible(parent, true);
}
@ -1210,7 +1210,7 @@ EditorUi.prototype.installShapePicker = function()
while (temp != null && graph.model.isVertex(temp) && geo != null && geo.relative)
{
cell = temp;
temp = graph.model.getParent(cell)
temp = cell.getParent()
geo = graph.getCellGeometry(temp);
}
@ -1634,7 +1634,7 @@ EditorUi.prototype.initClipboard = function()
// to avoid having to carry over the mapping from object
// ID to cell ID to the paste operation
let model = new mxGraphModel();
let parent = model.getChildAt(model.getRoot(), 0);
let parent = model.getRoot().getChildAt(0);
for (let i = 0; i < clones.length; i++)
{
@ -1647,8 +1647,8 @@ EditorUi.prototype.initClipboard = function()
{
let geo = graph.getCellGeometry(clones[i]);
if (geo != null && geo.relative && !model.isEdge(result[i]) &&
lookup[mxObjectIdentity.get(model.getParent(result[i]))] == null)
if (geo != null && geo.relative && !result[i].isEdge() &&
lookup[mxObjectIdentity.get(result[i].getParent())] == null)
{
geo.offset = null;
geo.relative = false;
@ -2120,7 +2120,7 @@ EditorUi.prototype.initCanvas = function()
model.addListener(mxEvent.CHANGE, function()
{
layersButton.style.display = (model.getChildCount(model.root) > 1) ? '' : 'none';
layersButton.style.display = (model.root.getChildCount() > 1) ? '' : 'none';
});
}
@ -2798,7 +2798,7 @@ EditorUi.prototype.isDiagramEmpty = function()
{
let model = this.editor.graph.getModel();
return model.getChildCount(model.root) == 1 && model.getChildCount(model.getChildAt(model.root, 0)) == 0;
return model.getChildCount(model.root) == 1 && model.root.getChildAt(0).getChildCount() == 0;
};
/**
@ -3475,16 +3475,16 @@ EditorUi.prototype.updateActionStates = function()
{
let cell = cells[i];
if (graph.getModel().isEdge(cell))
if (cell.isEdge())
{
edgeSelected = true;
}
if (graph.getModel().isVertex(cell))
if (cell.isVertex())
{
vertexSelected = true;
if (graph.getModel().getChildCount(cell) > 0 ||
if (cell.getChildCount() > 0 ||
graph.isContainer(cell))
{
groupSelected = true;
@ -3523,13 +3523,13 @@ EditorUi.prototype.updateActionStates = function()
(oneVertexSelected && !graph.isContainer(graph.getSelectionCell())));
this.actions.get('ungroup').setEnabled(groupSelected);
this.actions.get('removeFromGroup').setEnabled(oneVertexSelected &&
graph.getModel().isVertex(graph.getModel().getParent(graph.getSelectionCell())));
graph.getSelectionCell().getParent().isVertex());
// Updates menu states
let state = graph.view.getState(graph.getSelectionCell());
this.menus.get('navigation').setEnabled(selected || graph.view.currentRoot != null);
this.actions.get('collapsible').setEnabled(vertexSelected &&
(graph.isContainer(graph.getSelectionCell()) || graph.model.getChildCount(graph.getSelectionCell()) > 0));
(graph.isContainer(graph.getSelectionCell()) || graph.getSelectionCell().getChildCount() > 0));
this.actions.get('home').setEnabled(graph.view.currentRoot != null);
this.actions.get('exitGroup').setEnabled(graph.view.currentRoot != null);
this.actions.get('enterGroup').setEnabled(graph.getSelectionCount() == 1 && graph.isValidRoot(graph.getSelectionCell()));
@ -4106,7 +4106,7 @@ EditorUi.prototype.ctrlEnter = function()
for (let i = 0; i < cells.length; i++)
{
// Clones table rows instead of cells
let cell = (graph.isTableCell(cells[i])) ? graph.model.getParent(cells[i]) : cells[i];
let cell = (graph.isTableCell(cells[i])) ? cells[i].getParent() : cells[i];
if (cell != null && !lookup.get(cell))
{
@ -4593,7 +4593,7 @@ EditorUi.prototype.createKeyHandler = function(editor)
for (let i = 0; i < cells.length; i++)
{
if (graph.getModel().isVertex(cells[i]) && graph.isCellResizable(cells[i]))
if (cells[i].isVertex() && graph.isCellResizable(cells[i]))
{
let geo = graph.getCellGeometry(cells[i]);
@ -4632,7 +4632,7 @@ EditorUi.prototype.createKeyHandler = function(editor)
{
// Moves vertices up/down in a stack layout
let cell = graph.getSelectionCell();
let parent = graph.model.getParent(cell);
let parent = cell.getParent();
let layout = null;
if (graph.getSelectionCount() == 1 && graph.model.isVertex(cell) &&
@ -4651,7 +4651,7 @@ EditorUi.prototype.createKeyHandler = function(editor)
}
else if (keyCode == 39 ||keyCode == 40)
{
graph.model.add(parent, cell, Math.min(graph.model.getChildCount(parent), index + 1));
graph.model.add(parent, cell, Math.min(parent.getChildCount(), index + 1));
}
}
else
@ -4666,7 +4666,7 @@ EditorUi.prototype.createKeyHandler = function(editor)
if (mxUtils.getValue(style, 'part', '0') == '1')
{
let parent = graph.model.getParent(cells[i]);
let parent = cells[i].getParent();
if (graph.model.isVertex(parent) && mxUtils.indexOf(cells, parent) < 0)
{
@ -4790,7 +4790,7 @@ EditorUi.prototype.createKeyHandler = function(editor)
// On macOS, Control+Cursor is used by Expose so allow for Alt+Control to resize
if (!this.isControlDown(evt) && mxEvent.isShiftDown(evt) && mxEvent.isAltDown(evt))
{
if (graph.model.isVertex(graph.getSelectionCell()))
if (graph.getSelectionCell() && graph.getSelectionCell().isVertex())
{
return function()
{
@ -4799,9 +4799,9 @@ EditorUi.prototype.createKeyHandler = function(editor)
if (cells != null && cells.length > 0)
{
if (cells.length == 1 && graph.model.isEdge(cells[0]))
if (cells.length == 1 && cells[0].isEdge())
{
graph.setSelectionCell(graph.model.getTerminal(cells[0], false));
graph.setSelectionCell(cells[0].getTerminal(false));
}
else
{

View File

@ -132,7 +132,7 @@ Format.prototype.updateSelectionStateForCell = function(result, cell, cells)
{
let graph = this.editorUi.editor.graph;
if (graph.getModel().isVertex(cell))
if (cell.isVertex())
{
result.resizable = result.resizable && graph.isCellResizable(cell);
result.rotatable = result.rotatable && graph.isCellRotatable(cell);
@ -203,7 +203,7 @@ Format.prototype.updateSelectionStateForCell = function(result, cell, cells)
}
}
}
else if (graph.getModel().isEdge(cell))
else if (cell.isEdge())
{
result.edges.push(cell);
result.resizable = false;
@ -252,7 +252,7 @@ Format.prototype.updateSelectionStateForCell = function(result, cell, cells)
Format.prototype.isFillState = function(state)
{
return !this.isSpecialColor(state.style[mxConstants.STYLE_FILLCOLOR]) &&
(state.view.graph.model.isVertex(state.cell) ||
(state.cell.isVertex() ||
mxUtils.getValue(state.style, mxConstants.STYLE_SHAPE, null) == 'arrow' ||
mxUtils.getValue(state.style, mxConstants.STYLE_SHAPE, null) == 'filledEdge' ||
mxUtils.getValue(state.style, mxConstants.STYLE_SHAPE, null) == 'flexArrow');
@ -723,7 +723,7 @@ BaseFormatPanel.prototype.installInputHandler = function(input, key, defaultValu
for (let i = 0; i < cells.length; i++)
{
if (graph.model.getChildCount(cells[i]) == 0)
if (cells[i].getChildCount() == 0)
{
graph.autoSizeCell(cells[i], false);
}
@ -1745,8 +1745,8 @@ ArrangePanel.prototype.addGroupOps = function(div)
div.appendChild(btn);
count++;
}
else if (graph.getSelectionCount() == 1 && !graph.getModel().isEdge(cell) && !graph.isSwimlane(cell) &&
!graph.isTable(cell) && !ss.row && !ss.cell && graph.getModel().getChildCount(cell) > 0)
else if (graph.getSelectionCount() == 1 && !cell.isEdge() && !graph.isSwimlane(cell) &&
!graph.isTable(cell) && !ss.row && !ss.cell && cell.getChildCount() > 0)
{
btn = mxUtils.button(mxResources.get('ungroup'), function(evt)
{
@ -1802,8 +1802,8 @@ ArrangePanel.prototype.addGroupOps = function(div)
}
}
if (graph.getSelectionCount() == 1 && graph.getModel().isVertex(cell) && !ss.row &&
!ss.cell && graph.getModel().isVertex(graph.getModel().getParent(cell)))
if (graph.getSelectionCount() == 1 && cell.isVertex() && !ss.row &&
!ss.cell && cell.getParent().isVertex())
{
if (count > 0)
{
@ -2257,7 +2257,7 @@ ArrangePanel.prototype.addGeometry = function(container)
{
if (graph.isTableCell(cell))
{
cell = graph.model.getParent(cell);
cell = cell.getParent();
}
if (graph.isTableRow(cell))
@ -2424,7 +2424,7 @@ ArrangePanel.prototype.addGeometryHandler = function(input, fn)
for (let i = 0; i < cells.length; i++)
{
if (graph.getModel().isVertex(cells[i]))
if (cells[i].isVertex())
{
let geo = graph.getCellGeometry(cells[i]);
@ -2496,7 +2496,7 @@ ArrangePanel.prototype.addEdgeGeometryHandler = function(input, fn)
for (let i = 0; i < cells.length; i++)
{
if (graph.getModel().isEdge(cells[i]))
if (cells[i].isEdge())
{
let geo = graph.getCellGeometry(cells[i]);
@ -2658,11 +2658,11 @@ ArrangePanel.prototype.addEdgeGeometry = function(container)
div.style.display = 'none';
}
if (graph.getSelectionCount() == 1 && graph.model.isEdge(cell))
if (graph.getSelectionCount() == 1 && cell.isEdge())
{
let geo = graph.model.getGeometry(cell);
if (geo.sourcePoint != null && graph.model.getTerminal(cell, true) == null)
let geo = cell.getGeometry();
if (geo.sourcePoint != null && cell.getTerminal(true) == null)
{
xs.value = geo.sourcePoint.x;
ys.value = geo.sourcePoint.y;
@ -2672,7 +2672,7 @@ ArrangePanel.prototype.addEdgeGeometry = function(container)
divs.style.display = 'none';
}
if (geo.targetPoint != null && graph.model.getTerminal(cell, false) == null)
if (geo.targetPoint != null && cell.getTerminal(false) == null)
{
xt.value = geo.targetPoint.x;
yt.value = geo.targetPoint.y;
@ -5614,8 +5614,8 @@ DiagramStylePanel.prototype.addView = function(div)
graphStyle.background : null, [cells[i]]);
}
let edge = model.isEdge(cells[i]);
let newStyle = model.getStyle(cells[i]);
let edge = cells[i].isEdge();
let newStyle = cells[i].getStyle();
let current = (edge) ? graph.currentEdgeStyle : graph.currentVertexStyle;
for (let j = 0; j < styles.length; j++)
@ -5745,7 +5745,7 @@ DiagramStylePanel.prototype.addView = function(div)
let defaultStyle = graph.stylesheet.getDefaultVertexStyle();
let appliedStyle = vertexStyle;
if (model.isEdge(cell))
if (cell.isEdge())
{
defaultStyle = graph.stylesheet.getDefaultEdgeStyle();
appliedStyle = edgeStyle;
@ -5883,7 +5883,7 @@ DiagramStylePanel.prototype.addView = function(div)
let defaultStyle = graph.stylesheet.getDefaultVertexStyle();
let appliedStyle = vertexStyle;
if (model.isEdge(cell))
if (cell.isEdge())
{
defaultStyle = graph.stylesheet.getDefaultEdgeStyle();
appliedStyle = edgeStyle;

File diff suppressed because it is too large Load Diff

View File

@ -253,9 +253,9 @@ Menus.prototype.init = function()
let tmp = graph.getSelectionCell();
let roots = null;
if (tmp == null || graph.getModel().getChildCount(tmp) == 0)
if (tmp == null || tmp.getChildCount() == 0)
{
if (graph.getModel().getEdgeCount(tmp) == 0)
if (tmp.getEdgeCount() == 0)
{
roots = graph.findTreeRoots(graph.getDefaultParent());
}
@ -292,9 +292,9 @@ Menus.prototype.init = function()
let tmp = graph.getSelectionCell();
let roots = null;
if (tmp == null || graph.getModel().getChildCount(tmp) == 0)
if (tmp == null || tmp.getChildCount() == 0)
{
if (graph.getModel().getEdgeCount(tmp) == 0)
if (tmp.getEdgeCount() == 0)
{
roots = graph.findTreeRoots(graph.getDefaultParent());
}
@ -331,9 +331,9 @@ Menus.prototype.init = function()
let tmp = graph.getSelectionCell();
let roots = null;
if (tmp == null || graph.getModel().getChildCount(tmp) == 0)
if (tmp == null || tmp.getChildCount() == 0)
{
if (graph.getModel().getEdgeCount(tmp) == 0)
if (tmp.getEdgeCount() == 0)
{
roots = graph.findTreeRoots(graph.getDefaultParent());
}
@ -364,9 +364,9 @@ Menus.prototype.init = function()
if (!graph.isSelectionEmpty())
{
tmp = graph.getModel().getParent(tmp);
tmp = tmp.getParent();
if (graph.getModel().isVertex(tmp))
if (tmp.isVertex())
{
graph.updateGroupBounds([tmp], graph.gridSize * 2, true);
}
@ -388,14 +388,14 @@ Menus.prototype.init = function()
{
let tmp = graph.getSelectionCell();
if (tmp == null || graph.getModel().getChildCount(tmp) == 0)
if (tmp == null || tmp.getChildCount() == 0)
{
tmp = graph.getDefaultParent();
}
layout.execute(tmp);
if (graph.getModel().isVertex(tmp))
if (tmp.isVertex())
{
graph.updateGroupBounds([tmp], graph.gridSize * 2, true);
}
@ -410,14 +410,14 @@ Menus.prototype.init = function()
{
let tmp = graph.getSelectionCell();
if (tmp == null || graph.getModel().getChildCount(tmp) == 0)
if (tmp == null || tmp.getChildCount() == 0)
{
tmp = graph.getDefaultParent();
}
layout.execute(tmp);
if (graph.getModel().isVertex(tmp))
if (tmp.isVertex())
{
graph.updateGroupBounds([tmp], graph.gridSize * 2, true);
}
@ -787,7 +787,7 @@ Menus.prototype.edgeStyleChange = function(menu, label, keys, values, sprite, pa
{
let cell = cells[i];
if (graph.getModel().isEdge(cell))
if (cell.isEdge())
{
if (reset)
{
@ -877,7 +877,7 @@ Menus.prototype.createStyleChangeFunction = function(keys, values)
{
for (let j = 0; j < cells.length; j++)
{
if (graph.model.getChildCount(cells[j]) == 0)
if (cells[j].getChildCount() == 0)
{
graph.autoSizeCell(cells[j], false);
}
@ -1143,8 +1143,8 @@ Menus.prototype.addPopupMenuArrangeItems = function(menu, cell, evt)
{
this.addMenuItems(menu, ['-', 'group'], null, evt);
}
else if (graph.getSelectionCount() == 1 && !graph.getModel().isEdge(cell) &&
!graph.isSwimlane(cell) && graph.getModel().getChildCount(cell) > 0)
else if (graph.getSelectionCount() == 1 && !cell.isEdge() &&
!graph.isSwimlane(cell) && cell.getChildCount() > 0)
{
this.addMenuItems(menu, ['-', 'ungroup'], null, evt);
}
@ -1164,7 +1164,7 @@ Menus.prototype.addPopupMenuCellItems = function(menu, cell, evt)
{
let hasWaypoints = false;
if (graph.getModel().isEdge(cell) && mxUtils.getValue(state.style, mxConstants.STYLE_EDGE, null) != 'entityRelationEdgeStyle' &&
if (cell.isEdge() && mxUtils.getValue(state.style, mxConstants.STYLE_EDGE, null) != 'entityRelationEdgeStyle' &&
mxUtils.getValue(state.style, mxConstants.STYLE_SHAPE, null) != 'arrow')
{
let handler = graph.selectionCellsHandler.getHandler(cell);
@ -1188,12 +1188,12 @@ Menus.prototype.addPopupMenuCellItems = function(menu, cell, evt)
this.addMenuItems(menu, [(isWaypoint) ? 'removeWaypoint' : 'addWaypoint'], null, evt);
// Adds reset waypoints option if waypoints exist
let geo = graph.getModel().getGeometry(cell);
let geo = cell.getGeometry();
hasWaypoints = geo != null && geo.points != null && geo.points.length > 0;
}
if (graph.getSelectionCount() == 1 && (hasWaypoints || (graph.getModel().isVertex(cell) &&
graph.getModel().getEdgeCount(cell) > 0)))
if (graph.getSelectionCount() == 1 && (hasWaypoints || (cell.isVertex() &&
cell.getEdgeCount() > 0)))
{
this.addMenuItems(menu, ['-', 'clearWaypoints'], null, evt);
}
@ -1203,7 +1203,7 @@ Menus.prototype.addPopupMenuCellItems = function(menu, cell, evt)
this.addMenuItems(menu, ['-', 'editStyle', 'editData', 'editLink'], null, evt);
// Shows edit image action if there is an image in the style
if (graph.getModel().isVertex(cell) && mxUtils.getValue(state.style, mxConstants.STYLE_IMAGE, null) != null)
if (cell.isVertex() && mxUtils.getValue(state.style, mxConstants.STYLE_IMAGE, null) != null)
{
menu.addSeparator();
this.addMenuItem(menu, 'image', null, evt).firstChild.nextSibling.innerHTML = mxResources.get('editImage') + '...';

View File

@ -4181,7 +4181,7 @@
if (graph.isTableRow(state.cell) || graph.isTableCell(state.cell))
{
let dir = graph.getSwimlaneDirection(state.style);
let parent = graph.model.getParent(state.cell);
let parent = state.cell.getParent();
let cells = graph.model.getChildCells(parent, true);
let temp = [];

View File

@ -2607,7 +2607,7 @@ Sidebar.prototype.updateShapes = function(source, targets)
graph.model.beginUpdate();
try
{
let cellStyle = graph.getModel().getStyle(source);
let cellStyle = source.getStyle();
// Lists the styles to carry over from the existing shape
let styles = ['shadow', 'dashed', 'dashPattern', 'fontFamily', 'fontSize', 'fontColor', 'align', 'startFill',
@ -2621,8 +2621,8 @@ Sidebar.prototype.updateShapes = function(source, targets)
{
let targetCell = targets[i];
if ((graph.getModel().isVertex(targetCell) == graph.getModel().isVertex(source)) ||
(graph.getModel().isEdge(targetCell) == graph.getModel().isEdge(source)))
if ((targetCell.isVertex() == source.isVertex()) ||
(targetCell.isEdge() == source.isEdge()))
{
let style = graph.getCurrentCellStyle(targets[i]);
graph.getModel().setStyle(targetCell, cellStyle);
@ -2630,11 +2630,11 @@ Sidebar.prototype.updateShapes = function(source, targets)
// Removes all children of composite cells
if (mxUtils.getValue(style, 'composite', '0') == '1')
{
let childCount = graph.model.getChildCount(targetCell);
let childCount = targetCell.getChildCount();
for (let j = childCount; j >= 0; j--)
{
graph.model.remove(graph.model.getChildAt(targetCell, j));
graph.model.remove(targetCell.getChildAt(j));
}
}
@ -2822,7 +2822,7 @@ Sidebar.prototype.dropAndConnect = function(source, targets, direction, dropCell
var geo2 = graph.getCellGeometry(targets[dropCellIndex]);
// Handles special case where target should be ignored for stack layouts
let targetParent = graph.model.getParent(source);
let targetParent = source.getParent();
let validLayout = true;
// Ignores parent if it has a stack layout or if it is a table or row
@ -2838,7 +2838,7 @@ Sidebar.prototype.dropAndConnect = function(source, targets, direction, dropCell
}
// Checks if another container is at the drop location
let tmp = (graph.model.isEdge(source)) ? null : graph.view.getState(targetParent);
let tmp = (source.isEdge()) ? null : graph.view.getState(targetParent);
let dx = 0;
let dy = 0;
@ -2859,7 +2859,7 @@ Sidebar.prototype.dropAndConnect = function(source, targets, direction, dropCell
}
let useParent = !graph.isTableRow(source) && !graph.isTableCell(source) &&
(graph.model.isEdge(source) || (sourceGeo != null &&
(source.isEdge() || (sourceGeo != null &&
!sourceGeo.relative && validLayout));
let tempTarget = graph.getCellAt((geo.x + dx + graph.view.translate.x) * graph.view.scale,
@ -2879,7 +2879,7 @@ Sidebar.prototype.dropAndConnect = function(source, targets, direction, dropCell
targetParent = tempTarget;
useParent = true;
if (!graph.model.isEdge(source))
if (!source.isEdge())
{
geo.x -= offset.x - dx;
geo.y -= offset.y - dy;
@ -2896,7 +2896,7 @@ Sidebar.prototype.dropAndConnect = function(source, targets, direction, dropCell
dy = geo2.y;
// Ignores geometry of edges
if (graph.model.isEdge(targets[dropCellIndex]))
if (targets[dropCellIndex].isEdge())
{
dx = 0;
dy = 0;
@ -2906,14 +2906,14 @@ Sidebar.prototype.dropAndConnect = function(source, targets, direction, dropCell
(geo.y - (useParent ? dy : 0)), (useParent) ? targetParent : null);
tmp = targets;
if (graph.model.isEdge(source))
if (source.isEdge())
{
// Adds new terminal to edge
// LATER: Push new terminal out radially from edge start point
graph.model.setTerminal(source, targets[dropCellIndex],
direction == mxConstants.DIRECTION_NORTH);
}
else if (graph.model.isEdge(targets[dropCellIndex]))
else if (targets[dropCellIndex].isEdge())
{
// Adds new outgoing connection to vertex and clears points
graph.model.setTerminal(targets[dropCellIndex], source, true);
@ -2924,7 +2924,7 @@ Sidebar.prototype.dropAndConnect = function(source, targets, direction, dropCell
{
geo3.setTerminalPoint(geo.getTerminalPoint(false), false);
}
else if (useParent && graph.model.isVertex(targetParent))
else if (useParent && targetParent.isVertex())
{
// Adds parent offset to other nodes
let tmpState = graph.view.getState(targetParent);
@ -2991,7 +2991,7 @@ Sidebar.prototype.getDropAndConnectGeometry = function(source, target, direction
{
geo2 = geo2.clone();
if (graph.model.isEdge(source))
if (source.isEdge())
{
let state = graph.view.getState(source);
let pts = state.absolutePoints;
@ -3022,7 +3022,7 @@ Sidebar.prototype.getDropAndConnectGeometry = function(source, target, direction
let length = graph.defaultEdgeLength;
// Maintains edge length
if (graph.model.isEdge(target) && geo2.getTerminalPoint(true) != null &&
if (target.isEdge() && geo2.getTerminalPoint(true) != null &&
geo2.getTerminalPoint(false) != null)
{
var p0 = geo2.getTerminalPoint(true);
@ -3094,7 +3094,7 @@ Sidebar.prototype.getDropAndConnectGeometry = function(source, target, direction
}
// Adds offset to match cells without connecting edge
if (graph.model.isEdge(target) && geo2.getTerminalPoint(true) != null &&
if (target.isEdge() && geo2.getTerminalPoint(true) != null &&
target.getTerminal(false) != null)
{
let targetGeo = graph.getCellGeometry(target.getTerminal(false));
@ -3174,12 +3174,12 @@ Sidebar.prototype.createDragSource = function(elt, dropHandler, preview, cells,
for (let i = 0; i < cells.length; i++)
{
if (firstVertex == null && graph.model.isVertex(cells[i]))
if (firstVertex == null && cells[i].isVertex())
{
firstVertex = i;
}
else if (freeSourceEdge == null && graph.model.isEdge(cells[i]) &&
graph.model.getTerminal(cells[i], true) == null)
else if (freeSourceEdge == null && cells[i].isEdge() &&
cells[i].getTerminal(true) == null)
{
freeSourceEdge = i;
}
@ -3202,12 +3202,12 @@ Sidebar.prototype.createDragSource = function(elt, dropHandler, preview, cells,
if (cells != null && currentStyleTarget != null && activeArrow == styleTarget)
{
let tmp = graph.isCellSelected(currentStyleTarget.cell) ? graph.getSelectionCells() : [currentStyleTarget.cell];
let updatedCells = this.updateShapes((graph.model.isEdge(currentStyleTarget.cell)) ? cells[0] : cells[firstVertex], tmp);
let updatedCells = this.updateShapes((currentStyleTarget.cell.isEdge()) ? cells[0] : cells[firstVertex], tmp);
graph.setSelectionCells(updatedCells);
}
else if (cells != null && activeArrow != null && currentTargetState != null && activeArrow != styleTarget)
{
let index = (graph.model.isEdge(currentTargetState.cell) || freeSourceEdge == null) ? firstVertex : freeSourceEdge;
let index = (currentTargetState.cell.isEdge() || freeSourceEdge == null) ? firstVertex : freeSourceEdge;
graph.setSelectionCells(this.dropAndConnect(currentTargetState.cell, cells, direction, index, evt));
}
else
@ -3355,7 +3355,7 @@ Sidebar.prototype.createDragSource = function(elt, dropHandler, preview, cells,
if (currentStyleTarget != null && activeArrow == styleTarget)
{
this.previewElement.style.display = (graph.model.isEdge(currentStyleTarget.cell)) ? 'none' : '';
this.previewElement.style.display = (currentStyleTarget.cell.isEdge()) ? 'none' : '';
this.previewElement.style.left = currentStyleTarget.x + 'px';
this.previewElement.style.top = currentStyleTarget.y + 'px';
@ -3369,15 +3369,15 @@ Sidebar.prototype.createDragSource = function(elt, dropHandler, preview, cells,
dragSource.currentHighlight.hide();
}
let index = (graph.model.isEdge(currentTargetState.cell) || freeSourceEdge == null) ? firstVertex : freeSourceEdge;
let index = (currentTargetState.cell.isEdge() || freeSourceEdge == null) ? firstVertex : freeSourceEdge;
let geo = sidebar.getDropAndConnectGeometry(currentTargetState.cell, cells[index], direction, cells);
var geo2 = (!graph.model.isEdge(currentTargetState.cell)) ? graph.getCellGeometry(currentTargetState.cell) : null;
var geo2 = (!currentTargetState.cell.isEdge()) ? graph.getCellGeometry(currentTargetState.cell) : null;
var geo3 = graph.getCellGeometry(cells[index]);
let parent = graph.model.getParent(currentTargetState.cell);
let parent = currentTargetState.cell.getParent();
let dx = view.translate.x * view.scale;
let dy = view.translate.y * view.scale;
if (geo2 != null && !geo2.relative && graph.model.isVertex(parent) && parent != view.currentRoot)
if (geo2 != null && !geo2.relative && parent.isVertex() && parent != view.currentRoot)
{
let pState = view.getState(parent);
@ -3389,7 +3389,7 @@ Sidebar.prototype.createDragSource = function(elt, dropHandler, preview, cells,
var dy2 = geo3.y;
// Ignores geometry of edges
if (graph.model.isEdge(cells[index]))
if (cells[index].isEdge())
{
dx2 = 0;
dy2 = 0;
@ -3408,7 +3408,7 @@ Sidebar.prototype.createDragSource = function(elt, dropHandler, preview, cells,
this.previewElement.style.display = '';
}
else if (dragSource.currentHighlight.state != null &&
graph.model.isEdge(dragSource.currentHighlight.state.cell))
dragSource.currentHighlight.state.cell.isEdge())
{
// Centers drop cells when splitting edges
this.previewElement.style.left = Math.round(parseInt(this.previewElement.style.left) -
@ -3445,11 +3445,11 @@ Sidebar.prototype.createDragSource = function(elt, dropHandler, preview, cells,
// Uses connectable parent vertex if one exists
if (cell != null && !this.graph.isCellConnectable(cell) &&
!this.graph.model.isEdge(cell))
!cell.isEdge())
{
let parent = this.graph.getModel().getParent(cell);
let parent = this.cell.getParent();
if (this.graph.getModel().isVertex(parent) &&
if (parent.isVertex() &&
this.graph.isCellConnectable(parent))
{
cell = parent;
@ -3503,12 +3503,12 @@ Sidebar.prototype.createDragSource = function(elt, dropHandler, preview, cells,
mxUtils.getValue(state.style, mxConstants.STYLE_FILLCOLOR, mxConstants.NONE) != mxConstants.NONE ||
mxUtils.getValue(state.style, mxConstants.STYLE_GRADIENTCOLOR, mxConstants.NONE) != mxConstants.NONE)) ||
mxUtils.getValue(sourceCellStyle, mxConstants.STYLE_SHAPE) == 'image') ||
timeOnTarget > 1500 || graph.model.isEdge(state.cell)) && (timeOnTarget > this.dropTargetDelay) &&
!this.isDropStyleTargetIgnored(state) && ((graph.model.isVertex(state.cell) && firstVertex != null) ||
(graph.model.isEdge(state.cell) && graph.model.isEdge(cells[0]))))
timeOnTarget > 1500 || state.cell.isEdge()) && (timeOnTarget > this.dropTargetDelay) &&
!this.isDropStyleTargetIgnored(state) && ((state.cell.isVertex() && firstVertex != null) ||
(state.cell.isEdge() && cells[0].isEdge())))
{
currentStyleTarget = state;
let tmp = (graph.model.isEdge(state.cell)) ? graph.view.getPoint(state) :
let tmp = (state.cell.isEdge()) ? graph.view.getPoint(state) :
new mxPoint(state.getCenterX(), state.getCenterY());
tmp = new mxRectangle(tmp.x - this.refreshTarget.width / 2, tmp.y - this.refreshTarget.height / 2,
this.refreshTarget.width, this.refreshTarget.height);
@ -3539,7 +3539,7 @@ Sidebar.prototype.createDragSource = function(elt, dropHandler, preview, cells,
else if (currentStyleTarget != null && styleTargetParent != null)
{
// Sets active Arrow as side effect
let tmp = (graph.model.isEdge(currentStyleTarget.cell)) ? graph.view.getPoint(currentStyleTarget) : new mxPoint(currentStyleTarget.getCenterX(), currentStyleTarget.getCenterY());
let tmp = (currentStyleTarget.cell.isEdge()) ? graph.view.getPoint(currentStyleTarget) : new mxPoint(currentStyleTarget.getCenterX(), currentStyleTarget.getCenterY());
tmp = new mxRectangle(tmp.x - this.refreshTarget.width / 2, tmp.y - this.refreshTarget.height / 2,
this.refreshTarget.width, this.refreshTarget.height);
checkArrow(x, y, tmp, styleTarget);
@ -3551,7 +3551,7 @@ Sidebar.prototype.createDragSource = function(elt, dropHandler, preview, cells,
// LATER: Use hit-detection for edges
bbox = mxRectangle.fromRectangle(currentTargetState);
if (graph.model.isEdge(currentTargetState.cell))
if (currentTargetState.cell.isEdge())
{
let pts = currentTargetState.absolutePoints;
@ -3642,8 +3642,8 @@ Sidebar.prototype.createDragSource = function(elt, dropHandler, preview, cells,
}
let validTarget = (firstVertex == null || graph.isCellConnectable(cells[firstVertex])) &&
((graph.model.isEdge(cell) && firstVertex != null) ||
(graph.model.isVertex(cell) && graph.isCellConnectable(cell)));
((cell.isEdge() && firstVertex != null) ||
(cell.isVertex() && graph.isCellConnectable(cell)));
// Drop arrows shown after this.dropTargetDelay, hidden after 5 secs, switches arrows after 500ms
if ((currentTargetState != null && timeOnTarget >= 5000) ||
@ -3653,7 +3653,7 @@ Sidebar.prototype.createDragSource = function(elt, dropHandler, preview, cells,
{
activeTarget = false;
currentTargetState = ((timeOnTarget < 5000 && timeOnTarget > this.dropTargetDelay) ||
graph.model.isEdge(cell)) ? state : null;
cell.isEdge()) ? state : null;
if (currentTargetState != null && validTarget)
{
@ -3667,7 +3667,7 @@ Sidebar.prototype.createDragSource = function(elt, dropHandler, preview, cells,
}
}
if (graph.model.isEdge(cell))
if (cell.isEdge())
{
let pts = state.absolutePoints;
@ -3684,12 +3684,12 @@ Sidebar.prototype.createDragSource = function(elt, dropHandler, preview, cells,
roundTarget.style.left = Math.floor(pe.x - this.roundDrop.width / 2) + 'px';
roundTarget.style.top = Math.floor(pe.y - this.roundDrop.height / 2) + 'px';
if (graph.model.getTerminal(cell, true) == null)
if (cell.getTerminal(true) == null)
{
graph.container.appendChild(roundSource);
}
if (graph.model.getTerminal(cell, false) == null)
if (cell.getTerminal(false) == null)
{
graph.container.appendChild(roundTarget);
}
@ -3793,15 +3793,15 @@ Sidebar.prototype.createDragSource = function(elt, dropHandler, preview, cells,
{
// Selects parent group as drop target
while (target != null && !graph.isValidDropTarget(target, cells, evt) &&
model.isVertex(model.getParent(target)))
target.getParent().isVertex())
{
target = model.getParent(target);
target = target.getParent();
}
if (target != null && (graph.view.currentRoot == target ||
(!graph.isValidRoot(target) &&
graph.getModel().getChildCount(target) == 0) ||
graph.isCellLocked(target) || model.isEdge(target) ||
(!graph.isValidRoot(target) &&
target.getChildCount() == 0) ||
graph.isCellLocked(target) || target.isEdge() ||
!graph.isValidDropTarget(target, cells, evt)))
{
target = null;
@ -3851,13 +3851,13 @@ Sidebar.prototype.itemClicked = function(cells, ds, evt, elt)
// Alt+Click inserts and connects
if (mxEvent.isAltDown(evt) && graph.getSelectionCount() == 1 &&
graph.model.isVertex(graph.getSelectionCell()))
graph.getSelectionCell().isVertex())
{
let firstVertex = null;
for (let i = 0; i < cells.length && firstVertex == null; i++)
{
if (graph.model.isVertex(cells[i]))
if (cells[i].isVertex())
{
firstVertex = i;
}

View File

@ -27,7 +27,7 @@ class mxChildChange {
// execute(): void;
execute() {
if (this.child != null) {
let tmp = this.model.getParent(this.child);
let tmp = this.child.getParent();
const tmp2 = tmp != null ? tmp.getIndex(this.child) : 0;
if (this.previous == null) {
@ -84,10 +84,10 @@ class mxChildChange {
cell.setTerminal(source, true);
cell.setTerminal(target, false);
const childCount = this.model.getChildCount(cell);
const childCount = cell.getChildCount();
for (let i = 0; i < childCount; i += 1) {
this.connect(this.model.getChildAt(cell, i), isConnect);
this.connect(cell.getChildAt(i), isConnect);
}
}
}

View File

@ -1,10 +1,10 @@
import mxGraphView from './mxGraphView';
import mxEventObject from '../../util/event/mxEventObject';
import mxPoint from '../../util/datatypes/mxPoint';
import mxCell from '../cell/mxCell';
import mxEvent from '../../util/event/mxEvent';
import mxGraphModel from './mxGraphModel';
import mxGraph from "./mxGraph";
import mxGraphView from '../view/graph/mxGraphView';
import mxEventObject from '../util/event/mxEventObject';
import mxPoint from '../util/datatypes/mxPoint';
import mxCell from '../view/cell/mxCell';
import mxEvent from '../util/event/mxEvent';
import mxGraphModel from '../view/graph/mxGraphModel';
import mxGraph from "../view/graph/mxGraph";
/**
* Class: mxCurrentRootChange
@ -27,7 +27,7 @@ class mxCurrentRootChange {
this.isUp = true;
break;
}
tmp = model.getParent(tmp);
tmp = tmp.getParent();
}
}
}

View File

@ -1,9 +1,9 @@
import mxEventObject from '../../util/event/mxEventObject';
import mxResources from '../../util/mxResources';
import mxLog from '../../util/gui/mxLog';
import mxEvent from '../../util/event/mxEvent';
import mxGraphSelectionModel from './mxGraphSelectionModel';
import mxCell from '../cell/mxCell';
import mxEventObject from '../util/event/mxEventObject';
import mxResources from '../util/mxResources';
import mxLog from '../util/gui/mxLog';
import mxEvent from '../util/event/mxEvent';
import mxGraphSelectionModel from '../view/graph/mxGraphSelectionModel';
import mxCell from '../view/cell/mxCell';
/**
* @class mxSelectionChange

View File

@ -267,14 +267,14 @@ class mxDefaultPopupMenu {
createConditions(editor, cell, evt) {
// Creates array with conditions
const model = editor.graph.getModel();
const childCount = model.getChildCount(cell);
const childCount = cell.getChildCount();
// Adds some frequently used conditions
const conditions = [];
conditions.nocell = cell == null;
conditions.ncells = editor.graph.getSelectionCount() > 1;
conditions.notRoot =
model.getRoot() !== model.getParent(editor.graph.getDefaultParent());
model.getRoot() !== editor.graph.getDefaultParent().getParent();
conditions.cell = cell != null;
const isCell = cell != null && editor.graph.getSelectionCount() === 1;

View File

@ -303,7 +303,7 @@ class mxDefaultToolbar {
if (
target == null ||
model.isEdge(target) ||
target.isEdge() ||
!this.connectOnDrop ||
!graph.isCellConnectable(target)
) {
@ -311,7 +311,7 @@ class mxDefaultToolbar {
target != null &&
!graph.isValidDropTarget(target, [vertex], evt)
) {
target = model.getParent(target);
target = target.getParent();
}
this.insert(vertex, evt, target);
} else {
@ -370,8 +370,8 @@ class mxDefaultToolbar {
model.beginUpdate();
try {
const geo = model.getGeometry(source);
const g = model.getGeometry(vertex).clone();
const geo = source.getGeometry();
const g = vertex.getGeometry().clone();
// Moves the vertex away from the drop target that will
// be used as the source for the new connection
@ -391,7 +391,7 @@ class mxDefaultToolbar {
// Fires two add-events with the code below - should be fixed
// to only fire one add event for both inserts
const parent = model.getParent(source);
const parent = source.getParent();
graph.addCell(vertex, parent);
graph.constrainChild(vertex);
@ -399,7 +399,7 @@ class mxDefaultToolbar {
// the second function that fires an add event
edge = this.editor.createEdge(source, vertex);
if (model.getGeometry(edge) == null) {
if (edge.getGeometry() == null) {
const edgeGeometry = new mxGeometry();
edgeGeometry.relative = true;

View File

@ -1555,7 +1555,7 @@ class mxEditor extends mxEventSource {
let layout = null;
const model = self.graph.getModel();
if (model.getParent(cell) != null) {
if (cell.getParent() != null) {
// Executes the swimlane layout if a child of
// a swimlane has been changed. The layout is
// lazy created in createSwimlaneLayout.
@ -1573,7 +1573,7 @@ class mxEditor extends mxEventSource {
else if (
self.layoutDiagram &&
(graph.isValidRoot(cell) ||
model.getParent(model.getParent(cell)) == null)
cell.getParent().getParent() == null)
) {
if (self.diagramLayout == null) {
self.diagramLayout = self.createDiagramLayout();
@ -1892,14 +1892,14 @@ class mxEditor extends mxEventSource {
while (
cell != null &&
graph.getModel().getParent(graph.getModel().getParent(cell)) != null
cell.getParent().getParent() != null
) {
// Append each label of a valid root
if (graph.isValidRoot(cell)) {
title = ` > ${graph.convertValueToString(cell)}${title}`;
}
cell = graph.getModel().getParent(cell);
cell = cell.getParent();
}
const prefix = this.getRootTitle();
@ -2249,8 +2249,8 @@ class mxEditor extends mxEventSource {
let heightField = null;
// Adds fields for the location and size
if (model.isVertex(cell)) {
geo = model.getGeometry(cell);
if (cell.isVertex()) {
geo = cell.getGeometry();
if (geo != null) {
yField = form.addText('top', geo.y);
@ -2261,7 +2261,7 @@ class mxEditor extends mxEventSource {
}
// Adds a field for the cell style
const tmp = model.getStyle(cell);
const tmp = cell.getStyle();
const style = form.addText('Style', tmp || '');
// Creates textareas for each attribute of the
@ -2690,8 +2690,8 @@ class mxEditor extends mxEventSource {
parent = parent != null ? parent : this.graph.getSwimlaneAt(x, y);
const { scale } = this.graph.getView();
let geo = model.getGeometry(vertex);
const pgeo = model.getGeometry(parent);
let geo = vertex.getGeometry();
const pgeo = parent.getGeometry();
if (this.graph.isSwimlane(vertex) && !this.graph.swimlaneNesting) {
parent = null;

View File

@ -597,10 +597,10 @@ class mxConnectionHandler extends mxEventSource {
// Uses connectable parent vertex if one exists
if (cell != null && !self.graph.isCellConnectable(cell)) {
const parent = self.graph.getModel().getParent(cell);
const parent = self.cell.getParent();
if (
self.graph.getModel().isVertex(parent) &&
parent.isVertex() &&
self.graph.isCellConnectable(parent)
) {
cell = parent;
@ -2008,12 +2008,12 @@ class mxConnectionHandler extends mxEventSource {
// FIXME: Should not shift if vertex was aligned (same in Java)
if (
dropTarget == null ||
!this.graph.getModel().isEdge(dropTarget)
!dropTarget.isEdge()
) {
const pstate = this.graph.getView().getState(dropTarget);
if (pstate != null) {
const tmp = model.getGeometry(target);
const tmp = target.getGeometry();
tmp.x -= pstate.origin.x;
tmp.y -= pstate.origin.y;
}
@ -2030,10 +2030,10 @@ class mxConnectionHandler extends mxEventSource {
if (
source != null &&
target != null &&
model.getParent(source) === model.getParent(target) &&
model.getParent(model.getParent(source)) !== model.getRoot()
source.getParent() === target.getParent() &&
source.getParent().getParent() !== model.getRoot()
) {
parent = model.getParent(source);
parent = source.getParent();
if (
source.geometry != null &&
@ -2041,7 +2041,7 @@ class mxConnectionHandler extends mxEventSource {
target.geometry != null &&
target.geometry.relative
) {
parent = model.getParent(parent);
parent = parent.getParent();
}
}
@ -2077,7 +2077,7 @@ class mxConnectionHandler extends mxEventSource {
model.setGeometry(edge, this.edgeState.cell.geometry);
}
parent = model.getParent(source);
parent = source.getParent();
// Inserts edge before source
if (this.isInsertBefore(edge, source, target, evt, dropTarget)) {
@ -2090,7 +2090,7 @@ class mxConnectionHandler extends mxEventSource {
tmp.geometry.relative &&
tmp.parent !== edge.parent
) {
tmp = this.graph.model.getParent(tmp);
tmp = tmp.getParent();
}
if (
@ -2103,7 +2103,7 @@ class mxConnectionHandler extends mxEventSource {
}
// Makes sure the edge has a non-null, relative geometry
let geo = model.getGeometry(edge);
let geo = edge.getGeometry();
if (geo == null) {
geo = new mxGeometry();
@ -2218,12 +2218,12 @@ class mxConnectionHandler extends mxEventSource {
let geo = this.graph.getCellGeometry(source);
while (geo != null && geo.relative) {
source = this.graph.getModel().getParent(source);
source = source.getParent();
geo = this.graph.getCellGeometry(source);
}
const clone = this.graph.cloneCell(source);
geo = this.graph.getModel().getGeometry(clone);
geo = clone.getGeometry();
if (geo != null) {
const t = this.graph.view.translate;

View File

@ -206,10 +206,10 @@ class mxConstraintHandler {
// Uses connectable parent vertex if one exists
if (cell != null && !this.graph.isCellConnectable(cell)) {
const parent = this.graph.getModel().getParent(cell);
const parent = this.cell.getParent();
if (
this.graph.getModel().isVertex(parent) &&
parent.isVertex() &&
this.graph.isCellConnectable(parent)
) {
cell = parent;
@ -257,7 +257,7 @@ class mxConstraintHandler {
(this.currentFocusArea == null ||
this.currentFocus == null ||
state != null ||
!this.graph.getModel().isVertex(this.currentFocus.cell) ||
!this.currentFocus.cell.isVertex() ||
!mxUtils.intersects(this.currentFocusArea, mouse)) &&
state !== this.currentFocus
) {

View File

@ -273,7 +273,7 @@ class mxEdgeHandler {
*/
isParentHighlightVisible() {
return !this.graph.isCellSelected(
this.graph.model.getParent(this.state.cell)
this.state.cell.getParent()
);
}
@ -285,11 +285,11 @@ class mxEdgeHandler {
updateParentHighlight() {
if (!this.isDestroyed()) {
const visible = this.isParentHighlightVisible();
const parent = this.graph.model.getParent(this.state.cell);
const parent = this.state.cell.getParent();
const pstate = this.graph.view.getState(parent);
if (this.parentHighlight != null) {
if (this.graph.model.isVertex(parent) && visible) {
if (parent.isVertex() && visible) {
const b = this.parentHighlight.bounds;
if (
@ -315,7 +315,7 @@ class mxEdgeHandler {
}
} else if (this.parentHighlightEnabled && visible) {
if (
this.graph.model.isVertex(parent) &&
parent.isVertex() &&
pstate != null &&
pstate.parentHighlight == null
) {
@ -602,10 +602,10 @@ class mxEdgeHandler {
// Uses connectable parent vertex if one exists
if (cell != null && !this.graph.isCellConnectable(cell)) {
const parent = this.graph.getModel().getParent(cell);
const parent = this.cell.getParent();
if (
this.graph.getModel().isVertex(parent) &&
parent.isVertex() &&
this.graph.isCellConnectable(parent)
) {
cell = parent;
@ -626,7 +626,7 @@ class mxEdgeHandler {
cell === self.state.cell ||
(cell != null &&
!self.graph.connectableEdges &&
model.isEdge(cell)) ||
cell.isEdge()) ||
model.isAncestor(self.state.cell, cell)
) {
cell = null;
@ -644,7 +644,7 @@ class mxEdgeHandler {
const other = self.graph.view.getTerminalPort(
state,
self.graph.view.getState(
model.getTerminal(self.state.cell, !self.isSource)
self.state.cell.getTerminal(!self.isSource)
),
!self.isSource
);
@ -1052,7 +1052,7 @@ class mxEdgeHandler {
if (this.isSource || this.isTarget) {
const { cell } = this.state;
const terminal = this.graph.model.getTerminal(cell, this.isSource);
const terminal = cell.getTerminal(this.isSource);
if (
(terminal == null &&
@ -1252,7 +1252,7 @@ class mxEdgeHandler {
const other = this.graph.view.getTerminalPort(
this.state,
this.graph.view.getState(
model.getTerminal(this.state.cell, !this.isSource)
this.state.cell.getTerminal(!this.isSource)
),
!this.isSource
);
@ -1784,22 +1784,22 @@ class mxEdgeHandler {
if (terminal != null) {
const model = this.graph.getModel();
const parent = model.getParent(edge);
const parent = edge.getParent();
model.beginUpdate();
try {
// Clones and adds the cell
if (clone) {
let geo = model.getGeometry(edge);
let geo = edge.getGeometry();
clone = this.graph.cloneCell(edge);
model.add(parent, clone, model.getChildCount(parent));
model.add(parent, clone, parent.getChildCount());
if (geo != null) {
geo = geo.clone();
model.setGeometry(clone, geo);
}
const other = model.getTerminal(edge, !this.isSource);
const other = edge.getTerminal(!this.isSource);
this.graph.connectCell(clone, other, !this.isSource);
edge = clone;
@ -1822,7 +1822,7 @@ class mxEdgeHandler {
const pstate = this.graph
.getView()
.getState(this.graph.getModel().getParent(edge));
.getState(edge.getParent());
if (pstate != null) {
pt.x -= pstate.origin.x;
@ -1947,7 +1947,7 @@ class mxEdgeHandler {
const pstate = this.graph
.getView()
.getState(this.graph.getModel().getParent(this.state.cell));
.getState(this.state.cell.getParent());
if (pstate != null) {
point.x -= pstate.origin.x;
@ -1971,7 +1971,7 @@ class mxEdgeHandler {
// moveLabel(edgeState: mxCellState, x: number, y: number): void;
moveLabel(edgeState, x, y) {
const model = this.graph.getModel();
let geometry = model.getGeometry(edgeState.cell);
let geometry = edgeState.cell.getGeometry();
if (geometry != null) {
const { scale } = this.graph.getView();
@ -2032,7 +2032,7 @@ class mxEdgeHandler {
// connect(edge: mxCell, terminal: mxCell, isSource: boolean, isClone: boolean, me: mxMouseEvent): mxCell;
connect(edge, terminal, isSource, isClone, me) {
const model = this.graph.getModel();
const parent = model.getParent(edge);
const parent = edge.getParent();
model.beginUpdate();
try {
@ -2062,14 +2062,14 @@ class mxEdgeHandler {
model.beginUpdate();
try {
if (clone) {
const parent = model.getParent(edge);
const terminal = model.getTerminal(edge, !isSource);
const parent = edge.getParent();
const terminal = edge.getTerminal(!isSource);
edge = this.graph.cloneCell(edge);
model.add(parent, edge, model.getChildCount(parent));
model.add(parent, edge, parent.getChildCount());
model.setTerminal(edge, terminal, !isSource);
}
let geo = model.getGeometry(edge);
let geo = edge.getGeometry();
if (geo != null) {
geo = geo.clone();
@ -2100,16 +2100,16 @@ class mxEdgeHandler {
model.beginUpdate();
try {
if (clone) {
const parent = model.getParent(edge);
const source = model.getTerminal(edge, true);
const target = model.getTerminal(edge, false);
const parent = edge.getParent();
const source = edge.getTerminal(true);
const target = edge.getTerminal(false);
edge = this.graph.cloneCell(edge);
model.add(parent, edge, model.getChildCount(parent));
model.add(parent, edge, parent.getChildCount());
model.setTerminal(edge, source, true);
model.setTerminal(edge, target, false);
}
let geo = model.getGeometry(edge);
let geo = edge.getGeometry();
if (geo != null) {
geo = geo.clone();
@ -2158,9 +2158,9 @@ class mxEdgeHandler {
const s = this.graph.view.scale;
let offset = new mxPoint(t.x * s, t.y * s);
const parent = this.graph.model.getParent(this.state.cell);
const parent = this.state.cell.getParent();
if (this.graph.model.isVertex(parent)) {
if (parent.isVertex()) {
const pState = this.graph.view.getState(parent);
offset = new mxPoint(pState.x, pState.y);
}
@ -2212,7 +2212,7 @@ class mxEdgeHandler {
getHandleFillColor(index) {
const isSource = index === 0;
const { cell } = this.state;
const terminal = this.graph.getModel().getTerminal(cell, isSource);
const terminal = cell.getTerminal(isSource);
let color = mxConstants.HANDLE_FILLCOLOR;
if (
@ -2240,7 +2240,7 @@ class mxEdgeHandler {
redraw(ignoreHandles) {
if (this.state != null) {
this.abspoints = this.state.absolutePoints.slice();
const g = this.graph.getModel().getGeometry(this.state.cell);
const g = this.state.cell.getGeometry();
if (g != null) {
const pts = g.points;
@ -2636,7 +2636,7 @@ class mxEdgeHandler {
}
if (this.parentHighlight != null) {
const parent = this.graph.model.getParent(this.state.cell);
const parent = this.state.cell.getParent();
const pstate = this.graph.view.getState(parent);
if (pstate != null && pstate.parentHighlight === this.parentHighlight) {

View File

@ -215,7 +215,7 @@ class mxEdgeSegmentHandler extends mxElbowEdgeHandler {
// connect(edge: mxCell, terminal: mxCell, isSource: boolean, isClone: boolean, me: mxMouseEvent): mxCell;
connect(edge, terminal, isSource, isClone, me) {
const model = this.graph.getModel();
let geo = model.getGeometry(edge);
let geo = edge.getGeometry();
let result = null;
// Merges adjacent edge segments
@ -245,7 +245,7 @@ class mxEdgeSegmentHandler extends mxElbowEdgeHandler {
model.beginUpdate();
try {
if (result != null) {
geo = model.getGeometry(edge);
geo = edge.getGeometry();
if (geo != null) {
geo = geo.clone();

View File

@ -192,7 +192,7 @@ class mxElbowEdgeHandler extends mxEdgeHandler {
*/
// redrawInnerBends(p0: mxPoint, pe: mxPoint): void;
redrawInnerBends(p0, pe) {
const g = this.graph.getModel().getGeometry(this.state.cell);
const g = this.state.cell.getGeometry();
const pts = this.state.absolutePoints;
let pt = null;

View File

@ -458,10 +458,10 @@ class mxGraphHandler {
* selection state to the parent.
*/
isPropagateSelectionCell(cell, immediate, me) {
const parent = this.graph.model.getParent(cell);
const parent = cell.getParent();
if (immediate) {
const geo = this.graph.model.isEdge(cell)
const geo = cell.isEdge()
? null
: this.graph.getCellGeometry(cell);
@ -497,17 +497,17 @@ class mxGraphHandler {
!this.graph.isCellSelected(state.cell)
) {
const { model } = this.graph;
let next = this.graph.view.getState(model.getParent(state.cell));
let next = this.graph.view.getState(state.cell.getParent());
while (
next != null &&
!this.graph.isCellSelected(next.cell) &&
(model.isVertex(next.cell) || model.isEdge(next.cell)) &&
(next.cell.isVertex() || next.cell.isEdge()) &&
this.isPropagateSelectionCell(state.cell, true, me)
) {
state = next;
next = this.graph.view.getState(
this.graph.getModel().getParent(state.cell)
state.cell.getParent()
);
}
}
@ -531,7 +531,7 @@ class mxGraphHandler {
return this.graph.cellEditor.getEditingCell() != cell;
}
cell = this.graph.model.getParent(cell);
cell = cell.getParent();
}
}
@ -576,15 +576,15 @@ class mxGraphHandler {
!isAltDown(me.getEvent())
) {
const model = this.graph.getModel();
let parent = model.getParent(cell);
let parent = cell.getParent();
while (
this.graph.view.getState(parent) != null &&
(model.isVertex(parent) || model.isEdge(parent)) &&
(parent.isVertex() || parent.isEdge()) &&
this.isPropagateSelectionCell(cell, false, me)
) {
cell = parent;
parent = model.getParent(cell);
parent = cell.getParent();
}
}
@ -645,15 +645,15 @@ class mxGraphHandler {
if (this.isMoveEnabled()) {
const { model } = this.graph;
const geo = model.getGeometry(cell);
const geo = cell.getGeometry();
if (
this.graph.isCellMovable(cell) &&
(!model.isEdge(cell) ||
(!cell.isEdge() ||
this.graph.getSelectionCount() > 1 ||
(geo.points != null && geo.points.length > 0) ||
model.getTerminal(cell, true) == null ||
model.getTerminal(cell, false) == null ||
cell.getTerminal(true) == null ||
cell.getTerminal(false) == null ||
this.graph.allowDanglingEdges ||
(this.graph.isCloneEvent(me.getEvent()) &&
this.graph.isCellsCloneable()))
@ -682,9 +682,9 @@ class mxGraphHandler {
const filter = mxUtils.bind(this, cell => {
return (
this.graph.view.getState(cell) != null &&
model.isVertex(cell) &&
model.getGeometry(cell) != null &&
!model.getGeometry(cell).relative
cell.isVertex() &&
cell.getGeometry() != null &&
!cell.getGeometry().relative
);
});
@ -774,14 +774,14 @@ class mxGraphHandler {
const model = this.graph.getModel();
for (let i = 0; i < cells.length; i += 1) {
if (model.isVertex(cells[i]) || model.isEdge(cells[i])) {
if (cells[i].isVertex() || cells[i].isEdge()) {
const state = this.graph.view.getState(cells[i]);
if (state != null) {
let bbox = state;
if (
model.isVertex(cells[i]) &&
cells[i].isVertex() &&
state.shape != null &&
state.shape.boundingBox != null
) {
@ -859,8 +859,8 @@ class mxGraphHandler {
if (this.guidesEnabled) {
this.guide = this.createGuide();
const parent = this.graph.model.getParent(cell);
const ignore = this.graph.model.getChildCount(parent) < 2;
const parent = cell.getParent();
const ignore = parent.getChildCount() < 2;
// Uses connected states as guides
const connected = new mxDictionary();
@ -878,7 +878,7 @@ class mxGraphHandler {
}
this.guide.isStateIgnored = state => {
const p = this.graph.model.getParent(state.cell);
const p = state.cell.getParent();
return (
state.cell != null &&
@ -887,7 +887,7 @@ class mxGraphHandler {
!ignore &&
!connected.get(state) &&
(this.target == null ||
this.graph.model.getChildCount(this.target) >= 2) &&
this.target.getChildCount() >= 2) &&
p !== (this.target || parent)))
);
};
@ -908,10 +908,10 @@ class mxGraphHandler {
dict.put(cell, state);
count++;
const childCount = this.graph.model.getChildCount(cell);
const childCount = cell.getChildCount();
for (let i = 0; i < childCount; i += 1) {
count += this.addStates(this.graph.model.getChildAt(cell, i), dict);
count += this.addStates(cell.getChildAt(i), dict);
}
}
@ -1008,7 +1008,7 @@ class mxGraphHandler {
* Returns true if the given cell is a valid drop target.
*/
isValidDropTarget(target, me) {
return this.graph.model.getParent(this.cell) !== target;
return this.cell.getParent() !== target;
}
/**
@ -1108,7 +1108,7 @@ class mxGraphHandler {
this.connectOnDrop &&
cell != null &&
this.cells.length === 1 &&
graph.getModel().isVertex(cell) &&
cell.isVertex() &&
graph.isCellConnectable(cell)
) {
state = graph.getView().getState(cell);
@ -1187,7 +1187,7 @@ class mxGraphHandler {
graph.isEnabled() &&
graph.isCellMovable(me.getCell())
) {
if (graph.getModel().isEdge(me.getCell())) {
if (me.getCell().isEdge()) {
cursor = mxConstants.CURSOR_MOVABLE_EDGE;
} else {
cursor = mxConstants.CURSOR_MOVABLE_VERTEX;
@ -1289,7 +1289,7 @@ class mxGraphHandler {
}
// Temporarily changes position
if (this.graph.model.isVertex(state.cell)) {
if (state.cell.isVertex()) {
state.x += dx;
state.y += dy;
@ -1338,7 +1338,7 @@ class mxGraphHandler {
for (let i = 0; i < states.length; i += 1) {
const state = states[i][0];
if (this.graph.model.isEdge(state.cell)) {
if (state.cell.isEdge()) {
const geometry = this.graph.getCellGeometry(state.cell);
const points = [];
@ -1602,7 +1602,7 @@ class mxGraphHandler {
this.connectOnDrop &&
this.target == null &&
cell != null &&
graph.getModel().isVertex(cell) &&
cell.isVertex() &&
graph.isCellConnectable(cell) &&
graph.isEdgeValid(null, this.cell, cell)
) {
@ -1618,6 +1618,7 @@ class mxGraphHandler {
const { target } = this;
if (
target &&
graph.isSplitEnabled() &&
graph.isSplitTarget(target, this.cells, me.getEvent())
) {
@ -1702,7 +1703,7 @@ class mxGraphHandler {
*/
// shouldRemoveCellsFromParent(parent: mxCell, cells: mxCell[], evt: Event): boolean;
shouldRemoveCellsFromParent(parent, cells, evt) {
if (this.graph.getModel().isVertex(parent)) {
if (parent.isVertex()) {
const pState = this.graph.getView().getState(parent);
if (pState != null) {
@ -1741,7 +1742,7 @@ class mxGraphHandler {
}
// Removes cells from parent
const parent = this.graph.getModel().getParent(this.cell);
const parent = this.cell.getParent();
if (
target == null &&
@ -1771,7 +1772,7 @@ class mxGraphHandler {
// LATER: Recurse up the cell hierarchy
for (let i = 0; i < cells.length; i += 1) {
const par = this.graph.model.getParent(cells[i]);
const par = cells[i].getParent();
if (par != null && !dict.get(par)) {
dict.put(par, true);
@ -1818,10 +1819,10 @@ class mxGraphHandler {
return (
state != null &&
(this.graph.model.isEdge(state.cell) ||
this.graph.model.isVertex(state.cell)) &&
(state.cell.isEdge() ||
state.cell.isVertex()) &&
this.graph.isCellDeletable(state.cell) &&
this.graph.model.getChildCount(state.cell) === 0 &&
state.cell.getChildCount() === 0 &&
this.graph.isTransparentState(state)
);
}

View File

@ -277,7 +277,7 @@ class mxVertexHandler {
this.sizers.push(this.createSizer('se-resize', i++));
}
const geo = this.graph.model.getGeometry(this.state.cell);
const geo = this.state.cell.getGeometry();
if (
geo != null &&
@ -720,7 +720,7 @@ class mxVertexHandler {
if (this.selectionBorder != null) {
this.livePreviewActive =
this.livePreview &&
this.graph.model.getChildCount(this.state.cell) === 0;
this.state.cell.getChildCount() === 0;
this.inTolerance = true;
this.childOffsetX = 0;
this.childOffsetY = 0;
@ -733,11 +733,11 @@ class mxVertexHandler {
} else {
// Saves reference to parent state
const { model } = this.state.view.graph;
const parent = model.getParent(this.state.cell);
const parent = this.state.cell.getParent();
if (
this.state.view.currentRoot !== parent &&
(model.isVertex(parent) || model.isEdge(parent))
(parent.isVertex() || parent.isEdge())
) {
this.parentState = this.state.view.graph.view.getState(parent);
}
@ -989,7 +989,7 @@ class mxVertexHandler {
* Returns true if a ghost preview should be used for custom handles.
*/
isGhostPreview() {
return this.state.view.graph.model.getChildCount(this.state.cell) > 0;
return this.state.cell.getChildCount() > 0;
}
/**
@ -1466,8 +1466,8 @@ class mxVertexHandler {
if (angle !== 0) {
const model = this.graph.getModel();
if (model.isVertex(cell) || model.isEdge(cell)) {
if (!model.isEdge(cell)) {
if (cell.isVertex() || cell.isEdge()) {
if (!cell.isEdge()) {
const style = this.graph.getCurrentCellStyle(cell);
const total = (style[mxConstants.STYLE_ROTATION] || 0) + angle;
this.graph.setCellStyles(mxConstants.STYLE_ROTATION, total, [cell]);
@ -1478,18 +1478,18 @@ class mxVertexHandler {
if (geo != null) {
const pgeo = this.graph.getCellGeometry(parent);
if (pgeo != null && !model.isEdge(parent)) {
if (pgeo != null && !parent.isEdge()) {
geo = geo.clone();
geo.rotate(angle, new mxPoint(pgeo.width / 2, pgeo.height / 2));
model.setGeometry(cell, geo);
}
if ((model.isVertex(cell) && !geo.relative) || model.isEdge(cell)) {
if ((cell.isVertex() && !geo.relative) || cell.isEdge()) {
// Recursive rotation
const childCount = model.getChildCount(cell);
const childCount = cell.getChildCount();
for (let i = 0; i < childCount; i += 1) {
this.rotateCell(model.getChildAt(cell, i), angle, cell);
this.rotateCell(cell.getChildAt(i), angle, cell);
}
}
}
@ -1580,7 +1580,7 @@ class mxVertexHandler {
* in the graph using <mxGraph.resizeCell>.
*/
resizeCell(cell, dx, dy, index, gridEnabled, constrained, recurse) {
let geo = this.graph.model.getGeometry(cell);
let geo = cell.getGeometry();
if (geo != null) {
if (index === mxEvent.LABEL_HANDLE) {
@ -1637,10 +1637,10 @@ class mxVertexHandler {
// moveChildren(cell: mxCell, dx: number, dy: number): void;
moveChildren(cell, dx, dy) {
const model = this.graph.getModel();
const childCount = model.getChildCount(cell);
const childCount = cell.getChildCount();
for (let i = 0; i < childCount; i += 1) {
const child = model.getChildAt(cell, i);
const child = cell.getChildAt(i);
let geo = this.graph.getCellGeometry(child);
if (geo != null) {
@ -2138,7 +2138,7 @@ class mxVertexHandler {
*/
isParentHighlightVisible() {
return !this.graph.isCellSelected(
this.graph.model.getParent(this.state.cell)
this.state.cell.getParent()
);
}
@ -2151,11 +2151,11 @@ class mxVertexHandler {
updateParentHighlight() {
if (!this.isDestroyed()) {
const visible = this.isParentHighlightVisible();
const parent = this.graph.model.getParent(this.state.cell);
const parent = this.state.cell.getParent();
const pstate = this.graph.view.getState(parent);
if (this.parentHighlight != null) {
if (this.graph.model.isVertex(parent) && visible) {
if (parent.isVertex() && visible) {
const b = this.parentHighlight.bounds;
if (
@ -2181,7 +2181,7 @@ class mxVertexHandler {
}
} else if (this.parentHighlightEnabled && visible) {
if (
this.graph.model.isVertex(parent) &&
parent.isVertex() &&
pstate != null &&
pstate.parentHighlight == null
) {
@ -2267,7 +2267,7 @@ class mxVertexHandler {
}
if (this.parentHighlight != null) {
const parent = this.graph.model.getParent(this.state.cell);
const parent = this.state.cell.getParent();
const pstate = this.graph.view.getState(parent);
if (pstate != null && pstate.parentHighlight === this.parentHighlight) {

View File

@ -212,7 +212,7 @@ class mxGraphHierarchyModel {
// Looking for outgoing edges only
if (
cell !== vertices[i] &&
layout.graph.model.isVertex(cell) &&
cell.isVertex() &&
!layout.isVertexIgnored(cell)
) {
// We process all edge between this source and its targets

View File

@ -207,7 +207,7 @@ class mxSwimlaneModel {
internalVertices[i].swimlaneIndex = -1;
for (let ii = 0; ii < swimlanes.length; ii += 1) {
if (graph.model.getParent(vertices[i]) === swimlanes[ii]) {
if (vertices[i].getParent() === swimlanes[ii]) {
internalVertices[i].swimlaneIndex = ii;
break;
}
@ -227,7 +227,7 @@ class mxSwimlaneModel {
// Looking for outgoing edges only
if (
cell !== vertices[i] &&
layout.graph.model.isVertex(cell) &&
cell.isVertex() &&
!layout.isVertexIgnored(cell)
) {
// We process all edge between this source and its targets

View File

@ -235,7 +235,7 @@ class mxHierarchicalLayout extends mxGraphLayout {
if (
parent !== this.root &&
model.isVertex(parent) != null &&
parent.isVertex() != null &&
this.maintainParentLocation
) {
const geo = this.graph.getCellGeometry(parent);
@ -253,7 +253,7 @@ class mxHierarchicalLayout extends mxGraphLayout {
const ancestor =
parent != null ? model.isAncestor(parent, roots[i]) : true;
if (ancestor && model.isVertex(roots[i])) {
if (ancestor && roots[i].isVertex()) {
rootsCopy.push(roots[i]);
}
}
@ -314,7 +314,7 @@ class mxHierarchicalLayout extends mxGraphLayout {
for (const i in vertices) {
const cell = vertices[i];
if (model.isVertex(cell) && this.graph.isCellVisible(cell)) {
if (cell.isVertex() && this.graph.isCellVisible(cell)) {
const conns = this.getEdges(cell);
let fanOut = 0;
let fanIn = 0;
@ -369,10 +369,10 @@ class mxHierarchicalLayout extends mxGraphLayout {
const { model } = this.graph;
let edges = [];
const isCollapsed = this.graph.isCellCollapsed(cell);
const childCount = model.getChildCount(cell);
const childCount = cell.getChildCount();
for (let i = 0; i < childCount; i += 1) {
const child = model.getChildAt(cell, i);
const child = cell.getChildAt(i);
if (this.isPort(child)) {
edges = edges.concat(model.getEdges(child, true, true));
@ -446,12 +446,10 @@ class mxHierarchicalLayout extends mxGraphLayout {
if (terminal != null) {
if (this.isPort(terminal)) {
terminal = this.graph.model.getParent(terminal);
terminal = terminal.getParent();
}
terminalCache.put(edge, terminal);
}
return terminal;
}
@ -577,7 +575,7 @@ class mxHierarchicalLayout extends mxGraphLayout {
const { model } = this.graph;
if (
model.isVertex(cell) &&
cell.isVertex() &&
cell !== this.parent &&
this.graph.isCellVisible(cell)
) {
@ -588,10 +586,10 @@ class mxHierarchicalLayout extends mxGraphLayout {
this.traverseAncestors ||
(cell === this.parent && this.graph.isCellVisible(cell))
) {
const childCount = model.getChildCount(cell);
const childCount = cell.getChildCount();
for (let i = 0; i < childCount; i += 1) {
const child = model.getChildAt(cell, i);
const child = cell.getChildAt(i);
// Ignore ports in the layout vertex list, they are dealt with
// in the traversal mechanisms

View File

@ -241,7 +241,7 @@ class mxSwimlaneLayout extends mxGraphLayout {
}
if (parent == null) {
parent = model.getParent(swimlanes[0]);
parent = swimlanes[0].getParent();
}
// Maintaining parent location
@ -250,7 +250,7 @@ class mxSwimlaneLayout extends mxGraphLayout {
if (
parent !== this.root &&
model.isVertex(parent) != null &&
parent.isVertex() != null &&
this.maintainParentLocation
) {
const geo = this.graph.getCellGeometry(parent);
@ -428,7 +428,7 @@ class mxSwimlaneLayout extends mxGraphLayout {
if (
cell != null &&
model.isVertex(cell) &&
cell.isVertex() &&
this.graph.isCellVisible(cell) &&
model.isAncestor(parent, cell)
) {
@ -491,10 +491,10 @@ class mxSwimlaneLayout extends mxGraphLayout {
const { model } = this.graph;
let edges = [];
const isCollapsed = this.graph.isCellCollapsed(cell);
const childCount = model.getChildCount(cell);
const childCount = cell.getChildCount();
for (let i = 0; i < childCount; i += 1) {
const child = model.getChildAt(cell, i);
const child = cell.getChildAt(i);
if (this.isPort(child)) {
edges = edges.concat(model.getEdges(child, true, true));
@ -576,12 +576,10 @@ class mxSwimlaneLayout extends mxGraphLayout {
if (terminal != null) {
if (this.isPort(terminal)) {
terminal = this.graph.model.getParent(terminal);
terminal = terminal.getParent();
}
terminalCache.put(edge, terminal);
}
return terminal;
}
@ -712,9 +710,9 @@ class mxSwimlaneLayout extends mxGraphLayout {
const { model } = this.graph;
if (
model.isVertex(cell) &&
cell.isVertex() &&
cell !== this.parent &&
model.getParent(cell) !== this.parent &&
cell.getParent() !== this.parent &&
this.graph.isCellVisible(cell)
) {
result[mxObjectIdentity.get(cell)] = cell;
@ -724,10 +722,10 @@ class mxSwimlaneLayout extends mxGraphLayout {
this.traverseAncestors ||
(cell === this.parent && this.graph.isCellVisible(cell))
) {
const childCount = model.getChildCount(cell);
const childCount = cell.getChildCount();
for (let i = 0; i < childCount; i += 1) {
const child = model.getChildAt(cell, i);
const child = cell.getChildAt(i);
// Ignore ports in the layout vertex list, they are dealt with
// in the traversal mechanisms

View File

@ -1370,11 +1370,11 @@ class mxCoordinateAssignment extends mxHierarchicalLayoutStage {
y += jetty;
let x = jettys[parallelEdgeCount * 4 + arrayOffset];
const modelSource = graph.model.getTerminal(realEdge, true);
const modelSource = realEdge.getTerminal(true);
if (
this.layout.isPort(modelSource) &&
graph.model.getParent(modelSource) === realSource
modelSource.getParent() === realSource
) {
const state = graph.view.getState(modelSource);
@ -1477,12 +1477,12 @@ class mxCoordinateAssignment extends mxHierarchicalLayoutStage {
const y = rankY - jetty;
let x = jettys[parallelEdgeCount * 4 + 2 - arrayOffset];
const modelTarget = graph.model.getTerminal(realEdge, false);
const modelTarget = realEdge.getTerminal(false);
const realTarget = this.layout.getVisibleTerminal(realEdge, false);
if (
this.layout.isPort(modelTarget) &&
graph.model.getParent(modelTarget) === realTarget
modelTarget.getParent() === realTarget
) {
const state = graph.view.getState(modelTarget);

View File

@ -103,10 +103,10 @@ class mxCircleLayout extends mxGraphLayout {
let top = null;
let left = null;
const vertices = [];
const childCount = model.getChildCount(parent);
const childCount = parent.getChildCount();
for (let i = 0; i < childCount; i += 1) {
const cell = model.getChildAt(parent, i);
const cell = parent.getChildAt(i);
if (!this.isVertexIgnored(cell)) {
vertices.push(cell);

View File

@ -254,7 +254,7 @@ class mxCompactTreeLayout extends mxGraphLayout {
if (
this.graph.getEdges(
parent,
model.getParent(parent),
parent.getParent(),
this.invert,
!this.invert,
false
@ -303,7 +303,7 @@ class mxCompactTreeLayout extends mxGraphLayout {
if (
parent !== this.root &&
model.isVertex(parent) != null &&
parent.isVertex() != null &&
this.maintainParentLocation
) {
const geo = this.graph.getCellGeometry(parent);
@ -536,7 +536,7 @@ class mxCompactTreeLayout extends mxGraphLayout {
: view.getVisibleTerminal(edge, this.invert);
const tmp = this.dfs(target, parent);
if (tmp != null && model.getGeometry(target) != null) {
if (tmp != null && target.getGeometry() != null) {
if (prev == null) {
node.child = tmp;
} else {
@ -853,14 +853,14 @@ class mxCompactTreeLayout extends mxGraphLayout {
apply(node, bounds) {
const model = this.graph.getModel();
const { cell } = node;
let g = model.getGeometry(cell);
let g = cell.getGeometry();
if (cell != null && g != null) {
if (this.isVertexMovable(cell)) {
g = this.setVertexLocation(cell, node.x, node.y);
if (this.resizeParent) {
const parent = model.getParent(cell);
const parent = cell.getParent();
const id = mxCellPath.create(parent);
// Implements set semantic

View File

@ -37,10 +37,10 @@ class mxEdgeLabelLayout extends mxGraphLayout {
// Gets all vertices and edges inside the parent
const edges = [];
const vertices = [];
const childCount = model.getChildCount(parent);
const childCount = parent.getChildCount();
for (let i = 0; i < childCount; i += 1) {
const cell = model.getChildAt(parent, i);
const cell = parent.getChildAt(i);
const state = view.getState(cell);
if (state != null) {
@ -117,7 +117,7 @@ class mxEdgeLabelLayout extends mxGraphLayout {
dx = 0;
}
let g = model.getGeometry(edge.cell);
let g = edge.cell.getGeometry();
if (g != null) {
g = g.clone();

View File

@ -150,12 +150,12 @@ class mxGraphLayout {
const result = func(vertex, edge);
if (result == null || result) {
const edgeCount = this.graph.model.getEdgeCount(vertex);
const edgeCount = vertex.getEdgeCount();
if (edgeCount > 0) {
for (let i = 0; i < edgeCount; i += 1) {
const e = this.graph.model.getEdgeAt(vertex, i);
const isSource = this.graph.model.getTerminal(e, true) === vertex;
const e = vertex.getEdgeAt(i);
const isSource = e.getTerminal(true) === vertex;
if (!directed || isSource) {
const next = this.graph.view.getVisibleTerminal(e, !isSource);
@ -178,7 +178,7 @@ class mxGraphLayout {
// isAncestor(parent: mxCell, child: mxCell, traverseAncestors?: boolean): boolean;
isAncestor(parent, child, traverseAncestors) {
if (!traverseAncestors) {
return this.graph.model.getParent(child) === parent;
return child.getParent() === parent;
}
if (child === parent) {
@ -186,7 +186,7 @@ class mxGraphLayout {
}
while (child != null && child !== parent) {
child = this.graph.model.getParent(child);
child = child.getParent();
}
return child === parent;
@ -213,7 +213,7 @@ class mxGraphLayout {
// isVertexIgnored(vertex: mxCell): boolean;
isVertexIgnored(vertex) {
return (
!this.graph.getModel().isVertex(vertex) ||
!vertex.isVertex() ||
!this.graph.isCellVisible(vertex)
);
}
@ -229,10 +229,10 @@ class mxGraphLayout {
const model = this.graph.getModel();
return (
!model.isEdge(edge) ||
!edge.isEdge() ||
!this.graph.isCellVisible(edge) ||
model.getTerminal(edge, true) == null ||
model.getTerminal(edge, false) == null
edge.getTerminal(true) == null ||
edge.getTerminal(false) == null
);
}
@ -268,15 +268,15 @@ class mxGraphLayout {
const model = this.graph.getModel();
if (model.isAncestor(this.parent, parent)) {
let parentGeo = model.getGeometry(parent);
let parentGeo = parent.getGeometry();
while (parent !== this.parent) {
result.x += parentGeo.x;
result.y += parentGeo.y;
parent = model.getParent(parent);
parent = parent.getParent();
parentGeo = model.getGeometry(parent);
parentGeo = parent.getGeometry();
}
}
}
@ -292,7 +292,7 @@ class mxGraphLayout {
setEdgePoints(edge, points) {
if (edge != null) {
const { model } = this.graph;
let geometry = model.getGeometry(edge);
let geometry = edge.getGeometry();
if (geometry == null) {
geometry = new mxGeometry();
@ -302,7 +302,7 @@ class mxGraphLayout {
}
if (this.parent != null && points != null) {
const parent = model.getParent(edge);
const parent = edge.getParent();
const parentOffset = this.getParentOffset(parent);
@ -331,7 +331,7 @@ class mxGraphLayout {
// setVertexLocation(cell: mxCell, x: number, y: number): mxRectangle;
setVertexLocation(cell, x, y) {
const model = this.graph.getModel();
let geometry = model.getGeometry(cell);
let geometry = cell.getGeometry();
let result = null;
if (geometry != null) {
@ -363,7 +363,7 @@ class mxGraphLayout {
}
if (this.parent != null) {
const parent = model.getParent(cell);
const parent = cell.getParent();
if (parent != null && parent !== this.parent) {
const parentOffset = this.getParentOffset(parent);
@ -391,7 +391,7 @@ class mxGraphLayout {
*/
// getVertexBounds(cell: mxCell): mxRectangle;
getVertexBounds(cell) {
let geo = this.graph.getModel().getGeometry(cell);
let geo = cell.getGeometry();
// Checks for oversize label bounding box and corrects
// the return value accordingly
@ -424,7 +424,7 @@ class mxGraphLayout {
}
if (this.parent != null) {
const parent = this.graph.getModel().getParent(cell);
const parent = this.cell.getParent();
geo = geo.clone();
if (parent != null && parent !== this.parent) {

View File

@ -122,10 +122,10 @@ class mxParallelEdgeLayout extends mxGraphLayout {
}
} else {
const model = this.graph.getModel();
const childCount = model.getChildCount(parent);
const childCount = parent.getChildCount();
for (let i = 0; i < childCount; i += 1) {
addCell(model.getChildAt(parent, i));
addCell(parent.getChildAt(i));
}
}
@ -181,8 +181,8 @@ class mxParallelEdgeLayout extends mxGraphLayout {
const edge = parallels[0];
const view = this.graph.getView();
const model = this.graph.getModel();
const src = model.getGeometry(view.getVisibleTerminal(edge, true));
const trg = model.getGeometry(view.getVisibleTerminal(edge, false));
const src = view.getVisibleTerminal(edge, true).getGeometry();
const trg = view.getVisibleTerminal(edge, false).getGeometry();
let x0;
let y0;

View File

@ -79,17 +79,17 @@ class mxPartitionLayout extends mxGraphLayout {
// moveCell(cell: mxCell, x: number, y: number): void;
moveCell(cell, x, y) {
const model = this.graph.getModel();
const parent = model.getParent(cell);
const parent = cell.getParent();
if (cell != null && parent != null) {
let i = 0;
let last = 0;
const childCount = model.getChildCount(parent);
const childCount = parent.getChildCount();
// Finds index of the closest swimlane
// TODO: Take into account the orientation
for (i = 0; i < childCount; i += 1) {
const child = model.getChildAt(parent, i);
const child = parent.getChildAt(i);
const bounds = this.getVertexBounds(child);
if (bounds != null) {
@ -119,7 +119,7 @@ class mxPartitionLayout extends mxGraphLayout {
execute(parent) {
const horizontal = this.isHorizontal();
const model = this.graph.getModel();
let pgeo = model.getGeometry(parent);
let pgeo = parent.getGeometry();
// Handles special case where the parent is either a layer with no
// geometry or the current root of the view in which case the size
@ -136,10 +136,10 @@ class mxPartitionLayout extends mxGraphLayout {
if (pgeo != null) {
const children = [];
const childCount = model.getChildCount(parent);
const childCount = parent.getChildCount();
for (let i = 0; i < childCount; i += 1) {
const child = model.getChildAt(parent, i);
const child = parent.getChildAt(i);
if (!this.isVertexIgnored(child) && this.isVertexMovable(child)) {
children.push(child);
@ -174,7 +174,7 @@ class mxPartitionLayout extends mxGraphLayout {
try {
for (let i = 0; i < n; i += 1) {
const child = children[i];
let geo = model.getGeometry(child);
let geo = child.getGeometry();
if (geo != null) {
geo = geo.clone();

View File

@ -160,13 +160,13 @@ class mxStackLayout extends mxGraphLayout {
// moveCell(cell: mxCell, x: number, y: number): void;
moveCell(cell, x, y) {
const model = this.graph.getModel();
const parent = model.getParent(cell);
const parent = cell.getParent();
const horizontal = this.isHorizontal();
if (cell != null && parent != null) {
let i = 0;
let last = 0;
const childCount = model.getChildCount(parent);
const childCount = parent.getChildCount();
let value = horizontal ? x : y;
const pstate = this.graph.getView().getState(parent);
@ -177,10 +177,10 @@ class mxStackLayout extends mxGraphLayout {
value /= this.graph.view.scale;
for (i = 0; i < childCount; i += 1) {
const child = model.getChildAt(parent, i);
const child = parent.getChildAt(i);
if (child !== cell) {
const bounds = model.getGeometry(child);
const bounds = child.getGeometry();
if (bounds != null) {
const tmp = horizontal
@ -210,7 +210,7 @@ class mxStackLayout extends mxGraphLayout {
// getParentSize(): void;
getParentSize(parent) {
const model = this.graph.getModel();
let pgeo = model.getGeometry(parent);
let pgeo = parent.getGeometry();
// Handles special case where the parent is either a layer with no
// geometry or the current root of the view in which case the size
@ -234,11 +234,11 @@ class mxStackLayout extends mxGraphLayout {
// getLayoutCells(parent: mxCell): Array<mxCell>;
getLayoutCells(parent) {
const model = this.graph.getModel();
const childCount = model.getChildCount(parent);
const childCount = parent.getChildCount();
const cells = [];
for (let i = 0; i < childCount; i += 1) {
const child = model.getChildAt(parent, i);
const child = parent.getChildAt(i);
if (!this.isVertexIgnored(child) && this.isVertexMovable(child)) {
cells.push(child);
@ -346,7 +346,7 @@ class mxStackLayout extends mxGraphLayout {
for (let i = 0; i < cells.length; i += 1) {
const child = cells[i];
let geo = model.getGeometry(child);
let geo = child.getGeometry();
if (geo != null) {
geo = geo.clone();

View File

@ -58,10 +58,10 @@ class mxGraphViewCodec extends mxObjectCodec {
encodeCell(enc, view, cell) {
const model = view.graph.getModel();
const state = view.getState(cell);
const parent = model.getParent(cell);
const parent = cell.getParent();
if (parent == null || state != null) {
const childCount = model.getChildCount(cell);
const childCount = cell.getChildCount();
const geo = view.graph.getCellGeometry(cell);
let name = null;
@ -69,11 +69,11 @@ class mxGraphViewCodec extends mxObjectCodec {
name = 'layer';
} else if (parent == null) {
name = 'graph';
} else if (model.isEdge(cell)) {
} else if (cell.isEdge()) {
name = 'edge';
} else if (childCount > 0 && geo != null) {
name = 'group';
} else if (model.isVertex(cell)) {
} else if (cell.isVertex()) {
name = 'vertex';
}
@ -158,7 +158,7 @@ class mxGraphViewCodec extends mxObjectCodec {
const childNode = this.encodeCell(
enc,
view,
model.getChildAt(cell, i)
cell.getChildAt(i)
);
if (childNode != null) {

View File

@ -65,7 +65,7 @@ class mxEffects {
if (
change.constructor !== mxGeometryChange ||
graph.model.isEdge(change.cell)
change.cell.isEdge()
) {
mxUtils.setOpacity(state.shape.node, (100 * step) / maxStep);
} else {
@ -126,10 +126,10 @@ class mxEffects {
// static cascadeOpacity(graph: mxGraph, cell: mxCell, opacity: number): void;
static cascadeOpacity(graph, cell, opacity) {
// Fades all children
const childCount = graph.model.getChildCount(cell);
const childCount = cell.getChildCount();
for (let i = 0; i < childCount; i += 1) {
const child = graph.model.getChildAt(cell, i);
const child = cell.getChildAt(i);
const childState = graph.getView().getState(child);
if (childState != null) {

View File

@ -142,7 +142,7 @@ class mxMorphing extends mxAnimation {
delta = this.getDelta(state);
if (
this.graph.getModel().isVertex(cell) &&
cell.isVertex() &&
(delta.x != 0 || delta.y != 0)
) {
const translate = this.graph.view.getTranslate();
@ -156,11 +156,11 @@ class mxMorphing extends mxAnimation {
}
if (recurse && !this.stopRecursion(state, delta)) {
const childCount = this.graph.getModel().getChildCount(cell);
const childCount = cell.getChildCount();
for (let i = 0; i < childCount; i += 1) {
this.animateCell(
this.graph.getModel().getChildAt(cell, i),
cell.getChildAt(i),
move,
recurse
);
@ -205,7 +205,7 @@ class mxMorphing extends mxAnimation {
let result = null;
if (cell != null) {
const parent = this.graph.getModel().getParent(cell);
const parent = this.cell.getParent();
const geo = this.graph.getCellGeometry(cell);
result = this.getOriginForCell(parent);

View File

@ -1075,9 +1075,9 @@ class mxEdgeStyle {
) {
const { graph } = state.view;
const sourceEdge =
source == null ? false : graph.getModel().isEdge(source.cell);
source == null ? false : source.cell.isEdge();
const targetEdge =
target == null ? false : graph.getModel().isEdge(target.cell);
target == null ? false : target.cell.isEdge();
const pts = mxEdgeStyle.scalePointArray(
state.absolutePoints,

View File

@ -69,11 +69,11 @@ class mxImageExport {
visitor(state, canvas);
const { graph } = state.view;
const childCount = graph.model.getChildCount(state.cell);
const childCount = state.cell.getChildCount();
for (let i = 0; i < childCount; i += 1) {
const childState = graph.view.getState(
graph.model.getChildAt(state.cell, i)
state.cell.getChildAt(i)
);
this.visitStatesRecursive(childState, canvas, visitor);
}

View File

@ -1964,7 +1964,7 @@ const mxUtils = {
for (let i = 0; i < cells.length; i += 1) {
if (cells[i] != null) {
const style = mxUtils.setStyle(
model.getStyle(cells[i]),
cells[i].getStyle(),
key,
value
);
@ -2067,7 +2067,7 @@ const mxUtils = {
for (let i = 0; i < cells.length; i += 1) {
if (cells[i] != null) {
const style = mxUtils.setStyleFlag(
model.getStyle(cells[i]),
cells[i].getStyle(),
key,
flag,
value

View File

@ -71,6 +71,11 @@ class mxCell {
}
}
// TODO: Document me!!!
getChildren(): mxCell[] {
return this.children || [];
}
// TODO: Document me!
// used by invalidate() of mxGraphView
invalidating: boolean = false;

View File

@ -548,7 +548,7 @@ class mxCellEditor {
if (state == null) {
this.stopEditing(true);
} else if (this.textarea != null) {
const isEdge = this.graph.getModel().isEdge(state.cell);
const isEdge = state.cell.isEdge();
const { scale } = this.graph.getView();
let m = null;
@ -1106,7 +1106,7 @@ class mxCellEditor {
*/
// getEditorBounds(state: mxCellState): mxRectangle;
getEditorBounds(state: mxCellState): mxRectangle | null {
const isEdge = this.graph.getModel().isEdge(state.cell);
const isEdge = state.cell.isEdge();
const { scale } = this.graph.getView();
const minSize = this.getMinimumSize(state);
const minWidth = minSize.width;
@ -1196,7 +1196,7 @@ class mxCellEditor {
}
// Applies the horizontal and vertical label positions
if (this.graph.getModel().isVertex(state.cell)) {
if (state.cell.isVertex()) {
const horizontal: string = <string>mxUtils.getStringValue(
state.style,
mxConstants.STYLE_LABEL_POSITION,

View File

@ -177,7 +177,7 @@ class mxCellOverlay extends mxEventSource {
*/
// getBounds(state: mxCellState): mxRectangle;
getBounds(state: mxCellState) {
const isEdge = state.view.graph.getModel().isEdge(state.cell);
const isEdge = state.cell.isEdge();
const s = state.view.scale;
let pt = null;

View File

@ -245,7 +245,7 @@ class mxCellRenderer {
getShapeConstructor(state: mxCellState) {
let ctor = this.getShape(state.style[mxConstants.STYLE_SHAPE]);
if (ctor == null) {
ctor = <typeof mxShape>(state.view.graph.getModel().isEdge(state.cell)
ctor = <typeof mxShape>(state.cell.isEdge()
? this.defaultEdgeShape
: this.defaultVertexShape);
}
@ -428,7 +428,7 @@ class mxCellRenderer {
// createLabel(state: mxCellState, value: string): void;
createLabel(state: mxCellState, value: any) {
const { graph } = state.view;
const isEdge = graph.getModel().isEdge(state.cell);
const isEdge = state.cell.isEdge();
if (state.style.fontSize > 0 || state.style.fontSize == null) {
// Avoids using DOM node for empty labels
@ -1138,7 +1138,7 @@ class mxCellRenderer {
getLabelBounds(state: mxCellState): mxRectangle {
const { graph } = state.view;
const { scale } = state.view;
const isEdge = graph.getModel().isEdge(state.cell);
const isEdge = state.cell.isEdge();
let bounds = new mxRectangle(
state.absoluteOffset.x,
state.absoluteOffset.y
@ -1339,7 +1339,7 @@ class mxCellRenderer {
// @ts-ignore
const bounds = shape.overlay.getBounds(state);
if (!state.view.graph.getModel().isEdge(state.cell)) {
if (!state.cell.isEdge()) {
if (state.shape != null && rot !== 0) {
let cx = bounds.getCenterX();
let cy = bounds.getCenterY();
@ -1423,7 +1423,7 @@ class mxCellRenderer {
let cx = state.getCenterX();
let cy = state.getCenterY();
if (!state.view.graph.getModel().isEdge(state.cell)) {
if (!state.cell.isEdge()) {
cx = state.x + w * s;
cy = state.y + h * s;
@ -1456,7 +1456,7 @@ class mxCellRenderer {
}
}
return state.view.graph.getModel().isEdge(state.cell)
return state.cell.isEdge()
? new mxRectangle(
Math.round(cx - (w / 2) * s),
Math.round(cy - (h / 2) * s),
@ -1649,7 +1649,7 @@ class mxCellRenderer {
state.shape == null &&
state.view.graph.container != null &&
state.cell !== state.view.currentRoot &&
(model.isVertex(state.cell) || model.isEdge(state.cell))
(state.cell.isVertex() || state.cell.isEdge())
) {
state.shape = this.createShape(state);

View File

@ -125,9 +125,9 @@ class mxCellStatePreview {
if (state != null) {
const model = this.graph.getModel();
if (model.isVertex(state.cell)) {
if (state.cell.isVertex()) {
(<mxGraphView>state.view).updateCellState(state);
const geo = model.getGeometry(state.cell);
const geo = state.cell.getGeometry();
// Moves selection cells and non-relative vertices in
// the first phase so that edge terminal points will
@ -142,11 +142,11 @@ class mxCellStatePreview {
}
}
const childCount = model.getChildCount(state.cell);
const childCount = state.cell.getChildCount();
for (let i = 0; i < childCount; i += 1) {
this.translateState(
<mxCellState>(state.view).getState(model.getChildAt(state.cell, i)),
<mxCellState>(state.view).getState(state.cell.getChildAt(i)),
dx,
dy
);
@ -175,21 +175,21 @@ class mxCellStatePreview {
// Updates the edge terminal points and restores the
// (relative) positions of any (relative) children
if (model.isEdge(state.cell)) {
if (state.cell.isEdge()) {
state.view.updateCellState(state);
}
const geo = this.graph.getCellGeometry(<mxCell>state.cell);
const pState = state.view.getState(model.getParent(<mxCell>state.cell));
const pState = state.view.getState(<mxCell>state.cell.getParent());
// Moves selection vertices which are relative
if (
(dx !== 0 || dy !== 0) &&
geo != null &&
geo.relative &&
model.isVertex(state.cell) &&
state.cell.isVertex() &&
(pState == null ||
model.isVertex(pState.cell) ||
pState.cell.isVertex() ||
this.deltas.get(state.cell) != null)
) {
state.x += dx;
@ -203,11 +203,11 @@ class mxCellStatePreview {
visitor(state);
}
const childCount = model.getChildCount(state.cell);
const childCount = state.cell.getChildCount();
for (let i = 0; i < childCount; i += 1) {
this.revalidateState(
this.graph.view.getState(model.getChildAt(state.cell, i)),
this.graph.view.getState(state.cell.getChildAt(i)),
dx,
dy,
visitor
@ -225,10 +225,10 @@ class mxCellStatePreview {
// addEdges(state: mxCellState): void;
addEdges(state: mxCellState): void {
const model = this.graph.getModel();
const edgeCount = model.getEdgeCount(<mxCell>state.cell);
const edgeCount = state.cell.getEdgeCount();
for (let i = 0; i < edgeCount; i += 1) {
const s = state.view.getState(model.getEdgeAt(<mxCell>state.cell, i));
const s = state.view.getState(<mxCell>state.cell.getEdgeAt(i));
if (s != null) {
this.moveState(s, 0, 0);

View File

@ -178,8 +178,8 @@ class mxMultiplicity {
*/
// checkNeighbors(graph: mxGraph, edge: mxCell, source: mxCell, target: mxCell): boolean;
checkNeighbors(graph, edge, source, target) {
const sourceValue = graph.model.getValue(source);
const targetValue = graph.model.getValue(target);
const sourceValue = source.getValue();
const targetValue = target.getValue();
let isValid = !this.validNeighborsAllowed;
const valid = this.validNeighbors;
@ -203,7 +203,7 @@ class mxMultiplicity {
*/
// checkTerminal(graph: mxGraph, terminal: mxCell, edge: mxCell): boolean;
checkTerminal(graph, terminal, edge) {
const value = graph.model.getValue(terminal);
const value = terminal.getValue();
return this.checkType(graph, value, this.type, this.attr, this.value);
}

File diff suppressed because it is too large Load Diff

View File

@ -406,9 +406,9 @@ class mxGraphModel extends mxEventSource {
}
// Visits the children of the cell
const childCount = this.getChildCount(parent);
const childCount = parent.getChildCount();
for (let i = 0; i < childCount; i += 1) {
const child = <mxCell>this.getChildAt(parent, i);
const child = <mxCell>parent.getChildAt(i);
result = result.concat(this.filterDescendants(filter, child));
}
@ -426,7 +426,7 @@ class mxGraphModel extends mxEventSource {
if (cell != null) {
while (cell != null) {
root = cell;
cell = this.getParent(cell);
cell = cell.getParent();
}
}
return root;
@ -490,8 +490,8 @@ class mxGraphModel extends mxEventSource {
* @param {mxCell} cell that represents the possible layer.
*/
// isLayer(cell: mxCell): boolean;
isLayer(cell: mxCell | null): boolean {
return this.isRoot(this.getParent(cell));
isLayer(cell: mxCell): boolean {
return this.isRoot(cell.getParent());
}
/**
@ -506,7 +506,7 @@ class mxGraphModel extends mxEventSource {
child: mxCell | null): boolean {
while (child != null && child !== parent) {
child = this.getParent(child);
child = <mxCell>child.getParent();
}
return child === parent;
}
@ -517,8 +517,8 @@ class mxGraphModel extends mxEventSource {
* @param {mxCell} cell that specifies the cell.
*/
// contains(cell: mxCell): boolean;
contains(cell: mxCell | null): boolean {
return this.isAncestor(this.root, cell);
contains(cell: mxCell): boolean {
return this.isAncestor(<mxCell>this.root, cell);
}
/**
@ -527,8 +527,9 @@ class mxGraphModel extends mxEventSource {
* @param {mxCell} cell whose parent should be returned.
*/
// getParent(cell: mxCell): mxCell;
getParent(cell: mxCell | null): mxCell | null {
return cell != null ? cell.getParent() : null;
getParent(cell: mxCell): mxCell | null {
// SLATED FOR DELETION
return cell.getParent();
}
/**
@ -549,10 +550,10 @@ class mxGraphModel extends mxEventSource {
if (child !== parent && parent != null && child != null) {
// Appends the child if no index was specified
if (index == null) {
index = this.getChildCount(parent);
index = parent.getChildCount();
}
const parentChanged = parent !== this.getParent(child);
const parentChanged = parent !== child.getParent();
this.execute(new mxChildChange(this, parent, child, index));
// Maintains the edges parents by moving the edges
@ -616,10 +617,10 @@ class mxGraphModel extends mxEventSource {
}
// Recursively processes child cells
const childCount = this.getChildCount(cell);
const childCount = cell.getChildCount();
for (let i = 0; i < childCount; i += 1) {
this.cellAdded(this.getChildAt(cell, i));
this.cellAdded(cell.getChildAt(i));
}
}
}
@ -645,25 +646,22 @@ class mxGraphModel extends mxEventSource {
*/
// updateEdgeParents(cell: mxCell, root: mxCell): void;
updateEdgeParents(cell: mxCell,
root: mxCell | null=null): void {
// Gets the topmost node of the hierarchy
root = root || this.getRoot(cell);
root: mxCell=<mxCell>this.getRoot(cell)): void {
// Updates edges on children first
const childCount = this.getChildCount(cell);
const childCount = cell.getChildCount();
for (let i = 0; i < childCount; i += 1) {
const child = <mxCell>this.getChildAt(cell, i);
const child = <mxCell>cell.getChildAt(i);
this.updateEdgeParents(child, root);
}
// Updates the parents of all connected edges
const edgeCount = this.getEdgeCount(cell);
const edgeCount = cell.getEdgeCount();
const edges = [];
for (let i = 0; i < edgeCount; i += 1) {
edges.push(this.getEdgeAt(cell, i));
edges.push(<mxCell>cell.getEdgeAt(i));
}
for (let i = 0; i < edges.length; i += 1) {
@ -686,50 +684,50 @@ class mxGraphModel extends mxEventSource {
* @param {mxCell} root that represents the current root of the model.
*/
// updateEdgeParent(edge: mxCell, root: mxCell): void;
updateEdgeParent(edge: mxCell | null,
root: mxCell | null): void {
updateEdgeParent(edge: mxCell,
root: mxCell): void {
let source = this.getTerminal(edge, true);
let target = this.getTerminal(edge, false);
let source = edge.getTerminal(true);
let target = edge.getTerminal(false);
let cell = null;
// Uses the first non-relative descendants of the source terminal
while (
source != null &&
!this.isEdge(source) &&
!source.isEdge() &&
source.geometry != null &&
source.geometry.relative
) {
source = this.getParent(source);
source = source.getParent();
}
// Uses the first non-relative descendants of the target terminal
while (
target != null &&
this.ignoreRelativeEdgeParent &&
!this.isEdge(target) &&
!target.isEdge() &&
target.geometry != null &&
target.geometry.relative
) {
target = this.getParent(target);
target = target.getParent();
}
if (this.isAncestor(root, source) && this.isAncestor(root, target)) {
if (source === target) {
cell = this.getParent(source);
cell = source ? source.getParent() : null;
} else {
cell = this.getNearestCommonAncestor(source, target);
}
if (
cell != null &&
(this.getParent(cell) !== this.root || this.isAncestor(cell, edge)) &&
this.getParent(edge) !== cell
(cell.getParent() !== this.root || this.isAncestor(cell, edge)) &&
edge && edge.getParent() !== cell
) {
let geo = this.getGeometry(edge);
let geo = edge.getGeometry();
if (geo != null) {
const origin1 = this.getOrigin(this.getParent(edge));
const origin1 = this.getOrigin(<mxCell>edge.getParent());
const origin2 = this.getOrigin(cell);
const dx = origin2.x - origin1.x;
@ -740,7 +738,7 @@ class mxGraphModel extends mxEventSource {
this.setGeometry(edge, geo);
}
this.add(cell, edge, this.getChildCount(cell));
this.add(cell, edge, cell.getChildCount());
}
}
}
@ -750,14 +748,14 @@ class mxGraphModel extends mxEventSource {
* given parent as an {@link mxPoint}.
*/
// getOrigin(cell: mxCell): mxPoint;
getOrigin(cell: mxCell | null): mxPoint {
getOrigin(cell: mxCell): mxPoint {
let result = null;
if (cell != null) {
result = this.getOrigin(this.getParent(cell));
result = this.getOrigin(<mxCell>cell.getParent());
if (!this.isEdge(cell)) {
const geo = this.getGeometry(cell);
if (!cell.isEdge()) {
const geo = cell.getGeometry();
if (geo != null) {
result.x += geo.x;
@ -780,40 +778,39 @@ class mxGraphModel extends mxEventSource {
getNearestCommonAncestor(cell1: mxCell | null,
cell2: mxCell | null): mxCell | null {
if (cell1 != null && cell2 != null) {
// Creates the cell path for the second cell
let path = mxCellPath.create(cell2);
// Creates the cell path for the second cell
let path = mxCellPath.create(<mxCell>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);
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(<mxCell>cell);
// Inverts arguments
if (path.length < current.length) {
cell = cell2;
const tmp = current;
current = path;
path = tmp;
// Inverts arguments
if (path.length < current.length) {
cell = cell2;
const tmp = current;
current = path;
path = tmp;
}
while (cell != null) {
const parent = <mxCell>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;
}
while (cell != null) {
const parent = <mxCell>this.getParent(cell);
// 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(<string>current);
cell = parent;
}
current = mxCellPath.getParentPath(<string>current);
cell = parent;
}
}
return null;
}
@ -828,10 +825,9 @@ class mxGraphModel extends mxEventSource {
remove(cell: mxCell) {
if (cell === this.root) {
this.setRoot(null);
} else if (this.getParent(cell) != null) {
} else if (cell.getParent() != null) {
this.execute(new mxChildChange(this, null, cell));
}
return cell;
}
@ -844,10 +840,10 @@ class mxGraphModel extends mxEventSource {
cellRemoved(cell: mxCell) {
if (cell != null && this.cells != null) {
// Recursively processes child cells
const childCount = this.getChildCount(cell);
const childCount = cell.getChildCount();
for (let i = childCount - 1; i >= 0; i--) {
this.cellRemoved(<mxCell>this.getChildAt(cell, i));
this.cellRemoved(<mxCell>cell.getChildAt(i));
}
// Removes the dictionary entry for the cell
@ -872,7 +868,7 @@ class mxGraphModel extends mxEventSource {
parent: mxCell | null,
index: number) {
const previous = <mxCell>this.getParent(cell);
const previous = <mxCell>cell.getParent();
if (parent != null) {
if (parent !== previous || previous.getIndex(cell) !== index) {
@ -884,7 +880,7 @@ class mxGraphModel extends mxEventSource {
}
// Adds or removes the cell from the model
const par = this.contains(parent);
const par = parent ? this.contains(parent) : null;
const pre = this.contains(previous);
if (par && !pre) {
@ -901,8 +897,9 @@ class mxGraphModel extends mxEventSource {
* @param {mxCell} cell whose number of children should be returned.
*/
// getChildCount(cell?: mxCell): number;
getChildCount(cell: mxCell | null) {
return cell != null ? cell.getChildCount() : 0;
getChildCount(cell: mxCell) {
// SLATED FOR DELETION
return cell.getChildCount();
}
/**
@ -912,9 +909,10 @@ class mxGraphModel extends mxEventSource {
* @param index Integer that specifies the index of the child to be returned.
*/
// getChildAt(cell: mxCell, index: number): mxCell;
getChildAt(cell: mxCell | null,
getChildAt(cell: mxCell,
index: number): mxCell | null {
return cell != null ? cell.getChildAt(index) : null;
// SLATED FOR DELETION
return cell.getChildAt(index);
}
/**
@ -924,8 +922,9 @@ class mxGraphModel extends mxEventSource {
* @param {mxCell} cell the represents the parent.
*/
// getChildren(cell: mxCell): Array<mxCell>;
getChildren(cell: mxCell): mxCell[] | null {
return cell != null ? cell.children : null;
getChildren(cell: mxCell): mxCell[] {
// SLATED FOR DELETION
return cell.children || [];
}
/**
@ -934,7 +933,7 @@ class mxGraphModel extends mxEventSource {
* @param {mxCell} cell whose child vertices should be returned.
*/
// getChildVertices(parent: mxCell): Array<mxCell>;
getChildVertices(parent: mxCell | null) {
getChildVertices(parent: mxCell) {
return this.getChildCells(parent, true, false);
}
@ -944,7 +943,7 @@ class mxGraphModel extends mxEventSource {
* @param {mxCell} cell whose child edges should be returned.
*/
// getChildEdges(parent: mxCell): Array<mxCell>;
getChildEdges(parent: mxCell | null): (mxCell | null)[] {
getChildEdges(parent: mxCell): mxCell[] {
return this.getChildCells(parent, false, true);
}
@ -959,20 +958,20 @@ class mxGraphModel extends mxEventSource {
* Default is false.
*/
// getChildCells(parent: mxCell, vertices: boolean, edges: boolean): Array<mxCell>;
getChildCells(parent: mxCell | null,
getChildCells(parent: mxCell,
vertices: boolean=false,
edges: boolean=false): (mxCell | null)[] {
edges: boolean=false): mxCell[] {
const childCount = this.getChildCount(parent);
const childCount = parent.getChildCount();
const result = [];
for (let i = 0; i < childCount; i += 1) {
const child = <mxCell>this.getChildAt(parent, i);
const child = <mxCell>parent.getChildAt(i);
if (
(!edges && !vertices) ||
(edges && this.isEdge(child)) ||
(vertices && this.isVertex(child))
(edges && child.isEdge()) ||
(vertices && child.isVertex())
) {
result.push(child);
}
@ -988,9 +987,10 @@ class mxGraphModel extends mxEventSource {
* @param isSource Boolean indicating which end of the edge should be returned.
*/
// getTerminal(edge: mxCell, isSource: boolean): mxCell;
getTerminal(edge: mxCell | null,
getTerminal(edge: mxCell,
isSource: boolean=false): mxCell | null {
return edge != null ? edge.getTerminal(isSource) : null;
// SLATED FOR DELETION
return edge.getTerminal(isSource);
}
/**
@ -1005,15 +1005,15 @@ class mxGraphModel extends mxEventSource {
* target terminal of the edge.
*/
// setTerminal(edge: mxCell, terminal: mxCell, isSource: boolean): mxCell;
setTerminal(edge: mxCell | null,
setTerminal(edge: mxCell,
terminal: mxCell | null,
isSource: boolean): mxCell | null {
const terminalChanged = terminal !== this.getTerminal(edge, isSource);
const terminalChanged = terminal !== edge.getTerminal(isSource);
this.execute(new mxTerminalChange(this, edge, terminal, isSource));
if (this.maintainEdgeParent && terminalChanged) {
this.updateEdgeParent(edge, this.getRoot());
this.updateEdgeParent(edge, <mxCell>this.getRoot());
}
return terminal;
}
@ -1027,7 +1027,7 @@ class mxGraphModel extends mxEventSource {
* @param {mxCell} target that specifies the new target terminal.
*/
// setTerminals(edge: mxCell, source: mxCell, target: mxCell): void;
setTerminals(edge: mxCell | null,
setTerminals(edge: mxCell,
source: mxCell | null,
target: mxCell | null): void {
@ -1050,11 +1050,11 @@ class mxGraphModel extends mxEventSource {
* target terminal of the edge.
*/
// terminalForCellChanged(edge: mxCell, terminal: mxCell, isSource: boolean): mxCell;
terminalForCellChanged(edge: mxCell | null,
terminalForCellChanged(edge: mxCell,
terminal: mxCell | null,
isSource: boolean=false): mxCell | null {
const previous = this.getTerminal(edge, isSource);
const previous = edge.getTerminal(isSource);
if (terminal != null) {
terminal.insertEdge(edge, isSource);
} else if (previous != null) {
@ -1070,7 +1070,8 @@ class mxGraphModel extends mxEventSource {
*/
// getEdgeCount(cell: mxCell): number;
getEdgeCount(cell: mxCell): number {
return cell != null ? cell.getEdgeCount() : 0;
// SLATED FOR DELETION
return cell.getEdgeCount();
}
/**
@ -1083,7 +1084,8 @@ class mxGraphModel extends mxEventSource {
// getEdgeAt(cell: mxCell, index: number): mxCell;
getEdgeAt(cell: mxCell,
index: number): mxCell | null {
return cell != null ? cell.getEdgeAt(index) : null;
// SLATED FOR DELETION
return cell.getEdgeAt(index);
}
/**
@ -1100,11 +1102,11 @@ class mxGraphModel extends mxEventSource {
outgoing: boolean,
ignoredEdge: mxCell | null=null): number {
let count = 0;
const edgeCount = this.getEdgeCount(cell);
const edgeCount = cell.getEdgeCount();
for (let i = 0; i < edgeCount; i += 1) {
const edge = this.getEdgeAt(cell, i);
if (edge !== ignoredEdge && this.getTerminal(edge, outgoing) === cell) {
const edge = cell.getEdgeAt(i);
if (edge !== ignoredEdge && edge && edge.getTerminal(outgoing) === cell) {
count += 1;
}
}
@ -1129,7 +1131,7 @@ class mxGraphModel extends mxEventSource {
*
*/
// getIncomingEdges(cell: mxCell): Array<mxCell>;
getIncomingEdges(cell: mxCell): (mxCell | null)[] {
getIncomingEdges(cell: mxCell): mxCell[] {
return this.getEdges(cell, true, false, false);
}
@ -1140,7 +1142,7 @@ class mxGraphModel extends mxEventSource {
*
*/
// getOutgoingEdges(cell: mxCell): Array<mxCell>;
getOutgoingEdges(cell: mxCell): (mxCell | null)[] {
getOutgoingEdges(cell: mxCell): mxCell[] {
return this.getEdges(cell, false, true, false);
}
@ -1164,13 +1166,13 @@ class mxGraphModel extends mxEventSource {
outgoing: boolean=true,
includeLoops: boolean=true) {
const edgeCount = this.getEdgeCount(cell);
const edgeCount = cell.getEdgeCount();
const result = [];
for (let i = 0; i < edgeCount; i += 1) {
const edge = this.getEdgeAt(cell, i);
const source = this.getTerminal(edge, true);
const target = this.getTerminal(edge, false);
const edge = <mxCell>cell.getEdgeAt(i);
const source = edge.getTerminal(true);
const target = edge.getTerminal(false);
if (
(includeLoops && source === target) ||
@ -1201,8 +1203,8 @@ class mxGraphModel extends mxEventSource {
target: mxCell,
directed: boolean=false) {
const tmp1 = this.getEdgeCount(source);
const tmp2 = this.getEdgeCount(target);
const tmp1 = source.getEdgeCount();
const tmp2 = target.getEdgeCount();
// Assumes the source has less connected edges
let terminal = source;
@ -1220,9 +1222,9 @@ class mxGraphModel extends mxEventSource {
// Checks if the edge is connected to the correct
// cell and returns the first match
for (let i = 0; i < edgeCount; i += 1) {
const edge = this.getEdgeAt(terminal, i);
const src = this.getTerminal(edge, true);
const trg = this.getTerminal(edge, false);
const edge = <mxCell>terminal.getEdgeAt(i);
const src = edge.getTerminal(true);
const trg = edge.getTerminal(false);
const directedMatch = src === source && trg === target;
const oppositeMatch = trg === source && src === target;
@ -1230,7 +1232,6 @@ class mxGraphModel extends mxEventSource {
result.push(edge);
}
}
return result;
}
@ -1254,37 +1255,34 @@ class mxGraphModel extends mxEventSource {
const terminals = [];
if (edges != null) {
for (let i = 0; i < edges.length; i += 1) {
const source = this.getTerminal(edges[i], true);
const target = this.getTerminal(edges[i], false);
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 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);
}
// 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;
}
@ -1307,22 +1305,20 @@ class mxGraphModel extends mxEventSource {
for (let i = 0; i < cells.length; i += 1) {
const cell = cells[i];
let topmost = true;
let parent = this.getParent(cell);
let parent = cell.getParent();
while (parent != null) {
if (dict.get(parent)) {
topmost = false;
break;
}
parent = this.getParent(parent);
parent = parent.getParent();
}
if (topmost) {
tmp.push(cell);
}
}
return tmp;
}
@ -1332,8 +1328,9 @@ class mxGraphModel extends mxEventSource {
* @param {mxCell} cell that represents the possible vertex.
*/
// isVertex(cell: mxCell): boolean;
isVertex(cell: mxCell | null): boolean {
return cell != null ? cell.isVertex() : false;
isVertex(cell: mxCell): boolean {
// SLATED FOR DELETION
return cell.isVertex();
}
/**
@ -1342,8 +1339,9 @@ class mxGraphModel extends mxEventSource {
* @param {mxCell} cell that represents the possible edge.
*/
// isEdge(cell: mxCell): boolean;
isEdge(cell: mxCell | null): boolean {
return cell != null ? cell.isEdge() : false;
isEdge(cell: mxCell): boolean {
// SLATED FOR DELETION
return cell.isEdge();
}
/**
@ -1354,8 +1352,9 @@ class mxGraphModel extends mxEventSource {
* @param {mxCell} cell whose connectable state should be returned.
*/
// isConnectable(cell: mxCell): boolean;
isConnectable(cell: mxCell | null) {
return cell != null ? cell.isConnectable() : false;
isConnectable(cell: mxCell) {
// SLATED FOR DELECTION
return cell.isConnectable();
}
/**
@ -1364,8 +1363,9 @@ class mxGraphModel extends mxEventSource {
* @param {mxCell} cell whose user object should be returned.
*/
// getValue(cell: mxCell): any;
getValue(cell: mxCell | null) {
return cell != null ? cell.getValue() : null;
getValue(cell: mxCell) {
// SLATED FOR DELETION
return cell.getValue();
}
/**
@ -1412,8 +1412,9 @@ class mxGraphModel extends mxEventSource {
* @param {mxCell} cell whose geometry should be returned.
*/
// getGeometry(cell: mxCell): mxGeometry;
getGeometry(cell: mxCell | null): mxGeometry | null {
return cell != null ? cell.getGeometry() : null;
getGeometry(cell: mxCell): mxGeometry | null {
// SLATED FOR DELETION
return cell.getGeometry();
}
/**
@ -1425,10 +1426,10 @@ class mxGraphModel extends mxEventSource {
* @param {mxGeometry} geometry that defines the new geometry.
*/
// setGeometry(cell: mxCell, geometry: mxGeometry): mxGeometry;
setGeometry(cell: mxCell | null,
setGeometry(cell: mxCell,
geometry: mxGeometry): mxGeometry {
if (geometry !== this.getGeometry(cell)) {
if (geometry !== cell.getGeometry()) {
this.execute(new mxGeometryChange(this, cell, geometry));
}
return geometry;
@ -1442,7 +1443,7 @@ class mxGraphModel extends mxEventSource {
geometryForCellChanged(cell: mxCell,
geometry: mxGeometry): mxGeometry | null {
const previous = this.getGeometry(cell);
const previous = cell.getGeometry();
cell.setGeometry(geometry);
return previous;
}
@ -1454,6 +1455,7 @@ class mxGraphModel extends mxEventSource {
*/
// getStyle(cell: mxCell): string | null;
getStyle(cell: mxCell | null): any {
// SLATED FOR DELETION
return cell != null ? cell.getStyle() : null;
}
@ -1469,7 +1471,7 @@ class mxGraphModel extends mxEventSource {
setStyle(cell: mxCell,
style: any): any {
if (style !== this.getStyle(cell)) {
if (style !== cell.getStyle()) {
this.execute(new mxStyleChange(this, cell, style));
}
return style;
@ -1487,7 +1489,7 @@ class mxGraphModel extends mxEventSource {
styleForCellChanged(cell: mxCell,
style: any): mxCell | null {
const previous = this.getStyle(cell);
const previous = cell.getStyle();
cell.setStyle(style);
return previous;
}
@ -1498,8 +1500,9 @@ class mxGraphModel extends mxEventSource {
* @param {mxCell} cell whose collapsed state should be returned.
*/
// isCollapsed(cell: mxCell): boolean;
isCollapsed(cell: mxCell | null): boolean {
return cell != null ? cell.isCollapsed() : false;
isCollapsed(cell: mxCell): boolean {
// SLATED FOR DELETION
return cell.isCollapsed();
}
/**
@ -1513,7 +1516,7 @@ class mxGraphModel extends mxEventSource {
setCollapsed(cell: mxCell,
collapsed: boolean): boolean {
if (collapsed !== this.isCollapsed(cell)) {
if (collapsed !== cell.isCollapsed()) {
this.execute(new mxCollapseChange(this, cell, collapsed));
}
return collapsed;
@ -1531,7 +1534,7 @@ class mxGraphModel extends mxEventSource {
collapsedStateForCellChanged(cell: mxCell,
collapsed: boolean): boolean {
const previous = this.isCollapsed(cell);
const previous = cell.isCollapsed();
cell.setCollapsed(collapsed);
return previous;
}
@ -1542,8 +1545,9 @@ class mxGraphModel extends mxEventSource {
* @param {mxCell} cell whose visible state should be returned.
*/
// isVisible(cell: mxCell): boolean;
isVisible(cell: mxCell | null): boolean {
return cell != null ? cell.isVisible() : false;
isVisible(cell: mxCell): boolean {
// SLATED FOR DELETION
return cell.isVisible();
}
/**
@ -1557,7 +1561,7 @@ class mxGraphModel extends mxEventSource {
setVisible(cell: mxCell,
visible: boolean) {
if (visible !== this.isVisible(cell)) {
if (visible !== cell.isVisible()) {
this.execute(new mxVisibleChange(this, cell, visible));
}
return visible;
@ -1574,7 +1578,7 @@ class mxGraphModel extends mxEventSource {
// visibleStateForCellChanged(cell: mxCell, visible: boolean): boolean;
visibleStateForCellChanged(cell: mxCell,
visible: boolean): boolean {
const previous = this.isVisible(cell);
const previous = cell.isVisible();
cell.setVisible(visible);
return previous;
}
@ -1740,14 +1744,14 @@ class mxGraphModel extends mxEventSource {
// cells in the target model
for (const key in mapping) {
const cell = mapping[key];
let terminal = this.getTerminal(cell, true);
let terminal = cell.getTerminal(true);
if (terminal != null) {
terminal = mapping[mxCellPath.create(terminal)];
this.setTerminal(cell, terminal, true);
}
terminal = this.getTerminal(cell, false);
terminal = cell.getTerminal(false);
if (terminal != null) {
terminal = mapping[mxCellPath.create(terminal)];
@ -1781,7 +1785,7 @@ class mxGraphModel extends mxEventSource {
if (typeof cell.getId === 'function') {
const id: string = <string>cell.getId();
let target =
id != null && (!this.isEdge(cell) || !cloneAllEdges)
id != null && (!cell.isEdge() || !cloneAllEdges)
? this.getCell(id)
: null;
@ -1828,8 +1832,7 @@ class mxGraphModel extends mxEventSource {
const dict = new mxDictionary();
for (const cell of cells) {
const parent = this.getParent(cell);
const parent = cell.getParent();
if (parent != null && !dict.get(parent)) {
dict.put(parent, true);
parents.push(parent);
@ -1872,21 +1875,17 @@ class mxGraphModel extends mxEventSource {
// cloneCells(cells: Array<mxCell>, includeChildren?: boolean, mapping?: any): Array<mxCell>;
cloneCells(cells: mxCell[],
includeChildren: boolean=true,
mapping: any={}): (mxCell | null)[] {
mapping: any={}): mxCell[] {
const clones: (mxCell | null)[] = [];
const clones: mxCell[] = [];
for (let i = 0; i < cells.length; i += 1) {
if (cells[i] != null) {
clones.push(this.cloneCellImpl(cells[i], mapping, includeChildren));
} else {
clones.push(null);
}
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);
this.restoreClone(<mxCell>clones[i], cells[i], mapping);
}
}
return clones;
@ -1904,15 +1903,15 @@ class mxGraphModel extends mxEventSource {
let clone = mapping ? mapping[ident] : null;
if (clone == null) {
clone = this.cellCloned(cell);
clone = cell.clone();
mapping[ident] = clone;
if (includeChildren) {
const childCount = this.getChildCount(cell);
const childCount = cell.getChildCount();
for (let i = 0; i < childCount; i += 1) {
const cloneChild = this.cloneCellImpl(
<mxCell>this.getChildAt(cell, i),
<mxCell>cell.getChildAt(i),
mapping,
true
);
@ -1929,6 +1928,7 @@ class mxGraphModel extends mxEventSource {
*/
// cellCloned(cell: mxCell): mxCell;
cellCloned(cell: mxCell): mxCell {
// SLATED FOR DELETION
return cell.clone();
}
@ -1937,11 +1937,11 @@ class mxGraphModel extends mxEventSource {
* a network of cloned cells.
*/
// restoreClone(clone: mxCell, cell: mxCell, mapping?: any): void;
restoreClone(clone: mxCell | null,
cell: mxCell | null,
restoreClone(clone: mxCell,
cell: mxCell,
mapping: any): void {
const source = this.getTerminal(cell, true);
const source = cell.getTerminal(true);
if (source != null) {
const tmp = mapping[mxObjectIdentity.get(source)];
@ -1950,7 +1950,7 @@ class mxGraphModel extends mxEventSource {
}
}
const target = this.getTerminal(cell, false);
const target = cell.getTerminal(false);
if (target != null) {
const tmp = mapping[mxObjectIdentity.get(target)];
if (tmp != null) {
@ -1958,11 +1958,11 @@ class mxGraphModel extends mxEventSource {
}
}
const childCount = this.getChildCount(clone);
const childCount = clone.getChildCount();
for (let i = 0; i < childCount; i += 1) {
this.restoreClone(
this.getChildAt(clone, i),
this.getChildAt(cell, i),
<mxCell>clone.getChildAt(i),
<mxCell>cell.getChildAt(i),
mapping
);
}

View File

@ -10,7 +10,7 @@ import mxEventSource from '../../util/event/mxEventSource';
import mxEventObject from '../../util/event/mxEventObject';
import mxClient from '../../mxClient';
import mxUtils from '../../util/mxUtils';
import mxSelectionChange from './mxSelectionChange';
import mxSelectionChange from '../../atomic_changes/mxSelectionChange';
import mxEvent from '../../util/event/mxEvent';
import mxCell from '../cell/mxCell';
import mxGraph from './mxGraph';

View File

@ -25,7 +25,7 @@ import mxStyleRegistry from '../../util/datatypes/style/mxStyleRegistry';
import mxGraph from './mxGraph';
import mxCell from '../cell/mxCell';
import mxImage from '../../util/image/mxImage';
import mxCurrentRootChange from './mxCurrentRootChange';
import mxCurrentRootChange from '../../atomic_changes/mxCurrentRootChange';
import mxGraphModel from './mxGraphModel';
import mxShape from '../../shape/mxShape';
import mxGeometry from "../../util/datatypes/mxGeometry";
@ -371,10 +371,8 @@ class mxGraphView extends mxEventSource {
let result = null;
if (cells != null && cells.length > 0) {
const model = (<mxGraph>this.graph).getModel();
for (let i = 0; i < cells.length; i += 1) {
if (model.isVertex(cells[i]) || model.isEdge(cells[i])) {
if (cells[i].isVertex() || cells[i].isEdge()) {
const state = this.getState(cells[i]);
if (state != null) {
@ -497,22 +495,20 @@ class mxGraphView extends mxEventSource {
* @param force Boolean indicating if the current root should be ignored for
* recursion.
*/
// clear(cell?: mxCell, force?: boolean, recurse?: boolean): void;
// clear(cell: mxCell, force?: boolean, recurse?: boolean): void;
clear(
cell: mxCell | null = null,
cell: mxCell=<mxCell>(<mxGraph>this.graph).getModel().getRoot(),
force: boolean = false,
recurse: boolean = true
) {
const model: mxGraphModel = (<mxGraph>this.graph).getModel();
cell = cell || model.getRoot();
this.removeState(<mxCell>cell);
if (recurse && (force || cell != this.currentRoot)) {
const childCount: number = model.getChildCount(cell);
const childCount: number = cell.getChildCount();
for (let i = 0; i < childCount; i += 1) {
this.clear(model.getChildAt(cell, i), force);
this.clear(<mxCell>cell.getChildAt(i), force);
}
} else {
this.invalidate(cell);
@ -547,20 +543,20 @@ class mxGraphView extends mxEventSource {
// Recursively invalidates all descendants
if (recurse) {
const childCount = model.getChildCount(cell);
const childCount = cell.getChildCount();
for (let i = 0; i < childCount; i += 1) {
const child = model.getChildAt(cell, i);
const child = cell.getChildAt(i);
this.invalidate(child, recurse, includeEdges);
}
}
// Propagates invalidation to all connected edges
if (includeEdges) {
const edgeCount = model.getEdgeCount(cell);
const edgeCount = cell.getEdgeCount();
for (let i = 0; i < edgeCount; i += 1) {
this.invalidate(model.getEdgeAt(cell, i), recurse, includeEdges);
this.invalidate(cell.getEdgeAt(i), recurse, includeEdges);
}
}
@ -577,7 +573,7 @@ class mxGraphView extends mxEventSource {
* Default is {@link currentRoot} or the root of the model.
*/
// validate(cell?: mxCell): void;
validate(cell: mxCell | null = null) {
validate(cell: mxCell | null=null) {
const t0 = mxLog.enter('mxGraphView.validate');
window.status =
mxResources.get(this.updatingDocumentResource) ||
@ -588,10 +584,10 @@ class mxGraphView extends mxEventSource {
const graphBounds = this.getBoundingBox(
this.validateCellState(
<mxCell>this.validateCell(
cell ||
<mxCell>(cell ||
(this.currentRoot != null
? this.currentRoot
: (<mxGraph>this.graph).getModel().getRoot())
: (<mxGraph>this.graph).getModel().getRoot()))
)
)
);
@ -646,11 +642,11 @@ class mxGraphView extends mxEventSource {
if (recurse) {
const model = (<mxGraph>this.graph).getModel();
const childCount = model.getChildCount(state.cell);
const childCount = state.cell.getChildCount();
for (let i = 0; i < childCount; i += 1) {
const bounds = this.getBoundingBox(
this.getState(model.getChildAt(state.cell, i))
this.getState(state.cell.getChildAt(i))
);
if (bounds != null) {
@ -847,26 +843,24 @@ class mxGraphView extends mxEventSource {
* is true.
*/
// validateCell(cell: mxCell, visible?: boolean): void;
validateCell(cell: mxCell | null=null,
validateCell(cell: mxCell,
visible: boolean = true): mxCell | null {
if (cell != null) {
visible = visible && (<mxGraph>this.graph).isCellVisible(cell);
const state = this.getState(cell, visible);
visible = visible && cell.isVisible();
const state = this.getState(cell, visible);
if (state != null && !visible) {
this.removeState(cell);
} else {
const model = (<mxGraph>this.graph).getModel();
const childCount = model.getChildCount(cell);
if (state != null && !visible) {
this.removeState(cell);
} else {
const model = (<mxGraph>this.graph).getModel();
const childCount = cell.getChildCount();
for (let i = 0; i < childCount; i += 1) {
this.validateCell(
<mxCell>model.getChildAt(cell, i),
visible &&
(!this.isCellCollapsed(cell) || cell === this.currentRoot)
);
}
for (let i = 0; i < childCount; i += 1) {
this.validateCell(
<mxCell>cell.getChildAt(i),
visible &&
(!this.isCellCollapsed(cell) || cell === this.currentRoot)
);
}
}
return cell;
@ -899,7 +893,7 @@ class mxGraphView extends mxEventSource {
}
if (cell !== this.currentRoot) {
this.validateCellState(<mxCell>model.getParent(cell), false);
this.validateCellState(<mxCell>cell.getParent(), false);
}
state.setVisibleTerminalState(
@ -928,9 +922,9 @@ class mxGraphView extends mxEventSource {
this.stateValidated(state);
}
const childCount = model.getChildCount(cell);
const childCount = cell.getChildCount();
for (let i = 0; i < childCount; i += 1) {
this.validateCellState(<mxCell>model.getChildAt(cell, i));
this.validateCellState(<mxCell>cell.getChildAt(i));
}
}
}
@ -957,7 +951,7 @@ class mxGraphView extends mxEventSource {
if (state.cell !== this.currentRoot) {
const model = (<mxGraph>this.graph).getModel();
const pState = <mxCellState>this.getState(model.getParent(state.cell));
const pState = <mxCellState>this.getState(state.cell.getParent());
if (pState != null && pState.cell !== this.currentRoot) {
origin.x += (<mxPoint>pState.origin).x;
@ -974,11 +968,11 @@ class mxGraphView extends mxEventSource {
const geo = (<mxGraph>this.graph).getCellGeometry(<mxCell>state.cell);
if (geo != null) {
if (!model.isEdge(state.cell)) {
if (!state.cell.isEdge()) {
offset = <mxPoint>(geo.offset != null ? geo.offset : this.EMPTY_POINT);
if (geo.relative && pState != null) {
if (model.isEdge(pState.cell)) {
if (pState.cell.isEdge()) {
const origin = this.getPoint(pState, geo);
if (origin != null) {
@ -1006,11 +1000,11 @@ class mxGraphView extends mxEventSource {
state.height = this.scale * geo.height;
state.unscaledHeight = geo.height;
if (model.isVertex(state.cell)) {
if (state.cell.isVertex()) {
this.updateVertexState(state, geo);
}
if (model.isEdge(state.cell)) {
if (state.cell.isEdge()) {
this.updateEdgeState(state, geo);
}
}
@ -1021,7 +1015,7 @@ class mxGraphView extends mxEventSource {
/**
* Returns true if the children of the given cell should not be visible in the
* view. This implementation uses {@link mxGraph.isCellVisible} but it can be
* view. This implementation uses {@link mxCell.isCellVisible} but it can be
* overidden to use a separate condition.
*/
// isCellCollapsed(cell: mxCell): boolean;
@ -1037,9 +1031,9 @@ class mxGraphView extends mxEventSource {
geo: mxGeometry) {
const model = (<mxGraph>this.graph).getModel();
const pState = this.getState(model.getParent(state.cell));
const pState = this.getState(state.cell.getParent());
if (geo.relative && pState != null && !model.isEdge(pState.cell)) {
if (geo.relative && pState != null && !pState.cell.isEdge()) {
const alpha = mxUtils.toRadians(
pState.style[mxConstants.STYLE_ROTATION] || '0'
);
@ -1071,10 +1065,10 @@ class mxGraphView extends mxEventSource {
// as such edges are invalid and produce NPEs in the edge styles.
// Also removes connected edges that have no visible terminals.
if (
((<mxGraphModel>(<mxGraph>this.graph).model).getTerminal(state.cell, true) != null &&
(state.cell.getTerminal(true) != null &&
source == null) ||
(source == null && geo.getTerminalPoint(true) == null) ||
((<mxGraphModel>(<mxGraph>this.graph).model).getTerminal(state.cell, false) != null &&
(state.cell.getTerminal(false) != null &&
target == null) ||
(target == null && geo.getTerminalPoint(false) == null)
) {
@ -1200,9 +1194,9 @@ class mxGraphView extends mxEventSource {
stateValidated(state: mxCellState): void {
const graph = (<mxGraph>this.graph);
const fg =
(graph.getModel().isEdge(state.cell) &&
(state.cell.isEdge() &&
graph.keepEdgesInForeground) ||
(graph.getModel().isVertex(<mxCell>state.cell) &&
(state.cell.isVertex() &&
graph.keepEdgesInBackground);
const htmlNode = fg
? this.lastForegroundHtmlNode || this.lastHtmlNode
@ -1651,7 +1645,7 @@ class mxGraphView extends mxEventSource {
let flipH = false;
let flipV = false;
if ((<mxGraphModel>(<mxGraph>this.graph).model).isVertex(terminal.cell)) {
if (terminal.cell.isVertex()) {
flipH =
mxUtils.getValue(terminal.style, mxConstants.STYLE_FLIPH, 0) == 1;
flipV =
@ -1835,26 +1829,26 @@ class mxGraphView extends mxEventSource {
* should be returned.
*/
// getVisibleTerminal(edge: mxCell, source: boolean): mxCell;
getVisibleTerminal(edge: mxCell | null,
getVisibleTerminal(edge: mxCell,
source: boolean) {
const model = (<mxGraph>this.graph).getModel();
let result = model.getTerminal(edge, source);
let result = edge.getTerminal(source);
let best = result;
while (result != null && result != this.currentRoot) {
if (!(<mxGraph>this.graph).isCellVisible(best) || this.isCellCollapsed(result)) {
if ((best && !best.isVisible()) || this.isCellCollapsed(result)) {
best = result;
}
result = model.getParent(result);
result = result.getParent();
}
// Checks if the result is valid for the current view state
if (
best != null &&
(!model.contains(best) ||
model.getParent(best) === model.getRoot() ||
best.getParent() === model.getRoot() ||
best === this.currentRoot)
) {
best = null;
@ -2007,7 +2001,7 @@ class mxGraphView extends mxEventSource {
y: number) {
const model = (<mxGraph>this.graph).getModel();
const geometry = model.getGeometry(edgeState.cell);
const geometry = edgeState.cell.getGeometry();
if (geometry != null) {
const absolutePoints = (<mxPoint[]>edgeState.absolutePoints);
@ -2168,7 +2162,7 @@ class mxGraphView extends mxEventSource {
if (
create &&
(state == null || this.updateStyle) &&
(<mxGraph>this.graph).isCellVisible(cell)
cell.isVisible()
) {
if (state == null) {
state = this.createState(cell);
@ -2521,7 +2515,7 @@ class mxGraphView extends mxEventSource {
}
if (root != null && root.parentNode != null) {
this.clear(this.currentRoot, true);
this.clear(<mxCell>this.currentRoot, true);
mxEvent.removeGestureListeners(
document,
null,

View File

@ -243,7 +243,7 @@ class mxLayoutManager extends mxEventSource {
for (let i = 0; i < cells.length; i += 1) {
const layout = this.getLayout(
model.getParent(cells[i]),
cells[i].getParent(),
mxEvent.MOVE_CELLS
);
@ -271,7 +271,7 @@ class mxLayoutManager extends mxEventSource {
for (let i = 0; i < cells.length; i += 1) {
const layout = this.getLayout(
model.getParent(cells[i]),
cells[i].getParent(),
mxEvent.RESIZE_CELLS
);
if (layout != null) {
@ -349,7 +349,7 @@ class mxLayoutManager extends mxEventSource {
if (this.isBubbling()) {
const model = (<mxGraph>this.getGraph()).getModel();
this.addAncestorsWithLayout(<mxCell>model.getParent(cell), result);
this.addAncestorsWithLayout(<mxCell>cell.getParent(), result);
}
}
return result;
@ -363,8 +363,8 @@ class mxLayoutManager extends mxEventSource {
if (cell != null && this.hasLayout(cell)) {
const model = (<mxGraph>this.getGraph()).getModel();
for (let i = 0; i < model.getChildCount(cell); i += 1) {
const child = <mxCell>model.getChildAt(cell, i);
for (let i = 0; i < cell.getChildCount(); i += 1) {
const child = <mxCell>cell.getChildAt(i);
if (this.hasLayout(child)) {
result.push(child);

View File

@ -245,17 +245,16 @@ class mxSwimlaneManager extends mxEventSource {
*/
// swimlaneAdded(swimlane: mxCell): void;
swimlaneAdded(swimlane: mxCell): void {
const model = (<mxGraph>this.getGraph()).getModel();
const parent = model.getParent(swimlane);
const childCount = model.getChildCount(parent);
const parent = <mxCell>swimlane.getParent();
const childCount = parent.getChildCount();
let geo = null;
// Finds the first valid sibling swimlane as reference
for (let i = 0; i < childCount; i += 1) {
const child = <mxCell>model.getChildAt(parent, i);
const child = <mxCell>parent.getChildAt(i);
if (child !== swimlane && !this.isSwimlaneIgnored(child)) {
geo = model.getGeometry(child);
geo = child.getGeometry();
if (geo != null) {
break;
}
@ -286,7 +285,7 @@ class mxSwimlaneManager extends mxEventSource {
// Finds the top-level swimlanes and adds offsets
for (const cell of cells) {
if (!this.isSwimlaneIgnored(cell)) {
const geo = model.getGeometry(cell);
const geo = cell.getGeometry();
if (geo != null) {
const size = new mxRectangle(0, 0, geo.width, geo.height);
@ -295,7 +294,7 @@ class mxSwimlaneManager extends mxEventSource {
while (current != null) {
top = current;
current = <mxCell>model.getParent(current);
current = <mxCell>current.getParent();
const tmp = (<mxGraph>this.graph).isSwimlane(current)
? (<mxGraph>this.graph).getStartSize(current)
: new mxRectangle();
@ -342,7 +341,7 @@ class mxSwimlaneManager extends mxEventSource {
const horizontal = this.isCellHorizontal(swimlane);
if (!this.isSwimlaneIgnored(swimlane)) {
let geo = <mxGeometry>model.getGeometry(swimlane);
let geo = <mxGeometry>swimlane.getGeometry();
if (geo != null) {
if (
@ -368,10 +367,10 @@ class mxSwimlaneManager extends mxEventSource {
w -= tmp.width;
h -= tmp.height;
const childCount = model.getChildCount(swimlane);
const childCount = swimlane.getChildCount();
for (let i = 0; i < childCount; i += 1) {
const child = <mxCell>model.getChildAt(swimlane, i);
const child = <mxCell>swimlane.getChildAt(i);
this.resizeSwimlane(child, w, h, horizontal);
}
} finally {

View File

@ -57,7 +57,7 @@ class EdgeTolerance extends React.Component {
}
const cell = this.getCellAt(me.graphX, me.graphY);
if (this.getModel().isEdge(cell)) {
if (cell.isEdge()) {
me.state = this.view.getState(cell);
if (me.state != null && me.state.shape != null) {

View File

@ -144,7 +144,7 @@ class FixedPoints extends React.Component {
}
getAllConnectionConstraints(terminal) {
if (terminal != null && this.model.isVertex(terminal.cell)) {
if (terminal != null && terminal.cell.isVertex()) {
return [
new mxConnectionConstraint(new mxPoint(0, 0), true),
new mxConnectionConstraint(new mxPoint(0.5, 0), true),

View File

@ -66,11 +66,11 @@ class HelloPort extends React.Component {
// Implements a tooltip that shows the actual
// source and target of an edge
graph.getTooltipForCell = function(cell) {
if (this.model.isEdge(cell)) {
if (cell.isEdge()) {
return `${this.convertValueToString(
this.model.getTerminal(cell, true)
cell.getTerminal(true)
)} => ${this.convertValueToString(
this.model.getTerminal(cell, false)
cell.getTerminal(false)
)}`;
}

View File

@ -139,7 +139,7 @@ class PortRefs extends React.Component {
if (terminal.shape.stencil != null) {
return terminal.shape.stencil.constraints;
}
} else if (terminal != null && this.model.isVertex(terminal.cell)) {
} else if (terminal != null && terminal.cell.isVertex()) {
if (terminal.shape != null) {
const ports = terminal.shape.getPorts();
const cstrs = new Array();

View File

@ -52,7 +52,7 @@ class Clipboard extends React.Component {
mxClipboard.cellsToString = function(cells) {
const codec = new mxCodec();
const model = new mxGraphModel();
const parent = model.getChildAt(model.getRoot(), 0);
const parent = model.getRoot().getChildAt(0);
for (let i = 0; i < cells.length; i++) {
model.add(parent, cells[i]);
@ -200,16 +200,14 @@ class Clipboard extends React.Component {
const codec = new mxCodec(node.ownerDocument);
codec.decode(node, model);
const childCount = model.getChildCount(model.getRoot());
const targetChildCount = graph.model.getChildCount(
graph.model.getRoot()
);
const childCount = model.getRoot().getChildCount();
const targetChildCount = graph.model.getRoot().getChildCount();
// Merges existing layers and adds new layers
graph.model.beginUpdate();
try {
for (let i = 0; i < childCount; i++) {
let parent = model.getChildAt(model.getRoot(), i);
let parent = model.getRoot().getChildAt(i);
// Adds cells to existing layers if not locked
if (targetChildCount > i) {
@ -217,10 +215,10 @@ class Clipboard extends React.Component {
const target =
childCount === 1
? graph.getDefaultParent()
: graph.model.getChildAt(graph.model.getRoot(), i);
: graph.model.getRoot().getChildAt(i);
if (!graph.isCellLocked(target)) {
const children = model.getChildren(parent);
const children = parent.getChildren();
cells = cells.concat(
graph.importCells(children, dx, dy, target)
);
@ -233,7 +231,7 @@ class Clipboard extends React.Component {
0,
graph.model.getRoot()
)[0];
const children = graph.model.getChildren(parent);
const children = parent.getChildren();
graph.moveCells(children, dx, dy);
cells = cells.concat(children);
}

View File

@ -51,10 +51,10 @@ class Boundary extends React.Component {
// Removes folding icon for relative children
isCellFoldable(cell, collapse) {
const childCount = this.model.getChildCount(cell);
const childCount = cell.getChildCount();
for (let i = 0; i < childCount; i++) {
const child = this.model.getChildAt(cell, i);
const child = cell.getChildAt(i);
const geo = this.getCellGeometry(child);
if (geo != null && geo.relative) {
@ -69,12 +69,12 @@ class Boundary extends React.Component {
getRelativePosition(state, dx, dy) {
if (state != null) {
const model = graph.getModel();
const geo = model.getGeometry(state.cell);
const geo = state.cell.getGeometry();
if (geo != null && geo.relative && !model.isEdge(state.cell)) {
const parent = model.getParent(state.cell);
if (geo != null && geo.relative && !state.cell.isEdge()) {
const parent = state.cell.getParent();
if (model.isVertex(parent)) {
if (parent.isVertex()) {
const pstate = graph.view.getState(parent);
if (pstate != null) {
@ -116,7 +116,7 @@ class Boundary extends React.Component {
);
if (rel != null) {
let geo = this.model.getGeometry(cell);
let geo = cell.getGeometry();
if (geo != null && geo.relative) {
geo = geo.clone();
@ -164,7 +164,7 @@ class Boundary extends React.Component {
if (rel != null) {
const pstate = this.graph.view.getState(
this.graph.model.getParent(state.cell)
state.cell.getParent()
);
if (pstate != null) {

File diff suppressed because one or more lines are too long

View File

@ -161,7 +161,7 @@ class ContextIcons extends React.Component {
class MyCustomGraph extends mxGraph {
createHandler(state) {
if (state != null && this.model.isVertex(state.cell)) {
if (state != null && state.cell.isVertex()) {
return new mxVertexToolHandler(state);
}
return super.createHandler(state);

View File

@ -58,7 +58,7 @@ class Control extends React.Component {
const { graph } = state.view;
if (graph.getModel().isVertex(state.cell)) {
if (state.cell.isVertex()) {
if (state.deleteControl == null) {
const b = new mxRectangle(
0,
@ -91,7 +91,7 @@ class Control extends React.Component {
const h = state.deleteControl.bounds.height / oldScale;
const s = state.view.scale;
return state.view.graph.getModel().isEdge(state.cell)
return state.cell.isEdge()
? new mxRectangle(
state.x + state.width / 2 - (w / 2) * s,
state.y + state.height / 2 - (h / 2) * s,

View File

@ -158,7 +158,7 @@ class HoverIcons extends React.Component {
// Ignore everything but vertices
if (
graph.isMouseDown ||
(tmp != null && !graph.getModel().isVertex(tmp.cell))
(tmp != null && !tmp.cell.isVertex())
) {
tmp = null;
}

View File

@ -60,7 +60,7 @@ class Labels extends React.Component {
};
graph.isCellResizable = function(cell) {
const geo = this.model.getGeometry(cell);
const geo = cell.getGeometry();
return geo == null || !geo.relative;
};
@ -68,14 +68,14 @@ class Labels extends React.Component {
// Truncates the label to the size of the vertex
graph.getLabel = function(cell) {
const label = this.labelsVisible ? this.convertValueToString(cell) : '';
const geometry = this.model.getGeometry(cell);
const geometry = cell.getGeometry();
if (
!this.model.isCollapsed(cell) &&
!cell.isCollapsed() &&
geometry != null &&
(geometry.offset == null ||
(geometry.offset.x == 0 && geometry.offset.y == 0)) &&
this.model.isVertex(cell) &&
cell.isVertex() &&
geometry.width >= 2
) {
const style = this.getCellStyle(cell);
@ -93,12 +93,12 @@ class Labels extends React.Component {
// Enables wrapping for vertex labels
graph.isWrapping = function(cell) {
return this.model.isCollapsed(cell);
return cell.isCollapsed();
};
// Enables clipping of vertex labels if no offset is defined
graph.isLabelClipped = function(cell) {
const geometry = this.model.getGeometry(cell);
const geometry = cell.getGeometry();
return (
geometry != null &&

View File

@ -83,7 +83,7 @@ class SecondLabel extends React.Component {
// Hook for returning shape number for a given cell
graph.getSecondLabel = function(cell) {
if (!this.model.isEdge(cell)) {
if (!cell.isEdge()) {
// Possible to return any string here
return `The ID of this cell is ${cell.id}`;
}
@ -94,9 +94,9 @@ class SecondLabel extends React.Component {
let relativeChildVerticesVisible = true;
// Overrides method to hide relative child vertices
graph.isCellVisible = function(cell) {
const isVisible = function() {
return (
!this.model.isVertex(cell) ||
!cell.isVertex() ||
cell.geometry == null ||
!cell.geometry.relative ||
cell.geometry.relative == relativeChildVerticesVisible

View File

@ -43,7 +43,7 @@ class Wrapping extends React.Component {
// Disables in-place editing for edges
graph.isCellEditable = function(cell) {
return !this.model.isEdge(cell);
return !cell.isEdge();
};
// Gets the default parent for inserting new cells. This

View File

@ -37,25 +37,20 @@ class Collapse extends React.Component {
};
componentDidMount() {
class MyCustomModel extends mxGraphModel {
getStyle(cell) {
// Extends mxGraphModel.getStyle to show an image when collapsed
if (cell != null) {
let style = super.getStyle(cell);
if (this.isCollapsed(cell)) {
style =
`${style};shape=image;image=http://www.jgraph.com/images/mxgraph.gif;` +
`noLabel=1;imageBackground=#C3D9FF;imageBorder=#6482B9`;
}
return style;
}
return null;
}
}
const graph = new mxGraph(this.el, new MyCustomModel());
const graph = new mxGraph(this.el);
const parent = graph.getDefaultParent();
const getStyle = function() {
// Extends mxGraphModel.getStyle to show an image when collapsed
let style = super.getStyle();
if (this.isCollapsed()) {
style =
`${style};shape=image;image=http://www.jgraph.com/images/mxgraph.gif;` +
`noLabel=1;imageBackground=#C3D9FF;imageBorder=#6482B9`;
}
return style;
}
graph.batchUpdate(() => {
const v1 = graph.insertVertex({
parent,
@ -65,6 +60,7 @@ class Collapse extends React.Component {
style: 'shape=swimlane;startSize=20;',
});
v1.geometry.alternateBounds = new mxRectangle(0, 0, 110, 70);
v1.getStyle = getStyle;
const v11 = graph.insertVertex({
parent: v1,
@ -72,6 +68,7 @@ class Collapse extends React.Component {
position: [10, 40],
size: [120, 80],
});
v11.getStyle = getStyle;
});
};
}

View File

@ -47,7 +47,7 @@ class Constituent extends React.Component {
getInitialCellForEvent(me) {
let cell = super.getInitialCellForEvent(me);
if (this.graph.isPart(cell)) {
cell = this.graph.getModel().getParent(cell);
cell = this.cell.getParent();
}
return cell;
}
@ -66,7 +66,7 @@ class Constituent extends React.Component {
selectCellForEvent(cell, evt) {
// Redirects selection to parent
if (this.isPart(cell)) {
cell = this.model.getParent(cell);
cell = cell.getParent();
}
super.selectCellForEvent(cell, evt);
}

View File

@ -59,19 +59,19 @@ class Groups extends React.Component {
mxGraphHandler.prototype.getInitialCellForEvent;
mxGraphHandler.prototype.getInitialCellForEvent = function(me) {
const model = this.graph.getModel();
const psel = model.getParent(this.graph.getSelectionCell());
const psel = this.graph.getSelectionCell().getParent();
let cell = graphHandlerGetInitialCellForEvent.apply(this, arguments);
let parent = model.getParent(cell);
let parent = cell.getParent();
if (psel == null || (psel != cell && psel != parent)) {
while (
!this.graph.isCellSelected(cell) &&
!this.graph.isCellSelected(parent) &&
model.isVertex(parent) &&
parent.isVertex() &&
!this.graph.isValidRoot(parent)
) {
cell = parent;
parent = this.graph.getModel().getParent(cell);
parent = this.cell.getParent();
}
}
@ -84,13 +84,13 @@ class Groups extends React.Component {
mxGraphHandler.prototype.isDelayedSelection = function(cell) {
let result = graphHandlerIsDelayedSelection.apply(this, arguments);
const model = this.graph.getModel();
const psel = model.getParent(this.graph.getSelectionCell());
const parent = model.getParent(cell);
const psel = this.graph.getSelectionCell().getParent();
const parent = cell.getParent();
if (psel == null || (psel != cell && psel != parent)) {
if (
!this.graph.isCellSelected(cell) &&
model.isVertex(parent) &&
parent.isVertex() &&
!this.graph.isValidRoot(parent)
) {
result = true;
@ -109,15 +109,15 @@ class Groups extends React.Component {
}
const model = this.graph.getModel();
let parent = model.getParent(cell);
let parent = cell.getParent();
while (
this.graph.isCellSelected(cell) &&
model.isVertex(parent) &&
parent.isVertex() &&
!this.graph.isValidRoot(parent)
) {
cell = parent;
parent = model.getParent(cell);
parent = cell.getParent();
}
this.graph.selectCellForEvent(cell, me.getEvent());
@ -127,16 +127,14 @@ class Groups extends React.Component {
mxPopupMenuHandler.prototype.getCellForPopupEvent = function(me) {
let cell = me.getCell();
const model = this.graph.getModel();
let parent = model.getParent(cell);
let parent = cell.getParent();
while (model.isVertex(parent) && !this.graph.isValidRoot(parent)) {
while (parent.isVertex() && !this.graph.isValidRoot(parent)) {
if (this.graph.isCellSelected(parent)) {
cell = parent;
}
parent = model.getParent(parent);
parent = parent.getParent();
}
return cell;
};

View File

@ -119,13 +119,13 @@ class Layers extends React.Component {
this.el2.appendChild(
mxUtils.button('Layer 0', function() {
model.setVisible(layer0, !model.isVisible(layer0));
model.setVisible(layer0, !layer0.isVisible());
})
);
this.el2.appendChild(
mxUtils.button('Layer 1', function() {
model.setVisible(layer1, !model.isVisible(layer1));
model.setVisible(layer1, !layer1.isVisible());
})
);
}

View File

@ -203,7 +203,7 @@ class OrgChart extends React.Component {
graph.cellRenderer.getLabelValue = function(state) {
let result = state.cell.value;
if (state.view.graph.getModel().isVertex(state.cell)) {
if (state.cell.isVertex()) {
if (state.view.scale > 1) {
result += '\nDetails 1';
}
@ -278,7 +278,7 @@ class OrgChart extends React.Component {
const model = graph.getModel();
if (cell != null) {
if (model.isVertex(cell)) {
if (cell.isVertex()) {
menu.addItem(
'Add child',
'editors/images/overlays/check.png',
@ -292,7 +292,7 @@ class OrgChart extends React.Component {
graph.startEditingAtCell(cell);
});
if (cell.id != 'treeRoot' && model.isVertex(cell)) {
if (cell.id != 'treeRoot' && cell.isVertex()) {
menu.addItem('Delete', 'editors/images/delete.gif', function() {
deleteSubtree(graph, cell);
});
@ -371,7 +371,7 @@ class OrgChart extends React.Component {
model.beginUpdate();
try {
vertex = graph.insertVertex(parent, null, 'Double click to set name');
const geometry = model.getGeometry(vertex);
const geometry = vertex.getGeometry();
// Updates the geometry of the vertex with the
// preferred size computed in the graph

View File

@ -149,7 +149,7 @@ class SwimLanes extends React.Component {
graph.isValidSource = function(cell) {
if (previousIsValidSource.apply(this, arguments)) {
const style = this.getModel().getStyle(cell);
const style = cell.getStyle();
return (
style == null || !(style == 'end' || style.indexOf('end') == 0)
@ -166,10 +166,10 @@ class SwimLanes extends React.Component {
// the example below, so we use the state
// style below
graph.isValidTarget = function(cell) {
const style = this.getModel().getStyle(cell);
const style = cell.getStyle();
return (
!this.getModel().isEdge(cell) &&
!cell.isEdge() &&
!this.isSwimlane(cell) &&
(style == null || !(style == 'state' || style.indexOf('state') == 0))
);
@ -194,7 +194,7 @@ class SwimLanes extends React.Component {
// Checks if any lanes or pools are selected
for (let i = 0; i < cells.length; i++) {
const tmp = model.getParent(cells[i]);
const tmp = cells[i].getParent();
lane = lane || this.isPool(tmp);
pool = pool || this.isPool(cells[i]);
@ -205,33 +205,16 @@ class SwimLanes extends React.Component {
!pool &&
cell != lane &&
((lane && this.isPool(target)) ||
(cell && this.isPool(model.getParent(target))))
(cell && this.isPool(target.getParent())))
);
};
// Adds new method for identifying a pool
graph.isPool = function(cell) {
const model = this.getModel();
const parent = model.getParent(cell);
const parent = cell.getParent();
return parent != null && model.getParent(parent) == model.getRoot();
};
// Changes swimlane orientation while collapsed
graph.model.getStyle = function(cell) {
let style = mxGraphModel.prototype.getStyle.apply(this, arguments);
if (graph.isCellCollapsed(cell)) {
if (style != null) {
style += ';';
} else {
style = '';
}
style += 'horizontal=1;align=left;spacingLeft=14;';
}
return style;
return parent != null && parent.getParent() == model.getRoot();
};
// Keeps widths on collapse/expand
@ -239,7 +222,7 @@ class SwimLanes extends React.Component {
const cells = evt.getProperty('cells');
for (let i = 0; i < cells.length; i++) {
const geo = graph.model.getGeometry(cells[i]);
const geo = cells[i].getGeometry();
if (geo.alternateBounds != null) {
geo.width = geo.alternateBounds.width;
@ -250,6 +233,20 @@ class SwimLanes extends React.Component {
graph.addListener(mxEvent.FOLD_CELLS, foldingHandler);
}
// Changes swimlane orientation while collapsed
const getStyle = function() {
let style = super.getStyle();
if (this.isCellCollapsed()) {
if (style != null) {
style += ';';
} else {
style = '';
}
style += 'horizontal=1;align=left;spacingLeft=14;';
}
return style;
};
// Applies size changes to siblings and parents
new mxSwimlaneManager(graph);
@ -272,9 +269,9 @@ class SwimLanes extends React.Component {
layoutMgr.getLayout = function(cell) {
if (
!model.isEdge(cell) &&
graph.getModel().getChildCount(cell) > 0 &&
(model.getParent(cell) == model.getRoot() || graph.isPool(cell))
!cell.isEdge() &&
cell.getChildCount() > 0 &&
(cell.getParent() == model.getRoot() || graph.isPool(cell))
) {
layout.fill = graph.isPool(cell);
@ -288,229 +285,251 @@ class SwimLanes extends React.Component {
// is normally the first child of the root (ie. layer 0).
const parent = graph.getDefaultParent();
const insertVertex = options => {
const v = graph.insertVertex(options);
v.getStyle = getStyle;
return v;
};
const insertEdge = options => {
const e = graph.insertEdge(options);
e.getStyle = getStyle;
return e;
};
// Adds cells to the model in a single step
model.beginUpdate();
try {
const pool1 = graph.insertVertex(parent, null, 'Pool 1', 0, 0, 640, 0);
model.batchUpdate(() => {
const pool1 = insertVertex({
parent,
value: 'Pool 1',
position: [0, 0],
size: [640, 0],
});
pool1.setConnectable(false);
const lane1a = graph.insertVertex(pool1, null, 'Lane A', 0, 0, 640, 110);
const lane1a = insertVertex({
parent: pool1,
value: 'Lane A',
position: [0, 0],
size: [640, 110],
});
lane1a.setConnectable(false);
const lane1b = graph.insertVertex(pool1, null, 'Lane B', 0, 0, 640, 110);
const lane1b = insertVertex({
parent: pool1,
value: 'Lane B',
position: [0, 0],
size: [640, 110],
});
lane1b.setConnectable(false);
const pool2 = graph.insertVertex(parent, null, 'Pool 2', 0, 0, 640, 0);
const pool2 = insertVertex({
parent,
value: 'Pool 2',
position: [0, 0],
size: [640, 0],
});
pool2.setConnectable(false);
const lane2a = graph.insertVertex(pool2, null, 'Lane A', 0, 0, 640, 140);
const lane2a = insertVertex({
parent: pool2,
value: 'Lane A',
position: [0, 0],
size: [640, 140],
});
lane2a.setConnectable(false);
const lane2b = graph.insertVertex(pool2, null, 'Lane B', 0, 0, 640, 110);
const lane2b = insertVertex({
parent: pool2,
value: 'Lane B',
position: [0, 0],
size: [640, 110],
});
lane2b.setConnectable(false);
const start1 = graph.insertVertex(
lane1a,
null,
null,
40,
40,
30,
30,
'state'
);
const end1 = graph.insertVertex(
lane1a,
null,
'A',
560,
40,
30,
30,
'end'
);
const start1 = insertVertex({
parent: lane1a,
position: [40, 40],
size: [30, 30],
style: 'state',
});
const end1 = insertVertex({
parent: lane1a,
value: 'A',
position: [560, 40],
size: [30, 30],
style: 'end',
});
const step1 = graph.insertVertex(
lane1a,
null,
'Contact\nProvider',
90,
30,
80,
50,
'process'
);
const step11 = graph.insertVertex(
lane1a,
null,
'Complete\nAppropriate\nRequest',
190,
30,
80,
50,
'process'
);
const step111 = graph.insertVertex(
lane1a,
null,
'Receive and\nAcknowledge',
385,
30,
80,
50,
'process'
);
const step1 = insertVertex({
parent: lane1a,
value: 'Contact\nProvider',
position: [90, 30],
size: [80, 50],
style: 'process',
});
const step11 = insertVertex({
parent: lane1a,
value: 'Complete\nAppropriate\nRequest',
position: [190, 30],
size: [80, 50],
style: 'process',
});
const step111 = insertVertex({
parent: lane1a,
value: 'Receive and\nAcknowledge',
position: [385, 30],
size: [80, 50],
style: 'process',
});
const start2 = graph.insertVertex(
lane2b,
null,
null,
40,
40,
30,
30,
'state'
);
const start2 = insertVertex({
parent: lane2b,
position: [40, 40],
size: [30, 30],
style: 'state',
});
const step2 = graph.insertVertex(
lane2b,
null,
'Receive\nRequest',
90,
30,
80,
50,
'process'
);
const step22 = graph.insertVertex(
lane2b,
null,
'Refer to Tap\nSystems\nCoordinator',
190,
30,
80,
50,
'process'
);
const step2 = insertVertex({
parent: lane2b,
value: 'Receive\nRequest',
position: [90, 30],
size: [80, 50],
style: 'process',
});
const step22 = insertVertex({
parent: lane2b,
value: 'Refer to Tap\nSystems\nCoordinator',
position: [190, 30],
size: [80, 50],
style: 'process',
});
const step3 = graph.insertVertex(
lane1b,
null,
'Request 1st-\nGate\nInformation',
190,
30,
80,
50,
'process'
);
const step33 = graph.insertVertex(
lane1b,
null,
'Receive 1st-\nGate\nInformation',
290,
30,
80,
50,
'process'
);
const step3 = insertVertex({
parent: lane1b,
value: 'Request 1st-\nGate\nInformation',
position: [190, 30],
size: [80, 50],
style: 'process',
});
const step33 = insertVertex({
parent: lane1b,
value: 'Receive 1st-\nGate\nInformation',
position: [290, 30],
size: [80, 50],
style: 'process',
});
const step4 = graph.insertVertex(
lane2a,
null,
'Receive and\nAcknowledge',
290,
20,
80,
50,
'process'
);
const step44 = graph.insertVertex(
lane2a,
null,
'Contract\nConstraints?',
400,
20,
50,
50,
'condition'
);
const step444 = graph.insertVertex(
lane2a,
null,
'Tap for gas\ndelivery?',
480,
20,
50,
50,
'condition'
);
const step4 = insertVertex({
parent: lane2a,
value: 'Receive and\nAcknowledge',
position: [290, 20],
size: [80, 50],
style: 'process',
});
const step44 = insertVertex({
parent: lane2a,
value: 'Contract\nConstraints?',
position: [400, 20],
size: [50, 50],
style: 'condition',
});
const step444 = insertVertex({
parent: lane2a,
value: 'Tap for gas\ndelivery?',
position: [480, 20],
size: [50, 50],
style: 'condition',
});
const end2 = graph.insertVertex(
lane2a,
null,
'B',
560,
30,
30,
30,
'end'
);
const end3 = graph.insertVertex(
lane2a,
null,
'C',
560,
84,
30,
30,
'end'
);
const end2 = insertVertex({
parent: lane2a,
value: 'B',
position: [560, 30],
size: [30, 30],
style: 'end',
});
const end3 = insertVertex({
parent: lane2a,
value: 'C',
position: [560, 84],
size: [30, 30],
style: 'end',
});
let e = null;
graph.insertEdge(lane1a, null, null, start1, step1);
graph.insertEdge(lane1a, null, null, step1, step11);
graph.insertEdge(lane1a, null, null, step11, step111);
insertEdge({
parent: lane1a,
source: start1,
target: step1,
});
insertEdge({
parent: lane1a,
source: step1,
target: step11,
});
insertEdge({
parent: lane1a,
source: step11,
target: step111,
});
graph.insertEdge(lane2b, null, null, start2, step2);
graph.insertEdge(lane2b, null, null, step2, step22);
graph.insertEdge(parent, null, null, step22, step3);
graph.insertEdge(lane1b, null, null, step3, step33);
graph.insertEdge(lane2a, null, null, step4, step44);
graph.insertEdge(
lane2a,
null,
'No',
step44,
step444,
'verticalAlign=bottom'
);
graph.insertEdge(
insertEdge({
parent: lane2b,
source: start2,
target: step2,
});
insertEdge({
parent: lane2b,
source: step2,
target: step22,
});
insertEdge({
parent,
null,
'Yes',
step44,
step111,
'verticalAlign=bottom;horizontal=0;labelBackgroundColor=white;'
);
source: step22,
target: step3,
});
graph.insertEdge(
lane2a,
null,
'Yes',
step444,
end2,
'verticalAlign=bottom'
);
e = graph.insertEdge(
lane2a,
null,
'No',
step444,
end3,
'verticalAlign=top'
);
insertEdge({
parent: lane1b,
source: step3,
target: step33,
});
insertEdge({
parent: lane2a,
source: step4,
target: step44,
});
insertEdge({
parent: lane2a,
value: 'No',
source: step44,
target: step444,
style: 'verticalAlign=bottom',
});
insertEdge({
parent,
value: 'Yes',
source: step44,
target: step111,
style: 'verticalAlign=bottom;horizontal=0;labelBackgroundColor=white;',
});
insertEdge({
parent: lane2a,
value: 'Yes',
source: step444,
target: end2,
style: 'verticalAlign=bottom',
});
e = insertEdge({
parent: lane2a,
value: 'No',
source: step444,
target: end3,
style: 'verticalAlign=top',
});
e.geometry.points = [
new mxPoint(
step444.geometry.x + step444.geometry.width / 2,
@ -518,21 +537,41 @@ class SwimLanes extends React.Component {
),
];
graph.insertEdge(parent, null, null, step1, step2, 'crossover');
graph.insertEdge(parent, null, null, step3, step11, 'crossover');
e = graph.insertEdge(lane1a, null, null, step11, step33, 'crossover');
insertEdge({
parent,
source: step1,
target: step2,
style: 'crossover',
});
insertEdge({
parent,
source: step3,
target: step11,
style: 'crossover',
});
e = insertEdge({
parent: lane1a,
source: step11,
target: step33,
style: 'crossover',
});
e.geometry.points = [
new mxPoint(
step33.geometry.x + step33.geometry.width / 2 + 20,
step11.geometry.y + (step11.geometry.height * 4) / 5
),
];
graph.insertEdge(parent, null, null, step33, step4);
graph.insertEdge(lane1a, null, null, step111, end1);
} finally {
// Updates the display
model.endUpdate();
}
insertEdge({
parent,
source: step33,
target: step4,
});
insertEdge({
parent: lane1a,
source: step111,
target: end1,
});
});
}
}

View File

@ -95,7 +95,7 @@ class DynamicLoading extends React.Component {
// by requesting the respective data in the server-side
// (implemented for this demo using the server-function)
function load(graph, cell) {
if (graph.getModel().isVertex(cell)) {
if (cell.isVertex()) {
const cx = graph.container.clientWidth / 2;
const cy = graph.container.clientHeight / 2;
@ -115,7 +115,7 @@ class DynamicLoading extends React.Component {
for (var key in graph.getModel().cells) {
const tmp = graph.getModel().getCell(key);
if (tmp != cell && graph.getModel().isVertex(tmp)) {
if (tmp != cell && tmp.isVertex()) {
graph.removeCells([tmp]);
}
}
@ -124,7 +124,7 @@ class DynamicLoading extends React.Component {
graph.getModel().mergeChildren(model.getRoot().getChildAt(0), parent);
// Moves the given cell to the center
let geo = graph.getModel().getGeometry(cell);
let geo = cell.getGeometry();
if (geo != null) {
geo = geo.clone();
@ -143,13 +143,13 @@ class DynamicLoading extends React.Component {
for (var key in graph.getModel().cells) {
const tmp = graph.getModel().getCell(key);
if (tmp != cell && model.isVertex(tmp)) {
if (tmp != cell && tmp.isVertex()) {
vertices.push(tmp);
// Changes the initial location "in-place"
// to get a nice animation effect from the
// center to the radius of the circle
const geo = model.getGeometry(tmp);
const geo = tmp.getGeometry();
if (geo != null) {
geo.x = cx - geo.width / 2;
@ -167,7 +167,7 @@ class DynamicLoading extends React.Component {
);
for (let i = 0; i < cellCount; i++) {
let geo = graph.getModel().getGeometry(vertices[i]);
let geo = vertices[i].getGeometry();
if (geo != null) {
geo = geo.clone();

View File

@ -199,9 +199,9 @@ class Permissions extends React.Component {
graph.isCellEditable = function(cell) {
return (
(oldEditable.apply(this, arguments) &&
this.getModel().isVertex(cell) &&
cell.isVertex() &&
currentPermission.editVertices) ||
(this.getModel().isEdge(cell) && currentPermission.editEdges)
(cell.isEdge() && currentPermission.editEdges)
);
};
@ -209,9 +209,9 @@ class Permissions extends React.Component {
graph.isCellDeletable = function(cell) {
return (
(oldDeletable.apply(this, arguments) &&
this.getModel().isVertex(cell) &&
cell.isVertex() &&
currentPermission.editVertices) ||
(this.getModel().isEdge(cell) && currentPermission.editEdges)
(cell.isEdge() && currentPermission.editEdges)
);
};

View File

@ -57,16 +57,14 @@ class Visibility extends React.Component {
let showThree = true;
// Overridden to implement dynamic conditions
graph.isCellVisible = function(cell) {
let result = mxGraph.prototype.isCellVisible.apply(this, arguments);
if (result && cell.value != null) {
const isVisible = function() {
let result = super.isVisible();
if (result && this.value != null) {
result =
(showOne && cell.value == '1') ||
(showTwo && cell.value == '2') ||
(showThree && cell.value == '3');
(showOne && this.value == '1') ||
(showTwo && this.value == '2') ||
(showThree && this.value == '3');
}
return result;
};
@ -79,18 +77,23 @@ class Visibility extends React.Component {
position: [20, 20],
size: [80, 30],
});
v1.isVisible = isVisible;
const v2 = graph.insertVertex({
parent,
value: '2',
position: [200, 150],
size: [80, 30],
});
v2.isVisible = isVisible;
const e1 = graph.insertEdge({
parent,
value: '3',
source: v1,
target: v2,
});
e1.isVisible = isVisible;
});
// Dynamic conditions (requires refresh)
@ -116,7 +119,7 @@ class Visibility extends React.Component {
// Explicit show/hide
this.el2.appendChild(
mxUtils.button('Toggle cell', function() {
graph.toggleCells(!graph.getModel().isVisible(v1), [v1], true);
graph.toggleCells(!v1.isVisible(), [v1], true);
})
);

View File

@ -375,7 +375,7 @@ class Stencils extends React.Component {
if (cell != null) {
const style = mxUtils.prompt(
'Style',
graph.getModel().getStyle(cell)
cell.getStyle()
);
if (style != null) {

View File

@ -50,41 +50,34 @@ class DynamicStyle extends React.Component {
// not explicitely changed using mxStyleChange
graph.getView().updateStyle = true;
// Overrides mxGraphModel.getStyle to return a specific style
// Overrides mxCell.getStyle to return a specific style
// for edges that reflects their target terminal (in this case
// the strokeColor will be equal to the target's fillColor).
const previous = graph.model.getStyle;
graph.model.getStyle = function(cell) {
if (cell != null) {
let style = previous.apply(this, arguments);
const getStyle = function() {
let style = super.getStyle();
if (this.isEdge(cell)) {
const target = this.getTerminal(cell, false);
if (this.isEdge()) {
const target = this.getTerminal(false);
if (target != null) {
const targetStyle = graph.getCurrentCellStyle(target);
const fill = mxUtils.getValue(
targetStyle,
mxConstants.STYLE_FILLCOLOR
);
if (target != null) {
const targetStyle = graph.getCurrentCellStyle(target);
const fill = mxUtils.getValue(
targetStyle,
mxConstants.STYLE_FILLCOLOR
);
if (fill != null) {
style += `;strokeColor=${fill}`;
}
}
} else if (this.isVertex(cell)) {
const geometry = this.getGeometry(cell);
if (geometry != null && geometry.width > 80) {
style += ';fillColor=green';
if (fill != null) {
style += `;strokeColor=${fill}`;
}
}
return style;
} else if (this.isVertex()) {
const geometry = this.getGeometry();
if (geometry != null && geometry.width > 80) {
style += ';fillColor=green';
}
}
return null;
return style;
};
// Gets the default parent for inserting new cells. This
@ -100,6 +93,8 @@ class DynamicStyle extends React.Component {
size: [80, 30],
style: 'fillColor=green',
});
v1.getStyle = getStyle;
const v2 = graph.insertVertex({
parent,
value: 'World!',
@ -107,6 +102,8 @@ class DynamicStyle extends React.Component {
size: [80, 30],
style: 'fillColor=blue',
});
v2.getStyle = getStyle;
const v3 = graph.insertVertex({
parent,
value: 'World!',
@ -114,6 +111,8 @@ class DynamicStyle extends React.Component {
size: [80, 30],
style: 'fillColor=red',
});
v3.getStyle = getStyle;
const e1 = graph.insertEdge({
parent,
value: 'Connect',
@ -121,6 +120,7 @@ class DynamicStyle extends React.Component {
target: v2,
style: 'perimeterSpacing=4;strokeWidth=4;labelBackgroundColor=white;fontStyle=1',
});
e1.getStyle = getStyle;
});
};
}

View File

@ -75,7 +75,7 @@ class HoverStyle extends React.Component {
// Ignores everything but vertices
if (
graph.isMouseDown ||
(tmp != null && !graph.getModel().isVertex(tmp.cell))
(tmp != null && !tmp.cell.isVertex())
) {
tmp = null;
}

View File

@ -49,7 +49,7 @@ class Stylesheet extends React.Component {
graph.getLabel = function(cell) {
const label = mxGraph.prototype.getLabel.apply(this, arguments);
if (this.getModel().isEdge(cell)) {
if (cell.isEdge()) {
return `Transfer ${label}`;
}
return label;
@ -61,9 +61,9 @@ class Stylesheet extends React.Component {
const { cell } = state;
const model = this.getModel();
if (model.isEdge(cell)) {
const source = this.getLabel(model.getTerminal(cell, true));
const target = this.getLabel(model.getTerminal(cell, false));
if (modcellel.isEdge()) {
const source = this.getLabel(cell.getTerminal(true));
const target = this.getLabel(cell.getTerminal(false));
return `${source} -> ${target}`;
}

View File

@ -101,7 +101,7 @@ class UserObject extends React.Component {
// Overrides method to disallow edge label editing
graph.isCellEditable = function(cell) {
return !this.getModel().isEdge(cell);
return !cell.isEdge();
};
// Overrides method to provide a cell label in the display
@ -174,9 +174,9 @@ class UserObject extends React.Component {
const { getTooltipForCell } = graph;
graph.getTooltipForCell = function(cell) {
// Adds some relation details for edges
if (graph.getModel().isEdge(cell)) {
const src = this.getLabel(this.getModel().getTerminal(cell, true));
const trg = this.getLabel(this.getModel().getTerminal(cell, false));
if (cell.isEdge()) {
const src = this.getLabel(cell.getTerminal(true));
const trg = this.getLabel(cell.getTerminal(false));
return `${src} ${cell.value.nodeName} ${trg}`;
}

View File

@ -45,7 +45,7 @@ class LOD extends React.Component {
graph.centerZoom = false;
// Links level of detail to zoom level but can be independent of zoom
graph.isCellVisible = function(cell) {
const isVisible = function(cell) {
return cell.lod == null || cell.lod / 2 < this.view.scale;
};
@ -54,26 +54,35 @@ class LOD extends React.Component {
const parent = graph.getDefaultParent();
// Adds cells to the model in a single step
graph.getModel().beginUpdate();
try {
graph.batchUpdate(() => {
const v1 = graph.insertVertex(parent, null, '1', 20, 20, 80, 30);
v1.lod = 1;
v1.isVisible = isVisible;
const v2 = graph.insertVertex(parent, null, '1', 200, 150, 80, 30);
v2.lod = 1;
v2.isVisible = isVisible;
const v3 = graph.insertVertex(parent, null, '2', 20, 150, 40, 20);
v3.lod = 2;
v3.isVisible = isVisible;
const v4 = graph.insertVertex(parent, null, '3', 200, 10, 20, 20);
v4.lod = 3;
v4.isVisible = isVisible;
const e1 = graph.insertEdge(parent, null, '2', v1, v2, 'strokeWidth=2');
e1.lod = 2;
var e2 = graph.insertEdge(parent, null, '2', v3, v4, 'strokeWidth=2');
e1.isVisible = isVisible;
const e2 = graph.insertEdge(parent, null, '2', v3, v4, 'strokeWidth=2');
e2.lod = 2;
var e2 = graph.insertEdge(parent, null, '3', v1, v4, 'strokeWidth=1');
e2.lod = 3;
} finally {
// Updates the display
graph.getModel().endUpdate();
}
e2.isVisible = isVisible;
const e3 = graph.insertEdge(parent, null, '3', v1, v4, 'strokeWidth=1');
e3.lod = 3;
e3.isVisible = isVisible;
});
this.el2.appendChild(
mxUtils.button('+', function() {