summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdhitya Kamakshidasan2016-07-06 12:54:08 +0530
committerGitHub2016-07-06 12:54:08 +0530
commit57c13b64f9aab43e14b27dba4b58226fbd8d59b5 (patch)
tree582bf422a54d509fa94e36e312cf4adac97d3e4a
parent496dd42d6af4e1a08baeb4b43e3d53e9bc1235ab (diff)
parent91acba8d34158b30a663457247b3865881bb116d (diff)
downloadxcos-on-web-57c13b64f9aab43e14b27dba4b58226fbd8d59b5.tar.gz
xcos-on-web-57c13b64f9aab43e14b27dba4b58226fbd8d59b5.tar.bz2
xcos-on-web-57c13b64f9aab43e14b27dba4b58226fbd8d59b5.zip
Merge pull request #134 from jiteshjha/fixed-source-target-order
Fixes source target of edges order
-rw-r--r--index.html44
1 files changed, 44 insertions, 0 deletions
diff --git a/index.html b/index.html
index fc83c08..683bf30 100644
--- a/index.html
+++ b/index.html
@@ -609,6 +609,50 @@
alert("Control port must be connected to command port");
}
else {
+
+ /*
+ * For reverse edges, (that is, edges from input port to outport) :
+ * If the source is input port, and target is an output port
+ * NOTE: Manipulation of source object and target object
+ * with respect to current edge is not possible,
+ * as mxGraph.prototype.addEdge(@parameters) function is
+ * called just before the creation of the edge.
+ * Hence, the following code creates a identical new edge
+ * to replace the current edge.
+ */
+
+ 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 {
+
+ // Insert new edge in place of current edge
+ var newEdge = graph.insertEdge(parent, null, '', target, source);
+
+ // 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();
+ }
+
+ // Return null for the current edge,
+
+ /*
+ * Return null for the current edge,
+ * since we have created a new edge above to replace it
+ */
+ return null;
+ }
// If the edge is legit, return the edge.
return mxGraph.prototype.addEdge.apply(this, arguments);
}