root/SPARQLBuilderWWW/web/jsgui.html @ 151

リビジョン 151, 26.5 KB (コミッタ: atsuko, 10 年 前)

QueryPathGenerator? にgetFactory を追加

行番号 
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<head>
4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5<title>SPARQL Builder GUI</title>
6
7<style>
8
9.link {
10  stroke: #999;
11  stroke-opacity: .6;
12}
13.tlink {
14  stroke: #999;
15  stroke-opacity: .6;
16}
17
18#showpath {
19        position: absolute;
20        width: 200px;
21        height: auto;
22        padding: 15px;
23        -webkit-border-radius: 20px;
24        border-radius: 20px;
25        -webkit-box-shadow: 0px 0px 10px #000000;
26        box-shadow: 0px 0px 10px #000000;
27        background-image: -moz-linear-gradient(top, #eeeeff, #ffffff);
28        background-image: -ms-linear-gradient(top, #eeeeff, #ffffff);
29        background-image: -o-linear-gradient(top, #eeeeff, #ffffff);
30        background-image: -webkit-gradient(linear, center top, center bottom, from(#eeeeff), to(#ffffff));
31        background-image: -webkit-linear-gradient(top, #eeeeff, #ffffff);
32        background-image: linear-gradient(top, #eeeeff, #ffffff);
33        -webkit-background-clip: padding-box;
34        background-clip: padding-box;
35}
36
37</style>
38
39<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
40<script type="text/javascript" src="d3.min.js"></script>
41<!--<script type="text/javascript" src="http://lod.hozo.jp/SparqlFinder/js/template.js" charset="UTF-8"></script>-->
42<script>
43<!--
44
45// SETURLSETURLSETURLSETURLSETURLSETURLSETURLSETURLSETURLSETURLSETURLSETURL
46// SETURLSETURLSETURLSETURLSETURLSETURLSETURLSETURLSETURLSETURLSETURLSETURL
47
48// 隱ュ縺ソ霎シ縺ソ譎ゅ↓螳溯。後€ゅお繝ウ繝峨�繧、繝ウ繝医�繝ェ繧ケ繝医r騾壼クク縺ョ驟榊�縺ァ霑斐&繧後k縺薙→縺ァ蛻昴a縺ョ驕ク謚櫁い縺ォ謖ソ蜈・
49var getEndPointsURL = "eplist";
50
51// 繧ィ繝ウ繝峨�繧、繝ウ繝医′驕ク謚槭&繧後◆繧峨◎縺ョURL繧弾p縺ィ縺�≧蜷榊燕縺ァ騾∽ソ。縲√け繝ゥ繧ケ繝ェ繧ケ繝医r騾壼クク縺ョ驟榊�縺ァ霑斐&繧後k縺薙→縺ァ繧ッ繝ゥ繧ケ縺ョ驕ク謚櫁い縺ォ謖ソ蜈・
52var getClassListURL = "clist";
53
54// 繧ッ繝ゥ繧ケ莠後▽縺碁∈謚槭&繧後◆繧峨◎縺ョ繧ッ繝ゥ繧ケ蜷阪rstartclass縲‘ndclass縺ィ縺�≧蜷榊燕縺ァ縺昴l縺槭l騾∽ソ。縲√◎縺ョ莠後▽繧堤オ舌�繝代せ縺ョ繝ェ繧ケ繝医rJSON蠖「蠑上�繝�く繧ケ繝医〒霑斐&繧後k縺薙→縺ァ縺昴l繧偵げ繝ゥ繝輔↓謠冗判
55var getPathListURL = "plist";
56
57// 繝代せ縺碁∈謚槭&繧後◆繧泳sonpath縺ィ縺�≧蜷榊燕縺ァ繝代せ繧帝€壼クク縺ョ驟榊�縺ァ騾∽ソ。縲ヾPARQL繧ッ繧ィ繝ェ繧偵ユ繧ュ繧ケ繝医〒蜿励¢蜿悶j繝�く繧ケ繝医お繝ェ繧「縺ォ謖ソ蜈・
58var getSPARQLURL = "sparql";
59
60// 縺ァ縺阪≠縺後▲縺欖PARQL繧帝€∽ソ。縺吶kURL�域悴螳溯」�シ�
61
62// SETURLSETURLSETURLSETURLSETURLSETURLSETURLSETURLSETURLSETURLSETURLSETURL
63// SETURLSETURLSETURLSETURLSETURLSETURLSETURLSETURLSETURLSETURLSETURLSETURL
64
65
66var pathname = [];
67var PATHNUM = 0;
68var MAXDEPTH = 0;
69var TREESPACE = 0;
70var DRAWHEIGHT = 0;
71var NODEHEIGHT = 50;
72var MOUSEMOVED = 0;
73var jsontext = "";
74var DURATION = 0;
75
76
77// 髢九>縺溘i蜷�ィョ繧、繝ウ繧ソ繝シ繝輔ぉ繝シ繧ケ驛ィ蜩√�繧オ繧、繧コ繧貞、画峩縲√お繝ウ繝峨�繧、繝ウ繝井ク€隕ァ繧貞叙蠕励@繧サ繝�ヨ
78$(window).load(function() {
79
80        var menuwidth = window.innerWidth + "px";
81        var inputswidth = ((window.innerWidth - 100) / 2) + "px";
82        document.getElementById("menu").style.width = menuwidth;
83        document.endpoint.inputendpoint.style.width = inputswidth;
84        document.endpoint.selectendpoint.style.width = inputswidth;
85        document.seclass.startclass.style.width = inputswidth;
86        document.seclass.endclass.style.width = inputswidth;
87        document.path.sparql.style.width = inputswidth;
88        document.path.sendsparql.style.width = inputswidth;
89        document.getElementById("graph").style.top = document.getElementById("menu").offsetHeight + "px";
90
91        $.ajax({
92                type: "GET",
93                url : getEndPointsURL,
94                dataType: 'json',
95                success : function(data) {
96                        setEndpoints(data);
97                },
98                error : function(XMLHttpRequest, textStatus, errorThrown) {
99                        alert("繝ェ繧ッ繧ィ繧ケ繝域凾縺ォ縺ェ繧薙i縺九�繧ィ繝ゥ繝シ縺檎匱逕溘@縺セ縺励◆�� + textStatus +":\n" + errorThrown);
100                }
101        });
102
103});
104
105// 謠冗判蜃ヲ逅�
106function view_map(){
107
108        // make_data繝。繧ス繝�ラ縺ョ邨先棡繧貞叙蠕�
109        var json = make_data(0);
110        // 豺ア縺輔r蜿門セ�
111        var dep = MAXDEPTH;
112
113        // 蜃コ譚・荳翫′縺」縺溽オ先棡繧呈ク。縺励※繝槭ャ繝嶺ク翫�繝ュ繧ア繝シ繧キ繝ァ繝ウ繧偵そ繝�ヨ
114        set_map_location(0, json['nodes'], json['links']);
115
116        // SVG縺ョ蟷�→鬮倥&繧定ィュ螳夲シ亥ケ�シ夂判髱「縺�▲縺ア縺�€€鬮倥&�壹ヱ繧ケ縺ョ謨ー縺ォ蠢懊§險ュ螳夲シ�
117        var width = window.innerWidth;
118        var height = ((NODEHEIGHT * 1.5) * PATHNUM) + (NODEHEIGHT / 2);
119
120        // 繧ォ繝ゥ繝シ繧貞叙蠕�
121        var color = d3.scale.category20();
122
123        // SVG縺悟ュ伜惠縺吶k縺ェ繧峨�蜑企勁
124        if (d3.select("#graph").select("svg")) {
125                d3.select("#graph").select("svg").remove();
126        }
127        DURATION = 0;
128
129        /*
130        // 繝峨Λ繝�げ譎ゅ�蜃ヲ逅�
131        var drag = d3.behavior.drag().on("drag", function(d,i) {
132            d.x += d3.event.dx
133            d.y += d3.event.dy
134
135            d. isDrag = true;
136            DURATION = 0;
137            redraw();
138        });
139        */
140
141        // SVG縺ョ霑ス蜉
142        var svg = d3.select("#graph").append("svg")
143            .attr("width", width)
144            .attr("height", height);
145
146        // 閭梧勹縺ョ霑ス蜉
147        var bg = svg
148                .append("rect")
149                .attr("x", 0)
150                .attr("y", 0)
151                .attr("width", width)
152                .attr("height", height)
153                .attr("fill", "#fafafa");
154
155        // 繝ェ繝ウ繧ッ縺ョ菴懈�
156        var link = svg.selectAll(".link")
157        .data(json.links)
158        .enter().append("line")
159        .attr("class", "link")
160        .style("stroke-width", function(d) { return Math.sqrt(d.value);});
161
162        // 繝弱�繝峨�菴懈�
163        var node = svg.selectAll(".node")
164        .data(json.nodes)
165        .enter().append("circle")
166        .attr("class", "node")
167        .attr("r", (NODEHEIGHT / 2))
168        .attr("cx", function(d) { return d.x;} )
169        .attr("cy",  function(d) { return d.y; })
170        .style("stroke", function(d) { return '#fafafa'; })
171        .style("stroke-width", function(d) { return '1.5px'; })
172        .style("fill", function(d) { return color(d.group); })
173        .style("cursor", function(d) { return 'pointer'; });
174        //.call(drag);
175
176        // 繝弱�繝峨ユ繧ュ繧ケ繝医�菴懈�
177        var tnode = svg.selectAll("text.node")
178        .data(json.nodes)
179        .enter().append("svg:text")
180        .attr("class", "tnode")
181        .attr("x", function(d) { return d.x; })
182        .attr("y", function(d) { return d.y; })
183        .text(function(d) {
184                var nodetext = d.name
185                var nodesplit1 = nodetext.split("/");
186                var nodesplit2 = nodesplit1[nodesplit1.length - 1];
187                var nodesplit3 = nodesplit2.split("#");
188                nodetext = nodesplit3[nodesplit3.length - 1];
189                return nodetext;
190        })
191        .style("fill", function(d) { return '#000000'; })
192        //.style("stroke", function(d) { return '#000000'; })
193        //.style("stroke-width", function(d) { return '1.5px'; })
194        .style("text-anchor", function(d) { return 'middle'; })
195        .style("pointer-events", "none");
196        //.call(drag);
197
198        // 繝ェ繝ウ繧ッ繝�く繧ケ繝医�菴懈�
199        var tlink = svg.selectAll("text.link")
200        .data(json.links)
201        .enter().append("svg:text")
202        .attr("class", "tlink")
203        .attr("x", function(d) { return (json.nodes[d.source].x + json.nodes[d.target].x) / 2; })
204        .attr("y", function(d) { return (json.nodes[d.source].y + json.nodes[d.target].y) / 2; })
205        .style("fill", function(d) { return '#000000'; })
206        .style("text-anchor", function(d) { return 'middle'; });
207
208        // 繝弱�繝峨∈縺ョ繧ッ繝ェ繝�け縺ァ繝代せ謗「邏「縲√ヱ繧ケ荳ュ縺ョ繝ェ繝ウ繧ッ譁�ュ励r陦ィ遉コ
209        node.on("mouseover", function(d){
210
211                MOUSEMOVED = 0;
212
213                if(!d.isDrag){
214
215                        var path = [];
216                        pathname = [];
217
218                        if(d.nodeid != 0){
219                                path.push(d.nodeid);
220                                pathname.push(d.name);
221                                do{
222                                        for(var i = 0; i < link.data().length; i++){
223                                                if(path[(path.length-1)] == link.data()[i].target){
224                                                        path.push(link.data()[i].source);
225                                                        pathname.push(link.data()[i].property);
226                                                        pathname.push(node.data()[link.data()[i].source].name);
227                                                }
228                                        }
229                                }while(path[(path.length-1)] != 0);
230                                var resultText = "<h3>Selected Path</h3>";
231                                for (var i = pathname.length;i > 0; i--){
232                                        if(i % 2 == 1){
233                                                resultText = resultText + "<span style=\"font-weight: bold;\">" + pathname[i - 1] + "</span><br><br>";
234                                        }else{
235                                                resultText = resultText + pathname[i - 1] + "<br><br>";
236                                        }
237                                }
238
239                                document.getElementById("selectpath").innerHTML=(resultText);
240
241                                if(d.group > (MAXDEPTH - 2)){
242                                        document.getElementById("getsparqlbutton").style.display = "block";
243                                }else{
244                                        document.getElementById("getsparqlbutton").style.display = "none";
245                                }
246
247                                var xPosition = parseFloat(d3.select(this).attr("cx")) + parseFloat(d3.select(this).style("stroke-width")) + (NODEHEIGHT * 0.5);
248                                var yPosition = parseFloat(d3.select(this).attr("cy") - document.getElementById("showpath").offsetHeight + document.getElementById("menu").offsetHeight) + (NODEHEIGHT * 0.5);
249
250                                if(xPosition < 0){
251                                        xPosition = 0;
252                                }
253                                if(yPosition < 0){
254                                        yPosition = 0;
255                                }
256
257                                document.getElementById("showpath").style.left = xPosition + "px"
258                                document.getElementById("showpath").style.top = yPosition + "px"
259                                document.getElementById("showpath").style.display = "block";
260
261                        }else{
262                                document.getElementById("showpath").style.display = "none";
263                        }
264
265                        var movey = d.y;
266
267                        node
268                        .style("stroke", function(d){
269                                var strokecolor = "#fafafa";
270                                if(d.view == "now"){
271                                        d.view = "no";
272                                }
273                                if(d.view == "moved"){
274                                        d.view = "clicked";
275                                }
276
277                                if(d.view == "no"){
278                                        for(var n = 0; n < path.length; n++){
279                                                if(path[n] == d.nodeid){
280                                                        strokecolor = "#ffaaaa";
281                                                        d.view = "now";
282                                                }
283                                        }
284                                }else if(d.view == "clicked"){
285                                        strokecolor = "#ffaaaa";
286                                        for(var n = 0; n < path.length; n++){
287                                                if(path[n] == d.nodeid){
288                                                        d.view = "moved";
289                                                }
290                                        }
291                                }
292
293                                return strokecolor;
294                        })
295                        .attr("cy", function(d){
296                                if(d.view == "now" || d.view == "moved"){
297                                        var curty = d.y;
298                                        d.y = movey;
299                                        return curty;
300                                }else{
301                                        return d.y;
302                                }
303                        });
304
305                        tlink
306                        .text(function(d) {
307                                var linktext = "";
308                                if(d.view == "now"){
309                                        d.view = "no";
310                                }
311
312                                if(d.view == "no"){
313                                        for(var t = 0; t < path.length; t++){
314                                                if(path[t] == d.target && node.data()[d.target].view != "hide"){
315                                                        var propertytext = d.property
316                                                        var linksplit1 = propertytext.split("/");
317                                                        var linksplit2 = linksplit1[linksplit1.length - 1];
318                                                        var linksplit3 = linksplit2.split("#");
319                                                        linktext = linksplit3[linksplit3.length - 1];
320                                                        d.view = "now";
321                                                }
322                                        }
323                                }else if(d.view == "fix" && node.data()[d.target].view != "hide"){
324                                        var propertytext = d.property
325                                        var linksplit1 = propertytext.split("/");
326                                        var linksplit2 = linksplit1[linksplit1.length - 1];
327                                        var linksplit3 = linksplit2.split("#");
328                                        linktext = linksplit3[linksplit3.length - 1];
329                                }
330                                return linktext;
331                        });
332
333                        link
334                        .style("stroke", function(d){
335                                if(d.view == "no"){
336                                        return "#999";
337                                }else{
338                                        return "#ffaaaa";
339                                }
340                        });
341
342                        redraw();
343                }
344
345        }).on("click", function(d){
346
347                node
348                .style("stroke", function(d) {
349                        var strokecolor = "#fafafa"
350                        if(d.view == "now" || d.view == "clicked" || d.view == "moved"){
351                                strokecolor = "#ffaaaa"
352                                d.view = "clicked";
353                        }
354                        return strokecolor;
355                });
356
357                //d.hideparent = d.nodeid;
358
359                var childs = [];
360                var prevchilds = [];
361                prevchilds.push(d.nodeid);
362
363                do{
364                        var tmpchilds = [];
365                        var curchilds = [];
366                        for(var p = 0; p < prevchilds.length; p++){
367                                tmpchilds = get_children(prevchilds[p], json['links']);
368                                curchilds = curchilds.concat(tmpchilds);
369                        }
370                        prevchilds = curchilds;
371                        childs = childs.concat(curchilds);
372
373                }while(curchilds.length != 0);
374
375                var childy = d.y;
376                for(var c = 0; c < childs.length; c++){
377                        if(node.data()[childs[c]].y < childy){
378                                childy = node.data()[childs[c]].y;
379                        }
380                }
381
382                d.y = childy;
383
384                var maxdy = 0;
385                var mindy = 0;
386
387                for(var c = 0; c < childs.length; c++){
388                        if(node.data()[childs[c]].view != "hide"){
389                                var dy = node.data()[childs[c]].y - d.y;
390                                if(dy > maxdy){
391                                        maxdy = dy;
392                                }
393                                node.data()[childs[c]].x = d.x;
394                                node.data()[childs[c]].y = d.y;
395                                node.data()[childs[c]].dy = dy;
396                                node.data()[childs[c]].view = "hide";
397                                node.data()[childs[c]].hideparent = d.nodeid;
398                        }else{
399                                if(node.data()[childs[c]].hideparent == d.nodeid){
400                                        node.data()[childs[c]].x = d.x + (TREESPACE * (node.data()[childs[c]].group - d.group));
401                                        node.data()[childs[c]].y = node.data()[childs[c]].y + node.data()[childs[c]].dy;
402                                        if(-node.data()[childs[c]].dy < mindy){
403                                                mindy = -node.data()[childs[c]].dy;
404                                        }
405                                        node.data()[childs[c]].view = "appear";
406                                        node.data()[childs[c]].hideparent = -1;
407                                }
408                        }
409                }
410
411                node
412                .attr("r", function(d){
413                        if(d.view == "appear"){
414                                d.view = "no";
415                        }else if(d.y > childy){
416                                d.y = d.y - maxdy - mindy;
417                        }
418                        if(d.view == "hide"){
419                                d.x = node.data()[d.hideparent].x;
420                                d.y = node.data()[d.hideparent].y;
421                        }
422                        if(d.nodeid == 0){
423                                d.y = childy;
424                        }
425                        return (NODEHEIGHT / 2);
426                });
427
428                tlink
429                .text(function(d) {
430                        var linktext = "";
431                        if((d.view == "now" || d.view == "fix") && (node.data()[d.target].view != "hide")){
432                                var propertytext = d.property
433                                var linksplit1 = propertytext.split("/");
434                                var linksplit2 = linksplit1[linksplit1.length - 1];
435                                var linksplit3 = linksplit2.split("#");
436                                linktext = linksplit3[linksplit3.length - 1];
437                                d.view = "fix";
438                        }
439                        return linktext;
440                });
441
442
443                redraw();
444
445        }).on("mouseout", function(d){
446                d.isDrag = false;
447        });
448
449        var redraw = function (){
450                link
451                .transition()
452                .duration(DURATION)
453                .attr("x1", function(d) {return node.data()[d.source].x;})
454                .attr("y1", function(d) {return node.data()[d.source].y;})
455                .attr("x2", function(d) {return node.data()[d.target].x;})
456                .attr("y2", function(d) {return node.data()[d.target].y;});
457
458                tlink
459                .transition()
460                .duration(DURATION)
461                .attr("x", function(d) {return (node.data()[d.source].x + node.data()[d.target].x) / 2;})
462                .attr("y", function(d) {return ((node.data()[d.source].y + node.data()[d.target].y) / 2) + 5;});
463
464                node
465                .transition()
466                .duration(DURATION)
467                .attr("cx", function(d) {return d.x;})
468                .attr("cy", function(d) {return d.y;})
469                .style("opacity", function(d){
470                        var opa = 1.0;
471                        if(d.view == "hide"){
472                                opa = 0.0;
473                        }
474                        return opa;
475                })
476                .style("fill", function(d) {
477                        var fcolor = color(d.group);
478
479                        for(var n = 0; n < node.data().length; n++){
480                                if(d.nodeid == node.data()[n].hideparent){
481                                        fcolor = "ffaaaa";
482                                }
483                        }
484                        return fcolor;
485                })
486                .style("pointer-events", function(d){
487                        var pe = "auto";
488                        if(d.view == "hide"){
489                                pe = "none";
490                        }
491                        return pe;
492                });
493
494                tnode
495                .transition()
496                .duration(DURATION)
497                .attr("x", function(d) {return d.x;})
498                .attr("y", function(d) {
499                        var updown = (NODEHEIGHT * 0.4);
500                        if(d.group % 2 == 1){
501                                updown = -(NODEHEIGHT * 0.2);
502                        }
503                        if(d.view == "now" || d.view == "moved"){
504                                //updown = 5;
505                        }
506                        return d.y + updown;
507                })
508                .text(function(d){
509                        var nt = d.name;
510                        if(d.view == "hide"){
511                                nt = "";
512                        }
513                        return nt;
514                });
515
516                DURATION = 500;
517
518        };
519
520        bg.on("click", function() {
521                document.getElementById("showpath").style.display = "none";
522                d3.selectAll(".node").style("stroke-width", function(d) { return '1.5px'; });
523                d3.selectAll(".node").style("stroke", function(d) { return '#ffffff'; });
524
525                node
526                .style("stroke", function(d){
527                        if(d.view != "hide"){
528                                d.view = "no";
529                        }
530                        return "#fafafa";
531                });
532
533                tlink
534                .text(function(d) {
535                        d.view = "no";
536                        return "";
537                });
538
539                link
540                .style("stroke", function(d){
541                        return "#999";
542                });
543
544        });
545
546        bg.on("mousemove", function(){
547                MOUSEMOVED++;
548                if(MOUSEMOVED > 30){
549                        document.getElementById("showpath").style.display = "none";
550                        MOUSEMOVED = 0;
551                }
552        });
553
554        redraw();
555}
556
557// 繝��繧ソ縺ョ菴懈�繝。繧ス繝�ラ
558function make_data(tdepth, ret, parent, depth){
559        // ret縺梧悴螳夂セゥ縺ェ繧峨�螳夂セゥ縺励※莉」蜈・
560        if (ret == undefined){
561                ret = new Object();
562                ret['nodes'] = new Array();
563                ret['links'] = new Array();
564        }
565
566        PATHNUM = 0;
567        MAXDEPTH = 0;
568        TREESPACE = 0;
569        DRAWHEIGHT = NODEHEIGHT;
570
571        var obj = JSON.parse(jsontext);
572        // obj繝医ャ繝鈴嚴螻、縺ョ謨ー縺縺醍ケー繧願ソ斐@縺ェ縺後i
573        for(var i = 0; i < obj['paths'].length; i++){
574                if(i == 0){
575                        // 蛻晏屓縺縺代Ν繝シ繝医ヮ繝シ繝峨r繝励ャ繧キ繝・
576                        ret['nodes'].push({'name':obj['paths'][0]['startClassURI'], 'group': 0, 'x':50, 'y':50, 'nodeid':ret['nodes'].length, 'view' : 'no'});
577                }
578                // 蜈医↓source縺ォ0�医Ν繝シ繝茨シ峨r莉」蜈・
579                var source = 0;
580                // 蜈ア騾壹Ν繝シ繝亥愛螳壹rtrue縺ォ
581                var isCommon = true;
582
583                // classLinks縺ョ謨ー縺縺醍ケー繧願ソ斐@縺ェ縺後i
584                for(var j = 0;j < obj['paths'][i]['classLinks'].length; j++){
585
586                        if(MAXDEPTH < j+1){
587                                MAXDEPTH = j+1;
588                        }
589                        // 縺薙%縺セ縺ァ蜈ア騾壹Ν繝シ繝医↑繧�
590                        if(isCommon){
591                                // 莉雁屓繧ょ�騾壹°遒コ隱阪☆繧九◆繧√�繝輔Λ繧ー
592                                var isCommonNow = false;
593                                // nodes驟榊�縺ォ蜷後§linkedClass縺梧里縺ォ縺ゅk縺狗「コ隱�
594                                var targets = [];
595                                for(var k = 0; k < ret['nodes'].length; k++){
596                                        // 蜷碁嚴螻、縺九▽蜷後§蜷榊燕縺ョ繧ゅ�縺後≠縺」縺溘itargets驟榊�縺ォ逡ェ蜿キ繧定ソス蜉
597                                        if(ret['nodes'][k]['group'] == (j+1) && obj['paths'][i]['classLinks'][j]['linkedClassURI'] == ret['nodes'][k]['name']){
598                                                targets.push(k);
599                                        }
600                                }
601
602                                // 譌「縺ォ縺ゅ▲縺溷エ蜷医�links驟榊�縺ォ蜷後§link縺悟ュ伜惠縺吶k縺狗「コ隱�
603                                if(targets.length != 0){
604                                        // 蜈医⊇縺ゥ隕九▽縺代◆targets縺ョ謨ー縺縺醍ケー繧願ソ斐@縺ェ縺後i
605                                        for(var l = 0; l <targets.length; l++){
606                                                // links驟榊�縺ォ蜈ィ縺丞酔縺俶擅莉カ縺ョ繧ゅ�縺後≠繧九°遒コ隱�
607                                                for(var m = 0; m < ret['links'].length; m++){
608                                                        // 縺ゅ▲縺溷エ蜷井サ雁屓縺ョ繧ゅ�縺ッ霑ス蜉縺帙★source繧呈峩譁ー縺励※谺。縺ク
609                                                        if(ret['links'][m]['source'] == source && ret['links'][m]['target'] == targets[l] && ret['links'][m]['property'] == obj['paths'][i]['classLinks'][j]['propertyURI'] && !isCommonNow){
610                                                                // 蜈ア騾壹Ν繝シ繝医ヵ繝ゥ繧ー繧偵が繝ウ
611                                                                isCommonNow = true;
612                                                                source = targets[l];
613                                                        }
614                                                }
615                                        }
616
617                                        // 蜷дarget繧堤「コ隱阪@縺ヲ蜈ア騾壹Ν繝シ繝医〒縺ッ縺ェ縺九▲縺溷エ蜷域眠隕剰ソス蜉
618                                        if(!isCommonNow){
619                                                isCommon = false;
620                                                ret['nodes'].push({'name':obj['paths'][i]['classLinks'][j]['linkedClassURI'], 'group': (j+1), 'x':0, 'y':0, 'dy':0, 'nodeid':ret['nodes'].length, 'view' : 'no'});
621                                                ret['links'].push({'source':source, 'target':ret['nodes'].length - 1, 'value':5, 'property':obj['paths'][i]['classLinks'][j]['propertyURI'], 'view' : 'no'});
622                                                source = ret['nodes'].length - 1;
623                                        }
624
625                                // 縺ェ縺九▲縺溷エ蜷医�蛻・譚。莉カ縺ェ縺ョ縺ァ譁ー隕剰ソス蜉縺励※谺。縺ク
626                                }else{
627
628                                        isCommon = false;
629                                        ret['nodes'].push({'name':obj['paths'][i]['classLinks'][j]['linkedClassURI'], 'group': (j+1), 'x':0, 'y':0, 'dy':0, 'nodeid':ret['nodes'].length, 'view' : 'no'});
630                                        ret['links'].push({'source':source, 'target':ret['nodes'].length - 1, 'value':5, 'property':obj['paths'][i]['classLinks'][j]['propertyURI'], 'view' : 'no'});
631                                        source = ret['nodes'].length - 1;
632                                }
633                        // 譌「縺ォ蜈ア騾壹Ν繝シ繝医〒縺ェ縺�↑繧画眠隕剰ソス蜉縺励※谺。縺ク
634                        }else{
635                                ret['nodes'].push({'name':obj['paths'][i]['classLinks'][j]['linkedClassURI'], 'group': (j+1), 'x':0, 'y':0, 'dy':0, 'nodeid':ret['nodes'].length, 'view' : 'no'});
636                                ret['links'].push({'source':source, 'target':ret['nodes'].length - 1, 'value':5, 'property':obj['paths'][i]['classLinks'][j]['propertyURI'], 'view' : 'no'});
637                                source = ret['nodes'].length - 1;
638                        }
639
640                }
641                PATHNUM++;
642        }
643        TREESPACE = (window.innerWidth - 200) / (MAXDEPTH + 1);
644
645        // 縺ァ縺阪◆邨先棡繧定ソ斐☆
646        return ret;
647}
648
649// 逕滓�縺輔l縺溘ョ繝シ繧ソ縺ョ螳滄圀縺ョ繝ュ繧ア繝シ繧キ繝ァ繝ウ繧定ィ育ョ励☆繧九Γ繧ス繝�ラ�亥�蝗槭�myNodeIndex縺�縲]odes縺ォ逕滓�縺輔l縺殤odes驟榊�縲〕inks縺ォ逕滓�縺輔l縺殕inks驟榊�縺梧ク。縺輔l繧具シ�
650function set_map_location(myNodeIndex, nodes, links, depth, fromAngle, toAngle){
651
652        // depth縺梧悴螳夂セゥ縺ェ繧峨�0繧偵そ繝�ヨ
653        if (depth == undefined){
654                depth = 0;
655        }
656/*
657        // fromAngle縺梧悴螳夂セゥ縺ェ繧峨�0繧偵そ繝�ヨ
658        if (fromAngle == undefined){
659                fromAngle = 0;
660        }
661        // toAngle縺梧悴螳夂セゥ縺ェ繧峨�1繧偵そ繝�ヨ
662        if (toAngle == undefined){
663                toAngle = 1;
664        }
665*/
666
667        // 蜷�ィョ蛻晄悄蛹�
668        var children = undefined;
669        var parent = undefined;
670        var parentsChildren = undefined;
671
672        /*
673        ret['nodes'].push({'name':'aaaa', 'group': depth, 'x':(WIDTH/2), 'y':(HEIGHT/2)});
674        ret['links'].push({'source':parent, 'target':newIndex, 'value':5});
675        */
676
677        // links驟榊�縺ョ謨ー縺縺醍ケー繧願ソ斐@縺ェ縺後i
678        for (var i=0; i<links.length; i++){
679                // 縺昴�links縺ョtarget縺稽yNodeIndex縺ェ繧英arent繧偵そ繝�ヨ
680                if (links[i].target == myNodeIndex){
681                        parent = links[i].source;
682                }
683        }
684
685        // parent縺瑚ヲ九▽縺九▲縺ヲ縺�◆縺ェ繧峨�
686        if (parent != undefined){
687                // parent縺ィlinks繧呈ク。縺揚et_children繝。繧ス繝�ラ繧貞ョ溯。�
688                parentsChildren = get_children(parent, links);
689        }
690
691        if(myNodeIndex != 0){
692                DRAWHEIGHT += (NODEHEIGHT * 1.5);
693                var x = (depth * TREESPACE) + (TREESPACE / 3);
694                var y = DRAWHEIGHT;
695                nodes[myNodeIndex].x = x;
696                nodes[myNodeIndex].y = y;
697        }else{
698                var x = TREESPACE / 2;
699                var y = (NODEHEIGHT * 1.5) * ((PATHNUM - 1) / 2) + NODEHEIGHT;
700                nodes[myNodeIndex].x = x;
701                nodes[myNodeIndex].y = y;
702        }
703
704        /*
705        var x = (WIDTH/2) + depth * (WIDTH / (MAXDEPTH * 2 + 1)) * Math.sin(2 * 3.14 * ((toAngle + fromAngle) / 2));
706        var y = (HEIGHT/2) + depth * (HEIGHT / (MAXDEPTH * 2 + 1)) * Math.cos(2 * 3.14 * ((toAngle + fromAngle) / 2));
707        nodes[myNodeIndex].x = x;
708        nodes[myNodeIndex].y = y;
709
710        CIRCLE_SIZE = (WIDTH / (MAXDEPTH * 2 + 1));
711        */
712
713        children = get_children(myNodeIndex, links);
714
715        for (var i=0; i<children.length; i++){
716                if(i == 0){
717                        DRAWHEIGHT -= (NODEHEIGHT * 1.5);
718                }
719                var child = children[i];
720                set_map_location(child, nodes, links, depth+1, fromAngle + ((toAngle - fromAngle) / children.length) * i, fromAngle + ((toAngle - fromAngle) / children.length) * (i+1));
721        }
722
723}
724
725// 謖�ョ壹&繧後◆隕ェ縺梧戟縺、蟄舌r霑斐☆
726function get_children(index, links){
727        var children = new Array();
728        // links縺ョ謨ー縺縺醍「コ隱阪@縺ェ縺後i
729        for (var i=0; i<links.length; i++){
730                // 隕ェ縺梧ク。縺輔l縺溯ヲェ縺ィ荳€閾エ縺吶k譎ゅ�蟄舌r霑ス蜉
731                if (links[i].source == index){
732                        children.push(links[i].target);
733                }
734        }
735        return children;
736}
737
738// ZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZN
739// ZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZN
740
741function setEndpoints(ep){
742        for (var i = 0; i < ep.length; i++){
743                $("*[name=selectendpoint]").append('<option value="' + ep[i] + '">' + ep[i]);
744        }
745}
746
747function setEndpoint(){
748
749        var sel = $("*[name=selectendpoint]").val();
750
751        if(sel == "input"){
752                sel = $("*[name=inputendpoint]").val();
753        }
754
755        document.getElementById("showpath").style.display = "none";
756
757        $.ajax({
758                type: "GET",
759                url : getClassListURL,
760                data: {
761                    ep: sel
762  },
763                dataType: 'json',
764                success : function(epclass) {
765                        $("*[name=startclass] option").remove();
766                        $("*[name=endclass] option").remove();
767                        for (var i = 0; i < epclass.length; i++){
768                                $("*[name=startclass]").append('<option value="' + epclass[i] + '">' + epclass[i]);
769                                $("*[name=endclass]").append('<option value="' + epclass[i] + '">' + epclass[i]);
770                        }
771                },
772                error : function(XMLHttpRequest, textStatus, errorThrown) {
773                        alert("繝ェ繧ッ繧ィ繧ケ繝域凾縺ォ縺ェ繧薙i縺九�繧ィ繝ゥ繝シ縺檎匱逕溘@縺セ縺励◆�� + textStatus +":\n" + errorThrown);
774                }
775        });
776        document.getElementById("seclass").style.display = "block";
777}
778
779function setSEClass(){
780
781        var sel = $("*[name=selectendpoint]").val();
782
783        if(sel == "input"){
784                sel = $("*[name=inputendpoint]").val();
785        }
786
787        MAXDEPTH = 0;
788
789        document.getElementById("selectpath").innerHTML = "";
790        document.getElementById("showpath").style.display = "none";
791
792        var selstart = $("*[name=startclass]").val();
793        var selend = $("*[name=endclass]").val();
794
795        $.ajax({
796                type: "GET",
797                url : getPathListURL,
798                data: {
799                    ep: sel,
800                    startclass: selstart,
801                    endclass: selend
802  },
803                dataType: 'text',
804                success : function(nodes) {
805                        jsontext = nodes;
806                        view_map();
807                },
808                error : function(XMLHttpRequest, textStatus, errorThrown) {
809                        alert("繝ェ繧ッ繧ィ繧ケ繝域凾縺ォ縺ェ繧薙i縺九�繧ィ繝ゥ繝シ縺檎匱逕溘@縺セ縺励◆�� + textStatus +":\n" + errorThrown);
810                }
811        });
812}
813
814function getSPARQL(){
815
816        var selectpath = JSON.stringify(pathname);
817        //document.getElementById("selectpath").innerHTML=(resultText);
818
819        $.ajax({
820                type: "GET",
821                url : getSPARQLURL,
822                data: {
823                    jsonpath: selectpath
824  },
825                dataType: 'text',
826                success : function(sparql) {
827                        document.path.sparql.value = sparql;
828                        document.getElementById("showpath").style.display = "none";
829                        window.scrollTo(0, 0);
830                },
831                error : function(XMLHttpRequest, textStatus, errorThrown) {
832                        alert("繝ェ繧ッ繧ィ繧ケ繝域凾縺ォ縺ェ繧薙i縺九�繧ィ繝ゥ繝シ縺檎匱逕溘@縺セ縺励◆�� + textStatus +":\n" + errorThrown);
833                }
834        });
835}
836
837function sendSPARQL(){
838        var ep = $("*[name=selectendpoint]").val();
839
840        if(ep == "input"){
841                ep = $("*[name=inputendpoint]").val();
842        }
843
844        var query = $("*[name=sparql]").val();
845
846        query = encodeURI(query);
847
848        openpage = ep + "?format=text%2Fhtml&query=" + query;
849
850        window.open(openpage);
851}
852
853// ZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZN
854// ZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZNZN
855
856-->
857
858</script>
859</head>
860<body>
861
862<div id="menu" style="position: absolute; overflow:hidden; top:0px; left:0px; width: 1000px; background-color: #eeeeee;">
863
864        <div id="setting" style="margin: 15px; float: left;">
865                <div id="endpoint">
866                        <form name="endpoint">
867                                <input type="text" style="width: 200px;" name="inputendpoint"><br>
868                                <select size=1 name="selectendpoint" style="width: 200px;">
869                                        <option value="input">Textbox
870                                </select><br>
871                                <input type="button" name="setendpoint" value="SetEndPoint" onClick="setEndpoint()">
872                        </form>
873                </div>
874                <div id="seclass" style="margin-top: 30px;">
875                        <form name="seclass">
876                                StartClass<br>
877                                <select size=1 name="startclass" style="width: 200px;">
878                                </select><br>
879                                EndClass<br>
880                                <select size=1 name="endclass" style="width: 200px;">
881                                </select><br>
882                                <input type="button" name="setclass" value="SetClass" onClick="setSEClass()">
883                        </form>
884                </div>
885        </div>
886
887        <div id="editing" style="margin: 15px 25px; float: right;">
888                <form name="path">
889                        <textarea name="sparql" style="width: 300px; height: 180px;"></textarea><br>
890                        <input type="button" name="sendsparql" value="Send SPARQL" onClick="sendSPARQL()"><br>
891                </form>
892        </div>
893</div>
894<div id="graph" style="position: absolute; top:0px; left:0px;">
895</div>
896<div id="showpath" style="display: none;">
897        <div id="selectpath" style="word-wrap: break-word;">
898        </div>
899        <input type="button" id="getsparqlbutton" name="getsparql" value="Get SPARQL" onClick="getSPARQL()">
900</div>
901</body>
902</html>
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。