ruby-treemap 0.0.2 → 0.0.3
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.
- data/ChangeLog +4 -0
- data/lib/treemap.rb +2 -2
- data/lib/treemap/svg_output.rb +19 -1
- metadata +12 -12
data/ChangeLog
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
RubyTreemap - ChangeLog
|
3
3
|
===============================================================================
|
4
4
|
|
5
|
+
2008-11-23
|
6
|
+
* Applied patch from Peter Krantz
|
7
|
+
- Enables svg output with centered labels
|
8
|
+
|
5
9
|
2007-08-14
|
6
10
|
* Applied patch from Adrian Schoenig
|
7
11
|
- added an object attribute to the Treemap::Node class in order to
|
data/lib/treemap.rb
CHANGED
@@ -19,13 +19,13 @@ require File.dirname(__FILE__) + '/treemap/squarified_layout'
|
|
19
19
|
require File.dirname(__FILE__) + '/treemap/html_output'
|
20
20
|
require File.dirname(__FILE__) + '/treemap/rectangle'
|
21
21
|
require File.dirname(__FILE__) + '/treemap/gradient_color'
|
22
|
+
require File.dirname(__FILE__) + '/treemap/svg_output'
|
22
23
|
|
23
24
|
# XXX these are still expirmental. Requires RMagick
|
24
25
|
# require File.dirname(__FILE__) + '/treemap/image_output'
|
25
|
-
# require File.dirname(__FILE__) + '/treemap/svg_output'
|
26
26
|
|
27
27
|
module Treemap
|
28
|
-
VERSION = "0.0.
|
28
|
+
VERSION = "0.0.3"
|
29
29
|
|
30
30
|
def Treemap::dump_tree(node)
|
31
31
|
puts "#{node.label}: #{node.bounds.to_s}"
|
data/lib/treemap/svg_output.rb
CHANGED
@@ -27,6 +27,22 @@ class Treemap::SvgOutput < Treemap::OutputBase
|
|
27
27
|
CGI.escapeHTML(node.label)
|
28
28
|
end
|
29
29
|
|
30
|
+
def draw_node_body(node)
|
31
|
+
draw_label(node)
|
32
|
+
end
|
33
|
+
|
34
|
+
def draw_label(node)
|
35
|
+
# center label in box
|
36
|
+
label = ""
|
37
|
+
label += "<text style=\"text-anchor: middle\" font-size=\"15\""
|
38
|
+
label += " x=\"" + (node.bounds.x1 + node.bounds.width / 2).to_s + "\""
|
39
|
+
label += " y=\"" + (node.bounds.y1 + node.bounds.height / 2).to_s + "\">"
|
40
|
+
label += node_label(node)
|
41
|
+
label += "</text>\n"
|
42
|
+
|
43
|
+
label
|
44
|
+
end
|
45
|
+
|
30
46
|
def node_color(node)
|
31
47
|
color = "#CCCCCC"
|
32
48
|
|
@@ -83,8 +99,10 @@ class Treemap::SvgOutput < Treemap::OutputBase
|
|
83
99
|
svg += " fill=\"" + node_color(node) + "\""
|
84
100
|
svg += " stroke=\"#000000\""
|
85
101
|
svg += " stroke-width=\"1px\""
|
86
|
-
svg += "
|
102
|
+
svg += " />\n"
|
87
103
|
|
104
|
+
svg += draw_node_body(node)
|
105
|
+
|
88
106
|
if(!node.children.nil? and node.children.size > 0)
|
89
107
|
node.children.each do |c|
|
90
108
|
svg += draw_node(c)
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: ruby-treemap
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date:
|
6
|
+
version: 0.0.3
|
7
|
+
date: 2008-11-23 00:00:00 -05:00
|
8
8
|
summary: Treemap visualization in ruby
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -35,26 +35,26 @@ files:
|
|
35
35
|
- README
|
36
36
|
- ChangeLog
|
37
37
|
- COPYING
|
38
|
+
- lib/treemap.rb
|
38
39
|
- lib/treemap
|
39
|
-
- lib/treemap/
|
40
|
+
- lib/treemap/squarified_layout.rb
|
41
|
+
- lib/treemap/node.rb
|
40
42
|
- lib/treemap/image_output.rb
|
41
|
-
- lib/treemap/html_output.rb
|
42
43
|
- lib/treemap/rectangle.rb
|
43
|
-
- lib/treemap/
|
44
|
-
- lib/treemap/
|
44
|
+
- lib/treemap/svg_output.rb
|
45
|
+
- lib/treemap/html_output.rb
|
45
46
|
- lib/treemap/color_base.rb
|
46
|
-
- lib/treemap/
|
47
|
-
- lib/treemap/output_base.rb
|
47
|
+
- lib/treemap/layout_base.rb
|
48
48
|
- lib/treemap/gradient_color.rb
|
49
|
+
- lib/treemap/output_base.rb
|
49
50
|
- lib/treemap/slice_layout.rb
|
50
|
-
- lib/treemap.rb
|
51
51
|
- test/tc_simple.rb
|
52
|
-
- test/tc_squarified.rb
|
53
|
-
- test/tc_color.rb
|
54
|
-
- test/tc_slice.rb
|
55
52
|
- test/tc_svg.rb
|
53
|
+
- test/tc_slice.rb
|
54
|
+
- test/tc_squarified.rb
|
56
55
|
- test/test_base.rb
|
57
56
|
- test/tc_html.rb
|
57
|
+
- test/tc_color.rb
|
58
58
|
test_files: []
|
59
59
|
|
60
60
|
rdoc_options:
|