チェンジセット 122 : BH13SPARQLBuilder/src/hozo

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

ノードのクリックで畳み込み等ができるよう改良

ファイル:
1 変更

凡例:

変更なし
追加
削除
  • BH13SPARQLBuilder/src/hozo/maptool/jsgui.html

    r119 r122  
    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].split("#"); 
     311                                                        linktext = linksplit2[linksplit2.length]; 
    308312                                                        d.view = "now"; 
    309313                                                } 
    310314                                        } 
    311                                 }else if(d.view == "fix"){ 
    312                                         linktext = d.property; 
     315                                }else if(d.view == "fix" && node.data()[d.target].view != "hide"){ 
     316                                        var propertytext = d.property 
     317                                        var linksplit1 = propertytext.split("/"); 
     318                                        var linksplit2 = linksplit1[linksplit1.length].split("#"); 
     319                                        linktext = linksplit2[linksplit2.length]; 
    313320                                } 
    314321                                return linktext; 
     
    339346                }); 
    340347 
     348                //d.hideparent = d.nodeid; 
     349 
     350                var childs = []; 
     351                var prevchilds = []; 
     352                prevchilds.push(d.nodeid); 
     353 
     354                do{ 
     355                        var tmpchilds = []; 
     356                        var curchilds = []; 
     357                        for(var p = 0; p < prevchilds.length; p++){ 
     358                                tmpchilds = get_children(prevchilds[p], json['links']); 
     359                                curchilds = curchilds.concat(tmpchilds); 
     360                        } 
     361                        prevchilds = curchilds; 
     362                        childs = childs.concat(curchilds); 
     363 
     364                }while(curchilds.length != 0); 
     365 
     366                var childy = d.y; 
     367                for(var c = 0; c < childs.length; c++){ 
     368                        if(node.data()[childs[c]].y < childy){ 
     369                                childy = node.data()[childs[c]].y; 
     370                        } 
     371                } 
     372 
     373                d.y = childy; 
     374 
     375                var maxdy = 0; 
     376                var mindy = 0; 
     377 
     378                for(var c = 0; c < childs.length; c++){ 
     379                        if(node.data()[childs[c]].view != "hide"){ 
     380                                var dy = node.data()[childs[c]].y - d.y; 
     381                                if(dy > maxdy){ 
     382                                        maxdy = dy; 
     383                                } 
     384                                node.data()[childs[c]].x = d.x; 
     385                                node.data()[childs[c]].y = d.y; 
     386                                node.data()[childs[c]].dy = dy; 
     387                                node.data()[childs[c]].view = "hide"; 
     388                                node.data()[childs[c]].hideparent = d.nodeid; 
     389                        }else{ 
     390                                if(node.data()[childs[c]].hideparent == d.nodeid){ 
     391                                        node.data()[childs[c]].x = d.x + (TREESPACE * (node.data()[childs[c]].group - d.group)); 
     392                                        node.data()[childs[c]].y = node.data()[childs[c]].y + node.data()[childs[c]].dy; 
     393                                        if(-node.data()[childs[c]].dy < mindy){ 
     394                                                mindy = -node.data()[childs[c]].dy; 
     395                                        } 
     396                                        node.data()[childs[c]].view = "appear"; 
     397                                        node.data()[childs[c]].hideparent = -1; 
     398                                } 
     399                        } 
     400                } 
     401 
     402                node 
     403                .attr("r", function(d){ 
     404                        if(d.view == "appear"){ 
     405                                d.view = "no"; 
     406                        }else if(d.y > childy){ 
     407                                d.y = d.y - maxdy - mindy; 
     408                        } 
     409                        if(d.view == "hide"){ 
     410                                d.x = node.data()[d.hideparent].x; 
     411                                d.y = node.data()[d.hideparent].y; 
     412                        } 
     413                        if(d.nodeid == 0){ 
     414                                d.y = childy; 
     415                        } 
     416                        return (NODEHEIGHT / 2); 
     417                }); 
     418 
    341419                tlink 
    342420                .text(function(d) { 
    343421                        var linktext = ""; 
    344                         if(d.view == "now" || d.view == "fix"){ 
    345                                 linktext = d.property; 
     422                        if((d.view == "now" || d.view == "fix") && (node.data()[d.target].view != "hide")){ 
     423                                var propertytext = d.property 
     424                                var linksplit1 = propertytext.split("/"); 
     425                                var linksplit2 = linksplit1[linksplit1.length].split("#"); 
     426                                linktext = linksplit2[linksplit2.length]; 
    346427                                d.view = "fix"; 
    347428                        } 
    348429                        return linktext; 
    349430                }); 
     431 
     432 
     433                redraw(); 
    350434 
    351435        }).on("mouseout", function(d){ 
    352436                d.isDrag = false; 
    353437        }); 
    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         }; 
    366438 
    367439        var redraw = function (){ 
     
    384456                .duration(DURATION) 
    385457                .attr("cx", function(d) {return d.x;}) 
    386                 .attr("cy", function(d) {return d.y;}); 
     458                .attr("cy", function(d) {return d.y;}) 
     459                .style("opacity", function(d){ 
     460                        var opa = 1.0; 
     461                        if(d.view == "hide"){ 
     462                                opa = 0.0; 
     463                        } 
     464                        return opa; 
     465                }) 
     466                .style("fill", function(d) { 
     467                        var fcolor = color(d.group); 
     468 
     469                        for(var n = 0; n < node.data().length; n++){ 
     470                                if(d.nodeid == node.data()[n].hideparent){ 
     471                                        fcolor = "ffaaaa"; 
     472                                } 
     473                        } 
     474                        return fcolor; 
     475                }) 
     476                .style("pointer-events", function(d){ 
     477                        var pe = "auto"; 
     478                        if(d.view == "hide"){ 
     479                                pe = "none"; 
     480                        } 
     481                        return pe; 
     482                }); 
    387483 
    388484                tnode 
     
    395491                                updown = -(NODEHEIGHT * 0.2); 
    396492                        } 
     493                        if(d.view == "now" || d.view == "moved"){ 
     494                                //updown = 5; 
     495                        } 
    397496                        return d.y + updown; 
     497                }) 
     498                .text(function(d){ 
     499                        var nt = d.name; 
     500                        if(d.view == "hide"){ 
     501                                nt = ""; 
     502                        } 
     503                        return nt; 
    398504                }); 
    399505 
    400506                DURATION = 500; 
     507 
    401508        }; 
    402509 
     
    408515                node 
    409516                .style("stroke", function(d){ 
    410                         d.view = "no"; 
     517                        if(d.view != "hide"){ 
     518                                d.view = "no"; 
     519                        } 
    411520                        return "#fafafa"; 
    412521                }); 
     
    499608                                        if(!isCommonNow){ 
    500609                                                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'}); 
     610                                                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'}); 
    502611                                                ret['links'].push({'source':source, 'target':ret['nodes'].length - 1, 'value':5, 'property':obj['paths'][i]['classLinks'][j]['propertyURI'], 'view' : 'no'}); 
    503612                                                source = ret['nodes'].length - 1; 
     
    508617 
    509618                                        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'}); 
     619                                        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'}); 
    511620                                        ret['links'].push({'source':source, 'target':ret['nodes'].length - 1, 'value':5, 'property':obj['paths'][i]['classLinks'][j]['propertyURI'], 'view' : 'no'}); 
    512621                                        source = ret['nodes'].length - 1; 
     
    514623                        // 譌「縺ォ蜈ア騾壹Ν繝シ繝医〒縺ェ縺�↑繧画眠隕剰ソス蜉縺励※谺。縺ク 
    515624                        }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'}); 
     625                                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'}); 
    517626                                ret['links'].push({'source':source, 'target':ret['nodes'].length - 1, 'value':5, 'property':obj['paths'][i]['classLinks'][j]['propertyURI'], 'view' : 'no'}); 
    518627                                source = ret['nodes'].length - 1; 
     
    660769function setSEClass(){ 
    661770 
     771        var sel = $("*[name=selectendpoint]").val(); 
     772 
     773        if(sel == "input"){ 
     774                sel = $("*[name=inputendpoint]").val(); 
     775        } 
     776 
    662777        MAXDEPTH = 0; 
    663778 
     
    672787                url : getPathListURL, 
    673788                data: { 
     789                    ep: sel, 
    674790                    startclass: selstart, 
    675791                    endclass: selend