summaryrefslogtreecommitdiff
path: root/index.html
diff options
context:
space:
mode:
authorjiteshjha2016-07-07 15:36:49 +0530
committerjiteshjha2016-07-07 15:36:49 +0530
commit34f600dac8e428aa7ffa17e5ffb77d74f8c57f2d (patch)
tree304aff1e58f724f919cc7b4ed8c0d7a365d27fee /index.html
parent85b41d60c6fe61b11469d7ccdfb5cd54f9124cff (diff)
downloadxcos-on-web-34f600dac8e428aa7ffa17e5ffb77d74f8c57f2d.tar.gz
xcos-on-web-34f600dac8e428aa7ffa17e5ffb77d74f8c57f2d.tar.bz2
xcos-on-web-34f600dac8e428aa7ffa17e5ffb77d74f8c57f2d.zip
Used the function in the codebase
Diffstat (limited to 'index.html')
-rw-r--r--index.html81
1 files changed, 42 insertions, 39 deletions
diff --git a/index.html b/index.html
index 1c4683e..04c72fa 100644
--- a/index.html
+++ b/index.html
@@ -365,9 +365,6 @@
// Source edge is replaced with first edge and futureSource edges
cell.name = 'SPLIT_f';
- var firstEdge = graph.insertEdge(parent, null, '', cell.getChildAt(1), sourceTarget);
- var thirdEdge = graph.insertEdge(parent, null, '', cell.getChildAt(2), target);
- var futureSource = graph.insertEdge(parent, null, '', source.source, cell.getChildAt(0));
// Hide all the ports of a split-block
cell.getChildAt(0).setVisible(false);
@@ -377,9 +374,6 @@
// Remove the current source
graph.removeCells([source], true);
- // Set the newly made futureSource as the source
- source = futureSource;
-
/*
* If there are any waypoints, divide them for the two newly created edges.
* The two newly created edges are inherited from the source edge
@@ -394,9 +388,6 @@
for(var i = seg; i < waypoints.length; i++) {
waypoints2.push(waypoints[i]);
}
-
- source.geometry.points = waypoints1;
- firstEdge.geometry.points = waypoints2;
}
// Find the waypoints of the current edge, and set the waypoints for the new thirdEdge
@@ -406,7 +397,13 @@
waypoints3.pop();
}
- thirdEdge.geometry.points = waypoints3;
+ // Create three edges associated with the split-block
+ var firstEdge = createEdgeObject(graph, cell.getChildAt(1), sourceTarget, waypoints2);
+ var thirdEdge = createEdgeObject(graph, cell.getChildAt(2), target, waypoints3);
+ var futureSource = createEdgeObject(graph, source.source, cell.getChildAt(0), waypoints1);
+
+ // Set the newly made futureSource as the source
+ source = futureSource;
// Connectable for the ports and the split-block should be false
cell.getChildAt(0).setConnectable(false);
@@ -515,9 +512,6 @@
// Source edge is replaced with first edge and futureSource edges
cell.name = 'SPLIT_f';
- var firstEdge = graph.insertEdge(parent, null, '', cell.getChildAt(1), sourceTarget);
- var thirdEdge = graph.insertEdge(parent, null, '', cell.getChildAt(2), source);
- var futureSource = graph.insertEdge(parent, null, '', target.source, cell.getChildAt(0));
// Hide all the ports of a split-block
cell.getChildAt(0).setVisible(false);
@@ -526,7 +520,6 @@
// Remove the current source
graph.removeCells([target], true);
- target = futureSource;
/*
* If there are any waypoints, divide them for the two newly created edges.
@@ -542,9 +535,6 @@
for(var i = seg; i < waypoints.length; i++) {
waypoints2.push(waypoints[i]);
}
-
- target.geometry.points = waypoints1;
- firstEdge.geometry.points = waypoints2;
}
// Find the waypoints of the current edge, and set the waypoints for the new thirdEdge
@@ -552,14 +542,37 @@
if(waypoints3 != null && waypoints3.length > 1) {
waypoints3.pop();
}
- waypoints3.reverse();
- thirdEdge.geometry.points = waypoints3;
+ waypoints3.reverse();
+
+ // Create three edges associated with the split-block
+ var firstEdge = createEdgeObject(graph, cell.getChildAt(1), sourceTarget, waypoints2);
+ var thirdEdge = createEdgeObject(graph, cell.getChildAt(2), source, waypoints3);
+ var futureSource = createEdgeObject(graph, target.source, cell.getChildAt(0), waypoints1);
+
+ // Set the newly made futureSource as the source
+ target = futureSource;
// Connectable for the ports and the split-block should be false
cell.getChildAt(0).setConnectable(false);
cell.getChildAt(1).setConnectable(false);
cell.getChildAt(2).setConnectable(false);
cell.setConnectable(false);
+
+ // Get the parent of the splitBlock
+ var parent = graph.model.getParent(cell);
+
+ graph.model.beginUpdate();
+ try {
+ /*
+ * Adds the split-block to the parent at the last index
+ * Enables split-block to appear over it's associated edges
+ */
+ graph.model.add(parent, cell, graph.model.getChildCount(parent) - 1);
+ }
+ finally {
+ graph.model.endUpdate();
+ }
+
graph.refresh();
}
finally
@@ -624,26 +637,14 @@
if((source.value.indexOf('Input') != -1 && target.value.indexOf('Output') != -1)
|| (target.value == 'CommandPort' && source.value == 'ControlPort')) {
- // Begin graph DOM update
- graph.getModel().beginUpdate();
-
- try {
+ // Get points for the current edge from the global edgeState object
+ var waypoints = edgeState.absolutePoints;
- // Insert new edge in place of current edge
- var newEdge = graph.insertEdge(parent, null, '', target, source);
+ // Reverse waypoint array
+ waypoints.reverse();
- // Get points for the current edge from the global edgeState object
- var waypoints = edgeState.absolutePoints;
-
- // Reverse waypoint array
- waypoints.reverse();
-
- // Set the points for the new edge
- newEdge.geometry.points = waypoints;
- }
- finally {
- graph.getModel().endUpdate();
- }
+ // Create a new edge
+ var newEdge = createEdgeObject(graph, target, source, waypoints);
// Return null for the current edge,
@@ -1562,7 +1563,7 @@
* target -> destination object for the edge
* points -> waypoints to be inserted in the geometry
*/
- function createEdgeObject(source, target, points) {
+ function createEdgeObject(graph, source, target, points) {
// Start the update on the graph
graph.getModel().beginUpdate();
@@ -1570,7 +1571,7 @@
try {
// Create an edge from the given source object and target object
- var edge = graph.insertEdge(parent, null, '', source, target);
+ var edge = graph.insertEdge(graph.getDefaultParent(), null, '', source, target);
// Get geometry of the edge
var geometry = graph.getModel().getGeometry(edge);
@@ -1597,6 +1598,8 @@
// End the update
graph.getModel().endUpdate();
}
+
+ return edge;
}
/*