GaugeBase.js 3.15 KB
//>>built
define("dojo/_base/lang dojo/_base/declare dojo/dom-geometry dijit/registry dijit/_WidgetBase dojo/_base/html dojo/_base/event dojox/gfx dojox/widget/_Invalidating ./ScaleBase dojox/gfx/matrix".split(" "),function(d,h,e,k,l,m,p,n,f,g,q){return h("dojox.dgauges.GaugeBase",[l,f],{_elements:null,_scales:null,_elementsIndex:null,_elementsRenderers:null,_gfxGroup:null,_mouseShield:null,_widgetBox:null,_node:null,value:0,_mainIndicator:null,_getValueAttr:function(){if(this._mainIndicator)return this._mainIndicator.get("value");
this._setMainIndicator();return this._mainIndicator?this._mainIndicator.get("value"):this.value},_setValueAttr:function(a){this._set("value",a);this._mainIndicator?this._mainIndicator.set("value",a):(this._setMainIndicator(),this._mainIndicator&&this._mainIndicator.set("value",a))},_setMainIndicator:function(){for(var a,b=0;b<this._scales.length;b++)if(a=this._scales[b].getIndicator("indicator"))this._mainIndicator=a},_resetMainIndicator:function(){this._mainIndicator=null},font:null,constructor:function(a,
b){this.font={family:"Helvetica",style:"normal",variant:"small-caps",weight:"bold",size:"10pt",color:"black"};this._elements=[];this._scales=[];this._elementsIndex={};this._elementsRenderers={};this._node=k.byId(b);a=m.getMarginBox(b);this.surface=n.createSurface(this._node,a.w||1,a.h||1);this._widgetBox=a;this._baseGroup=this.surface.createGroup();this._mouseShield=this._baseGroup.createGroup();this._gfxGroup=this._baseGroup.createGroup()},_setCursor:function(a){this._node&&(this._node.style.cursor=
a)},_computeBoundingBox:function(a){return a?a.getBoundingBox():{x:0,y:0,width:0,height:0}},destroy:function(){this.surface.destroy();this.inherited(arguments)},resize:function(a,b){switch(arguments.length){case 1:e.setMarginBox(this._node,a);break;case 2:e.setMarginBox(this._node,{w:a,h:b})}var c=e.getMarginBox(this._node);this._widgetBox=c;var d=this.surface.getDimensions();return d.width!=c.w||d.height!=c.h?(this.surface.setDimensions(c.w,c.h),this._mouseShield.clear(),this._mouseShield.createRect({x:0,
y:0,width:c.w,height:c.h}).setFill([0,0,0,0]),this.invalidateRendering()):this},addElement:function(a,b){this._elementsIndex[a]&&this._elementsIndex[a]!=b&&this.removeElement(a);if(d.isFunction(b)){var c={};d.mixin(c,new f);c._name=a;c._gfxGroup=this._gfxGroup.createGroup();c.width=0;c.height=0;c._isGFX=!0;c.refreshRendering=function(){c._gfxGroup.clear();return b(c._gfxGroup,c.width,c.height)};this._elements.push(c);this._elementsIndex[a]=c}else b._name=a,b._gfxGroup=this._gfxGroup.createGroup(),
b._gauge=this,this._elements.push(b),this._elementsIndex[a]=b,b instanceof g&&this._scales.push(b);return this.invalidateRendering()},removeElement:function(a){var b=this._elementsIndex[a];if(b){b._gfxGroup.removeShape();var c=this._elements.indexOf(b);this._elements.splice(c,1);b instanceof g&&(c=this._scales.indexOf(b),this._scales.splice(c,1),this._resetMainIndicator());delete this._elementsIndex[a];delete this._elementsRenderers[a]}this.invalidateRendering();return b},getElement:function(a){return this._elementsIndex[a]},
getElementRenderer:function(a){return this._elementsRenderers[a]},onStartEditing:function(a){},onEndEditing:function(a){}})});