root / trunk / web / dojo / dojox / widget / gauge / BarIndicator.js
History | View | Annotate | Download (1.98 KB)
| 1 | 9 | andrej.cim | /*
|
|---|---|---|---|
| 2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
||
| 3 | Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||
| 4 | see: http://dojotoolkit.org/license for details
|
||
| 5 | */
|
||
| 6 | |||
| 7 | |||
| 8 | if(!dojo._hasResource["dojox.widget.gauge.BarIndicator"]){ |
||
| 9 | dojo._hasResource["dojox.widget.gauge.BarIndicator"]=true; |
||
| 10 | dojo.provide("dojox.widget.gauge.BarIndicator");
|
||
| 11 | dojo.require("dojox.widget.BarGauge");
|
||
| 12 | dojo.experimental("dojox.widget.gauge.BarIndicator");
|
||
| 13 | dojo.declare("dojox.widget.gauge.BarIndicator",[dojox.widget.gauge.BarLineIndicator],{_getShapes:function(){ |
||
| 14 | if(!this._gauge){ |
||
| 15 | return null; |
||
| 16 | } |
||
| 17 | var v=this.value; |
||
| 18 | if(v<this._gauge.min){ |
||
| 19 | v=this._gauge.min;
|
||
| 20 | } |
||
| 21 | if(v>this._gauge.max){ |
||
| 22 | v=this._gauge.max;
|
||
| 23 | } |
||
| 24 | var _1=this._gauge._getPosition(v); |
||
| 25 | if(_1==this.dataX){ |
||
| 26 | _1=this.dataX+1; |
||
| 27 | } |
||
| 28 | var y=this._gauge.dataY+Math.floor((this._gauge.dataHeight-this.width)/2)+this.offset; |
||
| 29 | var _2=[];
|
||
| 30 | _2[0]=this._gauge.surface.createRect({x:this._gauge.dataX,y:y,width:_1-this._gauge.dataX,height:this.width}); |
||
| 31 | _2[0].setStroke({color:this.color}); |
||
| 32 | _2[0].setFill(this.color); |
||
| 33 | _2[1]=this._gauge.surface.createLine({x1:this._gauge.dataX,y1:y,x2:_1,y2:y}); |
||
| 34 | _2[1].setStroke({color:this.highlight}); |
||
| 35 | if(this.highlight2){ |
||
| 36 | y--; |
||
| 37 | _2[2]=this._gauge.surface.createLine({x1:this._gauge.dataX,y1:y,x2:_1,y2:y}); |
||
| 38 | _2[2].setStroke({color:this.highlight2}); |
||
| 39 | } |
||
| 40 | return _2;
|
||
| 41 | },_createShapes:function(_3){ |
||
| 42 | for(var i in this.shapes){ |
||
| 43 | i=this.shapes[i];
|
||
| 44 | var _4={};
|
||
| 45 | for(var j in i){ |
||
| 46 | _4[j]=i[j]; |
||
| 47 | } |
||
| 48 | if(i.shape.type=="line"){ |
||
| 49 | _4.shape.x2=_3+_4.shape.x1; |
||
| 50 | }else{
|
||
| 51 | if(i.shape.type=="rect"){ |
||
| 52 | _4.width=_3; |
||
| 53 | } |
||
| 54 | } |
||
| 55 | i.setShape(_4); |
||
| 56 | } |
||
| 57 | },_move:function(_5){ |
||
| 58 | var _6=false; |
||
| 59 | var c;
|
||
| 60 | var v=this.value; |
||
| 61 | if(v<this.min){ |
||
| 62 | v=this.min;
|
||
| 63 | } |
||
| 64 | if(v>this.max){ |
||
| 65 | v=this.max;
|
||
| 66 | } |
||
| 67 | c=this._gauge._getPosition(this.currentValue); |
||
| 68 | this.currentValue=v;
|
||
| 69 | v=this._gauge._getPosition(v)-this._gauge.dataX; |
||
| 70 | if(_5){
|
||
| 71 | this._createShapes(v);
|
||
| 72 | }else{
|
||
| 73 | if(c!=v){
|
||
| 74 | var _7=new dojo.Animation({curve:[c,v],duration:this.duration,easing:this.easing}); |
||
| 75 | dojo.connect(_7,"onAnimate",dojo.hitch(this,this._createShapes)); |
||
| 76 | _7.play(); |
||
| 77 | } |
||
| 78 | } |
||
| 79 | }}); |
||
| 80 | } |