チェンジセット 129 : SPARQLBuilderWWW
- 更新日時:
- 2014/08/11 10:48:16 (10 年 前)
- ファイル:
-
- 1 変更
凡例:
- 変更なし
- 追加
- 削除
-
SPARQLBuilderWWW/web/jsgui.html
r124 r129 127 127 DURATION = 0; 128 128 129 /* 129 130 // 繝峨Λ繝�げ譎ゅ�蜃ヲ逅� 130 131 var drag = d3.behavior.drag().on("drag", function(d,i) { … … 136 137 redraw(); 137 138 }); 139 */ 138 140 139 141 // SVG縺ョ霑ス蜉 … … 156 158 .enter().append("line") 157 159 .attr("class", "link") 158 .style("stroke-width", function(d) { return Math.sqrt(d.value); 160 .style("stroke-width", function(d) { return Math.sqrt(d.value);}); 159 161 160 162 // 繝弱�繝峨�菴懈� … … 169 171 .style("stroke-width", function(d) { return '1.5px'; }) 170 172 .style("fill", function(d) { return color(d.group); }) 171 .style("cursor", function(d) { return 'pointer'; }) 172 .call(drag);173 .style("cursor", function(d) { return 'pointer'; }); 174 //.call(drag); 173 175 174 176 // 繝弱�繝峨ユ繧ュ繧ケ繝医�菴懈� … … 184 186 .style("stroke-width", function(d) { return '1.5px'; }) 185 187 .style("text-anchor", function(d) { return 'middle'; }) 186 .style("pointer-events", "none") 187 .call(drag);188 .style("pointer-events", "none"); 189 //.call(drag); 188 190 189 191 // 繝ェ繝ウ繧ッ繝�く繧ケ繝医�菴懈� … … 229 231 230 232 document.getElementById("selectpath").innerHTML=(resultText); 231 document.getElementById("showpath").style.display = "block";232 233 233 234 if(d.group > (MAXDEPTH - 2)){ … … 249 250 document.getElementById("showpath").style.left = xPosition + "px" 250 251 document.getElementById("showpath").style.top = yPosition + "px" 251 document.getElementById("showpath").style.display = "block";252 //document.getElementById("showpath").style.display = "block"; 252 253 253 254 }else{ … … 304 305 if(d.view == "no"){ 305 306 for(var t = 0; t < path.length; t++){ 306 if(path[t] == d.target){ 307 linktext = d.property; 307 if(path[t] == d.target && node.data()[d.target].view != "hide"){ 308 var propertytext = d.property 309 var linksplit1 = propertytext.split("/"); 310 var linksplit2 = linksplit1[linksplit1.length - 1]; 311 var linksplit3 = linksplit2.split("#"); 312 linktext = linksplit3[linksplit3.length - 1]; 308 313 d.view = "now"; 309 314 } 310 315 } 311 }else if(d.view == "fix"){ 312 linktext = d.property; 316 }else if(d.view == "fix" && node.data()[d.target].view != "hide"){ 317 var propertytext = d.property 318 var linksplit1 = propertytext.split("/"); 319 var linksplit2 = linksplit1[linksplit1.length - 1]; 320 var linksplit3 = linksplit2.split("#"); 321 linktext = linksplit3[linksplit3.length - 1]; 313 322 } 314 323 return linktext; … … 339 348 }); 340 349 350 //d.hideparent = d.nodeid; 351 352 var childs = []; 353 var prevchilds = []; 354 prevchilds.push(d.nodeid); 355 356 do{ 357 var tmpchilds = []; 358 var curchilds = []; 359 for(var p = 0; p < prevchilds.length; p++){ 360 tmpchilds = get_children(prevchilds[p], json['links']); 361 curchilds = curchilds.concat(tmpchilds); 362 } 363 prevchilds = curchilds; 364 childs = childs.concat(curchilds); 365 366 }while(curchilds.length != 0); 367 368 var childy = d.y; 369 for(var c = 0; c < childs.length; c++){ 370 if(node.data()[childs[c]].y < childy){ 371 childy = node.data()[childs[c]].y; 372 } 373 } 374 375 d.y = childy; 376 377 var maxdy = 0; 378 var mindy = 0; 379 380 for(var c = 0; c < childs.length; c++){ 381 if(node.data()[childs[c]].view != "hide"){ 382 var dy = node.data()[childs[c]].y - d.y; 383 if(dy > maxdy){ 384 maxdy = dy; 385 } 386 node.data()[childs[c]].x = d.x; 387 node.data()[childs[c]].y = d.y; 388 node.data()[childs[c]].dy = dy; 389 node.data()[childs[c]].view = "hide"; 390 node.data()[childs[c]].hideparent = d.nodeid; 391 }else{ 392 if(node.data()[childs[c]].hideparent == d.nodeid){ 393 node.data()[childs[c]].x = d.x + (TREESPACE * (node.data()[childs[c]].group - d.group)); 394 node.data()[childs[c]].y = node.data()[childs[c]].y + node.data()[childs[c]].dy; 395 if(-node.data()[childs[c]].dy < mindy){ 396 mindy = -node.data()[childs[c]].dy; 397 } 398 node.data()[childs[c]].view = "appear"; 399 node.data()[childs[c]].hideparent = -1; 400 } 401 } 402 } 403 404 node 405 .attr("r", function(d){ 406 if(d.view == "appear"){ 407 d.view = "no"; 408 }else if(d.y > childy){ 409 d.y = d.y - maxdy - mindy; 410 } 411 if(d.view == "hide"){ 412 d.x = node.data()[d.hideparent].x; 413 d.y = node.data()[d.hideparent].y; 414 } 415 if(d.nodeid == 0){ 416 d.y = childy; 417 } 418 return (NODEHEIGHT / 2); 419 }); 420 341 421 tlink 342 422 .text(function(d) { 343 423 var linktext = ""; 344 if(d.view == "now" || d.view == "fix"){ 345 linktext = d.property; 424 if((d.view == "now" || d.view == "fix") && (node.data()[d.target].view != "hide")){ 425 var propertytext = d.property 426 var linksplit1 = propertytext.split("/"); 427 var linksplit2 = linksplit1[linksplit1.length - 1]; 428 var linksplit3 = linksplit2.split("#"); 429 linktext = linksplit3[linksplit3.length - 1]; 346 430 d.view = "fix"; 347 431 } 348 432 return linktext; 349 433 }); 434 435 436 redraw(); 350 437 351 438 }).on("mouseout", function(d){ 352 439 d.isDrag = false; 353 440 }); 354 355 // 蝓コ譛ャ繝吶け繝医Ν邂怜�356 var vec = function(sx, sy, dx, dy){357 var vx = (dx - sx);358 var vy = (dy - sy);359 var dist = Math.sqrt(Math.pow(vx, 2) + Math.pow(vy, 2));360 var ret = [];361 ret.x = vx / dist;362 ret.y = vy / dist;363 364 return ret;365 };366 441 367 442 var redraw = function (){ … … 384 459 .duration(DURATION) 385 460 .attr("cx", function(d) {return d.x;}) 386 .attr("cy", function(d) {return d.y;}); 461 .attr("cy", function(d) {return d.y;}) 462 .style("opacity", function(d){ 463 var opa = 1.0; 464 if(d.view == "hide"){ 465 opa = 0.0; 466 } 467 return opa; 468 }) 469 .style("fill", function(d) { 470 var fcolor = color(d.group); 471 472 for(var n = 0; n < node.data().length; n++){ 473 if(d.nodeid == node.data()[n].hideparent){ 474 fcolor = "ffaaaa"; 475 } 476 } 477 return fcolor; 478 }) 479 .style("pointer-events", function(d){ 480 var pe = "auto"; 481 if(d.view == "hide"){ 482 pe = "none"; 483 } 484 return pe; 485 }); 387 486 388 487 tnode … … 395 494 updown = -(NODEHEIGHT * 0.2); 396 495 } 496 if(d.view == "now" || d.view == "moved"){ 497 //updown = 5; 498 } 397 499 return d.y + updown; 500 }) 501 .text(function(d){ 502 var nt = d.name; 503 if(d.view == "hide"){ 504 nt = ""; 505 } 506 return nt; 398 507 }); 399 508 400 509 DURATION = 500; 510 401 511 }; 402 512 … … 408 518 node 409 519 .style("stroke", function(d){ 410 d.view = "no"; 520 if(d.view != "hide"){ 521 d.view = "no"; 522 } 411 523 return "#fafafa"; 412 524 }); … … 499 611 if(!isCommonNow){ 500 612 isCommon = false; 501 ret['nodes'].push({'name':obj['paths'][i]['classLinks'][j]['linkedClassURI'], 'group': (j+1), 'x':0, 'y':0, ' nodeid':ret['nodes'].length, 'view' : 'no'});613 ret['nodes'].push({'name':obj['paths'][i]['classLinks'][j]['linkedClassURI'], 'group': (j+1), 'x':0, 'y':0, 'dy':0, 'nodeid':ret['nodes'].length, 'view' : 'no'}); 502 614 ret['links'].push({'source':source, 'target':ret['nodes'].length - 1, 'value':5, 'property':obj['paths'][i]['classLinks'][j]['propertyURI'], 'view' : 'no'}); 503 615 source = ret['nodes'].length - 1; … … 508 620 509 621 isCommon = false; 510 ret['nodes'].push({'name':obj['paths'][i]['classLinks'][j]['linkedClassURI'], 'group': (j+1), 'x':0, 'y':0, ' nodeid':ret['nodes'].length, 'view' : 'no'});622 ret['nodes'].push({'name':obj['paths'][i]['classLinks'][j]['linkedClassURI'], 'group': (j+1), 'x':0, 'y':0, 'dy':0, 'nodeid':ret['nodes'].length, 'view' : 'no'}); 511 623 ret['links'].push({'source':source, 'target':ret['nodes'].length - 1, 'value':5, 'property':obj['paths'][i]['classLinks'][j]['propertyURI'], 'view' : 'no'}); 512 624 source = ret['nodes'].length - 1; … … 514 626 // 譌「縺ォ蜈ア騾壹Ν繝シ繝医〒縺ェ縺�↑繧画眠隕剰ソス蜉縺励※谺。縺ク 515 627 }else{ 516 ret['nodes'].push({'name':obj['paths'][i]['classLinks'][j]['linkedClassURI'], 'group': (j+1), 'x':0, 'y':0, ' nodeid':ret['nodes'].length, 'view' : 'no'});628 ret['nodes'].push({'name':obj['paths'][i]['classLinks'][j]['linkedClassURI'], 'group': (j+1), 'x':0, 'y':0, 'dy':0, 'nodeid':ret['nodes'].length, 'view' : 'no'}); 517 629 ret['links'].push({'source':source, 'target':ret['nodes'].length - 1, 'value':5, 'property':obj['paths'][i]['classLinks'][j]['propertyURI'], 'view' : 'no'}); 518 630 source = ret['nodes'].length - 1; … … 660 772 function setSEClass(){ 661 773 662 MAXDEPTH = 0;663 664 774 var sel = $("*[name=selectendpoint]").val(); 665 775 … … 667 777 sel = $("*[name=inputendpoint]").val(); 668 778 } 779 780 MAXDEPTH = 0; 669 781 670 782 document.getElementById("selectpath").innerHTML = ""; … … 678 790 url : getPathListURL, 679 791 data: { 792 ep: sel, 680 793 startclass: selstart, 681 endclass: selend, 682 ep: sel 794 endclass: selend 683 795 }, 684 796 dataType: 'text',