rmagick4j 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/Manifest.txt +122 -107
  2. data/lib/RMagick.rb +84 -4
  3. data/lib/magick4j.jar +0 -0
  4. data/lib/rmagick4j/constants.rb +1 -0
  5. data/lib/rmagick4j/image.rb +51 -3
  6. data/lib/rmagick4j/image_list.rb +4 -0
  7. data/lib/rmagick4j/rmagick4j.rb +0 -1
  8. data/lib/rmagick4j/version.rb +1 -1
  9. data/test/eyetests/bullseye.rb +2 -1
  10. data/test/eyetests/doc.rb +79 -0
  11. data/test/eyetests/tests/draw_multiline_type_metrics.rb +1 -1
  12. data/test/eyetests/tests/draw_pop_push.rb +16 -0
  13. data/test/eyetests/tests/draw_pop_push_translate.rb +1 -1
  14. data/test/eyetests/tests/effect_blur.rb +9 -0
  15. data/test/eyetests/tests/effect_charcoal.rb +9 -0
  16. data/test/eyetests/tests/effect_edge.rb +9 -0
  17. data/test/eyetests/tests/effect_implode.rb +9 -0
  18. data/test/eyetests/tests/effect_negate.rb +9 -0
  19. data/test/eyetests/tests/effect_negate_true.rb +9 -0
  20. data/test/eyetests/tests/effect_normalize.rb +9 -0
  21. data/test/eyetests/tests/effect_shade.rb +9 -0
  22. data/test/eyetests/tests/effect_solarize.rb +10 -0
  23. data/test/eyetests/tests/effect_wave.rb +9 -0
  24. data/test/eyetests/tests/gradient_fill_vertical_fill.rb +1 -1
  25. data/test/eyetests/tests/gruff_dot_1.rb +19 -0
  26. data/test/eyetests/tests/gruff_line_2.rb +1 -1
  27. data/test/eyetests/tests/gruff_pie_1.rb +1 -1
  28. data/test/eyetests/tests/gruff_stacked_area_1.rb +23 -0
  29. data/test/eyetests/tests/new_image.rb +8 -1
  30. data/test/gruff_tests/test/gruff_test_case.rb +5 -2
  31. data/test/gruff_tests/test/test_bar.rb +15 -3
  32. data/test/gruff_tests/test/test_bullet.rb +26 -26
  33. data/test/gruff_tests/test/test_dot.rb +273 -0
  34. data/test/gruff_tests/test/test_legend.rb +37 -40
  35. data/test/gruff_tests/test/test_line.rb +75 -14
  36. data/test/gruff_tests/test/test_mini_bar.rb +1 -0
  37. data/test/gruff_tests/test/test_stacked_area.rb +52 -0
  38. data/test/spec/draw_spec.rb +1 -0
  39. data/test/spec/image_spec.rb +15 -1
  40. data/test/spec/stories/geometry_runner.rb +1 -1
  41. data/test/spec/stories/geometry_story.rb +1 -1
  42. metadata +186 -164
  43. data/lib/jhlabs-filters.jar +0 -0
