diff options
author | jiteshjha | 2016-07-07 12:03:56 +0530 |
---|---|---|
committer | jiteshjha | 2016-07-07 12:03:56 +0530 |
commit | 85b41d60c6fe61b11469d7ccdfb5cd54f9124cff (patch) | |
tree | c62c2343d637d5cfb1b0588531307f259545d548 /index.html | |
parent | 57c13b64f9aab43e14b27dba4b58226fbd8d59b5 (diff) | |
download | xcos-on-web-85b41d60c6fe61b11469d7ccdfb5cd54f9124cff.tar.gz xcos-on-web-85b41d60c6fe61b11469d7ccdfb5cd54f9124cff.tar.bz2 xcos-on-web-85b41d60c6fe61b11469d7ccdfb5cd54f9124cff.zip |
Added createEdgeObject - on request by Saarang
Diffstat (limited to 'index.html')
-rw-r--r-- | index.html | 45 |
1 files changed, 45 insertions, 0 deletions
@@ -1555,6 +1555,51 @@ }; /* + * @jiteshjha + * createEdgeObject(@parameters) creates an edge on the graph DOM + * @Parameters : + * source -> source object for the edge + * target -> destination object for the edge + * points -> waypoints to be inserted in the geometry + */ + function createEdgeObject(source, target, points) { + + // Start the update on the graph + graph.getModel().beginUpdate(); + + try { + + // Create an edge from the given source object and target object + var edge = graph.insertEdge(parent, null, '', source, target); + + // Get geometry of the edge + var geometry = graph.getModel().getGeometry(edge); + + /* + * Clone the geometry object + * NOTE: Direct manipulation of the geometry object may not be + * registered as an action for some cases, hence we clone the + * geometry, manipulate it and set the geometry. + */ + var cloneGeometry = geometry.clone(); + + // Add points in the cloned geometry + cloneGeometry.points = points; + + // Set the changed geometry for the edge + graph.getModel().setGeometry(edge, cloneGeometry); + + // Refresh to reflect changes made + graph.refresh(); + } + finally { + + // End the update + graph.getModel().endUpdate(); + } + } + + /* @jiteshjha Creates a dialog box related to the edge label properties. The properties implemented are : edge label, label fontStyle, |