changeset 115:509d350a4768 draft

modified sampleJSONData
author Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
date Mon, 18 Mar 2013 06:43:58 +0900
parents 2c280381bd53
children 55ca97731a4b
files public/viewer/viewer_white.html
diffstat 1 files changed, 74 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/public/viewer/viewer_white.html	Mon Mar 18 05:42:11 2013 +0900
+++ b/public/viewer/viewer_white.html	Mon Mar 18 06:43:58 2013 +0900
@@ -550,9 +550,8 @@
 	if (!childNode.position) {
 	    childNode.position = calcChildNodePosition(node, numCalcChild);
 	    updateNode(childNode);
-	    numCalcChild++;
-//	    recursiveShowRelationNodes(graphData, childNode);
 	}
+	numCalcChild++;
     }
     /* calcration of grandchildNode position  */
     for (var i=0; i<childNodeIds.length; i++) {
@@ -581,12 +580,43 @@
     testStart();
 })
 
+function recursiveCalcPosition(graphData, parentNode) {
+    if (!parentNode.position) updateNode(parentNode);
+    childNodeIds = getRelationNodeIds(graphData, parentNode);
+    /* calcration of childNode position */
+    var numCalcChild = 0;
+    var childArray = {};
+    for (var i=0; i<childNodeIds.length; i++) {
+	var id = childNodeIds[i];
+	var childNode = graphData.nodes[id];
+	childArray[id] = childNode;
+	if (!childNode.position) {
+	    childNode.position = calcChildNodePosition(parentNode, numCalcChild);
+	    numCalcChild++;
+	}
+    }
+    /* calcration of grandchildNode position  */
+    for (var id in childArray) {
+	var childNode = childArray[id];
+	var grandChildIds = getRelationNodeIds(graphData, childNode);
+	for (var i=0; i<grandChildIds.length; i++) {
+	    var gId = grandChildIds[i];
+	    var grandChild = graphData.nodes[gId];
+	    if (!grandChild.position) {
+ 		recursiveCalcPosition(graphData, childNode);
+	    }
+	}
+    }
+}
+
 var GRAPH_DATA = new GraphData();
+var rootNode = {};
 function testStart() {
     init();
     var graphData = parseJSONGraphData(GRAPH_DATA, sampleJSONData);
     var rootNodeId = "1";
-    var rootNode = graphData.nodes[rootNodeId];
+    rootNode = graphData.nodes[rootNodeId];
+    recursiveCalcPosition(graphData, rootNode);
     updateNode(rootNode);
 //    showRelationNodes(graphData, rootNode, {dependency:1});
 //    recursiveShowRelationNodes(graphData, rootNode);
@@ -616,7 +646,7 @@
         },
         {
             id:"3",
-	    title:"context2",
+	    title:"context3",
 	    createdUser:"tamayose"
         },
 	{
@@ -627,9 +657,18 @@
 	},
 	{
 	    id:"5",
-	    title:"5",
-	    kind:"agree",
+	    title:"conetxt5",
  	    createdUser:"oshiro"
+	},
+	{
+	    id:"6",
+	    title:"context6",
+ 	    createdUser:"kinjo"
+	},
+	{
+	    id:"7",
+	    title:"context7",
+ 	    createdUser:"tamayose"
 	}
     ],
     edges: [
@@ -642,25 +681,47 @@
         },
         {
             id:"12",
-            from:"2",
+            from:"1",
             to:"3",
-            rel:"dependency",
+            rel:"evidence",
             type:""
         },
         {
             id:"13",
             from:"3",
-            to:"1",
+            to:"4",
             rel:"evidence",
-            type:"both"
+            type:""
         },
 	{
 	    id:"14",
-	    from:"4",
-	    to:"2",
-	    rel:"dependency",
+	    from:"3",
+	    to:"5",
+	    rel:"derived",
+	    type:""
+	},
+	{
+	    id:"15",
+	    from:"6",
+	    to:"1",
+	    rel:"agreement",
+	    type:""
+	},
+	{
+	    id:"17",
+	    from:"7",
+	    to:"4",
+	    rel:"evidence",
+	    type:""
+	},
+	{
+	    id:"18",
+	    from:"7",
+	    to:"5",
+	    rel:"evidence",
 	    type:""
 	}
+
     ]
 };