@@ -0,0 +1,273 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require File.dirname(__FILE__) + "/gruff_test_case"
4
+
5
+ class TestGruffDot < GruffTestCase
6
+
7
+ # TODO Delete old output files once when starting tests
8
+
9
+ def setup
10
+ @datasets = [
11
+ [:Jimmy, [25, 36, 86, 39]],
12
+ [:Charles, [80, 54, 67, 54]],
13
+ [:Julie, [22, 29, 35, 38]],
14
+ #[:Jane, [95, 95, 95, 90, 85, 80, 88, 100]],
15
+ #[:Philip, [90, 34, 23, 12, 78, 89, 98, 88]],
16
+ #["Arthur", [5, 10, 13, 11, 6, 16, 22, 32]],
17
+ ]
18
+ end
19
+
20
+ def test_dot_graph
21
+ g = setup_basic_graph
22
+ g.title = "Dot Graph Test"
23
+ g.write("test/output/dot_keynote.png")
24
+ end
25
+
26
+ def test_dot_graph_set_colors
27
+ g = Gruff::Dot.new
28
+ g.title = "Dot Graph With Manual Colors"
29
+ g.labels = {
30
+ 0 => '5/6',
31
+ 1 => '5/15',
32
+ 2 => '5/24',
33
+ 3 => '5/30',
34
+ }
35
+ g.data(:Art, [0, 5, 8, 15], '#990000')
36
+ g.data(:Philosophy, [10, 3, 2, 8], '#009900')
37
+ g.data(:Science, [2, 15, 8, 11], '#990099')
38
+
39
+ g.minimum_value = 0
40
+
41
+ g.write("test/output/dot_manual_colors.png")
42
+ end
43
+
44
+ def test_dot_graph_small
45
+ g = Gruff::Dot.new(400)
46
+ g.title = "Visual Multi-Line Dot Graph Test"
47
+ g.labels = {
48
+ 0 => '5/6',
49
+ 1 => '5/15',
50
+ 2 => '5/24',
51
+ 3 => '5/30',
52
+ }
53
+ @datasets.each do |data|
54
+ g.data(data[0], data[1])
55
+ end
56
+
57
+ g.write("test/output/dot_keynote_small.png")
58
+ end
59
+
60
+ # Somewhat worthless test. Should an error be thrown?
61
+ # def test_nil_font
62
+ # g = setup_basic_graph 400
63
+ # g.title = "Nil Font"
64
+ # g.font = nil
65
+ # g.write "test/output/dot_nil_font.png"
66
+ # end
67
+
68
+
69
+ def test_no_line_markers
70
+ g = setup_basic_graph(400)
71
+ g.title = "No Line Markers"
72
+ g.hide_line_markers = true
73
+ g.write("test/output/dot_no_line_markers.png")
74
+ end
75
+
76
+ def test_no_legend
77
+ g = setup_basic_graph(400)
78
+ g.title = "No Legend"
79
+ g.hide_legend = true
80
+ g.write("test/output/dot_no_legend.png")
81
+ end
82
+
83
+ def test_no_title
84
+ g = setup_basic_graph(400)
85
+ g.title = "No Title"
86
+ g.hide_title = true
87
+ g.write("test/output/dot_no_title.png")
88
+ end
89
+
90
+ def test_no_title_or_legend
91
+ g = setup_basic_graph(400)
92
+ g.title = "No Title or Legend"
93
+ g.hide_legend = true
94
+ g.hide_title = true
95
+ g.write("test/output/dot_no_title_or_legend.png")
96
+ end
97
+
98
+ def test_set_marker_count
99
+ g = setup_basic_graph(400)
100
+ g.title = "Set marker"
101
+ g.marker_count = 10
102
+ g.write("test/output/dot_set_marker.png")
103
+ end
104
+
105
+ def test_set_legend_box_size
106
+ g = setup_basic_graph(400)
107
+ g.title = "Set Small Legend Box Size"
108
+ g.legend_box_size = 10.0
109
+ g.write("test/output/dot_set_legend_box_size_sm.png")
110
+
111
+ g = setup_basic_graph(400)
112
+ g.title = "Set Large Legend Box Size"
113
+ g.legend_box_size = 50.0
114
+ g.write("test/output/dot_set_legend_box_size_lg.png")
115
+ end
116
+
117
+ def test_x_y_labels
118
+ g = setup_basic_graph(400)
119
+ g.title = "X Y Labels"
120
+ g.x_axis_label = 'Score (%)'
121
+ g.y_axis_label = "Students"
122
+ g.write("test/output/dot_x_y_labels.png")
123
+ end
124
+
125
+ def test_wide_graph
126
+ g = setup_basic_graph('800x400')
127
+ g.title = "Wide Graph"
128
+ g.write("test/output/dot_wide_graph.png")
129
+
130
+ g = setup_basic_graph('400x200')
131
+ g.title = "Wide Graph Small"
132
+ g.write("test/output/dot_wide_graph_small.png")
133
+ end
134
+
135
+
136
+ def test_tall_graph
137
+ g = setup_basic_graph('400x600')
138
+ g.title = "Tall Graph"
139
+ g.write("test/output/dot_tall_graph.png")
140
+
141
+ g = setup_basic_graph('200x400')
142
+ g.title = "Tall Graph Small"
143
+ g.write("test/output/dot_tall_graph_small.png")
144
+ end
145
+
146
+
147
+ def test_one_value
148
+ g = Gruff::Dot.new
149
+ g.title = "One Value Graph Test"
150
+ g.labels = {
151
+ 0 => '1',
152
+ 1 => '2'
153
+ }
154
+ g.data('one', [1,1])
155
+
156
+ g.write("test/output/dot_one_value.png")
157
+ end
158
+
159
+
160
+ def test_negative
161
+ g = Gruff::Dot.new
162
+ g.title = "Pos/Neg Dot Graph Test"
163
+ g.labels = {
164
+ 0 => '5/6',
165
+ 1 => '5/15',
166
+ 2 => '5/24',
167
+ 3 => '5/30',
168
+ }
169
+ g.data(:apples, [-1, 0, 4, -4])
170
+ g.data(:peaches, [10, 8, 6, 3])
171
+
172
+ g.write("test/output/dot_pos_neg.png")
173
+ end
174
+
175
+
176
+ def test_nearly_zero
177
+ g = Gruff::Dot.new
178
+ g.title = "Nearly Zero Graph"
179
+ g.labels = {
180
+ 0 => '5/6',
181
+ 1 => '5/15',
182
+ 2 => '5/24',
183
+ 3 => '5/30',
184
+ }
185
+ g.data(:apples, [1, 2, 3, 4])
186
+ g.data(:peaches, [4, 3, 2, 1])
187
+ g.minimum_value = 0
188
+ g.maximum_value = 10
189
+ g.write("test/output/dot_nearly_zero_max_10.png")
190
+ end
191
+
192
+ def test_y_axis_increment
193
+ generate_with_y_axis_increment 2.0
194
+ generate_with_y_axis_increment 1
195
+ generate_with_y_axis_increment 5
196
+ generate_with_y_axis_increment 20
197
+ end
198
+
199
+ def generate_with_y_axis_increment(increment)
200
+ g = Gruff::Dot.new
201
+ g.title = "Y Axis Set to #{increment}"
202
+ g.labels = {
203
+ 0 => '5/6',
204
+ 1 => '5/15',
205
+ 2 => '5/24',
206
+ 3 => '5/30',
207
+ }
208
+ g.y_axis_increment = increment
209
+ g.data(:apples, [1, 0.2, 0.5, 0.7])
210
+ g.data(:peaches, [2.5, 2.3, 2, 6.1])
211
+ g.write("test/output/dot_y_increment_#{increment}.png")
212
+ end
213
+
214
+
215
+ def test_custom_theme
216
+ g = Gruff::Dot.new
217
+ g.title = "Custom Theme"
218
+ g.font = File.expand_path('CREABBRG.TTF', ENV['MAGICK_FONT_PATH'])
219
+ g.title_font_size = 60
220
+ g.legend_font_size = 32
221
+ g.marker_font_size = 32
222
+ g.theme = {
223
+ :colors => %w(#efd250 #666699 #e5573f #9595e2),
224
+ :marker_color => 'white',
225
+ :font_color => 'blue',
226
+ :background_image => "assets/pc306715.jpg"
227
+ }
228
+ g.labels = {
229
+ 0 => '5/6',
230
+ 1 => '5/15',
231
+ 2 => '5/24',
232
+ 3 => '5/30',
233
+ }
234
+ g.data(:vancouver, [1, 2, 3, 4])
235
+ g.data(:seattle, [2, 4, 6, 8])
236
+ g.data(:portland, [3, 1, 7, 3])
237
+ g.data(:victoria, [4, 3, 5, 7])
238
+ g.minimum_value = 0
239
+ g.write("test/output/dot_themed.png")
240
+ end
241
+
242
+ def test_july_enhancements
243
+ g = Gruff::Dot.new(600)
244
+ g.hide_legend = true
245
+ g.title = "Full speed ahead"
246
+ g.labels = (0..10).inject({}) { |memo, i| memo.merge({ i => (i*10).to_s}) }
247
+ g.data(:apples, (0..9).map { rand(20)/10.0 })
248
+ g.y_axis_increment = 1.0
249
+ g.x_axis_label = 'Score (%)'
250
+ g.y_axis_label = 'Students'
251
+ write_test_file g, 'enhancements.png'
252
+ end
253
+
254
+
255
+ protected
256
+
257
+ def setup_basic_graph(size=800)
258
+ g = Gruff::Dot.new(size)
259
+ g.title = "My Dot Graph"
260
+ g.labels = {
261
+ 0 => '5/6',
262
+ 1 => '5/15',
263
+ 2 => '5/24',
264
+ 3 => '5/30',
265
+ }
266
+ @datasets.each do |data|
267
+ g.data(data[0], data[1])
268
+ end
269
+ g
270
+ end
271
+
272
+ end
273
+
@@ -27,45 +27,42 @@ class TestGruffLegend < GruffTestCase
27
27
  }
