summaryrefslogtreecommitdiff
path: root/public/javascripts/sigma-connector.js
blob: c511de917970f7e99ed3e3e5cbd1f1b50ecb97ca (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
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...