389 | | // make_data繝。繧ス繝�ラ縺ョ邨先棡繧貞叙蠕� |
390 | | var json = make_data(0); |
391 | | |
392 | | if(json['nodes'].length != 0){ |
393 | | |
394 | | // 蜃コ譚・荳翫′縺」縺溽オ先棡繧呈ク。縺励※繝槭ャ繝嶺ク翫�繝ュ繧ア繝シ繧キ繝ァ繝ウ繧偵そ繝�ヨ |
395 | | set_map_location(0, json['nodes'], json['links']); |
396 | | |
397 | | // SVG縺ョ蟷�→鬮倥&繧定ィュ螳夲シ亥ケ�シ夂判髱「縺�▲縺ア縺�鬮倥&�壹ヱ繧ケ縺ョ謨ー縺ォ蠢懊§險ュ螳夲シ� |
398 | | var width = $('.SBGraph').width(); |
399 | | var height = $('.SBGraph').height(); |
400 | | var graphheight = ((NODEHEIGHT * 1.5) * PATHNUM) + (NODEHEIGHT / 2); |
401 | | |
402 | | var scoreleftmargin = NODEHEIGHT * 1.5; |
403 | | |
404 | | // SVG縺ョ蜑企勁 |
405 | | d3.select(".SBGraph svg").remove(); |
406 | | // 逕サ髱「繧オ繧、繧コ縺ォ蜷医o縺婀VG縺ョ霑ス蜉 |
407 | | var svg = d3.select(".SBGraph").append("svg") |
408 | | .attr("width", width) |
409 | | .attr("height", height) |
410 | | .attr("viewBox", "0 0 " + width + " " + height) |
411 | | .on("mousewheel", function(){ |
412 | | var vb = svg.attr("viewBox"); |
413 | | var spvb = vb.split(" "); |
414 | | |
415 | | var vby = (parseInt(spvb[1]) - event.wheelDelta); |
416 | | |
417 | | if(vby < 0){ |
418 | | vby = 0; |
419 | | }else if(vby > (graphheight - height)){ |
420 | | vby = (graphheight - height); |
421 | | if(vby < 0){ |
422 | | vby = 0; |
423 | | } |
424 | | }else{ |
425 | | event.preventDefault(); |
426 | | } |
427 | | |
428 | | svg.attr("viewBox", "0 " + vby + " " + width + " " + height); |
429 | | }); |
430 | | |
431 | | // 閭梧勹縺ョ霑ス蜉 |
432 | | var bg = svg |
433 | | .append("rect") |
434 | | .attr("x", 0) |
435 | | .attr("y", 0) |
436 | | .attr("width", width) |
437 | | .attr("height", function(){ |
438 | | if(graphheight < height){ |
439 | | return height; |
440 | | }else{ |
441 | | return graphheight; |
442 | | } |
443 | | }) |
444 | | .attr("fill", "#fafafa"); |
445 | | |
446 | | // links驟榊�繧呈ク。縺励Μ繝ウ繧ッ縺ョ菴懈� |
447 | | var link = svg.selectAll(".link") |
448 | | .data(json.links) |
449 | | .enter().append("line") |
450 | | .attr("class", "link") |
451 | | .style("stroke", "#999") |
452 | | .style("stroke-opacity", 0.6) |
453 | | .style("stroke-width", function(d) { return Math.sqrt(d.value);}); |
454 | | |
455 | | // nodes驟榊�繧呈ク。縺励ヮ繝シ繝峨�菴懈� |
456 | | var node = svg.selectAll(".node") |
457 | | .data(json.nodes) |
458 | | .enter().append("circle") |
459 | | .attr("class", "node") |
460 | | .attr("r", (NODEHEIGHT / 2)) |
461 | | .attr("cx", function(d) { return d.x;} ) |
462 | | .attr("cy", function(d) { return d.y; }) |
463 | | .style("stroke", function(d) { return '#fafafa'; }) |
464 | | .style("stroke-width", function(d) { return '1.5px'; }) |
465 | | .style("fill", function(d) { return d.nodecolor; }) |
466 | | .style("cursor", function(d) { return 'pointer'; }); |
467 | | |
468 | | // nodes驟榊�繧呈ク。縺励ヮ繝シ繝峨ユ繧ュ繧ケ繝医�菴懈� |
469 | | var tnode = svg.selectAll("text.node") |
470 | | .data(json.nodes) |
471 | | .enter().append("svg:text") |
472 | | .attr("class", "tnode") |
473 | | .attr("x", function(d) { return d.x; }) |
474 | | .attr("y", function(d) { return d.y; }) |
475 | | .text(function(d) { return d.name; }) |
476 | | .style("fill", function(d) { return '#000000'; }) |
477 | | .style("text-anchor", function(d) { return 'middle'; }) |
478 | | .style("pointer-events", "none"); |
479 | | |
480 | | // 繝ェ繝ウ繧ッ繝�く繧ケ繝医�菴懈� |
481 | | var tlink = svg.selectAll("text.link") |
482 | | .data(json.links) |
483 | | .enter().append("svg:text") |
484 | | .attr("class", "tlink") |
485 | | .attr("x", function(d) { return (json.nodes[d.source].x + json.nodes[d.target].x) / 2; }) |
486 | | .attr("y", function(d) { return (json.nodes[d.source].y + json.nodes[d.target].y) / 2; }) |
487 | | .style("fill", function(d) { return '#000000'; }) |
488 | | .style("text-anchor", function(d) { return 'middle'; }); |
489 | | |
490 | | // nodes驟榊�繧呈ク。縺励ヮ繝シ繝峨ユ繧ュ繧ケ繝医�菴懈� |
491 | | var tscore = svg.selectAll("text.score") |
492 | | .data(json.nodes) |
493 | | .enter().append("svg:text") |
494 | | .attr("class", "tscore") |
495 | | .attr("x", function(d) { return (d.x + scoreleftmargin); }) |
496 | | .attr("y", function(d) { return d.y; }) |
497 | | .text(function(d) { return d.score; |
498 | | }) |
499 | | .style("fill", function(d) { return '#FF0000'; }) |
500 | | .style("text-anchor", function(d) { return 'middle'; }) |
501 | | .style("pointer-events", "none"); |
502 | | |
503 | | // 繝槭え繧ケ縺ョ蜍輔″繧ォ繧ヲ繝ウ繝医r繝ォ繝シ繝医↓謖√◆縺帙k |
504 | | MOUSEMOVED = 0; |
505 | | |
506 | | // 繝弱�繝峨∈縺ョ繧ェ繝ウ繝槭え繧ケ縺ァ繝代せ謗「邏「縲√ヱ繧ケ荳ュ縺ョ繝ェ繝ウ繧ッ譁�ュ励r陦ィ遉コ |
507 | | node.on("mouseover", function(d){ |
508 | | |
509 | | // 繝槭え繧ケ縺ョ蜍輔″繧ォ繧ヲ繝ウ繝医r繝ェ繧サ繝�ヨ |
510 | | node.data()[0].mousemoved = 0; |
511 | | |
512 | | // 陦ィ遉コ縺吶k繝代せ菫晏ュ倡畑驟榊� |
513 | | var path = []; |
514 | | // 繝��繝ォ繝√ャ繝励∈縺ョ蜷榊燕陦ィ遉コ逕ィ驟榊� |
515 | | var pathname = []; |
516 | | |
517 | | // 繝ォ繝シ繝医ヮ繝シ繝我サ・螟悶↑繧� |
518 | | if(d.nodeid != 0){ |
519 | | // 縺セ縺壹が繝ウ繝槭え繧ケ縺輔l縺溘ヮ繝シ繝峨�id縺ィ蜷榊燕繧偵◎繧後◇繧瑚ソス蜉 |
520 | | path.push(d.nodeid); |
521 | | pathname.push(d.name); |
522 | | |
523 | | // 繝代せ謗「邏「 |
524 | | do{ |
525 | | // 繝ェ繝ウ繧ッ縺ョ謨ー縺縺醍ケー繧願ソ斐@ |
526 | | for(var i = 0; i < link.data().length; i++){ |
527 | | // 迴セ蝨ィ縺ョ譛蠕悟ーセ縺ォ郢九′繧九Μ繝ウ繧ッ縺後≠繧後� |
528 | | if(path[(path.length-1)] == link.data()[i].target){ |
529 | | // 縺昴�繝ェ繝ウ繧ッ縺ョ繧ス繝シ繧ケ蛛エ繝弱�繝峨�id繧定ソス蜉 |
530 | | path.push(link.data()[i].source); |
531 | | // 縺昴�繝ェ繝ウ繧ッ縺ョ蜷榊燕縺ィ繧ス繝シ繧ケ蛛エ繝弱�繝峨�蜷榊燕繧定ソス蜉 |
532 | | pathname.push(link.data()[i].property); |
533 | | pathname.push(node.data()[link.data()[i].source].name); |
534 | | } |
535 | | } |
536 | | // 繝ォ繝シ繝医ヮ繝シ繝峨↓霎ソ繧顔捩縺上∪縺ァ郢ー繧願ソ斐☆ |
537 | | }while(path[(path.length-1)] != 0); |
538 | | |
539 | | // 譛ォ遶ッ繝弱�繝峨〒縺ェ縺�↑繧� |
540 | | if(d.path == "notend"){ |
541 | | // 繝��繝ォ繝√ャ繝励r髱櫁。ィ遉コ縺ォ |
542 | | $('.SBSelectedPath').html('<h1>Please <span style="color: hsl(150, 50%, 75%);">select a leaf node</span> and <span style=\"color: hsl(200, 50%, 75%);\">push button</span> to generate a SPARQL</h1>'); |
543 | | }else{ |
544 | | // 譛ォ遶ッ繝弱�繝峨↑繧峨ヤ繝シ繝ォ繝√ャ繝励�諠�ア繧呈峩譁ー |
545 | | var resultText = '<div class="SBGenButton" onclick="generateSPARQL()">Generate<br />SPARQL</div>'; |
546 | | // 繝代せ縺ョ蜷榊燕驟榊�蛻�セ後m縺九i郢ー繧願ソ斐@縺ェ縺後i |
547 | | for (var i = pathname.length;i > 0; i--){ |
548 | | // 螂�焚逡ェ逶ョ�医ヮ繝シ繝峨�蜷榊燕�峨�螟ェ蟄励↓ |
549 | | if(i % 2 == 1){ |
550 | | if(i == 1){ |
551 | | resultText = resultText + "<div class=\"SBLeafNode\">" + pathname[i - 1] + "</div>"; |
552 | | }else if(i == pathname.length){ |
553 | | resultText = resultText + "<div class=\"SBRootNode\">" + pathname[i - 1] + "</div>"; |
554 | | }else{ |
555 | | resultText = resultText + "<div class=\"SBPathNode\">" + pathname[i - 1] + "</div>"; |
556 | | } |
557 | | // 蛛カ謨ー逡ェ逶ョ�医Μ繝ウ繧ッ縺ョ蜷榊燕�峨�縺昴�縺セ縺セ縺ァ陦ィ遉コ |
558 | | }else{ |
559 | | resultText = resultText + "<img src=\"images/pathline.png\"><div class=\"SBPathProperty\">" + pathname[i - 1] + "</div><img src=\"images/pathline.png\">"; |
560 | | } |
561 | | } |
562 | | |
563 | | // 繝��繝ォ繝√ャ繝励�蜀�ョケ繧呈嶌縺肴鋤縺� |
564 | | $('.SBSelectedPath').html(resultText); |
565 | | |
566 | | // 繧オ繝シ繝悶Ξ繝�ヨ縺ォ騾√j霑斐☆繝代せ繧ェ繝悶ず繧ァ繧ッ繝医r菫晏ュ� |
567 | | pathobj = d.path; |
568 | | } |
569 | | |
570 | | $('.SBPath').css('overflow-y', 'visible'); |
571 | | |
572 | | if($('.SBPath').height() < $('.SBSelectedPath').innerHeight()){ |
573 | | $('.SBPath').css('overflow-y', 'scroll'); |
574 | | } |
575 | | } |
576 | | |
577 | | // 繧ェ繝ウ繝槭え繧ケ縺輔l縺溘ヮ繝シ繝峨�鬮倥&縺ォ隕ェ繧貞粋繧上○繧九◆繧√↓蜷医o縺帙k鬮倥&繧剃ソ晏ュ� |
578 | | var movey = d.y; |
579 | | |
580 | | // 蜷�ヮ繝シ繝峨↓蟇セ縺� |
581 | | node |
582 | | // 霈ェ驛ュ邱壹�濶イ繧定ィュ螳� |
583 | | .style("stroke", function(d){ |
584 | | // 縺セ縺壹�閭梧勹濶イ�医ョ繝輔か繝ォ繝茨シ峨r謖�ョ� |
585 | | var strokecolor = "#fafafa"; |
586 | | |
587 | | // 繝代せ蛻、螳壹�蜑榊�逅� |
588 | | // 陦ィ遉コ繝輔Λ繧ー縺系ow�亥燕蝗槭が繝ウ繝槭え繧ケ縺ァ蜍輔>縺ヲ縺�◆繝弱�繝会シ峨↑繧� |
589 | | if(d.view == "now"){ |
590 | | // 繝弱�繝峨�陦ィ遉コ繝輔Λ繧ー繧地o縺ォ |
591 | | d.view = "no"; |
592 | | } |
593 | | // 陦ィ遉コ繝輔Λ繧ー縺稽oved�医け繝ェ繝�け縺輔l蝗コ螳壽ク医∩縺縺悟燕蝗槫虚縺�※縺�◆繝弱�繝会シ峨↑繧� |
594 | | if(d.view == "moved"){ |
595 | | // 陦ィ遉コ繝輔Λ繧ー繧団licked縺ォ謌サ縺� |
596 | | d.view = "clicked"; |
597 | | } |
598 | | |
599 | | // 陦ィ遉コ繝輔Λ繧ー縺系o縺ョ繧ゅ�縺九i遒コ隱� |
600 | | if(d.view == "no"){ |
601 | | // 繝代せ縺ョ繝弱�繝画焚縺縺醍ケー繧願ソ斐@縺ェ縺後i |
602 | | for(var n = 0; n < path.length; n++){ |
603 | | // 繝代せ蜀�↓蜷ォ縺セ繧後k繝弱�繝峨□縺」縺溘i |
604 | | if(path[n] == d.nodeid){ |
605 | | // 霈ェ驛ュ邱壹r襍、縺ォ |
606 | | strokecolor = "#ffaaaa"; |
607 | | // 陦ィ遉コ繝輔Λ繧ー繧地ow�井サ雁屓蜍輔>縺溘ヮ繝シ繝会シ峨↓ |
608 | | d.view = "now"; |
609 | | } |
610 | | } |
611 | | // 蝗コ螳壽ク医∩繝弱�繝峨□縺」縺溘i |
612 | | }else if(d.view == "clicked"){ |
613 | | // 縺セ縺壹�霈ェ驛ュ邱壹r襍、縺ォ |
614 | | strokecolor = "#ffaaaa"; |
615 | | // 繝代せ蜀�↓蜷ォ縺セ繧後k繝弱�繝峨°繝√ぉ繝�け |
616 | | for(var n = 0; n < path.length; n++){ |
617 | | if(path[n] == d.nodeid){ |
618 | | // 蜷ォ縺セ繧後※縺�◆縺ェ繧我サ雁屓蜍輔°縺吶◆繧√ヵ繝ゥ繧ー繧知oved縺ォ |
619 | | d.view = "moved"; |
620 | | } |
621 | | } |
622 | | } |
623 | | |
624 | | // 縺薙%縺セ縺ァ縺ァ蠕励i繧後◆霈ェ驛ュ邱壹�濶イ繧定ソ斐☆ |
625 | | return strokecolor; |
626 | | }) |
627 | | // 鬮倥&縺ョ蛟、 |
628 | | .attr("cy", function(d){ |
629 | | // 繝弱�繝峨′莉雁屓繧ェ繝ウ繝槭え繧ケ縺輔l縺溘�縺セ縺溘�蝗コ螳壽ク医∩縺縺檎ァサ蜍輔ヵ繝ゥ繧ー繧偵▽縺代i繧後※縺�l縺ー |
630 | | if(d.view == "now" || d.view == "moved"){ |
631 | | // 迴セ蝨ィ縺ョ鬮倥&繧貞叙蠕� |
632 | | var curty = d.y; |
633 | | // d.y縺ォ蟄舌ヮ繝シ繝峨�鬮倥&繧偵そ繝�ヨ |
634 | | d.y = movey; |
635 | | // 迴セ蝨ィ縺ョ鬮倥&繧定ソ斐☆�医%縺ョ譎らせ縺ァ縺ッ迴セ蝨ィ菴咲スョ縺ォ謠冗判縺輔l縲〉edraw髢「謨ー縺ァd.y縺ォ繧「繝九Γ繝シ繧キ繝ァ繝ウ縺輔l繧具シ� |
636 | | return curty; |
637 | | // 遘サ蜍募ッセ雎。縺ァ縺ェ縺�↑繧� |
638 | | }else{ |
639 | | // 迴セ蝨ィ菴咲スョ繧偵◎縺ョ縺セ縺セ霑斐☆ |
640 | | return d.y; |
641 | | } |
642 | | }); |
643 | | |
644 | | // 蜷�Μ繝ウ繧ッ繝�く繧ケ繝医↓蟇セ縺� |
645 | | tlink |
646 | | // 繝�く繧ケ繝郁。ィ遉コ蛻、螳� |
647 | | .text(function(d) { |
648 | | // 繝�ヵ繧ゥ繝ォ繝医〒遨コ繧偵そ繝�ヨ |
649 | | var linktext = ""; |
650 | | // 陦ィ遉コ繝輔Λ繧ー縺系ow�亥燕蝗櫁。ィ遉コ縺輔l縺ヲ縺�◆繝ェ繝ウ繧ッ�峨↑繧� |
651 | | if(d.view == "now"){ |
652 | | // 陦ィ遉コ繝輔Λ繧ー繧定ァ」髯、 |
653 | | d.view = "no"; |
654 | | } |
655 | | |
656 | | // 陦ィ遉コ繝輔Λ繧ー縺系o縺ェ繧� |
657 | | if(d.view == "no"){ |
658 | | // 繝代せ縺ョ繝弱�繝画焚蛻�ケー繧願ソ斐@ |
659 | | for(var t = 0; t < path.length; t++){ |
660 | | // 閾ェ霄ォ縺後◎縺ョ繝弱�繝峨∈謗・邯壹@縺ヲ縺�k繝ェ繝ウ繧ッ�医°縺、縺昴�繝弱�繝峨′謚倥j縺溘◆縺セ繧後※縺�↑縺代l縺ー�� |
661 | | if(path[t] == d.target && node.data()[d.target].view != "hide"){ |
662 | | // 繝ェ繝ウ繧ッ繝�く繧ケ繝医↓繝励Ο繝代ユ繧」縺ョ蛟、繧偵そ繝�ヨ |
663 | | linktext = d.property |
664 | | // 陦ィ遉コ繝輔Λ繧ー縺ォnow繧偵そ繝�ヨ |
665 | | d.view = "now"; |
666 | | } |
667 | | } |
668 | | // 陦ィ遉コ繝輔Λ繧ー縺掲ix�医け繝ェ繝�け縺輔l縺溘ヱ繧ケ縺ョ繝ェ繝ウ繧ッ�峨↑繧峨��医°縺、郢九′繧句�縺ョ繝弱�繝峨′謚倥j縺溘◆縺セ繧後※縺�↑縺代l縺ー�� |
669 | | }else if(d.view == "fix" && node.data()[d.target].view != "hide"){ |
670 | | // 繝ェ繝ウ繧ッ繝�く繧ケ繝医↓繝励Ο繝代ユ繧」縺ョ蛟、繧偵そ繝�ヨ |
671 | | linktext = d.property |
672 | | } |
673 | | // 縺薙%縺セ縺ァ縺ァ縺ァ縺阪◆繝ェ繝ウ繧ッ繝�く繧ケ繝医r霑斐☆ |
674 | | return linktext; |
675 | | }); |
| 390 | // make_data繝。繧ス繝�ラ縺ョ邨先棡繧貞叙蠕� |
| 391 | var json = make_data(0); |
| 392 | |
| 393 | // 繝代せ謨ー縺�縺ァ縺ェ縺代l縺ー |
| 394 | if(json['nodes'].length != 0){ |
| 395 | |
| 396 | // 蜃コ譚・荳翫′縺」縺溽オ先棡繧呈ク。縺励※繝槭ャ繝嶺ク翫�蠎ァ讓吶r繧サ繝�ヨ |
| 397 | set_map_location(0, json['nodes'], json['links']); |
| 398 | |
| 399 | // SVG縺ョ蟷�→鬮倥&逕ィ縺ォ謠冗判鬆伜沺縺ョ繧オ繧、繧コ繧貞叙蠕� |
| 400 | var width = $('.SBGraph').width(); |
| 401 | var height = $('.SBGraph').height(); |
| 402 | // SVG蜀��繧ー繝ゥ繝暮Κ蛻�ォ倥&�医ヱ繧ケ謨ー縺ォ蠢懊§繧具シ峨r繧サ繝�ヨ |
| 403 | var graphheight = ((NODEHEIGHT * 1.5) * PATHNUM) + (NODEHEIGHT / 2); |
| 404 | |
| 405 | // 繧ケ繧ウ繧「陦ィ遉コ縺ョ繝槭�繧ク繝ウ |
| 406 | var scoreleftmargin = NODEHEIGHT * 1.5; |
| 407 | |
| 408 | // SVG縺ョ蜑企勁 |
| 409 | d3.select(".SBGraph svg").remove(); |
| 410 | // 逕サ髱「繧オ繧、繧コ縺ォ蜷医o縺婀VG縺ョ霑ス蜉 |
| 411 | var svg = d3.select(".SBGraph").append("svg") |
| 412 | .attr("width", width) |
| 413 | .attr("height", height) |
| 414 | // 繝薙Η繝シ繝懊ャ繧ッ繧ケ縺ョ繧サ繝�ヨ |
| 415 | .attr("viewBox", "0 0 " + width + " " + height) |
| 416 | // 繧ケ繧ッ繝ュ繝シ繝ォ縺輔l縺溘i |
| 417 | .on("mousewheel", function(){ |
| 418 | // 迴セ蝨ィ縺ョ繝薙Η繝シ繝懊ャ繧ッ繧ケ縺ョ迥カ諷九r蜿門セ� |
| 419 | var vb = svg.attr("viewBox"); |
| 420 | // 繧ケ繝壹�繧ケ縺ァ蛹コ蛻�j蜷�、縺ォ蛻�ァ」 |
| 421 | var spvb = vb.split(" "); |
| 422 | |
| 423 | // 繝薙Η繝シ繝懊ャ繧ッ繧ケ縺ョy縺ョ蛟、縺九i莉雁屓縺ョ繝帙う繝シ繝ォ繧、繝吶Φ繝医�蟾ョ蛻�r蠑輔¥ |
| 424 | var vby = (parseInt(spvb[1]) - event.wheelDelta); |
| 425 | |
| 426 | // 0繧貞牡縺」縺ヲ縺�◆繧�縺ォ |
| 427 | if(vby < 0){ |
| 428 | vby = 0; |
| 429 | // 繧ケ繧ッ繝ュ繝シ繝ォ荳企剞�医げ繝ゥ繝輔し繧、繧コ蠑輔¥陦ィ遉コ鬆伜沺繧オ繧、繧コ�峨r雜�∴縺ヲ縺�◆繧芽」懈ュ」 |
| 430 | }else if(vby > (graphheight - height)){ |
| 431 | vby = (graphheight - height); |
| 432 | // 陬懈ュ」縺励◆邨先棡0繧貞牡縺」縺ヲ縺�◆繧�縺ォ |
| 433 | if(vby < 0){ |
| 434 | vby = 0; |
| 435 | } |
| 436 | } |
| 437 | |
| 438 | // 縺薙%縺セ縺ァ縺ァ縺ァ縺阪◆y繧偵そ繝�ヨ縺励ン繝・繝シ繝懊ャ繧ッ繧ケ繧呈峩譁ー |
| 439 | svg.attr("viewBox", "0 " + vby + " " + width + " " + height); |
| 440 | }); |
| 441 | |
| 442 | // 閭梧勹縺ョ霑ス蜉�磯ォ倥&莉・螟悶�謠冗判鬆伜沺縺昴�縺セ縺セ�� |
| 443 | var bg = svg |
| 444 | .append("rect") |
| 445 | .attr("x", 0) |
| 446 | .attr("y", 0) |
| 447 | .attr("width", width) |
| 448 | .attr("height", function(){ |
| 449 | // 繧ー繝ゥ繝暮Κ蛻��鬮倥&縺梧緒逕サ鬆伜沺縺ョ鬮倥&繧貞牡縺」縺ヲ縺�◆繧会シ医ヱ繧ケ縺悟ー代↑縺代l縺ー�画緒逕サ鬆伜沺縺ョ鬮倥&繧定ソ斐☆ |
| 450 | if(graphheight < height){ |
| 451 | return height; |
| 452 | }else{ |
| 453 | return graphheight; |
| 454 | } |
| 455 | }) |
| 456 | // 閭梧勹繧定埋縺�げ繝ャ繝シ縺ォ |
| 457 | .attr("fill", "#fafafa"); |
| 458 | |
| 459 | // links驟榊�繧呈ク。縺励Μ繝ウ繧ッ縺ョ菴懈� |
| 460 | var link = svg.selectAll(".link") |
| 461 | .data(json.links) |
| 462 | .enter().append("line") |
| 463 | .attr("class", "link") |
| 464 | .style("stroke", "#999") |
| 465 | .style("stroke-opacity", 0.6) |
| 466 | .style("stroke-width", 2); |
| 467 | |
| 468 | // nodes驟榊�繧呈ク。縺励ヮ繝シ繝峨�菴懈� |
| 469 | var node = svg.selectAll(".node") |
| 470 | .data(json.nodes) |
| 471 | .enter().append("circle") |
| 472 | .attr("class", "node") |
| 473 | .attr("r", (NODEHEIGHT / 2)) |
| 474 | .attr("cx", function(d) { return d.x;} ) |
| 475 | .attr("cy", function(d) { return d.y; }) |
| 476 | .style("fill", function(d) { return d.nodecolor; }) |
| 477 | .style("stroke", '#fafafa') |
| 478 | .style("stroke-width", '1.5px') |
| 479 | .style("cursor", 'pointer'); |
| 480 | |
| 481 | // nodes驟榊�繧呈ク。縺励ヮ繝シ繝峨ユ繧ュ繧ケ繝医�菴懈� |
| 482 | var tnode = svg.selectAll("text.node") |
| 483 | .data(json.nodes) |
| 484 | .enter().append("svg:text") |
| 485 | .attr("class", "tnode") |
| 486 | .attr("x", function(d) { return d.x; }) |
| 487 | .attr("y", function(d) { return d.y; }) |
| 488 | .text(function(d) { return d.name; }) |
| 489 | .style("fill", '#000000') |
| 490 | .style("text-anchor", 'middle') |
| 491 | .style("pointer-events", "none"); |
| 492 | |
| 493 | // 繝ェ繝ウ繧ッ繝�く繧ケ繝医�菴懈� |
| 494 | var tlink = svg.selectAll("text.link") |
| 495 | .data(json.links) |
| 496 | .enter().append("svg:text") |
| 497 | .attr("class", "tlink") |
| 498 | .attr("x", function(d) { return (json.nodes[d.source].x + json.nodes[d.target].x) / 2; }) |
| 499 | .attr("y", function(d) { return (json.nodes[d.source].y + json.nodes[d.target].y) / 2; }) |
| 500 | .style("fill", '#000000') |
| 501 | .style("text-anchor", 'middle'); |
| 502 | |
| 503 | // 繧ケ繧ウ繧「繝�く繧ケ繝医�菴懈� |
| 504 | var tscore = svg.selectAll("text.score") |
| 505 | .data(json.nodes) |
| 506 | .enter().append("svg:text") |
| 507 | .attr("class", "tscore") |
| 508 | .attr("x", function(d) { return (d.x + scoreleftmargin); }) |
| 509 | .attr("y", function(d) { return d.y; }) |
| 510 | .text(function(d) { return d.score; }) |
| 511 | .style("fill", '#ff0000') |
| 512 | .style("text-anchor", 'middle') |
| 513 | .style("pointer-events", "none"); |
| 514 | |
| 515 | // 繝弱�繝峨∈縺ョ繧ェ繝ウ繝槭え繧ケ縺ァ繝代せ謗「邏「縲√ヱ繧ケ荳ュ縺ョ繝ェ繝ウ繧ッ譁�ュ励r陦ィ遉コ |
| 516 | node.on("mouseover", function(d){ |
| 517 | |
| 518 | // 陦ィ遉コ縺吶k繝代せ菫晏ュ倡畑驟榊� |
| 519 | var path = []; |
| 520 | // 繝代せ陦ィ遉コ諠�ア菫晏ュ倡畑驟榊� |
| 521 | var pathname = []; |
| 522 | |
| 523 | // 縺セ縺壹が繝ウ繝槭え繧ケ縺輔l縺溘ヮ繝シ繝峨�id縺ィ蜷榊燕繧偵◎繧後◇繧瑚ソス蜉 |
| 524 | path.push(d.nodeid); |
| 525 | pathname.push(d.name); |
| 526 | |
| 527 | // 繝代せ謗「邏「 |
| 528 | do{ |
| 529 | // 繝ェ繝ウ繧ッ縺ョ謨ー縺縺醍ケー繧願ソ斐@ |
| 530 | for(var i = 0; i < link.data().length; i++){ |
| 531 | // 迴セ蝨ィ縺ョ譛蠕悟ーセ縺ォ郢九′繧九Μ繝ウ繧ッ縺後≠繧後� |
| 532 | if(path[(path.length-1)] == link.data()[i].target){ |
| 533 | // 縺昴�繝ェ繝ウ繧ッ縺ョ繧ス繝シ繧ケ蛛エ繝弱�繝峨�id繧定ソス蜉 |
| 534 | path.push(link.data()[i].source); |
| 535 | // 縺昴�繝ェ繝ウ繧ッ縺ョ蜷榊燕縺ィ繧ス繝シ繧ケ蛛エ繝弱�繝峨�蜷榊燕繧定ソス蜉 |
| 536 | pathname.push(link.data()[i].property); |
| 537 | pathname.push(node.data()[link.data()[i].source].name); |
| 538 | } |
| 539 | } |
| 540 | // 繝ォ繝シ繝医ヮ繝シ繝峨↓霎ソ繧顔捩縺上∪縺ァ郢ー繧願ソ斐☆ |
| 541 | }while(path[(path.length-1)] != 0); |
| 542 | |
| 543 | // 繝ォ繝シ繝医ヮ繝シ繝峨∪縺溘�騾比クュ繝弱�繝峨↑繧� |
| 544 | if(d.nodeid == 0 || d.path == "notend"){ |
| 545 | // 繝代せ陦ィ遉コ鬆伜沺繧偵ョ繝輔か繝ォ繝医↓ |
| 546 | $('.SBSelectedPath').html('<h1>Please <span style="color: hsl(150, 50%, 75%);">select a leaf node</span> and <span style=\"color: hsl(200, 50%, 75%);\">push button</span> to generate a SPARQL</h1>'); |
| 547 | // 譛ォ遶ッ繝弱�繝峨↑繧� |
| 548 | }else{ |
| 549 | |
| 550 | // 繝代せ陦ィ遉コ鬆伜沺逕ィ譁�ュ怜��医ず繧ァ繝阪Ξ繝シ繝医�繧ソ繝ウ繧偵∪縺夊ソス蜉�� |
| 551 | var resultText = '<div class="SBGenButton" onclick="generateSPARQL()">Generate<br />SPARQL</div>'; |
| 552 | // 繝代せ縺ョ蜷榊燕驟榊�蛻�セ後m縺九i郢ー繧願ソ斐@縺ェ縺後i |
| 553 | for (var i = pathname.length;i > 0; i--){ |
| 554 | // 螂�焚逡ェ逶ョ�医ヮ繝シ繝会シ峨↑繧� |
| 555 | if(i % 2 == 1){ |
| 556 | // 繝ォ繝シ繝医°騾比クュ縺区忰遶ッ縺九↓蠢懊§縺ヲ繧ッ繝ゥ繧ケ繧呈欠螳壹@霑ス險� |
| 557 | if(i == 1){ |
| 558 | resultText = resultText + "<div class=\"SBLeafNode\">" + pathname[i - 1] + "</div>"; |
| 559 | }else if(i == pathname.length){ |
| 560 | resultText = resultText + "<div class=\"SBRootNode\">" + pathname[i - 1] + "</div>"; |
| 561 | }else{ |
| 562 | resultText = resultText + "<div class=\"SBPathNode\">" + pathname[i - 1] + "</div>"; |
| 563 | } |
| 564 | // 蛛カ謨ー逡ェ逶ョ�医Μ繝ウ繧ッ�峨�繝ェ繝ウ繧ッ逕サ蜒上r蜑榊セ後↓縺、縺題ソス險� |
| 565 | }else{ |
| 566 | resultText = resultText + "<img src=\"images/pathline.png\"><div class=\"SBPathProperty\">" + pathname[i - 1] + "</div><img src=\"images/pathline.png\">"; |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | // 繝代せ陦ィ遉コ鬆伜沺縺ョ蜀�ョケ繧呈嶌縺肴鋤縺� |
| 571 | $('.SBSelectedPath').html(resultText); |
| 572 | |
| 573 | // 繧オ繝シ繝悶Ξ繝�ヨ縺ォ騾√j霑斐☆繝代せ繧ェ繝悶ず繧ァ繧ッ繝医r菫晏ュ� |
| 574 | pathobj = d.path; |
| 575 | |
| 576 | // 繝代せ陦ィ遉コ鬆伜沺縺ョ陦ィ遉コ險ュ螳壹rvisivle縺ォ |
| 577 | $('.SBPath').css('overflow-y', 'visible'); |
| 578 | |
| 579 | // 繝代せ蜀�ョケ縺ョ鬮倥&縺後ヱ繧ケ陦ィ遉コ鬆伜沺繧定カ�∴縺ヲ縺�◆繧� |
| 580 | if($('.SBPath').height() < $('.SBSelectedPath').innerHeight()){ |
| 581 | // 繝代せ陦ィ遉コ鬆伜沺縺ョ陦ィ遉コ險ュ螳壹r繧ケ繧ッ繝ュ繝シ繝ォ縺ォ |
| 582 | $('.SBPath').css('overflow-y', 'scroll'); |
| 583 | } |
| 584 | } |
| 585 | |
| 586 | // 繧ェ繝ウ繝槭え繧ケ縺輔l縺溘ヮ繝シ繝峨�鬮倥&縺ォ隕ェ繧貞粋繧上○繧九◆繧√↓蜷医o縺帙k鬮倥&繧剃ソ晏ュ� |
| 587 | var movey = d.y; |
| 588 | |
| 589 | // 蜷�ヮ繝シ繝峨↓蟇セ縺� |
| 590 | node |
| 591 | // 霈ェ驛ュ邱壹�濶イ繧定ィュ螳� |
| 592 | .style("stroke", function(d){ |
| 593 | // 縺セ縺壹�閭梧勹濶イ�医ョ繝輔か繝ォ繝茨シ峨r謖�ョ� |
| 594 | var strokecolor = "#fafafa"; |
| 595 | |
| 596 | // 繝代せ縺ョ繝弱�繝画焚縺縺醍ケー繧願ソ斐@縺ェ縺後i |
| 597 | for(var n = 0; n < path.length; n++){ |
| 598 | // 繝代せ蜀�↓蜷ォ縺セ繧後k繝弱�繝峨□縺」縺溘i |
| 599 | if(path[n] == d.nodeid){ |
| 600 | // 霈ェ驛ュ邱壹r襍、縺ォ |
| 601 | strokecolor = "#ffaaaa"; |
| 602 | } |
| 603 | } |
| 604 | |
| 605 | // 縺薙%縺セ縺ァ縺ァ蠕励i繧後◆霈ェ驛ュ邱壹�濶イ繧定ソ斐☆ |
| 606 | return strokecolor; |
| 607 | }) |
| 608 | // 鬮倥&縺ョ蛟、 |
| 609 | .attr("cy", function(d){ |
| 610 | |
| 611 | // 迴セ蝨ィ縺ョ鬮倥&繧貞叙蠕� |
| 612 | var currenty = d.y |
| 613 | |
| 614 | // 繝代せ縺ョ繝弱�繝画焚縺縺醍ケー繧願ソ斐@縺ェ縺後i |
| 615 | for(var n = 0; n < path.length; n++){ |
| 616 | // 繝代せ蜀�↓蜷ォ縺セ繧後k繝弱�繝峨□縺」縺溘i |
| 617 | if(path[n] == d.nodeid){ |
| 618 | // 蜀�Κ縺ァ謖√▽鬮倥&繧偵が繝ウ繝槭え繧ケ縺輔l縺溘ヮ繝シ繝峨→蜷後§縺ォ�亥�謠冗判譎ゅ↓蜿肴丐�� |
| 619 | d.y = movey; |
| 620 | } |
| 621 | } |
| 622 | |
| 623 | // 莉翫�迴セ譎らせ縺ョ鬮倥&繧定ソ斐☆ |
| 624 | return currenty; |
| 625 | }); |
| 626 | |
| 627 | // 蜷�Μ繝ウ繧ッ繝�く繧ケ繝医↓蟇セ縺� |
| 628 | tlink |
| 629 | // 繝�く繧ケ繝郁。ィ遉コ蛻、螳� |
| 630 | .text(function(d) { |
| 631 | // 繝�ヵ繧ゥ繝ォ繝医〒遨コ繧偵そ繝�ヨ |
| 632 | var linktext = ""; |
| 633 | |
| 634 | // 繝代せ縺ョ繝弱�繝画焚縺縺醍ケー繧願ソ斐@縺ェ縺後i |
| 635 | for(var t = 0; t < path.length; t++){ |
| 636 | // 閾ェ霄ォ縺後◎縺ョ繝弱�繝峨∈謗・邯壹@縺ヲ縺�k繝ェ繝ウ繧ッ縺ェ繧峨� |
| 637 | if(path[t] == d.target){ |
| 638 | // 繝ェ繝ウ繧ッ繝�く繧ケ繝医↓繝励Ο繝代ユ繧」縺ョ蛟、繧偵そ繝�ヨ |
| 639 | linktext = d.property |
| 640 | } |
| 641 | } |
| 642 | |
| 643 | // 縺薙%縺セ縺ァ縺ァ縺ァ縺阪◆繝ェ繝ウ繧ッ繝�く繧ケ繝医r霑斐☆ |
| 644 | return linktext; |
| 645 | }); |