rmagick4j 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. data/History.txt +84 -0
  2. data/LICENSE.txt +9 -0
  3. data/Manifest.txt +142 -0
  4. data/README.txt +25 -0
  5. data/Rakefile +109 -0
  6. data/lib/RMagick.rb +1861 -0
  7. data/lib/jhlabs-filters.jar +0 -0
  8. data/lib/magick4j.jar +0 -0
  9. data/lib/rmagick4j/constants.rb +21 -0
  10. data/lib/rmagick4j/draw.rb +86 -0
  11. data/lib/rmagick4j/enum.rb +120 -0
  12. data/lib/rmagick4j/gradient_fill.rb +14 -0
  13. data/lib/rmagick4j/image.rb +289 -0
  14. data/lib/rmagick4j/image_list.rb +21 -0
  15. data/lib/rmagick4j/pixel.rb +170 -0
  16. data/lib/rmagick4j/rmagick4j.rb +19 -0
  17. data/lib/rmagick4j/texture_fill.rb +14 -0
  18. data/lib/rmagick4j/type_metric.rb +8 -0
  19. data/lib/rmagick4j/version.rb +5 -0
  20. data/lib/rvg/clippath.rb +48 -0
  21. data/lib/rvg/container.rb +131 -0
  22. data/lib/rvg/deep_equal.rb +56 -0
  23. data/lib/rvg/describable.rb +53 -0
  24. data/lib/rvg/embellishable.rb +417 -0
  25. data/lib/rvg/misc.rb +739 -0
  26. data/lib/rvg/paint.rb +55 -0
  27. data/lib/rvg/pathdata.rb +131 -0
  28. data/lib/rvg/rvg.rb +283 -0
  29. data/lib/rvg/stretchable.rb +168 -0
  30. data/lib/rvg/stylable.rb +118 -0
  31. data/lib/rvg/text.rb +187 -0
  32. data/lib/rvg/transformable.rb +133 -0
  33. data/lib/rvg/units.rb +66 -0
  34. data/lib/svgsalamander.jar +0 -0
  35. data/test/RMagickTestSuite.rb +129 -0
  36. data/test/eyetests/bullseye.rb +150 -0
  37. data/test/eyetests/tests/draw_arc_basic.rb +16 -0
  38. data/test/eyetests/tests/draw_circle_affine.rb +19 -0
  39. data/test/eyetests/tests/draw_circle_basic.rb +16 -0
  40. data/test/eyetests/tests/draw_ellipse_affine.rb +19 -0
  41. data/test/eyetests/tests/draw_ellipse_basic.rb +16 -0
  42. data/test/eyetests/tests/draw_line_affine.rb +24 -0
  43. data/test/eyetests/tests/draw_line_basic.rb +20 -0
  44. data/test/eyetests/tests/draw_pattern_1.rb +35 -0
  45. data/test/eyetests/tests/draw_polygon_affine.rb +21 -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_rectangle_affine.rb +16 -0
  50. data/test/eyetests/tests/draw_rectangle_basic.rb +16 -0
  51. data/test/eyetests/tests/draw_rmagick_test_01.rb +35 -0
  52. data/test/eyetests/tests/draw_rmagick_test_02.rb +40 -0
  53. data/test/eyetests/tests/draw_rmagick_test_03.rb +17 -0
  54. data/test/eyetests/tests/draw_rmagick_test_04.rb +21 -0
  55. data/test/eyetests/tests/draw_roundrectangle_affine.rb +19 -0
  56. data/test/eyetests/tests/draw_roundrectangle_basic.rb +16 -0
  57. data/test/eyetests/tests/gradient_fill_horizontal_diagonal_fill.rb +9 -0
  58. data/test/eyetests/tests/gradient_fill_horizontal_fill.rb +9 -0
  59. data/test/eyetests/tests/gradient_fill_point_fill.rb +9 -0
  60. data/test/eyetests/tests/gradient_fill_vertical_diagonal_fill.rb +9 -0
  61. data/test/eyetests/tests/gradient_fill_vertical_fill.rb +9 -0
  62. data/test/eyetests/tests/gruff_accumulator_bar.rb +29 -0
  63. data/test/eyetests/tests/gruff_area_1.rb +16 -0
  64. data/test/eyetests/tests/gruff_area_2.rb +27 -0
  65. data/test/eyetests/tests/gruff_bar_1.rb +29 -0
  66. data/test/eyetests/tests/gruff_bar_2.rb +19 -0
  67. data/test/eyetests/tests/gruff_line_1.rb +13 -0
  68. data/test/eyetests/tests/gruff_line_2.rb +20 -0
  69. data/test/eyetests/tests/gruff_net_1.rb +16 -0
  70. data/test/eyetests/tests/gruff_net_2.rb +16 -0
  71. data/test/eyetests/tests/gruff_pie_1.rb +21 -0
  72. data/test/eyetests/tests/gruff_pie_2.rb +22 -0
  73. data/test/eyetests/tests/gruff_scene_1.rb +14 -0
  74. data/test/eyetests/tests/gruff_scene_2.rb +14 -0
  75. data/test/eyetests/tests/gruff_sidebar.rb +32 -0
  76. data/test/eyetests/tests/gruff_sidestacked_bar_1.rb +26 -0
  77. data/test/eyetests/tests/gruff_sidestacked_bar_2.rb +26 -0
  78. data/test/eyetests/tests/gruff_spider_1.rb +22 -0
  79. data/test/eyetests/tests/gruff_spider_2.rb +15 -0
  80. data/test/eyetests/tests/gruff_stacked_bar_1.rb +23 -0
  81. data/test/eyetests/tests/gruff_stacked_bar_2.rb +26 -0
  82. data/test/eyetests/tests/hatch_fill.rb +9 -0
  83. data/test/eyetests/tests/image_list_flatten_images.rb +15 -0
  84. data/test/eyetests/tests/new_image.rb +24 -0
  85. data/test/eyetests/tests/path_a_command_01.rb +16 -0
  86. data/test/eyetests/tests/path_a_command_02.rb +19 -0
  87. data/test/eyetests/tests/path_c_command_01.rb +16 -0
  88. data/test/eyetests/tests/path_c_command_02.rb +16 -0
  89. data/test/eyetests/tests/path_complex_01.rb +16 -0
  90. data/test/eyetests/tests/path_espiral_01.rb +28 -0
  91. data/test/eyetests/tests/path_h_command_01.rb +16 -0
  92. data/test/eyetests/tests/path_h_command_02.rb +16 -0
  93. data/test/eyetests/tests/path_l_command_01.rb +16 -0
  94. data/test/eyetests/tests/path_l_command_02.rb +16 -0
  95. data/test/eyetests/tests/path_m_command_01.rb +16 -0
  96. data/test/eyetests/tests/path_m_command_02.rb +16 -0
  97. data/test/eyetests/tests/path_m_command_03.rb +16 -0
  98. data/test/eyetests/tests/path_q_command_01.rb +16 -0
  99. data/test/eyetests/tests/path_q_command_02.rb +16 -0
  100. data/test/eyetests/tests/path_q_command_03.rb +25 -0
  101. data/test/eyetests/tests/path_s_command_01.rb +16 -0
  102. data/test/eyetests/tests/path_s_command_02.rb +16 -0
  103. data/test/eyetests/tests/path_star_01.rb +16 -0
  104. data/test/eyetests/tests/path_t_command_01.rb +16 -0
  105. data/test/eyetests/tests/path_t_command_02.rb +16 -0
  106. data/test/eyetests/tests/path_v_command_01.rb +16 -0
  107. data/test/eyetests/tests/path_v_command_02.rb +16 -0
  108. data/test/eyetests/tests/store_pixel_smiley.rb +123 -0
  109. data/test/eyetests/tests/texture_fill.rb +11 -0
  110. data/test/gruff_tests/test/gruff_test_case.rb +120 -0
  111. data/test/gruff_tests/test/monkey_gruff.rb +7 -0
  112. data/test/gruff_tests/test/test_accumulator_bar.rb +50 -0
  113. data/test/gruff_tests/test/test_area.rb +134 -0
  114. data/test/gruff_tests/test/test_bar.rb +283 -0
  115. data/test/gruff_tests/test/test_base.rb +8 -0
  116. data/test/gruff_tests/test/test_bullet.rb +26 -0
  117. data/test/gruff_tests/test/test_legend.rb +71 -0
  118. data/test/gruff_tests/test/test_line.rb +493 -0
  119. data/test/gruff_tests/test/test_mini_bar.rb +32 -0
  120. data/test/gruff_tests/test/test_mini_pie.rb +20 -0
  121. data/test/gruff_tests/test/test_mini_side_bar.rb +37 -0
  122. data/test/gruff_tests/test/test_net.rb +230 -0
  123. data/test/gruff_tests/test/test_photo.rb +41 -0
  124. data/test/gruff_tests/test/test_pie.rb +154 -0
  125. data/test/gruff_tests/test/test_scene.rb +100 -0
  126. data/test/gruff_tests/test/test_side_bar.rb +12 -0
  127. data/test/gruff_tests/test/test_sidestacked_bar.rb +89 -0
  128. data/test/gruff_tests/test/test_spider.rb +216 -0
  129. data/test/gruff_tests/test/test_stacked_bar.rb +52 -0
  130. data/test/images/clown.jpg +0 -0
  131. data/test/images/texture.jpg +0 -0
  132. data/test/implemented_methods.rb +18 -0
  133. data/test/spec/draw_spec.rb +24 -0
  134. data/test/spec/image_constants.rb +76 -0
  135. data/test/spec/image_spec.rb +23 -0
  136. data/test/spec/pixel_spec.rb +84 -0
  137. data/test/spec/stories/geometry_runner.rb +13 -0
  138. data/test/spec/stories/geometry_steps.rb +24 -0
  139. data/test/spec/stories/geometry_story.rb +116 -0
  140. data/test/spec/stories/image_filling_runner.rb +13 -0
  141. data/test/spec/stories/image_filling_steps.rb +64 -0
  142. data/test/spec/stories/image_filling_story.rb +41 -0
  143. metadata +215 -0
@@ -0,0 +1,16 @@
1
+ require File.join(File.dirname(__FILE__), 'new_image.rb')
2
+
3
+ include Magick
4
+
5
+ draw = Draw.new
6
+
7
+ draw.fill 'red'
8
+ draw.stroke 'blue'
9
+ draw.stroke_width(5)
10
+ draw.path 'M0,150 C25,50 125,50 150,150s125,100 150,0'
11
+
12
+ b = Image.new(300, 300, HatchFill.new('white', 'black'))
13
+
14
+ draw.draw(b)
15
+
16
+ b.write('path_s_command_02.jpg')
@@ -0,0 +1,16 @@
1
+ require File.join(File.dirname(__FILE__), 'new_image.rb')
2
+
3
+ include Magick
4
+
5
+ draw = Draw.new
6
+
7
+ draw.fill 'red'
8
+ draw.stroke 'blue'
9
+ draw.stroke_width(5)
10
+ draw.path 'M100,10 L100,10 40,180 190,60 10,60 160,180 z'
11
+
12
+ b = Image.new(300, 300, HatchFill.new('white', 'black'))
13
+
14
+ draw.draw(b)
15
+
16
+ b.write('path_star_01.jpg')
@@ -0,0 +1,16 @@
1
+ require File.join(File.dirname(__FILE__), 'new_image.rb')
2
+
3
+ include Magick
4
+
5
+ draw = Draw.new
6
+
7
+ draw.fill 'red'
8
+ draw.stroke 'blue'
9
+ draw.stroke_width(5)
10
+ draw.path 'M50,150 Q100,-100 150,150 T250,150'
11
+
12
+ b = Image.new(300, 300, HatchFill.new('white', 'black'))
13
+
14
+ draw.draw(b)
15
+
16
+ b.write('path_t_command_01.jpg')
@@ -0,0 +1,16 @@
1
+ require File.join(File.dirname(__FILE__), 'new_image.rb')
2
+
3
+ include Magick
4
+
5
+ draw = Draw.new
6
+
7
+ draw.fill 'red'
8
+ draw.stroke 'blue'
9
+ draw.stroke_width(5)
10
+ draw.path 'M50,150 Q100,-100 150,150t100,0'
11
+
12
+ b = Image.new(300, 300, HatchFill.new('white', 'black'))
13
+
14
+ draw.draw(b)
15
+
16
+ b.write('path_t_command_02.jpg')
@@ -0,0 +1,16 @@
1
+ require File.join(File.dirname(__FILE__), 'new_image.rb')
2
+
3
+ include Magick
4
+
5
+ draw = Draw.new
6
+
7
+ draw.fill 'red'
8
+ draw.stroke 'blue'
9
+ draw.stroke_width(5)
10
+ draw.path 'M50 50 L100 100 0 100M190 190L290 190V290 L190 290'
11
+
12
+ b = Image.new(300, 300, HatchFill.new('white', 'black'))
13
+
14
+ draw.draw(b)
15
+
16
+ b.write('path_v_command_01.jpg')
@@ -0,0 +1,16 @@
1
+ require File.join(File.dirname(__FILE__), 'new_image.rb')
2
+
3
+ include Magick
4
+
5
+ draw = Draw.new
6
+
7
+ draw.fill 'red'
8
+ draw.stroke 'blue'
9
+ draw.stroke_width(5)
10
+ draw.path 'M50 50 L100 100 0 100M190 190L290 190v100 L190 290v-100'
11
+
12
+ b = Image.new(300, 300, HatchFill.new('white', 'black'))
13
+
14
+ draw.draw(b)
15
+
16
+ b.write('path_v_command_02.jpg')
@@ -0,0 +1,123 @@
1
+ require File.join(File.dirname(__FILE__), 'new_image.rb')
2
+
3
+ include Magick
4
+
5
+ SmileWidth = 48
6
+ SmileHeight = 48
7
+ SmileBits = [
8
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
9
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
10
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
11
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
12
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0,
90
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
91
+ 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0,
92
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
93
+ 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
94
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
95
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
96
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
97
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
98
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
99
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
100
+ 0, 0, 0, 0 ]
101
+
102
+ img = Image.new(SmileWidth, SmileHeight)
103
+
104
+ q = Array.new # Create an array of pixels one
105
+ SmileWidth.times do # row long
106
+ q << Magick::Pixel.new(0,0,0,0)
107
+ end
108
+
109
+ n = 0
110
+ SmileHeight.times do |y| # Store pixels a row at a time
111
+ SmileWidth.times do |x| # Build a row of pixels
112
+ q[x].red = QuantumRange * SmileBits[n]
113
+ q[x].green = QuantumRange * SmileBits[n]
114
+ q[x].blue = QuantumRange * SmileBits[n]
115
+ n += 1
116
+ end
117
+ # Store the row of pixels
118
+ img.store_pixels(0, y, SmileWidth, 1, q)
119
+ end
120
+
121
+ # img.display # Now display the result
122
+ img.write('store_pixel_smiley.jpg')
123
+
@@ -0,0 +1,11 @@
1
+ require File.join(File.dirname(__FILE__), 'new_image.rb')
2
+
3
+ include Magick
4
+
5
+ texture_image = Image.load('texture.jpg').first
6
+
7
+ texture = TextureFill.new(texture_image)
8
+
9
+ image = Image.new 300, 300, texture
10
+
11
+ image.write('texture_fill.jpg')
@@ -0,0 +1,120 @@
1
+ $:.unshift(File.dirname(__FILE__) + "/../lib/")
2
+ require 'rubygems'
3
+
4
+ require 'test/unit'
5
+ require 'gruff'
6
+ require File.join(File.dirname(__FILE__),'monkey_gruff')
7
+ # require 'test_timer'
8
+
9
+ class GruffTestCase < Test::Unit::TestCase
10
+
11
+ def setup
12
+ @datasets = [
13
+ [:Jimmy, [25, 36, 86, 39, 25, 31, 79, 88]],
14
+ [:Charles, [80, 54, 67, 54, 68, 70, 90, 95]],
15
+ [:Julie, [22, 29, 35, 38, 36, 40, 46, 57]],
16
+ [:Jane, [95, 95, 95, 90, 85, 80, 88, 100]],
17
+ [:Philip, [90, 34, 23, 12, 78, 89, 98, 88]],
18
+ ["Arthur", [5, 10, 13, 11, 6, 16, 22, 32]],
19
+ ]
20
+
21
+ @labels = {
22
+ 0 => '5/6',
23
+ 1 => '5/15',
24
+ 2 => '5/24',
25
+ 3 => '5/30',
26
+ 4 => '6/4',
27
+ 5 => '6/12',
28
+ 6 => '6/21',
29
+ 7 => '6/28',
30
+ }
31
+ end
32
+
33
+ def setup_single_dataset
34
+ @datasets = [
35
+ [:Jimmy, [25, 36, 86]]
36
+ ]
37
+
38
+ @labels = {
39
+ 0 => 'You',
40
+ 1 => 'Average',
41
+ 2 => 'Lifetime'
42
+ }
43
+ end
44
+
45
+ def setup_wide_dataset
46
+ @datasets = [
47
+ ["Auto", 25],
48
+ ["Food", 5],
49
+ ["Entertainment", 15]
50
+ ]
51
+
52
+ @labels = { 0 => 'This Month' }
53
+ end
54
+
55
+ def test_dummy
56
+ assert true
57
+ end
58
+
59
+ protected
60
+
61
+ # Generate graphs at several sizes.
62
+ #
63
+ # Also writes the graph to disk.
64
+ #
65
+ # graph_sized 'bar_basic' do |g|
66
+ # g.data('students', [1, 2, 3, 4])
67
+ # end
68
+ #
69
+ def graph_sized(filename, sizes=['', 400])
70
+ class_name = self.class.name.gsub(/^TestGruff/, '')
71
+ Array(sizes).each do |size|
72
+ g = instance_eval("Gruff::#{class_name}.new #{size}")
73
+ g.title = "#{class_name} Graph"
74
+ yield g
75
+ write_test_file g, "#{filename}_#{size}.png"
76
+ end
77
+ end
78
+
79
+ def write_test_file(graph, filename)
80
+ graph.write(File.dirname(__FILE__) + "/output/#{filename}")
81
+ end
82
+
83
+ ##
84
+ # Example:
85
+ #
86
+ # setup_basic_graph Gruff::Pie, 400
87
+ #
88
+ def setup_basic_graph(*args)
89
+ klass, size = Gruff::Bar, 400
90
+ # Allow args to be klass, size or just klass or just size.
91
+ #
92
+ # TODO Refactor
93
+ case args.length
94
+ when 1
95
+ case args[0]
96
+ when Fixnum
97
+ size = args[0]
98
+ klass = eval("Gruff::#{self.class.name.gsub(/^TestGruff/, '')}")
99
+ when String
100
+ size = args[0]
101
+ klass = eval("Gruff::#{self.class.name.gsub(/^TestGruff/, '')}")
102
+ else
103
+ klass = args[0]
104
+ end
105
+ when 2
106
+ klass, size = args[0], args[1]
107
+ end
108
+
109
+ g = klass.new(size)
110
+ g.title = "My Bar Graph"
111
+ g.labels = @labels
112
+
113
+
114
+ @datasets.each do |data|
115
+ g.data(data[0], data[1])
116
+ end
117
+ g
118
+ end
119
+
120
+ end
@@ -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