code
stringlengths 24
2.07M
| docstring
stringlengths 25
85.3k
| func_name
stringlengths 1
92
| language
stringclasses 1
value | repo
stringlengths 5
64
| path
stringlengths 4
172
| url
stringlengths 44
218
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
setInfo = function setInfo(ele, obj) {
return ele.scratch('breadthfirst', obj);
}
|
Elements are drawn in a specific order based on compound depth (low to high), the element type (nodes above edges),
and z-index (low to high). These styles affect how this applies:
z-compound-depth: May be `bottom | orphan | auto | top`. The first drawn is `bottom`, then `orphan` which is the
same depth as the root of the compound graph, followed by the default value `auto` which draws in order from
root to leaves of the compound graph. The last drawn is `top`.
z-index-compare: May be `auto | manual`. The default value is `auto` which always draws edges under nodes.
`manual` ignores this convention and draws based on the `z-index` value setting.
z-index: An integer value that affects the relative draw order of elements. In general, an element with a higher
`z-index` will be drawn on top of an element with a lower `z-index`.
|
setInfo
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
function BreadthFirstLayout(options) {
this.options = extend({}, defaults$9, options);
}
|
Elements are drawn in a specific order based on compound depth (low to high), the element type (nodes above edges),
and z-index (low to high). These styles affect how this applies:
z-compound-depth: May be `bottom | orphan | auto | top`. The first drawn is `bottom`, then `orphan` which is the
same depth as the root of the compound graph, followed by the default value `auto` which draws in order from
root to leaves of the compound graph. The last drawn is `top`.
z-index-compare: May be `auto | manual`. The default value is `auto` which always draws edges under nodes.
`manual` ignores this convention and draws based on the `z-index` value setting.
z-index: An integer value that affects the relative draw order of elements. In general, an element with a higher
`z-index` will be drawn on top of an element with a lower `z-index`.
|
BreadthFirstLayout
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
_loop = function _loop(_i) {
var comp = components[_i];
var maxDegree = comp.maxDegree(false);
var compRoots = comp.filter(function (ele) {
return ele.degree(false) === maxDegree;
});
roots = roots.add(compRoots);
}
|
Elements are drawn in a specific order based on compound depth (low to high), the element type (nodes above edges),
and z-index (low to high). These styles affect how this applies:
z-compound-depth: May be `bottom | orphan | auto | top`. The first drawn is `bottom`, then `orphan` which is the
same depth as the root of the compound graph, followed by the default value `auto` which draws in order from
root to leaves of the compound graph. The last drawn is `top`.
z-index-compare: May be `auto | manual`. The default value is `auto` which always draws edges under nodes.
`manual` ignores this convention and draws based on the `z-index` value setting.
z-index: An integer value that affects the relative draw order of elements. In general, an element with a higher
`z-index` will be drawn on top of an element with a lower `z-index`.
|
_loop
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
addToDepth = function addToDepth(ele, d) {
if (depths[d] == null) {
depths[d] = [];
}
var i = depths[d].length;
depths[d].push(ele);
setInfo(ele, {
index: i,
depth: d
});
}
|
Elements are drawn in a specific order based on compound depth (low to high), the element type (nodes above edges),
and z-index (low to high). These styles affect how this applies:
z-compound-depth: May be `bottom | orphan | auto | top`. The first drawn is `bottom`, then `orphan` which is the
same depth as the root of the compound graph, followed by the default value `auto` which draws in order from
root to leaves of the compound graph. The last drawn is `top`.
z-index-compare: May be `auto | manual`. The default value is `auto` which always draws edges under nodes.
`manual` ignores this convention and draws based on the `z-index` value setting.
z-index: An integer value that affects the relative draw order of elements. In general, an element with a higher
`z-index` will be drawn on top of an element with a lower `z-index`.
|
addToDepth
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
changeDepth = function changeDepth(ele, newDepth) {
var _getInfo = getInfo(ele),
depth = _getInfo.depth,
index = _getInfo.index;
depths[depth][index] = null;
addToDepth(ele, newDepth);
}
|
Elements are drawn in a specific order based on compound depth (low to high), the element type (nodes above edges),
and z-index (low to high). These styles affect how this applies:
z-compound-depth: May be `bottom | orphan | auto | top`. The first drawn is `bottom`, then `orphan` which is the
same depth as the root of the compound graph, followed by the default value `auto` which draws in order from
root to leaves of the compound graph. The last drawn is `top`.
z-index-compare: May be `auto | manual`. The default value is `auto` which always draws edges under nodes.
`manual` ignores this convention and draws based on the `z-index` value setting.
z-index: An integer value that affects the relative draw order of elements. In general, an element with a higher
`z-index` will be drawn on top of an element with a lower `z-index`.
|
changeDepth
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
assignDepthsAt = function assignDepthsAt(i) {
var eles = depths[i];
for (var j = 0; j < eles.length; j++) {
var _ele2 = eles[j];
if (_ele2 == null) {
eles.splice(j, 1);
j--;
continue;
}
setInfo(_ele2, {
depth: i,
index: j
});
}
}
|
Elements are drawn in a specific order based on compound depth (low to high), the element type (nodes above edges),
and z-index (low to high). These styles affect how this applies:
z-compound-depth: May be `bottom | orphan | auto | top`. The first drawn is `bottom`, then `orphan` which is the
same depth as the root of the compound graph, followed by the default value `auto` which draws in order from
root to leaves of the compound graph. The last drawn is `top`.
z-index-compare: May be `auto | manual`. The default value is `auto` which always draws edges under nodes.
`manual` ignores this convention and draws based on the `z-index` value setting.
z-index: An integer value that affects the relative draw order of elements. In general, an element with a higher
`z-index` will be drawn on top of an element with a lower `z-index`.
|
assignDepthsAt
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
assignDepths = function assignDepths() {
for (var _i3 = 0; _i3 < depths.length; _i3++) {
assignDepthsAt(_i3);
}
}
|
Elements are drawn in a specific order based on compound depth (low to high), the element type (nodes above edges),
and z-index (low to high). These styles affect how this applies:
z-compound-depth: May be `bottom | orphan | auto | top`. The first drawn is `bottom`, then `orphan` which is the
same depth as the root of the compound graph, followed by the default value `auto` which draws in order from
root to leaves of the compound graph. The last drawn is `top`.
z-index-compare: May be `auto | manual`. The default value is `auto` which always draws edges under nodes.
`manual` ignores this convention and draws based on the `z-index` value setting.
z-index: An integer value that affects the relative draw order of elements. In general, an element with a higher
`z-index` will be drawn on top of an element with a lower `z-index`.
|
assignDepths
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
adjustMaximally = function adjustMaximally(ele, shifted) {
var eInfo = getInfo(ele);
var incomers = ele.incomers().filter(function (el) {
return el.isNode() && eles.has(el);
});
var maxDepth = -1;
var id = ele.id();
for (var k = 0; k < incomers.length; k++) {
var incmr = incomers[k];
var iInfo = getInfo(incmr);
maxDepth = Math.max(maxDepth, iInfo.depth);
}
if (eInfo.depth <= maxDepth) {
if (shifted[id]) {
return null;
}
changeDepth(ele, maxDepth + 1);
shifted[id] = true;
return true;
}
return false;
}
|
Elements are drawn in a specific order based on compound depth (low to high), the element type (nodes above edges),
and z-index (low to high). These styles affect how this applies:
z-compound-depth: May be `bottom | orphan | auto | top`. The first drawn is `bottom`, then `orphan` which is the
same depth as the root of the compound graph, followed by the default value `auto` which draws in order from
root to leaves of the compound graph. The last drawn is `top`.
z-index-compare: May be `auto | manual`. The default value is `auto` which always draws edges under nodes.
`manual` ignores this convention and draws based on the `z-index` value setting.
z-index: An integer value that affects the relative draw order of elements. In general, an element with a higher
`z-index` will be drawn on top of an element with a lower `z-index`.
|
adjustMaximally
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
enqueue = function enqueue(n) {
return Q.push(n);
}
|
Elements are drawn in a specific order based on compound depth (low to high), the element type (nodes above edges),
and z-index (low to high). These styles affect how this applies:
z-compound-depth: May be `bottom | orphan | auto | top`. The first drawn is `bottom`, then `orphan` which is the
same depth as the root of the compound graph, followed by the default value `auto` which draws in order from
root to leaves of the compound graph. The last drawn is `top`.
z-index-compare: May be `auto | manual`. The default value is `auto` which always draws edges under nodes.
`manual` ignores this convention and draws based on the `z-index` value setting.
z-index: An integer value that affects the relative draw order of elements. In general, an element with a higher
`z-index` will be drawn on top of an element with a lower `z-index`.
|
enqueue
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
dequeue = function dequeue() {
return Q.shift();
}
|
Elements are drawn in a specific order based on compound depth (low to high), the element type (nodes above edges),
and z-index (low to high). These styles affect how this applies:
z-compound-depth: May be `bottom | orphan | auto | top`. The first drawn is `bottom`, then `orphan` which is the
same depth as the root of the compound graph, followed by the default value `auto` which draws in order from
root to leaves of the compound graph. The last drawn is `top`.
z-index-compare: May be `auto | manual`. The default value is `auto` which always draws edges under nodes.
`manual` ignores this convention and draws based on the `z-index` value setting.
z-index: An integer value that affects the relative draw order of elements. In general, an element with a higher
`z-index` will be drawn on top of an element with a lower `z-index`.
|
dequeue
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
getWeightedPercent = function getWeightedPercent(ele) {
if (cachedWeightedPercent[ele.id()]) {
return cachedWeightedPercent[ele.id()];
}
var eleDepth = getInfo(ele).depth;
var neighbors = ele.neighborhood();
var percent = 0;
var samples = 0;
for (var _i5 = 0; _i5 < neighbors.length; _i5++) {
var neighbor = neighbors[_i5];
if (neighbor.isEdge() || neighbor.isParent() || !nodes.has(neighbor)) {
continue;
}
var bf = getInfo(neighbor);
if (bf == null) {
continue;
}
var index = bf.index;
var depth = bf.depth; // unassigned neighbours shouldn't affect the ordering
if (index == null || depth == null) {
continue;
}
var nDepth = depths[depth].length;
if (depth < eleDepth) {
// only get influenced by elements above
percent += index / nDepth;
samples++;
}
}
samples = Math.max(1, samples);
percent = percent / samples;
if (samples === 0) {
// put lone nodes at the start
percent = 0;
}
cachedWeightedPercent[ele.id()] = percent;
return percent;
}
|
Elements are drawn in a specific order based on compound depth (low to high), the element type (nodes above edges),
and z-index (low to high). These styles affect how this applies:
z-compound-depth: May be `bottom | orphan | auto | top`. The first drawn is `bottom`, then `orphan` which is the
same depth as the root of the compound graph, followed by the default value `auto` which draws in order from
root to leaves of the compound graph. The last drawn is `top`.
z-index-compare: May be `auto | manual`. The default value is `auto` which always draws edges under nodes.
`manual` ignores this convention and draws based on the `z-index` value setting.
z-index: An integer value that affects the relative draw order of elements. In general, an element with a higher
`z-index` will be drawn on top of an element with a lower `z-index`.
|
getWeightedPercent
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
sortFn = function sortFn(a, b) {
var apct = getWeightedPercent(a);
var bpct = getWeightedPercent(b);
var diff = apct - bpct;
if (diff === 0) {
return ascending(a.id(), b.id()); // make sure sort doesn't have don't-care comparisons
} else {
return diff;
}
}
|
Elements are drawn in a specific order based on compound depth (low to high), the element type (nodes above edges),
and z-index (low to high). These styles affect how this applies:
z-compound-depth: May be `bottom | orphan | auto | top`. The first drawn is `bottom`, then `orphan` which is the
same depth as the root of the compound graph, followed by the default value `auto` which draws in order from
root to leaves of the compound graph. The last drawn is `top`.
z-index-compare: May be `auto | manual`. The default value is `auto` which always draws edges under nodes.
`manual` ignores this convention and draws based on the `z-index` value setting.
z-index: An integer value that affects the relative draw order of elements. In general, an element with a higher
`z-index` will be drawn on top of an element with a lower `z-index`.
|
sortFn
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
getPosition = function getPosition(ele) {
var _getInfo2 = getInfo(ele),
depth = _getInfo2.depth,
index = _getInfo2.index;
var depthSize = depths[depth].length;
var distanceX = Math.max(bb.w / ((options.grid ? maxDepthSize : depthSize) + 1), minDistance);
var distanceY = Math.max(bb.h / (depths.length + 1), minDistance);
var radiusStepSize = Math.min(bb.w / 2 / depths.length, bb.h / 2 / depths.length);
radiusStepSize = Math.max(radiusStepSize, minDistance);
if (!options.circle) {
var epos = {
x: center.x + (index + 1 - (depthSize + 1) / 2) * distanceX,
y: (depth + 1) * distanceY
};
return epos;
} else {
var radius = radiusStepSize * depth + radiusStepSize - (depths.length > 0 && depths[0].length <= 3 ? radiusStepSize / 2 : 0);
var theta = 2 * Math.PI / depths[depth].length * index;
if (depth === 0 && depths[0].length === 1) {
radius = 1;
}
return {
x: center.x + radius * Math.cos(theta),
y: center.y + radius * Math.sin(theta)
};
}
}
|
Elements are drawn in a specific order based on compound depth (low to high), the element type (nodes above edges),
and z-index (low to high). These styles affect how this applies:
z-compound-depth: May be `bottom | orphan | auto | top`. The first drawn is `bottom`, then `orphan` which is the
same depth as the root of the compound graph, followed by the default value `auto` which draws in order from
root to leaves of the compound graph. The last drawn is `top`.
z-index-compare: May be `auto | manual`. The default value is `auto` which always draws edges under nodes.
`manual` ignores this convention and draws based on the `z-index` value setting.
z-index: An integer value that affects the relative draw order of elements. In general, an element with a higher
`z-index` will be drawn on top of an element with a lower `z-index`.
|
getPosition
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
function CircleLayout(options) {
this.options = extend({}, defaults$a, options);
}
|
Elements are drawn in a specific order based on compound depth (low to high), the element type (nodes above edges),
and z-index (low to high). These styles affect how this applies:
z-compound-depth: May be `bottom | orphan | auto | top`. The first drawn is `bottom`, then `orphan` which is the
same depth as the root of the compound graph, followed by the default value `auto` which draws in order from
root to leaves of the compound graph. The last drawn is `top`.
z-index-compare: May be `auto | manual`. The default value is `auto` which always draws edges under nodes.
`manual` ignores this convention and draws based on the `z-index` value setting.
z-index: An integer value that affects the relative draw order of elements. In general, an element with a higher
`z-index` will be drawn on top of an element with a lower `z-index`.
|
CircleLayout
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
getPos = function getPos(ele, i) {
var theta = options.startAngle + i * dTheta * (clockwise ? 1 : -1);
var rx = r * Math.cos(theta);
var ry = r * Math.sin(theta);
var pos = {
x: center.x + rx,
y: center.y + ry
};
return pos;
}
|
Elements are drawn in a specific order based on compound depth (low to high), the element type (nodes above edges),
and z-index (low to high). These styles affect how this applies:
z-compound-depth: May be `bottom | orphan | auto | top`. The first drawn is `bottom`, then `orphan` which is the
same depth as the root of the compound graph, followed by the default value `auto` which draws in order from
root to leaves of the compound graph. The last drawn is `top`.
z-index-compare: May be `auto | manual`. The default value is `auto` which always draws edges under nodes.
`manual` ignores this convention and draws based on the `z-index` value setting.
z-index: An integer value that affects the relative draw order of elements. In general, an element with a higher
`z-index` will be drawn on top of an element with a lower `z-index`.
|
getPos
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
function ConcentricLayout(options) {
this.options = extend({}, defaults$b, options);
}
|
Elements are drawn in a specific order based on compound depth (low to high), the element type (nodes above edges),
and z-index (low to high). These styles affect how this applies:
z-compound-depth: May be `bottom | orphan | auto | top`. The first drawn is `bottom`, then `orphan` which is the
same depth as the root of the compound graph, followed by the default value `auto` which draws in order from
root to leaves of the compound graph. The last drawn is `top`.
z-index-compare: May be `auto | manual`. The default value is `auto` which always draws edges under nodes.
`manual` ignores this convention and draws based on the `z-index` value setting.
z-index: An integer value that affects the relative draw order of elements. In general, an element with a higher
`z-index` will be drawn on top of an element with a lower `z-index`.
|
ConcentricLayout
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
function CoseLayout(options) {
this.options = extend({}, defaults$c, options);
this.options.layout = this;
}
|
@brief : constructor
@arg options : object containing layout options
|
CoseLayout
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
createLayoutInfo = function createLayoutInfo(cy, layout, options) {
// Shortcut
var edges = options.eles.edges();
var nodes = options.eles.nodes();
var layoutInfo = {
isCompound: cy.hasCompoundNodes(),
layoutNodes: [],
idToIndex: {},
nodeSize: nodes.size(),
graphSet: [],
indexToGraph: [],
layoutEdges: [],
edgeSize: edges.size(),
temperature: options.initialTemp,
clientWidth: cy.width(),
clientHeight: cy.width(),
boundingBox: makeBoundingBox(options.boundingBox ? options.boundingBox : {
x1: 0,
y1: 0,
w: cy.width(),
h: cy.height()
})
};
var components = options.eles.components();
var id2cmptId = {};
for (var i = 0; i < components.length; i++) {
var component = components[i];
for (var j = 0; j < component.length; j++) {
var node = component[j];
id2cmptId[node.id()] = i;
}
} // Iterate over all nodes, creating layout nodes
for (var i = 0; i < layoutInfo.nodeSize; i++) {
var n = nodes[i];
var nbb = n.layoutDimensions(options);
var tempNode = {};
tempNode.isLocked = n.locked();
tempNode.id = n.data('id');
tempNode.parentId = n.data('parent');
tempNode.cmptId = id2cmptId[n.id()];
tempNode.children = [];
tempNode.positionX = n.position('x');
tempNode.positionY = n.position('y');
tempNode.offsetX = 0;
tempNode.offsetY = 0;
tempNode.height = nbb.w;
tempNode.width = nbb.h;
tempNode.maxX = tempNode.positionX + tempNode.width / 2;
tempNode.minX = tempNode.positionX - tempNode.width / 2;
tempNode.maxY = tempNode.positionY + tempNode.height / 2;
tempNode.minY = tempNode.positionY - tempNode.height / 2;
tempNode.padLeft = parseFloat(n.style('padding'));
tempNode.padRight = parseFloat(n.style('padding'));
tempNode.padTop = parseFloat(n.style('padding'));
tempNode.padBottom = parseFloat(n.style('padding')); // forces
tempNode.nodeRepulsion = fn(options.nodeRepulsion) ? options.nodeRepulsion(n) : options.nodeRepulsion; // Add new node
layoutInfo.layoutNodes.push(tempNode); // Add entry to id-index map
layoutInfo.idToIndex[tempNode.id] = i;
} // Inline implementation of a queue, used for traversing the graph in BFS order
var queue = [];
var start = 0; // Points to the start the queue
var end = -1; // Points to the end of the queue
var tempGraph = []; // Second pass to add child information and
// initialize queue for hierarchical traversal
for (var i = 0; i < layoutInfo.nodeSize; i++) {
var n = layoutInfo.layoutNodes[i];
var p_id = n.parentId; // Check if node n has a parent node
if (null != p_id) {
// Add node Id to parent's list of children
layoutInfo.layoutNodes[layoutInfo.idToIndex[p_id]].children.push(n.id);
} else {
// If a node doesn't have a parent, then it's in the root graph
queue[++end] = n.id;
tempGraph.push(n.id);
}
} // Add root graph to graphSet
layoutInfo.graphSet.push(tempGraph); // Traverse the graph, level by level,
while (start <= end) {
// Get the node to visit and remove it from queue
var node_id = queue[start++];
var node_ix = layoutInfo.idToIndex[node_id];
var node = layoutInfo.layoutNodes[node_ix];
var children = node.children;
if (children.length > 0) {
// Add children nodes as a new graph to graph set
layoutInfo.graphSet.push(children); // Add children to que queue to be visited
for (var i = 0; i < children.length; i++) {
queue[++end] = children[i];
}
}
} // Create indexToGraph map
for (var i = 0; i < layoutInfo.graphSet.length; i++) {
var graph = layoutInfo.graphSet[i];
for (var j = 0; j < graph.length; j++) {
var index = layoutInfo.idToIndex[graph[j]];
layoutInfo.indexToGraph[index] = i;
}
} // Iterate over all edges, creating Layout Edges
for (var i = 0; i < layoutInfo.edgeSize; i++) {
var e = edges[i];
var tempEdge = {};
tempEdge.id = e.data('id');
tempEdge.sourceId = e.data('source');
tempEdge.targetId = e.data('target'); // Compute ideal length
var idealLength = fn(options.idealEdgeLength) ? options.idealEdgeLength(e) : options.idealEdgeLength;
var elasticity = fn(options.edgeElasticity) ? options.edgeElasticity(e) : options.edgeElasticity; // Check if it's an inter graph edge
var sourceIx = layoutInfo.idToIndex[tempEdge.sourceId];
var targetIx = layoutInfo.idToIndex[tempEdge.targetId];
var sourceGraph = layoutInfo.indexToGraph[sourceIx];
var targetGraph = layoutInfo.indexToGraph[targetIx];
if (sourceGraph != targetGraph) {
// Find lowest common graph ancestor
var lca = findLCA(tempEdge.sourceId, tempEdge.targetId, layoutInfo); // Compute sum of node depths, relative to lca graph
var lcaGraph = layoutInfo.graphSet[lca];
var depth = 0; // Source depth
var tempNode = layoutInfo.layoutNodes[sourceIx];
while (-1 === lcaGraph.indexOf(tempNode.id)) {
tempNode = layoutInfo.layoutNodes[layoutInfo.idToIndex[tempNode.parentId]];
depth++;
} // Target depth
tempNode = layoutInfo.layoutNodes[targetIx];
while (-1 === lcaGraph.indexOf(tempNode.id)) {
tempNode = layoutInfo.layoutNodes[layoutInfo.idToIndex[tempNode.parentId]];
depth++;
} // logDebug('LCA of nodes ' + tempEdge.sourceId + ' and ' + tempEdge.targetId +
// ". Index: " + lca + " Contents: " + lcaGraph.toString() +
// ". Depth: " + depth);
// Update idealLength
idealLength *= depth * options.nestingFactor;
}
tempEdge.idealLength = idealLength;
tempEdge.elasticity = elasticity;
layoutInfo.layoutEdges.push(tempEdge);
} // Finally, return layoutInfo object
return layoutInfo;
}
|
@brief : Creates an object which is contains all the data
used in the layout process
@arg cy : cytoscape.js object
@return : layoutInfo object initialized
|
createLayoutInfo
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
findLCA = function findLCA(node1, node2, layoutInfo) {
// Find their common ancester, starting from the root graph
var res = findLCA_aux(node1, node2, 0, layoutInfo);
if (2 > res.count) {
// If aux function couldn't find the common ancester,
// then it is the root graph
return 0;
} else {
return res.graph;
}
}
|
@brief : This function finds the index of the lowest common
graph ancestor between 2 nodes in the subtree
(from the graph hierarchy induced tree) whose
root is graphIx
@arg node1: node1's ID
@arg node2: node2's ID
@arg layoutInfo: layoutInfo object
|
findLCA
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
findLCA_aux = function findLCA_aux(node1, node2, graphIx, layoutInfo) {
var graph = layoutInfo.graphSet[graphIx]; // If both nodes belongs to graphIx
if (-1 < graph.indexOf(node1) && -1 < graph.indexOf(node2)) {
return {
count: 2,
graph: graphIx
};
} // Make recursive calls for all subgraphs
var c = 0;
for (var i = 0; i < graph.length; i++) {
var nodeId = graph[i];
var nodeIx = layoutInfo.idToIndex[nodeId];
var children = layoutInfo.layoutNodes[nodeIx].children; // If the node has no child, skip it
if (0 === children.length) {
continue;
}
var childGraphIx = layoutInfo.indexToGraph[layoutInfo.idToIndex[children[0]]];
var result = findLCA_aux(node1, node2, childGraphIx, layoutInfo);
if (0 === result.count) {
// Neither node1 nor node2 are present in this subgraph
continue;
} else if (1 === result.count) {
// One of (node1, node2) is present in this subgraph
c++;
if (2 === c) {
// We've already found both nodes, no need to keep searching
break;
}
} else {
// Both nodes are present in this subgraph
return result;
}
}
return {
count: c,
graph: graphIx
};
}
|
@brief : Auxiliary function used for LCA computation
@arg node1 : node1's ID
@arg node2 : node2's ID
@arg graphIx : subgraph index
@arg layoutInfo : layoutInfo object
@return : object of the form {count: X, graph: Y}, where:
X is the number of ancesters (max: 2) found in
graphIx (and it's subgraphs),
Y is the graph index of the lowest graph containing
all X nodes
|
findLCA_aux
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
randomizePositions = function randomizePositions(layoutInfo, cy) {
var width = layoutInfo.clientWidth;
var height = layoutInfo.clientHeight;
for (var i = 0; i < layoutInfo.nodeSize; i++) {
var n = layoutInfo.layoutNodes[i]; // No need to randomize compound nodes or locked nodes
if (0 === n.children.length && !n.isLocked) {
n.positionX = Math.random() * width;
n.positionY = Math.random() * height;
}
}
}
|
@brief : Randomizes the position of all nodes
|
randomizePositions
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
getScaleInBoundsFn = function getScaleInBoundsFn(layoutInfo, options, nodes) {
var bb = layoutInfo.boundingBox;
var coseBB = {
x1: Infinity,
x2: -Infinity,
y1: Infinity,
y2: -Infinity
};
if (options.boundingBox) {
nodes.forEach(function (node) {
var lnode = layoutInfo.layoutNodes[layoutInfo.idToIndex[node.data('id')]];
coseBB.x1 = Math.min(coseBB.x1, lnode.positionX);
coseBB.x2 = Math.max(coseBB.x2, lnode.positionX);
coseBB.y1 = Math.min(coseBB.y1, lnode.positionY);
coseBB.y2 = Math.max(coseBB.y2, lnode.positionY);
});
coseBB.w = coseBB.x2 - coseBB.x1;
coseBB.h = coseBB.y2 - coseBB.y1;
}
return function (ele, i) {
var lnode = layoutInfo.layoutNodes[layoutInfo.idToIndex[ele.data('id')]];
if (options.boundingBox) {
// then add extra bounding box constraint
var pctX = (lnode.positionX - coseBB.x1) / coseBB.w;
var pctY = (lnode.positionY - coseBB.y1) / coseBB.h;
return {
x: bb.x1 + pctX * bb.w,
y: bb.y1 + pctY * bb.h
};
} else {
return {
x: lnode.positionX,
y: lnode.positionY
};
}
};
}
|
@brief : Randomizes the position of all nodes
|
getScaleInBoundsFn
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
refreshPositions = function refreshPositions(layoutInfo, cy, options) {
// var s = 'Refreshing positions';
// logDebug(s);
var layout = options.layout;
var nodes = options.eles.nodes();
var getScaledPos = getScaleInBoundsFn(layoutInfo, options, nodes);
nodes.positions(getScaledPos); // Trigger layoutReady only on first call
if (true !== layoutInfo.ready) {
// s = 'Triggering layoutready';
// logDebug(s);
layoutInfo.ready = true;
layout.one('layoutready', options.ready);
layout.emit({
type: 'layoutready',
layout: this
});
}
}
|
@brief : Updates the positions of nodes in the network
@arg layoutInfo : LayoutInfo object
@arg cy : Cytoscape object
@arg options : Layout options
|
refreshPositions
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
step$1 = function step(layoutInfo, options, _step) {
// var s = "\n\n###############################";
// s += "\nSTEP: " + step;
// s += "\n###############################\n";
// logDebug(s);
// Calculate node repulsions
calculateNodeForces(layoutInfo, options); // Calculate edge forces
calculateEdgeForces(layoutInfo); // Calculate gravity forces
calculateGravityForces(layoutInfo, options); // Propagate forces from parent to child
propagateForces(layoutInfo); // Update positions based on calculated forces
updatePositions(layoutInfo);
}
|
@brief : Performs one iteration of the physical simulation
@arg layoutInfo : LayoutInfo object already initialized
@arg cy : Cytoscape object
@arg options : Layout options
|
step$1
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
calculateNodeForces = function calculateNodeForces(layoutInfo, options) {
// Go through each of the graphs in graphSet
// Nodes only repel each other if they belong to the same graph
// var s = 'calculateNodeForces';
// logDebug(s);
for (var i = 0; i < layoutInfo.graphSet.length; i++) {
var graph = layoutInfo.graphSet[i];
var numNodes = graph.length; // s = "Set: " + graph.toString();
// logDebug(s);
// Now get all the pairs of nodes
// Only get each pair once, (A, B) = (B, A)
for (var j = 0; j < numNodes; j++) {
var node1 = layoutInfo.layoutNodes[layoutInfo.idToIndex[graph[j]]];
for (var k = j + 1; k < numNodes; k++) {
var node2 = layoutInfo.layoutNodes[layoutInfo.idToIndex[graph[k]]];
nodeRepulsion(node1, node2, layoutInfo, options);
}
}
}
}
|
@brief : Computes the node repulsion forces
|
calculateNodeForces
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
randomDistance = function randomDistance(max) {
return -max + 2 * max * Math.random();
}
|
@brief : Computes the node repulsion forces
|
randomDistance
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
nodeRepulsion = function nodeRepulsion(node1, node2, layoutInfo, options) {
// var s = "Node repulsion. Node1: " + node1.id + " Node2: " + node2.id;
var cmptId1 = node1.cmptId;
var cmptId2 = node2.cmptId;
if (cmptId1 !== cmptId2 && !layoutInfo.isCompound) {
return;
} // Get direction of line connecting both node centers
var directionX = node2.positionX - node1.positionX;
var directionY = node2.positionY - node1.positionY;
var maxRandDist = 1; // s += "\ndirectionX: " + directionX + ", directionY: " + directionY;
// If both centers are the same, apply a random force
if (0 === directionX && 0 === directionY) {
directionX = randomDistance(maxRandDist);
directionY = randomDistance(maxRandDist);
}
var overlap = nodesOverlap(node1, node2, directionX, directionY);
if (overlap > 0) {
// s += "\nNodes DO overlap.";
// s += "\nOverlap: " + overlap;
// If nodes overlap, repulsion force is proportional
// to the overlap
var force = options.nodeOverlap * overlap; // Compute the module and components of the force vector
var distance = Math.sqrt(directionX * directionX + directionY * directionY); // s += "\nDistance: " + distance;
var forceX = force * directionX / distance;
var forceY = force * directionY / distance;
} else {
// s += "\nNodes do NOT overlap.";
// If there's no overlap, force is inversely proportional
// to squared distance
// Get clipping points for both nodes
var point1 = findClippingPoint(node1, directionX, directionY);
var point2 = findClippingPoint(node2, -1 * directionX, -1 * directionY); // Use clipping points to compute distance
var distanceX = point2.x - point1.x;
var distanceY = point2.y - point1.y;
var distanceSqr = distanceX * distanceX + distanceY * distanceY;
var distance = Math.sqrt(distanceSqr); // s += "\nDistance: " + distance;
// Compute the module and components of the force vector
var force = (node1.nodeRepulsion + node2.nodeRepulsion) / distanceSqr;
var forceX = force * distanceX / distance;
var forceY = force * distanceY / distance;
} // Apply force
if (!node1.isLocked) {
node1.offsetX -= forceX;
node1.offsetY -= forceY;
}
if (!node2.isLocked) {
node2.offsetX += forceX;
node2.offsetY += forceY;
} // s += "\nForceX: " + forceX + " ForceY: " + forceY;
// logDebug(s);
return;
}
|
@brief : Compute the node repulsion forces between a pair of nodes
|
nodeRepulsion
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
nodesOverlap = function nodesOverlap(node1, node2, dX, dY) {
if (dX > 0) {
var overlapX = node1.maxX - node2.minX;
} else {
var overlapX = node2.maxX - node1.minX;
}
if (dY > 0) {
var overlapY = node1.maxY - node2.minY;
} else {
var overlapY = node2.maxY - node1.minY;
}
if (overlapX >= 0 && overlapY >= 0) {
return Math.sqrt(overlapX * overlapX + overlapY * overlapY);
} else {
return 0;
}
}
|
@brief : Determines whether two nodes overlap or not
@return : Amount of overlapping (0 => no overlap)
|
nodesOverlap
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
findClippingPoint = function findClippingPoint(node, dX, dY) {
// Shorcuts
var X = node.positionX;
var Y = node.positionY;
var H = node.height || 1;
var W = node.width || 1;
var dirSlope = dY / dX;
var nodeSlope = H / W; // var s = 'Computing clipping point of node ' + node.id +
// " . Height: " + H + ", Width: " + W +
// "\nDirection " + dX + ", " + dY;
//
// Compute intersection
var res = {}; // Case: Vertical direction (up)
if (0 === dX && 0 < dY) {
res.x = X; // s += "\nUp direction";
res.y = Y + H / 2;
return res;
} // Case: Vertical direction (down)
if (0 === dX && 0 > dY) {
res.x = X;
res.y = Y + H / 2; // s += "\nDown direction";
return res;
} // Case: Intersects the right border
if (0 < dX && -1 * nodeSlope <= dirSlope && dirSlope <= nodeSlope) {
res.x = X + W / 2;
res.y = Y + W * dY / 2 / dX; // s += "\nRightborder";
return res;
} // Case: Intersects the left border
if (0 > dX && -1 * nodeSlope <= dirSlope && dirSlope <= nodeSlope) {
res.x = X - W / 2;
res.y = Y - W * dY / 2 / dX; // s += "\nLeftborder";
return res;
} // Case: Intersects the top border
if (0 < dY && (dirSlope <= -1 * nodeSlope || dirSlope >= nodeSlope)) {
res.x = X + H * dX / 2 / dY;
res.y = Y + H / 2; // s += "\nTop border";
return res;
} // Case: Intersects the bottom border
if (0 > dY && (dirSlope <= -1 * nodeSlope || dirSlope >= nodeSlope)) {
res.x = X - H * dX / 2 / dY;
res.y = Y - H / 2; // s += "\nBottom border";
return res;
} // s += "\nClipping point found at " + res.x + ", " + res.y;
// logDebug(s);
return res;
}
|
@brief : Finds the point in which an edge (direction dX, dY) intersects
the rectangular bounding box of it's source/target node
|
findClippingPoint
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
calculateGravityForces = function calculateGravityForces(layoutInfo, options) {
if (options.gravity === 0) {
return;
}
var distThreshold = 1; // var s = 'calculateGravityForces';
// logDebug(s);
for (var i = 0; i < layoutInfo.graphSet.length; i++) {
var graph = layoutInfo.graphSet[i];
var numNodes = graph.length; // s = "Set: " + graph.toString();
// logDebug(s);
// Compute graph center
if (0 === i) {
var centerX = layoutInfo.clientHeight / 2;
var centerY = layoutInfo.clientWidth / 2;
} else {
// Get Parent node for this graph, and use its position as center
var temp = layoutInfo.layoutNodes[layoutInfo.idToIndex[graph[0]]];
var parent = layoutInfo.layoutNodes[layoutInfo.idToIndex[temp.parentId]];
var centerX = parent.positionX;
var centerY = parent.positionY;
} // s = "Center found at: " + centerX + ", " + centerY;
// logDebug(s);
// Apply force to all nodes in graph
for (var j = 0; j < numNodes; j++) {
var node = layoutInfo.layoutNodes[layoutInfo.idToIndex[graph[j]]]; // s = "Node: " + node.id;
if (node.isLocked) {
continue;
}
var dx = centerX - node.positionX;
var dy = centerY - node.positionY;
var d = Math.sqrt(dx * dx + dy * dy);
if (d > distThreshold) {
var fx = options.gravity * dx / d;
var fy = options.gravity * dy / d;
node.offsetX += fx;
node.offsetY += fy; // s += ": Applied force: " + fx + ", " + fy;
} // s += ": skypped since it's too close to center";
// logDebug(s);
}
}
}
|
@brief : Computes gravity forces for all nodes
|
calculateGravityForces
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
propagateForces = function propagateForces(layoutInfo, options) {
// Inline implementation of a queue, used for traversing the graph in BFS order
var queue = [];
var start = 0; // Points to the start the queue
var end = -1; // Points to the end of the queue
// logDebug('propagateForces');
// Start by visiting the nodes in the root graph
queue.push.apply(queue, layoutInfo.graphSet[0]);
end += layoutInfo.graphSet[0].length; // Traverse the graph, level by level,
while (start <= end) {
// Get the node to visit and remove it from queue
var nodeId = queue[start++];
var nodeIndex = layoutInfo.idToIndex[nodeId];
var node = layoutInfo.layoutNodes[nodeIndex];
var children = node.children; // We only need to process the node if it's compound
if (0 < children.length && !node.isLocked) {
var offX = node.offsetX;
var offY = node.offsetY; // var s = "Propagating offset from parent node : " + node.id +
// ". OffsetX: " + offX + ". OffsetY: " + offY;
// s += "\n Children: " + children.toString();
// logDebug(s);
for (var i = 0; i < children.length; i++) {
var childNode = layoutInfo.layoutNodes[layoutInfo.idToIndex[children[i]]]; // Propagate offset
childNode.offsetX += offX;
childNode.offsetY += offY; // Add children to queue to be visited
queue[++end] = children[i];
} // Reset parent offsets
node.offsetX = 0;
node.offsetY = 0;
}
}
}
|
@brief : This function propagates the existing offsets from
parent nodes to its descendents.
@arg layoutInfo : layoutInfo Object
@arg cy : cytoscape Object
@arg options : Layout options
|
propagateForces
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
updatePositions = function updatePositions(layoutInfo, options) {
// var s = 'Updating positions';
// logDebug(s);
// Reset boundaries for compound nodes
for (var i = 0; i < layoutInfo.nodeSize; i++) {
var n = layoutInfo.layoutNodes[i];
if (0 < n.children.length) {
// logDebug("Resetting boundaries of compound node: " + n.id);
n.maxX = undefined;
n.minX = undefined;
n.maxY = undefined;
n.minY = undefined;
}
}
for (var i = 0; i < layoutInfo.nodeSize; i++) {
var n = layoutInfo.layoutNodes[i];
if (0 < n.children.length || n.isLocked) {
// No need to set compound or locked node position
// logDebug("Skipping position update of node: " + n.id);
continue;
} // s = "Node: " + n.id + " Previous position: (" +
// n.positionX + ", " + n.positionY + ").";
// Limit displacement in order to improve stability
var tempForce = limitForce(n.offsetX, n.offsetY, layoutInfo.temperature);
n.positionX += tempForce.x;
n.positionY += tempForce.y;
n.offsetX = 0;
n.offsetY = 0;
n.minX = n.positionX - n.width;
n.maxX = n.positionX + n.width;
n.minY = n.positionY - n.height;
n.maxY = n.positionY + n.height; // s += " New Position: (" + n.positionX + ", " + n.positionY + ").";
// logDebug(s);
// Update ancestry boudaries
updateAncestryBoundaries(n, layoutInfo);
} // Update size, position of compund nodes
for (var i = 0; i < layoutInfo.nodeSize; i++) {
var n = layoutInfo.layoutNodes[i];
if (0 < n.children.length && !n.isLocked) {
n.positionX = (n.maxX + n.minX) / 2;
n.positionY = (n.maxY + n.minY) / 2;
n.width = n.maxX - n.minX;
n.height = n.maxY - n.minY; // s = "Updating position, size of compound node " + n.id;
// s += "\nPositionX: " + n.positionX + ", PositionY: " + n.positionY;
// s += "\nWidth: " + n.width + ", Height: " + n.height;
// logDebug(s);
}
}
}
|
@brief : Updates the layout model positions, based on
the accumulated forces
|
updatePositions
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
updateAncestryBoundaries = function updateAncestryBoundaries(node, layoutInfo) {
// var s = "Propagating new position/size of node " + node.id;
var parentId = node.parentId;
if (null == parentId) {
// If there's no parent, we are done
// s += ". No parent node.";
// logDebug(s);
return;
} // Get Parent Node
var p = layoutInfo.layoutNodes[layoutInfo.idToIndex[parentId]];
var flag = false; // MaxX
if (null == p.maxX || node.maxX + p.padRight > p.maxX) {
p.maxX = node.maxX + p.padRight;
flag = true; // s += "\nNew maxX for parent node " + p.id + ": " + p.maxX;
} // MinX
if (null == p.minX || node.minX - p.padLeft < p.minX) {
p.minX = node.minX - p.padLeft;
flag = true; // s += "\nNew minX for parent node " + p.id + ": " + p.minX;
} // MaxY
if (null == p.maxY || node.maxY + p.padBottom > p.maxY) {
p.maxY = node.maxY + p.padBottom;
flag = true; // s += "\nNew maxY for parent node " + p.id + ": " + p.maxY;
} // MinY
if (null == p.minY || node.minY - p.padTop < p.minY) {
p.minY = node.minY - p.padTop;
flag = true; // s += "\nNew minY for parent node " + p.id + ": " + p.minY;
} // If updated boundaries, propagate changes upward
if (flag) {
// logDebug(s);
return updateAncestryBoundaries(p, layoutInfo);
} // s += ". No changes in boundaries/position of parent node " + p.id;
// logDebug(s);
return;
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
updateAncestryBoundaries
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
separateComponents = function separateComponents(layoutInfo, options) {
var nodes = layoutInfo.layoutNodes;
var components = [];
for (var i = 0; i < nodes.length; i++) {
var node = nodes[i];
var cid = node.cmptId;
var component = components[cid] = components[cid] || [];
component.push(node);
}
var totalA = 0;
for (var i = 0; i < components.length; i++) {
var c = components[i];
if (!c) {
continue;
}
c.x1 = Infinity;
c.x2 = -Infinity;
c.y1 = Infinity;
c.y2 = -Infinity;
for (var j = 0; j < c.length; j++) {
var n = c[j];
c.x1 = Math.min(c.x1, n.positionX - n.width / 2);
c.x2 = Math.max(c.x2, n.positionX + n.width / 2);
c.y1 = Math.min(c.y1, n.positionY - n.height / 2);
c.y2 = Math.max(c.y2, n.positionY + n.height / 2);
}
c.w = c.x2 - c.x1;
c.h = c.y2 - c.y1;
totalA += c.w * c.h;
}
components.sort(function (c1, c2) {
return c2.w * c2.h - c1.w * c1.h;
});
var x = 0;
var y = 0;
var usedW = 0;
var rowH = 0;
var maxRowW = Math.sqrt(totalA) * layoutInfo.clientWidth / layoutInfo.clientHeight;
for (var i = 0; i < components.length; i++) {
var c = components[i];
if (!c) {
continue;
}
for (var j = 0; j < c.length; j++) {
var n = c[j];
if (!n.isLocked) {
n.positionX += x - c.x1;
n.positionY += y - c.y1;
}
}
x += c.w + options.componentSpacing;
usedW += c.w + options.componentSpacing;
rowH = Math.max(rowH, c.h);
if (usedW > maxRowW) {
y += rowH + options.componentSpacing;
x = 0;
usedW = 0;
rowH = 0;
}
}
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
separateComponents
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
function GridLayout(options) {
this.options = extend({}, defaults$d, options);
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
GridLayout
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
small = function small(val) {
if (val == null) {
return Math.min(rows, cols);
} else {
var min = Math.min(rows, cols);
if (min == rows) {
rows = val;
} else {
cols = val;
}
}
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
small
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
large = function large(val) {
if (val == null) {
return Math.max(rows, cols);
} else {
var max = Math.max(rows, cols);
if (max == rows) {
rows = val;
} else {
cols = val;
}
}
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
large
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
used = function used(row, col) {
return cellUsed['c-' + row + '-' + col] ? true : false;
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
used
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
use = function use(row, col) {
cellUsed['c-' + row + '-' + col] = true;
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
use
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
moveToNextCell = function moveToNextCell() {
col++;
if (col >= cols) {
col = 0;
row++;
}
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
moveToNextCell
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
getPos = function getPos(element, i) {
var x, y;
if (element.locked() || element.isParent()) {
return false;
} // see if we have a manual position set
var rcPos = id2manPos[element.id()];
if (rcPos) {
x = rcPos.col * cellWidth + cellWidth / 2 + bb.x1;
y = rcPos.row * cellHeight + cellHeight / 2 + bb.y1;
} else {
// otherwise set automatically
while (used(row, col)) {
moveToNextCell();
}
x = col * cellWidth + cellWidth / 2 + bb.x1;
y = row * cellHeight + cellHeight / 2 + bb.y1;
use(row, col);
moveToNextCell();
}
return {
x: x,
y: y
};
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
getPos
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
function NullLayout(options) {
this.options = extend({}, defaults$e, options);
} // runs the layout
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
NullLayout
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
function PresetLayout(options) {
this.options = extend({}, defaults$f, options);
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
PresetLayout
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
function getPosition(node) {
if (options.positions == null) {
return copyPosition(node.position());
}
if (posIsFn) {
return options.positions(node);
}
var pos = options.positions[node._private.data.id];
if (pos == null) {
return null;
}
return pos;
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
getPosition
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
function RandomLayout(options) {
this.options = extend({}, defaults$g, options);
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
RandomLayout
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
getPos = function getPos(node, i) {
return {
x: bb.x1 + Math.round(Math.random() * bb.w),
y: bb.y1 + Math.round(Math.random() * bb.h)
};
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
getPos
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
function NullRenderer(options) {
this.options = options;
this.notifications = 0; // for testing
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
NullRenderer
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
throwImgErr = function throwImgErr() {
throw new Error('A headless instance can not render images');
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
throwImgErr
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
bbCollide = function bbCollide(x, y, size, angle, translation, edgeWidth, padding) {
var x1 = translation.x - size / 2 - padding;
var x2 = translation.x + size / 2 + padding;
var y1 = translation.y - size / 2 - padding;
var y2 = translation.y + size / 2 + padding;
var inside = x1 <= x && x <= x2 && y1 <= y && y <= y2;
return inside;
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
bbCollide
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
transform = function transform(x, y, size, angle, translation) {
var xRotated = x * Math.cos(angle) - y * Math.sin(angle);
var yRotated = x * Math.sin(angle) + y * Math.cos(angle);
var xScaled = xRotated * size;
var yScaled = yRotated * size;
var xTranslated = xScaled + translation.x;
var yTranslated = yScaled + translation.y;
return {
x: xTranslated,
y: yTranslated
};
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
transform
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
transformPoints = function transformPoints(pts, size, angle, translation) {
var retPts = [];
for (var i = 0; i < pts.length; i += 2) {
var x = pts[i];
var y = pts[i + 1];
retPts.push(transform(x, y, size, angle, translation));
}
return retPts;
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
transformPoints
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
pointsToArr = function pointsToArr(pts) {
var ret = [];
for (var i = 0; i < pts.length; i++) {
var p = pts[i];
ret.push(p.x, p.y);
}
return ret;
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
pointsToArr
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
standardGap = function standardGap(edge) {
return edge.pstyle('width').pfValue * edge.pstyle('arrow-scale').pfValue * 2;
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
standardGap
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
defineArrowShape = function defineArrowShape(name, defn) {
if (string(defn)) {
defn = arrowShapes[defn];
}
arrowShapes[name] = extend({
name: name,
points: [-0.15, -0.3, 0.15, -0.3, 0.15, 0.3, -0.15, 0.3],
collide: function collide(x, y, size, angle, translation, padding) {
var points = pointsToArr(transformPoints(this.points, size + 2 * padding, angle, translation));
var inside = pointInsidePolygonPoints(x, y, points);
return inside;
},
roughCollide: bbCollide,
draw: function draw(context, size, angle, translation) {
var points = transformPoints(this.points, size, angle, translation);
renderer.arrowShapeImpl('polygon')(context, points);
},
spacing: function spacing(edge) {
return 0;
},
gap: standardGap
}, defn);
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
defineArrowShape
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
styleValue = function styleValue(name) {
return parseFloat(style.getPropertyValue(name));
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
styleValue
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
function addEle(ele, sqDist) {
if (ele.isNode()) {
if (nearNode) {
return; // can't replace node
} else {
nearNode = ele;
near.push(ele);
}
}
if (ele.isEdge() && (sqDist == null || sqDist < minSqDist)) {
if (nearEdge) {
// then replace existing edge
// can replace only if same z-index
if (nearEdge.pstyle('z-compound-depth').value === ele.pstyle('z-compound-depth').value && nearEdge.pstyle('z-compound-depth').value === ele.pstyle('z-compound-depth').value) {
for (var i = 0; i < near.length; i++) {
if (near[i].isEdge()) {
near[i] = ele;
nearEdge = ele;
minSqDist = sqDist != null ? sqDist : minSqDist;
break;
}
}
}
} else {
near.push(ele);
nearEdge = ele;
minSqDist = sqDist != null ? sqDist : minSqDist;
}
}
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
addEle
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
function checkNode(node) {
var width = node.outerWidth() + 2 * nodeThreshold;
var height = node.outerHeight() + 2 * nodeThreshold;
var hw = width / 2;
var hh = height / 2;
var pos = node.position();
if (pos.x - hw <= x && x <= pos.x + hw // bb check x
&& pos.y - hh <= y && y <= pos.y + hh // bb check y
) {
var shape = r.nodeShapes[self.getNodeShape(node)];
if (shape.checkPoint(x, y, 0, width, height, pos.x, pos.y)) {
addEle(node, 0);
return true;
}
}
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
checkNode
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
function checkEdge(edge) {
var _p = edge._private;
var rs = _p.rscratch;
var styleWidth = edge.pstyle('width').pfValue;
var scale = edge.pstyle('arrow-scale').value;
var width = styleWidth / 2 + edgeThreshold; // more like a distance radius from centre
var widthSq = width * width;
var width2 = width * 2;
var src = _p.source;
var tgt = _p.target;
var sqDist;
if (rs.edgeType === 'segments' || rs.edgeType === 'straight' || rs.edgeType === 'haystack') {
var pts = rs.allpts;
for (var i = 0; i + 3 < pts.length; i += 2) {
if (inLineVicinity(x, y, pts[i], pts[i + 1], pts[i + 2], pts[i + 3], width2) && widthSq > (sqDist = sqdistToFiniteLine(x, y, pts[i], pts[i + 1], pts[i + 2], pts[i + 3]))) {
addEle(edge, sqDist);
return true;
}
}
} else if (rs.edgeType === 'bezier' || rs.edgeType === 'multibezier' || rs.edgeType === 'self' || rs.edgeType === 'compound') {
var pts = rs.allpts;
for (var i = 0; i + 5 < rs.allpts.length; i += 4) {
if (inBezierVicinity(x, y, pts[i], pts[i + 1], pts[i + 2], pts[i + 3], pts[i + 4], pts[i + 5], width2) && widthSq > (sqDist = sqdistToQuadraticBezier(x, y, pts[i], pts[i + 1], pts[i + 2], pts[i + 3], pts[i + 4], pts[i + 5]))) {
addEle(edge, sqDist);
return true;
}
}
} // if we're close to the edge but didn't hit it, maybe we hit its arrows
var src = src || _p.source;
var tgt = tgt || _p.target;
var arSize = self.getArrowWidth(styleWidth, scale);
var arrows = [{
name: 'source',
x: rs.arrowStartX,
y: rs.arrowStartY,
angle: rs.srcArrowAngle
}, {
name: 'target',
x: rs.arrowEndX,
y: rs.arrowEndY,
angle: rs.tgtArrowAngle
}, {
name: 'mid-source',
x: rs.midX,
y: rs.midY,
angle: rs.midsrcArrowAngle
}, {
name: 'mid-target',
x: rs.midX,
y: rs.midY,
angle: rs.midtgtArrowAngle
}];
for (var i = 0; i < arrows.length; i++) {
var ar = arrows[i];
var shape = r.arrowShapes[edge.pstyle(ar.name + '-arrow-shape').value];
var edgeWidth = edge.pstyle('width').pfValue;
if (shape.roughCollide(x, y, arSize, ar.angle, {
x: ar.x,
y: ar.y
}, edgeWidth, edgeThreshold) && shape.collide(x, y, arSize, ar.angle, {
x: ar.x,
y: ar.y
}, edgeWidth, edgeThreshold)) {
addEle(edge);
return true;
}
} // for compound graphs, hitting edge may actually want a connected node instead (b/c edge may have greater z-index precedence)
if (hasCompounds && near.length > 0) {
checkNode(src);
checkNode(tgt);
}
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
checkEdge
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
function preprop(obj, name, pre) {
return getPrefixedProperty(obj, name, pre);
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
preprop
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
function checkLabel(ele, prefix) {
var _p = ele._private;
var th = labelThreshold;
var prefixDash;
if (prefix) {
prefixDash = prefix + '-';
} else {
prefixDash = '';
}
ele.boundingBox();
var bb = _p.labelBounds[prefix || 'main'];
var text = ele.pstyle(prefixDash + 'label').value;
var eventsEnabled = ele.pstyle('text-events').strValue === 'yes';
if (!eventsEnabled || !text) {
return;
}
var lx = preprop(_p.rscratch, 'labelX', prefix);
var ly = preprop(_p.rscratch, 'labelY', prefix);
var theta = preprop(_p.rscratch, 'labelAngle', prefix);
var ox = ele.pstyle(prefixDash + 'text-margin-x').pfValue;
var oy = ele.pstyle(prefixDash + 'text-margin-y').pfValue;
var lx1 = bb.x1 - th - ox; // (-ox, -oy) as bb already includes margin
var lx2 = bb.x2 + th - ox; // and rotation is about (lx, ly)
var ly1 = bb.y1 - th - oy;
var ly2 = bb.y2 + th - oy;
if (theta) {
var cos = Math.cos(theta);
var sin = Math.sin(theta);
var rotate = function rotate(x, y) {
x = x - lx;
y = y - ly;
return {
x: x * cos - y * sin + lx,
y: x * sin + y * cos + ly
};
};
var px1y1 = rotate(lx1, ly1);
var px1y2 = rotate(lx1, ly2);
var px2y1 = rotate(lx2, ly1);
var px2y2 = rotate(lx2, ly2);
var points = [// with the margin added after the rotation is applied
px1y1.x + ox, px1y1.y + oy, px2y1.x + ox, px2y1.y + oy, px2y2.x + ox, px2y2.y + oy, px1y2.x + ox, px1y2.y + oy];
if (pointInsidePolygonPoints(x, y, points)) {
addEle(ele);
return true;
}
} else {
// do a cheaper bb check
if (inBoundingBox(bb, x, y)) {
addEle(ele);
return true;
}
}
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
checkLabel
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
rotate = function rotate(x, y) {
x = x - lx;
y = y - ly;
return {
x: x * cos - y * sin + lx,
y: x * sin + y * cos + ly
};
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
rotate
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
subDWH = function subDWH(dxy, dwh) {
if (dxy > 0) {
return Math.max(dxy - dwh, 0);
} else {
return Math.min(dxy + dwh, 0);
}
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
subDWH
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
getIsTooClose = function getIsTooClose(d) {
return Math.abs(d) < minD || Math.abs(d) >= Math.abs(l);
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
getIsTooClose
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
_loop = function _loop(p) {
var pairId = pairIds[p];
var pairInfo = hashTable.get(pairId);
var swappedpairInfo = void 0;
if (!pairInfo.hasUnbundled) {
var pllEdges = pairInfo.eles[0].parallelEdges().filter(function (e) {
return e.isBundledBezier();
});
clearArray(pairInfo.eles);
pllEdges.forEach(function (edge) {
return pairInfo.eles.push(edge);
}); // for each pair id, the edges should be sorted by index
pairInfo.eles.sort(function (edge1, edge2) {
return edge1.poolIndex() - edge2.poolIndex();
});
}
var firstEdge = pairInfo.eles[0];
var src = firstEdge.source();
var tgt = firstEdge.target(); // make sure src/tgt distinction is consistent w.r.t. pairId
if (src.poolIndex() > tgt.poolIndex()) {
var temp = src;
src = tgt;
tgt = temp;
}
var srcPos = pairInfo.srcPos = src.position();
var tgtPos = pairInfo.tgtPos = tgt.position();
var srcW = pairInfo.srcW = src.outerWidth();
var srcH = pairInfo.srcH = src.outerHeight();
var tgtW = pairInfo.tgtW = tgt.outerWidth();
var tgtH = pairInfo.tgtH = tgt.outerHeight();
var srcShape = pairInfo.srcShape = r.nodeShapes[_this.getNodeShape(src)];
var tgtShape = pairInfo.tgtShape = r.nodeShapes[_this.getNodeShape(tgt)];
pairInfo.dirCounts = {
'north': 0,
'west': 0,
'south': 0,
'east': 0,
'northwest': 0,
'southwest': 0,
'northeast': 0,
'southeast': 0
};
for (var _i2 = 0; _i2 < pairInfo.eles.length; _i2++) {
var _edge = pairInfo.eles[_i2];
var rs = _edge[0]._private.rscratch;
var _curveStyle = _edge.pstyle('curve-style').value;
var _edgeIsUnbundled = _curveStyle === 'unbundled-bezier' || _curveStyle === 'segments' || _curveStyle === 'taxi'; // whether the normalised pair order is the reverse of the edge's src-tgt order
var edgeIsSwapped = !src.same(_edge.source());
if (!pairInfo.calculatedIntersection && src !== tgt && (pairInfo.hasBezier || pairInfo.hasUnbundled)) {
pairInfo.calculatedIntersection = true; // pt outside src shape to calc distance/displacement from src to tgt
var srcOutside = srcShape.intersectLine(srcPos.x, srcPos.y, srcW, srcH, tgtPos.x, tgtPos.y, 0);
var srcIntn = pairInfo.srcIntn = srcOutside; // pt outside tgt shape to calc distance/displacement from src to tgt
var tgtOutside = tgtShape.intersectLine(tgtPos.x, tgtPos.y, tgtW, tgtH, srcPos.x, srcPos.y, 0);
var tgtIntn = pairInfo.tgtIntn = tgtOutside;
var intersectionPts = pairInfo.intersectionPts = {
x1: srcOutside[0],
x2: tgtOutside[0],
y1: srcOutside[1],
y2: tgtOutside[1]
};
var posPts = pairInfo.posPts = {
x1: srcPos.x,
x2: tgtPos.x,
y1: srcPos.y,
y2: tgtPos.y
};
var dy = tgtOutside[1] - srcOutside[1];
var dx = tgtOutside[0] - srcOutside[0];
var l = Math.sqrt(dx * dx + dy * dy);
var vector = pairInfo.vector = {
x: dx,
y: dy
};
var vectorNorm = pairInfo.vectorNorm = {
x: vector.x / l,
y: vector.y / l
};
var vectorNormInverse = {
x: -vectorNorm.y,
y: vectorNorm.x
}; // if node shapes overlap, then no ctrl pts to draw
pairInfo.nodesOverlap = !number(l) || tgtShape.checkPoint(srcOutside[0], srcOutside[1], 0, tgtW, tgtH, tgtPos.x, tgtPos.y) || srcShape.checkPoint(tgtOutside[0], tgtOutside[1], 0, srcW, srcH, srcPos.x, srcPos.y);
pairInfo.vectorNormInverse = vectorNormInverse;
swappedpairInfo = {
nodesOverlap: pairInfo.nodesOverlap,
dirCounts: pairInfo.dirCounts,
calculatedIntersection: true,
hasBezier: pairInfo.hasBezier,
hasUnbundled: pairInfo.hasUnbundled,
eles: pairInfo.eles,
srcPos: tgtPos,
tgtPos: srcPos,
srcW: tgtW,
srcH: tgtH,
tgtW: srcW,
tgtH: srcH,
srcIntn: tgtIntn,
tgtIntn: srcIntn,
srcShape: tgtShape,
tgtShape: srcShape,
posPts: {
x1: posPts.x2,
y1: posPts.y2,
x2: posPts.x1,
y2: posPts.y1
},
intersectionPts: {
x1: intersectionPts.x2,
y1: intersectionPts.y2,
x2: intersectionPts.x1,
y2: intersectionPts.y1
},
vector: {
x: -vector.x,
y: -vector.y
},
vectorNorm: {
x: -vectorNorm.x,
y: -vectorNorm.y
},
vectorNormInverse: {
x: -vectorNormInverse.x,
y: -vectorNormInverse.y
}
};
}
var passedPairInfo = edgeIsSwapped ? swappedpairInfo : pairInfo;
rs.nodesOverlap = passedPairInfo.nodesOverlap;
rs.srcIntn = passedPairInfo.srcIntn;
rs.tgtIntn = passedPairInfo.tgtIntn;
if (hasCompounds && (src.isParent() || src.isChild() || tgt.isParent() || tgt.isChild()) && (src.parents().anySame(tgt) || tgt.parents().anySame(src) || src.same(tgt) && src.isParent())) {
_this.findCompoundLoopPoints(_edge, passedPairInfo, _i2, _edgeIsUnbundled);
} else if (src === tgt) {
_this.findLoopPoints(_edge, passedPairInfo, _i2, _edgeIsUnbundled);
} else if (_curveStyle === 'segments') {
_this.findSegmentsPoints(_edge, passedPairInfo);
} else if (_curveStyle === 'taxi') {
_this.findTaxiPoints(_edge, passedPairInfo);
} else if (_curveStyle === 'straight' || !_edgeIsUnbundled && pairInfo.eles.length % 2 === 1 && _i2 === Math.floor(pairInfo.eles.length / 2)) {
_this.findStraightEdgePoints(_edge);
} else {
_this.findBezierPoints(_edge, passedPairInfo, _i2, _edgeIsUnbundled, edgeIsSwapped);
}
_this.findEndpoints(_edge);
_this.tryToCorrectInvalidPoints(_edge, passedPairInfo);
_this.checkForInvalidEdgeWarning(_edge);
_this.storeAllpts(_edge);
_this.storeEdgeProjections(_edge);
_this.calculateArrowAngles(_edge);
_this.recalculateEdgeLabelProjections(_edge);
_this.calculateLabelAngles(_edge);
} // for pair edges
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
_loop
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
function getPts(pts) {
var retPts = [];
if (pts == null) {
return;
}
for (var i = 0; i < pts.length; i += 2) {
var x = pts[i];
var y = pts[i + 1];
retPts.push({
x: x,
y: y
});
}
return retPts;
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
getPts
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
function pushBezierPts(r, edge, pts) {
var qbezierAt$1 = function qbezierAt$1(p1, p2, p3, t) {
return qbezierAt(p1, p2, p3, t);
};
var _p = edge._private;
var bpts = _p.rstyle.bezierPts;
for (var i = 0; i < r.bezierProjPcts.length; i++) {
var p = r.bezierProjPcts[i];
bpts.push({
x: qbezierAt$1(pts[0], pts[2], pts[4], p),
y: qbezierAt$1(pts[1], pts[3], pts[5], p)
});
}
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
pushBezierPts
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
qbezierAt$1 = function qbezierAt$1(p1, p2, p3, t) {
return qbezierAt(p1, p2, p3, t);
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
qbezierAt$1
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
lineAngleFromDelta = function lineAngleFromDelta(dx, dy) {
var angle = Math.atan(dy / dx);
if (dx === 0 && angle < 0) {
angle = angle * -1;
}
return angle;
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
lineAngleFromDelta
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
lineAngle = function lineAngle(p0, p1) {
var dx = p1.x - p0.x;
var dy = p1.y - p0.y;
return lineAngleFromDelta(dx, dy);
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
lineAngle
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
bezierAngle = function bezierAngle(p0, p1, p2, t) {
var t0 = bound(0, t - 0.001, 1);
var t1 = bound(0, t + 0.001, 1);
var lp0 = qbezierPtAt(p0, p1, p2, t0);
var lp1 = qbezierPtAt(p0, p1, p2, t1);
return lineAngle(lp0, lp1);
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
bezierAngle
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
setRs = function setRs(propName, prefix, value) {
setPrefixedProperty(_p.rscratch, propName, prefix, value);
setPrefixedProperty(_p.rstyle, propName, prefix, value);
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
setRs
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
createControlPointInfo = function createControlPointInfo() {
if (createControlPointInfo.cache) {
return createControlPointInfo.cache;
} // use cache so only 1x per edge
var ctrlpts = []; // store each ctrlpt info init
for (var i = 0; i + 5 < rs.allpts.length; i += 4) {
var p0 = {
x: rs.allpts[i],
y: rs.allpts[i + 1]
};
var p1 = {
x: rs.allpts[i + 2],
y: rs.allpts[i + 3]
}; // ctrlpt
var p2 = {
x: rs.allpts[i + 4],
y: rs.allpts[i + 5]
};
ctrlpts.push({
p0: p0,
p1: p1,
p2: p2,
startDist: 0,
length: 0,
segments: []
});
}
var bpts = _p.rstyle.bezierPts;
var nProjs = r.bezierProjPcts.length;
function addSegment(cp, p0, p1, t0, t1) {
var length = dist(p0, p1);
var prevSegment = cp.segments[cp.segments.length - 1];
var segment = {
p0: p0,
p1: p1,
t0: t0,
t1: t1,
startDist: prevSegment ? prevSegment.startDist + prevSegment.length : 0,
length: length
};
cp.segments.push(segment);
cp.length += length;
} // update each ctrlpt with segment info
for (var _i = 0; _i < ctrlpts.length; _i++) {
var cp = ctrlpts[_i];
var prevCp = ctrlpts[_i - 1];
if (prevCp) {
cp.startDist = prevCp.startDist + prevCp.length;
}
addSegment(cp, cp.p0, bpts[_i * nProjs], 0, r.bezierProjPcts[0]); // first
for (var j = 0; j < nProjs - 1; j++) {
addSegment(cp, bpts[_i * nProjs + j], bpts[_i * nProjs + j + 1], r.bezierProjPcts[j], r.bezierProjPcts[j + 1]);
}
addSegment(cp, bpts[_i * nProjs + nProjs - 1], cp.p2, r.bezierProjPcts[nProjs - 1], 1); // last
}
return createControlPointInfo.cache = ctrlpts;
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
createControlPointInfo
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
function addSegment(cp, p0, p1, t0, t1) {
var length = dist(p0, p1);
var prevSegment = cp.segments[cp.segments.length - 1];
var segment = {
p0: p0,
p1: p1,
t0: t0,
t1: t1,
startDist: prevSegment ? prevSegment.startDist + prevSegment.length : 0,
length: length
};
cp.segments.push(segment);
cp.length += length;
} // update each ctrlpt with segment info
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
addSegment
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
calculateEndProjection = function calculateEndProjection(prefix) {
var angle;
var isSrc = prefix === 'source';
if (!content[prefix]) {
return;
}
var offset = edge.pstyle(prefix + '-text-offset').pfValue;
switch (rs.edgeType) {
case 'self':
case 'compound':
case 'bezier':
case 'multibezier':
{
var cps = createControlPointInfo();
var selected;
var startDist = 0;
var totalDist = 0; // find the segment we're on
for (var i = 0; i < cps.length; i++) {
var _cp = cps[isSrc ? i : cps.length - 1 - i];
for (var j = 0; j < _cp.segments.length; j++) {
var _seg = _cp.segments[isSrc ? j : _cp.segments.length - 1 - j];
var lastSeg = i === cps.length - 1 && j === _cp.segments.length - 1;
startDist = totalDist;
totalDist += _seg.length;
if (totalDist >= offset || lastSeg) {
selected = {
cp: _cp,
segment: _seg
};
break;
}
}
if (selected) {
break;
}
}
var cp = selected.cp;
var seg = selected.segment;
var tSegment = (offset - startDist) / seg.length;
var segDt = seg.t1 - seg.t0;
var t = isSrc ? seg.t0 + segDt * tSegment : seg.t1 - segDt * tSegment;
t = bound(0, t, 1);
p = qbezierPtAt(cp.p0, cp.p1, cp.p2, t);
angle = bezierAngle(cp.p0, cp.p1, cp.p2, t);
break;
}
case 'straight':
case 'segments':
case 'haystack':
{
var d = 0,
di,
d0;
var p0, p1;
var l = rs.allpts.length;
for (var _i2 = 0; _i2 + 3 < l; _i2 += 2) {
if (isSrc) {
p0 = {
x: rs.allpts[_i2],
y: rs.allpts[_i2 + 1]
};
p1 = {
x: rs.allpts[_i2 + 2],
y: rs.allpts[_i2 + 3]
};
} else {
p0 = {
x: rs.allpts[l - 2 - _i2],
y: rs.allpts[l - 1 - _i2]
};
p1 = {
x: rs.allpts[l - 4 - _i2],
y: rs.allpts[l - 3 - _i2]
};
}
di = dist(p0, p1);
d0 = d;
d += di;
if (d >= offset) {
break;
}
}
var pD = offset - d0;
var _t = pD / di;
_t = bound(0, _t, 1);
p = lineAt(p0, p1, _t);
angle = lineAngle(p0, p1);
break;
}
}
setRs('labelX', prefix, p.x);
setRs('labelY', prefix, p.y);
setRs('labelAutoAngle', prefix, angle);
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
calculateEndProjection
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
rscratch = function rscratch(propName, value) {
if (value) {
setPrefixedProperty(_p.rscratch, propName, prefix, value);
return value;
} else {
return getPrefixedProperty(_p.rscratch, propName, prefix);
}
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
rscratch
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
enqueue = function enqueue(eles) {
var dirtyStyleCaches = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
elesToUpdate.merge(eles);
if (dirtyStyleCaches) {
for (var i = 0; i < eles.length; i++) {
var ele = eles[i];
var _p = ele._private;
var rstyle = _p.rstyle;
rstyle.clean = false;
rstyle.cleanConnected = false;
}
}
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
enqueue
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
updateEleCalcs = function updateEleCalcs(willDraw) {
if (willDraw) {
var fns = r.onUpdateEleCalcsFns; // because we need to have up-to-date style (e.g. stylesheet mappers)
// before calculating rendered style (and pstyle might not be called yet)
elesToUpdate.cleanStyle();
for (var i = 0; i < elesToUpdate.length; i++) {
var ele = elesToUpdate[i];
var rstyle = ele._private.rstyle;
if (ele.isNode() && !rstyle.cleanConnected) {
enqueue(ele.connectedEdges());
rstyle.cleanConnected = true;
}
}
if (fns) {
for (var _i = 0; _i < fns.length; _i++) {
var fn = fns[_i];
fn(willDraw, elesToUpdate);
}
}
r.recalculateRenderedStyle(elesToUpdate);
elesToUpdate = cy.collection();
}
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
updateEleCalcs
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
isCleanConnected = function isCleanConnected(ele) {
return ele._private.rstyle.cleanConnected;
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
isCleanConnected
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
on = function on(event, handler, useCapture) {
var args = Array.prototype.slice.call(arguments);
if (tgtIsDom && r.supportsPassiveEvents) {
// replace useCapture w/ opts obj
args[2] = {
capture: useCapture != null ? useCapture : false,
passive: false,
once: false
};
}
r.bindings.push({
target: tgt,
args: args
});
(tgt.addEventListener || tgt.on).apply(tgt, args);
return this;
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
on
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
isSelected = function isSelected(ele) {
return ele.selected();
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
isSelected
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
triggerEvents = function triggerEvents(target, names, e, position) {
if (target == null) {
target = r.cy;
}
for (var i = 0; i < names.length; i++) {
var name = names[i];
target.emit({
originalEvent: e,
type: name,
position: position
});
}
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
triggerEvents
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
isMultSelKeyDown = function isMultSelKeyDown(e) {
return e.shiftKey || e.metaKey || e.ctrlKey; // maybe e.altKey
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
isMultSelKeyDown
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
allowPanningPassthrough = function allowPanningPassthrough(down, downs) {
var allowPassthrough = true;
if (r.cy.hasCompoundNodes() && down && down.pannable()) {
// a grabbable compound node below the ele => no passthrough panning
for (var i = 0; downs && i < downs.length; i++) {
var down = downs[i]; //if any parent node in event hierarchy isn't pannable, reject passthrough
if (down.isNode() && down.isParent() && !down.pannable()) {
allowPassthrough = false;
break;
}
}
} else {
allowPassthrough = true;
}
return allowPassthrough;
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
allowPanningPassthrough
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
setGrabbed = function setGrabbed(ele) {
ele[0]._private.grabbed = true;
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
setGrabbed
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
setFreed = function setFreed(ele) {
ele[0]._private.grabbed = false;
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
setFreed
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
setInDragLayer = function setInDragLayer(ele) {
ele[0]._private.rscratch.inDragLayer = true;
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
setInDragLayer
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
setOutDragLayer = function setOutDragLayer(ele) {
ele[0]._private.rscratch.inDragLayer = false;
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
setOutDragLayer
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
setGrabTarget = function setGrabTarget(ele) {
ele[0]._private.rscratch.isGrabTarget = true;
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
setGrabTarget
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
removeGrabTarget = function removeGrabTarget(ele) {
ele[0]._private.rscratch.isGrabTarget = false;
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
removeGrabTarget
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
addToDragList = function addToDragList(ele, opts) {
var list = opts.addToList;
var listHasEle = list.has(ele);
if (!listHasEle) {
list.merge(ele);
setGrabbed(ele);
}
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
addToDragList
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
addDescendantsToDrag = function addDescendantsToDrag(node, opts) {
if (!node.cy().hasCompoundNodes()) {
return;
}
if (opts.inDragLayer == null && opts.addToList == null) {
return;
} // nothing to do
var innerNodes = node.descendants();
if (opts.inDragLayer) {
innerNodes.forEach(setInDragLayer);
innerNodes.connectedEdges().forEach(setInDragLayer);
}
if (opts.addToList) {
opts.addToList.unmerge(innerNodes);
}
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
addDescendantsToDrag
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
addNodesToDrag = function addNodesToDrag(nodes, opts) {
opts = opts || {};
var hasCompoundNodes = nodes.cy().hasCompoundNodes();
if (opts.inDragLayer) {
nodes.forEach(setInDragLayer);
nodes.neighborhood().stdFilter(function (ele) {
return !hasCompoundNodes || ele.isEdge();
}).forEach(setInDragLayer);
}
if (opts.addToList) {
nodes.forEach(function (ele) {
addToDragList(ele, opts);
});
}
addDescendantsToDrag(nodes, opts); // always add to drag
// also add nodes and edges related to the topmost ancestor
updateAncestorsInDragLayer(nodes, {
inDragLayer: opts.inDragLayer
});
r.updateCachedGrabbedEles();
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
addNodesToDrag
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
freeDraggedElements = function freeDraggedElements(grabbedEles) {
if (!grabbedEles) {
return;
} // just go over all elements rather than doing a bunch of (possibly expensive) traversals
r.getCachedZSortedEles().forEach(function (ele) {
setFreed(ele);
setOutDragLayer(ele);
removeGrabTarget(ele);
});
r.updateCachedGrabbedEles();
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
freeDraggedElements
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
updateAncestorsInDragLayer = function updateAncestorsInDragLayer(node, opts) {
if (opts.inDragLayer == null && opts.addToList == null) {
return;
} // nothing to do
if (!node.cy().hasCompoundNodes()) {
return;
} // find top-level parent
var parent = node.ancestors().orphans(); // no parent node: no nodes to add to the drag layer
if (parent.same(node)) {
return;
}
var nodes = parent.descendants().spawnSelf().merge(parent).unmerge(node).unmerge(node.descendants());
var edges = nodes.connectedEdges();
if (opts.inDragLayer) {
edges.forEach(setInDragLayer);
nodes.forEach(setInDragLayer);
}
if (opts.addToList) {
nodes.forEach(function (ele) {
addToDragList(ele, opts);
});
}
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
updateAncestorsInDragLayer
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
blurActiveDomElement = function blurActiveDomElement() {
if (document.activeElement != null && document.activeElement.blur != null) {
document.activeElement.blur();
}
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
blurActiveDomElement
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
forEachUp = function forEachUp(domEle, fn) {
while (domEle != null) {
fn(domEle);
domEle = domEle.parentNode;
}
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
forEachUp
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
inBoxSelection = function inBoxSelection() {
return r.selection[4] !== 0;
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
inBoxSelection
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
eventInContainer = function eventInContainer(e) {
// save cycles if mouse events aren't to be captured
var containerPageCoords = r.findContainerClientCoords();
var x = containerPageCoords[0];
var y = containerPageCoords[1];
var width = containerPageCoords[2];
var height = containerPageCoords[3];
var positions = e.touches ? e.touches : [e];
var atLeastOnePosInside = false;
for (var i = 0; i < positions.length; i++) {
var p = positions[i];
if (x <= p.clientX && p.clientX <= x + width && y <= p.clientY && p.clientY <= y + height) {
atLeastOnePosInside = true;
break;
}
}
if (!atLeastOnePosInside) {
return false;
}
var container = r.container;
var target = e.target;
var tParent = target.parentNode;
var containerIsTarget = false;
while (tParent) {
if (tParent === container) {
containerIsTarget = true;
break;
}
tParent = tParent.parentNode;
}
if (!containerIsTarget) {
return false;
} // if target is outisde cy container, then this event is not for us
return true;
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
eventInContainer
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
checkForTaphold = function checkForTaphold() {
r.hoverData.tapholdCancelled = false;
clearTimeout(r.hoverData.tapholdTimeout);
r.hoverData.tapholdTimeout = setTimeout(function () {
if (r.hoverData.tapholdCancelled) {
return;
} else {
var ele = r.hoverData.down;
if (ele) {
ele.emit({
originalEvent: e,
type: 'taphold',
position: {
x: pos[0],
y: pos[1]
}
});
} else {
cy.emit({
originalEvent: e,
type: 'taphold',
position: {
x: pos[0],
y: pos[1]
}
});
}
}
}, r.tapholdDuration);
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
checkForTaphold
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
makeEvent = function makeEvent(type) {
return {
originalEvent: e,
type: type,
position: {
x: pos[0],
y: pos[1]
}
};
}
|
@brief : Function used for keeping track of compound node
sizes, since they should bound all their subnodes.
|
makeEvent
|
javascript
|
pistazie/cdk-dia
|
src/render/cytoscape/base/js/app.8e9fe77f.js
|
https://github.com/pistazie/cdk-dia/blob/master/src/render/cytoscape/base/js/app.8e9fe77f.js
|
MIT
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.