root/SPARQLBuilderWWW/web/newsparqlbuilder.js @ 237

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

細かなUI設定の調整

  • 属性 svn:mime-type の設定値 text/plain
行番号 
1
2var PATHNUM = 0;
3var MAXDEPTH = 0;
4var TREESPACE = 0;
5var NODEHEIGHT = 0;
6var DRAWHEIGHT = 0;
7var MOUSEMOVED = 0;
8
9var endpoint = "";
10var startclass= "";
11var endclass = "";
12
13var defendpoint = "";
14var defstartclass= "";
15var defendclass = "";
16
17var jsontext = "";
18var pathobj = "";
19
20var pathlimit = 10;
21
22
23// 繝壹�繧ク隱ュ縺ソ霎シ縺ソ縺悟ョ御コ�ャ。隨ャ螳溯。�
24$(function(){
25
26        // 繝壹�繧ク縺ョ繝代�繝�Κ蛻�r霑ス蜉
27        initparts();
28
29        getParameter();
30
31        if(defendpoint != "" && defstartclass != "" && defendclass != ""){
32                openSPARQLBuilder();
33        }
34
35});
36
37function initparts(){
38        var sbdiv = $('div#SPARQLBUILDER');
39        if(sbdiv.find('div').length == 0){
40                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>';
41                var sbmodal = '<div class="SBModalView"><div class="SBModalContents"><div class="SBSelects"><select class="SBEndPointSelect"></select><select class="SBStartClassSelect"></select><select class="SBEndClassSelect"></select><input type="button" class="SBSaveESE" value="PermaLink" onClick="openPermalink()"></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" onClick="viewAll()"></div><div class="SBGraph"><div class="SBAjaxLoad"><div class="SBLoadIcon"><img src="images/ajax-loader.gif"></div></div></div><div class="SBSelectedPath"></div><div class="SBModalButtons"><input type="button" class="SBModalButton" value="Close" onclick="closeSPARQLBuilder()"></div></div>';
42
43                sbdiv.html(sbtop);
44                $('body').append(sbmodal);
45        }
46
47        $('.SBModalView').click(function(){
48                $(this).fadeOut(700);
49        });
50
51        $('.SBModalContents').click(function(){
52                event.stopPropagation();
53        });
54
55        loadEndPointList();
56
57        $(".SBEndPointSelect").change(function() {
58                changeEndPoint();
59        });
60
61        $(".SBStartClassSelect").change(function() {
62                startClass = $(".SBStartClassSelect").val();
63                loadPathList();
64        });
65        $(".SBEndClassSelect").change(function() {
66                endClass = $(".SBEndClassSelect").val();
67                loadPathList();
68        });
69
70        d3.select('.SBModalView').on("mousewheel", function(){
71                event.preventDefault();
72        });
73
74}
75
76
77function getParameter()
78{
79    if( 1 < window.location.search.length )
80    {
81        var query = window.location.search.substring( 1 );
82        var parameters = query.split( '&' );
83
84        for( var i = 0; i < parameters.length; i++ )
85        {
86            var element = parameters[ i ].split( '=' );
87            if(decodeURIComponent( element[ 0 ] ) == "ep"){
88                defendpoint = decodeURIComponent( element[ 1 ] )
89            }else if(decodeURIComponent( element[ 0 ] ) == "st"){
90                defstartclass = decodeURIComponent( element[ 1 ] )
91            }else if(decodeURIComponent( element[ 0 ] ) == "en"){
92                defendclass = decodeURIComponent( element[ 1 ] )
93            }
94        }
95    }
96}
97
98
99function openSPARQLBuilder(){
100
101        $('.SBModalView').css('top', $(window).scrollTop()).css('height', window.innerHeight).fadeIn();
102
103        resizeModalView();
104
105        $(".SBEndPointSelect").select2();
106        $(".SBStartClassSelect").select2();
107        $(".SBEndClassSelect").select2();
108
109        if(defendpoint != "" && defstartclass != "" && defendclass != ""){
110
111                $('.SBStartClassSelect').on('lccomplete', function(){
112                        $('.SBStartClassSelect').val(defstartclass);
113                        defstartclass = "";
114                        $('.SBEndClassSelect').val(defendclass);
115                        defendclass = "";
116
117                        $(".SBEndPointSelect").select2();
118                        $(".SBStartClassSelect").select2();
119                        $(".SBEndClassSelect").select2();
120
121                        $('.SBStartClassSelect').unbind('lccomplete');
122                });
123
124                loadPathList();
125
126                var eplist = $('.SBEndPointSelect option');
127
128                if(eplist.length == 0){
129                        $('.SBEndPointSelect').on('epcomplete', function(){
130                                $('.SBEndPointSelect').val(defendpoint);
131                                defendpoint = "";
132                                loadClassList();
133                                $('.SBEndPointSelect').unbind('epcomplete');
134                        });
135                }else{
136                        $('.SBEndPointSelect').val(defendpoint);
137                        defendpoint = "";
138                        loadClassList();
139                }
140        }
141}
142
143function resizeModalView(){
144
145        if($('.SBModalView').css('display') == 'block'){
146                var mvw = $('.SBModalContents').width();
147                var mvh = $('.SBModalContents').height();
148                $('.SBModalContents .SBForms').css('width', (mvw - 201) + 'px').css('height', 56 + 'px');
149                $('.SBModalContents .SBMessage').css('width', 200 + 'px').css('height', 56 + 'px');
150                $('.SBModalContents .SBGraph').css('width', (mvw - 201) + 'px').css('height', (mvh - 57) + 'px');
151                $('.SBModalContents .SBPath').css('width', 180 + 'px').css('height', (mvh - 77 - 26) + 'px');
152                $('.SBModalContents .SBModalButtons').css('width', 200 + 'px').css('height', '26px');
153
154                var selw = Math.floor($('.SBModalContents .SBSelects').width());
155
156                if(selw % 2 == 1){
157                        selw--;
158                }
159                $('.SBModalContents .SBSelects').css('width', selw);
160        }
161}
162
163function openSample(ep, st, en){
164        defendpoint = ep;
165        defstartclass = st;
166        defendclass = en;
167
168        openSPARQLBuilder();
169}
170
171function openPermalink(){
172        var baseurl = location.href;
173        var spliturl = baseurl.split('?');
174        var url = spliturl[0] + "?ep=" + encodeURIComponent(endpoint) + "&st=" + encodeURIComponent(startclass) + "&en=" + encodeURIComponent(endclass);
175
176        window.open(url);
177}
178
179function closeSPARQLBuilder(){
180        $('.SBModalView').fadeOut();
181}
182
183function switchLoadIcon(mode) {
184        if(mode == "view"){
185                $('.SBAjaxLoad').show();
186        }else{
187                $('.SBAjaxLoad').hide();
188        }
189};
190
191function loadEndPointList(){
192        $('.SBSaveESE').attr('disabled', true);
193        var url = 'http://www.sparqlbuilder.org/api/eplist';
194        $.ajax({
195                url: url,
196                success: function(data) {
197                        var list = eval(data);
198                        $(".SBEndPointSelect").empty();
199                        $(".SBEndPointSelect").append('<option value="SBDefault">SELECT EndPoint</option>');
200                        for (var i = 0; i < list.length; ++i) {
201                                $(".SBEndPointSelect").append('<option value="' + list[i] + '">' + list[i] + '</option>');
202                                switchLoadIcon("hide");
203                                if($('.SBModalView').attr('display') == 'block'){
204                                        $(".SBEndPointSelect").select2();
205                                        $(".SBStartClassSelect").select2();
206                                        $(".SBEndClassSelect").select2();
207                                }
208                        }
209                        $(".SBEndPointSelect").trigger(new $.Event('epcomplete'));
210                },
211        });
212}
213
214changeEndPoint = function() {
215        endpoint = $(".SBEndPointSelect").val();
216        if(endpoint != "SBDefault"){
217                loadClassList();
218        }
219};
220
221loadClassList = function() {
222        $('.SBSaveESE').attr('disabled', true);
223        var url = "http://www.sparqlbuilder.org/api/clist?ep=" + encodeURIComponent(endpoint);
224        $.ajax({
225                type : "GET",
226                url : url,
227                async : false,
228                success : function(data) {
229                        var list = eval(data);
230                        $(".SBStartClassSelect").empty();
231                        $(".SBEndClassSelect").empty();
232                        $(".SBStartClassSelect").append('<option value="SBDefault">SELECT StartClass</option>');
233                        $(".SBEndClassSelect").append('<option value="SBDefault">SELECT EndClass</option>');
234                        for (var i = 0; i < list.length; ++i) {
235                                $(".SBStartClassSelect").append('<option value="' + list[i]['uri'] + '">' + list[i]['label'] + ' (' + list[i]['number'] + ')' + '</option>');
236                                $(".SBEndClassSelect").append('<option value="' + list[i]['uri'] + '">' + list[i]['label'] + ' (' + list[i]['number'] + ')' + '</option>');
237                        }
238                        $(".SBStartClassSelect").select2();
239                        $(".SBEndClassSelect").select2();
240                        $(".SBStartClassSelect").trigger(new $.Event('lccomplete'));
241                }
242        });
243};
244
245loadPathList = function() {
246        startclass = $(".SBStartClassSelect").val();
247        endclass = $(".SBEndClassSelect").val();
248
249        if(defendpoint != "" && defstartclass != "" && defendclass != ""){
250                endpoint = defendpoint;
251                startclass = defstartclass;
252                endclass = defendclass;
253        }
254
255        $('.SBSaveESE').attr('disabled', true);
256        if (startclass == null || endclass == null || startclass == "SBDefault" || endclass == "SBDefault"){
257                return;
258        }
259
260        pathlimit = 10;
261
262        $('.SBResult').hide();
263        $('.SBViewAll').hide();
264        $('.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><img src=\"images/pathline.png\" style="display:none;">');
265
266        var url = "http://www.sparqlbuilder.org/api/plist?ep=" + encodeURIComponent(endpoint)
267                                                                                                                        + "&startclass=" + encodeURIComponent(startclass)
268                                                                                                                        + "&endclass="   + encodeURIComponent(endclass);
269        //var self = this;
270        switchLoadIcon("view");
271        setTimeout(function(){
272                $.ajax({
273                        type : "GET",
274                        url : url,
275                        //async : false,
276                        timeout : 1000000,
277                        success : function(data) {
278                                jsontext = data;
279                                view_map();
280                                switchLoadIcon("hide");
281                                $('.SBSaveESE').attr('disabled', false);
282                        },
283                        error: function(data){
284                                switchLoadIcon("hide");
285                                alert("error: ", data);
286                        }
287                });
288        }, 100);
289};
290
291function viewAll(){
292        pathlimit = 0;
293        view_map();
294}
295
296generateSPARQL = function() {
297    var path = JSON.stringify(pathobj);
298    var url = 'http://www.sparqlbuilder.org/api/sparql?path=' + encodeURIComponent(path);
299    $.ajax({
300        type: "GET",
301        url : url,
302        dataType: 'text',
303        async: false,
304        success : function(data) {
305            $(".SBSparqlArea").val(data);
306            closeSPARQLBuilder();
307        }
308    });
309};
310
311function sendSPARQL(){
312        var sendep = $(".SBEndPointSelect").val();
313
314        var query = $(".SBSparqlArea").val();
315
316        if(sendep == "SBDefault" || query == ""){
317                return;
318        }
319
320        query = encodeURIComponent(query);
321
322        openpage = sendep + "?format=text%2Fhtml&query=" + query;
323
324        window.open(openpage);
325}
326
327function downloadResult(){
328
329        var sendep = $(".SBEndPointSelect").val();
330
331        var query = $(".SBSparqlArea").val();
332
333        if(sendep == "SBDefault" || query == ""){
334                return;
335        }
336
337        qr = sendQuery(sendep,query);
338
339        qr.fail(
340                function (xhr, textStatus, thrownError) {
341                        alert("Error: A '" + textStatus+ "' occurred.");
342                }
343        );
344        qr.done(
345                function (d) {
346                        downloadCSV(d.results.bindings);
347                }
348        );
349}
350
351function downloadCSV(data){
352
353        if (data instanceof Array) {
354                var result_txt ="";
355
356                var i=0;
357                for ( var key in data[0]) {
358                        if(i>0){result_txt +=",";}
359                        result_txt += key;
360                        i++;
361                }
362
363                result_txt += "\n";
364
365                for (var d = 0; d < data.length; d++) {
366                        var i = 0;
367                        for ( var key in data[d]) {
368                                if(i>0){result_txt +=",";}
369                                result_txt += data[d][key].value;
370                                i++;
371                        }
372                        result_txt += '\n';
373                }
374
375                var blob = new Blob( [result_txt], {type: 'text/plain'} )
376
377                var link = document.createElement('a')
378                link.href = URL.createObjectURL(blob)
379                link.download = 'result' + '.csv'
380
381                document.body.appendChild(link) // for Firefox
382                link.click()
383                document.body.removeChild(link) // for Firefox
384        }
385};
386
387view_map = function(){
388
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                });
676
677            // 蜷�Μ繝ウ繧ッ縺ォ蟇セ縺�
678            link
679                // 邱壹�濶イ蛻、螳�
680                .style("stroke", function(d){
681                    // 陦ィ遉コ繝輔Λ繧ー縺系o縺ェ繧峨�
682                    if(d.view == "no"){
683                        // 濶イ繧偵ョ繝輔か繝ォ繝医↓
684                        return "#999";
685                    // 縺昴l莉・螟厄シ亥崋螳壹d繧ェ繝ウ繝槭え繧ケ縺輔l縺溘ヱ繧ケ縺ォ蜷ォ縺セ繧後k�峨↑繧�
686                    }else{
687                        // 濶イ繧定オ、縺ォ
688                        return "#ffaaaa";
689                    }
690                });
691
692            // 縺薙%縺セ縺ァ縺ョ險ュ螳壹r蜈�↓蜀肴緒逕サ
693            redraw();
694
695        // 繝弱�繝峨∈縺ョ繧ッ繝ェ繝�け縺ァ驕ク謚槫崋螳壼喧�亥所縺ウ謚倥j逡ウ縺ソ蜃ヲ逅�シ�
696        }).on("click", function(d){
697
698            // 蜷�ヮ繝シ繝峨↓蟇セ縺�
699            node
700                // 霈ェ驛ュ邱壹�蛻、螳�
701                .style("stroke", function(d) {
702                    // 繝�ヵ繧ゥ繝ォ繝医�濶イ繧偵そ繝�ヨ
703                    var strokecolor = "#fafafa"
704                    // 陦ィ遉コ繝輔Λ繧ー縺後が繝ウ繝槭え繧ケ荳ュ繝サ蝗コ螳壻クュ繝サ遘サ蜍穂クュ�磯∈謚槭&繧後※縺�k繝弱�繝会シ峨↑繧峨�
705                    if(d.view == "now" || d.view == "clicked" || d.view == "moved"){
706                        // 濶イ繧定オ、縺ォ
707                        strokecolor = "#ffaaaa"
708                        // 陦ィ遉コ繝輔Λ繧ー繧貞崋螳壻クュ縺ォ
709                        d.view = "clicked";
710                    }
711                    // 縺薙%縺セ縺ァ縺ァ縺ァ縺阪◆濶イ繧定ソ斐☆
712                    return strokecolor;
713                });
714
715            // 蜷�Μ繝ウ繧ッ縺ォ蟇セ縺�
716            tlink
717                // 繝�く繧ケ繝郁。ィ遉コ蛻、螳�
718                .text(function(d) {
719                    // 繝�ヵ繧ゥ繝ォ繝医〒遨コ縺ォ
720                    var linktext = "";
721                    // 陦ィ遉コ繝輔Λ繧ー縺檎樟蝨ィ陦ィ遉コ荳ュ縺セ縺溘�蝗コ螳壼喧貂医∩縺ェ繧峨��医°縺、謚倥j逡ウ縺ソ荳ュ縺ァ縺ェ縺代l縺ー��
722                    if((d.view == "now" || d.view == "fix") && (node.data()[d.target].view != "hide")){
723                        // 繝ェ繝ウ繧ッ繝�く繧ケ繝医↓繝励Ο繝代ユ繧」縺ョ蛟、繧偵そ繝�ヨ
724                        linktext = d.property
725                        // 陦ィ遉コ繝輔Λ繧ー繧貞崋螳壻クュ縺ォ
726                        d.view = "fix";
727                    }
728                    // 繝�く繧ケ繝医r霑斐☆
729                    return linktext;
730                });
731
732            // 縺薙%縺セ縺ァ縺ョ蜃ヲ逅�オ先棡繧貞�縺ォ蜀肴緒逕サ
733            redraw();
734
735        });
736
737        // 蜀肴緒逕サ髢「謨ー
738        var redraw = function (duration){
739
740            // 縺九¢繧区凾髢薙′譛ェ謖�ョ壹↑繧峨�
741            if(duration == undefined){
742                // 0.5遘偵°縺代※繧「繝九Γ繝シ繧キ繝ァ繝ウ
743                duration = 500;
744            }
745
746            // 蜷�Μ繝ウ繧ッ縺ォ縺、縺�※險ュ螳壹&繧後◆菴咲スョ縺ォ蜀肴緒逕サ
747            link
748                .transition()
749                .duration(duration)
750                .attr("x1", function(d) {return node.data()[d.source].x;})
751                .attr("y1", function(d) {return node.data()[d.source].y;})
752                .attr("x2", function(d) {return node.data()[d.target].x;})
753                .attr("y2", function(d) {return node.data()[d.target].y;});
754
755            // 蜷�ヮ繝シ繝峨↓縺、縺�※險ュ螳壹&繧後◆菴咲スョ縺ォ蜀肴緒逕サ�医°縺、謚倥j縺溘◆縺セ繧御クュ縺ョ蝣エ蜷医�謠冗判蛻�イ仙�逅�シ�
756            node
757                .transition()
758                .duration(duration)
759                .attr("cx", function(d) {return d.x;})
760                .attr("cy", function(d) {return d.y;});
761
762            // 蜷�ヮ繝シ繝峨ユ繧ュ繧ケ繝医↓縺、縺�※險ュ螳壹&繧後◆菴咲スョ縺ォ蜀肴緒逕サ縲√ユ繧ュ繧ケ繝域緒逕サ菴咲スョ繧剃ク贋ク九↓謖ッ繧具シ医°縺、謚倥j縺溘◆縺セ繧御クュ縺ョ蝣エ蜷医�謠冗判蛻�イ仙�逅�シ�
763            tnode
764            .transition()
765            .duration(duration)
766            .attr("x", function(d) {return d.x;})
767            .attr("y", function(d) {
768                // 繝�ヵ繧ゥ繝ォ繝医〒蟆代@荳九£繧�
769                var updown = (self.NODEHEIGHT * 0.4);
770                // 螂�焚逡ェ逶ョ縺ョ豺ア縺輔↑繧牙ー代@荳翫£繧�
771                if(d.group % 2 == 1){
772                    updown = -(self.NODEHEIGHT * 0.2);
773                }
774                // 縺昴�蛟、繧帝ォ倥&縺ォ霑斐☆縺薙→縺ァ繝�く繧ケ繝域緒逕サ菴咲スョ縺御コ偵>驕輔>縺ォ縺ェ繧�
775                return d.y + updown;
776            });
777
778            // 蜷�Μ繝ウ繧ッ繝�く繧ケ繝医↓縺、縺�※險ュ螳壹&繧後◆菴咲スョ縺ォ蜀肴緒逕サ
779            tlink
780                .transition()
781                .duration(duration)
782                .attr("x", function(d) {return (node.data()[d.source].x + node.data()[d.target].x) / 2;})
783                .attr("y", function(d) {return ((node.data()[d.source].y + node.data()[d.target].y) / 2) + 5;});
784
785        };
786
787        // 閭梧勹驛ィ蛻�′繧ッ繝ェ繝�け縺輔l縺溘i陦ィ遉コ縺ョ蝗コ螳壼喧繧定ァ」髯、
788        bg.on("click", function() {
789            // 繝��繝ォ繝√ャ繝励r髱櫁。ィ遉コ
790            $('.SBTooltip').hide();
791            d3.selectAll(".node").style("stroke-width", function(d) { return '1.5px'; });
792            d3.selectAll(".node").style("stroke", function(d) { return '#ffffff'; });
793
794            // 蜷�ヮ繝シ繝峨�霈ェ驛ュ邱壹�濶イ繧偵ョ繝輔か繝ォ繝医↓
795            node
796                .style("stroke", function(d){
797                    if(d.view != "hide"){
798                        d.view = "no";
799                    }
800                    return "#fafafa";
801                });
802
803            // 繝ェ繝ウ繧ッ繝�く繧ケ繝医r蜈ィ縺ヲ遨コ縺ォ
804            tlink
805                .text(function(d) {
806                    d.view = "no";
807                    return "";
808                });
809
810            // 繝ェ繝ウ繧ッ縺ョ濶イ繧貞�縺ヲ繝�ヵ繧ゥ繝ォ繝医↓
811            link
812                .style("stroke", function(d){
813                    return "#999";
814                });
815
816            /*
817            if(svg.attr("width") == width){
818                    svg.attr("width", (width / 5))
819                    .attr("height", (width * 9 / 16 / 5))
820                    .attr("viewBox", "0 0 " + width + " " + (width * 9 / 16));
821            }else{
822                    svg.attr("width", width)
823                    .attr("height", height)
824                    .attr("viewBox", "0 0 " + width + " " + height);
825            }
826            */
827
828        });
829
830        // 閭梧勹荳翫〒繝槭え繧ケ縺悟虚縺上#縺ィ縺ォ
831        bg.on("mousemove", function(){
832            // MOUSEMOVED繧定ソス蜉�医ヮ繝シ繝峨↓繧ェ繝ウ繝槭え繧ケ縺輔l繧句コヲ縺ォ繧ォ繧ヲ繝ウ繝医Μ繧サ繝�ヨ��
833                MOUSEMOVED++;
834            // 30繧定カ�∴縺溘i
835            if(MOUSEMOVED > 30){
836                // 繝��繝ォ繝√ャ繝励r髱櫁。ィ遉コ縺ォ縺励※繧ォ繧ヲ繝ウ繝医Μ繧サ繝�ヨ
837                $('.SBTooltip').hide();
838                MOUSEMOVED = 0;
839            }
840        });
841
842        // 蛻晏屓縺ョ縺ソduration繧�縺ィ謖�ョ壹@蜀肴緒逕サ�医い繝九Γ繝シ繧キ繝ァ繝ウ縺ェ縺暦シ�
843        redraw(0);
844
845    }else{
846        // SVG縺ョ蜑企勁
847        d3.select(".SBGraph svg").remove();
848    }
849};
850
851make_data = function(tdepth, ret, parent, depth){
852        // ret縺梧悴螳夂セゥ縺ェ繧峨�螳夂セゥ縺励※莉」蜈・
853        if (ret == undefined){
854                ret = new Object();
855                ret['nodes'] = new Array();
856                ret['links'] = new Array();
857        }
858
859        PATHNUM = 0;
860        MAXDEPTH = 0;
861        TREESPACE = 0;
862        NODEHEIGHT = 50;
863        DRAWHEIGHT = NODEHEIGHT;
864
865        var viewnum;
866
867        var obj = jsontext;
868
869        $('.SBResult').css('color', 'black').css('font-weight', 'normal').css('margin-top', '4px');
870
871        $('.SBPlural').text('s');
872
873        if(obj.length == 0){
874                $('.SBResult').css('color', 'red').css('font-weight', 'bold').css('margin-top', '20px');
875                $('.SBPlural').text('');
876        }else if(obj.length == 1){
877                $('.SBPlural').text('');
878        }
879
880        if(obj.length <= 10){
881                viewnum = obj.length;
882                $('.SBResult').css('margin-top', '20px');
883                $('.SBViewall').hide();
884        }else if(pathlimit == 10){
885                viewnum = 10;
886                $('.SBViewall').show();
887        }else{
888                viewnum = obj.length;
889                $('.SBResult').css('margin-top', '20px');
890                $('.SBViewall').hide();
891        }
892
893        $('.SBPathnum').text(obj.length);
894        $('.SBResult').show();
895
896    // obj繝医ャ繝鈴嚴螻、縺ョ謨ー縺縺醍ケー繧願ソ斐@縺ェ縺後i
897    for(var i = 0; i < viewnum; i++){
898        if(i == 0){
899            // 蛻晏屓縺縺代Ν繝シ繝医ヮ繝シ繝峨r繝励ャ繧キ繝・
900            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': 'hsl(40, 50%, 75%)'});
901        }
902        // 蜈医↓source縺ォ0�医Ν繝シ繝茨シ峨r莉」蜈・
903        var source = 0;
904        // 蜈ア騾壹Ν繝シ繝亥愛螳壹rtrue縺ォ
905        var isCommon = true;
906
907        var score = obj[i]['score'];
908
909        // classLinks縺ョ謨ー縺縺醍ケー繧願ソ斐@縺ェ縺後i
910        for(var j = 0;j < obj[i]['classLinks'].length; j++){
911
912            // 繝ェ繝ウ繧ッ縺ョ蜷榊燕繧旦RL譛ォ蟆セ縺九i蜿門セ�
913            var propertytext = obj[i]['classLinks'][j]['predicate'];
914            var propertysplit1 = propertytext.split("/");
915            var propertysplit2 = propertysplit1[propertysplit1.length - 1];
916            var propertysplit3 = propertysplit2.split("#");
917            propertytext = propertysplit3[propertysplit3.length - 1];
918
919            if(MAXDEPTH < j+1){
920                MAXDEPTH = j+1;
921            }
922            // 縺薙%縺セ縺ァ蜈ア騾壹Ν繝シ繝医↑繧�
923            if(isCommon){
924                // 莉雁屓繧ょ�騾壹°遒コ隱阪☆繧九◆繧√�繝輔Λ繧ー
925                var isCommonNow = false;
926                // nodes驟榊�縺ォ蜷後§linkedClass縺梧里縺ォ縺ゅk縺狗「コ隱�
927                var targets = [];
928                for(var k = 0; k < ret['nodes'].length; k++){
929                    // 蜷碁嚴螻、縺九▽蜷後§蜷榊燕縺ョ繧ゅ�縺後≠縺」縺溘itargets驟榊�縺ォ逡ェ蜿キ繧定ソス蜉
930                    if(ret['nodes'][k]['group'] == (j+1) && obj[i]['classLinks'][j]['linkedClass'] == ret['nodes'][k]['uri']){
931                        targets.push(k);
932                    }
933                }
934
935                // 譌「縺ォ縺ゅ▲縺溷エ蜷医�links驟榊�縺ォ蜷後§link縺悟ュ伜惠縺吶k縺狗「コ隱�
936                if(targets.length != 0){
937                    // 蜈医⊇縺ゥ隕九▽縺代◆targets縺ョ謨ー縺縺醍ケー繧願ソ斐@縺ェ縺後i
938                    for(var l = 0; l <targets.length; l++){
939                        // links驟榊�縺ォ蜈ィ縺丞酔縺俶擅莉カ縺ョ繧ゅ�縺後≠繧九°遒コ隱�
940                        for(var m = 0; m < ret['links'].length; m++){
941                            // 縺ゅ▲縺溷エ蜷井サ雁屓縺ョ繧ゅ�縺ッ霑ス蜉縺帙★source繧呈峩譁ー縺励※谺。縺ク
942                            if(ret['links'][m]['source'] == source && ret['links'][m]['target'] == targets[l] && ret['links'][m]['uri'] == obj[i]['classLinks'][j]['predicate'] && !isCommonNow){
943                                // 蜈ア騾壹Ν繝シ繝医ヵ繝ゥ繧ー繧偵が繝ウ
944                                isCommonNow = true;
945                                source = targets[l];
946                            }
947                        }
948                    }
949
950                    // 蜷дarget繧堤「コ隱阪@縺ヲ蜈ア騾壹Ν繝シ繝医〒縺ッ縺ェ縺九▲縺溷エ蜷域眠隕剰ソス蜉
951                    if(!isCommonNow){
952                        isCommon = false;
953                        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'});
954                        ret['links'].push({'source':source, 'target':ret['nodes'].length - 1, 'value':5, 'property': propertytext, 'uri': obj[i]['classLinks'][j]['predicate'], 'view' : 'no'});
955                        source = ret['nodes'].length - 1;
956                    }
957
958                // 縺ェ縺九▲縺溷エ蜷医�蛻・譚。莉カ縺ェ縺ョ縺ァ譁ー隕剰ソス蜉縺励※谺。縺ク
959                }else{
960
961                    isCommon = false;
962                    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'});
963                    ret['links'].push({'source':source, 'target':ret['nodes'].length - 1, 'value':5, 'property': propertytext, 'uri': obj[i]['classLinks'][j]['predicate'], 'view' : 'no'});
964                    source = ret['nodes'].length - 1;
965                }
966            // 譌「縺ォ蜈ア騾壹Ν繝シ繝医〒縺ェ縺�↑繧画眠隕剰ソス蜉縺励※谺。縺ク
967            }else{
968                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'});
969                ret['links'].push({'source':source, 'target':ret['nodes'].length - 1, 'value':5, 'property': propertytext, 'uri': obj[i]['classLinks'][j]['predicate'], 'view' : 'no'});
970                source = ret['nodes'].length - 1;
971            }
972
973        }
974        ret['nodes'][ret['nodes'].length - 1]['path'] = obj[i];
975        ret['nodes'][ret['nodes'].length - 1]['score'] = score;
976        ret['nodes'][ret['nodes'].length - 1]['nodecolor'] = 'hsl(150, 50%, 75%)';
977        PATHNUM++;
978    }
979    TREESPACE = $('.SBGraph').width() / (MAXDEPTH + 1);
980
981    // 縺ァ縺阪◆邨先棡繧定ソ斐☆
982    return ret;
983};
984
985set_map_location = function(myNodeIndex, nodes, links, depth, fromAngle, toAngle){
986
987    // depth縺梧悴螳夂セゥ縺ェ繧峨�0繧偵そ繝�ヨ
988    if (depth == undefined){
989        depth = 0;
990    }
991
992    // 蜷�ィョ蛻晄悄蛹�
993    var children = undefined;
994    var parent = undefined;
995    var parentsChildren = undefined;
996
997    // links驟榊�縺ョ謨ー縺縺醍ケー繧願ソ斐@縺ェ縺後i
998    for (var i=0; i<links.length; i++){
999        // 縺昴�links縺ョtarget縺稽yNodeIndex縺ェ繧英arent繧偵そ繝�ヨ
1000        if (links[i].target == myNodeIndex){
1001            parent = links[i].source;
1002        }
1003    }
1004
1005    // parent縺瑚ヲ九▽縺九▲縺ヲ縺�◆縺ェ繧峨�
1006    if (parent != undefined){
1007        // parent縺ィlinks繧呈ク。縺揚et_children繝。繧ス繝�ラ繧貞ョ溯。�
1008        parentsChildren = get_children(parent, links);
1009    }
1010
1011    if(myNodeIndex != 0){
1012        DRAWHEIGHT += (NODEHEIGHT * 1.5);
1013        var x = (depth * TREESPACE) + (TREESPACE / 3);
1014        var y = DRAWHEIGHT;
1015        nodes[myNodeIndex].x = x;
1016        nodes[myNodeIndex].y = y;
1017    }else{
1018        var x = TREESPACE / 3;
1019        var y = (NODEHEIGHT * 1.5) * ((PATHNUM - 1) / 2) + NODEHEIGHT;
1020        nodes[myNodeIndex].x = x;
1021        nodes[myNodeIndex].y = y;
1022    }
1023
1024    children = get_children(myNodeIndex, links);
1025
1026    for (var i=0; i<children.length; i++){
1027        if(i == 0){
1028            DRAWHEIGHT -= (NODEHEIGHT * 1.5);
1029        }
1030        var child = children[i];
1031        set_map_location(child, nodes, links, depth+1, fromAngle + ((toAngle - fromAngle) / children.length) * i, fromAngle + ((toAngle - fromAngle) / children.length) * (i+1));
1032    }
1033
1034};
1035
1036// 謖�ョ壹&繧後◆隕ェ縺梧戟縺、蟄舌r霑斐☆
1037get_children = function(index, links){
1038    var children = new Array();
1039    // links縺ョ謨ー縺縺醍「コ隱阪@縺ェ縺後i
1040    for (var i=0; i<links.length; i++){
1041        // 隕ェ縺梧ク。縺輔l縺溯ヲェ縺ィ荳€閾エ縺吶k譎ゅ�蟄舌r霑ス蜉
1042        if (links[i].source == index){
1043            children.push(links[i].target);
1044        }
1045    }
1046    return children;
1047};
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。