チェンジセット 129 : SPARQLBuilderWWW/web/jsgui.html

差分発生行の前後
無視リスト:
更新日時:
2014/08/11 10:48:16 (10 年 前)
更新者:
lenz
ログメッセージ:

ノード上に表示するURIを/及び#で区切った末尾部分のみになるよう短縮

子を持つノードをクリックした際に畳み込む処理を追加

ファイル:
1 変更

凡例:

変更なし
追加
削除
  • SPARQLBuilderWWW/web/jsgui.html

    r124 r129  
    127127        DURATION = 0; 
    128128 
     129        /* 
    129130        // 繝峨Λ繝�げ譎ゅ�蜃ヲ逅� 
    130131        var drag = d3.behavior.drag().on("drag", function(d,i) { 
     
    136137            redraw(); 
    137138        }); 
     139        */ 
    138140 
    139141        // SVG縺ョ霑ス蜉 
     
    156158        .enter().append("line") 
    157159        .attr("class", "link") 
    158         .style("stroke-width", function(d) { return Math.sqrt(d.value); }); 
     160        .style("stroke-width", function(d) { return Math.sqrt(d.value);}); 
    159161 
    160162        // 繝弱�繝峨�菴懈� 
     
    169171        .style("stroke-width", function(d) { return '1.5px'; }) 
    170172        .style("fill", function(d) { return color(d.group); }) 
    171         .style("cursor", function(d) { return 'pointer'; }) 
    172         .call(drag); 
     173        .style("cursor", function(d) { return 'pointer'; }); 
     174        //.call(drag); 
    173175 
    174176        // 繝弱�繝峨ユ繧ュ繧ケ繝医�菴懈� 
     
    184186        .style("stroke-width", function(d) { return '1.5px'; }) 
    185187        .style("text-anchor", function(d) { return 'middle'; }) 
    186         .style("pointer-events", "none") 
    187         .call(drag); 
     188        .style("pointer-events", "none"); 
     189        //.call(drag); 
    188190 
    189191        // 繝ェ繝ウ繧ッ繝�く繧ケ繝医�菴懈� 
     
    229231 
    230232                                document.getElementById("selectpath").innerHTML=(resultText); 
    231                                 document.getElementById("showpath").style.display = "block"; 
    232233 
    233234                                if(d.group > (MAXDEPTH - 2)){ 
     
    249250                                document.getElementById("showpath").style.left = xPosition + "px" 
    250251                                document.getElementById("showpath").style.top = yPosition + "px" 
    251                                 document.getElementById("showpath").style.display = "block"; 
     252                                //document.getElementById("showpath").style.display = "block"; 
    252253 
    253254                        }else{ 
     
    304305                                if(d.view == "no"){ 
    305306                                        for(var t = 0; t < path.length; t++){ 
    306                                                 if(path[t] == d.target){ 
    307                                                         linktext = d.property; 
     307                                                if(path[t] == d.target && node.data()[d.target].view != "hide"){ 
     308                                                        var propertytext = d.property 
     309                                                        var linksplit1 = propertytext.split("/"); 
     310                                                        var linksplit2 = linksplit1[linksplit1.length - 1]; 
     311                                                        var linksplit3 = linksplit2.split("#"); 
     312                                                        linktext = linksplit3[linksplit3.length - 1]; 
    308313                                                        d.view = "now"; 
    309314                                                } 
    310315                                        } 
    311                                 }else if(d.view == "fix"){ 
    312                                         linktext = d.property; 
     316                                }else if(d.view == "fix" && node.data()[d.target].view != "hide"){ 
     317                                        var propertytext = d.property 
     318                                        var linksplit1 = propertytext.split("/"); 
     319                                        var linksplit2 = linksplit1[linksplit1.length - 1]; 
     320                                        var linksplit3 = linksplit2.split("#"); 
     321                                        linktext = linksplit3[linksplit3.length - 1]; 
    313322                                } 
    314323                                return linktext; 
     
    339348                }); 
    340349 
     350                //d.hideparent = d.nodeid; 
     351 
     352                var childs = []; 
     353                var prevchilds = []; 
     354                prevchilds.push(d.nodeid); 
     355 
     356                do{ 
     357                        var tmpchilds = []; 
     358                        var curchilds = []; 
     359                        for(var p = 0; p < prevchilds.length; p++){ 
     360                                tmpchilds = get_children(prevchilds[p], json['links']); 
     361                                curchilds = curchilds.concat(tmpchilds); 
     362                        } 
     363                        prevchilds = curchilds; 
     364                        childs = childs.concat(curchilds); 
     365 
     366                }while(curchilds.length != 0); 
     367 
     368                var childy = d.y; 
     369                for(var c = 0; c < childs.length; c++){ 
     370                        if(node.data()[childs[c]].y < childy){ 
     371                                childy = node.data()[childs[c]].y; 
     372                        } 
     373                } 
     374 
     375                d.y = childy; 
     376 
     377                var maxdy = 0; 
     378                var mindy = 0; 
     379 
     380                for(var c = 0; c < childs.length; c++){ 
     381                        if(node.data()[childs[c]].view != "hide"){ 
     382                                var dy = node.data()[childs[c]].y - d.y; 
     383                                if(dy > maxdy){ 
     384                                        maxdy = dy; 
     385                                } 
     386                                node.data()[childs[c]].x = d.x; 
     387                                node.data()[childs[c]].y = d.y; 
     388                                node.data()[childs[c]].dy = dy; 
     389                                node.data()[childs[c]].view = "hide"; 
     390                                node.data()[childs[c]].hideparent = d.nodeid; 
     391                        }else{ 
     392                                if(node.data()[childs[c]].hideparent == d.nodeid){ 
     393                                        node.data()[childs[c]].x = d.x + (TREESPACE * (node.data()[childs[c]].group - d.group)); 
     394                                        node.data()[childs[c]].y = node.data()[childs[c]].y + node.data()[childs[c]].dy; 
     395                                        if(-node.data()[childs[c]].dy < mindy){ 
     396                                                mindy = -node.data()[childs[c]].dy; 
     397                                        } 
     398                                        node.data()[childs[c]].view = "appear"; 
     399                                        node.data()[childs[c]].hideparent = -1; 
     400                                } 
     401                        } 
     402                } 
     403 
     404                node 
     405                .attr("r", function(d){ 
     406                        if(d.view == "appear"){ 
     407                                d.view = "no"; 
     408                        }else if(d.y > childy){ 
     409                                d.y = d.y - maxdy - mindy; 
     410                        } 
     411                        if(d.view == "hide"){ 
     412                                d.x = node.data()[d.hideparent].x; 
     413                                d.y = node.data()[d.hideparent].y; 
     414                        } 
     415                        if(d.nodeid == 0){ 
     416                                d.y = childy; 
     417                        } 
     418                        return (NODEHEIGHT / 2); 
     419                }); 
     420 
    341421                tlink 
    342422                .text(function(d) { 
    343423                        var linktext = ""; 
    344                         if(d.view == "now" || d.view == "fix"){ 
    345                                 linktext = d.property; 
     424                        if((d.view == "now" || d.view == "fix") && (node.data()[d.target].view != "hide")){ 
     425                                var propertytext = d.property 
     426                                var linksplit1 = propertytext.split("/"); 
     427                                var linksplit2 = linksplit1[linksplit1.length - 1]; 
     428                                var linksplit3 = linksplit2.split("#"); 
     429                                linktext = linksplit3[linksplit3.length - 1]; 
    346430                                d.view = "fix"; 
    347431                        } 
    348432                        return linktext; 
    349433                }); 
     434 
     435 
     436                redraw(); 
    350437 
    351438        }).on("mouseout", function(d){ 
    352439                d.isDrag = false; 
    353440        }); 
    354  
    355         // 蝓コ譛ャ繝吶け繝医Ν邂怜� 
    356         var vec = function(sx, sy, dx, dy){ 
    357                 var vx = (dx - sx); 
    358                 var vy = (dy - sy); 
    359                 var dist = Math.sqrt(Math.pow(vx, 2) + Math.pow(vy, 2)); 
    360                 var ret = []; 
    361                 ret.x = vx / dist; 
    362                 ret.y = vy / dist; 
    363  
    364                 return ret; 
    365         }; 
    366441 
    367442        var redraw = function (){ 
     
    384459                .duration(DURATION) 
    385460                .attr("cx", function(d) {return d.x;}) 
    386                 .attr("cy", function(d) {return d.y;}); 
     461                .attr("cy", function(d) {return d.y;}) 
     462                .style("opacity", function(d){ 
     463                        var opa = 1.0; 
     464                        if(d.view == "hide"){ 
     465                                opa = 0.0; 
     466                        } 
     467                        return opa; 
     468                }) 
     469                .style("fill", function(d) { 
     470                        var fcolor = color(d.group); 
     471 
     472                        for(var n = 0; n < node.data().length; n++){ 
     473                                if(d.nodeid == node.data()[n].hideparent){ 
     474                                        fcolor = "ffaaaa"; 
     475                                } 
     476                        } 
     477                        return fcolor; 
     478                }) 
     479                .style("pointer-events", function(d){ 
     480                        var pe = "auto"; 
     481                        if(d.view == "hide"){ 
     482                                pe = "none"; 
     483                        } 
     484                        return pe; 
     485                }); 
    387486 
    388487                tnode 
     
    395494                                updown = -(NODEHEIGHT * 0.2); 
    396495                        } 
     496                        if(d.view == "now" || d.view == "moved"){ 
     497                                //updown = 5; 
     498                        } 
    397499                        return d.y + updown; 
     500                }) 
     501                .text(function(d){ 
     502                        var nt = d.name; 
     503                        if(d.view == "hide"){ 
     504                                nt = ""; 
     505                        } 
     506                        return nt; 
    398507                }); 
    399508 
    400509                DURATION = 500; 
     510 
    401511        }; 
    402512 
     
    408518                node 
    409519                .style("stroke", function(d){ 
    410                         d.view = "no"; 
     520                        if(d.view != "hide"){ 
     521                                d.view = "no"; 
     522                        } 
    411523                        return "#fafafa"; 
    412524                }); 
     
    499611                                        if(!isCommonNow){ 
    500612                                                isCommon = false; 
    501                                                 ret['nodes'].push({'name':obj['paths'][i]['classLinks'][j]['linkedClassURI'], 'group': (j+1), 'x':0, 'y':0, 'nodeid':ret['nodes'].length, 'view' : 'no'}); 
     613                                                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'}); 
    502614                                                ret['links'].push({'source':source, 'target':ret['nodes'].length - 1, 'value':5, 'property':obj['paths'][i]['classLinks'][j]['propertyURI'], 'view' : 'no'}); 
    503615                                                source = ret['nodes'].length - 1; 
     
    508620 
    509621                                        isCommon = false; 
    510                                         ret['nodes'].push({'name':obj['paths'][i]['classLinks'][j]['linkedClassURI'], 'group': (j+1), 'x':0, 'y':0, 'nodeid':ret['nodes'].length, 'view' : 'no'}); 
     622                                        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'}); 
    511623                                        ret['links'].push({'source':source, 'target':ret['nodes'].length - 1, 'value':5, 'property':obj['paths'][i]['classLinks'][j]['propertyURI'], 'view' : 'no'}); 
    512624                                        source = ret['nodes'].length - 1; 
     
    514626                        // 譌「縺ォ蜈ア騾壹Ν繝シ繝医〒縺ェ縺�↑繧画眠隕剰ソス蜉縺励※谺。縺ク 
    515627                        }else{ 
    516                                 ret['nodes'].push({'name':obj['paths'][i]['classLinks'][j]['linkedClassURI'], 'group': (j+1), 'x':0, 'y':0, 'nodeid':ret['nodes'].length, 'view' : 'no'}); 
     628                                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'}); 
    517629                                ret['links'].push({'source':source, 'target':ret['nodes'].length - 1, 'value':5, 'property':obj['paths'][i]['classLinks'][j]['propertyURI'], 'view' : 'no'}); 
    518630                                source = ret['nodes'].length - 1; 
     
    660772function setSEClass(){ 
    661773 
    662         MAXDEPTH = 0; 
    663  
    664774        var sel = $("*[name=selectendpoint]").val(); 
    665775 
     
    667777                sel = $("*[name=inputendpoint]").val(); 
    668778        } 
     779 
     780        MAXDEPTH = 0; 
    669781 
    670782        document.getElementById("selectpath").innerHTML = ""; 
     
    678790                url : getPathListURL, 
    679791                data: { 
     792                    ep: sel, 
    680793                    startclass: selstart, 
    681                     endclass: selend, 
    682                     ep: sel 
     794                    endclass: selend 
    683795  }, 
    684796                dataType: 'text',