@zklogic/draw.io
Version:
Draw.IO - Graph Editor integration in Angular-cli
1 lines • 4.92 kB
JavaScript
!function(){var e=mxGuide.prototype.move;mxGuide.prototype.move=function(i,t,n,h){var r=t.y,s=t.x,l=!1,o=!1;if(null!=this.states&&null!=i&&null!=t){var u=this,d=new mxCellState,x=this.graph.getView().scale,g=Math.max(2,this.getGuideTolerance()/2);d.x=i.x+s,d.y=i.y+r,d.width=i.width,d.height=i.height;for(var y=[],a=[],f=0;f<this.states.length;f++){var p=this.states[f];p instanceof mxCellState&&(!h&&this.graph.isCellSelected(p.cell)||((d.x>=p.x&&d.x<=p.x+p.width||p.x>=d.x&&p.x<=d.x+d.width)&&(d.y>p.y+p.height+4||d.y+d.height+4<p.y)?y.push(p):(d.y>=p.y&&d.y<=p.y+p.height||p.y>=d.y&&p.y<=d.y+d.height)&&(d.x>p.x+p.width+4||d.x+d.width+4<p.x)&&a.push(p)))}var w=0,v=0,m=0,P=0,b=0,c=0,A=0,V=0,G=5*x;if(y.length>1){y.push(d),y.sort((function(e,i){return e.y-i.y}));var H=!1,C=d==y[0],k=d==y[y.length-1];if(!C&&!k)for(f=1;f<y.length-1;f++)if(d==y[f]){var E=y[f-1];m=v=P=((U=y[f+1]).y-E.y-E.height-d.height)/2;break}for(f=0;f<y.length-1;f++){E=y[f];var S=y[f+1],D=d==E||d==S,I=S.y-E.y-E.height;if(H|=d==E,0==v&&0==w)v=I,w=1;else if(Math.abs(v-I)<=(D||1==f&&H?g:0))w+=1;else{if(w>1&&H){y=y.slice(0,f+1);break}if(!(y.length-f>=3)||H)break;w=0,m=v=0!=P?P:0,y.splice(0,0==f?1:f),f=-1}0!=m||D||(v=m=I)}3==y.length&&y[1]==d&&(m=0)}if(a.length>1){if(a.push(d),a.sort((function(e,i){return e.x-i.x})),H=!1,C=d==a[0],k=d==a[a.length-1],!C&&!k)for(f=1;f<a.length-1;f++)if(d==a[f]){E=a[f-1],A=c=V=((U=a[f+1]).x-E.x-E.width-d.width)/2;break}for(f=0;f<a.length-1;f++){E=a[f],S=a[f+1],D=d==E||d==S;var O=S.x-E.x-E.width;if(H|=d==E,0==c&&0==b)c=O,b=1;else if(Math.abs(c-O)<=(D||1==f&&H?g:0))b+=1;else{if(b>1&&H){a=a.slice(0,f+1);break}if(!(a.length-f>=3)||H)break;b=0,A=c=0!=V?V:0,a.splice(0,0==f?1:f),f=-1}0!=A||D||(c=A=O)}3==a.length&&a[1]==d&&(A=0)}var T=function(e,i,t,n){var h=[],r=0,s=0;if(n?(r=G,s=0):(r=0,s=G),h.push(new mxPoint(e.x-r,e.y-s)),h.push(new mxPoint(e.x+r,e.y+s)),h.push(e),h.push(i),h.push(new mxPoint(i.x-r,i.y-s)),h.push(new mxPoint(i.x+r,i.y+s)),null!=t)return t.points=h,t;var l=new mxPolyline(h,mxConstants.GUIDE_COLOR,mxConstants.GUIDE_STROKEWIDTH);return l.dialect=mxConstants.DIALECT_SVG,l.pointerEvents=!1,l.init(u.graph.getView().getOverlayPane()),l},M=function(e,i){if(e&&null!=u.guidesArrHor)for(var t=0;t<u.guidesArrHor.length;t++)u.guidesArrHor[t].node.style.visibility="hidden";if(i&&null!=u.guidesArrVer)for(t=0;t<u.guidesArrVer.length;t++)u.guidesArrVer[t].node.style.visibility="hidden"};if(b>1&&b==a.length-1){var X=[],Y=u.guidesArrHor,_=[],L=0,R=a[K=a[0]==d?1:0].y+a[K].height;if(A>0)for(f=0;f<a.length-1;f++)E=a[f],S=a[f+1],d==E?(L=S.x-E.width-A,_.push(new mxPoint(L+E.width+G,R)),_.push(new mxPoint(S.x-G,R))):d==S?(_.push(new mxPoint(E.x+E.width+G,R)),L=E.x+E.width+A,_.push(new mxPoint(L-G,R))):(_.push(new mxPoint(E.x+E.width+G,R)),_.push(new mxPoint(S.x-G,R)));else{E=a[0];var U=a[2];L=E.x+E.width+(U.x-E.x-E.width-d.width)/2,_.push(new mxPoint(E.x+E.width+G,R)),_.push(new mxPoint(L-G,R)),_.push(new mxPoint(L+d.width+G,R)),_.push(new mxPoint(U.x-G,R))}for(f=0;f<_.length;f+=2)(z=T(_[f],_[f+1],null!=Y?Y[f/2]:null)).node.style.visibility="visible",z.redraw(),X.push(z);for(f=_.length/2;null!=Y&&f<Y.length;f++)Y[f].destroy();u.guidesArrHor=X,s=L-i.x,l=!0}else M(!0);if(w>1&&w==y.length-1){X=[],Y=u.guidesArrVer;var K,W=[],j=0,q=y[K=y[0]==d?1:0].x+y[K].width;if(m>0)for(f=0;f<y.length-1;f++)E=y[f],S=y[f+1],d==E?(j=S.y-E.height-m,W.push(new mxPoint(q,j+E.height+G)),W.push(new mxPoint(q,S.y-G))):d==S?(W.push(new mxPoint(q,E.y+E.height+G)),j=E.y+E.height+m,W.push(new mxPoint(q,j-G))):(W.push(new mxPoint(q,E.y+E.height+G)),W.push(new mxPoint(q,S.y-G)));else E=y[0],U=y[2],j=E.y+E.height+(U.y-E.y-E.height-d.height)/2,W.push(new mxPoint(q,E.y+E.height+G)),W.push(new mxPoint(q,j-G)),W.push(new mxPoint(q,j+d.height+G)),W.push(new mxPoint(q,U.y-G));for(f=0;f<W.length;f+=2){var z;(z=T(W[f],W[f+1],null!=Y?Y[f/2]:null,!0)).node.style.visibility="visible",z.redraw(),X.push(z)}for(f=W.length/2;null!=Y&&f<Y.length;f++)Y[f].destroy();u.guidesArrVer=X,r=j-i.y,o=!0}else M(!1,!0)}if(l||o){var B=new mxPoint(s,r),F=e.call(this,i,B,n,h);return l&&!o?B.y=F.y:o&&!l&&(B.x=F.x),F.y!=B.y&&null!=this.guideY&&null!=this.guideY.node&&(this.guideY.node.style.visibility="hidden"),F.x!=B.x&&null!=this.guideX&&null!=this.guideX.node&&(this.guideX.node.style.visibility="hidden"),B}return M(!0,!0),e.apply(this,arguments)};var i=mxGuide.prototype.setVisible;mxGuide.prototype.setVisible=function(e){var t=this;i.call(t,e);var n=t.guidesArrVer,h=t.guidesArrHor;if(null!=n)for(var r=0;r<n.length;r++)n[r].node.style.visibility=e?"visible":"hidden";if(null!=h)for(r=0;r<h.length;r++)h[r].node.style.visibility=e?"visible":"hidden"};var t=mxGuide.prototype.destroy;mxGuide.prototype.destroy=function(){t.call(this);var e=this.guidesArrVer,i=this.guidesArrHor;if(null!=e){for(var n=0;n<e.length;n++)e[n].destroy();this.guidesArrVer=null}if(null!=i){for(n=0;n<i.length;n++)i[n].destroy();this.guidesArrHor=null}}}();