[209] | 1 | var SPARQLBuilder = function(result,endpoint) {
|
---|
| 2 | this.result = result;
|
---|
| 3 | this.builder = this.createBuilder('http://www.sparqlbuilder.org/forms/guiform.php');
|
---|
| 4 | this.showBuilder();
|
---|
| 5 | this.drawGraph = null;
|
---|
| 6 | this.startClass = null;
|
---|
| 7 | this.endClass = null;
|
---|
| 8 | this.endPoint = endpoint;
|
---|
| 9 | };
|
---|
| 10 |
|
---|
| 11 | SPARQLBuilder.prototype.createBuilder = function(form) {
|
---|
| 12 | var builder = $('<div class="SparqlBuilder"></div>');
|
---|
| 13 | var content = $('<div class="SparqlBuilderContent"></div>');
|
---|
| 14 | builder.prepend(content);
|
---|
| 15 | var self = this;
|
---|
| 16 | $.ajax({
|
---|
| 17 | type : "GET",
|
---|
| 18 | url : form,
|
---|
| 19 | async : false,
|
---|
| 20 | success : function(data) {
|
---|
| 21 | content.prepend($(data));
|
---|
| 22 | }
|
---|
| 23 | });
|
---|
| 24 | $("body").prepend(builder);
|
---|
| 25 | return builder;
|
---|
[219] | 26 | };
|
---|
[209] | 27 |
|
---|
| 28 | SPARQLBuilder.prototype.showBuilder = function() {
|
---|
| 29 | var width = $(document).width();
|
---|
| 30 | var height = $(document).height();
|
---|
| 31 | this.builder.css("width", width);
|
---|
| 32 | this.builder.css("height", height);
|
---|
| 33 | this.builder.css("display", "block");
|
---|
| 34 |
|
---|
| 35 | document.getElementById("sparqlBuilderAjaxload").style.width = width;
|
---|
| 36 | document.getElementById("sparqlBuilderAjaxload").style.height = height;
|
---|
| 37 | this.loadIcon("hide");
|
---|
| 38 |
|
---|
| 39 | var self = this;
|
---|
| 40 | this.loadEndPointList();
|
---|
| 41 |
|
---|
| 42 | $("#EndPointSelect").change(function() {
|
---|
| 43 | self.changeEndPoint();
|
---|
| 44 | });
|
---|
| 45 | //$("#SetClassButton").click(function() {
|
---|
| 46 | // self.startClass = $("#StartClassSelect").val();
|
---|
| 47 | // self.endClass = $("#EndClassSelect").val();
|
---|
| 48 | // self.loadPathList();
|
---|
| 49 | //});
|
---|
| 50 | $("#StartClassSelect").change(function() {
|
---|
| 51 | self.startClass = $("#StartClassSelect").val();
|
---|
| 52 | self.loadPathList();
|
---|
| 53 | });
|
---|
| 54 | $("#EndClassSelect").change(function() {
|
---|
| 55 | self.endClass = $("#EndClassSelect").val();
|
---|
| 56 | self.loadPathList();
|
---|
| 57 | });
|
---|
| 58 | $("#sparqlBuilderViewall").click(function() {
|
---|
| 59 | self.drawGraph.setPathLimit(0);
|
---|
| 60 | self.drawGraph.view_map();
|
---|
| 61 | });
|
---|
| 62 | $("#GenerateSPARQLButton").click(function() {
|
---|
| 63 | var sparql = self.generateSPARQL(self.drawGraph.pathobj);
|
---|
| 64 | });
|
---|
| 65 | $("#SparqlBuilderCancel").click(function() {
|
---|
| 66 | self.hideBuilder();
|
---|
| 67 | });
|
---|
[219] | 68 | };
|
---|
[209] | 69 |
|
---|
| 70 | SPARQLBuilder.prototype.loadIcon = function(mode) {
|
---|
| 71 | if(mode == "view"){
|
---|
| 72 | document.getElementById("sparqlBuilderAjaxload").style.display = "block";
|
---|
| 73 | }else{
|
---|
| 74 | document.getElementById("sparqlBuilderAjaxload").style.display = "none";
|
---|
| 75 | }
|
---|
[219] | 76 | };
|
---|
[209] | 77 |
|
---|
| 78 | SPARQLBuilder.prototype.loadEndPointList = function() {
|
---|
| 79 | var url = 'http://www.sparqlbuilder.org/api/eplist';
|
---|
| 80 | $.ajax({
|
---|
| 81 | url: url,
|
---|
| 82 | success: function(data) {
|
---|
| 83 | var list = eval(data);
|
---|
[219] | 84 | var event = new $.Event('complete');
|
---|
[209] | 85 | $("#EndPointSelect").empty();
|
---|
| 86 | $("#EndPointSelect").append('<option>SELECT</option>');
|
---|
| 87 | for (var i = 0; i < list.length; ++i) {
|
---|
| 88 | $("#EndPointSelect").append('<option value="' + list[i] + '">' + list[i] + '</option>');
|
---|
| 89 | }
|
---|
[219] | 90 | $("#EndPointSelect").trigger(event);
|
---|
[209] | 91 | },
|
---|
| 92 | });
|
---|
[219] | 93 | };
|
---|
[209] | 94 |
|
---|
| 95 | SPARQLBuilder.prototype.loadClassList = function() {
|
---|
| 96 | var url = "http://www.sparqlbuilder.org/api/clist?ep=" + encodeURIComponent(this.endpoint);
|
---|
[215] | 97 | //var url = "http://localhost:8080/api/clist?ep=" + encodeURIComponent(this.endpoint);
|
---|
[209] | 98 | $.ajax({
|
---|
| 99 | type : "GET",
|
---|
| 100 | url : url,
|
---|
| 101 | async : false,
|
---|
| 102 | success : function(data) {
|
---|
[219] | 103 | var list = eval(data);
|
---|
| 104 | var event = new $.Event('complete');
|
---|
[209] | 105 | $("#StartClassSelect").empty();
|
---|
| 106 | $("#EndClassSelect").empty();
|
---|
| 107 | for (var i = 0; i < list.length; ++i) {
|
---|
| 108 | //$("#StartClassSelect").append('<option value="' + list[i]['uri'] + '">' + list[i]['display'] + '</option>');
|
---|
| 109 | //$("#EndClassSelect").append('<option value="' + list[i]['uri'] + '">' + list[i]['display'] + '</option>');
|
---|
| 110 | $("#StartClassSelect").append('<option value="' + list[i]['uri'] + '">' + list[i]['label'] + ' (' + list[i]['number'] + ')' + '</option>');
|
---|
| 111 | $("#EndClassSelect").append('<option value="' + list[i]['uri'] + '">' + list[i]['label'] + ' (' + list[i]['number'] + ')' + '</option>');
|
---|
| 112 | }
|
---|
[219] | 113 | $("#StartClassSelect").trigger(event)
|
---|
| 114 | $("#EndClassSelect").trigger(event)
|
---|
[209] | 115 | }
|
---|
| 116 | });
|
---|
[219] | 117 | };
|
---|
[209] | 118 |
|
---|
| 119 | SPARQLBuilder.prototype.loadPathList = function() {
|
---|
| 120 | if (this.startClass == null || this.endClass == null ){ return; }
|
---|
| 121 | var startclass = $("#StartClassSelect").val();
|
---|
| 122 | var endclass = $("#EndClassSelect").val();
|
---|
| 123 | var url = "http://www.sparqlbuilder.org/api/plist?ep=" + encodeURIComponent(this.endpoint)
|
---|
| 124 | + "&startclass=" + encodeURIComponent(startclass)
|
---|
| 125 | + "&endclass=" + encodeURIComponent(endclass);
|
---|
[215] | 126 | //var url = "http://localhost:8080/api/plist?ep=" + encodeURIComponent(this.endpoint)
|
---|
| 127 | // + "&startclass=" + encodeURIComponent(startclass)
|
---|
| 128 | // + "&endclass=" + encodeURIComponent(endclass);
|
---|
[209] | 129 | var self = this;
|
---|
| 130 | self.loadIcon("view");
|
---|
| 131 | setTimeout(function(){
|
---|
| 132 |
|
---|
| 133 | $.ajax({
|
---|
| 134 | type : "GET",
|
---|
| 135 | url : url,
|
---|
| 136 | async : false,
|
---|
| 137 | timeout : 1000000,
|
---|
| 138 | success : function(data) {
|
---|
| 139 | var width = $(".SparqlBuilderContent").width();
|
---|
| 140 | self.drawGraph = new SPARQLBuilderDrawGraph(data, width, 10);
|
---|
| 141 | self.loadIcon("hide");
|
---|
| 142 | self.drawGraph.view_map();
|
---|
| 143 | },
|
---|
| 144 | error: function(data){
|
---|
| 145 | self.loadIcon("hide");
|
---|
| 146 | alert("error: ", data);
|
---|
| 147 | }
|
---|
| 148 | });
|
---|
| 149 | }, 100)
|
---|
[219] | 150 | };
|
---|
[209] | 151 |
|
---|
| 152 | SPARQLBuilder.prototype.changeEndPoint = function() {
|
---|
| 153 | this.endpoint = $("#EndPointSelect").val();
|
---|
| 154 | this.loadClassList();
|
---|
[219] | 155 | };
|
---|
[209] | 156 |
|
---|
| 157 | SPARQLBuilder.prototype.hideBuilder = function() {
|
---|
| 158 | this.builder.hide();
|
---|
[219] | 159 | };
|
---|
[209] | 160 |
|
---|
| 161 | SPARQLBuilder.prototype.generateSPARQL = function(pathobj) {
|
---|
| 162 | var path = JSON.stringify(pathobj);
|
---|
[215] | 163 | var url = 'http://www.sparqlbuilder.org/api/sparql?path=' + encodeURIComponent(path);
|
---|
| 164 | //var url = 'http://localhost:8080/api/sparql?path=' + encodeURIComponent(path);
|
---|
[209] | 165 | var sparql = '';
|
---|
| 166 | var self = this;
|
---|
| 167 | $.ajax({
|
---|
| 168 | type: "GET",
|
---|
| 169 | url : url,
|
---|
| 170 | dataType: 'text',
|
---|
| 171 | async: false,
|
---|
| 172 | success : function(data) {
|
---|
| 173 | $("#" + self.result).val(data);
|
---|
| 174 | //$("#" + self.endPoint).val($('EndPointSelect').val());
|
---|
| 175 | $("#" + self.endPoint).val(self.endpoint);
|
---|
| 176 | self.hideBuilder();
|
---|
| 177 | }
|
---|
| 178 | });
|
---|
[219] | 179 | };
|
---|
[209] | 180 |
|
---|
| 181 | var SPARQLBuilderDrawGraph = function(jsontext, width, pathlimit) {
|
---|
| 182 | this.jsontext = jsontext;
|
---|
| 183 | this.width = width;
|
---|
| 184 | this.pathlimit = pathlimit;
|
---|
| 185 | this.pathobj = null;
|
---|
| 186 | this.NODEHEIGHT = 50;
|
---|
| 187 | this.MOUSEMOVED = 0;
|
---|
[219] | 188 | };
|
---|
[209] | 189 |
|
---|
| 190 | SPARQLBuilderDrawGraph.prototype.setPathLimit = function(pathlimit) {
|
---|
| 191 | this.pathlimit = pathlimit;
|
---|
[219] | 192 | };
|
---|
[209] | 193 |
|
---|
| 194 | SPARQLBuilderDrawGraph.prototype.view_map = function(){
|
---|
| 195 |
|
---|
| 196 | // make_data繝。繧ス繝�ラ縺ョ邨先棡繧貞叙蠕� |
---|
| 197 | var json = this.make_data(0);
|
---|
| 198 |
|
---|
| 199 | // SVG縺悟ュ伜惠縺吶k縺ェ繧峨�蜑企勁
|
---|
| 200 | if (d3.select("#sparqlBuilderGraph").select("svg")) {
|
---|
| 201 | d3.select("#sparqlBuidlerGraph").select("svg").remove();
|
---|
| 202 | }
|
---|
| 203 |
|
---|
| 204 | if(json['nodes'].length != 0){
|
---|
| 205 |
|
---|
| 206 | // 蜃コ譚・荳翫′縺」縺溽オ先棡繧呈ク。縺励※繝槭ャ繝嶺ク翫�繝ュ繧ア繝シ繧キ繝ァ繝ウ繧偵そ繝�ヨ
|
---|
| 207 | this.set_map_location(0, json['nodes'], json['links']);
|
---|
| 208 |
|
---|
| 209 | // SVG縺ョ蟷�→鬮倥&繧定ィュ螳夲シ亥ケ�シ夂判髱「縺�▲縺ア縺�鬮倥&�壹ヱ繧ケ縺ョ謨ー縺ォ蠢懊§險ュ螳夲シ� |
---|
| 210 | var width = this.width;
|
---|
| 211 | var height = ((this.NODEHEIGHT * 1.5) * this.PATHNUM) + (this.NODEHEIGHT / 2);
|
---|
| 212 |
|
---|
| 213 | // 繧ォ繝ゥ繝シ繧貞叙蠕� |
---|
| 214 | var color = d3.scale.category20();
|
---|
| 215 |
|
---|
| 216 | // 逕サ髱「繧オ繧、繧コ縺ォ蜷医o縺婀VG縺ョ霑ス蜉
|
---|
| 217 | var svg = d3.select("#sparqlBuilderGraph").append("svg")
|
---|
| 218 | .attr("width", width)
|
---|
| 219 | .attr("height", height);
|
---|
| 220 |
|
---|
| 221 | // 閭梧勹縺ョ霑ス蜉
|
---|
| 222 | var bg = svg
|
---|
| 223 | .append("rect")
|
---|
| 224 | .attr("x", 0)
|
---|
| 225 | .attr("y", 0)
|
---|
| 226 | .attr("width", width)
|
---|
| 227 | .attr("height", height)
|
---|
| 228 | .attr("fill", "#fafafa");
|
---|
| 229 |
|
---|
| 230 | // links驟榊�繧呈ク。縺励Μ繝ウ繧ッ縺ョ菴懈�
|
---|
| 231 | var link = svg.selectAll(".link")
|
---|
| 232 | .data(json.links)
|
---|
| 233 | .enter().append("line")
|
---|
| 234 | .attr("class", "link")
|
---|
| 235 | .style("stroke-width", function(d) { return Math.sqrt(d.value);});
|
---|
| 236 |
|
---|
| 237 | // nodes驟榊�繧呈ク。縺励ヮ繝シ繝峨�菴懈�
|
---|
| 238 | var node = svg.selectAll(".node")
|
---|
| 239 | .data(json.nodes)
|
---|
| 240 | .enter().append("circle")
|
---|
| 241 | .attr("class", "node")
|
---|
| 242 | .attr("r", (this.NODEHEIGHT / 2))
|
---|
| 243 | .attr("cx", function(d) { return d.x;} )
|
---|
| 244 | .attr("cy", function(d) { return d.y; })
|
---|
| 245 | .style("stroke", function(d) { return '#fafafa'; })
|
---|
| 246 | .style("stroke-width", function(d) { return '1.5px'; })
|
---|
| 247 | .style("fill", function(d) { return d.nodecolor; })
|
---|
| 248 | .style("cursor", function(d) { return 'pointer'; });
|
---|
| 249 |
|
---|
| 250 | // nodes驟榊�繧呈ク。縺励ヮ繝シ繝峨ユ繧ュ繧ケ繝医�菴懈�
|
---|
| 251 | var tnode = svg.selectAll("text.node")
|
---|
| 252 | .data(json.nodes)
|
---|
| 253 | .enter().append("svg:text")
|
---|
| 254 | .attr("class", "tnode")
|
---|
| 255 | .attr("x", function(d) { return d.x; })
|
---|
| 256 | .attr("y", function(d) { return d.y; })
|
---|
| 257 | .text(function(d) { return d.name; })
|
---|
| 258 | .style("fill", function(d) { return '#000000'; })
|
---|
| 259 | .style("text-anchor", function(d) { return 'middle'; })
|
---|
| 260 | .style("pointer-events", "none");
|
---|
| 261 |
|
---|
| 262 | // 繝ェ繝ウ繧ッ繝�く繧ケ繝医�菴懈�
|
---|
| 263 | var tlink = svg.selectAll("text.link")
|
---|
| 264 | .data(json.links)
|
---|
| 265 | .enter().append("svg:text")
|
---|
| 266 | .attr("class", "tlink")
|
---|
| 267 | .attr("x", function(d) { return (json.nodes[d.source].x + json.nodes[d.target].x) / 2; })
|
---|
| 268 | .attr("y", function(d) { return (json.nodes[d.source].y + json.nodes[d.target].y) / 2; })
|
---|
| 269 | .style("fill", function(d) { return '#000000'; })
|
---|
| 270 | .style("text-anchor", function(d) { return 'middle'; });
|
---|
| 271 |
|
---|
| 272 | // 繝弱�繝峨∈縺ョ繧ェ繝ウ繝槭え繧ケ縺ァ繝代せ謗「邏「縲√ヱ繧ケ荳ュ縺ョ繝ェ繝ウ繧ッ譁�ュ励r陦ィ遉コ
|
---|
| 273 | var self = this;
|
---|
| 274 | node.on("mouseover", function(d){
|
---|
| 275 |
|
---|
| 276 | // 繝槭え繧ケ縺ョ蜍輔″繧ォ繧ヲ繝ウ繝医r繝ェ繧サ繝�ヨ
|
---|
| 277 | this.MOUSEMOVED = 0;
|
---|
| 278 |
|
---|
| 279 | // 陦ィ遉コ縺吶k繝代せ菫晏ュ倡畑驟榊�
|
---|
| 280 | var path = [];
|
---|
| 281 | // 繝��繝ォ繝√ャ繝励∈縺ョ蜷榊燕陦ィ遉コ逕ィ驟榊�
|
---|
| 282 | var pathname = [];
|
---|
| 283 |
|
---|
| 284 | // 繝ォ繝シ繝医ヮ繝シ繝我サ・螟悶↑繧� |
---|
| 285 | if(d.nodeid != 0){
|
---|
| 286 | // 縺セ縺壹が繝ウ繝槭え繧ケ縺輔l縺溘ヮ繝シ繝峨�id縺ィ蜷榊燕繧偵◎繧後◇繧瑚ソス蜉
|
---|
| 287 | path.push(d.nodeid);
|
---|
| 288 | pathname.push(d.name);
|
---|
| 289 |
|
---|
| 290 | // 繝代せ謗「邏「
|
---|
| 291 | do{
|
---|
| 292 | // 繝ェ繝ウ繧ッ縺ョ謨ー縺縺醍ケー繧願ソ斐@
|
---|
| 293 | for(var i = 0; i < link.data().length; i++){
|
---|
| 294 | // 迴セ蝨ィ縺ョ譛蠕悟ーセ縺ォ郢九′繧九Μ繝ウ繧ッ縺後≠繧後�
|
---|
| 295 | if(path[(path.length-1)] == link.data()[i].target){
|
---|
| 296 | // 縺昴�繝ェ繝ウ繧ッ縺ョ繧ス繝シ繧ケ蛛エ繝弱�繝峨�id繧定ソス蜉
|
---|
| 297 | path.push(link.data()[i].source);
|
---|
| 298 | // 縺昴�繝ェ繝ウ繧ッ縺ョ蜷榊燕縺ィ繧ス繝シ繧ケ蛛エ繝弱�繝峨�蜷榊燕繧定ソス蜉
|
---|
| 299 | pathname.push(link.data()[i].property);
|
---|
| 300 | pathname.push(node.data()[link.data()[i].source].name);
|
---|
| 301 | }
|
---|
| 302 | }
|
---|
| 303 | // 繝ォ繝シ繝医ヮ繝シ繝峨↓霎ソ繧顔捩縺上∪縺ァ郢ー繧願ソ斐☆
|
---|
| 304 | }while(path[(path.length-1)] != 0);
|
---|
| 305 |
|
---|
| 306 | // 譛ォ遶ッ繝弱�繝峨〒縺ェ縺�↑繧� |
---|
| 307 | if(d.path == "notend"){
|
---|
| 308 | // 繝��繝ォ繝√ャ繝励r髱櫁。ィ遉コ縺ォ
|
---|
| 309 | document.getElementById("sparqlBuilderShowpath").style.display = "none";
|
---|
| 310 | }else{
|
---|
| 311 | // 譛ォ遶ッ繝弱�繝峨↑繧峨ヤ繝シ繝ォ繝√ャ繝励�諠�ア繧呈峩譁ー
|
---|
| 312 | var resultText = "<h3>Selected Path</h3>";
|
---|
| 313 | // 繝代せ縺ョ蜷榊燕驟榊�蛻�セ後m縺九i郢ー繧願ソ斐@縺ェ縺後i
|
---|
| 314 | for (var i = pathname.length;i > 0; i--){
|
---|
| 315 | // 螂�焚逡ェ逶ョ�医ヮ繝シ繝峨�蜷榊燕�峨�螟ェ蟄励↓
|
---|
| 316 | if(i % 2 == 1){
|
---|
| 317 | resultText = resultText + "<span style=\"font-weight: bold;\">" + pathname[i - 1] + "</span><br><br>";
|
---|
| 318 | // 蛛カ謨ー逡ェ逶ョ�医Μ繝ウ繧ッ縺ョ蜷榊燕�峨�縺昴�縺セ縺セ縺ァ陦ィ遉コ
|
---|
| 319 | }else{
|
---|
| 320 | resultText = resultText + pathname[i - 1] + "<br><br>";
|
---|
| 321 | }
|
---|
| 322 | }
|
---|
| 323 | // 繝��繝ォ繝√ャ繝励�蜀�ョケ繧呈嶌縺肴鋤縺� |
---|
| 324 | document.getElementById("sparqlBuilderSelectpath").innerHTML=(resultText);
|
---|
| 325 | document.getElementById("sparqlBuilderShowpath").style.display = "block";
|
---|
| 326 |
|
---|
| 327 | // 繧オ繝シ繝悶Ξ繝�ヨ縺ォ騾√j霑斐☆繝代せ繧ェ繝悶ず繧ァ繧ッ繝医r菫晏ュ� |
---|
| 328 | self.pathobj = d.path;
|
---|
| 329 |
|
---|
| 330 | // 繝��繝ォ繝√ャ繝苓。ィ遉コ譎ゅ�蠎ァ讓呻シ医が繝ウ繝槭え繧ケ縺輔l縺溘ヮ繝シ繝峨�讓ェ縺ォ繝懊ち繝ウ縺梧擂繧九h縺��鄂ョ�� |
---|
| 331 | var xPosition = parseFloat(d3.select(this).attr("cx")) + parseFloat(d3.select(this).style("stroke-width")) + (self.NODEHEIGHT * 0.5);
|
---|
| 332 | var yPosition = parseFloat(d3.select(this).attr("cy") - document.getElementById("sparqlBuilderShowpath").offsetHeight + 50 + document.getElementById("sparqlBuilderSetting").offsetHeight) + (self.NODEHEIGHT * 0.5);
|
---|
| 333 |
|
---|
| 334 | // 繝��繝ォ繝√ャ繝励′逕サ髱「螟悶↓蜃コ縺ェ縺�h縺�」懈ュ」
|
---|
| 335 | if(xPosition < 0){
|
---|
| 336 | xPosition = 0;
|
---|
| 337 | }
|
---|
| 338 | if(yPosition < 0){
|
---|
| 339 | yPosition = 0;
|
---|
| 340 | }
|
---|
| 341 |
|
---|
| 342 | // 逕滓�縺励◆蠎ァ讓吶↓繝��繝ォ繝√ャ繝励r陦ィ遉コ
|
---|
| 343 | document.getElementById("sparqlBuilderShowpath").style.left = xPosition + "px"
|
---|
| 344 | document.getElementById("sparqlBuilderShowpath").style.top = yPosition + "px"
|
---|
| 345 | }
|
---|
| 346 | // 繝ォ繝シ繝医ヮ繝シ繝峨□縺」縺溘↑繧� |
---|
| 347 | }else{
|
---|
| 348 | // 繝��繝ォ繝√ャ繝励r髱櫁。ィ遉コ
|
---|
| 349 | document.getElementById("sparqlBuilderShowpath").style.display = "none";
|
---|
| 350 | }
|
---|
| 351 |
|
---|
| 352 | // 繧ェ繝ウ繝槭え繧ケ縺輔l縺溘ヮ繝シ繝峨�鬮倥&縺ォ隕ェ繧貞粋繧上○繧九◆繧√↓蜷医o縺帙k鬮倥&繧剃ソ晏ュ� |
---|
| 353 | var movey = d.y;
|
---|
| 354 |
|
---|
| 355 | // 蜷�ヮ繝シ繝峨↓蟇セ縺� |
---|
| 356 | node
|
---|
| 357 | // 霈ェ驛ュ邱壹�濶イ繧定ィュ螳� |
---|
| 358 | .style("stroke", function(d){
|
---|
| 359 | // 縺セ縺壹�閭梧勹濶イ�医ョ繝輔か繝ォ繝茨シ峨r謖�ョ� |
---|
| 360 | var strokecolor = "#fafafa";
|
---|
| 361 |
|
---|
| 362 | // 繝代せ蛻、螳壹�蜑榊�逅� |
---|
| 363 | // 陦ィ遉コ繝輔Λ繧ー縺系ow�亥燕蝗槭が繝ウ繝槭え繧ケ縺ァ蜍輔>縺ヲ縺�◆繝弱�繝会シ峨↑繧� |
---|
| 364 | if(d.view == "now"){
|
---|
| 365 | // 繝弱�繝峨�陦ィ遉コ繝輔Λ繧ー繧地o縺ォ
|
---|
| 366 | d.view = "no";
|
---|
| 367 | }
|
---|
| 368 | // 陦ィ遉コ繝輔Λ繧ー縺稽oved�医け繝ェ繝�け縺輔l蝗コ螳壽ク医∩縺縺悟燕蝗槫虚縺�※縺�◆繝弱�繝会シ峨↑繧� |
---|
| 369 | if(d.view == "moved"){
|
---|
| 370 | // 陦ィ遉コ繝輔Λ繧ー繧団licked縺ォ謌サ縺� |
---|
| 371 | d.view = "clicked";
|
---|
| 372 | }
|
---|
| 373 |
|
---|
| 374 | // 陦ィ遉コ繝輔Λ繧ー縺系o縺ョ繧ゅ�縺九i遒コ隱� |
---|
| 375 | if(d.view == "no"){
|
---|
| 376 | // 繝代せ縺ョ繝弱�繝画焚縺縺醍ケー繧願ソ斐@縺ェ縺後i
|
---|
| 377 | for(var n = 0; n < path.length; n++){
|
---|
| 378 | // 繝代せ蜀�↓蜷ォ縺セ繧後k繝弱�繝峨□縺」縺溘i
|
---|
| 379 | if(path[n] == d.nodeid){
|
---|
| 380 | // 霈ェ驛ュ邱壹r襍、縺ォ
|
---|
| 381 | strokecolor = "#ffaaaa";
|
---|
| 382 | // 陦ィ遉コ繝輔Λ繧ー繧地ow�井サ雁屓蜍輔>縺溘ヮ繝シ繝会シ峨↓
|
---|
| 383 | d.view = "now";
|
---|
| 384 | }
|
---|
| 385 | }
|
---|
| 386 | // 蝗コ螳壽ク医∩繝弱�繝峨□縺」縺溘i
|
---|
| 387 | }else if(d.view == "clicked"){
|
---|
| 388 | // 縺セ縺壹�霈ェ驛ュ邱壹r襍、縺ォ
|
---|
| 389 | strokecolor = "#ffaaaa";
|
---|
| 390 | // 繝代せ蜀�↓蜷ォ縺セ繧後k繝弱�繝峨°繝√ぉ繝�け
|
---|
| 391 | for(var n = 0; n < path.length; n++){
|
---|
| 392 | if(path[n] == d.nodeid){
|
---|
| 393 | // 蜷ォ縺セ繧後※縺�◆縺ェ繧我サ雁屓蜍輔°縺吶◆繧√ヵ繝ゥ繧ー繧知oved縺ォ
|
---|
| 394 | d.view = "moved";
|
---|
| 395 | }
|
---|
| 396 | }
|
---|
| 397 | }
|
---|
| 398 |
|
---|
| 399 | // 縺薙%縺セ縺ァ縺ァ蠕励i繧後◆霈ェ驛ュ邱壹�濶イ繧定ソ斐☆
|
---|
| 400 | return strokecolor;
|
---|
| 401 | })
|
---|
| 402 | // 鬮倥&縺ョ蛟、
|
---|
| 403 | .attr("cy", function(d){
|
---|
| 404 | // 繝弱�繝峨′莉雁屓繧ェ繝ウ繝槭え繧ケ縺輔l縺溘�縺セ縺溘�蝗コ螳壽ク医∩縺縺檎ァサ蜍輔ヵ繝ゥ繧ー繧偵▽縺代i繧後※縺�l縺ー
|
---|
| 405 | if(d.view == "now" || d.view == "moved"){
|
---|
| 406 | // 迴セ蝨ィ縺ョ鬮倥&繧貞叙蠕� |
---|
| 407 | var curty = d.y;
|
---|
| 408 | // d.y縺ォ蟄舌ヮ繝シ繝峨�鬮倥&繧偵そ繝�ヨ
|
---|
| 409 | d.y = movey;
|
---|
| 410 | // 迴セ蝨ィ縺ョ鬮倥&繧定ソ斐☆�医%縺ョ譎らせ縺ァ縺ッ迴セ蝨ィ菴咲スョ縺ォ謠冗判縺輔l縲〉edraw髢「謨ー縺ァd.y縺ォ繧「繝九Γ繝シ繧キ繝ァ繝ウ縺輔l繧具シ� |
---|
| 411 | return curty;
|
---|
| 412 | // 遘サ蜍募ッセ雎。縺ァ縺ェ縺�↑繧� |
---|
| 413 | }else{
|
---|
| 414 | // 迴セ蝨ィ菴咲スョ繧偵◎縺ョ縺セ縺セ霑斐☆
|
---|
| 415 | return d.y;
|
---|
| 416 | }
|
---|
| 417 | });
|
---|
| 418 |
|
---|
| 419 | // 蜷�Μ繝ウ繧ッ繝�く繧ケ繝医↓蟇セ縺� |
---|
| 420 | tlink
|
---|
| 421 | // 繝�く繧ケ繝郁。ィ遉コ蛻、螳� |
---|
| 422 | .text(function(d) {
|
---|
| 423 | // 繝�ヵ繧ゥ繝ォ繝医〒遨コ繧偵そ繝�ヨ
|
---|
| 424 | var linktext = "";
|
---|
| 425 | // 陦ィ遉コ繝輔Λ繧ー縺系ow�亥燕蝗櫁。ィ遉コ縺輔l縺ヲ縺�◆繝ェ繝ウ繧ッ�峨↑繧� |
---|
| 426 | if(d.view == "now"){
|
---|
| 427 | // 陦ィ遉コ繝輔Λ繧ー繧定ァ」髯、
|
---|
| 428 | d.view = "no";
|
---|
| 429 | }
|
---|
| 430 |
|
---|
| 431 | // 陦ィ遉コ繝輔Λ繧ー縺系o縺ェ繧� |
---|
| 432 | if(d.view == "no"){
|
---|
| 433 | // 繝代せ縺ョ繝弱�繝画焚蛻�ケー繧願ソ斐@
|
---|
| 434 | for(var t = 0; t < path.length; t++){
|
---|
| 435 | // 閾ェ霄ォ縺後◎縺ョ繝弱�繝峨∈謗・邯壹@縺ヲ縺�k繝ェ繝ウ繧ッ�医°縺、縺昴�繝弱�繝峨′謚倥j縺溘◆縺セ繧後※縺�↑縺代l縺ー�� |
---|
| 436 | if(path[t] == d.target && node.data()[d.target].view != "hide"){
|
---|
| 437 | // 繝ェ繝ウ繧ッ繝�く繧ケ繝医↓繝励Ο繝代ユ繧」縺ョ蛟、繧偵そ繝�ヨ
|
---|
| 438 | linktext = d.property
|
---|
| 439 | // 陦ィ遉コ繝輔Λ繧ー縺ォnow繧偵そ繝�ヨ
|
---|
| 440 | d.view = "now";
|
---|
| 441 | }
|
---|
| 442 | }
|
---|
| 443 | // 陦ィ遉コ繝輔Λ繧ー縺掲ix�医け繝ェ繝�け縺輔l縺溘ヱ繧ケ縺ョ繝ェ繝ウ繧ッ�峨↑繧峨��医°縺、郢九′繧句�縺ョ繝弱�繝峨′謚倥j縺溘◆縺セ繧後※縺�↑縺代l縺ー�� |
---|
| 444 | }else if(d.view == "fix" && node.data()[d.target].view != "hide"){
|
---|
| 445 | // 繝ェ繝ウ繧ッ繝�く繧ケ繝医↓繝励Ο繝代ユ繧」縺ョ蛟、繧偵そ繝�ヨ
|
---|
| 446 | linktext = d.property
|
---|
| 447 | }
|
---|
| 448 | // 縺薙%縺セ縺ァ縺ァ縺ァ縺阪◆繝ェ繝ウ繧ッ繝�く繧ケ繝医r霑斐☆
|
---|
| 449 | return linktext;
|
---|
| 450 | });
|
---|
| 451 |
|
---|
| 452 | // 蜷�Μ繝ウ繧ッ縺ォ蟇セ縺� |
---|
| 453 | link
|
---|
| 454 | // 邱壹�濶イ蛻、螳� |
---|
| 455 | .style("stroke", function(d){
|
---|
| 456 | // 陦ィ遉コ繝輔Λ繧ー縺系o縺ェ繧峨�
|
---|
| 457 | if(d.view == "no"){
|
---|
| 458 | // 濶イ繧偵ョ繝輔か繝ォ繝医↓
|
---|
| 459 | return "#999";
|
---|
| 460 | // 縺昴l莉・螟厄シ亥崋螳壹d繧ェ繝ウ繝槭え繧ケ縺輔l縺溘ヱ繧ケ縺ォ蜷ォ縺セ繧後k�峨↑繧� |
---|
| 461 | }else{
|
---|
| 462 | // 濶イ繧定オ、縺ォ
|
---|
| 463 | return "#ffaaaa";
|
---|
| 464 | }
|
---|
| 465 | });
|
---|
| 466 |
|
---|
| 467 | // 縺薙%縺セ縺ァ縺ョ險ュ螳壹r蜈�↓蜀肴緒逕サ
|
---|
| 468 | redraw();
|
---|
| 469 |
|
---|
| 470 | // 繝弱�繝峨∈縺ョ繧ッ繝ェ繝�け縺ァ驕ク謚槫崋螳壼喧�亥所縺ウ謚倥j逡ウ縺ソ蜃ヲ逅�シ� |
---|
| 471 | }).on("click", function(d){
|
---|
| 472 |
|
---|
| 473 | // 蜷�ヮ繝シ繝峨↓蟇セ縺� |
---|
| 474 | node
|
---|
| 475 | // 霈ェ驛ュ邱壹�蛻、螳� |
---|
| 476 | .style("stroke", function(d) {
|
---|
| 477 | // 繝�ヵ繧ゥ繝ォ繝医�濶イ繧偵そ繝�ヨ
|
---|
| 478 | var strokecolor = "#fafafa"
|
---|
| 479 | // 陦ィ遉コ繝輔Λ繧ー縺後が繝ウ繝槭え繧ケ荳ュ繝サ蝗コ螳壻クュ繝サ遘サ蜍穂クュ�磯∈謚槭&繧後※縺�k繝弱�繝会シ峨↑繧峨�
|
---|
| 480 | if(d.view == "now" || d.view == "clicked" || d.view == "moved"){
|
---|
| 481 | // 濶イ繧定オ、縺ォ
|
---|
| 482 | strokecolor = "#ffaaaa"
|
---|
| 483 | // 陦ィ遉コ繝輔Λ繧ー繧貞崋螳壻クュ縺ォ
|
---|
| 484 | d.view = "clicked";
|
---|
| 485 | }
|
---|
| 486 | // 縺薙%縺セ縺ァ縺ァ縺ァ縺阪◆濶イ繧定ソ斐☆
|
---|
| 487 | return strokecolor;
|
---|
| 488 | });
|
---|
| 489 |
|
---|
| 490 | // 縺薙%縺九i蟄舌ヮ繝シ繝峨�逡ウ縺ソ霎シ縺ソ蜃ヲ逅�シ育樟蝨ィ縺ッ蟒�ュ「縲∝ソオ縺ョ縺溘a繧ウ繝シ繝峨�谿九@縺ヲ縺翫¥�� |
---|
| 491 | /*
|
---|
| 492 | var childs = [];
|
---|
| 493 | var prevchilds = [];
|
---|
| 494 | prevchilds.push(d.nodeid);
|
---|
| 495 |
|
---|
| 496 | //
|
---|
| 497 | do{
|
---|
| 498 | var tmpchilds = [];
|
---|
| 499 | var curchilds = [];
|
---|
| 500 | for(var p = 0; p < prevchilds.length; p++){
|
---|
| 501 | tmpchilds = this.get_children(prevchilds[p], json['links']);
|
---|
| 502 | curchilds = curchilds.concat(tmpchilds);
|
---|
| 503 | }
|
---|
| 504 | prevchilds = curchilds;
|
---|
| 505 | childs = childs.concat(curchilds);
|
---|
| 506 |
|
---|
| 507 | }while(curchilds.length != 0);
|
---|
| 508 |
|
---|
| 509 | var childy = d.y;
|
---|
| 510 | for(var c = 0; c < childs.length; c++){
|
---|
| 511 | if(node.data()[childs[c]].y < childy){
|
---|
| 512 | childy = node.data()[childs[c]].y;
|
---|
| 513 | }
|
---|
| 514 | }
|
---|
| 515 |
|
---|
| 516 | d.y = childy;
|
---|
| 517 |
|
---|
| 518 | var maxdy = 0;
|
---|
| 519 | var mindy = 0;
|
---|
| 520 |
|
---|
| 521 | for(var c = 0; c < childs.length; c++){
|
---|
| 522 | if(node.data()[childs[c]].view != "hide"){
|
---|
| 523 | var dy = node.data()[childs[c]].y - d.y;
|
---|
| 524 | if(dy > maxdy){
|
---|
| 525 | maxdy = dy;
|
---|
| 526 | }
|
---|
| 527 | node.data()[childs[c]].x = d.x;
|
---|
| 528 | node.data()[childs[c]].y = d.y;
|
---|
| 529 | node.data()[childs[c]].dy = dy;
|
---|
| 530 | node.data()[childs[c]].view = "hide";
|
---|
| 531 | node.data()[childs[c]].hideparent = d.nodeid;
|
---|
| 532 | }else{
|
---|
| 533 | if(node.data()[childs[c]].hideparent == d.nodeid){
|
---|
| 534 | node.data()[childs[c]].x = d.x + (this.TREESPACE * (node.data()[childs[c]].group - d.group));
|
---|
| 535 | node.data()[childs[c]].y = node.data()[childs[c]].y + node.data()[childs[c]].dy;
|
---|
| 536 | if(-node.data()[childs[c]].dy < mindy){
|
---|
| 537 | mindy = -node.data()[childs[c]].dy;
|
---|
| 538 | }
|
---|
| 539 | node.data()[childs[c]].view = "appear";
|
---|
| 540 | node.data()[childs[c]].hideparent = -1;
|
---|
| 541 | }
|
---|
| 542 | }
|
---|
| 543 | }
|
---|
| 544 |
|
---|
| 545 | node
|
---|
| 546 | .attr("r", function(d){
|
---|
| 547 | if(d.view == "appear"){
|
---|
| 548 | d.view = "no";
|
---|
| 549 | }else if(d.y > childy){
|
---|
| 550 | d.y = d.y - maxdy - mindy;
|
---|
| 551 | }
|
---|
| 552 | if(d.view == "hide"){
|
---|
| 553 | d.x = node.data()[d.hideparent].x;
|
---|
| 554 | d.y = node.data()[d.hideparent].y;
|
---|
| 555 | }
|
---|
| 556 | if(d.nodeid == 0){
|
---|
| 557 | d.y = childy;
|
---|
| 558 | }
|
---|
| 559 | return (this.NODEHEIGHT / 2);
|
---|
| 560 | });
|
---|
| 561 | */
|
---|
| 562 |
|
---|
| 563 | // 蜷�Μ繝ウ繧ッ縺ォ蟇セ縺� |
---|
| 564 | tlink
|
---|
| 565 | // 繝�く繧ケ繝郁。ィ遉コ蛻、螳� |
---|
| 566 | .text(function(d) {
|
---|
| 567 | // 繝�ヵ繧ゥ繝ォ繝医〒遨コ縺ォ
|
---|
| 568 | var linktext = "";
|
---|
| 569 | // 陦ィ遉コ繝輔Λ繧ー縺檎樟蝨ィ陦ィ遉コ荳ュ縺セ縺溘�蝗コ螳壼喧貂医∩縺ェ繧峨��医°縺、謚倥j逡ウ縺ソ荳ュ縺ァ縺ェ縺代l縺ー�� |
---|
| 570 | if((d.view == "now" || d.view == "fix") && (node.data()[d.target].view != "hide")){
|
---|
| 571 | // 繝ェ繝ウ繧ッ繝�く繧ケ繝医↓繝励Ο繝代ユ繧」縺ョ蛟、繧偵そ繝�ヨ
|
---|
| 572 | linktext = d.property
|
---|
| 573 | // 陦ィ遉コ繝輔Λ繧ー繧貞崋螳壻クュ縺ォ
|
---|
| 574 | d.view = "fix";
|
---|
| 575 | }
|
---|
| 576 | // 繝�く繧ケ繝医r霑斐☆
|
---|
| 577 | return linktext;
|
---|
| 578 | });
|
---|
| 579 |
|
---|
| 580 | // 縺薙%縺セ縺ァ縺ョ蜃ヲ逅�オ先棡繧貞�縺ォ蜀肴緒逕サ
|
---|
| 581 | redraw();
|
---|
| 582 |
|
---|
| 583 | });
|
---|
| 584 |
|
---|
| 585 | // 蜀肴緒逕サ髢「謨ー
|
---|
| 586 | var redraw = function (duration){
|
---|
| 587 |
|
---|
| 588 | // 縺九¢繧区凾髢薙′譛ェ謖�ョ壹↑繧峨�
|
---|
| 589 | if(duration == undefined){
|
---|
| 590 | // 0.5遘偵°縺代※繧「繝九Γ繝シ繧キ繝ァ繝ウ
|
---|
| 591 | duration = 500;
|
---|
| 592 | }
|
---|
| 593 |
|
---|
| 594 | // 蜷�Μ繝ウ繧ッ縺ォ縺、縺�※險ュ螳壹&繧後◆菴咲スョ縺ォ蜀肴緒逕サ
|
---|
| 595 | link
|
---|
| 596 | .transition()
|
---|
| 597 | .duration(duration)
|
---|
| 598 | .attr("x1", function(d) {return node.data()[d.source].x;})
|
---|
| 599 | .attr("y1", function(d) {return node.data()[d.source].y;})
|
---|
| 600 | .attr("x2", function(d) {return node.data()[d.target].x;})
|
---|
| 601 | .attr("y2", function(d) {return node.data()[d.target].y;});
|
---|
| 602 |
|
---|
| 603 | // 蜷�Μ繝ウ繧ッ繝�く繧ケ繝医↓縺、縺�※險ュ螳壹&繧後◆菴咲スョ縺ォ蜀肴緒逕サ
|
---|
| 604 | tlink
|
---|
| 605 | .transition()
|
---|
| 606 | .duration(duration)
|
---|
| 607 | .attr("x", function(d) {return (node.data()[d.source].x + node.data()[d.target].x) / 2;})
|
---|
| 608 | .attr("y", function(d) {return ((node.data()[d.source].y + node.data()[d.target].y) / 2) + 5;});
|
---|
| 609 |
|
---|
| 610 | // 蜷�ヮ繝シ繝峨↓縺、縺�※險ュ螳壹&繧後◆菴咲スョ縺ォ蜀肴緒逕サ�医°縺、謚倥j縺溘◆縺セ繧御クュ縺ョ蝣エ蜷医�謠冗判蛻�イ仙�逅�シ� |
---|
| 611 | node
|
---|
| 612 | .transition()
|
---|
| 613 | .duration(duration)
|
---|
| 614 | .attr("cx", function(d) {return d.x;})
|
---|
| 615 | .attr("cy", function(d) {return d.y;})
|
---|
| 616 | .style("opacity", function(d){
|
---|
| 617 | var opa = 1.0;
|
---|
| 618 | if(d.view == "hide"){
|
---|
| 619 | opa = 0.0;
|
---|
| 620 | }
|
---|
| 621 | return opa;
|
---|
| 622 | })
|
---|
| 623 | .style("fill", function(d) {
|
---|
| 624 | var fcolor = d.nodecolor;
|
---|
| 625 |
|
---|
| 626 | for(var n = 0; n < node.data().length; n++){
|
---|
| 627 | if(d.nodeid == node.data()[n].hideparent){
|
---|
| 628 | fcolor = "ffaaaa";
|
---|
| 629 | }
|
---|
| 630 | }
|
---|
| 631 | return fcolor;
|
---|
| 632 | })
|
---|
| 633 | .style("pointer-events", function(d){
|
---|
| 634 | var pe = "auto";
|
---|
| 635 | if(d.view == "hide"){
|
---|
| 636 | pe = "none";
|
---|
| 637 | }
|
---|
| 638 | return pe;
|
---|
| 639 | });
|
---|
| 640 |
|
---|
| 641 | // 蜷�ヮ繝シ繝峨ユ繧ュ繧ケ繝医↓縺、縺�※險ュ螳壹&繧後◆菴咲スョ縺ォ蜀肴緒逕サ縲√ユ繧ュ繧ケ繝域緒逕サ菴咲スョ繧剃ク贋ク九↓謖ッ繧具シ医°縺、謚倥j縺溘◆縺セ繧御クュ縺ョ蝣エ蜷医�謠冗判蛻�イ仙�逅�シ� |
---|
| 642 | tnode
|
---|
| 643 | .transition()
|
---|
| 644 | .duration(duration)
|
---|
| 645 | .attr("x", function(d) {return d.x;})
|
---|
| 646 | .attr("y", function(d) {
|
---|
| 647 | // 繝�ヵ繧ゥ繝ォ繝医〒蟆代@荳九£繧� |
---|
| 648 | var updown = (self.NODEHEIGHT * 0.4);
|
---|
| 649 | // 螂�焚逡ェ逶ョ縺ョ豺ア縺輔↑繧牙ー代@荳翫£繧� |
---|
| 650 | if(d.group % 2 == 1){
|
---|
| 651 | updown = -(self.NODEHEIGHT * 0.2);
|
---|
| 652 | }
|
---|
| 653 | // 縺昴�蛟、繧帝ォ倥&縺ォ霑斐☆縺薙→縺ァ繝�く繧ケ繝域緒逕サ菴咲スョ縺御コ偵>驕輔>縺ォ縺ェ繧� |
---|
| 654 | return d.y + updown;
|
---|
| 655 | })
|
---|
| 656 | // 謚倥j逡ウ縺ソ迥カ諷九↑繧峨ユ繧ュ繧ケ繝郁。ィ遉コ繧呈カ医☆
|
---|
| 657 | .text(function(d){
|
---|
| 658 | var nodetext = d.name
|
---|
| 659 | if(d.view == "hide"){
|
---|
| 660 | nodetext = "";
|
---|
| 661 | }
|
---|
| 662 | return nodetext;
|
---|
| 663 | });
|
---|
| 664 |
|
---|
| 665 | };
|
---|
| 666 |
|
---|
| 667 | // 閭梧勹驛ィ蛻�′繧ッ繝ェ繝�け縺輔l縺溘i陦ィ遉コ縺ョ蝗コ螳壼喧繧定ァ」髯、
|
---|
| 668 | bg.on("click", function() {
|
---|
| 669 | // 繝��繝ォ繝√ャ繝励r髱櫁。ィ遉コ
|
---|
| 670 | document.getElementById("sparqlBuilderShowpath").style.display = "none";
|
---|
| 671 | d3.selectAll(".node").style("stroke-width", function(d) { return '1.5px'; });
|
---|
| 672 | d3.selectAll(".node").style("stroke", function(d) { return '#ffffff'; });
|
---|
| 673 |
|
---|
| 674 | // 蜷�ヮ繝シ繝峨�霈ェ驛ュ邱壹�濶イ繧偵ョ繝輔か繝ォ繝医↓
|
---|
| 675 | node
|
---|
| 676 | .style("stroke", function(d){
|
---|
| 677 | if(d.view != "hide"){
|
---|
| 678 | d.view = "no";
|
---|
| 679 | }
|
---|
| 680 | return "#fafafa";
|
---|
| 681 | });
|
---|
| 682 |
|
---|
| 683 | // 繝ェ繝ウ繧ッ繝�く繧ケ繝医r蜈ィ縺ヲ遨コ縺ォ
|
---|
| 684 | tlink
|
---|
| 685 | .text(function(d) {
|
---|
| 686 | d.view = "no";
|
---|
| 687 | return "";
|
---|
| 688 | });
|
---|
| 689 |
|
---|
| 690 | // 繝ェ繝ウ繧ッ縺ョ濶イ繧貞�縺ヲ繝�ヵ繧ゥ繝ォ繝医↓
|
---|
| 691 | link
|
---|
| 692 | .style("stroke", function(d){
|
---|
| 693 | return "#999";
|
---|
| 694 | });
|
---|
| 695 |
|
---|
| 696 | });
|
---|
| 697 |
|
---|
| 698 | // 閭梧勹荳翫〒繝槭え繧ケ縺悟虚縺上#縺ィ縺ォ
|
---|
| 699 | bg.on("mousemove", function(){
|
---|
| 700 | // MOUSEMOVED繧定ソス蜉�医ヮ繝シ繝峨↓繧ェ繝ウ繝槭え繧ケ縺輔l繧句コヲ縺ォ繧ォ繧ヲ繝ウ繝医Μ繧サ繝�ヨ�� |
---|
| 701 | this.MOUSEMOVED++;
|
---|
| 702 | // 30繧定カ�∴縺溘i
|
---|
| 703 | if(this.MOUSEMOVED > 30){
|
---|
| 704 | // 繝��繝ォ繝√ャ繝励r髱櫁。ィ遉コ縺ォ縺励※繧ォ繧ヲ繝ウ繝医Μ繧サ繝�ヨ
|
---|
| 705 | document.getElementById("sparqlBuilderShowpath").style.display = "none";
|
---|
| 706 | this.MOUSEMOVED = 0;
|
---|
| 707 | }
|
---|
| 708 | });
|
---|
| 709 |
|
---|
| 710 | // 蛻晏屓縺ョ縺ソduration繧�縺ィ謖�ョ壹@蜀肴緒逕サ�医い繝九Γ繝シ繧キ繝ァ繝ウ縺ェ縺暦シ� |
---|
| 711 | redraw(0);
|
---|
| 712 | }
|
---|
[219] | 713 | };
|
---|
[209] | 714 |
|
---|
| 715 | // 繝��繧ソ縺ョ菴懈�繝。繧ス繝�ラ
|
---|
| 716 | SPARQLBuilderDrawGraph.prototype.make_data = function(tdepth, ret, parent, depth){
|
---|
| 717 | // ret縺梧悴螳夂セゥ縺ェ繧峨�螳夂セゥ縺励※莉」蜈・
|
---|
| 718 | if (ret == undefined){
|
---|
| 719 | ret = new Object();
|
---|
| 720 | ret['nodes'] = new Array();
|
---|
| 721 | ret['links'] = new Array();
|
---|
| 722 | }
|
---|
| 723 |
|
---|
| 724 | this.PATHNUM = 0;
|
---|
| 725 | this.MAXDEPTH = 0;
|
---|
| 726 | this.TREESPACE = 0;
|
---|
| 727 | this.DRAWHEIGHT = this.NODEHEIGHT;
|
---|
| 728 |
|
---|
| 729 | var viewnum;
|
---|
| 730 |
|
---|
| 731 | var obj = this.jsontext;
|
---|
| 732 |
|
---|
| 733 | document.getElementById("sparqlBuilderResultmessage").style.color = "black";
|
---|
| 734 | document.getElementById("sparqlBuilderResultmessage").style.fontWeight = "normal";
|
---|
| 735 |
|
---|
| 736 | document.getElementById("sparqlBuilderPlural").innerHTML = "s";
|
---|
| 737 |
|
---|
[213] | 738 | if(obj.length == 0){
|
---|
[209] | 739 | document.getElementById("sparqlBuilderResultmessage").style.color = "red";
|
---|
| 740 | document.getElementById("sparqlBuilderResultmessage").style.fontWeight = "bold";
|
---|
| 741 | document.getElementById("sparqlBuilderPlural").innerHTML = "";
|
---|
[213] | 742 | }else if(obj.length == 1){
|
---|
[209] | 743 | document.getElementById("sparqlBuilderPlural").innerHTML = "";
|
---|
| 744 | }
|
---|
| 745 |
|
---|
[213] | 746 | if(obj.length <= 10){
|
---|
| 747 | viewnum = obj.length;
|
---|
[209] | 748 | document.getElementById("sparqlBuilderViewall").style.display = "none";
|
---|
| 749 | }else if(this.pathlimit == 10){
|
---|
| 750 | viewnum = 10;
|
---|
| 751 | document.getElementById("sparqlBuilderViewall").style.display = "block";
|
---|
| 752 | }else{
|
---|
[213] | 753 | viewnum = obj.length;
|
---|
[209] | 754 | document.getElementById("sparqlBuilderViewall").style.display = "none";
|
---|
| 755 | }
|
---|
| 756 |
|
---|
[213] | 757 | document.getElementById("sparqlBuilderPathnum").innerHTML = obj.length;
|
---|
[209] | 758 | document.getElementById("sparqlBuilderResultmessage").style.display = "block";
|
---|
| 759 |
|
---|
| 760 | // obj繝医ャ繝鈴嚴螻、縺ョ謨ー縺縺醍ケー繧願ソ斐@縺ェ縺後i
|
---|
| 761 | for(var i = 0; i < viewnum; i++){
|
---|
| 762 | if(i == 0){
|
---|
| 763 | // 蛻晏屓縺縺代Ν繝シ繝医ヮ繝シ繝峨r繝励ャ繧キ繝・
|
---|
[213] | 764 | ret['nodes'].push({'name': obj[0]['label'], 'uri': obj[0]['startClass'], 'group': 0, 'x':50, 'y':50, 'nodeid':ret['nodes'].length, 'view' : 'no', 'path': 'notend', 'nodecolor': '#d0a36a'});
|
---|
[209] | 765 | }
|
---|
| 766 | // 蜈医↓source縺ォ0�医Ν繝シ繝茨シ峨r莉」蜈・
|
---|
| 767 | var source = 0;
|
---|
| 768 | // 蜈ア騾壹Ν繝シ繝亥愛螳壹rtrue縺ォ
|
---|
| 769 | var isCommon = true;
|
---|
| 770 |
|
---|
| 771 | // classLinks縺ョ謨ー縺縺醍ケー繧願ソ斐@縺ェ縺後i
|
---|
[213] | 772 | for(var j = 0;j < obj[i]['classLinks'].length; j++){
|
---|
[209] | 773 |
|
---|
| 774 | // 繝ェ繝ウ繧ッ縺ョ蜷榊燕繧旦RL譛ォ蟆セ縺九i蜿門セ� |
---|
[213] | 775 | var propertytext = obj[i]['classLinks'][j]['predicate'];
|
---|
[209] | 776 | var propertysplit1 = propertytext.split("/");
|
---|
| 777 | var propertysplit2 = propertysplit1[propertysplit1.length - 1];
|
---|
| 778 | var propertysplit3 = propertysplit2.split("#");
|
---|
| 779 | propertytext = propertysplit3[propertysplit3.length - 1];
|
---|
| 780 |
|
---|
| 781 | if(this.MAXDEPTH < j+1){
|
---|
| 782 | this.MAXDEPTH = j+1;
|
---|
| 783 | }
|
---|
| 784 | // 縺薙%縺セ縺ァ蜈ア騾壹Ν繝シ繝医↑繧� |
---|
| 785 | if(isCommon){
|
---|
| 786 | // 莉雁屓繧ょ�騾壹°遒コ隱阪☆繧九◆繧√�繝輔Λ繧ー
|
---|
| 787 | var isCommonNow = false;
|
---|
| 788 | // nodes驟榊�縺ォ蜷後§linkedClass縺梧里縺ォ縺ゅk縺狗「コ隱� |
---|
| 789 | var targets = [];
|
---|
| 790 | for(var k = 0; k < ret['nodes'].length; k++){
|
---|
| 791 | // 蜷碁嚴螻、縺九▽蜷後§蜷榊燕縺ョ繧ゅ�縺後≠縺」縺溘itargets驟榊�縺ォ逡ェ蜿キ繧定ソス蜉
|
---|
[213] | 792 | if(ret['nodes'][k]['group'] == (j+1) && obj[i]['classLinks'][j]['linkedClass'] == ret['nodes'][k]['uri']){
|
---|
[209] | 793 | targets.push(k);
|
---|
| 794 | }
|
---|
| 795 | }
|
---|
| 796 |
|
---|
| 797 | // 譌「縺ォ縺ゅ▲縺溷エ蜷医�links驟榊�縺ォ蜷後§link縺悟ュ伜惠縺吶k縺狗「コ隱� |
---|
| 798 | if(targets.length != 0){
|
---|
| 799 | // 蜈医⊇縺ゥ隕九▽縺代◆targets縺ョ謨ー縺縺醍ケー繧願ソ斐@縺ェ縺後i
|
---|
| 800 | for(var l = 0; l <targets.length; l++){
|
---|
| 801 | // links驟榊�縺ォ蜈ィ縺丞酔縺俶擅莉カ縺ョ繧ゅ�縺後≠繧九°遒コ隱� |
---|
| 802 | for(var m = 0; m < ret['links'].length; m++){
|
---|
| 803 | // 縺ゅ▲縺溷エ蜷井サ雁屓縺ョ繧ゅ�縺ッ霑ス蜉縺帙★source繧呈峩譁ー縺励※谺。縺ク
|
---|
[213] | 804 | if(ret['links'][m]['source'] == source && ret['links'][m]['target'] == targets[l] && ret['links'][m]['uri'] == obj[i]['classLinks'][j]['propertyURI'] && !isCommonNow){
|
---|
[209] | 805 | // 蜈ア騾壹Ν繝シ繝医ヵ繝ゥ繧ー繧偵が繝ウ
|
---|
| 806 | isCommonNow = true;
|
---|
| 807 | source = targets[l];
|
---|
| 808 | }
|
---|
| 809 | }
|
---|
| 810 | }
|
---|
| 811 |
|
---|
| 812 | // 蜷дarget繧堤「コ隱阪@縺ヲ蜈ア騾壹Ν繝シ繝医〒縺ッ縺ェ縺九▲縺溷エ蜷域眠隕剰ソス蜉
|
---|
| 813 | if(!isCommonNow){
|
---|
| 814 | isCommon = false;
|
---|
[213] | 815 | ret['nodes'].push({'name': obj[i]['classLinks'][j]['label'], 'uri': obj[i]['classLinks'][j]['linkedClass'], 'group': (j+1), 'x':0, 'y':0, 'dy':0, 'nodeid':ret['nodes'].length, 'view' : 'no', 'path': 'notend', 'nodecolor': '#cccccc'});
|
---|
| 816 | ret['links'].push({'source':source, 'target':ret['nodes'].length - 1, 'value':5, 'property': propertytext, 'uri': obj[i]['classLinks'][j]['predicate'], 'view' : 'no'});
|
---|
[209] | 817 | source = ret['nodes'].length - 1;
|
---|
| 818 | }
|
---|
| 819 |
|
---|
| 820 | // 縺ェ縺九▲縺溷エ蜷医�蛻・譚。莉カ縺ェ縺ョ縺ァ譁ー隕剰ソス蜉縺励※谺。縺ク
|
---|
| 821 | }else{
|
---|
| 822 |
|
---|
| 823 | isCommon = false;
|
---|
[213] | 824 | ret['nodes'].push({'name': obj[i]['classLinks'][j]['label'], 'uri': obj[i]['classLinks'][j]['linkedClass'], 'group': (j+1), 'x':0, 'y':0, 'dy':0, 'nodeid':ret['nodes'].length, 'view' : 'no', 'path': 'notend', 'nodecolor': '#cccccc'});
|
---|
| 825 | ret['links'].push({'source':source, 'target':ret['nodes'].length - 1, 'value':5, 'property': propertytext, 'uri': obj[i]['classLinks'][j]['predicate'], 'view' : 'no'});
|
---|
[209] | 826 | source = ret['nodes'].length - 1;
|
---|
| 827 | }
|
---|
| 828 | // 譌「縺ォ蜈ア騾壹Ν繝シ繝医〒縺ェ縺�↑繧画眠隕剰ソス蜉縺励※谺。縺ク
|
---|
| 829 | }else{
|
---|
[213] | 830 | ret['nodes'].push({'name': obj[i]['classLinks'][j]['label'], 'uri': obj[i]['classLinks'][j]['linkedClass'], 'group': (j+1), 'x':0, 'y':0, 'dy':0, 'nodeid':ret['nodes'].length, 'view' : 'no', 'path': 'notend', 'nodecolor': '#cccccc'});
|
---|
| 831 | ret['links'].push({'source':source, 'target':ret['nodes'].length - 1, 'value':5, 'property': propertytext, 'uri': obj[i]['classLinks'][j]['predicate'], 'view' : 'no'});
|
---|
[209] | 832 | source = ret['nodes'].length - 1;
|
---|
| 833 | }
|
---|
| 834 |
|
---|
| 835 | }
|
---|
[213] | 836 | ret['nodes'][ret['nodes'].length - 1]['path'] = obj[i];
|
---|
[209] | 837 | ret['nodes'][ret['nodes'].length - 1]['nodecolor'] = '#8cddc0';
|
---|
| 838 | this.PATHNUM++;
|
---|
| 839 | }
|
---|
| 840 | this.TREESPACE = (window.innerWidth - 200) / (this.MAXDEPTH + 1);
|
---|
| 841 |
|
---|
| 842 | // 縺ァ縺阪◆邨先棡繧定ソ斐☆
|
---|
| 843 | return ret;
|
---|
[219] | 844 | };
|
---|
[209] | 845 |
|
---|
| 846 | // 逕滓�縺輔l縺溘ョ繝シ繧ソ縺ョ螳滄圀縺ョ繝ュ繧ア繝シ繧キ繝ァ繝ウ繧定ィ育ョ励☆繧九Γ繧ス繝�ラ�亥�蝗槭�myNodeIndex縺�縲]odes縺ォ逕滓�縺輔l縺殤odes驟榊�縲〕inks縺ォ逕滓�縺輔l縺殕inks驟榊�縺梧ク。縺輔l繧具シ� |
---|
| 847 | SPARQLBuilderDrawGraph.prototype.set_map_location = function(myNodeIndex, nodes, links, depth, fromAngle, toAngle){
|
---|
| 848 |
|
---|
| 849 | // depth縺梧悴螳夂セゥ縺ェ繧峨�0繧偵そ繝�ヨ
|
---|
| 850 | if (depth == undefined){
|
---|
| 851 | depth = 0;
|
---|
| 852 | }
|
---|
| 853 |
|
---|
| 854 | // 蜷�ィョ蛻晄悄蛹� |
---|
| 855 | var children = undefined;
|
---|
| 856 | var parent = undefined;
|
---|
| 857 | var parentsChildren = undefined;
|
---|
| 858 |
|
---|
| 859 | // links驟榊�縺ョ謨ー縺縺醍ケー繧願ソ斐@縺ェ縺後i
|
---|
| 860 | for (var i=0; i<links.length; i++){
|
---|
| 861 | // 縺昴�links縺ョtarget縺稽yNodeIndex縺ェ繧英arent繧偵そ繝�ヨ
|
---|
| 862 | if (links[i].target == myNodeIndex){
|
---|
| 863 | parent = links[i].source;
|
---|
| 864 | }
|
---|
| 865 | }
|
---|
| 866 |
|
---|
| 867 | // parent縺瑚ヲ九▽縺九▲縺ヲ縺�◆縺ェ繧峨�
|
---|
| 868 | if (parent != undefined){
|
---|
| 869 | // parent縺ィlinks繧呈ク。縺揚et_children繝。繧ス繝�ラ繧貞ョ溯。� |
---|
| 870 | parentsChildren = this.get_children(parent, links);
|
---|
| 871 | }
|
---|
| 872 |
|
---|
| 873 | if(myNodeIndex != 0){
|
---|
| 874 | this.DRAWHEIGHT += (this.NODEHEIGHT * 1.5);
|
---|
| 875 | var x = (depth * this.TREESPACE) + (this.TREESPACE / 3);
|
---|
| 876 | var y = this.DRAWHEIGHT;
|
---|
| 877 | nodes[myNodeIndex].x = x;
|
---|
| 878 | nodes[myNodeIndex].y = y;
|
---|
| 879 | }else{
|
---|
| 880 | var x = this.TREESPACE / 2;
|
---|
| 881 | var y = (this.NODEHEIGHT * 1.5) * ((this.PATHNUM - 1) / 2) + this.NODEHEIGHT;
|
---|
| 882 | nodes[myNodeIndex].x = x;
|
---|
| 883 | nodes[myNodeIndex].y = y;
|
---|
| 884 | }
|
---|
| 885 |
|
---|
| 886 | children = this.get_children(myNodeIndex, links);
|
---|
| 887 |
|
---|
| 888 | for (var i=0; i<children.length; i++){
|
---|
| 889 | if(i == 0){
|
---|
| 890 | this.DRAWHEIGHT -= (this.NODEHEIGHT * 1.5);
|
---|
| 891 | }
|
---|
| 892 | var child = children[i];
|
---|
| 893 | this.set_map_location(child, nodes, links, depth+1, fromAngle + ((toAngle - fromAngle) / children.length) * i, fromAngle + ((toAngle - fromAngle) / children.length) * (i+1));
|
---|
| 894 | }
|
---|
| 895 |
|
---|
[219] | 896 | };
|
---|
[209] | 897 |
|
---|
| 898 | // 謖�ョ壹&繧後◆隕ェ縺梧戟縺、蟄舌r霑斐☆
|
---|
| 899 | SPARQLBuilderDrawGraph.prototype.get_children = function(index, links){
|
---|
| 900 | var children = new Array();
|
---|
| 901 | // links縺ョ謨ー縺縺醍「コ隱阪@縺ェ縺後i
|
---|
| 902 | for (var i=0; i<links.length; i++){
|
---|
| 903 | // 隕ェ縺梧ク。縺輔l縺溯ヲェ縺ィ荳閾エ縺吶k譎ゅ�蟄舌r霑ス蜉
|
---|
| 904 | if (links[i].source == index){
|
---|
| 905 | children.push(links[i].target);
|
---|
| 906 | }
|
---|
| 907 | }
|
---|
| 908 | return children;
|
---|
[219] | 909 | };
|
---|