root/SPARQLBuilderWWW/web/newsparqlbuilder.js @ 234

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

トップページを追加、同じコードで動くようjsを一部改造

トップページの飾り付けは未実装

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