oop_II-6/EHEC_Server/EHEC_Server/alchemy/alchemy.min.js

3 lines
64 KiB
JavaScript
Raw Normal View History

2018-07-14 19:58:18 +02:00
(function(){"Alchemy.js is a graph drawing application for the web.\nCopyright (C) 2014 GraphAlchemist, Inc.\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU Affero General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU Affero General Public License for more details.\n\nYou should have received a copy of the GNU Affero General Public License\nalong with this program. If not, see <http://www.gnu.org/licenses/>.\nlets";var a,b,c,d,e,f,g,h,i,j,k,l,m=[].slice,n=function(a,b){return function(){return a.apply(b,arguments)}};a=function(){function a(a){null==a&&(a=null),this.a=this,this.version="0.4.1",this.get=new this.Get(this),this.remove=new this.Remove(this),this.create=new this.Create(this),this.set=new this.Set(this),this.drawing={DrawEdge:c(this),DrawEdges:d(this),DrawNode:e(this),DrawNodes:f(this),EdgeUtils:this.EdgeUtils(this),NodeUtils:this.NodeUtils(this)},this.controlDash=this.controlDash(this),this.stats=this.stats(this),this.layout=j,this.clustering=b,this.models={Node:this.Node(this),Edge:this.Edge(this)},this.utils={warnings:new l(this)},this.filters=this.filters(this),this.exports=this.exports(this),this.visControls={},this.styles={},this.editor={},this.log={},this.state={interactions:"default",layout:"default"},this.startGraph=this.startGraph(this),this.updateGraph=this.updateGraph(this),this.generateLayout=this.generateLayout(this),this.svgStyles=this.svgStyles(this),this.interactions=this.interactions(this),this.search=this.search(this),this.plugins=this.plugins(this),this._nodes={},this._edges={},this.getNodes=this.get.getNodes,this.getEdges=this.get.getEdges,this.allNodes=this.get.allNodes,this.allEdges=this.get.allEdges,a&&this.begin(a)}return a.prototype.begin=function(b){var c;switch(c=this.setConf(b),typeof this.conf.dataSource){case"string":d3.json(this.a.conf.dataSource,this.a.startGraph);break;case"object":this.a.startGraph(this.a.conf.dataSource)}return this.plugins.init(),a.prototype.instances.push(this),this},a.prototype.setConf=function(a){var b,c;null!=a.theme&&(a=_.merge(_.cloneDeep(this.defaults),this.a.themes[""+a.theme]));for(b in a)switch(c=a[b],b){case"clusterColors":a.clusterColours=c;break;case"backgroundColor":a.backgroundColour=c;break;case"nodeColor":a[nodeColour]=c}return this.a.conf=_.merge(_.cloneDeep(this.defaults),a)},a.prototype.instances=[],a.prototype.getInst=function(b){var c;return c=parseInt(d3.select(b).attr("alchInst")),a.prototype.instances[c]},a}(),k="undefined"!=typeof exports&&null!==exports?exports:this,k.Alchemy=a,k.alchemy={begin:function(b){return k.alchemy=new a(b)}},a.prototype.Create=function(){function a(a){this.a=a}return a.prototype.nodes=function(){var a,b,c,d,e,f,g;for(c=arguments[0],d=2<=arguments.length?m.call(arguments,1):[],a=this.a,e=function(b){var c;return a._nodes[b.id]?console.warn("A node with the id "+b.id+" already exists.\nConsider using the @a.get.nodes() method to \nretrieve the node and then using the Node methods."):(c=new a.models.Node(b),a._nodes[b.id]=c,[c])},d=_.union(d,c),f=0,g=d.length;g>f;f++)b=d[f],e(b);return this.a.initial?this.a.updateGraph():void 0},a.prototype.edges=function(){var a,b,c,d,e;return c=arguments[0],d=2<=arguments.length?m.call(arguments,1):[],a=this.a,e=function(b){var c,d;return b.id&&!a._edges[b.id]?(c=new a.models.Edge(b),a._edges[b.id]=[c],[c]):b.id&&a._edges[b.id]?console.warn("An edge with that id "+someEdgeMap.id+" already exists.\nConsider using the @a.get.edge() method to \nretrieve the edge and then using the Edge methods.\nNote: id's are not required for edges. Alchemy will create\nan unlimited number of edges for the same source and target node.\nSimply omit 'id' when creating the edge."):(d=a._edges[""+b.source+"-"+b.target],d?(c=new a.models.Edge(b,d.length),d
return b.force.on("tick",b.layout.tick).start(),b.elements.nodes.svg.attr("transform",function(a){return"translate("+a.x+", "+a.y+")"})}},a.prototype.defaults={plugins:null,renderer:"svg",graphWidth:function(){return d3.select(this.divSelector).node().parentElement.clientWidth},graphHeight:function(){return"BODY"===d3.select(this.divSelector).node().parentElement.nodeName?window.innerHeight:d3.select(this.divSelector).node().parentElement.clientHeight},alpha:.5,collisionDetection:!0,nodeOverlap:25,fixNodes:!1,fixRootNodes:!1,forceLocked:!0,linkDistancefn:"default",nodePositions:null,showEditor:!1,captionToggle:!1,toggleRootNodes:!1,removeElement:!1,cluster:!1,clusterKey:"cluster",clusterColours:d3.shuffle(["#DD79FF","#FFFC00","#00FF30","#5168FF","#00C0FF","#FF004B","#00CDCD","#f83f00","#f800df","#ff8d8f","#ffcd00","#184fff","#ff7e00"]),clusterControl:!1,nodeStats:!1,edgeStats:!1,edgeFilters:!1,nodeFilters:!1,edgesToggle:!1,nodesToggle:!1,zoomControls:!1,nodeCaption:"caption",nodeCaptionsOnByDefault:!1,nodeStyle:{all:{radius:10,color:"#68B9FE",borderColor:"#127DC1",borderWidth:function(a,b){return b/3},captionColor:"#FFFFFF",captionBackground:null,captionSize:12,selected:{color:"#FFFFFF",borderColor:"#349FE3"},highlighted:{color:"#EEEEFF"},hidden:{color:"none",borderColor:"none"}}},nodeColour:null,nodeMouseOver:"caption",nodeRadius:10,nodeTypes:null,rootNodes:"root",rootNodeRadius:15,nodeClick:null,edgeCaption:"caption",edgeCaptionsOnByDefault:!1,edgeStyle:{all:{width:4,color:"#CCC",opacity:.2,directed:!0,curved:!0,selected:{opacity:1},highlighted:{opacity:1},hidden:{opacity:0}}},edgeTypes:null,curvedEdges:!1,edgeWidth:function(){return 4},edgeOverlayWidth:20,directedEdges:!1,edgeArrowSize:5,edgeClick:null,search:!1,searchMethod:"contains",backgroundColour:"#000000",theme:null,afterLoad:"afterLoad",divSelector:"#alchemy",dataSource:null,initialScale:1,initialTranslate:[0,0],scaleExtent:[.5,2.4],exportSVG:!1,dataWarning:"default",warningMessage:"There be no data! What's going on?"},c=function(a){return{a:a,createLink:function(a){var b;return b=this.a.conf,a.append("path").attr("class","edge-line").attr("id",function(a){return"path-"+a.id}),a.filter(function(a){return null!=a.caption}).append("text"),a.append("path").attr("class","edge-handler").style("stroke-width",""+b.edgeOverlayWidth).style("opacity","0")},styleLink:function(a){var b,c,d;return b=this.a,c=this.a.conf,d=this.a.drawing.EdgeUtils,a.each(function(a){var b,e,f,g,h,i,j,k,l;return f=d.edgeWalk(a),e=c.curvedEdges?30:0,b=e/10,k=a.source.radius+a["stroke-width"]/2,l=e/10,j=f.edgeLength/2,g=f.edgeLength-(a.target.radius-a.target["stroke-width"]/2),h=e/10,i=d3.select(this),i.style(d.edgeStyle(a)),i.attr("transform","translate("+a.source.x+", "+a.source.y+") rotate("+f.edgeAngle+")"),i.select(".edge-line").attr("d",function(){var d,f,i;return f="M"+k+","+l+"q"+j+","+e+" "+g+","+h,c.directedEdges?(i=2*a["stroke-width"],d="l"+-i+","+(i+b)+" l"+i+","+(-i-b)+" l"+-i+","+(-i+b),f+d):f}()),i.select(".edge-handler").attr("d",function(){return i.select(".edge-line").attr("d")})})},classEdge:function(a){return a.classed("active",!0)},styleText:function(a){var b,c,d;return b=this.a.conf,c=b.curvedEdges,d=this.a.drawing.EdgeUtils,a.select("text").each(function(a){var c,e;return e=d.edgeWalk(a),c=e.edgeLength/2,d3.select(this).attr("dx",""+c).text(a.caption).attr("xlink:xlink:href","#path-"+a.source.id+"-"+a.target.id).style("display",function(){return b.edgeCaptionsOnByDefault?"block":void 0})})},setInteractions:function(a){var b;return b=this.a.interactions,a.select(".edge-handler").on("click",b.edgeClick).on("mouseover",function(a){return b.edgeMouseOver(a)}).on("mouseout",function(a){return b.edgeMouseOut(a)})}}},d=function(a){return{a:a,createEdge:function(a){var b,c;return b=this.a.drawing.DrawEdge,c=this.a.vis.selectAll("g.edge").data(a),c.enter().append("g").attr("id",function(a){return"edge-"+a.id+"-"+a.pos}).attr("class",function(a){return"edge "+a.edgeType}).attr("source-target",function(a){return""+a.source.id+"-"+a.target.id}),b.createLink(c),b.classEdge(c),b.sty
},color:function(){return"#68B9FE"},borderColor:function(){return"#127DC1"},borderWidth:function(a,b){return b/3},captionColor:function(){return"#FFFFFF"},captionBackground:function(){return null},captionSize:12,selected:{color:function(){return"#FFFFFF"},borderColor:function(){return"38DD38"}},highlighted:{color:function(){return"#EEEEFF"}},hidden:{color:function(){return"none"},borderColor:function(){return"none"}}}},edgeStyle:{all:{width:4,color:"#333",opacity:.4,directed:!1,curved:!1,selected:{color:"#38DD38",opacity:.9},highlighted:{color:"#383838",opacity:.7},hidden:{opacity:0}}}}},a.prototype.exports=function(a){var b;return b=a,{init:function(){return b.exports.show()},show:function(){return b.dash.select("#all-exports").append("li").attr({"class":"list-group-item active-label toggle"}).html("SVG").on("click",function(){var a,c,d,e,f;return d=d3.select(""+b.conf.divSelector+" svg").node(),c=(new XMLSerializer).serializeToString(d),e="data:image/svg+xml;utf8,"+c,a=e.replace("xlink:",""),f=window.open(a),f.focus()})}}},l=function(){function a(a){this.dataWarning=n(this.dataWarning,this),this.a=a}return a.prototype.dataWarning=function(){return this.a.conf.dataWarning&&"function"==typeof this.a.conf.dataWarning?this.a.conf.dataWarning():"default"===this.a.conf.dataWarning?console.log("No dataSource was loaded"):void 0},a.prototype.divWarning=function(){return"create an element that matches the value for 'divSelector' in your conf.\nFor instance, if you are using the default 'divSelector' conf, simply provide\n<div id='#alchemy'></div>."},a}()}).call(this);