AnalogNeedleIndicator.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. Copyright (c) 2004-2012, 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. if(!dojo._hasResource['dojox.widget.gauge.AnalogNeedleIndicator']){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
  7. dojo._hasResource['dojox.widget.gauge.AnalogNeedleIndicator'] = true;
  8. dojo.provide('dojox.widget.gauge.AnalogNeedleIndicator');
  9. dojo.require('dojox.widget.AnalogGauge');
  10. dojo.experimental("dojox.widget.gauge.AnalogNeedleIndicator");
  11. dojo.declare("dojox.widget.gauge.AnalogNeedleIndicator",[dojox.widget.gauge.AnalogLineIndicator],{
  12. _getShapes: function(){
  13. // summary:
  14. // Override of dojox.widget.AnalogLineIndicator._getShapes
  15. if(!this._gauge){
  16. return null;
  17. }
  18. var x = Math.floor(this.width/2);
  19. var head = this.width * 5;
  20. var odd = (this.width & 1);
  21. var shapes = [];
  22. var stroke = {color: this.color, width: 1};
  23. if(this.color.type){
  24. stroke.color = this.color.colors[0].color;
  25. }
  26. var xy = (Math.sqrt(2) * (x));
  27. shapes[0] = this._gauge.surface.createPath()
  28. .setStroke(stroke).setFill(this.color)
  29. .moveTo(xy, -xy).arcTo((2*x), (2*x), 0, 0, 0, -xy, -xy)
  30. .lineTo(0, -this.length).closePath();
  31. shapes[1] = this._gauge.surface.createCircle({cx: 0, cy: 0, r: this.width})
  32. .setStroke({color: this.color})
  33. .setFill(this.color);
  34. return shapes;
  35. }
  36. });
  37. }