rmagick4j 0.3.4-java → 0.3.9-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +7 -0
  2. data/History.txt +84 -0
  3. data/LICENSE.txt +31 -0
  4. data/README.txt +25 -0
  5. data/Rakefile +65 -0
  6. data/lib/magick4j.jar +0 -0
  7. data/lib/{RMagick.rb → rmagick.rb} +574 -405
  8. data/lib/rmagick4j/constants.rb +34 -0
  9. data/lib/rmagick4j/draw.rb +124 -0
  10. data/lib/rmagick4j/enum.rb +120 -0
  11. data/lib/rmagick4j/gradient_fill.rb +14 -0
  12. data/lib/rmagick4j/image.rb +351 -0
  13. data/lib/rmagick4j/image_list.rb +25 -0
  14. data/lib/rmagick4j/pixel.rb +170 -0
  15. data/lib/rmagick4j/rmagick4j.rb +15 -430
  16. data/lib/rmagick4j/texture_fill.rb +14 -0
  17. data/lib/rmagick4j/type_metric.rb +8 -0
  18. data/lib/rmagick4j/version.rb +5 -0
  19. data/lib/rvg/clippath.rb +2 -2
  20. data/lib/rvg/container.rb +2 -2
  21. data/lib/rvg/describable.rb +2 -2
  22. data/lib/rvg/embellishable.rb +2 -2
  23. data/lib/rvg/misc.rb +3 -3
  24. data/lib/rvg/paint.rb +7 -2
  25. data/lib/rvg/pathdata.rb +2 -2
  26. data/lib/rvg/rvg.rb +3 -3
  27. data/lib/rvg/stretchable.rb +15 -3
  28. data/lib/rvg/stylable.rb +2 -2
  29. data/lib/rvg/text.rb +2 -2
  30. data/lib/rvg/transformable.rb +2 -2
  31. data/lib/rvg/units.rb +2 -2
  32. data/test/RMagickTestSuite.rb +129 -0
  33. data/test/eyetests/bullseye.rb +151 -0
  34. data/test/eyetests/doc.rb +79 -0
  35. data/test/eyetests/tests/draw_arc_basic.rb +16 -0
  36. data/test/eyetests/tests/draw_circle_affine.rb +19 -0
  37. data/test/eyetests/tests/draw_circle_basic.rb +16 -0
  38. data/test/eyetests/tests/draw_clip_path.rb +44 -0
  39. data/test/eyetests/tests/draw_ellipse_affine.rb +19 -0
  40. data/test/eyetests/tests/draw_ellipse_basic.rb +16 -0
  41. data/test/eyetests/tests/draw_line_affine.rb +24 -0
  42. data/test/eyetests/tests/draw_line_basic.rb +21 -0
  43. data/test/eyetests/tests/draw_multiline_type_metrics.rb +42 -0
  44. data/test/eyetests/tests/draw_pattern_1.rb +35 -0
  45. data/test/eyetests/tests/draw_polygon_affine.rb +22 -0
  46. data/test/eyetests/tests/draw_polygon_basic.rb +19 -0
  47. data/test/eyetests/tests/draw_polyline_affine.rb +19 -0
  48. data/test/eyetests/tests/draw_polyline_basic.rb +18 -0
  49. data/test/eyetests/tests/draw_pop_push.rb +16 -0
  50. data/test/eyetests/tests/draw_pop_push_translate.rb +22 -0
  51. data/test/eyetests/tests/draw_rectangle_affine.rb +16 -0
  52. data/test/eyetests/tests/draw_rectangle_basic.rb +16 -0
  53. data/test/eyetests/tests/draw_rectangle_narrow.rb +18 -0
  54. data/test/eyetests/tests/draw_rmagick_test_01.rb +35 -0
  55. data/test/eyetests/tests/draw_rmagick_test_02.rb +40 -0
  56. data/test/eyetests/tests/draw_rmagick_test_03.rb +17 -0
  57. data/test/eyetests/tests/draw_rmagick_test_04.rb +21 -0
  58. data/test/eyetests/tests/draw_rotate_01.rb +33 -0
  59. data/test/eyetests/tests/draw_roundrectangle_affine.rb +19 -0
  60. data/test/eyetests/tests/draw_roundrectangle_basic.rb +16 -0
  61. data/test/eyetests/tests/draw_scale_01.rb +33 -0
  62. data/test/eyetests/tests/draw_skewx_01.rb +34 -0
  63. data/test/eyetests/tests/draw_skewy_01.rb +33 -0
  64. data/test/eyetests/tests/draw_stroke_miterlimit.rb +21 -0
  65. data/test/eyetests/tests/effect_blur.rb +9 -0
  66. data/test/eyetests/tests/effect_charcoal.rb +9 -0
  67. data/test/eyetests/tests/effect_edge.rb +9 -0
  68. data/test/eyetests/tests/effect_implode.rb +9 -0
  69. data/test/eyetests/tests/effect_negate.rb +9 -0
  70. data/test/eyetests/tests/effect_negate_true.rb +9 -0
  71. data/test/eyetests/tests/effect_normalize.rb +9 -0
  72. data/test/eyetests/tests/effect_shade.rb +9 -0
  73. data/test/eyetests/tests/effect_solarize.rb +10 -0
  74. data/test/eyetests/tests/effect_wave.rb +9 -0
  75. data/test/eyetests/tests/gradient_fill_horizontal_diagonal_fill.rb +9 -0
  76. data/test/eyetests/tests/gradient_fill_horizontal_fill.rb +9 -0
  77. data/test/eyetests/tests/gradient_fill_point_fill.rb +9 -0
  78. data/test/eyetests/tests/gradient_fill_vertical_diagonal_fill.rb +9 -0
  79. data/test/eyetests/tests/gradient_fill_vertical_fill.rb +9 -0
  80. data/test/eyetests/tests/gruff_accumulator_bar.rb +29 -0
  81. data/test/eyetests/tests/gruff_area_1.rb +16 -0
  82. data/test/eyetests/tests/gruff_area_2.rb +27 -0
  83. data/test/eyetests/tests/gruff_bar_1.rb +29 -0
  84. data/test/eyetests/tests/gruff_bar_2.rb +19 -0
  85. data/test/eyetests/tests/gruff_dot_1.rb +19 -0
  86. data/test/eyetests/tests/gruff_line_1.rb +13 -0
  87. data/test/eyetests/tests/gruff_line_2.rb +20 -0
  88. data/test/eyetests/tests/gruff_net_1.rb +16 -0
  89. data/test/eyetests/tests/gruff_net_2.rb +16 -0
  90. data/test/eyetests/tests/gruff_pie_1.rb +21 -0
  91. data/test/eyetests/tests/gruff_pie_2.rb +22 -0
  92. data/test/eyetests/tests/gruff_scene_1.rb +14 -0
  93. data/test/eyetests/tests/gruff_scene_2.rb +14 -0
  94. data/test/eyetests/tests/gruff_sidebar.rb +32 -0
  95. data/test/eyetests/tests/gruff_sidestacked_bar_1.rb +26 -0
  96. data/test/eyetests/tests/gruff_sidestacked_bar_2.rb +26 -0
  97. data/test/eyetests/tests/gruff_spider_1.rb +22 -0
  98. data/test/eyetests/tests/gruff_spider_2.rb +15 -0
  99. data/test/eyetests/tests/gruff_stacked_area_1.rb +23 -0
  100. data/test/eyetests/tests/gruff_stacked_bar_1.rb +23 -0
  101. data/test/eyetests/tests/gruff_stacked_bar_2.rb +26 -0
  102. data/test/eyetests/tests/hatch_fill.rb +9 -0
  103. data/test/eyetests/tests/image_list_flatten_images.rb +15 -0
  104. data/test/eyetests/tests/new_image.rb +31 -0
  105. data/test/eyetests/tests/path_a_command_01.rb +16 -0
  106. data/test/eyetests/tests/path_a_command_02.rb +19 -0
  107. data/test/eyetests/tests/path_c_command_01.rb +16 -0
  108. data/test/eyetests/tests/path_c_command_02.rb +16 -0
  109. data/test/eyetests/tests/path_complex_01.rb +16 -0
  110. data/test/eyetests/tests/path_espiral_01.rb +29 -0
  111. data/test/eyetests/tests/path_h_command_01.rb +16 -0
  112. data/test/eyetests/tests/path_h_command_02.rb +16 -0
  113. data/test/eyetests/tests/path_l_command_01.rb +16 -0
  114. data/test/eyetests/tests/path_l_command_02.rb +16 -0
  115. data/test/eyetests/tests/path_m_command_01.rb +16 -0
  116. data/test/eyetests/tests/path_m_command_02.rb +16 -0
  117. data/test/eyetests/tests/path_m_command_03.rb +16 -0
  118. data/test/eyetests/tests/path_q_command_01.rb +16 -0
  119. data/test/eyetests/tests/path_q_command_02.rb +16 -0
  120. data/test/eyetests/tests/path_q_command_03.rb +25 -0
  121. data/test/eyetests/tests/path_s_command_01.rb +16 -0
  122. data/test/eyetests/tests/path_s_command_02.rb +16 -0
  123. data/test/eyetests/tests/path_star_01.rb +19 -0
  124. data/test/eyetests/tests/path_t_command_01.rb +16 -0
  125. data/test/eyetests/tests/path_t_command_02.rb +16 -0
  126. data/test/eyetests/tests/path_v_command_01.rb +16 -0
  127. data/test/eyetests/tests/path_v_command_02.rb +16 -0
  128. data/test/eyetests/tests/store_pixel_smiley.rb +123 -0
  129. data/test/eyetests/tests/texture_fill.rb +11 -0
  130. data/test/gruff_tests/test/gruff_test_case.rb +123 -0
  131. data/test/gruff_tests/test/monkey_gruff.rb +7 -0
  132. data/test/gruff_tests/test/test_accumulator_bar.rb +50 -0
  133. data/test/gruff_tests/test/test_area.rb +134 -0
  134. data/test/gruff_tests/test/test_bar.rb +295 -0
  135. data/test/gruff_tests/test/test_base.rb +8 -0
  136. data/test/gruff_tests/test/test_bullet.rb +26 -0
  137. data/test/gruff_tests/test/test_dot.rb +273 -0
  138. data/test/gruff_tests/test/test_legend.rb +68 -0
  139. data/test/gruff_tests/test/test_line.rb +554 -0
  140. data/test/gruff_tests/test/test_mini_bar.rb +33 -0
  141. data/test/gruff_tests/test/test_mini_pie.rb +20 -0
  142. data/test/gruff_tests/test/test_mini_side_bar.rb +37 -0
  143. data/test/gruff_tests/test/test_net.rb +230 -0
  144. data/test/gruff_tests/test/test_photo.rb +41 -0
  145. data/test/gruff_tests/test/test_pie.rb +154 -0
  146. data/test/gruff_tests/test/test_scene.rb +100 -0
  147. data/test/gruff_tests/test/test_side_bar.rb +12 -0
  148. data/test/gruff_tests/test/test_sidestacked_bar.rb +89 -0
  149. data/test/gruff_tests/test/test_spider.rb +216 -0
  150. data/test/gruff_tests/test/test_stacked_area.rb +52 -0
  151. data/test/gruff_tests/test/test_stacked_bar.rb +52 -0
  152. data/test/images/clown.jpg +0 -0
  153. data/test/images/texture.jpg +0 -0
  154. data/test/implemented_methods.rb +18 -0
  155. data/test/spec/draw_spec.rb +43 -0
  156. data/test/spec/features/step_definitions/geometry_steps.rb +22 -0
  157. data/test/spec/features/step_definitions/image_filling_steps.rb +49 -0
  158. data/test/spec/features/support/env.rb +3 -0
  159. data/test/spec/image_constants.rb +76 -0
  160. data/test/spec/image_spec.rb +83 -0
  161. data/test/spec/pixel_spec.rb +89 -0
  162. metadata +333 -45
  163. data/lib/RMagick.jar +0 -0
  164. data/lib/jhlabs-filters.jar +0 -0
@@ -0,0 +1,33 @@
1
+
2
+ require File.dirname(__FILE__) + "/gruff_test_case"
3
+
4
+ class TestMiniBar < GruffTestCase
5
+
6
+ def test_simple_bar
7
+ setup_single_dataset
8
+ g = setup_basic_graph(Gruff::Mini::Bar, 200)
9
+ g.hide_mini_legend = true
10
+ write_test_file g, 'mini_bar.png'
11
+ end
12
+
13
+ # def test_simple_bar_wide_dataset
14
+ # setup_wide_dataset
15
+ # g = setup_basic_graph(Gruff::Mini::Bar, 200)
16
+ # write_test_file g, 'mini_bar_wide_data.png'
17
+ # end
18
+ #
19
+ # def test_code_sample
20
+ # g = Gruff::Mini::Bar.new(200)
21
+ # g.data "Jim", [200, 500, 400]
22
+ # g.labels = { 0 => 'This Month', 1 => 'Average', 2 => 'Overall'}
23
+ # g.write "mini_bar_one_color.png"
24
+ #
25
+ # g = Gruff::Mini::Bar.new(200)
26
+ # g.data "Car", 200
27
+ # g.data "Food", 500
28
+ # g.data "Art", 1000
29
+ # g.data "Music", 16
30
+ # g.write "mini_bar_many_colors.png"
31
+ # end
32
+
33
+ end
@@ -0,0 +1,20 @@
1
+
2
+ require File.dirname(__FILE__) + "/gruff_test_case"
3
+
4
+ class TestMiniPie < GruffTestCase
5
+
6
+ def test_simple_pie
7
+ g = setup_basic_graph(Gruff::Mini::Pie, 200)
8
+ write_test_file g, 'mini_pie.png'
9
+ end
10
+
11
+ # def test_code_sample
12
+ # g = Gruff::Mini::Pie.new(200)
13
+ # g.data "Car", 200
14
+ # g.data "Food", 500
15
+ # g.data "Art", 1000
16
+ # g.data "Music", 16
17
+ # g.write "mini_pie.png"
18
+ # end
19
+
20
+ end
@@ -0,0 +1,37 @@
1
+
2
+ require File.dirname(__FILE__) + "/gruff_test_case"
3
+
4
+ class TestMiniSideBar < GruffTestCase
5
+
6
+ def test_one_color
7
+ # Use a single data set
8
+ @datasets = [
9
+ [:Jimmy, [25, 36, 86, 39]]
10
+ ]
11
+ @labels = {
12
+ 0 => 'Auto',
13
+ 1 => 'Entertainment',
14
+ 2 => 'Food',
15
+ 3 => 'Bus'
16
+ }
17
+
18
+ g = setup_basic_graph(Gruff::Mini::SideBar, 200)
19
+ write_test_file g, 'mini_side_bar.png'
20
+ end
21
+
22
+ def test_multi_color
23
+ # @datasets = [
24
+ # [:Jimmy, [25, 36, 86, 39]]
25
+ # ]
26
+ # @labels = {
27
+ # 0 => 'Auto',
28
+ # 1 => 'Entertainment',
29
+ # 2 => 'Food',
30
+ # 3 => 'Bus'
31
+ # }
32
+
33
+ g = setup_basic_graph(Gruff::Mini::SideBar, 200)
34
+ write_test_file g, 'mini_side_bar_multi_color.png'
35
+ end
36
+
37
+ end
@@ -0,0 +1,230 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require File.dirname(__FILE__) + "/gruff_test_case"
4
+
5
+ class TestGruffNet < GruffTestCase
6
+
7
+ def setup
8
+ @datasets = [
9
+ [:Jimmy, [25, 36, 86, 39, 25, 31, 79, 88]],
10
+ [:Charles, [80, 54, 67, 54, 68, 70, 90, 95]],
11
+ [:Julie, [22, 29, 35, 38, 36, 40, 46, 57]],
12
+ [:Jane, [95, 95, 95, 90, 85, 80, 88, 100]],
13
+ [:Philip, [90, 34, 23, 12, 78, 89, 98, 88]],
14
+ ["Arthur", [5, 10, 13, 11, 6, 16, 22, 32]],
15
+ ]
16
+
17
+ @sample_labels = {
18
+ 0 => '5/6',
19
+ 1 => '5/15',
20
+ 2 => '5/24',
21
+ 3 => '5/30',
22
+ 4 => '6/4',
23
+ 5 => '6/12',
24
+ 6 => '6/21',
25
+ 7 => '6/28',
26
+ }
27
+ end
28
+
29
+ def test_net_small_values
30
+ @datasets = [
31
+ [:small, [0.1, 0.14356, 0.0, 0.5674839, 0.456]],
32
+ [:small2, [0.2, 0.3, 0.1, 0.05, 0.9]]
33
+ ]
34
+
35
+ g = Gruff::Net.new
36
+ g.title = "Small Values Net Graph Test"
37
+ @datasets.each do |data|
38
+ g.data(data[0], data[1])
39
+ end
40
+ g.write("test/output/net_small.png")
41
+
42
+ g = Gruff::Net.new(400)
43
+ g.title = "Small Values Net Graph Test 400px"
44
+ @datasets.each do |data|
45
+ g.data(data[0], data[1])
46
+ end
47
+ g.write("test/output/net_small_small.png")
48
+ end
49
+
50
+ def test_net_starts_with_zero
51
+ @datasets = [
52
+ [:first0, [0, 5, 10, 8, 18]],
53
+ [:normal, [1, 2, 3, 4, 5]]
54
+ ]
55
+
56
+ g = Gruff::Net.new
57
+ g.title = "Small Values Net Graph Test"
58
+ @datasets.each do |data|
59
+ g.data(data[0], data[1])
60
+ end
61
+ g.write("test/output/net_small_zero.png")
62
+
63
+ g = Gruff::Net.new(400)
64
+ g.title = "Small Values Net Graph Test 400px"
65
+ @datasets.each do |data|
66
+ g.data(data[0], data[1])
67
+ end
68
+ g.write("test/output/net_small_small_zero.png")
69
+ end
70
+
71
+
72
+ def test_net_large_values
73
+ @datasets = [
74
+ [:large, [100_005, 35_000, 28_000, 27_000]],
75
+ [:large2, [35_000, 28_000, 27_000, 100_005]],
76
+ [:large3, [28_000, 27_000, 100_005, 35_000]],
77
+ [:large4, [1_238, 39_092, 27_938, 48_876]]
78
+ ]
79
+
80
+ g = Gruff::Net.new
81
+ g.title = "Very Large Values Net Graph Test"
82
+ @datasets.each do |data|
83
+ g.data(data[0], data[1])
84
+ end
85
+
86
+ g.write("test/output/net_large.png")
87
+ end
88
+
89
+ def test_many_datapoints
90
+ g = Gruff::Net.new
91
+ g.title = "Many Multi-Net Graph Test"
92
+ g.labels = {
93
+ 0 => 'June',
94
+ 10 => 'July',
95
+ 30 => 'August',
96
+ 50 => 'September',
97
+ }
98
+ g.data('many points', (0..50).collect {|i| rand(100) })
99
+
100
+ # Default theme
101
+ g.write("test/output/net_many.png")
102
+ end
103
+
104
+
105
+ def test_similar_high_end_values
106
+ g = Gruff::Net.new
107
+ g.title = "Similar High End Values Test"
108
+ g.data('similar points', %w(29.43 29.459 29.498 29.53 29.548 29.589 29.619 29.66 29.689 29.849 29.878 29.74 29.769 29.79 29.808 29.828).collect {|i| i.to_f} )
109
+
110
+ # Default theme
111
+ g.write("test/output/net_similar_high_end_values.png")
112
+ end
113
+
114
+ def test_many_nets_graph_small
115
+ g = Gruff::Net.new(400)
116
+ g.title = "Many Values Net Test 400px"
117
+ g.labels = {
118
+ 0 => '5/6',
119
+ 10 => '5/15',
120
+ 20 => '5/24',
121
+ 30 => '5/30',
122
+ 40 => '6/4',
123
+ 50 => '6/16'
124
+ }
125
+ %w{jimmy jane philip arthur julie bert}.each do |student_name|
126
+ g.data(student_name, (0..50).collect { |i| rand 100 })
127
+ end
128
+
129
+ # Default theme
130
+ g.write("test/output/net_many_nets_small.png")
131
+ end
132
+
133
+ def test_dots_graph_tiny
134
+ g = Gruff::Net.new(300)
135
+ g.title = "Dots Test 300px"
136
+ g.labels = {
137
+ 0 => '5/6',
138
+ 10 => '5/15',
139
+ 20 => '5/24',
140
+ 30 => '5/30',
141
+ 40 => '6/4',
142
+ 50 => '6/16'
143
+ }
144
+ %w{jimmy jane philip arthur julie bert}.each do |student_name|
145
+ g.data(student_name, (0..50).collect { |i| rand 100 })
146
+ end
147
+
148
+ # Default theme
149
+ g.write("test/output/net_dots_tiny.png")
150
+ end
151
+
152
+ def test_no_data
153
+ g = Gruff::Net.new(400)
154
+ g.title = "No Data"
155
+ # Default theme
156
+ g.write("test/output/net_no_data.png")
157
+
158
+ g = Gruff::Net.new(400)
159
+ g.title = "No Data Title"
160
+ g.no_data_message = 'There is no data'
161
+ g.write("test/output/net_no_data_msg.png")
162
+ end
163
+
164
+
165
+ def test_all_zeros
166
+ g = Gruff::Net.new(400)
167
+ g.title = "All Zeros"
168
+
169
+ g.data(:gus, [0,0,0,0])
170
+
171
+ # Default theme
172
+ g.write("test/output/net_no_data_other.png")
173
+ end
174
+
175
+ def test_no_title
176
+ g = Gruff::Net.new(400)
177
+ g.labels = @sample_labels
178
+ @datasets.each do |data|
179
+ g.data(data[0], data[1])
180
+ end
181
+
182
+ g.write("test/output/net_no_title.png")
183
+ end
184
+
185
+ def test_no_net_markers
186
+ g = setup_basic_graph(400)
187
+ g.title = "No Net Markers"
188
+ g.hide_line_markers = true
189
+ g.write("test/output/net_no_net_markers.png")
190
+ end
191
+
192
+ def test_no_legend
193
+ g = setup_basic_graph(400)
194
+ g.title = "No Legend"
195
+ g.hide_legend = true
196
+ g.write("test/output/net_no_legend.png")
197
+ end
198
+
199
+ def test_nothing_but_the_graph
200
+ g = setup_basic_graph(400)
201
+ g.title = "THIS TITLE SHOULD NOT DISPLAY!!!"
202
+ g.hide_line_markers = true
203
+ g.hide_legend = true
204
+ g.hide_title = true
205
+ g.write("test/output/net_nothing_but_the_graph.png")
206
+ end
207
+
208
+ def test_wide_graph
209
+ g = setup_basic_graph('800x400')
210
+ g.title = "Wide Graph"
211
+ g.write("test/output/net_wide_graph.png")
212
+
213
+ g = setup_basic_graph('400x200')
214
+ g.title = "Wide Graph Small"
215
+ g.write("test/output/net_wide_graph_small.png")
216
+ end
217
+
218
+ protected
219
+
220
+ def setup_basic_graph(size=800)
221
+ g = Gruff::Net.new(size)
222
+ g.title = "My Graph Title"
223
+ g.labels = @sample_labels
224
+ @datasets.each do |data|
225
+ g.data(data[0], data[1])
226
+ end
227
+ return g
228
+ end
229
+
230
+ end
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require File.dirname(__FILE__) + "/gruff_test_case"
4
+
5
+ class TestGruffPhotoBar < GruffTestCase
6
+
7
+ # def setup
8
+ # @datasets = [
9
+ # [:Jimmy, [25, 36, 86, 39]],
10
+ # [:Charles, [80, 54, 67, 54]],
11
+ # # [:Charity, [0, nil, 100, 90]],
12
+ # ]
13
+ # end
14
+ #
15
+ # def test_bar_graph
16
+ # bar_graph_sized
17
+ # bar_graph_sized(400)
18
+ # end
19
+ #
20
+ #
21
+ # protected
22
+ #
23
+ # def bar_graph_sized(size=800)
24
+ # g = Gruff::PhotoBar.new(size)
25
+ # g.title = "Photo Bar Graph Test #{size}px"
26
+ # g.labels = {
27
+ # 0 => '5/6',
28
+ # 1 => '5/15',
29
+ # 2 => '5/24',
30
+ # 3 => '5/30',
31
+ # }
32
+ # @datasets.each do |data|
33
+ # g.data(*data)
34
+ # end
35
+ #
36
+ # g.theme = 'plastik'
37
+ #
38
+ # g.write("test/output/photo_plastik_#{size}.png")
39
+ # end
40
+
41
+ end
@@ -0,0 +1,154 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require File.dirname(__FILE__) + "/gruff_test_case"
4
+
5
+ class TestGruffPie < GruffTestCase
6
+
7
+ def setup
8
+ @datasets = [
9
+ [:Darren, [25]],
10
+ [:Chris, [80]],
11
+ [:Egbert, [22]],
12
+ [:Adam, [95]],
13
+ [:Bill, [90]],
14
+ ["Frank", [5]],
15
+ ["Zero", [0]],
16
+ ]
17
+ end
18
+
19
+ def test_pie_graph
20
+ g = Gruff::Pie.new
21
+ g.title = "Visual Pie Graph Test"
22
+ @datasets.each do |data|
23
+ g.data(data[0], data[1])
24
+ end
25
+
26
+ # Default theme
27
+ g.write("test/output/pie_keynote.png")
28
+ end
29
+
30
+ def test_pie_graph_greyscale
31
+ g = Gruff::Pie.new
32
+ g.title = "Greyscale Pie Graph Test"
33
+ g.theme_greyscale
34
+ @datasets.each do |data|
35
+ g.data(data[0], data[1])
36
+ end
37
+
38
+ # Default theme
39
+ g.write("test/output/pie_grey.png")
40
+ end
41
+
42
+ def test_pie_graph_pastel
43
+ g = Gruff::Pie.new
44
+ g.theme_pastel
45
+ g.title = "Pastel Pie Graph Test"
46
+ @datasets.each do |data|
47
+ g.data(data[0], data[1])
48
+ end
49
+
50
+ # Default theme
51
+ g.write("test/output/pie_pastel.png")
52
+ end
53
+
54
+
55
+ def test_pie_graph_small
56
+ g = Gruff::Pie.new(400)
57
+ g.title = "Visual Pie Graph Test Small"
58
+ @datasets.each do |data|
59
+ g.data(data[0], data[1])
60
+ end
61
+
62
+ # Default theme
63
+ g.write("test/output/pie_keynote_small.png")
64
+ end
65
+
66
+ def test_pie_graph_nearly_equal
67
+ g = Gruff::Pie.new
68
+ g.title = "Pie Graph Nearly Equal"
69
+
70
+ g.data(:Blake, [41])
71
+ g.data(:Aaron, [42])
72
+ # g.data(:Grouch, [40])
73
+ # g.data(:Snuffleupagus, [43])
74
+
75
+ g.write("test/output/pie_nearly_equal.png")
76
+ end
77
+
78
+ def test_pie_graph_equal
79
+ g = Gruff::Pie.new
80
+ g.title = "Pie Graph Equal"
81
+
82
+ g.data(:Bert, [41])
83
+ g.data(:Adam, [41])
84
+
85
+ g.write("test/output/pie_equal.png")
86
+ end
87
+
88
+ def test_pie_graph_zero
89
+ g = Gruff::Pie.new
90
+ g.title = "Pie Graph One Zero"
91
+
92
+ g.data(:Bert, [0])
93
+ g.data(:Adam, [1])
94
+
95
+ g.write("test/output/pie_zero.png")
96
+ end
97
+
98
+
99
+ def test_pie_graph_one_val
100
+ g = Gruff::Pie.new
101
+ g.title = "Pie Graph One Val"
102
+
103
+ g.data(:Bert, 53)
104
+ g.data(:Adam, 29)
105
+
106
+ g.write("test/output/pie_one_val.png")
107
+ end
108
+
109
+
110
+ def test_wide
111
+ g = setup_basic_graph('800x400')
112
+ g.title = "Wide Pie"
113
+ g.write("test/output/pie_wide.png")
114
+ end
115
+
116
+ def test_label_size
117
+ g = setup_basic_graph()
118
+ g.title = "Pie With Small Legend"
119
+ g.legend_font_size = 10
120
+ g.write("test/output/pie_legend.png")
121
+
122
+ g = setup_basic_graph(400)
123
+ g.title = "Small Pie With Small Legend"
124
+ g.legend_font_size = 10
125
+ g.write("test/output/pie_legend_small.png")
126
+ end
127
+
128
+
129
+ def test_tiny_simple_pie
130
+ @datasets = (1..5).map {|n| ['Auto', [rand(100)]]}
131
+
132
+ g = setup_basic_graph 200
133
+ g.hide_legend = true
134
+ g.hide_title = true
135
+ g.hide_line_numbers = true
136
+
137
+ g.marker_font_size = 40.0
138
+ g.minimum_value = 0.0
139
+
140
+ write_test_file g, "pie_simple.png"
141
+ end
142
+
143
+ protected
144
+
145
+ def setup_basic_graph(size=800)
146
+ g = Gruff::Pie.new(size)
147
+ g.title = "My Graph Title"
148
+ @datasets.each do |data|
149
+ g.data(data[0], data[1])
150
+ end
151
+ return g
152
+ end
153
+
154
+ end