/src/com/globalworks/lbs/tools/charts/series/dots/bow.as

https://github.com/fgontier/LBS_earnings_potential_calculator
ActionScript | 141 lines | 98 code | 22 blank | 21 comment | 10 complexity | 563d95048aa20f9c597db3401d9afd7b MD5 | raw file
  1. package charts.series.dots {
  2. import flash.display.Sprite;
  3. import flash.display.Graphics;
  4. import flash.display.BlendMode;
  5. import charts.series.Element;
  6. import caurina.transitions.Tweener;
  7. import caurina.transitions.Equations;
  8. import string.Utils;
  9. import flash.geom.Point;
  10. public class bow extends PointDotBase {
  11. public function bow( index:Number, value:Properties ) {
  12. var colour:Number = string.Utils.get_colour( value.get('colour') );
  13. super( index, value );
  14. this.tooltip = this.replace_magic_values( value.get('tip') );
  15. this.attach_events();
  16. // if style.x is null then user wants a gap in the line
  17. //
  18. // I don't understand what this is doing...
  19. //
  20. // if (style.x == null)
  21. // {
  22. // this.visible = false;
  23. // }
  24. // else
  25. // {
  26. if (value.get('hollow'))
  27. {
  28. // Hollow - set the fill to the background color/alpha
  29. if (value.get('background-colour') != null)
  30. {
  31. var bgColor:Number = string.Utils.get_colour( value.get('background-colour') );
  32. }
  33. else
  34. {
  35. bgColor = colour;
  36. }
  37. this.graphics.beginFill(bgColor, value.get('background-alpha'));
  38. }
  39. else
  40. {
  41. // set the fill to be the same color and alpha as the line
  42. this.graphics.beginFill( colour, value.get('alpha') );
  43. }
  44. this.graphics.lineStyle( value.get('width'), colour, value.get('alpha') );
  45. this.draw(this.graphics, this.radius, value.get('rotation'));
  46. // Check to see if part of the line needs to be erased
  47. if (value.get('halo-size') > 0)
  48. {
  49. var s:Sprite = new Sprite();
  50. s.graphics.lineStyle( 0, 0, 0 );
  51. s.graphics.beginFill( 0, 1 );
  52. this.draw(s.graphics, value.get('halo-size')+this.radius, value.get('rotation'));
  53. s.blendMode = BlendMode.ERASE;
  54. s.graphics.endFill();
  55. this.line_mask = s;
  56. }
  57. // }
  58. }
  59. public override function set_tip( b:Boolean ):void {
  60. if ( b )
  61. {
  62. if ( !this.is_tip )
  63. {
  64. Tweener.addTween(this, {scaleX:1.3, time:0.4, transition:"easeoutbounce"} );
  65. Tweener.addTween(this, {scaleY:1.3, time:0.4, transition:"easeoutbounce" } );
  66. if (this.line_mask != null)
  67. {
  68. Tweener.addTween(this.line_mask, {scaleX:1.3, time:0.4, transition:"easeoutbounce"} );
  69. Tweener.addTween(this.line_mask, {scaleY:1.3, time:0.4, transition:"easeoutbounce" } );
  70. }
  71. }
  72. this.is_tip = true;
  73. }
  74. else
  75. {
  76. Tweener.removeTweens(this);
  77. Tweener.removeTweens(this.line_mask);
  78. this.scaleX = 1;
  79. this.scaleY = 1;
  80. if (this.line_mask != null)
  81. {
  82. this.line_mask.scaleX = 1;
  83. this.line_mask.scaleY = 1;
  84. }
  85. this.is_tip = false;
  86. }
  87. }
  88. private function draw( aGraphics:Graphics, aRadius:Number, aRotation:Number ):void
  89. {
  90. var angle:Number = 60;
  91. // Start at center point
  92. aGraphics.moveTo(0, 0);
  93. // Upper right side point (unrotated)
  94. var degrees:Number = -90 + aRotation + angle;
  95. var xVal:Number = calcXOnCircle(aRadius, degrees);
  96. var yVal:Number = calcYOnCircle(aRadius, degrees);
  97. aGraphics.lineTo(xVal, yVal);
  98. // Lower right side point (unrotated)
  99. degrees += angle;
  100. xVal = calcXOnCircle(aRadius, degrees);
  101. yVal = calcYOnCircle(aRadius, degrees);
  102. aGraphics.lineTo(xVal, yVal);
  103. // Back to the center
  104. aGraphics.lineTo(xVal, yVal);
  105. // Upper left side point (unrotated)
  106. degrees = -90 + aRotation - angle;
  107. xVal = calcXOnCircle(aRadius, degrees);
  108. yVal = calcYOnCircle(aRadius, degrees);
  109. aGraphics.lineTo(xVal, yVal);
  110. // Lower Left side point (unrotated)
  111. degrees -= angle;
  112. xVal = calcXOnCircle(aRadius, degrees);
  113. yVal = calcYOnCircle(aRadius, degrees);
  114. aGraphics.lineTo(xVal, yVal);
  115. // Back to the center
  116. aGraphics.lineTo(xVal, yVal);
  117. }
  118. }
  119. }