AnalogNeedleIndicator.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. define("dojox/gauges/AnalogNeedleIndicator", ["dojo/_base/declare","./AnalogIndicatorBase"],
  2. function(declare, AnalogIndicatorBase) {
  3. /*=====
  4. AnalogIndicatorBase = dojox.gauges.AnalogIndicatorBase;
  5. =====*/
  6. return declare("dojox.gauges.AnalogNeedleIndicator", [AnalogIndicatorBase], {
  7. // summary:
  8. // An indicator for the AnalogGauge that draws a needle. The needle is drawn on the angle that corresponds
  9. // to the value of the indicator.
  10. _getShapes: function(group){
  11. // summary:
  12. // Override of dojox.gauges.AnalogLineIndicator._getShapes
  13. if(!this._gauge){
  14. return null;
  15. }
  16. var x = Math.floor(this.width/2);
  17. var shapes = [];
  18. var color = this.color ? this.color : 'black';
  19. var strokeColor = this.strokeColor ? this.strokeColor : color;
  20. var strokeWidth = this.strokeWidth ? this.strokeWidth : 1;
  21. var stroke = {
  22. color: strokeColor,
  23. width: strokeWidth
  24. };
  25. if (color.type && !this.strokeColor){
  26. stroke.color = color.colors[0].color;
  27. }
  28. var xy = (Math.sqrt(2) * (x));
  29. shapes[0] = group.createPath()
  30. .setStroke(stroke).setFill(color)
  31. .moveTo(xy, -xy).arcTo((2*x), (2*x), 0, 0, 0, -xy, -xy)
  32. .lineTo(0, -this.length).closePath();
  33. shapes[1] = group.createCircle({cx: 0, cy: 0, r: this.width})
  34. .setStroke(stroke)
  35. .setFill(color);
  36. return shapes;
  37. }
  38. });
  39. });