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
@@ -12,6 +12,10 @@ module Magick
12
12
 
13
13
  Image.from_image(image)
14
14
  end
15
+
16
+ def remap
17
+ # TODO: Implement. Just here to avoid RMagick 2.9 errors.
18
+ end
15
19
 
16
20
  def to_blob(&add)
17
21
  # TODO Support lists.
@@ -3,7 +3,6 @@ require 'java'
3
3
  rmagick4j_dir = File.dirname(__FILE__)
4
4
 
5
5
  # TODO See about using Raven to get gems of jhlabs and svgsalamander?
6
- require File.join(rmagick4j_dir, '..', 'jhlabs-filters.jar')
7
6
  require File.join(rmagick4j_dir, '..', 'magick4j.jar')
8
7
  require File.join(rmagick4j_dir, '..', 'svgsalamander.jar')
9
8
 
@@ -1,5 +1,5 @@
1
1
  module RMagick4J
2
2
  module Version
3
- VERSION = "0.3.6"
3
+ VERSION = "0.3.7"
4
4
  end
5
5
  end
@@ -101,11 +101,12 @@ module Bullseye
101
101
  @default_model = DefaultListModel.new
102
102
  super(@default_model)
103
103
  load_test_scripts
104
+
104
105
  self.setSelectedIndex(0)
105
106
  end
106
107
 
107
108
  def load_test_scripts
108
- Dir[File.dirname(__FILE__) + '/tests/*.rb'].each do |script|
109
+ Dir[File.dirname(__FILE__) + '/tests/*.rb'].sort.each do |script|
109
110
  script = script.gsub(/(^.*tests\/|.rb$)/,'').split('_').map{|x| x.capitalize}.join(' ')
110
111
  @default_model.addElement(script) unless script == 'New Image'
111
112
  end
@@ -0,0 +1,79 @@
1
+ require 'erb'
2
+ require 'ftools'
3
+
4
+ if ARGV.size == 0
5
+ puts 'usage: ruby doc.rb directory'
6
+ exit
7
+ end
8
+
9
+ File.makedirs ARGV[0] unless File.exists?(ARGV[0]) && File.directory?(ARGV[0])
10
+
11
+ IMAGE_DIR = File.join(ARGV[0], 'img')
12
+
13
+ File.makedirs IMAGE_DIR unless File.exists?(IMAGE_DIR) && File.directory?(IMAGE_DIR)
14
+
15
+ TESTS= Dir[File.join(File.dirname(__FILE__),'tests','*.rb')].reject{|x| x=~ /new_image.rb$/ }
16
+
17
+ IMAGES = []
18
+
19
+ i = 0
20
+ size = TESTS.size
21
+
22
+ TESTS.each do |test|
23
+ i += 1
24
+ puts "Running #{test} in JRuby. #{i}/#{size}"
25
+ `jruby #{test} #{IMAGE_DIR}`
26
+ puts "Running #{test} in Ruby. #{i}/#{size}"
27
+ `sh -c 'ruby #{test} #{IMAGE_DIR}'`
28
+ IMAGES << test.split(/\//).last[0...-3]
29
+ end
30
+
31
+ template = %{
32
+ <html>
33
+
34
+ <head>
35
+ <title>RMagick4J Vs. RMagick</title>
36
+ </head>
37
+
38
+ <body>
39
+ These examples are supposed to show:<br/>
40
+ <ul>
41
+ <li>There are some bugs in RMagick4J<li>
42
+ <li>There are still a lot of features left in RMagick4J (I will continue working on this project after GSoC)</li>
43
+ <li>There are some bugs in ImageMagick and, therefore, in RMagick</li>
44
+ </ul>
45
+ <table>
46
+ <% i = 0 %>
47
+ <% IMAGES.sort.each do |img| %>
48
+ <% if i % 4 == 0 %>
49
+ <tr>
50
+ <td >RMagick4J</td>
51
+ <td>RMagick</td>
52
+ </tr>
53
+ <% end %>
54
+ <tr>
55
+ <td>
56
+ <img src="<%= File.join('img', img) %>.jruby.jpg"/>
57
+ </td>
58
+ <td>
59
+ <img src="<%= File.join('img', img) %>.mri.jpg"/>
60
+ </td>
61
+ </tr>
62
+ <% i += 1%>
63
+ <% end %>
64
+ </table>
65
+ </body>
66
+
67
+ </html>
68
+ }.gsub(/^ /, '')
69
+
70
+ puts 'Running template'
71
+ rhtml = ERB.new template
72
+
73
+ doc = rhtml.result binding
74
+
75
+ html = File.new(File.join(ARGV[0], 'index.html'), 'w')
76
+
77
+ html.write doc
78
+
79
+ html.close
@@ -39,4 +39,4 @@ gc.rectangle(x, y, x+metrics.width, y+metrics.height)
39
39
  gc.draw(background)
40
40
 
41
41
 
42
- background.write('draw_multiline_type_metrics.jpg')
42
+ background.write('draw_multiline_type_metrics.jpg')
@@ -0,0 +1,16 @@
1
+ require File.join(File.dirname(__FILE__), 'new_image.rb')
2
+
3
+ include Magick
4
+
5
+ clown = Image.load("clown.jpg").first
6
+
7
+ draw = Draw.new
8
+ draw.push
9
+ draw.stroke 'green'
10
+ draw.fill 'yellow'
11
+ draw.circle clown.columns/2, clown.rows/2, clown.columns/4, clown.rows/2
12
+ draw.pop
13
+
14
+ draw.draw clown
15
+
16
+ clown.write "draw_pop_push.jpg"
@@ -19,4 +19,4 @@ b = Image.new(300, 300)
19
19
 
20
20
  draw.draw b
21
21
 
22
- b.write('draw_pop_push_translate.jpg')
22
+ b.write('draw_pop_push_translate.jpg')
@@ -0,0 +1,9 @@
1
+ require File.join(File.dirname(__FILE__), 'new_image.rb')
2
+
3
+ include Magick
4
+
5
+ clown = Image.load("clown.jpg").first
6
+
7
+ clown = clown.blur_image 4.75, 2.0
8
+
9
+ clown.write "effect_blur.jpg"
@@ -0,0 +1,9 @@
1
+ require File.join(File.dirname(__FILE__), 'new_image.rb')
2
+
3
+ include Magick
4
+
5
+ clown = Image.load("clown.jpg").first
6
+
7
+ clown = clown.charcoal 5
8
+
9
+ clown.write "effect_charcoal.jpg"
@@ -0,0 +1,9 @@
1
+ require File.join(File.dirname(__FILE__), 'new_image.rb')
2
+
3
+ include Magick
4
+
5
+ clown = Image.load("clown.jpg").first
6
+
7
+ clown = clown.edge 5
8
+
9
+ clown.write "effect_edge.jpg"
@@ -0,0 +1,9 @@
1
+ require File.join(File.dirname(__FILE__), 'new_image.rb')
2
+
3
+ include Magick
4
+
5
+ clown = Image.load("clown.jpg").first
6
+
7
+ clown = clown.implode 0.75
8
+
9
+ clown.write "effect_implode.jpg"
@@ -0,0 +1,9 @@
1
+ require File.join(File.dirname(__FILE__), 'new_image.rb')
2
+
3
+ include Magick
4
+
5
+ clown = Image.load("clown.jpg").first
6
+
7
+ clown = clown.negate
8
+
9
+ clown.write "effect_negate.jpg"
@@ -0,0 +1,9 @@
1
+ require File.join(File.dirname(__FILE__), 'new_image.rb')
2
+
3
+ include Magick
4
+
5
+ clown = Image.load("clown.jpg").first
6
+
7
+ clown = clown.negate true
8
+
9
+ clown.write "effect_negate_true.jpg"
@@ -0,0 +1,9 @@
1
+ require File.join(File.dirname(__FILE__), 'new_image.rb')
2
+
3
+ include Magick
4
+
5
+ clown = Image.load("clown.jpg").first
6
+
7
+ clown = clown.normalize
8
+
9
+ clown.write "effect_normalize.jpg"
@@ -0,0 +1,9 @@
1
+ require File.join(File.dirname(__FILE__), 'new_image.rb')
2
+
3
+ include Magick
4
+
5
+ clown = Image.load("clown.jpg").first
6
+
7
+ clown = clown.shade(true, 50, 50)
8
+
9
+ clown.write "effect_shade.jpg"
@@ -0,0 +1,10 @@
1
+ require File.join(File.dirname(__FILE__), 'new_image.rb')
2
+
3
+ include Magick
4
+
5
+ clown = Image.load("clown.jpg").first
6
+
7
+ # The parameter is quite important, 'cause in RMagick4J QuantumRange is 256 and in ImageMagick it can change.
8
+ clown = clown.solarize(27.5.to_threshold)
9
+
10
+ clown.write "effect_solarize.jpg"
@@ -0,0 +1,9 @@
1
+ require File.join(File.dirname(__FILE__), 'new_image.rb')
2
+
3
+ include Magick
4
+
5
+ clown = Image.load("clown.jpg").first
6
+
7
+ clown = clown.wave
8
+
9
+ clown.write "effect_wave.jpg"
@@ -6,4 +6,4 @@ fill = GradientFill.new(200, 0, 200, 300,'#000000','#ff8844')
6
6
 
7
7
  image = Image.new(300,300,fill)
8
8
 
9
- image.write('gradient_fill_vertical_fill.jpg')
9
+ image.write('gradient_fill_vertical_fill.jpg')
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'gruff'
3
+ require File.join(File.dirname(__FILE__), 'new_image.rb')
4
+
5
+ g = Gruff::Dot.new
6
+ g.title = "Dot Graph With Manual Colors"
7
+ g.labels = {
8
+ 0 => '5/6',
9
+ 1 => '5/15',
10
+ 2 => '5/24',
11
+ 3 => '5/30',
12
+ }
13
+ g.data(:Art, [0, 5, 8, 15], '#990000')
14
+ g.data(:Philosophy, [10, 3, 2, 8], '#009900')
15
+ g.data(:Science, [2, 15, 8, 11], '#990099')
16
+
17
+ g.minimum_value = 0
18
+
19
+ g.write("gruff_dot_1.jpg")
@@ -17,4 +17,4 @@ g.baseline_color = 'green'
17
17
  g.data(data[0], data[1])
18
18
  end
19
19
 
20
- g.write("gruff_line_2.jpg")
20
+ g.write("gruff_line_2.jpg")
@@ -18,4 +18,4 @@ g.title = "Visual Pie Graph Test"
18
18
  end
19
19
 
20
20
  # Default theme
21
- g.write("gruff_pie_1.jpg")
21
+ g.write("gruff_pie_1.jpg")
@@ -0,0 +1,23 @@
1
+ require 'rubygems'
2
+ require 'gruff'
3
+ require File.join(File.dirname(__FILE__), 'new_image.rb')
4
+
5
+ @datasets = [
6
+ [:Jimmy, [25, 36, 86, 39]],
7
+ [:Charles, [80, 54, 67, 54]],
8
+ [:Julie, [22, 29, 35, 38]],
9
+ ]
10
+
11
+ g = Gruff::StackedArea.new
12
+
13
+ g.labels = {
14
+ 0 => '5/6',
15
+ 1 => '5/15',
16
+ 2 => '5/24',
17
+ 3 => '5/30'
18
+ }
19
+
20
+ @datasets.each do |data|
21
+ g.data(data[0], data[1])
22
+ end
23
+ g.write "gruff_stacked_area_1.jpg"
@@ -5,6 +5,13 @@ else
5
5
  require "RMagick"
6
6
  end
7
7
 
8
+ class Float
9
+
10
+ def to_threshold
11
+ self/255 * Magick::QuantumRange
12
+ end
13
+ end
14
+
8
15
  class Magick::Image
9
16
  alias_method :old_write, :write
10
17
 
@@ -12,7 +19,7 @@ class Magick::Image
12
19
  file = File.join(File.expand_path(File.dirname(__FILE__)), '..', '..', 'images', filename)
13
20
  self.read file, &add
14
21
  end
15
-
22
+
16
23
  def write(filename)
17
24
  engine = (PLATFORM == 'java' ? 'jruby' : 'mri')
18
25
  new_filename = filename.sub(/(\.[^\.]*)$/, '.' + engine + '\1')
@@ -3,9 +3,12 @@ require 'rubygems'
3
3
 
4
4
  require 'test/unit'
5
5
  require 'gruff'
6
- require File.join(File.dirname(__FILE__),'monkey_gruff')
6
+ require 'fileutils'
7
7
  # require 'test_timer'
8
8
 
9
+ TEST_OUTPUT_DIR = File.dirname(__FILE__) + "/output"
10
+ FileUtils.mkdir_p(TEST_OUTPUT_DIR)
11
+
9
12
  class GruffTestCase < Test::Unit::TestCase
10
13
 
11
14
  def setup
@@ -77,7 +80,7 @@ protected
77
80
  end
78
81
 
79
82
  def write_test_file(graph, filename)
80
- graph.write(File.dirname(__FILE__) + "/output/#{filename}")
83
+ graph.write([TEST_OUTPUT_DIR, filename].join("/"))
81
84
  end
82
85
 
83
86
  ##
@@ -114,12 +114,12 @@ class TestGruffBar < GruffTestCase
114
114
 
115
115
  def test_set_legend_box_size
116
116
  g = setup_basic_graph(400)
117
- g.title = "Set Legend Box Size"
117
+ g.title = "Set Small Legend Box Size"
118
118
  g.legend_box_size = 10.0
119
119
  g.write("test/output/bar_set_legend_box_size_sm.png")
120
120
 
121
121
  g = setup_basic_graph(400)
122
- g.title = "Set Legend Box Size"
122
+ g.title = "Set Large Legend Box Size"
123
123
  g.legend_box_size = 50.0
124
124
  g.write("test/output/bar_set_legend_box_size_lg.png")
125
125
  end
@@ -233,7 +233,7 @@ class TestGruffBar < GruffTestCase
233
233
  :colors => %w(#efd250 #666699 #e5573f #9595e2),
234
234
  :marker_color => 'white',
235
235
  :font_color => 'blue',
236
- :background_image => File.join(File.dirname(__FILE__),"..","assets/pc306715.jpg")
236
+ :background_image => "assets/pc306715.jpg"
237
237
  }
238
238
  g.labels = {
239
239
  0 => '5/6',
@@ -248,6 +248,18 @@ class TestGruffBar < GruffTestCase
248
248
  g.minimum_value = 0
249
249
  g.write("test/output/bar_themed.png")
250
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
251
263
 
252
264
  def test_july_enhancements
253
265
  g = Gruff::Bar.new(600)
@@ -1,26 +1,26 @@
1
- require File.dirname(__FILE__) + "/gruff_test_case"
2
-
3
- class TestGruffBullet < GruffTestCase
4
-
5
- def setup
6
- @data_args = [75, 100, {
7
- :target => 80,
8
- :low => 50,
9
- :high => 90
10
- }]
11
- end
12
-
13
- def test_bullet_graph
14
- g = Gruff::Bullet.new
15
- g.title = "Monthly Revenue"
16
- g.data *@data_args
17
- g.write("test/output/bullet_greyscale.png")
18
- end
19
-
20
- def test_no_options
21
- g = Gruff::Bullet.new
22
- g.data 127, 150
23
- g.write("test/output/bullet_no_options.png")
24
- end
25
-
26
- end
1
+ # require File.dirname(__FILE__) + "/gruff_test_case"
2
+ #
3
+ # class TestGruffBullet < GruffTestCase
4
+ #
5
+ # def setup
6
+ # @data_args = [75, 100, {
7
+ # :target => 80,
8
+ # :low => 50,
9
+ # :high => 90
10
+ # }]
11
+ # end
12
+ #
13
+ # def test_bullet_graph
14
+ # g = Gruff::Bullet.new
15
+ # g.title = "Monthly Revenue"
16
+ # g.data *@data_args
17
+ # g.write("test/output/bullet_greyscale.png")
18
+ # end
19
+ #
20
+ # def test_no_options
21
+ # g = Gruff::Bullet.new
22
+ # g.data 127, 150
23
+ # g.write("test/output/bullet_no_options.png")
24
+ # end
25
+ #
26
+ # end