28
28
  end
29
29
 
30
- ## TODO Fix implementation
30
+ def full_suite_for(name, type)
31
+ [800, 400].each do |width|
32
+ [nil, 4, 16, 30].each do |font_size|
33
+ g = type.new(width)
34
+ g.title = "Wrapped Legend Bar Test #{font_size}pts #{width}px"
35
+ g.labels = @sample_labels
36
+ 0xEFD250.step(0xFF0000, 60) do |num|
37
+ g.colors << "#%x" % num
38
+ end
39
+
40
+ @datasets.each do |data|
41
+ g.data(data[0], data[1])
42
+ end
43
+
44
+ g.legend_font_size = font_size unless font_size.nil?
45
+ g.write("test/output/#{name}_wrapped_legend_#{font_size}_#{width}.png")
46
+ end
47
+ end
48
+ end
31
49
 
32
- # def test_bar_legend_wrap
33
- # [800, 400].each do |width|
34
- # [nil, 4, 16, 30].each do |font_size|
35
- # g = Gruff::Bar.new(width)
36
- # g.title = "Wrapped Legend Bar Test #{font_size}pts #{width}px"
37
- # g.labels = @sample_labels
38
- # 0xEFD250.step(0xFF0000, 60) do |num|
39
- # g.colors << "#%x" % num
40
- # end
41
- #
42
- # @datasets.each do |data|
43
- # g.data(data[0], data[1])
44
- # end
45
- #
46
- # g.legend_font_size = font_size unless font_size.nil?
47
- # g.write("test/output/bar_wrapped_legend_#{font_size}_#{width}.png")
48
- # end
49
- # end
50
- # end
51
- #
52
- # def test_pie_legend_wrap
53
- # [800, 400].each do |width|
54
- # [nil, 4, 16, 30].each do |font_size|
55
- # g = Gruff::Pie.new(width)
56
- # g.title = "Wrapped Legend Pie Test #{font_size}pts #{width}px"
57
- # g.labels = @sample_labels
58
- # 0xEFD250.step(0xFF0000, 60) do |num|
59
- # g.colors << "#%x" % num
60
- # end
61
- #
62
- # @datasets.each do |data|
63
- # g.data(data[0], data[1])
64
- # end
65
- #
66
- # g.legend_font_size = font_size unless font_size.nil?
67
- # g.write("test/output/pie_wrapped_legend_#{font_size}_#{width}.png")
68
- # end
69
- # end
70
- # end
50
+ def test_bar_legend_wrap
51
+ full_suite_for(:bar, Gruff::Bar)
52
+ end
53
+
54
+ def test_pie_legend_wrap
55
+ full_suite_for(:pie, Gruff::Pie)
56
+ end
57
+
58
+ def test_more_than_two_lines_of_legends
59
+ @datasets = @datasets + [[:Julie2, [22, 29, 35, 38, 36, 40, 46, 57]],
60
+ [:Jane2, [95, 95, 95, 90, 85, 80, 88, 100]],
61
+ [:Philip2, [90, 34, 23, 12, 78, 89, 98, 88]],
62
+ ["Arthur2", [5, 10, 13, 11, 6, 16, 22, 32]],
63
+ ["Vincent2", [5, 10, 13, 11, 6, 16, 22, 32]],
64
+ ["Jake2", [5, 10, 13, 11, 6, 16, 22, 32]],
65
+ ["Stephen2", [5, 10, 13, 11, 6, 16, 22, 32]]]
66
+ full_suite_for(:bar2, Gruff::Bar)
67
+ end
71
68
  end
