Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clinicaltrials
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
david Chavalarias
clinicaltrials
Commits
7b5ba7fa
Commit
7b5ba7fa
authored
Sep 22, 2014
by
PkSM3
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FA2 bipartite independent layouting and Bugfix:DisableLevelButt
parent
b5307731
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
416 deletions
+70
-416
enviroment.js
tinawebJS/js/enviroment.js
+8
-231
main.js
tinawebJS/js/main.js
+1
-1
methods.js
tinawebJS/js/methods.js
+19
-164
sigma.forceatlas2.js
tinawebJS/js/sigma.forceatlas2.js
+42
-20
No files found.
tinawebJS/js/enviroment.js
View file @
7b5ba7fa
...
@@ -2,162 +2,6 @@
...
@@ -2,162 +2,6 @@
//============================ < NEW BUTTONS > =============================//
//============================ < NEW BUTTONS > =============================//
//obsolete
function
changeButton
(
bc
)
{
if
(
!
isUndef
(
bc
.
id
)
&&
bc
.
id
!=
swclickActual
)
{
if
(
bc
.
id
!=
"switch"
)
pushSWClick
(
bc
.
id
);
else
pushSWClick
(
swclickActual
)
pr
(
"
\
t***changebutton bc.id:"
+
bc
.
id
+
" , swMacro:"
+
swMacro
)
if
(
bc
.
id
==
"social"
)
{
if
(
swMacro
)
changeToMacro
(
bc
.
id
);
else
changeToMeso
(
bc
.
id
);
// $("#category-A").show();
// $("#category-B").hide();
}
if
(
bc
.
id
==
"semantic"
)
{
if
(
swMacro
)
changeToMacro
(
bc
.
id
);
else
changeToMeso
(
bc
.
id
);
// $("#category-A").hide();
// $("#category-B").show();
}
if
(
bc
.
id
==
"sociosemantic"
)
{
if
(
swMacro
)
changeToMacro
(
bc
.
id
);
else
changeToMeso
(
bc
.
id
);
// $("#category-A").show();
// $("#category-B").show();
}
if
(
bc
.
id
==
"switch"
){
if
(
swMacro
)
changeToMacro
(
swclickActual
);
else
changeToMeso
(
swclickActual
);
}
}
// fullurl = returnBaseUrl()+"img/trans/";
// if(img.id=="socio") {
// if ( img.src==fullurl+"hover_scholars.png" ) {
// changeButton("active_scholars.png");
// if(document.getElementById("viewType").src==fullurl+"status_macro_view.png"){
// changeToMacro("social");
// }
// if(document.getElementById("viewType").src==fullurl+"status_meso_view.png"){
// changeToMeso("social");
// }
// }
// }
//
// if(img.id=="semantic") {
// if ( img.src==fullurl+"hover_tags.png" ) {
// changeButton("active_tags.png");
// if(document.getElementById("viewType").src==fullurl+"status_macro_view.png"){
// changeToMacro("semantic");
// }
// if(document.getElementById("viewType").src==fullurl+"status_meso_view.png"){
// changeToMeso("semantic");
// }
// }
// }
//
// if(img.id=="sociosemantic") {
// if ( img.src==fullurl+"hover_sociosem.png" ) {
// changeButton("active_sociosem.png");
// if(document.getElementById("viewType").src==fullurl+"status_macro_view.png"){
// changeToMacro("sociosemantic");
// }
// if(document.getElementById("viewType").src==fullurl+"status_meso_view.png"){
// changeToMeso("sociosemantic");
// }
// }
//
// }
// if(img.id=="switch") {
// hasbeenclicked=false;
// if ( img.src==fullurl+"graph_meso.png"){
// changeButton("graph_macro.png");
// pushSWClick(swclickActual);
// changeToMeso(swclickActual);
// hasbeenclicked=true;
// }
// if ( img.src==fullurl+"graph_macro.png" && hasbeenclicked==false){
// changeButton("graph_meso.png");
// pushSWClick(swclickActual);
// changeToMacro(swclickActual);
// }
// }
// fullurl = returnBaseUrl()+"img/trans/";
// hasbeenclicked=false;
// if(bc=="graph_meso.png"){
// document.getElementById("switch").src=fullurl+"graph_meso.png";
// document.getElementById("viewType").src=fullurl+"status_macro_view.png";
// hasbeenclicked=true;
// }
// if(bc=="graph_macro.png" && hasbeenclicked==false){
// document.getElementById("switch").src=fullurl+"graph_macro.png";
// document.getElementById("viewType").src=fullurl+"status_meso_view.png";
// }
//
// if(bc=="active_scholars.png"){
// document.getElementById("socio").src=fullurl+"active_scholars.png";
// document.getElementById("semantic").src=fullurl+"inactive_tags.png";
// document.getElementById("sociosemantic").src=fullurl+"inactive_sociosem.png";
// pushSWClick("social");
// pr("swclickPrev: "+swclickPrev+" - swclickActual: "+swclickActual);
// $("#category-A").show();
// $("#category-B").hide();
// }
// if(bc=="active_tags.png"){
// document.getElementById("socio").src=fullurl+"inactive_scholars.png";
// document.getElementById("semantic").src=fullurl+"active_tags.png";
// document.getElementById("sociosemantic").src=fullurl+"inactive_sociosem.png";
// pushSWClick("semantic");
// pr("swclickPrev: "+swclickPrev+" - swclickActual: "+swclickActual);
// $("#category-A").hide();
// $("#category-B").show();
// }
// if(bc=="active_sociosem.png"){
// document.getElementById("socio").src=fullurl+"inactive_scholars.png";
// document.getElementById("semantic").src=fullurl+"inactive_tags.png";
// document.getElementById("sociosemantic").src=fullurl+"active_sociosem.png";
// pushSWClick("sociosemantic");
// pr("swclickPrev: "+swclickPrev+" - swclickActual: "+swclickActual);
// $("#category-A").show();
// $("#category-B").show();
// }
// if(bc=="selectNode"){
// if(categories.length==2) $("#switchbutton").show();
// if(document.getElementById("switch").src==fullurl+"graph_meso_null.png"){
// if(document.getElementById("viewType").src==fullurl+"status_macro_view.png"){
// document.getElementById("switch").src=fullurl+"graph_meso.png";
// }
// if(document.getElementById("viewType").src==fullurl+"status_meso_view.png"){
// document.getElementById("switch").src=fullurl+"graph_macro.png";
// }
// }
// }
// if(bc=="unselectNodes"){
// document.getElementById("switch").src=fullurl+"graph_meso_null.png";
// }
// /*tofix*/
//// if(is_empty(selections)){
//// /***** The animation *****/
//// _cG = $("#leftcolumn");
//// _cG.animate({
//// "left" : "-" + _cG.width() + "px"
//// }, function() {
//// $("#aUnfold").attr("class","rightarrow");
//// $("#zonecentre").css({
//// left: "0"
//// });
//// });
//// }
}
function
changeType
()
{
function
changeType
()
{
pr
(
"***swclickActual:"
+
swclickActual
+
" , swMacro:"
+
swMacro
)
pr
(
"***swclickActual:"
+
swclickActual
+
" , swMacro:"
+
swMacro
)
if
(
swclickActual
==
"social"
)
{
if
(
swclickActual
==
"social"
)
{
...
@@ -236,7 +80,9 @@ function changeLevel() {
...
@@ -236,7 +80,9 @@ function changeLevel() {
pushSWClick
(
swclickActual
);
pushSWClick
(
swclickActual
);
pr
(
"swMacro: "
+
swMacro
+
" - [swclickPrev: "
+
bf
+
"] - [swclickActual: "
+
swclickActual
+
"]"
)
pr
(
"swMacro: "
+
swMacro
+
" - [swclickPrev: "
+
bf
+
"] - [swclickActual: "
+
swclickActual
+
"]"
)
// ANALIZING CURRENT STATE:
if
(
swMacro
){
if
(
swMacro
){
// Macro Level -- swMacro:true
if
(
swclickActual
==
"social"
)
{
if
(
swclickActual
==
"social"
)
{
changeToMeso
(
"social"
)
changeToMeso
(
"social"
)
RefreshState
(
"a"
);
RefreshState
(
"a"
);
...
@@ -246,7 +92,10 @@ function changeLevel() {
...
@@ -246,7 +92,10 @@ function changeLevel() {
RefreshState
(
"b"
);
RefreshState
(
"b"
);
}
}
swMacro
=
false
;
swMacro
=
false
;
return
;
}
else
{
}
else
{
// Meso Level -- swMacro:false
if
(
swclickActual
==
"social"
)
{
if
(
swclickActual
==
"social"
)
{
changeToMacro
(
"social"
)
changeToMacro
(
"social"
)
RefreshState
(
"A"
)
RefreshState
(
"A"
)
...
@@ -256,7 +105,9 @@ function changeLevel() {
...
@@ -256,7 +105,9 @@ function changeLevel() {
RefreshState
(
"B"
)
RefreshState
(
"B"
)
}
}
swMacro
=
true
;
swMacro
=
true
;
return
;
}
}
// changeToMeso("social")
// changeToMeso("social")
// changeToMeso("semantic")
// changeToMeso("semantic")
...
@@ -264,61 +115,6 @@ function changeLevel() {
...
@@ -264,61 +115,6 @@ function changeLevel() {
// changeToMacro("semantic")
// changeToMacro("semantic")
}
}
//obsolete
function
changeHoverActive
(
img
)
{
fullurl
=
returnBaseUrl
()
+
"img/trans/"
;
if
(
img
.
id
==
"socio"
)
{
if
(
img
.
src
==
fullurl
+
"hover_scholars.png"
)
{
changeButton
(
"active_scholars.png"
);
if
(
document
.
getElementById
(
"viewType"
).
src
==
fullurl
+
"status_macro_view.png"
){
changeToMacro
(
"social"
);
}
if
(
document
.
getElementById
(
"viewType"
).
src
==
fullurl
+
"status_meso_view.png"
){
changeToMeso
(
"social"
);
}
}
}
if
(
img
.
id
==
"semantic"
)
{
if
(
img
.
src
==
fullurl
+
"hover_tags.png"
)
{
changeButton
(
"active_tags.png"
);
if
(
document
.
getElementById
(
"viewType"
).
src
==
fullurl
+
"status_macro_view.png"
){
changeToMacro
(
"semantic"
);
}
if
(
document
.
getElementById
(
"viewType"
).
src
==
fullurl
+
"status_meso_view.png"
){
changeToMeso
(
"semantic"
);
}
}
}
if
(
img
.
id
==
"sociosemantic"
)
{
if
(
img
.
src
==
fullurl
+
"hover_sociosem.png"
)
{
changeButton
(
"active_sociosem.png"
);
if
(
document
.
getElementById
(
"viewType"
).
src
==
fullurl
+
"status_macro_view.png"
){
changeToMacro
(
"sociosemantic"
);
}
if
(
document
.
getElementById
(
"viewType"
).
src
==
fullurl
+
"status_meso_view.png"
){
changeToMeso
(
"sociosemantic"
);
}
}
}
if
(
img
.
id
==
"switch"
)
{
hasbeenclicked
=
false
;
if
(
img
.
src
==
fullurl
+
"graph_meso.png"
){
changeButton
(
"graph_macro.png"
);
pushSWClick
(
swclickActual
);
changeToMeso
(
swclickActual
);
hasbeenclicked
=
true
;
}
if
(
img
.
src
==
fullurl
+
"graph_macro.png"
&&
hasbeenclicked
==
false
){
changeButton
(
"graph_meso.png"
);
pushSWClick
(
swclickActual
);
changeToMacro
(
swclickActual
);
}
}
}
//obsolete
//obsolete
function
neweffectshow
(){
function
neweffectshow
(){
if
(
!
is_empty
(
selections
)){
if
(
!
is_empty
(
selections
)){
...
@@ -667,25 +463,6 @@ function search(string) {
...
@@ -667,25 +463,6 @@ function search(string) {
$
.
doTimeout
(
30
,
function
(){
$
.
doTimeout
(
30
,
function
(){
MultipleSelection
(
id_node
);
MultipleSelection
(
id_node
);
});
});
// if(categoriesIndex.length==1) updateLeftPanel_uni();
// if(categoriesIndex.length==2) updateLeftPanel_fix();
// if(is_empty(selections)==true){
// $("#names").html("");
// $("#opossiteNodes").html("");
// $("#information").html("");
// changeButton("unselectNodes");
// }
// else {
// greyEverything();
// overNodes=true;
// for(var i in selections){
// markAsSelected(i,true);
// }
// changeButton("selectNode");
// partialGraph.draw();
// }
$
(
"input#searchinput"
).
val
(
""
);
$
(
"input#searchinput"
).
val
(
""
);
$
(
"input#searchinput"
).
autocomplete
(
"close"
);
$
(
"input#searchinput"
).
autocomplete
(
"close"
);
}
}
...
...
tinawebJS/js/main.js
View file @
7b5ba7fa
...
@@ -525,7 +525,7 @@ function theListeners(){
...
@@ -525,7 +525,7 @@ function theListeners(){
else
{
else
{
if
(
!
is_empty
(
selections
)){
if
(
!
is_empty
(
selections
)){
cancelSelection
(
false
);
cancelSelection
(
false
);
LevelButtonDisable
(
true
);
//
LevelButtonDisable(true);
}
}
}
}
});
});
...
...
tinawebJS/js/methods.js
View file @
7b5ba7fa
...
@@ -142,7 +142,7 @@ function cancelSelection (fromTagCloud) {
...
@@ -142,7 +142,7 @@ function cancelSelection (fromTagCloud) {
n
.
attr
[
'grey'
]
=
0
;
n
.
attr
[
'grey'
]
=
0
;
}).
draw
(
2
,
1
,
2
);
}).
draw
(
2
,
1
,
2
);
//Nodes colors go back to normal
//Nodes colors go back to normal
changeButton
(
"unselectNodes"
);
if
(
fromTagCloud
==
false
){
if
(
fromTagCloud
==
false
){
$
(
"#names"
).
html
(
""
);
$
(
"#names"
).
html
(
""
);
...
@@ -212,12 +212,12 @@ function RefreshState(newNOW){
...
@@ -212,12 +212,12 @@ function RefreshState(newNOW){
}
}
}
}
i
=
0
;
for
(
var
s
in
selections
)
{
i
++
;
break
;}
//
i=0; for(var s in selections) { i++; break;}
if
(
is_empty
(
selections
)
||
i
==
0
)
LevelButtonDisable
(
true
);
//
if(is_empty(selections) || i==0) LevelButtonDisable(true);
else
LevelButtonDisable
(
false
);
//
else LevelButtonDisable(false);
//complete graphs case
//complete graphs case
sels
=
getNodeIDs
(
selections
).
length
//
sels=getNodeIDs(selections).length
if
(
NOW
==
"A"
||
NOW
==
"a"
)
{
if
(
NOW
==
"A"
||
NOW
==
"a"
)
{
// N : number of nodes
// N : number of nodes
// k : number of ( selected nodes + their neighbors )
// k : number of ( selected nodes + their neighbors )
...
@@ -232,6 +232,12 @@ function RefreshState(newNOW){
...
@@ -232,6 +232,12 @@ function RefreshState(newNOW){
}
else
LevelButtonDisable
(
false
);
}
else
LevelButtonDisable
(
false
);
if
(
s
==
N
)
LevelButtonDisable
(
false
);
if
(
s
==
N
)
LevelButtonDisable
(
false
);
}
}
if
(
NOW
==
"a"
)
{
i
=
0
;
for
(
var
s
in
selections
)
{
i
++
;
break
;}
if
(
is_empty
(
selections
)
||
i
==
0
)
LevelButtonDisable
(
false
);
}
EdgeWeightFilter
(
"#sliderAEdgeWeight"
,
"label"
,
"nodes1"
,
"weight"
);
EdgeWeightFilter
(
"#sliderAEdgeWeight"
,
"label"
,
"nodes1"
,
"weight"
);
$
(
"#colorGraph"
).
show
();
$
(
"#colorGraph"
).
show
();
...
@@ -247,6 +253,13 @@ function RefreshState(newNOW){
...
@@ -247,6 +253,13 @@ function RefreshState(newNOW){
}
else
LevelButtonDisable
(
false
);
}
else
LevelButtonDisable
(
false
);
if
(
s
==
N
)
LevelButtonDisable
(
false
);
if
(
s
==
N
)
LevelButtonDisable
(
false
);
}
}
if
(
NOW
==
"b"
)
{
i
=
0
;
for
(
var
s
in
selections
)
{
i
++
;
break
;}
if
(
is_empty
(
selections
)
||
i
==
0
)
LevelButtonDisable
(
false
);
}
EdgeWeightFilter
(
"#sliderBEdgeWeight"
,
"label"
,
"nodes2"
,
"weight"
);
EdgeWeightFilter
(
"#sliderBEdgeWeight"
,
"label"
,
"nodes2"
,
"weight"
);
NodeWeightFilter
(
"#sliderBNodeWeight"
,
"type"
,
"NGram"
,
"size"
)
NodeWeightFilter
(
"#sliderBNodeWeight"
,
"type"
,
"NGram"
,
"size"
)
$
(
"#colorGraph"
).
hide
();
$
(
"#colorGraph"
).
hide
();
...
@@ -576,60 +589,6 @@ function graphTagCloudElem(node_id){
...
@@ -576,60 +589,6 @@ function graphTagCloudElem(node_id){
changeLevel
();
changeLevel
();
}
}
//obsolete
function
graphDocs
(
node_id
){
pr
(
"
\
tin graphDocs, node_id: "
+
node_id
);
fullurl
=
returnBaseUrl
()
+
"img/trans/"
;
document
.
getElementById
(
"viewType"
).
src
=
fullurl
+
"status_meso_view.png"
;
document
.
getElementById
(
"socio"
).
src
=
fullurl
+
"active_scholars.png"
;
document
.
getElementById
(
"semantic"
).
src
=
fullurl
+
"inactive_tags.png"
;
document
.
getElementById
(
"sociosemantic"
).
src
=
fullurl
+
"inactive_sociosem.png"
;
document
.
getElementById
(
"switch"
).
src
=
fullurl
+
"graph_macro.png"
;
hideEverything
()
//partialGraph.stopForceAtlas2();
if
(
Nodes
[
node_id
].
type
==
catSoc
)
{
labels
=
[];
unHide
(
node_id
);
for
(
i
=
0
;
i
<
nodes1
[
node_id
].
neighbours
.
length
;
i
++
)
{
unHide
(
nodes1
[
node_id
].
neighbours
[
i
]);
}
existingNodes
=
partialGraph
.
_core
.
graph
.
nodes
.
filter
(
function
(
n
)
{
return
!
n
[
'hidden'
];
});
for
(
i
=
0
;
i
<
existingNodes
.
length
;
i
++
){
if
(
existingNodes
[
i
].
id
==
node_id
)
i
++
;
for
(
j
=
0
;
j
<
existingNodes
.
length
;
j
++
){
i1
=
existingNodes
[
i
].
id
+
";"
+
existingNodes
[
j
].
id
;
i2
=
existingNodes
[
j
].
id
+
";"
+
existingNodes
[
i
].
id
;
if
(
!
isUndef
(
Edges
[
i1
])
&&
!
isUndef
(
Edges
[
i2
])){
if
(
Edges
[
i1
].
weight
>
Edges
[
i2
].
weight
){
unHide
(
i1
);
}
if
(
Edges
[
i1
].
weight
<
Edges
[
i2
].
weight
){
unHide
(
i2
);
}
if
(
Edges
[
i1
].
weight
==
Edges
[
i2
].
weight
){
unHide
(
i1
);
}
}
}
}
node
=
partialGraph
.
_core
.
graph
.
nodesIndex
[
node_id
];
selection
(
node
);
$
(
"#category-A"
).
show
();
$
(
"#category-B"
).
hide
();
changeButton
(
"active_scholars.png"
);
}
}
function
updateDownNodeEvent
(
selectionRadius
){
function
updateDownNodeEvent
(
selectionRadius
){
pr
(
"actualizando eventos downode"
);
pr
(
"actualizando eventos downode"
);
partialGraph
.
unbind
(
"downnodes"
);
partialGraph
.
unbind
(
"downnodes"
);
...
@@ -1205,50 +1164,6 @@ function hoverNodeEffectWhileFA2(selectionRadius) {
...
@@ -1205,50 +1164,6 @@ function hoverNodeEffectWhileFA2(selectionRadius) {
// getOpossitesNodes(nodeID, false);//passing just the node-id
// getOpossitesNodes(nodeID, false);//passing just the node-id
}
}
}
}
// if(cursor_size>0 &&){
// //The click WAS in a node and the cursor_size is ON
// //if(checkBox==false) cancelSelection(false);
// x1 = partialGraph._core.mousecaptor.mouseX;
// y1 = partialGraph._core.mousecaptor.mouseY;
// //dist1(centerClick,selectionRadius)
// partialGraph.iterNodes(function(n){
// if(n.hidden==false){
// distance = Math.sqrt(
// Math.pow((x1-parseInt(n.displayX)),2) +
// Math.pow((y1-parseInt(n.displayY)),2)
// );
// if(parseInt(distance)<=cursor_size) {
// getOpossitesNodes(n,true);//passing the entire node
// }
// }
// });
// }
// if(categoriesIndex.length==1) updateLeftPanel_uni();
// if(categoriesIndex.length==2) updateLeftPanel_fix();
// //The most brilliant way of knowing if an array is empty in the world of JavaScript
// i=0; for(var s in selections) {i++;break};
// if(is_empty(selections) || i==0){
// pr("cursor radius ON, downNode -> selecciones vacias");
// $("#names").html(""); //Information extracted, just added
// $("#opossiteNodes").html(""); //Information extracted, just added
// $("#information").html("");
// $("#tips").html(getTips());
// $("#topPapers").html(""); $("#topPapers").hide();
// changeButton("unselectNodes");
// //cancelSelection(false);
// graphResetColor();
// }
// else {
// greyEverything();
// for(var i in selections){
// markAsSelected(i,true);
// }
// RefreshState("")
// }
// overNodes=true;
// partialGraph.draw();
});
});
}
}
...
@@ -1705,35 +1620,6 @@ function highlightOpossites (list){/*here*/
...
@@ -1705,35 +1620,6 @@ function highlightOpossites (list){/*here*/
}
}
}
}
function
selectOpossites
(
list
){
//Expanding selection
cancelSelection
(
false
);
checkBox
=
true
;
for
(
var
n
in
list
){
getOpossitesNodes
(
n
,
false
);
}
updateLeftPanel_fix
();
i
=
0
;
for
(
var
s
in
selections
)
i
++
;
if
(
is_empty
(
selections
)
==
true
||
i
==
0
){
$
(
"#names"
).
html
(
""
);
//Information extracted, just added
$
(
"#opossiteNodes"
).
html
(
""
);
//Information extracted, just added
$
(
"#information"
).
html
(
""
);
$
(
"#topPapers"
).
html
(
""
);
$
(
"#topPapers"
).
hide
();
$
(
"#tips"
).
html
(
getTips
());
changeButton
(
"unselectNodes"
);
cancelSelection
(
false
);
}
else
{
greyEverything
();
for
(
var
i
in
list
){
markAsSelected
(
i
,
true
);
}
changeButton
(
"selectNode"
);
}
overNodes
=
true
;
checkBox
=
false
;
partialGraph
.
draw
();
}
function
getByID
(
elem
)
{
function
getByID
(
elem
)
{
return
document
.
getElementById
(
elem
);
return
document
.
getElementById
(
elem
);
}
}
...
@@ -1826,37 +1712,6 @@ function saveGraphIMG(){
...
@@ -1826,37 +1712,6 @@ function saveGraphIMG(){
document
.
location
.
href
=
strData
.
replace
(
"image/png"
,
strDownloadMime
)
document
.
location
.
href
=
strData
.
replace
(
"image/png"
,
strDownloadMime
)
}
}
//to erase
function
testSave
(){
var
strDownloadMime
=
"image/octet-stream"
var
nodesDiv
=
partialGraph
.
_core
.
domElements
.
nodes
;
var
nodesCtx
=
nodesDiv
.
getContext
(
"2d"
);
var
edgesDiv
=
partialGraph
.
_core
.
domElements
.
edges
;
var
edgesCtx
=
edgesDiv
.
getContext
(
"2d"
);
var
labelsDiv
=
partialGraph
.
_core
.
domElements
.
labels
;
var
labelsCtx
=
labelsDiv
.
getContext
(
"2d"
);
nodesCtx
.
drawImage
(
labelsDiv
,
0
,
0
);
edgesCtx
.
drawImage
(
nodesDiv
,
0
,
0
);
var
strData
=
edgesDiv
.
toDataURL
(
"image/png"
);
pr
(
strData
)
// document.location.href = strData.replace("image/png", strDownloadMime)
}
//obsolete
function
getSwitchButton
(){
return
document
.
getElementById
(
"switchbutton"
).
src
;
}
//obsolete
//obsolete
function
setComponentButton
(
comp_name
){
function
setComponentButton
(
comp_name
){
document
.
getElementById
(
comp_name
);
document
.
getElementById
(
comp_name
);
...
...
tinawebJS/js/sigma.forceatlas2.js
View file @
7b5ba7fa
...
@@ -43,6 +43,8 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
...
@@ -43,6 +43,8 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
self
.
graph
.
nodes
.
forEach
(
function
(
n
)
{
self
.
graph
.
nodes
.
forEach
(
function
(
n
)
{
if
(
n
.
degree
>
0
)
{
n
.
fa2
=
{
n
.
fa2
=
{
mass
:
1
+
n
.
degree
,
mass
:
1
+
n
.
degree
,
old_dx
:
0
,
old_dx
:
0
,
...
@@ -51,6 +53,8 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
...
@@ -51,6 +53,8 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
dy
:
0
dy
:
0
};
};
}
});
});
return
self
;
return
self
;
...
@@ -74,6 +78,8 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
...
@@ -74,6 +78,8 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
self
.
count
++
;
self
.
count
++
;
nodes
.
forEach
(
function
(
n
)
{
nodes
.
forEach
(
function
(
n
)
{
if
(
n
.
degree
>
0
)
{
if
(
n
.
fa2
)
{
if
(
n
.
fa2
)
{
n
.
fa2
.
mass
=
1
+
n
.
degree
;
n
.
fa2
.
mass
=
1
+
n
.
degree
;
n
.
fa2
.
old_dx
=
n
.
fa2
.
dx
;
n
.
fa2
.
old_dx
=
n
.
fa2
.
dx
;
...
@@ -90,6 +96,8 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
...
@@ -90,6 +96,8 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
};
};
}
}
}
});
});
// If Barnes Hut active, initialize root region
// If Barnes Hut active, initialize root region
...
@@ -102,7 +110,9 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
...
@@ -102,7 +110,9 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
if
(
self
.
p
.
outboundAttractionDistribution
)
{
if
(
self
.
p
.
outboundAttractionDistribution
)
{
self
.
p
.
outboundAttCompensation
=
0
;
self
.
p
.
outboundAttCompensation
=
0
;
nodes
.
forEach
(
function
(
n
)
{
nodes
.
forEach
(
function
(
n
)
{
if
(
!
n
.
hidden
&&
n
.
degree
>
0
)
{
self
.
p
.
outboundAttCompensation
+=
n
.
fa2
.
mass
;
self
.
p
.
outboundAttCompensation
+=
n
.
fa2
.
mass
;
}
});
});
self
.
p
.
outboundAttCompensation
/=
nodes
.
length
;
self
.
p
.
outboundAttCompensation
/=
nodes
.
length
;
}
}
...
@@ -125,7 +135,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
...
@@ -125,7 +135,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
var
i
=
self
.
state
.
index
;
var
i
=
self
.
state
.
index
;
while
(
i
<
nodes
.
length
&&
i
<
self
.
state
.
index
+
cInt
)
{
while
(
i
<
nodes
.
length
&&
i
<
self
.
state
.
index
+
cInt
)
{
var
n
=
nodes
[
i
++
];
var
n
=
nodes
[
i
++
];
if
(
n
.
fa2
)
if
(
!
n
.
hidden
&&
n
.
degree
>
0
&&
n
.
fa2
)
rootRegion
.
applyForce
(
n
,
Repulsion
,
barnesHutTheta
);
rootRegion
.
applyForce
(
n
,
Repulsion
,
barnesHutTheta
);
}
}
if
(
i
==
nodes
.
length
)
{
if
(
i
==
nodes
.
length
)
{
...
@@ -138,9 +148,9 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
...
@@ -138,9 +148,9 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
var
i1
=
self
.
state
.
index
;
var
i1
=
self
.
state
.
index
;
while
(
i1
<
nodes
.
length
&&
i1
<
self
.
state
.
index
+
cInt
)
{
while
(
i1
<
nodes
.
length
&&
i1
<
self
.
state
.
index
+
cInt
)
{
var
n1
=
nodes
[
i1
++
];
var
n1
=
nodes
[
i1
++
];
if
(
n1
.
fa2
)
if
(
!
n1
.
hidden
&&
n1
.
degree
>
0
&&
n1
.
fa2
)
nodes
.
forEach
(
function
(
n2
,
i2
)
{
nodes
.
forEach
(
function
(
n2
,
i2
)
{
if
(
i2
<
i1
&&
n2
.
fa2
)
{
if
(
i2
<
i1
&&
(
!
n2
.
hidden
&&
n2
.
degree
>
0
&&
n2
.
fa2
)
)
{
Repulsion
.
apply_nn
(
n1
,
n2
);
Repulsion
.
apply_nn
(
n1
,
n2
);
}
}
});
});
...
@@ -171,7 +181,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
...
@@ -171,7 +181,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
var
i
=
self
.
state
.
index
;
var
i
=
self
.
state
.
index
;
while
(
i
<
nodes
.
length
&&
i
<
self
.
state
.
index
+
sInt
)
{
while
(
i
<
nodes
.
length
&&
i
<
self
.
state
.
index
+
sInt
)
{
var
n
=
nodes
[
i
++
];
var
n
=
nodes
[
i
++
];
if
(
n
.
fa2
)
if
(
!
n
.
hidden
&&
n
.
degree
>
0
&&
n
.
fa2
)
Gravity
.
apply_g
(
n
,
gravity
/
scalingRatio
);
Gravity
.
apply_g
(
n
,
gravity
/
scalingRatio
);
}
}
...
@@ -198,22 +208,28 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
...
@@ -198,22 +208,28 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
if
(
self
.
p
.
edgeWeightInfluence
==
0
)
{
if
(
self
.
p
.
edgeWeightInfluence
==
0
)
{
while
(
i
<
edges
.
length
&&
i
<
self
.
state
.
index
+
cInt
)
{
while
(
i
<
edges
.
length
&&
i
<
self
.
state
.
index
+
cInt
)
{
var
e
=
edges
[
i
++
];
var
e
=
edges
[
i
++
];
if
(
!
e
.
hidden
)
{
Attraction
.
apply_nn
(
e
.
source
,
e
.
target
,
1
);
Attraction
.
apply_nn
(
e
.
source
,
e
.
target
,
1
);
}
}
}
}
else
if
(
self
.
p
.
edgeWeightInfluence
==
1
)
{
}
else
if
(
self
.
p
.
edgeWeightInfluence
==
1
)
{
while
(
i
<
edges
.
length
&&
i
<
self
.
state
.
index
+
cInt
)
{
while
(
i
<
edges
.
length
&&
i
<
self
.
state
.
index
+
cInt
)
{
var
e
=
edges
[
i
++
];
var
e
=
edges
[
i
++
];
if
(
!
e
.
hidden
)
{
Attraction
.
apply_nn
(
e
.
source
,
e
.
target
,
e
.
weight
||
1
);
Attraction
.
apply_nn
(
e
.
source
,
e
.
target
,
e
.
weight
||
1
);
}
}
}
}
else
{
}
else
{
while
(
i
<
edges
.
length
&&
i
<
self
.
state
.
index
+
cInt
)
{
while
(
i
<
edges
.
length
&&
i
<
self
.
state
.
index
+
cInt
)
{
var
e
=
edges
[
i
++
];
var
e
=
edges
[
i
++
];
if
(
!
e
.
hidden
)
{
Attraction
.
apply_nn
(
Attraction
.
apply_nn
(
e
.
source
,
e
.
target
,
e
.
source
,
e
.
target
,
Math
.
pow
(
e
.
weight
||
1
,
self
.
p
.
edgeWeightInfluence
)
Math
.
pow
(
e
.
weight
||
1
,
self
.
p
.
edgeWeightInfluence
)
);
);
}
}
}
}
}
if
(
i
==
edges
.
length
)
{
if
(
i
==
edges
.
length
)
{
self
.
state
.
step
=
4
;
self
.
state
.
step
=
4
;
...
@@ -233,7 +249,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
...
@@ -233,7 +249,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
nodes
.
forEach
(
function
(
n
)
{
nodes
.
forEach
(
function
(
n
)
{
var
fixed
=
n
.
fixed
||
false
;
var
fixed
=
n
.
fixed
||
false
;
if
(
!
fixed
&&
n
.
fa2
)
{
if
(
!
fixed
&&
!
n
.
hidden
&&
n
.
degree
>
0
&&
n
.
fa2
)
{
var
swinging
=
Math
.
sqrt
(
Math
.
pow
(
n
.
fa2
.
old_dx
-
n
.
fa2
.
dx
,
2
)
+
var
swinging
=
Math
.
sqrt
(
Math
.
pow
(
n
.
fa2
.
old_dx
-
n
.
fa2
.
dx
,
2
)
+
Math
.
pow
(
n
.
fa2
.
old_dy
-
n
.
fa2
.
dy
,
2
));
Math
.
pow
(
n
.
fa2
.
old_dy
-
n
.
fa2
.
dy
,
2
));
...
@@ -285,8 +301,10 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
...
@@ -285,8 +301,10 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
// Save old coordinates
// Save old coordinates
nodes
.
forEach
(
function
(
n
)
{
nodes
.
forEach
(
function
(
n
)
{
if
(
!
n
.
hidden
&&
n
.
degree
>
0
)
{
n
.
old_x
=
+
n
.
x
;
n
.
old_x
=
+
n
.
x
;
n
.
old_y
=
+
n
.
y
;
n
.
old_y
=
+
n
.
y
;
}
});
});
self
.
state
.
step
=
5
;
self
.
state
.
step
=
5
;
...
@@ -302,7 +320,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
...
@@ -302,7 +320,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
while
(
i
<
nodes
.
length
&&
i
<
self
.
state
.
index
+
sInt
)
{
while
(
i
<
nodes
.
length
&&
i
<
self
.
state
.
index
+
sInt
)
{
var
n
=
nodes
[
i
++
];
var
n
=
nodes
[
i
++
];
var
fixed
=
n
.
fixed
||
false
;
var
fixed
=
n
.
fixed
||
false
;
if
(
!
fixed
&&
n
.
fa2
)
{
if
(
!
fixed
&&
!
n
.
hidden
&&
n
.
degree
>
0
&&
n
.
fa2
)
{
// Adaptive auto-speed: the speed of each node is lowered
// Adaptive auto-speed: the speed of each node is lowered
// when the node swings.
// when the node swings.
var
swinging
=
Math
.
sqrt
(
var
swinging
=
Math
.
sqrt
(
...
@@ -327,7 +345,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
...
@@ -327,7 +345,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
while
(
i
<
nodes
.
length
&&
i
<
self
.
state
.
index
+
sInt
)
{
while
(
i
<
nodes
.
length
&&
i
<
self
.
state
.
index
+
sInt
)
{
var
n
=
nodes
[
i
++
];
var
n
=
nodes
[
i
++
];
var
fixed
=
n
.
fixed
||
false
;
var
fixed
=
n
.
fixed
||
false
;
if
(
!
fixed
&&
n
.
fa2
)
{
if
(
!
fixed
&&
!
n
.
hidden
&&
n
.
degree
>
0
&&
n
.
fa2
)
{
// Adaptive auto-speed: the speed of each node is lowered
// Adaptive auto-speed: the speed of each node is lowered
// when the node swings.
// when the node swings.
var
swinging
=
Math
.
sqrt
(
var
swinging
=
Math
.
sqrt
(
...
@@ -364,6 +382,8 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
...
@@ -364,6 +382,8 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
this
.
graph
.
nodes
.
forEach
(
function
(
n
)
{
this
.
graph
.
nodes
.
forEach
(
function
(
n
)
{
n
.
fa2
=
null
;
n
.
fa2
=
null
;
});
});
pr
(
"#nodes: "
+
V
);
pr
(
"#edges: "
+
E
);
}
}
// Auto Settings
// Auto Settings
...
@@ -997,7 +1017,9 @@ sigma.publicPrototype.startForceAtlas2 = function() {
...
@@ -997,7 +1017,9 @@ sigma.publicPrototype.startForceAtlas2 = function() {
for
(
var
i
in
this
.
_core
.
graph
.
nodesIndex
)
{
for
(
var
i
in
this
.
_core
.
graph
.
nodesIndex
)
{
// if(this._core.graph.nodesIndex[i].degree==0)
if
(
this
.
_core
.
graph
.
nodesIndex
[
i
].
degree
==
0
)
{
this
.
_core
.
graph
.
nodesIndex
[
i
].
color
=
"#000000"
}
// this._core.graph.nodesIndex[i].hidden = true;
// this._core.graph.nodesIndex[i].hidden = true;
pr
(
i
+
" -> "
+
this
.
_core
.
graph
.
nodesIndex
[
i
].
degree
)
pr
(
i
+
" -> "
+
this
.
_core
.
graph
.
nodesIndex
[
i
].
degree
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment