rmagick4j 0.3.4-java → 0.3.9-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,7 @@
1
+ module Gruff
2
+ class Base
3
+ def write(filename)
4
+ #do nothing
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,50 @@
1
+ require File.dirname(__FILE__) + "/gruff_test_case"
2
+
3
+ class TestGruffAccumulatorBar < GruffTestCase
4
+
5
+ # TODO Delete old output files once when starting tests
6
+
7
+ def setup
8
+ @datasets = [
9
+ (1..20).to_a.map { rand(10) }
10
+ ]
11
+ end
12
+
13
+ def test_accumulator
14
+ g = Gruff::AccumulatorBar.new 500
15
+ g.title = "Your Savings"
16
+ g.hide_legend = true
17
+
18
+ # g.font = File.expand_path(File.dirname(__FILE__) + "/../assets/fonts/ATMA____.TTF")
19
+
20
+ g.marker_font_size = 18
21
+
22
+ g.theme = {
23
+ :colors => ['#aedaa9', '#12a702'], # 3077a9 blue, aedaa9 light green
24
+ :marker_color => '#dddddd',
25
+ :font_color => 'black',
26
+ :background_colors => "white"
27
+ # :background_image => File.expand_path(File.dirname(__FILE__) + "/../assets/backgrounds/43things.png")
28
+ }
29
+
30
+ # Attempt at negative numbers
31
+ # g.data 'Savings', (1..20).to_a.map { rand(10) * (rand(2) > 0 ? 1 : -1) }
32
+ g.data 'Savings', (1..12).to_a.map { rand(100) }
33
+ g.labels = (0..11).to_a.inject({}) {|memo, index| {index => '12-26'}.merge(memo)}
34
+
35
+ g.maximum_value = 1000
36
+ g.minimum_value = 0
37
+
38
+ g.write("test/output/accum_bar.png")
39
+ end
40
+
41
+ def test_too_many_args
42
+ assert_raise(Gruff::IncorrectNumberOfDatasetsException) {
43
+ g = Gruff::AccumulatorBar.new
44
+ g.data 'First', [1,1,1]
45
+ g.data 'Too Many', [1,1,1]
46
+ g.write("test/output/_SHOULD_NOT_ACTUALLY_BE_WRITTEN.png")
47
+ }
48
+ end
49
+
50
+ end
@@ -0,0 +1,134 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require File.dirname(__FILE__) + "/gruff_test_case"
4
+
5
+ class TestGruffArea < 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
+ @sample_labels = {
17
+ 0 => '5/6',
18
+ 1 => '5/15',
19
+ 2 => '5/24',
20
+ 3 => '5/30',
21
+ 4 => '6/4',
22
+ 5 => '6/12',
23
+ 6 => '6/21',
24
+ 7 => '6/28',
25
+ }
26
+
27
+ end
28
+
29
+ def test_area_graph
30
+ g = Gruff::Area.new
31
+ g.title = "Visual Multi-Area Graph Test"
32
+ g.labels = {
33
+ 0 => '5/6',
34
+ 2 => '5/15',
35
+ 4 => '5/24',
36
+ 6 => '5/30',
37
+ }
38
+ @datasets.each do |data|
39
+ g.data(data[0], data[1])
40
+ end
41
+
42
+ # Default theme
43
+ g.write("test/output/area_keynote.png")
44
+ end
45
+
46
+ def test_resize
47
+ g = Gruff::Area.new(400)
48
+ g.title = "Small Size Multi-Area Graph Test"
49
+ g.labels = {
50
+ 0 => '5/6',
51
+ 2 => '5/15',
52
+ 4 => '5/24',
53
+ 6 => '5/30',
54
+ }
55
+ @datasets.each do |data|
56
+ g.data(data[0], data[1])
57
+ end
58
+
59
+ # Default theme
60
+ g.write("test/output/area_keynote_small.png")
61
+ end
62
+
63
+ def test_many_datapoints
64
+ g = Gruff::Area.new
65
+ g.title = "Many Multi-Area Graph Test"
66
+ g.labels = {
67
+ 0 => 'June',
68
+ 10 => 'July',
69
+ 30 => 'August',
70
+ 50 => 'September',
71
+ }
72
+ g.data('many points', (0..50).collect {|i| rand(100) })
73
+
74
+ # Default theme
75
+ g.write("test/output/area_many.png")
76
+ end
77
+
78
+ def test_many_areas_graph_small
79
+ g = Gruff::Area.new(400)
80
+ g.title = "Many Values Area Test 400px"
81
+ g.labels = {
82
+ 0 => '5/6',
83
+ 10 => '5/15',
84
+ 20 => '5/24',
85
+ 30 => '5/30',
86
+ 40 => '6/4',
87
+ 50 => '6/16'
88
+ }
89
+ %w{jimmy jane philip arthur julie bert}.each do |student_name|
90
+ g.data(student_name, (0..50).collect { |i| rand 100 })
91
+ end
92
+
93
+ # Default theme
94
+ g.write("test/output/area_many_areas_small.png")
95
+ end
96
+
97
+ def test_area_graph_tiny
98
+ g = Gruff::Area.new(300)
99
+ g.title = "Area Test 300px"
100
+ g.labels = {
101
+ 0 => '5/6',
102
+ 10 => '5/15',
103
+ 20 => '5/24',
104
+ 30 => '5/30',
105
+ 40 => '6/4',
106
+ 50 => '6/16'
107
+ }
108
+ %w{jimmy jane philip arthur julie bert}.each do |student_name|
109
+ g.data(student_name, (0..50).collect { |i| rand 100 })
110
+ end
111
+
112
+ # Default theme
113
+ g.write("test/output/area_tiny.png")
114
+ end
115
+
116
+ def test_wide
117
+ g = setup_basic_graph('800x400')
118
+ g.title = "Area Wide"
119
+ g.write("test/output/area_wide.png")
120
+ end
121
+
122
+ protected
123
+
124
+ def setup_basic_graph(size=800)
125
+ g = Gruff::Area.new(size)
126
+ g.title = "My Graph Title"
127
+ g.labels = @sample_labels
128
+ @datasets.each do |data|
129
+ g.data(data[0], data[1])
130
+ end
131
+ return g
132
+ end
133
+
134
+ end
@@ -0,0 +1,295 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require File.dirname(__FILE__) + "/gruff_test_case"
4
+
5
+ class TestGruffBar < 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_bar_graph
21
+ g = setup_basic_graph
22
+ g.title = "Bar Graph Test"
23
+ g.write("test/output/bar_keynote.png")
24
+
25
+ g = setup_basic_graph
26
+ g.title = "Visual Multi-Line Bar Graph Test"
27
+ g.theme_rails_keynote
28
+ g.write("test/output/bar_rails_keynote.png")
29
+
30
+ g = setup_basic_graph
31
+ g.title = "Visual Multi-Line Bar Graph Test"
32
+ g.theme_odeo
33
+ g.write("test/output/bar_odeo.png")
34
+ end
35
+
36
+ def test_bar_graph_set_colors
37
+ g = Gruff::Bar.new
38
+ g.title = "Bar Graph With Manual Colors"
39
+ g.labels = {
40
+ 0 => '5/6',
41
+ 1 => '5/15',
42
+ 2 => '5/24',
43
+ 3 => '5/30',
44
+ }
45
+ g.data(:Art, [0, 5, 8, 15], '#990000')
46
+ g.data(:Philosophy, [10, 3, 2, 8], '#009900')
47
+ g.data(:Science, [2, 15, 8, 11], '#990099')
48
+
49
+ g.minimum_value = 0
50
+
51
+ g.write("test/output/bar_manual_colors.png")
52
+ end
53
+
54
+ def test_bar_graph_small
55
+ g = Gruff::Bar.new(400)
56
+ g.title = "Visual Multi-Line Bar Graph Test"
57
+ g.labels = {
58
+ 0 => '5/6',
59
+ 1 => '5/15',
60
+ 2 => '5/24',
61
+ 3 => '5/30',
62
+ }
63
+ @datasets.each do |data|
64
+ g.data(data[0], data[1])
65
+ end
66
+
67
+ g.write("test/output/bar_keynote_small.png")
68
+ end
69
+
70
+ # Somewhat worthless test. Should an error be thrown?
71
+ # def test_nil_font
72
+ # g = setup_basic_graph 400
73
+ # g.title = "Nil Font"
74
+ # g.font = nil
75
+ # g.write "test/output/bar_nil_font.png"
76
+ # end
77
+
78
+
79
+ def test_no_line_markers
80
+ g = setup_basic_graph(400)
81
+ g.title = "No Line Markers"
82
+ g.hide_line_markers = true
83
+ g.write("test/output/bar_no_line_markers.png")
84
+ end
85
+
86
+ def test_no_legend
87
+ g = setup_basic_graph(400)
88
+ g.title = "No Legend"
89
+ g.hide_legend = true
90
+ g.write("test/output/bar_no_legend.png")
91
+ end
92
+
93
+ def test_no_title
94
+ g = setup_basic_graph(400)
95
+ g.title = "No Title"
96
+ g.hide_title = true
97
+ g.write("test/output/bar_no_title.png")
98
+ end
99
+
100
+ def test_no_title_or_legend
101
+ g = setup_basic_graph(400)
102
+ g.title = "No Title or Legend"
103
+ g.hide_legend = true
104
+ g.hide_title = true
105
+ g.write("test/output/bar_no_title_or_legend.png")
106
+ end
107
+
108
+ def test_set_marker_count
109
+ g = setup_basic_graph(400)
110
+ g.title = "Set marker"
111
+ g.marker_count = 10
112
+ g.write("test/output/bar_set_marker.png")
113
+ end
114
+
115
+ def test_set_legend_box_size
116
+ g = setup_basic_graph(400)
117
+ g.title = "Set Small Legend Box Size"
118
+ g.legend_box_size = 10.0
119
+ g.write("test/output/bar_set_legend_box_size_sm.png")
120
+
121
+ g = setup_basic_graph(400)
122
+ g.title = "Set Large Legend Box Size"
123
+ g.legend_box_size = 50.0
124
+ g.write("test/output/bar_set_legend_box_size_lg.png")
125
+ end
126
+
127
+ def test_x_y_labels
128
+ g = setup_basic_graph(400)
129
+ g.title = "X Y Labels"
130
+ g.x_axis_label = 'Score (%)'
131
+ g.y_axis_label = "Students"
132
+ g.write("test/output/bar_x_y_labels.png")
133
+ end
134
+
135
+ def test_wide_graph
136
+ g = setup_basic_graph('800x400')
137
+ g.title = "Wide Graph"
138
+ g.write("test/output/bar_wide_graph.png")
139
+
140
+ g = setup_basic_graph('400x200')
141
+ g.title = "Wide Graph Small"
142
+ g.write("test/output/bar_wide_graph_small.png")
143
+ end
144
+
145
+
146
+ def test_tall_graph
147
+ g = setup_basic_graph('400x600')
148
+ g.title = "Tall Graph"
149
+ g.write("test/output/bar_tall_graph.png")
150
+
151
+ g = setup_basic_graph('200x400')
152
+ g.title = "Tall Graph Small"
153
+ g.write("test/output/bar_tall_graph_small.png")
154
+ end
155
+
156
+
157
+ def test_one_value
158
+ g = Gruff::Bar.new
159
+ g.title = "One Value Graph Test"
160
+ g.labels = {
161
+ 0 => '1',
162
+ 1 => '2'
163
+ }
164
+ g.data('one', [1,1])
165
+
166
+ g.write("test/output/bar_one_value.png")
167
+ end
168
+
169
+
170
+ def test_negative
171
+ g = Gruff::Bar.new
172
+ g.title = "Pos/Neg Bar Graph Test"
173
+ g.labels = {
174
+ 0 => '5/6',
175
+ 1 => '5/15',
176
+ 2 => '5/24',
177
+ 3 => '5/30',
178
+ }
179
+ g.data(:apples, [-1, 0, 4, -4])
180
+ g.data(:peaches, [10, 8, 6, 3])
181
+
182
+ g.write("test/output/bar_pos_neg.png")
183
+ end
184
+
185
+
186
+ def test_nearly_zero
187
+ g = Gruff::Bar.new
188
+ g.title = "Nearly Zero Graph"
189
+ g.labels = {
190
+ 0 => '5/6',
191
+ 1 => '5/15',
192
+ 2 => '5/24',
193
+ 3 => '5/30',
194
+ }
195
+ g.data(:apples, [1, 2, 3, 4])
196
+ g.data(:peaches, [4, 3, 2, 1])
197
+ g.minimum_value = 0
198
+ g.maximum_value = 10
199
+ g.write("test/output/bar_nearly_zero_max_10.png")
200
+ end
201
+
202
+ def test_y_axis_increment
203
+ generate_with_y_axis_increment 2.0
204
+ generate_with_y_axis_increment 1
205
+ generate_with_y_axis_increment 5
206
+ generate_with_y_axis_increment 20
207
+ end
208
+
209
+ def generate_with_y_axis_increment(increment)
210
+ g = Gruff::Bar.new
211
+ g.title = "Y Axis Set to #{increment}"
212
+ g.labels = {
213
+ 0 => '5/6',
214
+ 1 => '5/15',
215
+ 2 => '5/24',
216
+ 3 => '5/30',
217
+ }
218
+ g.y_axis_increment = increment
219
+ g.data(:apples, [1, 0.2, 0.5, 0.7])
220
+ g.data(:peaches, [2.5, 2.3, 2, 6.1])
221
+ g.write("test/output/bar_y_increment_#{increment}.png")
222
+ end
223
+
224
+
225
+ def test_custom_theme
226
+ g = Gruff::Bar.new
227
+ g.title = "Custom Theme"
228
+ g.font = File.expand_path('CREABBRG.TTF', ENV['MAGICK_FONT_PATH'])
229
+ g.title_font_size = 60
230
+ g.legend_font_size = 32
231
+ g.marker_font_size = 32
232
+ g.theme = {
233
+ :colors => %w(#efd250 #666699 #e5573f #9595e2),
234
+ :marker_color => 'white',
235
+ :font_color => 'blue',
236
+ :background_image => "assets/pc306715.jpg"
237
+ }
238
+ g.labels = {
239
+ 0 => '5/6',
240
+ 1 => '5/15',
241
+ 2 => '5/24',
242
+ 3 => '5/30',
243
+ }
244
+ g.data(:vancouver, [1, 2, 3, 4])
245
+ g.data(:seattle, [2, 4, 6, 8])
246
+ g.data(:portland, [3, 1, 7, 3])
247
+ g.data(:victoria, [4, 3, 5, 7])
248
+ g.minimum_value = 0
249
+ g.write("test/output/bar_themed.png")
250
+ end
251
+
252
+ def test_legend_should_not_overlap
253
+ g = Gruff::Bar.new(400)
254
+ g.theme_37signals()
255
+ g.title = 'My Graph'
256
+ g.data("Apples Oranges Watermelon Apples Oranges", [1, 2, 3, 4, 4, 3])
257
+ g.data('Oranges', [4, 8, 7, 9, 8, 9])
258
+ g.data('Watermelon', [2, 3, 1, 5, 6, 8])
259
+ g.data('Peaches', [9, 9, 10, 8, 7, 9])
260
+ g.labels = {0 => '2003', 2 => '2004', 4 => '2005'}
261
+ g.write("test/output/bar_long_legend_text.png")
262
+ end
263
+
264
+ def test_july_enhancements
265
+ g = Gruff::Bar.new(600)
266
+ g.hide_legend = true
267
+ g.title = "Full speed ahead"
268
+ g.labels = (0..10).inject({}) { |memo, i| memo.merge({ i => (i*10).to_s}) }
269
+ g.data(:apples, (0..9).map { rand(20)/10.0 })
270
+ g.y_axis_increment = 1.0
271
+ g.x_axis_label = 'Score (%)'
272
+ g.y_axis_label = 'Students'
273
+ write_test_file g, 'enhancements.png'
274
+ end
275
+
276
+
277
+ protected
278
+
279
+ def setup_basic_graph(size=800)
280
+ g = Gruff::Bar.new(size)
281
+ g.title = "My Bar Graph"
282
+ g.labels = {
283
+ 0 => '5/6',
284
+ 1 => '5/15',
285
+ 2 => '5/24',
286
+ 3 => '5/30',
287
+ }
288
+ @datasets.each do |data|
289
+ g.data(data[0], data[1])
290
+ end
291
+ g
292
+ end
293
+
294
+ end
295
+