@@ -5,6 +5,27 @@ require File.dirname(__FILE__) + "/gruff_test_case"
5
5
  class TestGruffLine < GruffTestCase
6
6
 
7
7
  # TODO Delete old output files once when starting tests
8
+
9
+ def test_should_render_with_transparent_theme
10
+ g = Gruff::Line.new(400)
11
+ g.title = "Transparent Background"
12
+ g.theme = {
13
+ :colors => ['black', 'grey'],
14
+ :marker_color => 'grey',
15
+ :font_color => 'black',
16
+ :background_colors => 'transparent'
17
+ }
18
+
19
+ g.labels = {
20
+ 0 => '5/6',
21
+ 1 => '5/15',
22
+ 2 => '5/24',
23
+ 3 => '5/30',
24
+ }
25
+ g.data(:apples, [-1, 0, 4, -4])
26
+ g.data(:peaches, [10, 8, 6, 3])
27
+ g.write("test/output/line_transparent.png")
28
+ end
8
29
 
9
30
  def test_line_graph_with_themes
10
31
  line_graph_with_themes()
@@ -118,21 +139,32 @@ class TestGruffLine < GruffTestCase
118
139
  g.write("test/output/line_large.png")
119
140
  end
120
141
 
121
- def test_long_title
122
-
123
- end
124
-
125
- def test_add_colors
126
-
127
- end
142
+ # def test_long_title
143
+ #
144
+ # end
145
+ #
146
+ # def test_add_colors
147
+ #
148
+ # end
149
+ #
128
150
 
