From e7e749d9b971a10110011c83bf19afdbbe4f3bc6 Mon Sep 17 00:00:00 2001 From: franck cuny Date: Mon, 13 Jun 2011 16:42:36 +0200 Subject: change layout and add new js Signed-off-by: franck cuny --- public/javascripts/sigma-connector.js | 125 ++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 public/javascripts/sigma-connector.js (limited to 'public/javascripts/sigma-connector.js') diff --git a/public/javascripts/sigma-connector.js b/public/javascripts/sigma-connector.js new file mode 100644 index 0000000..c511de9 --- /dev/null +++ b/public/javascripts/sigma-connector.js @@ -0,0 +1,125 @@ +// --- SiGMa (API version) JavaSCript connector --- +// Contains the functions to send data to a SiGMa.swf instance. + +// You have to initialize this parameter before using the +// different functions: +var sigmaDOM; +var outputFunction; + +// This function starts the layout algorithm: +function initForceAtlas(){ + try{ + sigmaDOM.initForceAtlas(); + }catch(e){ + if(outputFunction){ + outputFunction(e.description); + } + } +} + +// This function stops the layout algorithm: +function killForceAtlas(){ + try{ + sigmaDOM.killForceAtlas(); + }catch(e){ + if(outputFunction){ + outputFunction(e.description); + } + } +} + +// This function delete the whole graph in SiGMa: +function deleteGraph(){ + try{ + sigmaDOM.deleteGraph(); + }catch(e){ + if(outputFunction){ + outputFunction(e.description); + } + } +} + +// This function pushes each non-existing node and edge in the graph, +// and removes the ones that were in SiGMa: +function updateGraph(graph){ + try{ + sigmaDOM.updateGraph(graph); + }catch(e){ + if(outputFunction){ + outputFunction(e.description); + } + } +} + +// This function pushes each non-existing node and edge in the graph, +// and updates the ones that are already in SiGMa: +function pushGraph(graph){ + try{ + sigmaDOM.pushGraph(graph); + }catch(e){ + if(outputFunction){ + outputFunction(e.description); + } + } +} + +// This function activates the fish-eye zoom: +function activateFishEye(){ + try{ + sigmaDOM.activateFishEye(); + }catch(e){ + if(outputFunction){ + outputFunction(e.description); + } + } +} + +// This function desactivates the fish-eye zoom: +function deactivateFishEye(){ + try{ + sigmaDOM.deactivateFishEye(); + }catch(e){ + if(outputFunction){ + outputFunction(e.description); + } + } +} + +// This function sets the color of the nodes relatively to one +// attribute: +function setColor(field,attributes){ + try{ + sigmaDOM.setColor(field,attributes); + }catch(e){ + if(outputFunction){ + outputFunction(e.description); + } + } +} + +// This function sets the color of the nodes relatively to one +// attribute: +function setSize(field){ + try{ + sigmaDOM.setSize(field); + }catch(e){ + if(outputFunction){ + outputFunction(e.description); + } + } +} + +// This function recenters the graph in SiGMa (basically, it +// cancels each zooming action and every drag'n'drop): +function recenterGraph(){ + try{ + sigmaDOM.resetGraphPosition(); + }catch(e){ + if(outputFunction){ + outputFunction(e.description); + } + } +} + +// /!\ This script is just a draft, most of the methods might change +// soon, and a lot of missing features are already in development... -- cgit v1.2.3