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, JGraph Ltd
* Copyright (c) 2006-2015, Gaudenz Alder * 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 = [];
};
/** class mxGraphAbstractHierarchyCell {
* Variable: maxRank /**
* * Variable: maxRank
* The maximum rank this cell occupies. Default is -1. *
*/ * The maximum rank this cell occupies. Default is -1.
maxRank = -1; */
maxRank = -1;
/** /**
* Variable: minRank * Variable: minRank
* *
* The minimum rank this cell occupies. Default is -1. * The minimum rank this cell occupies. Default is -1.
*/ */
minRank = -1; minRank = -1;
/** /**
* Variable: x * Variable: x
* *
* The x position of this cell for each layer it occupies * The x position of this cell for each layer it occupies
*/ */
x = null; x = null;
/** /**
* Variable: y * Variable: y
* *
* The y position of this cell for each layer it occupies * The y position of this cell for each layer it occupies
*/ */
y = null; y = null;
/** /**
* Variable: width * Variable: width
* *
* The width of this cell. Default is 0. * The width of this cell. Default is 0.
*/ */
width = 0; width = 0;
/** /**
* Variable: height * Variable: height
* *
* The height of this cell. Default is 0. * The height of this cell. Default is 0.
*/ */
height = 0; height = 0;
/** /**
* Variable: nextLayerConnectedCells * Variable: nextLayerConnectedCells
* *
* A cached version of the cells this cell connects to on the next layer up * A cached version of the cells this cell connects to on the next layer up
*/ */
nextLayerConnectedCells = null; nextLayerConnectedCells = null;
/** /**
* Variable: previousLayerConnectedCells * Variable: previousLayerConnectedCells
* *
* A cached version of the cells this cell connects to on the next layer down * A cached version of the cells this cell connects to on the next layer down
*/ */
previousLayerConnectedCells = null; previousLayerConnectedCells = null;
/** /**
* Variable: temp * Variable: temp
* *
* Temporary variable for general use. Generally, try to avoid * Temporary variable for general use. Generally, try to avoid
* carrying information between stages. Currently, the longest * carrying information between stages. Currently, the longest
* path layering sets temp to the rank position in fixRanks() * path layering sets temp to the rank position in fixRanks()
* and the crossing reduction uses this. This meant temp couldn't * and the crossing reduction uses this. This meant temp couldn't
* be used for hashing the nodes in the model dfs and so hashCode * be used for hashing the nodes in the model dfs and so hashCode
* was created * was created
*/ */
temp = null; temp = null;
/** /**
* Function: getNextLayerConnectedCells * Class: mxGraphAbstractHierarchyCell
* *
* Returns the cells this cell connects to on the next layer up * An abstraction of an internal hierarchy node or edge
*/ *
getNextLayerConnectedCells = (layer)=> * Constructor: mxGraphAbstractHierarchyCell
{ *
return null; * Constructs a new hierarchical layout algorithm.
}; */
constructor() {
this.x = [];
this.y = [];
this.temp = [];
};
/** /**
* Function: getPreviousLayerConnectedCells * Function: getNextLayerConnectedCells
* *
* Returns the cells this cell connects to on the next layer down * Returns the cells this cell connects to on the next layer up
*/ */
getPreviousLayerConnectedCells = (layer)=> getNextLayerConnectedCells = (layer) => {
{ return null;
return null; };
};
/** /**
* Function: isEdge * Function: getPreviousLayerConnectedCells
* *
* Returns whether or not this cell is an edge * Returns the cells this cell connects to on the next layer down
*/ */
isEdge = ()=> getPreviousLayerConnectedCells = (layer) => {
{ return null;
return false; };
};
/** /**
* Function: isVertex * Function: isEdge
* *
* Returns whether or not this cell is a node * Returns whether or not this cell is an edge
*/ */
isVertex = ()=> isEdge = () => {
{ return false;
return false; };
};
/** /**
* Function: getGeneralPurposeVariable * Function: isVertex
* *
* Gets the value of temp for the specified layer * Returns whether or not this cell is a node
*/ */
getGeneralPurposeVariable = (layer)=> isVertex = () => {
{ return false;
return null; };
};
/** /**
* Function: setGeneralPurposeVariable * Function: getGeneralPurposeVariable
* *
* Set the value of temp for the specified layer * Gets the value of temp for the specified layer
*/ */
setGeneralPurposeVariable = (layer, value)=> getGeneralPurposeVariable = (layer) => {
{ return null;
return null; };
};
/** /**
* Function: setX * Function: setGeneralPurposeVariable
* *
* Set the value of x for the specified layer * Set the value of temp for the specified layer
*/ */
setX = (layer, value)=> setGeneralPurposeVariable = (layer, value) => {
{ return null;
if (this.isVertex()) };
{
this.x[0] = value;
}
else if (this.isEdge())
{
this.x[layer - this.minRank - 1] = value;
}
};
/** /**
* Function: getX * Function: setX
* *
* Gets the value of x on the specified layer * Set the value of x for the specified layer
*/ */
getX = (layer)=> setX = (layer, value) => {
{ if (this.isVertex()) {
if (this.isVertex()) this.x[0] = value;
{ } else if (this.isEdge()) {
return this.x[0]; this.x[layer - this.minRank - 1] = value;
} }
else if (this.isEdge()) };
{
return this.x[layer - this.minRank - 1];
}
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];
}
/** return 0.0;
* Function: setY };
*
* Set the value of y for the specified layer /**
*/ * Function: setY
setY = (layer, value)=> *
{ * Set the value of y for the specified layer
if (this.isVertex()) */
{ setY = (layer, value) => {
this.y[0] = value; if (this.isVertex()) {
} this.y[0] = value;
else if (this.isEdge()) } else if (this.isEdge()) {
{ this.y[layer - this.minRank - 1] = value;
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, JGraph Ltd
* Copyright (c) 2006-2015, Gaudenz Alder * 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]));
}
};
/** class mxGraphHierarchyEdge extends mxGraphAbstractHierarchyCell {
* Extends mxGraphAbstractHierarchyCell. /**
*/ * Variable: edges
mxGraphHierarchyEdge.prototype = new mxGraphAbstractHierarchyCell(); *
constructor = mxGraphHierarchyEdge; * The graph edge(s) this object represents. Parallel edges are all grouped
* together within one hierarchy edge.
*/
edges = null;
/** /**
* Variable: edges * Variable: ids
* *
* The graph edge(s) this object represents. Parallel edges are all grouped * The object identities of the wrapped cells
* together within one hierarchy edge. */
*/ ids = null;
edges = null;
/** /**
* Variable: ids * Variable: source
* *
* The object identities of the wrapped cells * The node this edge is sourced at
*/ */
ids = null; source = null;
/** /**
* Variable: source * Variable: target
* *
* The node this edge is sourced at * The node this edge targets
*/ */
source = null; target = null;
/** /**
* Variable: target * Variable: isReversed
* *
* The node this edge targets * Whether or not the direction of this edge has been reversed
*/ * internally to create a DAG for the hierarchical layout
target = null; */
isReversed = false;
/** /**
* Variable: isReversed * Class: mxGraphHierarchyEdge
* *
* Whether or not the direction of this edge has been reversed * An abstraction of a hierarchical edge for the hierarchy layout
* internally to create a DAG for the hierarchical layout *
*/ * Constructor: mxGraphHierarchyEdge
isReversed = false; *
* Constructs a hierarchy edge
*
* Arguments:
*
* edges - a list of real graph edges this abstraction represents
*/
constructor(edges) {
super(edges);
this.edges = edges;
this.ids = [];
/** for (var i = 0; i < edges.length; i++) {
* Function: invert this.ids.push(mxObjectIdentity.get(edges[i]));
* }
* 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 * Function: invert
* *
* Returns the cells this cell connects to on the next layer up * Inverts the direction of this internal edge(s)
*/ */
getNextLayerConnectedCells = (layer)=> invert = (layer) => {
{ var temp = this.source;
if (this.nextLayerConnectedCells == null) this.source = this.target;
{ this.target = temp;
this.nextLayerConnectedCells = []; this.isReversed = !this.isReversed;
};
for (var i = 0; i < this.temp.length; i++)
{ /**
this.nextLayerConnectedCells[i] = []; * Function: getNextLayerConnectedCells
*
if (i == this.temp.length - 1) * Returns the cells this cell connects to on the next layer up
{ */
this.nextLayerConnectedCells[i].push(this.source); getNextLayerConnectedCells = (layer) => {
} if (this.nextLayerConnectedCells == null) {
else this.nextLayerConnectedCells = [];
{
this.nextLayerConnectedCells[i].push(this); 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];
};
/** 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 = [];
for (var i = 0; i < this.temp.length; i++) /**
{ * Function: getPreviousLayerConnectedCells
this.previousLayerConnectedCells[i] = []; *
* Returns the cells this cell connects to on the next layer down
if (i == 0) */
{ getPreviousLayerConnectedCells = (layer) => {
this.previousLayerConnectedCells[i].push(this.target); if (this.previousLayerConnectedCells == null) {
} this.previousLayerConnectedCells = [];
else
{ for (var i = 0; i < this.temp.length; i++) {
this.previousLayerConnectedCells[i].push(this); 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 * Function: isEdge
* *
* Returns true. * Returns true.
*/ */
isEdge = ()=> isEdge = () => {
{ return true;
return true; };
};
/** /**
* Function: getGeneralPurposeVariable * Function: getGeneralPurposeVariable
* *
* Gets the value of temp for the specified layer * Gets the value of temp for the specified layer
*/ */
getGeneralPurposeVariable = (layer)=> getGeneralPurposeVariable = (layer) => {
{ return this.temp[layer - this.minRank - 1];
return this.temp[layer - this.minRank - 1]; };
};
/** /**
* Function: setGeneralPurposeVariable * Function: setGeneralPurposeVariable
* *
* Set the value of temp for the specified layer * Set the value of temp for the specified layer
*/ */
setGeneralPurposeVariable = (layer, value)=> setGeneralPurposeVariable = (layer, value) => {
{ this.temp[layer - this.minRank - 1] = value;
this.temp[layer - this.minRank - 1] = value; };
};
/** /**
* Function: getCoreCell * Function: getCoreCell
* *
* Gets the first core edge associated with this wrapper * Gets the first core edge associated with this wrapper
*/ */
getCoreCell = ()=> getCoreCell = () => {
{ if (this.edges != null && this.edges.length > 0) {
if (this.edges != null && this.edges.length > 0) return this.edges[0];
{ }
return this.edges[0];
} return null;
};
return null; }
};
export default mxGraphHierarchyEdge;

View File

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

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, JGraph Ltd
* Copyright (c) 2006-2015, Gaudenz Alder * 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() { };
/** class mxHierarchicalLayoutStage {
* Function: execute /**
* * Class: mxHierarchicalLayoutStage
* Takes the graph detail and configuration information within the facade *
* and creates the resulting laid out graph within that facade for further * The specific layout interface for hierarchical layouts. It adds a
* use. * <code>run</code> method with a parameter for the hierarchical layout model
*/ * that is shared between the layout stages.
execute = (parent)=> { }; *
* 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, JGraph Ltd
* Copyright (c) 2006-2015, Gaudenz Alder * 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;
};
/** class mxMinimumCycleRemover extends mxHierarchicalLayoutStage {
* Extends mxHierarchicalLayoutStage. /**
*/ * Variable: layout
mxMinimumCycleRemover.prototype = new mxHierarchicalLayoutStage(); *
constructor = mxMinimumCycleRemover; * Reference to the enclosing <mxHierarchicalLayout>.
*/
layout = null;
/** /**
* Variable: layout * Class: mxMinimumCycleRemover
* *
* Reference to the enclosing <mxHierarchicalLayout>. * An implementation of the first stage of the Sugiyama layout. Straightforward
*/ * longest path calculation of layer assignment
layout = null; *
* Constructor: mxMinimumCycleRemover
*
* Creates a cycle remover for the given internal model.
*/
constructor(layout) {
// constructor not called
this.layout = layout;
};
/** /**
* Function: execute * Function: execute
* *
* Takes the graph detail and configuration information within the facade * Takes the graph detail and configuration information within the facade
* and creates the resulting laid out graph within that facade for further * and creates the resulting laid out graph within that facade for further
* use. * use.
*/ */
execute = (parent)=> execute = (parent) => {
{ var model = this.layout.getModel();
var model = this.layout.getModel(); var seenNodes = new Object();
var seenNodes = new Object(); var unseenNodesArray = model.vertexMapper.getValues();
var unseenNodesArray = model.vertexMapper.getValues(); var unseenNodes = new Object();
var unseenNodes = new Object();
for (var i = 0; i < unseenNodesArray.length; i++) for (var i = 0; i < unseenNodesArray.length; i++) {
{ unseenNodes[unseenNodesArray[i].id] = unseenNodesArray[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);
} }
seenNodes[node.id] = node; // Perform a dfs through the internal model. If a cycle is found,
delete unseenNodes[node.id]; // reverse it.
}, rootsArray, true, null); var rootsArray = null;
// If there are any nodes that should be nodes that the dfs can miss if (model.roots != null) {
// these need to be processed with the dfs and the roots assigned var modelRoots = model.roots;
// correctly to form a correct internal model rootsArray = [];
var seenNodesCopy = mxUtils.clone(seenNodes, null, true);
// Pick a random cell and dfs from it for (var i = 0; i < modelRoots.length; i++) {
model.visit((parent, node, connectingEdge, layer, seen)=> rootsArray[i] = model.vertexMapper.get(modelRoots[i]);
{ }
// 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; model.visit((parent, node, connectingEdge, layer, seen) => {
delete unseenNodes[node.id]; // Check if the cell is in it's own ancestor list, if so
}, unseenNodes, true, seenNodesCopy); // 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, JGraph Ltd
* Copyright (c) 2006-2015, Gaudenz Alder * 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;
};
/** class mxSwimlaneOrdering extends mxHierarchicalLayoutStage {
* Extends mxHierarchicalLayoutStage. /**
*/ * Variable: layout
mxSwimlaneOrdering.prototype = new mxHierarchicalLayoutStage(); *
constructor = mxSwimlaneOrdering; * Reference to the enclosing <mxHierarchicalLayout>.
*/
layout = null;
/** /**
* Variable: layout * Class: mxSwimlaneOrdering
* *
* Reference to the enclosing <mxHierarchicalLayout>. * An implementation of the first stage of the Sugiyama layout. Straightforward
*/ * longest path calculation of layer assignment
layout = null; *
* Constructor: mxSwimlaneOrdering
*
* Creates a cycle remover for the given internal model.
*/
constructor(layout) {
// super not called
this.layout = layout;
};
/** /**
* Function: execute * Function: execute
* *
* Takes the graph detail and configuration information within the facade * Takes the graph detail and configuration information within the facade
* and creates the resulting laid out graph within that facade for further * and creates the resulting laid out graph within that facade for further
* use. * use.
*/ */
execute = (parent)=> execute = (parent) => {
{ var model = this.layout.getModel();
var model = this.layout.getModel(); var seenNodes = new Object();
var seenNodes = new Object(); var unseenNodes = mxUtils.clone(model.vertexMapper, null, true);
var unseenNodes = mxUtils.clone(model.vertexMapper, null, true);
// Perform a dfs through the internal model. If a cycle is found,
// Perform a dfs through the internal model. If a cycle is found, // reverse it.
// reverse it. var rootsArray = null;
var rootsArray = null;
if (model.roots != null) {
if (model.roots != null) var modelRoots = model.roots;
{ rootsArray = [];
var modelRoots = model.roots;
rootsArray = []; for (var i = 0; i < modelRoots.length; i++) {
rootsArray[i] = model.vertexMapper.get(modelRoots[i]);
for (var i = 0; i < modelRoots.length; i++) }
{
rootsArray[i] = model.vertexMapper.get(modelRoots[i]);
} }
}
model.visit((parent, node, connectingEdge, layer, seen)=> model.visit((parent, node, connectingEdge, layer, seen) => {
{ // Check if the cell is in it's own ancestor list, if so
// Check if the cell is in it's own ancestor list, if so // invert the connecting edge and reverse the target/source
// invert the connecting edge and reverse the target/source // relationship to that edge in the parent and the cell
// relationship to that edge in the parent and the cell // Ancestor hashes only line up within a swimlane
// Ancestor hashes only line up within a swimlane var isAncestor = parent != null && parent.swimlaneIndex == node.swimlaneIndex && node.isAncestor(parent);
var isAncestor = parent != null && parent.swimlaneIndex == node.swimlaneIndex && node.isAncestor(parent);
// If the source->target swimlane indices go from higher to // If the source->target swimlane indices go from higher to
// lower, the edge is reverse // lower, the edge is reverse
var reversedOverSwimlane = parent != null && connectingEdge != null && var reversedOverSwimlane = parent != null && connectingEdge != null &&
parent.swimlaneIndex < node.swimlaneIndex && connectingEdge.source == node; parent.swimlaneIndex < node.swimlaneIndex && connectingEdge.source == node;
if (isAncestor) if (isAncestor) {
{ connectingEdge.invert();
connectingEdge.invert(); mxUtils.remove(connectingEdge, parent.connectsAsSource);
mxUtils.remove(connectingEdge, parent.connectsAsSource); node.connectsAsSource.push(connectingEdge);
node.connectsAsSource.push(connectingEdge); parent.connectsAsTarget.push(connectingEdge);
parent.connectsAsTarget.push(connectingEdge); mxUtils.remove(connectingEdge, node.connectsAsTarget);
mxUtils.remove(connectingEdge, node.connectsAsTarget); } else if (reversedOverSwimlane) {
} connectingEdge.invert();
else if (reversedOverSwimlane) mxUtils.remove(connectingEdge, parent.connectsAsTarget);
{ node.connectsAsTarget.push(connectingEdge);
connectingEdge.invert(); parent.connectsAsSource.push(connectingEdge);
mxUtils.remove(connectingEdge, parent.connectsAsTarget); mxUtils.remove(connectingEdge, node.connectsAsSource);
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];
var cellId = mxCellPath.create(node.cell); }, rootsArray, true, null);
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"; import mxDictionary from "FIXME";
class mxGraphLayout { 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 * Class: mxGraphLayout
* *
@ -32,28 +54,6 @@ class mxGraphLayout {
this.graph = graph; 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 * Function: moveCell
* *

View File

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