root/SPARQLBuilderWWW/web/newsparqlbuilder.js @ 243

リビジョン 243, 31.3 KB (コミッタ: lenz, 10 年 前)

スクロール及びPermalinkボタンの発動系問題の解決
Permalinkボタンのサイズを固定長に調整

  • 属性 svn:mime-type の設定値 text/plain
Rev行番号 
[232]1
2var PATHNUM = 0;
3var MAXDEPTH = 0;
4var TREESPACE = 0;
[239]5var NODEHEIGHT = 50;
[232]6var DRAWHEIGHT = 0;
7
8var endpoint = "";
9var startclass= "";
10var endclass = "";
11
[233]12var defendpoint = "";
13var defstartclass= "";
14var defendclass = "";
15
[232]16var jsontext = "";
17var pathobj = "";
18
19var pathlimit = 10;
20
21
22// 繝壹�繧ク隱ュ縺ソ霎シ縺ソ縺悟ョ御コ�ャ。隨ャ螳溯。�
23$(function(){
24
25        // 繝壹�繧ク縺ョ繝代�繝�Κ蛻�r霑ス蜉
26        initparts();
[233]27
28        getParameter();
29
30        if(defendpoint != "" && defstartclass != "" && defendclass != ""){
31                openSPARQLBuilder();
32        }
33
[232]34});
35
36function initparts(){
37        var sbdiv = $('div#SPARQLBUILDER');
[234]38        if(sbdiv.find('div').length == 0){
[240]39                var sbtop = '<div class="SBTopItems"><input type="button" class="SBTopButton" value="Open SPARQLBuilder" onclick="openSPARQLBuilder()"><input type="button" class="SBTopButton" value="Try with Sample" onclick="openSample(\'http://www.ebi.ac.uk/rdf/services/reactome/sparql\', \'http://www.biopax.org/release/biopax-level3.owl#Protein\', \'http://www.biopax.org/release/biopax-level3.owl#Pathway\')"><br><textarea class="SBSparqlArea" rows="10"></textarea><br><input type="button" class="SBTopButton" value="Send SPARQL" onclick="sendSPARQL()"><input type="button" class="SBTopButton" value="Download Result" onclick="downloadResult()"></div><div class="SBTutorialLink">Tutorial for SPARQL Builder GUI is <a href="http://www.sparqlbuilder.org/doc/how-to-use-sparql-builder-gui/" target="_blank">here</a>.</div>';
[238]40                var sbmodal = '<div class="SBModalView"><div class="SBModalContents"><div class="SBForms"><div class="SBSelects"><select class="SBEndPointSelect"></select><select class="SBStartClassSelect"></select><select class="SBEndClassSelect"></select></div><div class="SBPermaLink"><input type="button" class="SBPermaLinkButton" value="Permalink" onclick="openPermalink()" disabled="disabled"></div></div><div class="SBMessage"><div class="SBResult"><span class="SBPathnum"></span> Path<span class="SBPlural"></span> found.</div><input type="button" class="SBViewAll" value="View All Path" onclick="viewAll()"></div><div class="SBGraph"><div class="SBAjaxLoad" style="display: none;"><div class="SBLoadIcon"><img src="images/ajax-loader.gif"></div></div></div><div class="SBPath"><div class="SBSelectedPath"></div></div><div class="SBModalButtons"><input type="button" class="SBModalButton" value="Close" onclick="closeSPARQLBuilder()"></div></div></div>';
[232]41
[234]42                sbdiv.html(sbtop);
43                $('body').append(sbmodal);
44        }
[232]45
46        $('.SBModalView').click(function(){
47                $(this).fadeOut(700);
48        });
49
[242]50        $('.SBModalContents').click(function(event){
[232]51                event.stopPropagation();
52        });
53
54        loadEndPointList();
55
56        $(".SBEndPointSelect").change(function() {
57                changeEndPoint();
58        });
59
60        $(".SBStartClassSelect").change(function() {
61                startClass = $(".SBStartClassSelect").val();
62                loadPathList();
63        });
64        $(".SBEndClassSelect").change(function() {
65                endClass = $(".SBEndClassSelect").val();
66                loadPathList();
67        });
68
[243]69        d3.select('.SBModalView').on("mousewheel", function(){
[236]70                event.preventDefault();
[243]71                event.stopPropagation();
[236]72        });
73
[243]74        d3.select('body').on("mousewheel", function(){
75                console.log("WTF");
76        });
77
[232]78}
79
[233]80
81function getParameter()
82{
83    if( 1 < window.location.search.length )
84    {
85        var query = window.location.search.substring( 1 );
86        var parameters = query.split( '&' );
87
88        for( var i = 0; i < parameters.length; i++ )
89        {
90            var element = parameters[ i ].split( '=' );
91            if(decodeURIComponent( element[ 0 ] ) == "ep"){
92                defendpoint = decodeURIComponent( element[ 1 ] )
93            }else if(decodeURIComponent( element[ 0 ] ) == "st"){
94                defstartclass = decodeURIComponent( element[ 1 ] )
95            }else if(decodeURIComponent( element[ 0 ] ) == "en"){
96                defendclass = decodeURIComponent( element[ 1 ] )
97            }
98        }
99    }
100}
101
102
[232]103function openSPARQLBuilder(){
104
105        $('.SBModalView').css('top', $(window).scrollTop()).css('height', window.innerHeight).fadeIn();
106
[235]107        resizeModalView();
[232]108
109        $(".SBEndPointSelect").select2();
110        $(".SBStartClassSelect").select2();
111        $(".SBEndClassSelect").select2();
112
[233]113        if(defendpoint != "" && defstartclass != "" && defendclass != ""){
114
115                $('.SBStartClassSelect').on('lccomplete', function(){
116                        $('.SBStartClassSelect').val(defstartclass);
117                        defstartclass = "";
118                        $('.SBEndClassSelect').val(defendclass);
119                        defendclass = "";
120
121                        $(".SBEndPointSelect").select2();
122                        $(".SBStartClassSelect").select2();
123                        $(".SBEndClassSelect").select2();
124
125                        $('.SBStartClassSelect').unbind('lccomplete');
126                });
127
128                loadPathList();
129
130                var eplist = $('.SBEndPointSelect option');
131
132                if(eplist.length == 0){
133                        $('.SBEndPointSelect').on('epcomplete', function(){
134                                $('.SBEndPointSelect').val(defendpoint);
135                                defendpoint = "";
136                                loadClassList();
137                                $('.SBEndPointSelect').unbind('epcomplete');
138                        });
139                }else{
140                        $('.SBEndPointSelect').val(defendpoint);
141                        defendpoint = "";
142                        loadClassList();
143                }
144        }
[232]145}
146
[235]147function resizeModalView(){
148
149        if($('.SBModalView').css('display') == 'block'){
150                var mvw = $('.SBModalContents').width();
151                var mvh = $('.SBModalContents').height();
152                $('.SBModalContents .SBForms').css('width', (mvw - 201) + 'px').css('height', 56 + 'px');
153                $('.SBModalContents .SBMessage').css('width', 200 + 'px').css('height', 56 + 'px');
154                $('.SBModalContents .SBGraph').css('width', (mvw - 201) + 'px').css('height', (mvh - 57) + 'px');
155                $('.SBModalContents .SBPath').css('width', 180 + 'px').css('height', (mvh - 77 - 26) + 'px');
156                $('.SBModalContents .SBModalButtons').css('width', 200 + 'px').css('height', '26px');
157
[243]158                var formw = $('.SBModalContents .SBForms').width();
159                var selw = Math.floor(formw - 120);
[236]160
[235]161                if(selw % 2 == 1){
[236]162                        selw--;
[235]163                }
[236]164                $('.SBModalContents .SBSelects').css('width', selw);
[243]165                $('.SBModalContents .SBPermaLink').css('width', Math.floor(formw - selw));
[235]166        }
167}
168
[233]169function openSample(ep, st, en){
170        defendpoint = ep;
171        defstartclass = st;
172        defendclass = en;
173
174        openSPARQLBuilder();
175}
176
[232]177function openPermalink(){
[233]178        var baseurl = location.href;
179        var spliturl = baseurl.split('?');
180        var url = spliturl[0] + "?ep=" + encodeURIComponent(endpoint) + "&st=" + encodeURIComponent(startclass) + "&en=" + encodeURIComponent(endclass);
[232]181
[233]182        window.open(url);
[232]183}
184
185function closeSPARQLBuilder(){
186        $('.SBModalView').fadeOut();
187}
188
189function switchLoadIcon(mode) {
190        if(mode == "view"){
191                $('.SBAjaxLoad').show();
192        }else{
193                $('.SBAjaxLoad').hide();
194        }
195};
196
197function loadEndPointList(){
[243]198        $('.SBPermaLinkButton').attr('disabled', true);
[232]199        var url = 'http://www.sparqlbuilder.org/api/eplist';
200        $.ajax({
201                url: url,
202                success: function(data) {
203                        var list = eval(data);
204                        $(".SBEndPointSelect").empty();
[241]205                        $(".SBEndPointSelect").append('<option value="SBDefault">SELECT Endpoint</option>');
[232]206                        for (var i = 0; i < list.length; ++i) {
207                                $(".SBEndPointSelect").append('<option value="' + list[i] + '">' + list[i] + '</option>');
208                                switchLoadIcon("hide");
209                                if($('.SBModalView').attr('display') == 'block'){
210                                        $(".SBEndPointSelect").select2();
211                                        $(".SBStartClassSelect").select2();
212                                        $(".SBEndClassSelect").select2();
213                                }
214                        }
[233]215                        $(".SBEndPointSelect").trigger(new $.Event('epcomplete'));
[232]216                },
217        });
218}
219
220changeEndPoint = function() {
221        endpoint = $(".SBEndPointSelect").val();
222        if(endpoint != "SBDefault"){
223                loadClassList();
224        }
225};
226
227loadClassList = function() {
[243]228        $('.SBPermaLinkButton').attr('disabled', true);
[232]229        var url = "http://www.sparqlbuilder.org/api/clist?ep=" + encodeURIComponent(endpoint);
230        $.ajax({
231                type : "GET",
232                url : url,
233                async : false,
234                success : function(data) {
235                        var list = eval(data);
236                        $(".SBStartClassSelect").empty();
237                        $(".SBEndClassSelect").empty();
[236]238                        $(".SBStartClassSelect").append('<option value="SBDefault">SELECT StartClass</option>');
239                        $(".SBEndClassSelect").append('<option value="SBDefault">SELECT EndClass</option>');
[232]240                        for (var i = 0; i < list.length; ++i) {
241                                $(".SBStartClassSelect").append('<option value="' + list[i]['uri'] + '">' + list[i]['label'] + ' (' + list[i]['number'] + ')' + '</option>');
242                                $(".SBEndClassSelect").append('<option value="' + list[i]['uri'] + '">' + list[i]['label'] + ' (' + list[i]['number'] + ')' + '</option>');
243                        }
244                        $(".SBStartClassSelect").select2();
245                        $(".SBEndClassSelect").select2();
[233]246                        $(".SBStartClassSelect").trigger(new $.Event('lccomplete'));
[232]247                }
248        });
249};
250
251loadPathList = function() {
[233]252        startclass = $(".SBStartClassSelect").val();
253        endclass = $(".SBEndClassSelect").val();
254
255        if(defendpoint != "" && defstartclass != "" && defendclass != ""){
256                endpoint = defendpoint;
257                startclass = defstartclass;
258                endclass = defendclass;
259        }
260
[232]261        $('.SBSaveESE').attr('disabled', true);
262        if (startclass == null || endclass == null || startclass == "SBDefault" || endclass == "SBDefault"){
263                return;
264        }
265
266        pathlimit = 10;
267
268        $('.SBResult').hide();
269        $('.SBViewAll').hide();
[239]270        $('.SBSelectedPath').html('<h1>Please <span style="color: hsl(150, 50%, 75%);">select a leaf node</span> and click to generate a SPARQL</h1><img src=\"images/pathline.png\" style="display:none;">');
[232]271
272        var url = "http://www.sparqlbuilder.org/api/plist?ep=" + encodeURIComponent(endpoint)
273                                                                                                                        + "&startclass=" + encodeURIComponent(startclass)
274                                                                                                                        + "&endclass="   + encodeURIComponent(endclass);
[239]275
[232]276        switchLoadIcon("view");
277        setTimeout(function(){
278                $.ajax({
279                        type : "GET",
280                        url : url,
281                        //async : false,
282                        timeout : 1000000,
283                        success : function(data) {
284                                jsontext = data;
285                                view_map();
286                                switchLoadIcon("hide");
[243]287                                $('.SBPermaLinkButton').attr('disabled', false);
[232]288                        },
289                        error: function(data){
290                                switchLoadIcon("hide");
291                                alert("error: ", data);
292                        }
293                });
294        }, 100);
295};
296
297function viewAll(){
298        pathlimit = 0;
299        view_map();
300}
301
302generateSPARQL = function() {
303    var path = JSON.stringify(pathobj);
304    var url = 'http://www.sparqlbuilder.org/api/sparql?path=' + encodeURIComponent(path);
305    $.ajax({
306        type: "GET",
307        url : url,
308        dataType: 'text',
309        async: false,
310        success : function(data) {
311            $(".SBSparqlArea").val(data);
312            closeSPARQLBuilder();
313        }
314    });
315};
316
317function sendSPARQL(){
318        var sendep = $(".SBEndPointSelect").val();
319
320        var query = $(".SBSparqlArea").val();
321
322        if(sendep == "SBDefault" || query == ""){
323                return;
324        }
325
326        query = encodeURIComponent(query);
327
328        openpage = sendep + "?format=text%2Fhtml&query=" + query;
329
330        window.open(openpage);
331}
332
333function downloadResult(){
334
335        var sendep = $(".SBEndPointSelect").val();
336
337        var query = $(".SBSparqlArea").val();
338
339        if(sendep == "SBDefault" || query == ""){
340                return;
341        }
342
343        qr = sendQuery(sendep,query);
344
345        qr.fail(
346                function (xhr, textStatus, thrownError) {
347                        alert("Error: A '" + textStatus+ "' occurred.");
348                }
349        );
350        qr.done(
351                function (d) {
352                        downloadCSV(d.results.bindings);
353                }
354        );
355}
356
357function downloadCSV(data){
358
359        if (data instanceof Array) {
360                var result_txt ="";
361
362                var i=0;
363                for ( var key in data[0]) {
364                        if(i>0){result_txt +=",";}
365                        result_txt += key;
366                        i++;
367                }
368
369                result_txt += "\n";
370
371                for (var d = 0; d < data.length; d++) {
372                        var i = 0;
373                        for ( var key in data[d]) {
374                                if(i>0){result_txt +=",";}
375                                result_txt += data[d][key].value;
376                                i++;
377                        }
378                        result_txt += '\n';
379                }
380
381                var blob = new Blob( [result_txt], {type: 'text/plain'} )
382
383                var link = document.createElement('a')
384                link.href = URL.createObjectURL(blob)
385                link.download = 'result' + '.csv'
386
387                document.body.appendChild(link) // for Firefox
388                link.click()
389                document.body.removeChild(link) // for Firefox
390        }
391};
392
[238]393
394// 繧ー繝ゥ繝墓緒逕サ驛ィ蛻�
[232]395view_map = function(){
396
[238]397        // make_data繝。繧ス繝�ラ縺ョ邨先棡繧貞叙蠕�
[239]398        var json = make_data();
[232]399
[238]400        // 繝代せ謨ー縺�縺ァ縺ェ縺代l縺ー
401        if(json['nodes'].length != 0){
[232]402
[238]403                // 蜃コ譚・荳翫′縺」縺溽オ先棡繧呈ク。縺励※繝槭ャ繝嶺ク翫�蠎ァ讓吶r繧サ繝�ヨ
404                set_map_location(0, json['nodes'], json['links']);
[232]405
[238]406                // SVG縺ョ蟷�→鬮倥&逕ィ縺ォ謠冗判鬆伜沺縺ョ繧オ繧、繧コ繧貞叙蠕�
407                var width = $('.SBGraph').width();
408                var height = $('.SBGraph').height();
409                // SVG蜀��繧ー繝ゥ繝暮Κ蛻�ォ倥&�医ヱ繧ケ謨ー縺ォ蠢懊§繧具シ峨r繧サ繝�ヨ
410                var graphheight = ((NODEHEIGHT * 1.5) * PATHNUM) + (NODEHEIGHT / 2);
[232]411
[238]412                // 繧ケ繧ウ繧「陦ィ遉コ縺ョ繝槭�繧ク繝ウ
413                var scoreleftmargin = NODEHEIGHT * 1.5;
[232]414
[238]415                // SVG縺ョ蜑企勁
416                d3.select(".SBGraph svg").remove();
417                // 逕サ髱「繧オ繧、繧コ縺ォ蜷医o縺婀VG縺ョ霑ス蜉
418                var svg = d3.select(".SBGraph").append("svg")
419                        .attr("width", width)
420                        .attr("height", height)
421                        // 繝薙Η繝シ繝懊ャ繧ッ繧ケ縺ョ繧サ繝�ヨ
422                        .attr("viewBox", "0 0 " + width + " " + height)
423                        // 繧ケ繧ッ繝ュ繝シ繝ォ縺輔l縺溘i
424                        .on("mousewheel", function(){
425                                // 迴セ蝨ィ縺ョ繝薙Η繝シ繝懊ャ繧ッ繧ケ縺ョ迥カ諷九r蜿門セ�
426                                var vb = svg.attr("viewBox");
427                                // 繧ケ繝壹�繧ケ縺ァ蛹コ蛻�j蜷�€、縺ォ蛻�ァ」
428                                var spvb = vb.split(" ");
[232]429
[238]430                                // 繝薙Η繝シ繝懊ャ繧ッ繧ケ縺ョy縺ョ蛟、縺九i莉雁屓縺ョ繝帙う繝シ繝ォ繧、繝吶Φ繝医�蟾ョ蛻�r蠑輔¥
431                                var vby = (parseInt(spvb[1]) - event.wheelDelta);
[232]432
[238]433                                // 0繧貞牡縺」縺ヲ縺�◆繧�縺ォ
434                                if(vby < 0){
435                                        vby = 0;
436                                // 繧ケ繧ッ繝ュ繝シ繝ォ荳企剞�医げ繝ゥ繝輔し繧、繧コ蠑輔¥陦ィ遉コ鬆伜沺繧オ繧、繧コ�峨r雜�∴縺ヲ縺�◆繧芽」懈ュ」
437                                }else if(vby > (graphheight - height)){
438                                        vby = (graphheight - height);
439                                        // 陬懈ュ」縺励◆邨先棡0繧貞牡縺」縺ヲ縺�◆繧�縺ォ
440                                        if(vby < 0){
441                                                vby = 0;
442                                        }
443                                }
[232]444
[238]445                                // 縺薙%縺セ縺ァ縺ァ縺ァ縺阪◆y繧偵そ繝�ヨ縺励ン繝・繝シ繝懊ャ繧ッ繧ケ繧呈峩譁ー
446                                svg.attr("viewBox", "0 " + vby + " " + width + " " + height);
447                    });
[232]448
[238]449                // 閭梧勹縺ョ霑ス蜉�磯ォ倥&莉・螟悶�謠冗判鬆伜沺縺昴�縺セ縺セ��
450                var bg = svg
451                        .append("rect")
452                        .attr("x", 0)
453                        .attr("y", 0)
454                        .attr("width", width)
455                        .attr("height", function(){
456                                // 繧ー繝ゥ繝暮Κ蛻��鬮倥&縺梧緒逕サ鬆伜沺縺ョ鬮倥&繧貞牡縺」縺ヲ縺�◆繧会シ医ヱ繧ケ縺悟ー代↑縺代l縺ー�画緒逕サ鬆伜沺縺ョ鬮倥&繧定ソ斐☆
457                                        if(graphheight < height){
458                                                return height;
459                                        }else{
460                                                return graphheight;
461                                        }
462                                })
463                        // 閭梧勹繧定埋縺�げ繝ャ繝シ縺ォ
464                        .attr("fill", "#fafafa");
[232]465
[238]466                // links驟榊�繧呈ク。縺励Μ繝ウ繧ッ縺ョ菴懈�
467                var link = svg.selectAll(".link")
468                        .data(json.links)
469                        .enter().append("line")
470                        .attr("class", "link")
471                        .style("stroke", "#999")
472                        .style("stroke-opacity", 0.6)
473                        .style("stroke-width", 2);
[232]474
[238]475                // nodes驟榊�繧呈ク。縺励ヮ繝シ繝峨�菴懈�
476                var node = svg.selectAll(".node")
477                        .data(json.nodes)
478                        .enter().append("circle")
479                        .attr("class", "node")
480                        .attr("r", (NODEHEIGHT / 2))
481                        .attr("cx", function(d) { return d.x;} )
482                        .attr("cy",  function(d) { return d.y; })
483                        .style("fill", function(d) { return d.nodecolor; })
484                        .style("stroke", '#fafafa')
485                        .style("stroke-width", '1.5px')
[239]486                        // 譛ォ遶ッ繝弱�繝峨�縺ソ繝槭え繧ケ繧「繧、繧ウ繝ウ繧偵�繧、繝ウ繧ソ繝シ縺ォ
487                        .style("cursor", function(d){
488                                if(d.path == "notend"){
489                                        return 'normal';
490                                }else{
491                                        return 'pointer';
492                                }
493                        });
[232]494
[238]495                // nodes驟榊�繧呈ク。縺励ヮ繝シ繝峨ユ繧ュ繧ケ繝医�菴懈�
496                var tnode = svg.selectAll("text.node")
497                        .data(json.nodes)
498                        .enter().append("svg:text")
499                        .attr("class", "tnode")
500                        .attr("x", function(d) { return d.x; })
501                        .attr("y", function(d) { return d.y; })
502                        .text(function(d) { return d.name; })
503                        .style("fill", '#000000')
504                        .style("text-anchor", 'middle')
505                        .style("pointer-events", "none");
[232]506
[238]507                // 繝ェ繝ウ繧ッ繝�く繧ケ繝医�菴懈�
508                var tlink = svg.selectAll("text.link")
509                        .data(json.links)
510                        .enter().append("svg:text")
511                        .attr("class", "tlink")
512                        .attr("x", function(d) { return (json.nodes[d.source].x + json.nodes[d.target].x) / 2; })
513                        .attr("y", function(d) { return (json.nodes[d.source].y + json.nodes[d.target].y) / 2; })
514                        .style("fill", '#000000')
515                        .style("text-anchor", 'middle');
[232]516
[238]517                // 繧ケ繧ウ繧「繝�く繧ケ繝医�菴懈�
518                var tscore = svg.selectAll("text.score")
519                        .data(json.nodes)
520                        .enter().append("svg:text")
521                        .attr("class", "tscore")
522                        .attr("x", function(d) { return (d.x + scoreleftmargin); })
[239]523                        .attr("y", function(d) { return d.y + 4; })
[238]524                        .text(function(d) { return d.score; })
525                        .style("fill", '#ff0000')
526                        .style("text-anchor", 'middle')
527                        .style("pointer-events", "none");
[232]528
[238]529                // 繝弱�繝峨∈縺ョ繧ェ繝ウ繝槭え繧ケ縺ァ繝代せ謗「邏「縲√ヱ繧ケ荳ュ縺ョ繝ェ繝ウ繧ッ譁�ュ励r陦ィ遉コ
530                node.on("mouseover", function(d){
[232]531
[238]532                        // 陦ィ遉コ縺吶k繝代せ菫晏ュ倡畑驟榊�
533                        var path = [];
534                        // 繝代せ陦ィ遉コ諠�ア菫晏ュ倡畑驟榊�
535                        var pathname = [];
[232]536
[238]537                        // 縺セ縺壹が繝ウ繝槭え繧ケ縺輔l縺溘ヮ繝シ繝峨�id縺ィ蜷榊燕繧偵◎繧後◇繧瑚ソス蜉
538                        path.push(d.nodeid);
539                        pathname.push(d.name);
[232]540
[238]541                        // 繝代せ謗「邏「
542                        do{
543                                // 繝ェ繝ウ繧ッ縺ョ謨ー縺縺醍ケー繧願ソ斐@
544                                for(var i = 0; i < link.data().length; i++){
545                                        // 迴セ蝨ィ縺ョ譛€蠕悟ーセ縺ォ郢九′繧九Μ繝ウ繧ッ縺後≠繧後�
546                                        if(path[(path.length-1)] == link.data()[i].target){
547                                                // 縺昴�繝ェ繝ウ繧ッ縺ョ繧ス繝シ繧ケ蛛エ繝弱�繝峨�id繧定ソス蜉
548                                                path.push(link.data()[i].source);
549                                                // 縺昴�繝ェ繝ウ繧ッ縺ョ蜷榊燕縺ィ繧ス繝シ繧ケ蛛エ繝弱�繝峨�蜷榊燕繧定ソス蜉
550                                                pathname.push(link.data()[i].property);
551                                                pathname.push(node.data()[link.data()[i].source].name);
552                                        }
553                                }
554                        // 繝ォ繝シ繝医ヮ繝シ繝峨↓霎ソ繧顔捩縺上∪縺ァ郢ー繧願ソ斐☆
555                        }while(path[(path.length-1)] != 0);
[232]556
[238]557                        // 繝ォ繝シ繝医ヮ繝シ繝峨∪縺溘�騾比クュ繝弱�繝峨↑繧�
558                        if(d.nodeid == 0 || d.path == "notend"){
559                                // 繝代せ陦ィ遉コ鬆伜沺繧偵ョ繝輔か繝ォ繝医↓
[239]560                                $('.SBSelectedPath').html('<h1>Please <span style="color: hsl(150, 50%, 75%);">select a leaf node</span> and click to generate a SPARQL</h1>');
[238]561                        // 譛ォ遶ッ繝弱�繝峨↑繧�
562                        }else{
[232]563
[239]564                                // 繝代せ陦ィ遉コ鬆伜沺逕ィ譁�ュ怜�
565                                var resultText = '';
[238]566                                // 繝代せ縺ョ蜷榊燕驟榊�蛻�セ後m縺九i郢ー繧願ソ斐@縺ェ縺後i
567                                for (var i = pathname.length;i > 0; i--){
568                                        // 螂�焚逡ェ逶ョ�医ヮ繝シ繝会シ峨↑繧�
569                                        if(i % 2 == 1){
570                                                // 繝ォ繝シ繝医°騾比クュ縺区忰遶ッ縺九↓蠢懊§縺ヲ繧ッ繝ゥ繧ケ繧呈欠螳壹@霑ス險�
571                                                if(i == 1){
572                                                        resultText = resultText + "<div class=\"SBLeafNode\">" + pathname[i - 1] + "</div>";
573                                                }else if(i == pathname.length){
574                                                        resultText = resultText + "<div class=\"SBRootNode\">" + pathname[i - 1] + "</div>";
575                                                }else{
576                                                        resultText = resultText + "<div class=\"SBPathNode\">" + pathname[i - 1] + "</div>";
577                                                }
578                                        // 蛛カ謨ー逡ェ逶ョ�医Μ繝ウ繧ッ�峨�繝ェ繝ウ繧ッ逕サ蜒上r蜑榊セ後↓縺、縺題ソス險�
579                                        }else{
580                                                resultText = resultText + "<img src=\"images/pathline.png\"><div class=\"SBPathProperty\">" + pathname[i - 1] + "</div><img src=\"images/pathline.png\">";
581                                        }
582                                }
[232]583
[238]584                                // 繝代せ陦ィ遉コ鬆伜沺縺ョ蜀�ョケ繧呈嶌縺肴鋤縺�
585                                $('.SBSelectedPath').html(resultText);
[235]586
[238]587                                // 繧オ繝シ繝悶Ξ繝�ヨ縺ォ騾√j霑斐☆繝代せ繧ェ繝悶ず繧ァ繧ッ繝医r菫晏ュ�
588                                pathobj = d.path;
[232]589
[238]590                                // 繝代せ陦ィ遉コ鬆伜沺縺ョ陦ィ遉コ險ュ螳壹rvisivle縺ォ
591                                $('.SBPath').css('overflow-y', 'visible');
[232]592
[238]593                                // 繝代せ蜀�ョケ縺ョ鬮倥&縺後ヱ繧ケ陦ィ遉コ鬆伜沺繧定カ�∴縺ヲ縺�◆繧�
594                                if($('.SBPath').height() < $('.SBSelectedPath').innerHeight()){
595                                        // 繝代せ陦ィ遉コ鬆伜沺縺ョ陦ィ遉コ險ュ螳壹r繧ケ繧ッ繝ュ繝シ繝ォ縺ォ
596                                        $('.SBPath').css('overflow-y', 'scroll');
597                                }
598                        }
[235]599
[238]600                        // 繧ェ繝ウ繝槭え繧ケ縺輔l縺溘ヮ繝シ繝峨�鬮倥&縺ォ隕ェ繧貞粋繧上○繧九◆繧√↓蜷医o縺帙k鬮倥&繧剃ソ晏ュ�
601                        var movey = d.y;
[232]602
[238]603                        // 蜷�ヮ繝シ繝峨↓蟇セ縺�
604                        node
605                                // 霈ェ驛ュ邱壹�濶イ繧定ィュ螳�
606                                .style("stroke", function(d){
607                                        // 縺セ縺壹�閭梧勹濶イ�医ョ繝輔か繝ォ繝茨シ峨r謖�ョ�
608                                        var strokecolor = "#fafafa";
[232]609
[238]610                                        // 繝代せ縺ョ繝弱�繝画焚縺縺醍ケー繧願ソ斐@縺ェ縺後i
611                                        for(var n = 0; n < path.length; n++){
612                                                // 繝代せ蜀�↓蜷ォ縺セ繧後k繝弱�繝峨□縺」縺溘i
613                                                if(path[n] == d.nodeid){
614                                                        // 霈ェ驛ュ邱壹r襍、縺ォ
615                                                        strokecolor = "#ffaaaa";
616                                                }
617                                        }
[232]618
[238]619                                        // 縺薙%縺セ縺ァ縺ァ蠕励i繧後◆霈ェ驛ュ邱壹�濶イ繧定ソ斐☆
620                                        return strokecolor;
621                                })
622                                // 鬮倥&縺ョ蛟、
623                                .attr("cy", function(d){
[232]624
[238]625                                        // 迴セ蝨ィ縺ョ鬮倥&繧貞叙蠕�
626                                        var currenty = d.y
[232]627
[238]628                                        // 繝代せ縺ョ繝弱�繝画焚縺縺醍ケー繧願ソ斐@縺ェ縺後i
629                                        for(var n = 0; n < path.length; n++){
630                                                // 繝代せ蜀�↓蜷ォ縺セ繧後k繝弱�繝峨□縺」縺溘i
631                                                if(path[n] == d.nodeid){
632                                                        // 蜀�Κ縺ァ謖√▽鬮倥&繧偵が繝ウ繝槭え繧ケ縺輔l縺溘ヮ繝シ繝峨→蜷後§縺ォ�亥�謠冗判譎ゅ↓蜿肴丐��
633                                                        d.y = movey;
634                                                }
635                                        }
[232]636
[238]637                                        // 莉翫�迴セ譎らせ縺ョ鬮倥&繧定ソ斐☆
638                                        return currenty;
639                                });
[232]640
[238]641                        // 蜷�Μ繝ウ繧ッ繝�く繧ケ繝医↓蟇セ縺�
642                        tlink
643                                // 繝�く繧ケ繝郁。ィ遉コ蛻、螳�
644                                .text(function(d) {
645                                        // 繝�ヵ繧ゥ繝ォ繝医〒遨コ繧偵そ繝�ヨ
646                                        var linktext = "";
[232]647
[238]648                                        // 繝代せ縺ョ繝弱�繝画焚縺縺醍ケー繧願ソ斐@縺ェ縺後i
649                                        for(var t = 0; t < path.length; t++){
650                                                // 閾ェ霄ォ縺後◎縺ョ繝弱�繝峨∈謗・邯壹@縺ヲ縺�k繝ェ繝ウ繧ッ縺ェ繧峨�
651                                                if(path[t] == d.target){
652                                                        // 繝ェ繝ウ繧ッ繝�く繧ケ繝医↓繝励Ο繝代ユ繧」縺ョ蛟、繧偵そ繝�ヨ
653                                                        linktext = d.property
654                                                }
655                                        }
656
657                                        // 縺薙%縺セ縺ァ縺ァ縺ァ縺阪◆繝ェ繝ウ繧ッ繝�く繧ケ繝医r霑斐☆
658                                        return linktext;
659                                });
660
[239]661                        // 蜷�Μ繝ウ繧ッ縺ォ蟇セ縺�
662                        link
663                                // 邱壹�濶イ蛻、螳�
664                                .style("stroke", function(d){
[238]665
[239]666                                        var strokecolor = "#999";
[238]667
668                                        // 繝代せ縺ョ繝弱�繝画焚縺縺醍ケー繧願ソ斐@縺ェ縺後i
669                                        for(var t = 0; t < path.length; t++){
670                                                // 閾ェ霄ォ縺後◎縺ョ繝弱�繝峨∈謗・邯壹@縺ヲ縺�k繝ェ繝ウ繧ッ縺ェ繧峨�
671                                                if(path[t] == d.target){
672                                                        // 繝ェ繝ウ繧ッ縺ョ濶イ縺ォ襍、繧偵そ繝�ヨ
673                                                        strokecolor = "#ffaaaa"
674                                                }
675                                        }
676
[239]677                                        // 邱壹�濶イ繧定ソ斐☆
[238]678                                        return strokecolor;
[239]679                                });
[232]680
[239]681                        // 縺薙%縺セ縺ァ縺ョ險ュ螳壹r蜈�↓蜀肴緒逕サ
682                        redraw();
[232]683
[239]684                // 繧ッ繝ェ繝�け縺輔l縺溘→縺�
685                }).on("click", function(d){
686                        // 譛ォ遶ッ繝弱�繝峨↑繧峨せ繝代�繧ッ繝ォ逋コ陦�
687                        if(d.path != "notend"){
688                                generateSPARQL();
689                        }
690                });
[232]691
[239]692                // 蜀肴緒逕サ髢「謨ー
693                var redraw = function (duration){
[232]694
[239]695                        // 縺九¢繧区凾髢薙′譛ェ謖�ョ壹↑繧峨�
696                        if(duration == undefined){
697                                // 0.5遘偵°縺代※繧「繝九Γ繝シ繧キ繝ァ繝ウ
698                                duration = 500;
699                        }
[232]700
[239]701                        // 蜷�Μ繝ウ繧ッ縺ォ縺、縺�※險ュ螳壹&繧後◆菴咲スョ縺ォ蜀肴緒逕サ
702                        link
703                                .transition()
704                                .duration(duration)
705                                .attr("x1", function(d) {return node.data()[d.source].x;})
706                                .attr("y1", function(d) {return node.data()[d.source].y;})
707                                .attr("x2", function(d) {return node.data()[d.target].x;})
708                                .attr("y2", function(d) {return node.data()[d.target].y;});
[232]709
[239]710                        // 蜷�ヮ繝シ繝峨↓縺、縺�※險ュ螳壹&繧後◆菴咲スョ縺ォ蜀肴緒逕サ
711                        node
712                                .transition()
713                                .duration(duration)
714                                .attr("cx", function(d) {return d.x;})
715                                .attr("cy", function(d) {return d.y;});
[232]716
[239]717                        // 蜷�ヮ繝シ繝峨ユ繧ュ繧ケ繝医↓縺、縺�※險ュ螳壹&繧後◆菴咲スョ縺ォ蜀肴緒逕サ縲√ユ繧ュ繧ケ繝域緒逕サ菴咲スョ繧剃ク贋ク九↓謖ッ繧�
718                        tnode
719                                .transition()
720                                .duration(duration)
721                                .attr("x", function(d) {return d.x;})
722                                .attr("y", function(d) {
723                                        // 繝�ヵ繧ゥ繝ォ繝医〒蟆代@荳九£繧�
724                                        var updown = (NODEHEIGHT * 0.4);
725                                        // 螂�焚逡ェ逶ョ縺ョ豺ア縺輔↑繧牙ー代@荳翫£繧�
726                                        if(d.group % 2 == 1){
727                                                updown = -(NODEHEIGHT * 0.2);
728                                        }
729                                        // 縺昴�蛟、繧帝ォ倥&縺ォ霑斐☆縺薙→縺ァ繝�く繧ケ繝域緒逕サ菴咲スョ縺御コ偵>驕輔>縺ォ縺ェ繧�
730                                        return d.y + updown;
731                                });
[232]732
[239]733                        // 蜷�Μ繝ウ繧ッ繝�く繧ケ繝医↓縺、縺�※險ュ螳壹&繧後◆菴咲スョ縺ォ蜀肴緒逕サ
734                        tlink
735                                .transition()
736                                .duration(duration)
737                                .attr("x", function(d) {return (node.data()[d.source].x + node.data()[d.target].x) / 2;})
738                                .attr("y", function(d) {return ((node.data()[d.source].y + node.data()[d.target].y) / 2) + 4;});
[232]739
[239]740                };
[232]741
[239]742                // 蛻晏屓縺ョ縺ソduration繧�縺ィ謖�ョ壹@蜀肴緒逕サ�医い繝九Γ繝シ繧キ繝ァ繝ウ縺ェ縺暦シ�
743                redraw(0);
[232]744
[239]745        }else{
746                // SVG縺ョ蜑企勁
747                d3.select(".SBGraph svg").remove();
748        }
749};
[232]750
751
[239]752// 繝��繧ソ菴懈�繝。繧ス繝�ラ
753make_data = function(){
[232]754
[239]755        // 邨先棡逕ィ繧ェ繝悶ず繧ァ繧ッ繝医r蛻晄悄蛹�
756        ret = new Object();
757        ret['nodes'] = new Array();
758        ret['links'] = new Array();
[232]759
[239]760        // 蜷�ィョ螟画焚縺ョ蛻晄悄蛹�
[232]761        PATHNUM = 0;
762        MAXDEPTH = 0;
763        TREESPACE = 0;
764        DRAWHEIGHT = NODEHEIGHT;
765
[239]766        // 陦ィ遉コ縺吶k繝代せ謨ー
[232]767        var viewnum;
768
[239]769        // jsontext繧貞叙蠕�
[232]770        var obj = jsontext;
771
[239]772        // 邨先棡繝代せ謨ー縺ョ繧ケ繧ソ繧、繝ォ繧偵Μ繧サ繝�ヨ
[237]773        $('.SBResult').css('color', 'black').css('font-weight', 'normal').css('margin-top', '4px');
[232]774
[239]775        // 隍�焚蠖「縺ョs繧偵▽縺代k
[232]776        $('.SBPlural').text('s');
777
[239]778        // 繝代せ縺ョ謨ー縺�縺縺」縺溘i
[232]779        if(obj.length == 0){
[239]780                // 邨先棡繝代せ謨ー縺ョ繧ケ繧ソ繧、繝ォ繧定オ、縺ョ螟ェ蟄励↓縺鈴伜沺蜀�ク贋ク倶クュ螟ョ縺ォ
[237]781                $('.SBResult').css('color', 'red').css('font-weight', 'bold').css('margin-top', '20px');
[239]782                // 隍�焚蠖「縺ョs繧貞炎髯、
[232]783                $('.SBPlural').text('');
[239]784        // 繝代せ謨ー縺�縺ェ繧�
[232]785        }else if(obj.length == 1){
[239]786                // 隍�焚蠖「縺ョs繧貞炎髯、
[232]787                $('.SBPlural').text('');
788        }
789
[239]790        // 繝代せ縺ョ謨ー縺悟香莉・荳九↑繧�
[232]791        if(obj.length <= 10){
[239]792                // 陦ィ遉コ謨ー繧偵ヱ繧ケ謨ー縺ォ
[232]793                viewnum = obj.length;
[239]794                // 邨先棡繝代せ謨ー縺ョ繧ケ繧ソ繧、繝ォ繧帝伜沺蜀�ク贋ク倶クュ螟ョ縺ォ
[237]795                $('.SBResult').css('margin-top', '20px');
[239]796                // 蜈ィ陦ィ遉コ繝懊ち繝ウ繧帝國縺�
[232]797                $('.SBViewall').hide();
[239]798        // 繝ェ繝溘ャ繝医′10縺ェ繧峨�
[232]799        }else if(pathlimit == 10){
[239]800                // 陦ィ遉コ繝代せ謨ー繧�0縺ォ
[232]801                viewnum = 10;
[239]802                // 蜈ィ陦ィ遉コ繝懊ち繝ウ繧貞�縺�
[232]803                $('.SBViewall').show();
[239]804        // 繝ェ繝溘ャ繝医′縺ェ縺代l縺ー
[232]805        }else{
[239]806                // 陦ィ遉コ繝代せ謨ー繧貞�繝代せ謨ー縺ォ
[232]807                viewnum = obj.length;
[239]808                // 邨先棡繝代せ謨ー縺ョ繧ケ繧ソ繧、繝ォ繧帝伜沺蜀�ク贋ク倶クュ螟ョ縺ォ
[237]809                $('.SBResult').css('margin-top', '20px');
[239]810                // 蜈ィ陦ィ遉コ繝懊ち繝ウ繧帝國縺�
[232]811                $('.SBViewall').hide();
812        }
813
[239]814        // 邨先棡繝代せ謨ー縺ョ蛟、繧呈峩譁ー
[232]815        $('.SBPathnum').text(obj.length);
[239]816        // 邨先棡繝代せ謨ー繧定。ィ遉コ
[232]817        $('.SBResult').show();
818
[239]819        // obj繝医ャ繝鈴嚴螻、縺ョ謨ー縺縺醍ケー繧願ソ斐@縺ェ縺後i
820        for(var i = 0; i < viewnum; i++){
821                if(i == 0){
822                        // 蛻晏屓縺縺代Ν繝シ繝医ヮ繝シ繝峨r繝励ャ繧キ繝・
823                        ret['nodes'].push({'name': obj[0]['label'], 'uri': obj[0]['startClass'], 'group': 0, 'x':50, 'y':50, 'nodeid':ret['nodes'].length, 'path': 'notend', 'nodecolor': 'hsl(40, 50%, 75%)'});
824                }
825                // 蜈医↓source縺ォ0�医Ν繝シ繝茨シ峨r莉」蜈・
826                var source = 0;
827                // 蜈ア騾壹Ν繝シ繝亥愛螳壹rtrue縺ォ
828                var isCommon = true;
[232]829
[239]830                // 縺薙�繝代せ縺ョ繧ケ繧ウ繧「繧貞叙蠕�
831                var score = obj[i]['score'];
[232]832
[239]833                // classLinks縺ョ謨ー縺縺醍ケー繧願ソ斐@縺ェ縺後i
834                for(var j = 0;j < obj[i]['classLinks'].length; j++){
[232]835
[239]836                        // 繝ェ繝ウ繧ッ縺ョ蜷榊燕繧旦RL譛ォ蟆セ縺九i蜿門セ�
837                        var propertytext = obj[i]['classLinks'][j]['predicate'];
838                        var propertysplit1 = propertytext.split("/");
839                        var propertysplit2 = propertysplit1[propertysplit1.length - 1];
840                        var propertysplit3 = propertysplit2.split("#");
841                        propertytext = propertysplit3[propertysplit3.length - 1];
[232]842
[239]843                        // 豺ア縺輔′譛€螟ァ繧医j螟ァ縺阪¢繧後�譖エ譁ー
844                        if(MAXDEPTH < j+1){
845                                MAXDEPTH = j+1;
846                        }
847                        // 縺薙%縺セ縺ァ蜈ア騾壹Ν繝シ繝医↑繧�
848                        if(isCommon){
849                                // 莉雁屓繧ょ�騾壹°遒コ隱阪☆繧九◆繧√�繝輔Λ繧ー
850                                var isCommonNow = false;
851                                // nodes驟榊�縺ォ蜷後§linkedClass縺梧里縺ォ縺ゅk縺狗「コ隱�
852                                var targets = [];
853                                for(var k = 0; k < ret['nodes'].length; k++){
854                                        // 蜷碁嚴螻、縺九▽蜷後§蜷榊燕縺ョ繧ゅ�縺後≠縺」縺溘itargets驟榊�縺ォ逡ェ蜿キ繧定ソス蜉
855                                        if(ret['nodes'][k]['group'] == (j+1) && obj[i]['classLinks'][j]['linkedClass'] == ret['nodes'][k]['uri']){
856                                                targets.push(k);
857                                        }
858                                }
[232]859
[239]860                                // 譌「縺ォ縺ゅ▲縺溷エ蜷医�links驟榊�縺ォ蜷後§link縺悟ュ伜惠縺吶k縺狗「コ隱�
861                                if(targets.length != 0){
862                                        // 蜈医⊇縺ゥ隕九▽縺代◆targets縺ョ謨ー縺縺醍ケー繧願ソ斐@縺ェ縺後i
863                                        for(var l = 0; l <targets.length; l++){
864                                                // links驟榊�縺ォ蜈ィ縺丞酔縺俶擅莉カ縺ョ繧ゅ�縺後≠繧九°遒コ隱�
865                                                for(var m = 0; m < ret['links'].length; m++){
866                                                        // 縺ゅ▲縺溷エ蜷井サ雁屓縺ョ繧ゅ�縺ッ霑ス蜉縺帙★source繧呈峩譁ー縺励※谺。縺ク
867                                                        if(ret['links'][m]['source'] == source && ret['links'][m]['target'] == targets[l] && ret['links'][m]['uri'] == obj[i]['classLinks'][j]['predicate'] && !isCommonNow){
868                                                                // 蜈ア騾壹Ν繝シ繝医ヵ繝ゥ繧ー繧偵が繝ウ
869                                                                isCommonNow = true;
870                                                                source = targets[l];
871                                                        }
872                                                }
873                                        }
[232]874
[239]875                                        // 蜷дarget繧堤「コ隱阪@縺ヲ蜈ア騾壹Ν繝シ繝医〒縺ッ縺ェ縺九▲縺溷エ蜷域眠隕剰ソス蜉
876                                        if(!isCommonNow){
877                                                isCommon = false;
878                                                ret['nodes'].push({'name': obj[i]['classLinks'][j]['label'], 'uri': obj[i]['classLinks'][j]['linkedClass'], 'group': (j+1), 'x':0, 'y':0, 'nodeid':ret['nodes'].length, 'path': 'notend', 'nodecolor': '#cccccc'});
879                                                ret['links'].push({'source':source, 'target':ret['nodes'].length - 1, 'property': propertytext, 'uri': obj[i]['classLinks'][j]['predicate']});
880                                                source = ret['nodes'].length - 1;
881                                        }
[232]882
[239]883                                // 縺ェ縺九▲縺溷エ蜷医�蛻・譚。莉カ縺ェ縺ョ縺ァ譁ー隕剰ソス蜉縺励※谺。縺ク
884                                }else{
[232]885
[239]886                                        isCommon = false;
887                                        ret['nodes'].push({'name': obj[i]['classLinks'][j]['label'], 'uri': obj[i]['classLinks'][j]['linkedClass'], 'group': (j+1), 'x':0, 'y':0, 'nodeid':ret['nodes'].length, 'path': 'notend', 'nodecolor': '#cccccc'});
888                                        ret['links'].push({'source':source, 'target':ret['nodes'].length - 1, 'property': propertytext, 'uri': obj[i]['classLinks'][j]['predicate']});
889                                        source = ret['nodes'].length - 1;
890                                }
891                        // 譌「縺ォ蜈ア騾壹Ν繝シ繝医〒縺ェ縺�↑繧画眠隕剰ソス蜉縺励※谺。縺ク
892                        }else{
893                                ret['nodes'].push({'name': obj[i]['classLinks'][j]['label'], 'uri': obj[i]['classLinks'][j]['linkedClass'], 'group': (j+1), 'x':0, 'y':0, 'nodeid':ret['nodes'].length, 'path': 'notend', 'nodecolor': '#cccccc'});
894                                ret['links'].push({'source':source, 'target':ret['nodes'].length - 1, 'property': propertytext, 'uri': obj[i]['classLinks'][j]['predicate']});
895                                source = ret['nodes'].length - 1;
896                        }
[232]897
[239]898                }
899                // 譛€蠕鯉シ域忰遶ッ繝弱�繝会シ峨↓蜷�ィョ蛟、繧定ソス蜉
900                ret['nodes'][ret['nodes'].length - 1]['path'] = obj[i];
901                ret['nodes'][ret['nodes'].length - 1]['score'] = score;
902                ret['nodes'][ret['nodes'].length - 1]['nodecolor'] = 'hsl(150, 50%, 75%)';
903                // 繝代せ謨ー繧定ソス蜉
904                PATHNUM++;
905        }
906        // 繝弱�繝蛾俣縺ョ繧ケ繝壹�繧ケ繧定ィ育ョ�
907        TREESPACE = $('.SBGraph').width() / (MAXDEPTH + 1);
[232]908
[239]909        // 縺ァ縺阪◆邨先棡繧定ソ斐☆
910        return ret;
[232]911};
912
913set_map_location = function(myNodeIndex, nodes, links, depth, fromAngle, toAngle){
914
915    // depth縺梧悴螳夂セゥ縺ェ繧峨�0繧偵そ繝�ヨ
916    if (depth == undefined){
917        depth = 0;
918    }
919
920    // 蜷�ィョ蛻晄悄蛹�
921    var children = undefined;
922    var parent = undefined;
923    var parentsChildren = undefined;
924
925    // links驟榊�縺ョ謨ー縺縺醍ケー繧願ソ斐@縺ェ縺後i
926    for (var i=0; i<links.length; i++){
927        // 縺昴�links縺ョtarget縺稽yNodeIndex縺ェ繧英arent繧偵そ繝�ヨ
928        if (links[i].target == myNodeIndex){
929            parent = links[i].source;
930        }
931    }
932
933    // parent縺瑚ヲ九▽縺九▲縺ヲ縺�◆縺ェ繧峨�
934    if (parent != undefined){
935        // parent縺ィlinks繧呈ク。縺揚et_children繝。繧ス繝�ラ繧貞ョ溯。�
936        parentsChildren = get_children(parent, links);
937    }
938
939    if(myNodeIndex != 0){
940        DRAWHEIGHT += (NODEHEIGHT * 1.5);
941        var x = (depth * TREESPACE) + (TREESPACE / 3);
942        var y = DRAWHEIGHT;
943        nodes[myNodeIndex].x = x;
944        nodes[myNodeIndex].y = y;
945    }else{
946        var x = TREESPACE / 3;
947        var y = (NODEHEIGHT * 1.5) * ((PATHNUM - 1) / 2) + NODEHEIGHT;
948        nodes[myNodeIndex].x = x;
949        nodes[myNodeIndex].y = y;
950    }
951
952    children = get_children(myNodeIndex, links);
953
954    for (var i=0; i<children.length; i++){
955        if(i == 0){
956            DRAWHEIGHT -= (NODEHEIGHT * 1.5);
957        }
958        var child = children[i];
959        set_map_location(child, nodes, links, depth+1, fromAngle + ((toAngle - fromAngle) / children.length) * i, fromAngle + ((toAngle - fromAngle) / children.length) * (i+1));
960    }
961
962};
963
964// 謖�ョ壹&繧後◆隕ェ縺梧戟縺、蟄舌r霑斐☆
965get_children = function(index, links){
966    var children = new Array();
967    // links縺ョ謨ー縺縺醍「コ隱阪@縺ェ縺後i
968    for (var i=0; i<links.length; i++){
969        // 隕ェ縺梧ク。縺輔l縺溯ヲェ縺ィ荳€閾エ縺吶k譎ゅ�蟄舌r霑ス蜉
970        if (links[i].source == index){
971            children.push(links[i].target);
972        }
973    }
974    return children;
975};
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。