manual js syntax updates

development
mcyph 2021-03-20 10:37:54 +11:00
parent 0b8e1695f8
commit 5a241d7283
13 changed files with 4509 additions and 5142 deletions

View File

@ -2,199 +2,185 @@
* Copyright (c) 2006-2015, JGraph Ltd
* Copyright (c) 2006-2015, Gaudenz Alder
*/
/**
* Class: mxGraphAbstractHierarchyCell
*
* An abstraction of an internal hierarchy node or edge
*
* Constructor: mxGraphAbstractHierarchyCell
*
* Constructs a new hierarchical layout algorithm.
*/
function mxGraphAbstractHierarchyCell()
{
this.x = [];
this.y = [];
this.temp = [];
};
/**
* Variable: maxRank
*
* The maximum rank this cell occupies. Default is -1.
*/
maxRank = -1;
class mxGraphAbstractHierarchyCell {
/**
* Variable: maxRank
*
* The maximum rank this cell occupies. Default is -1.
*/
maxRank = -1;
/**
* Variable: minRank
*
* The minimum rank this cell occupies. Default is -1.
*/
minRank = -1;
/**
* Variable: minRank
*
* The minimum rank this cell occupies. Default is -1.
*/
minRank = -1;
/**
* Variable: x
*
* The x position of this cell for each layer it occupies
*/
x = null;
/**
* Variable: x
*
* The x position of this cell for each layer it occupies
*/
x = null;
/**
* Variable: y
*
* The y position of this cell for each layer it occupies
*/
y = null;
/**
* Variable: y
*
* The y position of this cell for each layer it occupies
*/
y = null;
/**
* Variable: width
*
* The width of this cell. Default is 0.
*/
width = 0;
/**
* Variable: width
*
* The width of this cell. Default is 0.
*/
width = 0;
/**
* Variable: height
*
* The height of this cell. Default is 0.
*/
height = 0;
/**
* Variable: height
*
* The height of this cell. Default is 0.
*/
height = 0;
/**
* Variable: nextLayerConnectedCells
*
* A cached version of the cells this cell connects to on the next layer up
*/
nextLayerConnectedCells = null;
/**
* Variable: nextLayerConnectedCells
*
* A cached version of the cells this cell connects to on the next layer up
*/
nextLayerConnectedCells = null;
/**
* Variable: previousLayerConnectedCells
*
* A cached version of the cells this cell connects to on the next layer down
*/
previousLayerConnectedCells = null;
/**
* Variable: previousLayerConnectedCells
*
* A cached version of the cells this cell connects to on the next layer down
*/
previousLayerConnectedCells = null;
/**
* Variable: temp
*
* Temporary variable for general use. Generally, try to avoid
* carrying information between stages. Currently, the longest
* path layering sets temp to the rank position in fixRanks()
* and the crossing reduction uses this. This meant temp couldn't
* be used for hashing the nodes in the model dfs and so hashCode
* was created
*/
temp = null;
/**
* Variable: temp
*
* Temporary variable for general use. Generally, try to avoid
* carrying information between stages. Currently, the longest
* path layering sets temp to the rank position in fixRanks()
* and the crossing reduction uses this. This meant temp couldn't
* be used for hashing the nodes in the model dfs and so hashCode
* was created
*/
temp = null;
/**
* Function: getNextLayerConnectedCells
*
* Returns the cells this cell connects to on the next layer up
*/
getNextLayerConnectedCells = (layer)=>
{
return null;
};
/**
* Class: mxGraphAbstractHierarchyCell
*
* An abstraction of an internal hierarchy node or edge
*
* Constructor: mxGraphAbstractHierarchyCell
*
* Constructs a new hierarchical layout algorithm.
*/
constructor() {
this.x = [];
this.y = [];
this.temp = [];
};
/**
* Function: getPreviousLayerConnectedCells
*
* Returns the cells this cell connects to on the next layer down
*/
getPreviousLayerConnectedCells = (layer)=>
{
return null;
};
/**
* Function: getNextLayerConnectedCells
*
* Returns the cells this cell connects to on the next layer up
*/
getNextLayerConnectedCells = (layer) => {
return null;
};
/**
* Function: isEdge
*
* Returns whether or not this cell is an edge
*/
isEdge = ()=>
{
return false;
};
/**
* Function: getPreviousLayerConnectedCells
*
* Returns the cells this cell connects to on the next layer down
*/
getPreviousLayerConnectedCells = (layer) => {
return null;
};
/**
* Function: isVertex
*
* Returns whether or not this cell is a node
*/
isVertex = ()=>
{
return false;
};
/**
* Function: isEdge
*
* Returns whether or not this cell is an edge
*/
isEdge = () => {
return false;
};
/**
* Function: getGeneralPurposeVariable
*
* Gets the value of temp for the specified layer
*/
getGeneralPurposeVariable = (layer)=>
{
return null;
};
/**
* Function: isVertex
*
* Returns whether or not this cell is a node
*/
isVertex = () => {
return false;
};
/**
* Function: setGeneralPurposeVariable
*
* Set the value of temp for the specified layer
*/
setGeneralPurposeVariable = (layer, value)=>
{
return null;
};
/**
* Function: getGeneralPurposeVariable
*
* Gets the value of temp for the specified layer
*/
getGeneralPurposeVariable = (layer) => {
return null;
};
/**
* Function: setX
*
* Set the value of x for the specified layer
*/
setX = (layer, value)=>
{
if (this.isVertex())
{
this.x[0] = value;
}
else if (this.isEdge())
{
this.x[layer - this.minRank - 1] = value;
}
};
/**
* Function: setGeneralPurposeVariable
*
* Set the value of temp for the specified layer
*/
setGeneralPurposeVariable = (layer, value) => {
return null;
};
/**
* Function: getX
*
* Gets the value of x on the specified layer
*/
getX = (layer)=>
{
if (this.isVertex())
{
return this.x[0];
}
else if (this.isEdge())
{
return this.x[layer - this.minRank - 1];
}
/**
* Function: setX
*
* Set the value of x for the specified layer
*/
setX = (layer, value) => {
if (this.isVertex()) {
this.x[0] = value;
} else if (this.isEdge()) {
this.x[layer - this.minRank - 1] = value;
}
};
return 0.0;
};
/**
* Function: getX
*
* Gets the value of x on the specified layer
*/
getX = (layer) => {
if (this.isVertex()) {
return this.x[0];
} else if (this.isEdge()) {
return this.x[layer - this.minRank - 1];
}
/**
* Function: setY
*
* Set the value of y for the specified layer
*/
setY = (layer, value)=>
{
if (this.isVertex())
{
this.y[0] = value;
}
else if (this.isEdge())
{
this.y[layer -this. minRank - 1] = value;
}
};
return 0.0;
};
/**
* Function: setY
*
* Set the value of y for the specified layer
*/
setY = (layer, value) => {
if (this.isVertex()) {
this.y[0] = value;
} else if (this.isEdge()) {
this.y[layer - this.minRank - 1] = value;
}
};
}
export default mxGraphAbstractHierarchyCell;

