source: code/Website/open-flash-chart/charts/series/dots/bow.as@ 7849

Last change on this file since 7849 was 7849, checked in by dennisw, 15 years ago
File size: 3.8 KB
Line 
1package 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 bow extends PointDotBase {
13
14 public function bow( 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.draw(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.draw(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 draw( aGraphics:Graphics, aRadius:Number, aRotation:Number ):void
104 {
105 var angle:Number = 60;
106
107 // Start at center point
108 aGraphics.moveTo(0, 0);
109
110 // Upper right side point (unrotated)
111 var degrees:Number = -90 + aRotation + angle;
112 var xVal:Number = calcXOnCircle(aRadius, degrees);
113 var yVal:Number = calcYOnCircle(aRadius, degrees);
114 aGraphics.lineTo(xVal, yVal);
115
116 // Lower right side point (unrotated)
117 degrees += angle;
118 xVal = calcXOnCircle(aRadius, degrees);
119 yVal = calcYOnCircle(aRadius, degrees);
120 aGraphics.lineTo(xVal, yVal);
121
122 // Back to the center
123 aGraphics.lineTo(xVal, yVal);
124
125 // Upper left side point (unrotated)
126 degrees = -90 + aRotation - angle;
127 xVal = calcXOnCircle(aRadius, degrees);
128 yVal = calcYOnCircle(aRadius, degrees);
129 aGraphics.lineTo(xVal, yVal);
130
131 // Lower Left side point (unrotated)
132 degrees -= angle;
133 xVal = calcXOnCircle(aRadius, degrees);
134 yVal = calcYOnCircle(aRadius, degrees);
135 aGraphics.lineTo(xVal, yVal);
136
137 // Back to the center
138 aGraphics.lineTo(xVal, yVal);
139 }
140 }
141}
Note: See TracBrowser for help on using the repository browser.