ziya 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. data/Manifest.txt +74 -28
  2. data/README.txt +91 -14
  3. data/Rakefile +1 -1
  4. data/bin/ziyafy +2 -0
  5. data/charts/AC_RunActiveContent.js +292 -0
  6. data/charts/charts.swf +0 -0
  7. data/charts/charts_library/ar3d.swf +0 -0
  8. data/charts/charts_library/arno.swf +0 -0
  9. data/charts/charts_library/ars3.swf +0 -0
  10. data/charts/charts_library/arst.swf +0 -0
  11. data/charts/charts_library/brfl.swf +0 -0
  12. data/charts/charts_library/brno.swf +0 -0
  13. data/charts/charts_library/brst.swf +0 -0
  14. data/charts/charts_library/buno.swf +0 -0
  15. data/charts/charts_library/cl3d.swf +0 -0
  16. data/charts/charts_library/clfl.swf +0 -0
  17. data/charts/charts_library/clno.swf +0 -0
  18. data/charts/charts_library/clp3.swf +0 -0
  19. data/charts/charts_library/cls3.swf +0 -0
  20. data/charts/charts_library/clst.swf +0 -0
  21. data/charts/charts_library/cnno.swf +0 -0
  22. data/charts/charts_library/lnno.swf +0 -0
  23. data/charts/charts_library/mxno.swf +0 -0
  24. data/charts/charts_library/pi3d.swf +0 -0
  25. data/charts/charts_library/pino.swf +0 -0
  26. data/charts/charts_library/pono.swf +0 -0
  27. data/charts/charts_library/scno.swf +0 -0
  28. data/charts/full_screen.swf +0 -0
  29. data/charts/sliders/black.swf +0 -0
  30. data/charts/sliders/preview_handle_1.swf +0 -0
  31. data/charts/sliders/preview_handle_2.swf +0 -0
  32. data/fred.rb +36 -0
  33. data/gauges/designs/circle.yml +18 -0
  34. data/gauges/designs/signal.yml +14 -0
  35. data/gauges/designs/thermo.yml +119 -0
  36. data/gauges/designs/title.yml +11 -0
  37. data/gauges/gauge.swf +0 -0
  38. data/lib/ziya.rb +17 -5
  39. data/lib/ziya/charts/area.rb +6 -1
  40. data/lib/ziya/charts/area_threed.rb +16 -0
  41. data/lib/ziya/charts/bar.rb +8 -3
  42. data/lib/ziya/charts/base.rb +210 -153
  43. data/lib/ziya/charts/bubble.rb +18 -0
  44. data/lib/ziya/charts/candle_stick.rb +6 -1
  45. data/lib/ziya/charts/column.rb +7 -2
  46. data/lib/ziya/charts/column_threed.rb +6 -1
  47. data/lib/ziya/charts/floating_bar.rb +6 -1
  48. data/lib/ziya/charts/floating_column.rb +7 -2
  49. data/lib/ziya/charts/line.rb +7 -2
  50. data/lib/ziya/charts/mixed.rb +5 -0
  51. data/lib/ziya/charts/parallel_threed_column.rb +6 -1
  52. data/lib/ziya/charts/pie.rb +7 -2
  53. data/lib/ziya/charts/pie_threed.rb +7 -2
  54. data/lib/ziya/charts/polar.rb +6 -1
  55. data/lib/ziya/charts/scatter.rb +6 -1
  56. data/lib/ziya/charts/stacked_area.rb +5 -0
  57. data/lib/ziya/charts/stacked_bar.rb +5 -0
  58. data/lib/ziya/charts/stacked_column.rb +7 -2
  59. data/lib/ziya/charts/stacked_threed_area.rb +16 -0
  60. data/lib/ziya/charts/stacked_threed_column.rb +6 -1
  61. data/lib/ziya/components/area.rb +5 -2
  62. data/lib/ziya/components/axis_category.rb +8 -60
  63. data/lib/ziya/components/axis_ticks.rb +25 -27
  64. data/lib/ziya/components/axis_value.rb +5 -48
  65. data/lib/ziya/components/base.rb +59 -17
  66. data/lib/ziya/components/bevel.rb +15 -0
  67. data/lib/ziya/components/blur.rb +13 -0
  68. data/lib/ziya/components/chart_border.rb +4 -23
  69. data/lib/ziya/components/chart_grid_h.rb +17 -19
  70. data/lib/ziya/components/chart_grid_v.rb +18 -19
  71. data/lib/ziya/components/chart_guide.rb +16 -0
  72. data/lib/ziya/components/chart_label.rb +16 -0
  73. data/lib/ziya/components/chart_pref.rb +12 -12
  74. data/lib/ziya/components/chart_rect.rb +27 -26
  75. data/lib/ziya/components/chart_transition.rb +15 -16
  76. data/lib/ziya/components/circle.rb +5 -2
  77. data/lib/ziya/components/draw.rb +12 -11
  78. data/lib/ziya/components/draw_base.rb +10 -0
  79. data/lib/ziya/components/filter.rb +26 -0
  80. data/lib/ziya/components/glow.rb +14 -0
  81. data/lib/ziya/components/image.rb +5 -1
  82. data/lib/ziya/components/legend.rb +18 -0
  83. data/lib/ziya/components/line.rb +6 -2
  84. data/lib/ziya/components/link.rb +9 -9
  85. data/lib/ziya/components/link_data.rb +9 -10
  86. data/lib/ziya/components/rect.rb +7 -2
  87. data/lib/ziya/components/scroll.rb +26 -0
  88. data/lib/ziya/components/shadow.rb +14 -0
  89. data/lib/ziya/components/text.rb +5 -1
  90. data/lib/ziya/components/update.rb +19 -0
  91. data/lib/ziya/gauges/base.rb +172 -0
  92. data/lib/ziya/gauges/radial.rb +18 -0
  93. data/lib/ziya/gauges/signal.rb +138 -0
  94. data/lib/ziya/gauges/support/area.rb +13 -0
  95. data/lib/ziya/gauges/support/base.rb +33 -0
  96. data/lib/ziya/gauges/support/circle.rb +14 -0
  97. data/lib/ziya/gauges/support/design.rb +5 -0
  98. data/lib/ziya/gauges/support/image.rb +12 -0
  99. data/lib/ziya/gauges/support/line.rb +12 -0
  100. data/lib/ziya/gauges/support/link.rb +24 -0
  101. data/lib/ziya/gauges/support/move.rb +15 -0
  102. data/lib/ziya/gauges/support/point.rb +12 -0
  103. data/lib/ziya/gauges/support/polygon.rb +13 -0
  104. data/lib/ziya/gauges/support/radial_base.rb +21 -0
  105. data/lib/ziya/gauges/support/radial_numbers.rb +41 -0
  106. data/lib/ziya/gauges/support/radial_ticks.rb +29 -0
  107. data/lib/ziya/gauges/support/rect.rb +14 -0
  108. data/lib/ziya/gauges/support/rotate.rb +15 -0
  109. data/lib/ziya/gauges/support/scale.rb +15 -0
  110. data/lib/ziya/gauges/support/text.rb +21 -0
  111. data/lib/ziya/gauges/support/update.rb +12 -0
  112. data/lib/ziya/gauges/thermo.rb +121 -0
  113. data/lib/ziya/helpers/base_helper.rb +39 -6
  114. data/lib/ziya/utils/text.rb +6 -0
  115. data/lib/ziya/version.rb +1 -1
  116. data/lib/ziya/ziya_helper.rb +289 -62
  117. data/spec/charts/base_spec.rb +35 -21
  118. data/spec/charts/chart_type_spec.rb +24 -3
  119. data/spec/components/area_spec.rb +9 -2
  120. data/spec/components/draw_spec.rb +1 -2
  121. data/spec/components/filter_spec.rb +27 -0
  122. data/spec/components/link_spec.rb +1 -2
  123. data/spec/components/series_color_spec.rb +1 -2
  124. data/spec/components/series_explode_spec.rb +1 -2
  125. data/spec/components/series_switch_spec.rb +1 -2
  126. data/spec/designs/circle.yml +7 -0
  127. data/spec/designs/crapping_out.yml +8 -0
  128. data/spec/designs/gauge_1.yml +43 -0
  129. data/spec/designs/gauge_2.yml +11 -0
  130. data/spec/designs/gauge_no_name.yml +43 -0
  131. data/spec/designs/gauge_raw.yml +5 -0
  132. data/spec/designs/thermo.yml +13 -0
  133. data/spec/gauges/base_spec.rb +90 -0
  134. data/spec/gauges/signal_spec.rb +36 -0
  135. data/spec/gauges/support/area_spec.rb +40 -0
  136. data/spec/gauges/support/circle_spec.rb +78 -0
  137. data/spec/gauges/support/image_spec.rb +35 -0
  138. data/spec/gauges/support/line_spec.rb +34 -0
  139. data/spec/gauges/support/link_spec.rb +35 -0
  140. data/spec/gauges/support/move_spec.rb +45 -0
  141. data/spec/gauges/support/polygon_spec.rb +36 -0
  142. data/spec/gauges/support/radial_numbers_spec.rb +35 -0
  143. data/spec/gauges/support/radial_ticks_spec.rb +30 -0
  144. data/spec/gauges/support/rotate_spec.rb +45 -0
  145. data/spec/gauges/support/scale_spec.rb +46 -0
  146. data/spec/gauges/support/text_spec.rb +40 -0
  147. data/spec/gauges/thermo_spec.rb +49 -0
  148. data/spec/helpers/base_helper_spec.rb +20 -6
  149. data/spec/spec_helper.rb +4 -1
  150. data/spec/test_helpers/gauge_2_helper.rb +17 -0
  151. data/spec/utils/logger_spec.rb +1 -3
  152. data/spec/utils/text_spec.rb +1 -2
  153. data/spec/ziya_helper_spec.rb +88 -11
  154. data/spec/ziya_spec.rb +1 -1
  155. data/tasks/gem.rake +1 -1
  156. metadata +79 -32
  157. data/charts/themes/commando/bar_chart.yml +0 -9
  158. data/charts/themes/commando/base_chart.yml +0 -65
  159. data/charts/themes/commando/column_chart.yml +0 -13
  160. data/charts/themes/commando/column_threed_chart.yml +0 -25
  161. data/charts/themes/commando/parallel_threed_column_chart.yml +0 -17
  162. data/charts/themes/commando/pie_chart.yml +0 -22
  163. data/charts/themes/commando/pie_threed_chart.yml +0 -28
  164. data/charts/themes/commando/polar_chart.yml +0 -11
  165. data/charts/themes/commando/stacked_bar_chart.yml +0 -9
  166. data/charts/themes/commando/stacked_column_chart.yml +0 -14
  167. data/charts/themes/commando/stacked_threed_column_chart.yml +0 -17
  168. data/charts/themes/default/bar_chart.yml +0 -3
  169. data/charts/themes/default/base_chart.yml +0 -67
  170. data/charts/themes/default/column_chart.yml +0 -13
  171. data/charts/themes/default/column_threed_chart.yml +0 -25
  172. data/charts/themes/default/parallel_threed_column_chart.yml +0 -17
  173. data/charts/themes/default/pie_chart.yml +0 -29
  174. data/charts/themes/default/pie_threed_chart.yml +0 -28
  175. data/charts/themes/default/polar_chart.yml +0 -12
  176. data/charts/themes/default/stacked_bar_chart.yml +0 -3
  177. data/charts/themes/default/stacked_column_chart.yml +0 -14
  178. data/charts/themes/default/stacked_threed_column_chart.yml +0 -17
  179. data/charts/themes/default/test.yml +0 -4
  180. data/lib/ziya/components/chart_value.rb +0 -71
  181. data/lib/ziya/components/legend_label.rb +0 -18
  182. data/lib/ziya/components/legend_rect.rb +0 -19
  183. data/lib/ziya/components/legend_transition.rb +0 -18
  184. data/lib/ziya/components/live_update.rb +0 -21