View File

@ -2,186 +2,165 @@
* Copyright (c) 2006-2015, JGraph Ltd
* Copyright (c) 2006-2015, Gaudenz Alder
*/
/**
* Class: mxGraphHierarchyEdge
*
* An abstraction of a hierarchical edge for the hierarchy layout
*
* Constructor: mxGraphHierarchyEdge
*
* Constructs a hierarchy edge
*
* Arguments:
*
* edges - a list of real graph edges this abstraction represents
*/
function mxGraphHierarchyEdge(edges)
{
mxGraphAbstractHierarchyCell.apply(this, arguments);
this.edges = edges;
this.ids = [];
for (var i = 0; i < edges.length; i++)
{
this.ids.push(mxObjectIdentity.get(edges[i]));
}
};
/**
* Extends mxGraphAbstractHierarchyCell.
*/
mxGraphHierarchyEdge.prototype = new mxGraphAbstractHierarchyCell();
constructor = mxGraphHierarchyEdge;
class mxGraphHierarchyEdge extends mxGraphAbstractHierarchyCell {
/**
* Variable: edges
*
* The graph edge(s) this object represents. Parallel edges are all grouped
* together within one hierarchy edge.
*/
edges = null;
/**
* Variable: edges
*
* The graph edge(s) this object represents. Parallel edges are all grouped
* together within one hierarchy edge.
*/
edges = null;
/**
* Variable: ids
*
* The object identities of the wrapped cells
*/
ids = null;
/**
* Variable: ids
*
* The object identities of the wrapped cells
*/
ids = null;
/**
* Variable: source
*
* The node this edge is sourced at
*/
source = null;
/**
* Variable: source
*
* The node this edge is sourced at
*/
source = null;
/**
* Variable: target
*
* The node this edge targets
*/
target = null;
/**
* Variable: target
*
* The node this edge targets
*/
target = null;
/**
* Variable: isReversed
*
* Whether or not the direction of this edge has been reversed
* internally to create a DAG for the hierarchical layout
*/
isReversed = false;
/**
* Variable: isReversed
*
* Whether or not the direction of this edge has been reversed
* internally to create a DAG for the hierarchical layout
*/
isReversed = false;
/**
* Class: mxGraphHierarchyEdge
*
* An abstraction of a hierarchical edge for the hierarchy layout
*
* Constructor: mxGraphHierarchyEdge
*
* Constructs a hierarchy edge
*
* Arguments:
*
* edges - a list of real graph edges this abstraction represents
*/
constructor(edges) {
super(edges);
this.edges = edges;
this.ids = [];
/**
* Function: invert
*
* Inverts the direction of this internal edge(s)
*/
invert = (layer)=>
{
var temp = this.source;
this.source = this.target;
this.target = temp;
this.isReversed = !this.isReversed;
};
for (var i = 0; i < edges.length; i++) {
this.ids.push(mxObjectIdentity.get(edges[i]));
}
};
/**
* Function: getNextLayerConnectedCells
*
* Returns the cells this cell connects to on the next layer up
*/
getNextLayerConnectedCells = (layer)=>
{
if (this.nextLayerConnectedCells == null)
{
this.nextLayerConnectedCells = [];
for (var i = 0; i < this.temp.length; i++)
{
this.nextLayerConnectedCells[i] = [];
if (i == this.temp.length - 1)
{
this.nextLayerConnectedCells[i].push(this.source);
}
else
{
this.nextLayerConnectedCells[i].push(this);
/**
* Function: invert
*
* Inverts the direction of this internal edge(s)
*/
invert = (layer) => {
var temp = this.source;
this.source = this.target;
this.target = temp;
this.isReversed = !this.isReversed;
};
/**
* Function: getNextLayerConnectedCells
*
* Returns the cells this cell connects to on the next layer up
*/
getNextLayerConnectedCells = (layer) => {
if (this.nextLayerConnectedCells == null) {
this.nextLayerConnectedCells = [];
for (var i = 0; i < this.temp.length; i++) {
this.nextLayerConnectedCells[i] = [];
if (i === this.temp.length - 1) {
this.nextLayerConnectedCells[i].push(this.source);
} else {
this.nextLayerConnectedCells[i].push(this);
}
}
}
}
return this.nextLayerConnectedCells[layer - this.minRank - 1];
};
/**
* Function: getPreviousLayerConnectedCells
*
* Returns the cells this cell connects to on the next layer down
*/
getPreviousLayerConnectedCells = (layer)=>
{
if (this.previousLayerConnectedCells == null)
{
this.previousLayerConnectedCells = [];
return this.nextLayerConnectedCells[layer - this.minRank - 1];
};
for (var i = 0; i < this.temp.length; i++)
{
this.previousLayerConnectedCells[i] = [];
if (i == 0)
{
this.previousLayerConnectedCells[i].push(this.target);
}
else
{
this.previousLayerConnectedCells[i].push(this);
/**
* Function: getPreviousLayerConnectedCells
*
* Returns the cells this cell connects to on the next layer down
*/
getPreviousLayerConnectedCells = (layer) => {
if (this.previousLayerConnectedCells == null) {
this.previousLayerConnectedCells = [];
for (var i = 0; i < this.temp.length; i++) {
this.previousLayerConnectedCells[i] = [];
if (i === 0) {
this.previousLayerConnectedCells[i].push(this.target);
} else {
this.previousLayerConnectedCells[i].push(this);
}
}
}
}
return this.previousLayerConnectedCells[layer - this.minRank - 1];
};
return this.previousLayerConnectedCells[layer - this.minRank - 1];
};
/**
* Function: isEdge
*
* Returns true.
*/
isEdge = ()=>
{
return true;
};
/**
* Function: isEdge
*
* Returns true.
*/
isEdge = () => {
return true;
};
/**
* Function: getGeneralPurposeVariable
*
* Gets the value of temp for the specified layer
*/
getGeneralPurposeVariable = (layer)=>
{
return this.temp[layer - this.minRank - 1];
};
/**
* Function: getGeneralPurposeVariable
*
* Gets the value of temp for the specified layer
*/
getGeneralPurposeVariable = (layer) => {
return this.temp[layer - this.minRank - 1];
};
/**
* Function: setGeneralPurposeVariable
*
* Set the value of temp for the specified layer
*/
setGeneralPurposeVariable = (layer, value)=>
{
this.temp[layer - this.minRank - 1] = value;
};
/**
* Function: setGeneralPurposeVariable
*
* Set the value of temp for the specified layer
*/
setGeneralPurposeVariable = (layer, value) => {
this.temp[layer - this.minRank - 1] = value;
};
/**
* Function: getCoreCell
*
* Gets the first core edge associated with this wrapper
*/
getCoreCell = ()=>
{
if (this.edges != null && this.edges.length > 0)
{
return this.edges[0];
}
return null;
};
/**
* Function: getCoreCell
*
* Gets the first core edge associated with this wrapper
*/
getCoreCell = () => {
if (this.edges != null && this.edges.length > 0) {
return this.edges[0];
}
return null;
};
}
export default mxGraphHierarchyEdge;

View File

@ -15,206 +15,180 @@
*
* cell - the real graph cell this node represents
*/
function mxGraphHierarchyNode(cell)
{
mxGraphAbstractHierarchyCell.apply(this, arguments);
this.cell = cell;
this.id = mxObjectIdentity.get(cell);
this.connectsAsTarget = [];
this.connectsAsSource = [];
};
class mxGraphHierarchyNode extends mxGraphAbstractHierarchyCell {
constructor(cell) {
super(cell);
this.cell = cell;
this.id = mxObjectIdentity.get(cell);
this.connectsAsTarget = [];
this.connectsAsSource = [];
};
/**
* Extends mxGraphAbstractHierarchyCell.
*/
mxGraphHierarchyNode.prototype = new mxGraphAbstractHierarchyCell();
constructor = mxGraphHierarchyNode;
/**
* Variable: cell
*
* The graph cell this object represents.
*/
cell = null;
/**
* Variable: cell
*
* The graph cell this object represents.
*/
cell = null;
/**
* Variable: id
*
* The object identity of the wrapped cell
*/
id = null;
/**
* Variable: id
*
* The object identity of the wrapped cell
*/
id = null;
/**
* Variable: connectsAsTarget
*
* Collection of hierarchy edges that have this node as a target
*/
connectsAsTarget = null;
/**
* Variable: connectsAsTarget
*
* Collection of hierarchy edges that have this node as a target
*/
connectsAsTarget = null;
/**
* Variable: connectsAsSource
*
* Collection of hierarchy edges that have this node as a source
*/
connectsAsSource = null;
/**
* Variable: connectsAsSource
*
* Collection of hierarchy edges that have this node as a source
*/
connectsAsSource = null;
/**
* Variable: hashCode
*
* Assigns a unique hashcode for each node. Used by the model dfs instead
* of copying HashSets
*/
hashCode = false;
/**
* Variable: hashCode
*
* Assigns a unique hashcode for each node. Used by the model dfs instead
* of copying HashSets
*/
hashCode = false;
/**
* Function: getRankValue
*
* Returns the integer value of the layer that this node resides in
*/
getRankValue = (layer) => {
return this.maxRank;
};
/**
* Function: getRankValue
*
* Returns the integer value of the layer that this node resides in
*/
getRankValue = (layer)=>
{
return this.maxRank;
};
/**
* Function: getNextLayerConnectedCells
*
* Returns the cells this cell connects to on the next layer up
*/
getNextLayerConnectedCells = (layer) => {
if (this.nextLayerConnectedCells == null) {
this.nextLayerConnectedCells = [];
this.nextLayerConnectedCells[0] = [];
/**
* Function: getNextLayerConnectedCells
*
* Returns the cells this cell connects to on the next layer up
*/
getNextLayerConnectedCells = (layer)=>
{
if (this.nextLayerConnectedCells == null)
{
this.nextLayerConnectedCells = [];
this.nextLayerConnectedCells[0] = [];
for (var i = 0; i < this.connectsAsTarget.length; i++)
{
var edge = this.connectsAsTarget[i];
for (var i = 0; i < this.connectsAsTarget.length; i++) {
var edge = this.connectsAsTarget[i];
if (edge.maxRank == -1 || edge.maxRank == layer + 1)
{
// Either edge is not in any rank or
// no dummy nodes in edge, add node of other side of edge
this.nextLayerConnectedCells[0].push(edge.source);
}
else
{
// Edge spans at least two layers, add edge
this.nextLayerConnectedCells[0].push(edge);
if (edge.maxRank == -1 || edge.maxRank == layer + 1) {
// Either edge is not in any rank or
// no dummy nodes in edge, add node of other side of edge
this.nextLayerConnectedCells[0].push(edge.source);
} else {
// Edge spans at least two layers, add edge
this.nextLayerConnectedCells[0].push(edge);
}
}
}
}
return this.nextLayerConnectedCells[0];
};
return this.nextLayerConnectedCells[0];
};
/**
* Function: getPreviousLayerConnectedCells
*
* Returns the cells this cell connects to on the next layer down
*/
getPreviousLayerConnectedCells = (layer)=>
{
if (this.previousLayerConnectedCells == null)
{
this.previousLayerConnectedCells = [];
this.previousLayerConnectedCells[0] = [];
for (var i = 0; i < this.connectsAsSource.length; i++)
{
var edge = this.connectsAsSource[i];
/**
* Function: getPreviousLayerConnectedCells
*
* Returns the cells this cell connects to on the next layer down
*/
getPreviousLayerConnectedCells = (layer) => {
if (this.previousLayerConnectedCells == null) {
this.previousLayerConnectedCells = [];
this.previousLayerConnectedCells[0] = [];
if (edge.minRank == -1 || edge.minRank == layer - 1)
{
// No dummy nodes in edge, add node of other side of edge
this.previousLayerConnectedCells[0].push(edge.target);
}
else
{
// Edge spans at least two layers, add edge
this.previousLayerConnectedCells[0].push(edge);
for (var i = 0; i < this.connectsAsSource.length; i++) {
var edge = this.connectsAsSource[i];
if (edge.minRank == -1 || edge.minRank == layer - 1) {
// No dummy nodes in edge, add node of other side of edge
this.previousLayerConnectedCells[0].push(edge.target);
} else {
// Edge spans at least two layers, add edge
this.previousLayerConnectedCells[0].push(edge);
}
}
}
}
return this.previousLayerConnectedCells[0];
};
return this.previousLayerConnectedCells[0];
};
/**
* Function: isVertex
*
* Returns true.
*/
isVertex = ()=>
{
return true;
};
/**
* Function: isVertex
*
* Returns true.
*/
isVertex = () => {
return true;
};
/**
* Function: getGeneralPurposeVariable
*
* Gets the value of temp for the specified layer
*/
getGeneralPurposeVariable = (layer)=>
{
return this.temp[0];
};
/**
* Function: getGeneralPurposeVariable
*
* Gets the value of temp for the specified layer
*/
getGeneralPurposeVariable = (layer) => {
return this.temp[0];
};
/**
* Function: setGeneralPurposeVariable
*
* Set the value of temp for the specified layer
*/
setGeneralPurposeVariable = (layer, value)=>
{
this.temp[0] = value;
};
/**
* Function: setGeneralPurposeVariable
*
* Set the value of temp for the specified layer
*/
setGeneralPurposeVariable = (layer, value) => {
this.temp[0] = value;
};
/**
* Function: isAncestor
*/
isAncestor = (otherNode)=>
{
// Firstly, the hash code of this node needs to be shorter than the
// other node
if (otherNode != null && this.hashCode != null && otherNode.hashCode != null
&& this.hashCode.length < otherNode.hashCode.length)
{
if (this.hashCode == otherNode.hashCode)
{
return true;
}
if (this.hashCode == null || this.hashCode == null)
{
return false;
}
// Secondly, this hash code must match the start of the other
// node's hash code. Arrays.equals cannot be used here since
// the arrays are different length, and we do not want to
// perform another array copy.
for (var i = 0; i < this.hashCode.length; i++)
{
if (this.hashCode[i] != otherNode.hashCode[i])
{
/**
* Function: isAncestor
*/
isAncestor = (otherNode) => {
// Firstly, the hash code of this node needs to be shorter than the
// other node
if (otherNode != null && this.hashCode != null && otherNode.hashCode != null
&& this.hashCode.length < otherNode.hashCode.length) {
if (this.hashCode == otherNode.hashCode) {
return true;
}
if (this.hashCode == null || this.hashCode == null) {
return false;
}
// Secondly, this hash code must match the start of the other
// node's hash code. Arrays.equals cannot be used here since
// the arrays are different length, and we do not want to
// perform another array copy.
for (var i = 0; i < this.hashCode.length; i++) {
if (this.hashCode[i] != otherNode.hashCode[i]) {
return false;
}
}
return true;
}
return true;
}
return false;
};
return false;
};
/**
* Function: getCoreCell
*
* Gets the core vertex associated with this wrapper
*/
getCoreCell = () => {
return this.cell;
};
}
/**
* Function: getCoreCell
*
* Gets the core vertex associated with this wrapper
*/
getCoreCell = ()=>
{
return this.cell;
};
export default mxGraphHierarchyNode;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2,24 +2,30 @@
* Copyright (c) 2006-2015, JGraph Ltd
* Copyright (c) 2006-2015, Gaudenz Alder
*/
/**
* Class: mxHierarchicalLayoutStage
*
* The specific layout interface for hierarchical layouts. It adds a
* <code>run</code> method with a parameter for the hierarchical layout model
* that is shared between the layout stages.
*
* Constructor: mxHierarchicalLayoutStage
*
* Constructs a new hierarchical layout stage.
*/
function mxHierarchicalLayoutStage() { };
/**
* Function: execute
*
* Takes the graph detail and configuration information within the facade
* and creates the resulting laid out graph within that facade for further
* use.
*/
execute = (parent)=> { };
class mxHierarchicalLayoutStage {
/**
* Class: mxHierarchicalLayoutStage
*
* The specific layout interface for hierarchical layouts. It adds a
* <code>run</code> method with a parameter for the hierarchical layout model
* that is shared between the layout stages.
*
* Constructor: mxHierarchicalLayoutStage
*
* Constructs a new hierarchical layout stage.
*/
constructor() {
}
/**
* Function: execute
*
* Takes the graph detail and configuration information within the facade
* and creates the resulting laid out graph within that facade for further
* use.
*/
execute = (parent)=> { };
}
export default mxHierarchicalLayoutStage;

View File

@ -2,107 +2,98 @@
* Copyright (c) 2006-2015, JGraph Ltd
* Copyright (c) 2006-2015, Gaudenz Alder
*/
/**
* Class: mxMinimumCycleRemover
*
* An implementation of the first stage of the Sugiyama layout. Straightforward
* longest path calculation of layer assignment
*
* Constructor: mxMinimumCycleRemover
*
* Creates a cycle remover for the given internal model.
*/
function mxMinimumCycleRemover(layout)
{
this.layout = layout;
};
/**
* Extends mxHierarchicalLayoutStage.
*/
mxMinimumCycleRemover.prototype = new mxHierarchicalLayoutStage();
constructor = mxMinimumCycleRemover;
class mxMinimumCycleRemover extends mxHierarchicalLayoutStage {
/**
* Variable: layout
*
* Reference to the enclosing <mxHierarchicalLayout>.
*/
layout = null;
/**
* Variable: layout
*
* Reference to the enclosing <mxHierarchicalLayout>.
*/
layout = null;
/**
* Class: mxMinimumCycleRemover
*
* An implementation of the first stage of the Sugiyama layout. Straightforward
* longest path calculation of layer assignment
*
* Constructor: mxMinimumCycleRemover
*
* Creates a cycle remover for the given internal model.
*/
constructor(layout) {
// constructor not called
this.layout = layout;
};
/**
* Function: execute
*
* Takes the graph detail and configuration information within the facade
* and creates the resulting laid out graph within that facade for further
* use.
*/
execute = (parent)=>
{
var model = this.layout.getModel();
var seenNodes = new Object();
var unseenNodesArray = model.vertexMapper.getValues();
var unseenNodes = new Object();
/**
* Function: execute
*
* Takes the graph detail and configuration information within the facade
* and creates the resulting laid out graph within that facade for further
* use.
*/
execute = (parent) => {
var model = this.layout.getModel();
var seenNodes = new Object();
var unseenNodesArray = model.vertexMapper.getValues();
var unseenNodes = new Object();
for (var i = 0; i < unseenNodesArray.length; i++)
{
unseenNodes[unseenNodesArray[i].id] = unseenNodesArray[i];
}
// Perform a dfs through the internal model. If a cycle is found,
// reverse it.
var rootsArray = null;
if (model.roots != null)
{
var modelRoots = model.roots;
rootsArray = [];
for (var i = 0; i < modelRoots.length; i++)
{
rootsArray[i] = model.vertexMapper.get(modelRoots[i]);
}
}
model.visit((parent, node, connectingEdge, layer, seen)=>
{
// Check if the cell is in it's own ancestor list, if so
// invert the connecting edge and reverse the target/source
// relationship to that edge in the parent and the cell
if (node.isAncestor(parent))
{
connectingEdge.invert();
mxUtils.remove(connectingEdge, parent.connectsAsSource);
parent.connectsAsTarget.push(connectingEdge);
mxUtils.remove(connectingEdge, node.connectsAsTarget);
node.connectsAsSource.push(connectingEdge);
for (var i = 0; i < unseenNodesArray.length; i++) {
unseenNodes[unseenNodesArray[i].id] = unseenNodesArray[i];
}
seenNodes[node.id] = node;
delete unseenNodes[node.id];
}, rootsArray, true, null);
// Perform a dfs through the internal model. If a cycle is found,
// reverse it.
var rootsArray = null;
// If there are any nodes that should be nodes that the dfs can miss
// these need to be processed with the dfs and the roots assigned
// correctly to form a correct internal model
var seenNodesCopy = mxUtils.clone(seenNodes, null, true);
if (model.roots != null) {
var modelRoots = model.roots;
rootsArray = [];
// Pick a random cell and dfs from it
model.visit((parent, node, connectingEdge, layer, seen)=>
{
// Check if the cell is in it's own ancestor list, if so
// invert the connecting edge and reverse the target/source
// relationship to that edge in the parent and the cell
if (node.isAncestor(parent))
{
connectingEdge.invert();
mxUtils.remove(connectingEdge, parent.connectsAsSource);
node.connectsAsSource.push(connectingEdge);
parent.connectsAsTarget.push(connectingEdge);
mxUtils.remove(connectingEdge, node.connectsAsTarget);
for (var i = 0; i < modelRoots.length; i++) {
rootsArray[i] = model.vertexMapper.get(modelRoots[i]);
}
}
seenNodes[node.id] = node;
delete unseenNodes[node.id];
}, unseenNodes, true, seenNodesCopy);
};
model.visit((parent, node, connectingEdge, layer, seen) => {
// Check if the cell is in it's own ancestor list, if so
// invert the connecting edge and reverse the target/source
// relationship to that edge in the parent and the cell
if (node.isAncestor(parent)) {
connectingEdge.invert();
mxUtils.remove(connectingEdge, parent.connectsAsSource);
parent.connectsAsTarget.push(connectingEdge);
mxUtils.remove(connectingEdge, node.connectsAsTarget);
node.connectsAsSource.push(connectingEdge);
}
seenNodes[node.id] = node;
delete unseenNodes[node.id];
}, rootsArray, true, null);
// If there are any nodes that should be nodes that the dfs can miss
// these need to be processed with the dfs and the roots assigned
// correctly to form a correct internal model
var seenNodesCopy = mxUtils.clone(seenNodes, null, true);
// Pick a random cell and dfs from it
model.visit((parent, node, connectingEdge, layer, seen) => {
// Check if the cell is in it's own ancestor list, if so
// invert the connecting edge and reverse the target/source
// relationship to that edge in the parent and the cell
if (node.isAncestor(parent)) {
connectingEdge.invert();
mxUtils.remove(connectingEdge, parent.connectsAsSource);
node.connectsAsSource.push(connectingEdge);
parent.connectsAsTarget.push(connectingEdge);
mxUtils.remove(connectingEdge, node.connectsAsTarget);
}
seenNodes[node.id] = node;
delete unseenNodes[node.id];
}, unseenNodes, true, seenNodesCopy);
};
}
export default mxMinimumCycleRemover;

View File

@ -2,94 +2,86 @@
* Copyright (c) 2006-2015, JGraph Ltd
* Copyright (c) 2006-2015, Gaudenz Alder
*/
/**
* Class: mxSwimlaneOrdering
*
* An implementation of the first stage of the Sugiyama layout. Straightforward
* longest path calculation of layer assignment
*
* Constructor: mxSwimlaneOrdering
*
* Creates a cycle remover for the given internal model.
*/
function mxSwimlaneOrdering(layout)
{
this.layout = layout;
};
/**
* Extends mxHierarchicalLayoutStage.
*/
mxSwimlaneOrdering.prototype = new mxHierarchicalLayoutStage();
constructor = mxSwimlaneOrdering;
class mxSwimlaneOrdering extends mxHierarchicalLayoutStage {
/**
* Variable: layout
*
* Reference to the enclosing <mxHierarchicalLayout>.
*/
layout = null;
/**
* Variable: layout
*
* Reference to the enclosing <mxHierarchicalLayout>.
*/
layout = null;
/**
* Class: mxSwimlaneOrdering
*
* An implementation of the first stage of the Sugiyama layout. Straightforward
* longest path calculation of layer assignment
*
* Constructor: mxSwimlaneOrdering
*
* Creates a cycle remover for the given internal model.
*/
constructor(layout) {
// super not called
this.layout = layout;
};
/**
* Function: execute
*
* Takes the graph detail and configuration information within the facade
* and creates the resulting laid out graph within that facade for further
* use.
*/
execute = (parent)=>
{
var model = this.layout.getModel();
var seenNodes = new Object();
var unseenNodes = mxUtils.clone(model.vertexMapper, null, true);
// Perform a dfs through the internal model. If a cycle is found,
// reverse it.
var rootsArray = null;
if (model.roots != null)
{
var modelRoots = model.roots;
rootsArray = [];
for (var i = 0; i < modelRoots.length; i++)
{
rootsArray[i] = model.vertexMapper.get(modelRoots[i]);
/**
* Function: execute
*
* Takes the graph detail and configuration information within the facade
* and creates the resulting laid out graph within that facade for further
* use.
*/
execute = (parent) => {
var model = this.layout.getModel();
var seenNodes = new Object();
var unseenNodes = mxUtils.clone(model.vertexMapper, null, true);
// Perform a dfs through the internal model. If a cycle is found,
// reverse it.
var rootsArray = null;
if (model.roots != null) {
var modelRoots = model.roots;
rootsArray = [];
for (var i = 0; i < modelRoots.length; i++) {
rootsArray[i] = model.vertexMapper.get(modelRoots[i]);
}
}
}
model.visit((parent, node, connectingEdge, layer, seen)=>
{
// Check if the cell is in it's own ancestor list, if so
// invert the connecting edge and reverse the target/source
// relationship to that edge in the parent and the cell
// Ancestor hashes only line up within a swimlane
var isAncestor = parent != null && parent.swimlaneIndex == node.swimlaneIndex && node.isAncestor(parent);
model.visit((parent, node, connectingEdge, layer, seen) => {
// Check if the cell is in it's own ancestor list, if so
// invert the connecting edge and reverse the target/source
// relationship to that edge in the parent and the cell
// Ancestor hashes only line up within a swimlane
var isAncestor = parent != null && parent.swimlaneIndex == node.swimlaneIndex && node.isAncestor(parent);
// If the source->target swimlane indices go from higher to
// lower, the edge is reverse
var reversedOverSwimlane = parent != null && connectingEdge != null &&
parent.swimlaneIndex < node.swimlaneIndex && connectingEdge.source == node;
// If the source->target swimlane indices go from higher to
// lower, the edge is reverse
var reversedOverSwimlane = parent != null && connectingEdge != null &&
parent.swimlaneIndex < node.swimlaneIndex && connectingEdge.source == node;
if (isAncestor)
{
connectingEdge.invert();
mxUtils.remove(connectingEdge, parent.connectsAsSource);
node.connectsAsSource.push(connectingEdge);
parent.connectsAsTarget.push(connectingEdge);
mxUtils.remove(connectingEdge, node.connectsAsTarget);
}
else if (reversedOverSwimlane)
{
connectingEdge.invert();
mxUtils.remove(connectingEdge, parent.connectsAsTarget);
node.connectsAsTarget.push(connectingEdge);
parent.connectsAsSource.push(connectingEdge);
mxUtils.remove(connectingEdge, node.connectsAsSource);
}
var cellId = mxCellPath.create(node.cell);
seenNodes[cellId] = node;
delete unseenNodes[cellId];
}, rootsArray, true, null);
};
if (isAncestor) {
connectingEdge.invert();
mxUtils.remove(connectingEdge, parent.connectsAsSource);
node.connectsAsSource.push(connectingEdge);
parent.connectsAsTarget.push(connectingEdge);
mxUtils.remove(connectingEdge, node.connectsAsTarget);
} else if (reversedOverSwimlane) {
connectingEdge.invert();
mxUtils.remove(connectingEdge, parent.connectsAsTarget);
node.connectsAsTarget.push(connectingEdge);
parent.connectsAsSource.push(connectingEdge);
mxUtils.remove(connectingEdge, node.connectsAsSource);
}
var cellId = mxCellPath.create(node.cell);
seenNodes[cellId] = node;
delete unseenNodes[cellId];
}, rootsArray, true, null);
};
}
export default mxSwimlaneOrdering;

View File

@ -7,6 +7,28 @@ import mxRectangle from "FIXME";
import mxDictionary from "FIXME";
class mxGraphLayout {
/**
* Variable: graph
*
* Reference to the enclosing <mxGraph>.
*/
graph = null;
/**
* Variable: useBoundingBox
*
* Boolean indicating if the bounding box of the label should be used if
* its available. Default is true.
*/
useBoundingBox = true;
/**
* Variable: parent
*
* The parent cell of the layout, if any
*/
parent = null;
/**
* Class: mxGraphLayout
*
@ -32,28 +54,6 @@ class mxGraphLayout {
this.graph = graph;
};
/**
* Variable: graph
*
* Reference to the enclosing <mxGraph>.
*/
graph = null;
/**
* Variable: useBoundingBox
*
* Boolean indicating if the bounding box of the label should be used if
* its available. Default is true.
*/
useBoundingBox = true;
/**
* Variable: parent
*
* The parent cell of the layout, if any
*/
parent = null;
/**
* Function: moveCell
*

View File

@ -471,7 +471,7 @@ class mxStencil extends mxShape {
var sx = w / this.w0;
var sy = h / this.h0;
var inverse = (direction == mxConstants.DIRECTION_NORTH || direction == mxConstants.DIRECTION_SOUTH);
var inverse = (direction === mxConstants.DIRECTION_NORTH || direction === mxConstants.DIRECTION_SOUTH);
if (inverse) {
sy = w / this.h0;
@ -483,7 +483,7 @@ class mxStencil extends mxShape {
y0 -= delta;
}
if (this.aspect == 'fixed') {
if (this.aspect === 'fixed') {
sy = Math.min(sx, sy);
sx = sy;
@ -594,7 +594,7 @@ class mxStencil extends mxShape {
y0 + Number(node.getAttribute('y1')) * sy,
x0 + Number(node.getAttribute('x2')) * sx,
y0 + Number(node.getAttribute('y2')) * sy);
} else if (name == 'curve') {
} else if (name === 'curve') {
canvas.curveTo(x0 + Number(node.getAttribute('x1')) * sx,
y0 + Number(node.getAttribute('y1')) * sy,
x0 + Number(node.getAttribute('x2')) * sx,