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