129
151
  def test_request_too_many_colors
130
-
131
- end
132
-
133
- def test_add_data
134
-
152
+ g = Gruff::Line.new
153
+ g.title = "More Sets Than in Color Array"
154
+ # g.theme = {} # Sets theme with only black and white
155
+ @datasets.each do |data|
156
+ g.data(data[0], data[1])
157
+ end
158
+ @datasets.each do |data|
159
+ g.data("#{data[0]}-B", data[1].map {|d| d + 20})
160
+ end
161
+ g.write("test/output/line_more_sets_than_colors.png")
135
162
  end
163
+
164
+ #
165
+ # def test_add_data
166
+ #
167
+ # end
136
168
 
137
169
  def test_many_datapoints
138
170
  g = Gruff::Line.new
@@ -414,8 +446,38 @@ class TestGruffLine < GruffTestCase
414
446
  g.hide_line_markers = false
415
447
  g.write('test/output/line_no_hide.png')
416
448
  end
449
+
450
+
451
+ def test_jruby_error
452
+ g = Gruff::Line.new
453
+ g.theme = {
454
+ :colors => ['#7F0099', '#2F85ED', '#2FED09','#EC962F'],
455
+ :marker_color => '#aaa',
456
+ :background_colors => ['#E8E8E8','#B9FD6C']
457
+ }
458
+ g.hide_title = true
459
+
460
+ g.legend_font_size = 12
461
+ g.marker_font_size = 16
462
+ g.hide_dots = false
463
+ g.label_max_decimals = 1
464
+
465
+ g.write('test/output/line_jruby_error.png')
466
+ end
467
+
468
+ private
469
+
470
+ def bmi(params={})
471
+ g = basic_graph()
417
472
 
418
- protected
473
+ g.y_axis_label = 'BMI'
474
+
475
+ bmis = [24.3, 23.9, 23.7, 23.7, 23.6, 23.9, 23.6, 23.7, 23.4, 23.4, 23.4, 22.9]
476
+
477
+ g.data( 'BMI', bmis )
478
+ g.hide_legend = true
479
+ return g
480
+ end
419
481
 
420
482
  # TODO Reset data after each theme
421
483
  def line_graph_with_themes(size=nil)
@@ -439,7 +501,6 @@ protected
439
501
  end
440
502
  g.write("test/output/line_theme_37signals_#{size}.png")
441
503
 
442
-
443
504
  g = Gruff::Line.new(size)
444
505
  g.title = "Multi-Line Graph Test #{size}"
445
506
  g.labels = @labels