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