1 |
- !function(z,Z){"use strict";var E="position",t="absolute",G="relative",u="px",T="left",M="right",W="top",v="bottom",p="display",V="none",j="block",i=ht.Default,P=i.getInternal(),B=Math.floor,d=Math.ceil,A=Math.PI,C=null,w=z.parseInt,$=function(k){return k.getContext("2d")},S=function(){return document},e=function(n){return S().createElement(n)},h=function(){return e("canvas")},D=function(e,E,x){e.style.setProperty(E,x,C)},U=function(S,r,F){i.def(ht.widget[S],r,F)},k=function(r,u){r.appendChild(u)},F=function(o,A){o.removeChild(A)},q=function(u,b,X,W){u.addEventListener(b,X,!!W)},n=function(z,Y,v,K){z.removeEventListener(Y,v,!!K)};ht.widget.RulerFrame=function(i){var T=this,n=T._view=P.createView(null,T),j=T.$1k=h(),R=T.$2k=h(),M=T.$3k=h(),F=T.$4k=h();T._defaultRulerConfig={size:20,borderWidth:1,borderStyle:"solid",borderColor:"#888",defaultMajorTickSpacing:50,minMajorTickSpacing:10,minPhysicalMajorTickSpacing:40,maxPhysicalMajorTickSpacing:100,tickSpacingAdaptable:!0,majorTickTextFont:"12px Arial",majorTickTextColor:"#666",majorTickColor:"#888",minorTickColor:"#ccc",background:"rgba(0,0,0,0)",guideColor:"rgb(0, 173, 239)",guideWidth:2,guideVisible:!1,guideTipVisible:!1,guideTipBorderColor:"#666",guideTipTextColor:"#666",guideTipTextFont:"12px Arial",guideTipBackground:"#fff"},T._topRulerConfig={visible:!0},T._rightRulerConfig={visible:!1},T._bottomRulerConfig={visible:!1},T._leftRulerConfig={visible:!0},k(n,j),k(n,M),k(n,R),k(n,F),D(n,E,G),D(n,"box-sizing","border-box"),D(n,"-moz-box-sizing","border-box"),D(j,E,t),D(R,E,t),D(M,E,t),D(F,E,t),T.$14k=function(){T.$13k=1,T.iv()},T.$15k=function(u){if(T._topRulerConfig.guideVisible||T._rightRulerConfig.guideVisible||T._bottomRulerConfig.guideVisible||T._leftRulerConfig.guideVisible||T._defaultRulerConfig.guideVisible||(T._topRulerConfig.guideTipVisible||T._rightRulerConfig.guideTipVisible||T._bottomRulerConfig.guideTipVisible||T._leftRulerConfig.guideTipVisible||T._defaultRulerConfig.guideTipVisible)&&T._component){var x=n.getBoundingClientRect();T.$16k={x:u.clientX-x.left,y:u.clientY-x.top},T.$5k()}},T.setComponent(i)},U("RulerFrame",Z,{ms_v:1,ms_fire:1,ms_ac:["defaultRulerConfig","topRulerConfig","rightRulerConfig","bottomRulerConfig","leftRulerConfig","component"],setComponent:function(V){var m=this,f=m._component,y=m.getView();if(y){if(m._component=V,m.fp("component",f,V),f){var z=m.getComponentView(f);F(y,z),n(y,"mousemove",m.$15k),m.removeComponentPropertyChangeListener(f,m.$14k)}if(V){var W=m.getComponentView(V);k(y,W),D(W,E,t),q(y,"mousemove",m.$15k),m.addComponentPropertyChangeListener(V,m.$14k)}}},addComponentPropertyChangeListener:function(t,X){t&&t.mp&&t.mp(X)},removeComponentPropertyChangeListener:function(M,l){M&&M.ump&&M.ump(l)},getComponentHZoom:function(I){return I&&I.getZoom?I.getZoom():1},getComponentVZoom:function(q){return q&&q.getZoom?q.getZoom():1},getComponentViewRect:function(Y){return Y&&Y.getViewRect?Y.getViewRect():void 0},getComponentView:function(X){return X&&X.getView?X.getView():X},invalidateComponent:function(Z){Z&&Z.iv&&Z.iv()},validateComponent:function(d){d&&d.validate&&d.validate()},$7k:function(n,w,s,R,f,U,N,$,l,d,T,K){if(w.visible){var E=this._defaultRulerConfig,q="borderStyle",i="borderColor",e="borderWidth",X="background",S=w[q]||E[q],m=w[i]||E[i],A=w[e]||E[e],a=w.size!=C?w.size:E.size,H=w[X]||E[X],x=a+A,Z=this.$6k(A,S,m,n,s,f,x,N,$,l,d,T,K);D(n,f,"0px"),U?P.setCanvas(n,R-Z,a):P.setCanvas(n,a,R-Z),D(n,"background",H),D(n,p,j)}else D(n,p,V),D(this.getComponentView(this._component),f,"0px")},$6k:function(q,i,o,J,x,K,c,d,L,l,H,B,m){var v=0;return D(J,x,q+"px "+i+" "+o),D(this.getComponentView(this._component),K,c+u),d?(D(J,L,l+u),v+=l):D(J,L,"0px"),H?(D(J,B,m+u),v+=m):D(J,B,"0px"),v},validateImpl:function(){var b=this,p=b._component,g=b.$1k,y=b.$2k,N=b.$3k,c=b.$4k,_=b._view,j=b._defaultRulerConfig,Z=b._topRulerConfig,m=b._rightRulerConfig,H=b._bottomRulerConfig,r=b._leftRulerConfig,J=j.size;if(_&&p){var n=Z.size!=C?Z.size:J,B=m.size!=C?m.size:J,z=H.size!=C?H.size:J,l=r.size!=C?r.size:J;b.$7k(g,Z,"border-bottom",_.offsetWidth,W,!0,r.visible,T,l,m.visible,M,B),b.$7k(y,m,"border-left",_.offsetHeight,M,!1,Z.visible,W,n,H.visible,v,z),b.$7k(N,H,"border-top",_.offsetWidth,v,!0,r.visible,T,l,m.visible,M,B),b.$7k(c,r,"border-right",_.offsetHeight,T,!1,Z.visible,W,n,H.visible,v,z),b.$13k?delete b.$13k:b.invalidateComponent(p),b.validateComponent(p),b.$5k()}},$5k:function(){function i(c,A,T,V,f,E){if(A.visible){var x=$(c),D=A[Z]||S,i=A[k]!=C?A[k]:_,v=A[y]||d,g=A[n]||z,L=A.size!=C?A.size:M,Xm=A[q]||h,qo=A[t]||s,On=A[l]||u,ef=A[R]!=C?A[R]:B,Oh=A[I]!=C?A[I]:b,Zp=A[j]!=C?A[j]:N,hj=A[O]!=C?A[O]:K,Dl=A[r]!=C?A[r]:Y,Rd=A[e]!=C?A[e]:F,sc=A[p]||$d,un=A[m]||Mp;i&&(D=o[E]=o.$8k(o[E]||D,A[Q]||J,A[G]||U,V?X:P,qo)),T.call(o,x,H,W,w,a,L,V?X:P,D,v,g,f,Xm,On);var Zr=o.$16k;(ef||Oh)&&Zr&&(V?o.$9k(x,Zr.x,L,sc,un,ef,Oh,Zp,hj,Dl,Rd):o.$10k(x,Zr.y,L,sc,un,ef,Oh,Zp,hj,Dl,Rd,f))}}var o=this,D=o.$1k,T=o.$2k,E=o.$3k,A=o.$4k,f=o._topRulerConfig,c=o._rightRulerConfig,g=o._bottomRulerConfig,v=o._leftRulerConfig,x=o._defaultRulerConfig,V=o._component,L=o.getComponentViewRect(V),X=o.getComponentHZoom(V),P=o.getComponentVZoom(V),H=L.x*X,w=H+L.width*X,W=L.y*P,a=W+L.height*P,M=o._defaultRulerConfig.size,Z="defaultMajorTickSpacing",Q="maxPhysicalMajorTickSpacing",G="minPhysicalMajorTickSpacing",k="tickSpacingAdaptable",y="majorTickTextFont",n="majorTickTextColor",q="majorTickColor",l="minorTickColor",R="guideVisible",I="guideTipVisible",j="guideTipBorderColor",O="guideTipTextColor",r="guideTipTextFont",e="guideTipBackground",p="guideColor",m="guideWidth",t="minMajorTickSpacing",S=x[Z],J=x[Q],U=x[G],_=x[k],d=x[y],z=x[n],h=x[q],s=x[t],u=x[l],B=x[R],b=x[I],N=x[j],K=x[O],Y=x[r],F=x[e],$d=x[p],Mp=x[m];o._view&&V&&(i(D,f,o.$11k,!0,!1,"_currentTopMajorTickSpacing"),i(T,c,o.$12k,!1,!0,"_currentRightMajorTickSpacing"),i(E,g,o.$11k,!0,!0,"_currentBottomMajorTickSpacing"),i(A,v,o.$12k,!1,!1,"_currenLeftMajorTickSpacing"))},$8k:function(H,w,E,m,G){return E>H*m?H=B(w/m/G)*G:H*m>w&&(H=d(E/m/G)*G),H},getHTipText:function(V){var N=this,J=N._component,k=0,b=N._view.getBoundingClientRect();return J.lp?k=w(J.lp({clientX:V.x+b.left,clientY:V.y}).x):k-=w(this.getComponentView(J).style.left)||0,k},$9k:function(z,S,q,I,W,s,T,i,X,K,d){var f=this,h=f._component;z.save(),P.translateAndScale(z,0,0,1);var k=S-(w(this.getComponentView(h).style.left)||0),o=0;if(S=f.getHTipText(f.$16k),s&&(z.beginPath(),z.fillStyle=I,z.rect(k,o,W,q),z.fill()),T){z.beginPath(),z.textAlign="center",z.textBaseline="middle",z.font=K;var c=z.measureText(S).width+6;z.fillStyle=d,z.rect(k-c/2,o,c,q),z.fill(),z.strokeStyle=i,z.stroke(),z.beginPath(),z.fillStyle=X,z.fillText(S,k,o+q/2)}z.restore()},getVTipText:function(l){var Q=this,t=Q._component,J=0,r=Q._view.getBoundingClientRect();return t.lp?J=w(t.lp({clientX:l.x,clientY:l.y+r.top}).y):J-=w(this.getComponentView(t).style.top)||0,J},formatScaleText:function(b){return Math.round(b)},$10k:function(U,s,W,L,h,X,S,G,r,O,I,u){var F=this,Y=F._component;U.save(),P.translateAndScale(U,0,0,1);var n=W/2,o=s-(w(this.getComponentView(Y).style.top)||0);if(s=F.getVTipText(F.$16k),X&&(U.beginPath(),U.fillStyle=L,U.rect(n-W/2,o,W,h),U.fill()),S){U.translate(n,o),U.rotate((u?90:-90)*A/180),U.translate(-n,-o),U.beginPath(),U.textAlign="center",U.textBaseline="middle",U.font=O;var a=U.measureText(s).width+6;U.fillStyle=I,U.rect(n-a/2,o-W/2,a,W),U.fill(),U.strokeStyle=G,U.stroke(),U.fillStyle=r,U.fillText(s,n,o)}U.restore()},$11k:function(q,E,R,T,b,W,G,L,_,r,f,c,y){q.save(),R=0;var p=E,D=T,o=(p+D)/2;E=0,T=D-p,P.translateAndScale(q,0,0,1);var h=0,H=0,v=w(W/2),F=W-v,s=f?0:v,Y=L*G,l=Y/10;E-=Y,T+=Y,q.clearRect(E,0,T-E,W),q.beginPath(),q.fillStyle=y;var N=B(o/l)*l-p;for(h=N;T>h;h+=l)q.rect(h,R+s,1,F);for(h=N;h>E;h-=l)q.rect(h,R+s,1,F);for(q.fill(),s=f?0:1,q.beginPath(),q.fillStyle=c,N=B(o/Y)*Y-p,h=N;T>h;h+=Y)q.rect(h,R+s,1,W-1);for(h=N;h>E;h-=Y)q.rect(h,R+s,1,W-1);q.fill();var O=w(/\d+px/.exec(_)[0]),X=(O||10)/2;q.textBaseline="middle",s=f?W-X-2:X+2,q.beginPath(),q.fillStyle=r,q.font=_;var K=B(o/Y)*Y/G;for(h=N,H=K;T>h;h+=Y,H+=L){var J=this.getHScaleText?this.getHScaleText(h):H;q.fillText(this.formatScaleText(J),h+2,R+s)}for(h=N,H=K;h>E;h-=Y,H-=L){var J=this.getHScaleText?this.getHScaleText(h):H;q.fillText(this.formatScaleText(J),h+2,R+s)}q.restore()},$12k:function(b,T,r,e,l,K,a,L,g,m,I,C,f){function M(q,t,K,d,l,$){l=S.getVScaleText?S.getVScaleText(K):l,l=S.formatScaleText(l),b.translate(q+t,K),b.rotate(-d),b.translate(-q-t,-K),b.fillText(l,q+t+($?2:1),K),b.translate(q+t,K),b.rotate(d),b.translate(-q-t,-K)}b.save(),T=0;var Q=r,Y=l,V=(Q+Y)/2;r=0,l=Y-Q,P.translateAndScale(b,0,0,1);var z=0,S=this,X=0,H=w(K/2),d=K-H,v=I?0:H,Z=L*a,s=Z/10;r-=Z,l+=Z,b.clearRect(T,0,K,l-r),b.beginPath(),b.fillStyle=f;var $=B(V/s)*s-Q;for(z=$;l>z;z+=s)b.rect(T+v,z,d,1);for(z=$;z>r;z-=s)b.rect(T+v,z,d,1);for(b.fill(),v=I?0:1,b.beginPath(),b.fillStyle=C,$=B(V/Z)*Z-Q,z=$;l>z;z+=Z)b.rect(T+v,z,K-1,1);for(z=$;z>r;z-=Z)b.rect(T+v,z,K-1,1);b.fill();var R=w(/\d+px/.exec(g)[0]),k=(R||10)/2,h=90*A/180;b.textBaseline="middle",v=I?K-k:k+2,h=I?-h:h,b.beginPath(),b.fillStyle=m,b.font=g;var n=B(V/Z)*Z/a;for(z=$,X=n;l>z;z+=Z,X+=L)M(T,v,z,h,X,I);for(z=$,X=n;z>r;z-=Z,X-=L)M(T,v,z,h,X,I);b.restore()},onPropertyChanged:function(){this.iv()},dispose:function(){var T=this,q=T._component,O=T._view;q&&T.removeComponentPropertyChangeListener(q,T.$14k),O&&(n(O,"mousemove",T.$15k),F(O.parentNode,O),T._view=null)}})}("undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:this,Object);
|