@@ -0,0 +1,18 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Abstract class representing a radial based gauge
3
+ #
4
+ # Author: Fernand
5
+ # -----------------------------------------------------------------------------
6
+ module Ziya::Gauges
7
+ class Radial < Base
8
+
9
+ # =========================================================================
10
+ protected
11
+
12
+ # converts degrees to radiants
13
+ def deg2rad( degrees )
14
+ degrees * Math::PI / 180
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,138 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Meter gauge
3
+ #
4
+ # Records current value from 0..10 and variance of changes of value between
5
+ # ticks.
6
+ #
7
+ # Author: Fernand
8
+ # -----------------------------------------------------------------------------
9
+ module Ziya::Gauges
10
+ class Signal < Radial
11
+
12
+ # -------------------------------------------------------------------------
13
+ # ctor
14
+ def initialize( license, design_id="signal" )
15
+ super( license, design_id )
16
+ options[:delta] = options[:signal] - options[:previous]
17
+ end
18
+
19
+ # -------------------------------------------------------------------------
20
+ # set signal prefs
21
+ def set_preferences( opts={} )
22
+ super( opts )
23
+ options[:delta] = options[:signal] - options[:previous]
24
+ end
25
+
26
+ # =========================================================================
27
+ protected
28
+
29
+ # -----------------------------------------------------------------------
30
+ # setup signal gauge default options
31
+ def default_options
32
+ {
33
+ :x => 20,
34
+ :y => 20,
35
+ :signal => 5,
36
+ :previous => 0,
37
+ :average => nil,
38
+ :gauge_colors => %w[17ff00 49ff00 7cff00 aeff00 e1ff00 ffea00 ffb700 ff8300 ff5000 ff1c00 ff0000]
39
+ }
40
+ end
41
+
42
+ # =========================================================================
43
+ private
44
+
45
+ # draws signal polygons
46
+ def signal_indicator( x, y, radius, width, length, start_angle, end_angle, tick_count, thickness, color )
47
+ buff = []
48
+ rank = options[:signal]
49
+ avg = options[:average]
50
+ i = start_angle
51
+ j = start_angle + width
52
+ count = 1
53
+ while( i < end_angle ) do
54
+ fill_alpha = (rank < count) ? 40 : 100
55
+ fill_color = colorizer( rank )
56
+ if ( avg and avg == count )
57
+ fill_color = "0CFF00"
58
+ fill_alpha = 70
59
+ end
60
+ x1, y1 = x+Math::sin(deg2rad(i))*(radius) , y-Math::cos(deg2rad(i))*(radius)
61
+ x2, y2 = x+Math::sin(deg2rad(i))*(radius+length), y-Math::cos(deg2rad(i))*(radius+length)
62
+ x3, y3 = x+Math::sin(deg2rad(j))*(radius+length), y-Math::cos(deg2rad(j))*(radius+length)
63
+ x4, y4 = x+Math::sin(deg2rad(j))*(radius) , y-Math::cos(deg2rad(j))*(radius)
64
+
65
+ polygon = Ziya::Gauges::Support::Polygon.new(
66
+ :fill_color => fill_color, :fill_alpha => fill_alpha,
67
+ :line_color => fill_color, :line_alpha => fill_alpha,
68
+ :components => YAML::Omap[
69
+ "rpt_#{count}_1".to_sym, Ziya::Gauges::Support::Point.new( :x => x1, :y => y1 ),
70
+ "rpt_#{count}_2".to_sym, Ziya::Gauges::Support::Point.new( :x => x2, :y => y2 ),
71
+ "rpt_#{count}_3".to_sym, Ziya::Gauges::Support::Point.new( :x => x3, :y => y3 ),
72
+ "rpt_#{count}_4".to_sym, Ziya::Gauges::Support::Point.new( :x => x4, :y => y4 )
73
+ ]
74
+ )
75
+ # dump polygon to yaml rep
76
+ buff << "#{indent}#{polygon.to_comp_yaml( "r_poly_#{count}", 2 )}"
77
+ i += (end_angle-start_angle)/(tick_count)
78
+ j = i + width
79
+ count += 1
80
+ end
81
+ buff.join( "\n" )
82
+ end
83
+
84
+ # -----------------------------------------------------------------------
85
+ # draws signal change indicator
86
+ def delta_indicator( x, y )
87
+ buff = []
88
+ fill_color = 'ff0000'
89
+ fill_alpha = 50
90
+ spacer = 10.0
91
+ height = 7.0
92
+ start = y
93
+ fill_alphas = calc_change_alpha( options[:delta] )
94
+ 6.times do |i|
95
+ fill_color = ( i < 3 ) ? 'ff0000' : '00ff00'
96
+ fill_alpha = fill_alphas[i]
97
+
98
+ x1, y1 = x, start
99
+ if i < 3
100
+ x2, y2 = x+height/2, start-height
101
+ else
102
+ x2, y2 = x+height/2, start+height
103
+ end
104
+ x3, y3 = x+height, start
105
+
106
+ polygon = Ziya::Gauges::Support::Polygon.new(
107
+ :fill_color => fill_color, :fill_alpha => fill_alpha,
108
+ :line_color => fill_color, :line_alpha => fill_alpha,
109
+ :components => YAML::Omap[
110
+ "mpt_#{i}_1".to_sym, Ziya::Gauges::Support::Point.new( :x => x1, :y => y1 ),
111
+ "mpt_#{i}_2".to_sym, Ziya::Gauges::Support::Point.new( :x => x2, :y => y2 ),
112
+ "mpt_#{i}_3".to_sym, Ziya::Gauges::Support::Point.new( :x => x3, :y => y3 )
113
+ ]
114
+ )
115
+ buff << "#{indent}#{polygon.to_comp_yaml( "m_poly_#{i}", 2 )}"
116
+ start += (i+1) == 3 ? 5 : spacer
117
+ end
118
+ buff.join( "\n" )
119
+ end
120
+
121
+ # calculates the change delta for this one to previous
122
+ def calc_change_alpha( change )
123
+ alphas = []
124
+ indexes = case change.abs
125
+ when 0..1 : change >= 0 ? [2] : [3]
126
+ when 1..5 : change >= 0 ? [1, 2] : [3,4]
127
+ when 5...10 : change >= 0 ? [0, 1, 2] : [3,4,5]
128
+ end
129
+ 6.times { |i| alphas[i] = indexes.include?(i) ? 100 : 10 }
130
+ alphas
131
+ end
132
+
133
+ # colororize color wheel
134
+ def colorizer( rank )
135
+ options[:gauge_colors][rank]
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,13 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Draws a clickable area for a gauge
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # -----------------------------------------------------------------------------
6
+ require 'ziya/gauges/support/base'
7
+
8
+ module Ziya::Gauges::Support
9
+ class Area < Base
10
+ has_attribute :x, :y, :width, :height, :url, :target, :text, :font, :bold, :size,
11
+ :color, :background_color, :alpha, :stop_sound
12
+ end
13
+ end
@@ -0,0 +1,33 @@
1
+ module Ziya::Gauges::Support
2
+ class Base < Ziya::Components::Base
3
+ include Ziya::Helpers::BaseHelper
4
+
5
+ # -----------------------------------------------------------------------
6
+ # converts component to yaml style component for yaml parser consumption
7
+ def to_comp_yaml( name, indent_multiplier=1 )
8
+ buff = []
9
+ tab = indent( indent_multiplier )
10
+ buff << "#{dial( demodulize( self.class.name ), name )}"
11
+ options.each_pair do |k,v|
12
+ if v.is_a? YAML::Omap
13
+ buff << "#{tab}#{indent}#{dials}"
14
+ v.each do |name, comp|
15
+ buff << "#{tab}#{indent(2)}#{dial( demodulize(comp.class.name), name )}"
16
+ comp.options.each_pair { |k,v| buff << "#{tab}#{indent(4)}#{k}: #{v}"}
17
+ end
18
+ else
19
+ buff << "#{tab}#{indent(1)}#{k}: #{v}" if options[k] and !options[k].to_s.empty?
20
+ end
21
+ end
22
+
23
+ # if ( self.respond_to? :dials )
24
+ # buff << "#{tab}dials:"
25
+ # for dial in dials do
26
+ # buff << "#{tab}#{dial( demodulize( dial.class.name ) )}"
27
+ # dial.options.each_pair { |k,v| buff << "#{tab}#{tab}#{k}: #{v}"}
28
+ # end
29
+ # end
30
+ buff.join( "\n" )
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,14 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Draws a circle for a gauge
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # -----------------------------------------------------------------------------
6
+ require 'ziya/gauges/support/base'
7
+
8
+ module Ziya::Gauges::Support
9
+ class Circle < Base
10
+ has_attribute :x, :y, :radius, :start, :end,
11
+ :fill_color, :fill_alpha, :line_color, :line_alpha,
12
+ :line_thickness
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ module Ziya::Gauges::Support
2
+ class Design < Base
3
+ has_attribute :components
4
+ end
5
+ end
@@ -0,0 +1,12 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Draws an image for a gauge
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # -----------------------------------------------------------------------------
6
+ require 'ziya/gauges/support/base'
7
+
8
+ module Ziya::Gauges::Support
9
+ class Image < Base
10
+ has_attribute :url, :x, :y, :width, :height, :rotation, :alpha, :retry, :timeout
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Draws a line for a gauge
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # -----------------------------------------------------------------------------
6
+ require 'ziya/gauges/support/base'
7
+
8
+ module Ziya::Gauges::Support
9
+ class Line < Base
10
+ has_attribute :x1, :y1, :x2, :y2, :color, :alpha, :thickness
11
+ end
12
+ end
@@ -0,0 +1,24 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Create a link on a component
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # -----------------------------------------------------------------------------
6
+ require 'ziya/gauges/support/base'
7
+
8
+ module Ziya::Gauges::Support
9
+ class Link < Base
10
+ has_attribute :components
11
+
12
+ # has_attribute :areas
13
+ # attr_accessor :areas
14
+
15
+ # -------------------------------------------------------------------------
16
+ # Dump has_attribute into xml element
17
+ # def flatten( xml )
18
+ # xml.link do
19
+ # areas.each { |area| area.flatten( xml ) } if areas and !areas.empty?
20
+ # end
21
+ # end
22
+
23
+ end
24
+ end
@@ -0,0 +1,15 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Create an animation to move a component
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # -----------------------------------------------------------------------------
6
+ require 'ziya/gauges/support/base'
7
+
8
+ module Ziya::Gauges::Support
9
+ class Move < Base
10
+ has_attribute :start_x_offset, :start_y_offset, :end_x_offset, :end_y_offset, :step,
11
+ :shake_span, :shake_frequency, :shake_snap,
12
+ :shadow_alpha, :shadow_x_offset, :shadow_y_offset,
13
+ :components
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Draws a point for a gauge
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # -----------------------------------------------------------------------------
6
+ require 'ziya/gauges/support/base'
7
+
8
+ module Ziya::Gauges::Support
9
+ class Point < Base
10
+ has_attribute :x, :y
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Draws a polygon for a gauge
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # -----------------------------------------------------------------------------
6
+ require 'ziya/gauges/support/base'
7
+
8
+ module Ziya::Gauges::Support
9
+ class Polygon < Base
10
+ has_attribute :fill_color, :fill_alpha, :line_color, :line_alpha,
11
+ :line_thickness, :components
12
+ end
13
+ end
@@ -0,0 +1,21 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Draws things in a circular layout. This is an abstract class and should not
3
+ # be used directly.
4
+ #
5
+ # Author:: Fernand Galiana
6
+ # -----------------------------------------------------------------------------
7
+ require 'ziya/gauges/support/base'
8
+
9
+ module Ziya::Gauges::Support
10
+ class RadialBase < Base
11
+ has_attribute :x, :y, :radius, :start_angle, :end_angle, :ticks, :color, :alpha
12
+
13
+ # =========================================================================
14
+ protected
15
+
16
+ # converts degrees to radiant
17
+ def deg2rad( degrees )
18
+ degrees * Math::PI / 180
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,41 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Draws a set of numbers in a circular layout
3
+ #
4
+ # BOZO !! use components to render ??
5
+ #
6
+ # Author:: Fernand Galiana
7
+ # -----------------------------------------------------------------------------
8
+ require 'ziya/gauges/support/radial_base'
9
+
10
+ module Ziya::Gauges::Support
11
+ class RadialNumbers < RadialBase
12
+ has_attribute :start_num, :end_num,
13
+ :font, :size, :bold, :width, :height, :align
14
+
15
+ # overrides flatten to generate a series of radial tick marksß
16
+ def flatten( xml )
17
+ number = start_num
18
+ i = start_angle
19
+ while( i <= end_angle ) do
20
+ angle = deg2rad( i )
21
+ hash = { :x => (x + Math::sin( angle ) * radius).to_i,
22
+ :y => (y - Math::cos( angle ) * radius).to_i,
23
+ :width => width || 20,
24
+ :height => height || 20,
25
+ :font => font || "Arial",
26
+ :size => size || 10,
27
+ :bold => bold || true,
28
+ :alpha => alpha,
29
+ :rotation => i,
30
+ :align => align || "left",
31
+ :color => color }
32
+ xml.text( hash ) do
33
+ xml.text! number.to_s
34
+ end
35
+ i += (end_angle-start_angle)/(ticks-1)
36
+ number += (end_num-start_num)/(ticks-1)
37
+ end
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,29 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Draws a circle with ticks
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # -----------------------------------------------------------------------------
6
+ require 'ziya/gauges/support/radial_base'
7
+
8
+ module Ziya::Gauges::Support
9
+ class RadialTicks < RadialBase
10
+ has_attribute :length, :thickness
11
+
12
+ # overrides flatten to generate a series of radial tick marks
13
+ def flatten( xml )
14
+ i = start_angle
15
+ while( i <= end_angle ) do
16
+ angle = deg2rad( i )
17
+ hash = { :x1 => (x + Math::sin( angle ) * radius).to_i,
18
+ :y1 => (y - Math::cos( angle ) * radius).to_i,
19
+ :x2 => (x + Math::sin( angle ) * (radius + length)).to_i,
20
+ :y2 => (y - Math::cos( angle ) * (radius + length)).to_i,
21
+ :thickness => thickness,
22
+ :color => color }
23
+ xml.line( hash )
24
+ i += (end_angle-start_angle)/(ticks-1)
25
+ end
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,14 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Draws a rectangle for a gauge
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # -----------------------------------------------------------------------------
6
+ require 'ziya/gauges/support/base'
7
+
8
+ module Ziya::Gauges::Support
9
+ class Rect < Base
10
+ has_attribute :x, :y, :width, :height, :rotation,
11
+ :fill_color, :fill_alpha, :line_color, :line_alpha,
12
+ :line_thickness
13
+ end
14
+ end
@@ -0,0 +1,15 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Create an animation to rotate a component
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # -----------------------------------------------------------------------------
6
+ require 'ziya/gauges/support/base'
7
+
8
+ module Ziya::Gauges::Support
9
+ class Rotate < Base
10
+ has_attribute :x, :y, :start, :step, :span,
11
+ :shake_span, :shake_frequency, :shake_snap,
12
+ :shadow_alpha, :shadow_x_offset, :shadow_y_offset,
13
+ :components
14
+ end
15
+ end