rsyntaxtree 0.6.92 → 0.7.0
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.
- checksums.yaml +4 -4
- data/Gemfile +0 -5
- data/README.md +28 -25
- data/bin/rsyntaxtree +14 -11
- data/fonts/NotoSansCJKjp-Regular.otf +0 -0
- data/fonts/NotoSansMonoCJKjp-Regular.otf +0 -0
- data/fonts/NotoSerifCJKjp-Regular.otf +0 -0
- data/lib/rsyntaxtree.rb +43 -61
- data/lib/rsyntaxtree/element.rb +1 -1
- data/lib/rsyntaxtree/elementlist.rb +2 -2
- data/lib/rsyntaxtree/error_message.rb +1 -1
- data/lib/rsyntaxtree/imgutils.rb +1 -1
- data/lib/rsyntaxtree/string_parser.rb +1 -1
- data/lib/rsyntaxtree/svg_graph.rb +1 -1
- data/lib/rsyntaxtree/tree_graph.rb +13 -10
- data/lib/rsyntaxtree/version.rb +1 -1
- data/rsyntaxtree.gemspec +3 -6
- metadata +12 -56
- data/app.rb +0 -56
- data/config.ru +0 -8
- data/fonts/ipagp.ttf +0 -0
- data/fonts/ipamp.ttf +0 -0
- data/helpers/helpers.rb +0 -22
- data/public/bootstrap/css/bootstrap-responsive.css +0 -581
- data/public/bootstrap/css/bootstrap-responsive.min.css +0 -4
- data/public/bootstrap/css/bootstrap.css +0 -3496
- data/public/bootstrap/css/bootstrap.min.css +0 -632
- data/public/bootstrap/img/glyphicons-halflings-white.png +0 -0
- data/public/bootstrap/img/glyphicons-halflings.png +0 -0
- data/public/bootstrap/js/bootstrap.js +0 -1731
- data/public/bootstrap/js/bootstrap.min.js +0 -7
- data/public/bootstrap/js/jquery.js +0 -4
- data/public/css/rsyntaxtree.css +0 -5
- data/public/js/rsyntaxtree.js +0 -137
- data/views/footer.haml +0 -3
- data/views/index.haml +0 -141
- data/views/layout.haml +0 -44
- data/views/navbar.haml +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5dcdb349a03810a145b1f240feee3ccc72f9f4f
|
4
|
+
data.tar.gz: a696ad43029ef6ea253f40a7277c621e52166fee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea1203926e30c5e02083f0975cb39856cc223ee83d8a9da69792f417b164b55b8f74818f125891aee088d71ccb90e2c451e11b9c2fa829bdae57108689985166
|
7
|
+
data.tar.gz: 5dfa20627985562e499262b3e107f0c2fb020d831be3b29c1f47625ad4d381e42aaa70f22fbfbc2e665a5974d2c066f0add3744b6fa99d9bb209fdc8b3269762
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
# RSyntaxTree: yet another syntax tree generator in Ruby
|
2
2
|
|
3
|
-
RSyntaxTree is a graphical syntax tree generator written in the Ruby programming language
|
3
|
+
**RSyntaxTree** is a graphical syntax tree generator written in the Ruby programming language inspired by [phpSyntaxTree](http://ironcreek.net/phpsyntaxtree/).
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
RSyntaxTree consists of an easy-to-use command-line app and a web-based interface made with [Sinatra](http://www.sinatrarb.com) web framework.
|
5
|
+
- - -
|
8
6
|
|
9
7
|
### Web Interface
|
10
8
|
|
11
|
-
Working web interface of
|
9
|
+
Working web interface of is available at <https://yohasebe.com/rsyntaxtree>.
|
12
10
|
|
13
11
|
### Installation
|
14
12
|
|
@@ -16,26 +14,29 @@ Working web interface of a previous version of RSyntaxTree is available at http:
|
|
16
14
|
|
17
15
|
### Usage
|
18
16
|
|
19
|
-
For the web interface, see Usage section
|
17
|
+
For the web interface, see Usage section of <https://yohasebe.com/rsyntaxtree>.
|
20
18
|
|
21
19
|
For the command-line interface, type `$rsyntaxtree -h` after installation. Here's what you get:
|
22
20
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
21
|
+
```text
|
22
|
+
RSyntaxTree, (linguistic) syntax tree generator written in Ruby.
|
23
|
+
|
24
|
+
Usage:
|
25
|
+
rsyntaxtree [options] "[VP [VP [V set] [NP bracket notation]] [ADV here]]"
|
26
|
+
where [options] are:
|
27
|
+
-o, --outdir=<s> Output directory (default: ./)
|
28
|
+
-f, --format=<s> Output format: png, pdf, or svg (default: png)
|
29
|
+
-l, --leafstyle=<s> visual style of tree leaves: auto, triangle, bar, or nothing (default: auto)
|
30
|
+
-n, --fontstyle=<s> Font style (available when ttf font is specified): sans, serif, mono, cjk (default: sans)
|
31
|
+
-t, --font=<s> Path to a ttf font used to generate tree (optional)
|
32
|
+
-s, --fontsize=<i> Size: 8-26 (default: 16)
|
33
|
+
-m, --margin=<i> Margin: 0-120 (default: 0)
|
34
|
+
-c, --color=<s> Color text and bars: on or off (default: on)
|
35
|
+
-y, --symmetrize=<s> Generate symmetrical, balanced tree: on or off (default: on)
|
36
|
+
-a, --autosub=<s> Put subscript numbers to nodes: on or off (default: off)
|
37
|
+
-v, --version Print version and exit
|
38
|
+
-h, --help Show this message
|
39
|
+
```
|
39
40
|
|
40
41
|
### Tips
|
41
42
|
|
@@ -49,11 +50,13 @@ You can put a subscript to any node by putting the _ character between the main
|
|
49
50
|
|
50
51
|
Bracket notation (auto-subscript-on):
|
51
52
|
|
52
|
-
|
53
|
+
```text
|
54
|
+
[S [NP RSyntaxTree^][VP [V generates][NP multilingual syntax trees]]]
|
55
|
+
```
|
53
56
|
|
54
57
|
Resulting PNG
|
55
58
|
|
56
|
-

|
57
60
|
|
58
61
|
### Development
|
59
62
|
|
@@ -61,7 +64,7 @@ For the latest updates and downloads please visit http://github.com/yohasebe/rsy
|
|
61
64
|
|
62
65
|
### Author
|
63
66
|
|
64
|
-
Yoichiro Hasebe yohasebe@gmail.com
|
67
|
+
Yoichiro Hasebe <yohasebe@gmail.com>
|
65
68
|
|
66
69
|
### License
|
67
70
|
|
data/bin/rsyntaxtree
CHANGED
@@ -7,7 +7,7 @@ require 'rsyntaxtree'
|
|
7
7
|
require 'trollop'
|
8
8
|
|
9
9
|
opts = Trollop::options do
|
10
|
-
version "RSyntaxTree #{RSyntaxTree::VERSION} (c)
|
10
|
+
version "RSyntaxTree #{RSyntaxTree::VERSION} (c) 2018 Yoichiro Hasebe"
|
11
11
|
banner <<-EOS
|
12
12
|
RSyntaxTree, (linguistic) syntax tree generator written in Ruby.
|
13
13
|
|
@@ -22,11 +22,13 @@ EOS
|
|
22
22
|
:default => "png"
|
23
23
|
opt :leafstyle, "visual style of tree leaves: auto, triangle, bar, or nothing",
|
24
24
|
:default => "auto"
|
25
|
-
opt :fontstyle, "Font style (available when ttf font is specified): sans
|
26
|
-
:default => "
|
25
|
+
opt :fontstyle, "Font style (available when ttf font is specified): sans, serif, mono, cjk",
|
26
|
+
:default => "sans"
|
27
27
|
opt :font, "Path to a ttf font used to generate tree (optional)", :type => String
|
28
|
-
opt :fontsize, "
|
28
|
+
opt :fontsize, "Size: 8-26",
|
29
29
|
:default => 16
|
30
|
+
opt :margin, "Margin: 0-120",
|
31
|
+
:default => 0
|
30
32
|
opt :color, "Color text and bars: on or off",
|
31
33
|
:default => "on"
|
32
34
|
opt :symmetrize, "Generate symmetrical, balanced tree: on or off",
|
@@ -38,30 +40,31 @@ end
|
|
38
40
|
Trollop::die :outdir, "must be an exsting directory path" unless FileTest::directory?(opts[:outdir])
|
39
41
|
Trollop::die :format, "must be png or svg" unless /\A(png|pdf|svg)\z/ =~ opts[:format]
|
40
42
|
Trollop::die :leafstyle, "must be auto, triangle, bar, or nothing" unless /\A(auto|triangle|bar|nothing)\z/ =~ opts[:leafstyle]
|
41
|
-
Trollop::die :fontstyle, "must be sans
|
43
|
+
Trollop::die :fontstyle, "must be sans, serif, mono, cjk" unless /\A(sans|serif|mono|cjk)\z/ =~ opts[:fontstyle]
|
42
44
|
Trollop::die :font, "must be path to an existing ttf font" if opts[:font] && !File::exists?(opts[:font])
|
43
|
-
Trollop::die :fontsize, "must be in the range 8-
|
45
|
+
Trollop::die :fontsize, "must be in the range 8-26" unless opts[:fontsize] >= 8 && opts[:fontsize] <= 26
|
46
|
+
Trollop::die :margin, "must be in the range 0-120" if opts[:margin] < 0 || opts[:margin] > 120
|
44
47
|
Trollop::die :color, "must be either on or off" unless /\A(on|off)\z/ =~ opts[:color]
|
45
48
|
Trollop::die :symmetrize, "must be either on or off" unless /\A(on|off)\z/ =~ opts[:symmetrize]
|
46
49
|
Trollop::die :autosub, "must be either on or off" unless /\A(on|off)\z/ =~ opts[:autosub]
|
47
50
|
|
48
51
|
string_opts = {}
|
49
52
|
opts.each do |key, value|
|
50
|
-
string_opts[key.
|
53
|
+
string_opts[key.to_sym] = value unless key == :font && !value
|
51
54
|
end
|
52
55
|
|
53
56
|
data = ARGV[0]
|
54
57
|
|
55
58
|
unless data && RSGenerator.check_data(data)
|
56
|
-
puts "bracket notation
|
59
|
+
puts "Error: given bracket notation is invalid; try 'rsyntaxtree --help' "
|
57
60
|
exit
|
58
61
|
end
|
59
62
|
|
60
|
-
string_opts[
|
63
|
+
string_opts[:data] = data
|
61
64
|
|
62
65
|
rsg = RSGenerator.new(string_opts)
|
63
|
-
ext = string_opts[
|
64
|
-
outfile = File.new(File.expand_path(string_opts[
|
66
|
+
ext = string_opts[:format]
|
67
|
+
outfile = File.new(File.expand_path(string_opts[:outdir]) + "/syntree." + ext, "wb")
|
65
68
|
case ext
|
66
69
|
when "png"
|
67
70
|
outfile.write rsg.draw_png
|
Binary file
|
Binary file
|
Binary file
|
data/lib/rsyntaxtree.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
#
|
11
11
|
# This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
|
12
12
|
# excellent program phpSyntaxTree.
|
13
|
-
# Copyright (c) 2007-
|
13
|
+
# Copyright (c) 2007-2018 Yoichiro Hasebe <yohasebe@gmail.com>
|
14
14
|
# Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
|
15
15
|
#
|
16
16
|
# This program is free software; you can redistribute it and/or modify
|
@@ -28,7 +28,6 @@
|
|
28
28
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
29
29
|
|
30
30
|
$LOAD_PATH << File.join( File.dirname(__FILE__), 'rsyntaxtree')
|
31
|
-
$LOAD_PATH << File.join( File.dirname(__FILE__), '../helpers')
|
32
31
|
|
33
32
|
require 'uri'
|
34
33
|
require 'imgutils'
|
@@ -38,32 +37,18 @@ require 'string_parser'
|
|
38
37
|
require 'tree_graph'
|
39
38
|
require 'svg_graph'
|
40
39
|
require 'error_message'
|
41
|
-
require 'helpers'
|
42
40
|
require 'version'
|
41
|
+
require 'pp'
|
43
42
|
|
44
43
|
FONT_DIR = File.expand_path(File.dirname(__FILE__) + "/../fonts")
|
45
44
|
|
46
|
-
##################################################
|
47
|
-
# if !development?
|
48
|
-
# # load and store Google Analytics code, if any, to a variable
|
49
|
-
# ga_path = File.dirname(__FILE__) + "/../google_analytics_tracking_code"
|
50
|
-
# if File.exists?(ga_path)
|
51
|
-
# gfile = File.open(ga_path, "r:UTF-8:UTF-8")
|
52
|
-
# $GOOGLE_CODE = gfile.read
|
53
|
-
# gfile.close
|
54
|
-
# else
|
55
|
-
# $GOOGLE_CODE = ""
|
56
|
-
# end
|
57
|
-
# end
|
58
|
-
##################################################
|
59
|
-
|
60
45
|
class RSGenerator
|
61
|
-
include Helpers
|
62
46
|
def initialize(params = {})
|
63
47
|
new_params = {}
|
64
|
-
params.each do |
|
48
|
+
params.each do |keystr, value|
|
49
|
+
key = keystr.to_sym
|
65
50
|
case key
|
66
|
-
when
|
51
|
+
when :data
|
67
52
|
data = URI.unescape(value)
|
68
53
|
data = data.gsub('-AMP-', '&')
|
69
54
|
.gsub('-PERCENT-', "%")
|
@@ -72,83 +57,80 @@ class RSGenerator
|
|
72
57
|
.gsub('-OABRACKET-', '<')
|
73
58
|
.gsub('-CABRACKET-', '>')
|
74
59
|
new_params[key] = data
|
75
|
-
when
|
76
|
-
new_params[key] = value
|
77
|
-
when
|
60
|
+
when :symmetrize, :color, :autosub
|
61
|
+
new_params[key] = value && value != "off" ? true : false
|
62
|
+
when :fontsize
|
63
|
+
new_params[key] = value.to_i
|
64
|
+
when :margin
|
78
65
|
new_params[key] = value.to_i
|
79
|
-
when
|
80
|
-
if value == "sans
|
81
|
-
new_params[
|
82
|
-
elsif value == "serif"
|
83
|
-
new_params[
|
84
|
-
elsif value == "
|
85
|
-
new_params[
|
86
|
-
elsif value == "
|
87
|
-
new_params[
|
88
|
-
elsif value == "
|
89
|
-
new_params[
|
90
|
-
elsif value == "
|
91
|
-
new_params[
|
92
|
-
elsif value == "tnr"
|
93
|
-
new_params["font"] = FONT_DIR + "/TimesNewRoman.ttf"
|
94
|
-
elsif value == "noto"
|
95
|
-
new_params["font"] = FONT_DIR + "/NotoSansCJK.ttc"
|
66
|
+
when :fontstyle
|
67
|
+
if value == "noto-sans" || value == "sans"
|
68
|
+
new_params[:font] = FONT_DIR + "/NotoSansCJKjp-Regular.otf"
|
69
|
+
elsif value == "noto-serif" || value == "serif"
|
70
|
+
new_params[:font] = FONT_DIR + "/NotoSerifCJKjp-Regular.otf"
|
71
|
+
elsif value == "noto-mono" || value == "mono"
|
72
|
+
new_params[:font] = FONT_DIR + "/NotoSansMonoCJKjp-Regular.otf"
|
73
|
+
elsif value == "western-sans"
|
74
|
+
new_params[:font] = FONT_DIR + "/DroidSans.ttf"
|
75
|
+
elsif value == "western-serif"
|
76
|
+
new_params[:font] = FONT_DIR + "/DroidSerif-Regular.ttf"
|
77
|
+
elsif value == "cjk zenhei" || value == "cjk"
|
78
|
+
new_params[:font] = FONT_DIR + "/wqy-zenhei.ttf"
|
96
79
|
end
|
97
80
|
else
|
98
81
|
new_params[key] = value
|
99
82
|
end
|
100
83
|
end
|
101
84
|
|
102
|
-
|
103
85
|
@params = {
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
86
|
+
:symmetrize => true,
|
87
|
+
:color => true,
|
88
|
+
:autosub => false,
|
89
|
+
:fontsize => 18,
|
90
|
+
:format => "png",
|
91
|
+
:leafstyle => "auto",
|
92
|
+
:font => FONT_DIR + "/NotoSansCKjp-Regular.otf",
|
93
|
+
:filename => "syntree",
|
94
|
+
:data => "",
|
95
|
+
:margin => 0
|
113
96
|
}
|
114
97
|
|
115
98
|
@params.merge! new_params
|
116
99
|
end
|
117
100
|
|
118
101
|
def self.check_data(text)
|
119
|
-
# StringParser.validate_text(text)
|
120
102
|
sp = StringParser.new(text)
|
121
103
|
sp.valid?
|
122
104
|
end
|
123
105
|
|
124
106
|
def draw_png
|
125
|
-
@params[
|
107
|
+
@params[:format] = "png"
|
126
108
|
draw_tree
|
127
109
|
end
|
128
110
|
|
129
111
|
def draw_pdf
|
130
|
-
@params[
|
112
|
+
@params[:format] = "pdf"
|
131
113
|
draw_tree
|
132
114
|
end
|
133
115
|
|
134
116
|
def draw_tree
|
135
|
-
sp = StringParser.new(@params[
|
117
|
+
sp = StringParser.new(@params[:data])
|
136
118
|
sp.parse
|
137
|
-
sp.auto_subscript if @params[
|
119
|
+
sp.auto_subscript if @params[:autosub]
|
138
120
|
elist = sp.get_elementlist
|
139
121
|
graph = TreeGraph.new(elist,
|
140
|
-
@params[
|
141
|
-
graph.to_blob(@params[
|
122
|
+
@params[:symmetrize], @params[:color], @params[:leafstyle], @params[:font], @params[:fontsize], @params[:format], @params[:margin])
|
123
|
+
graph.to_blob(@params[:format])
|
142
124
|
end
|
143
125
|
|
144
126
|
def draw_svg
|
145
|
-
@params[
|
146
|
-
sp = StringParser.new(@params[
|
127
|
+
@params[:format] = "svg"
|
128
|
+
sp = StringParser.new(@params[:data].gsub('&', '&').gsub('%', '%'))
|
147
129
|
sp.parse
|
148
|
-
sp.auto_subscript if @params[
|
130
|
+
sp.auto_subscript if @params[:autosub]
|
149
131
|
elist = sp.get_elementlist
|
150
132
|
graph = SVGGraph.new(elist,
|
151
|
-
@params[
|
133
|
+
@params[:symmetrize], @params[:color], @params[:leafstyle], @params[:font], @params[:fontsize])
|
152
134
|
graph.svg_data
|
153
135
|
end
|
154
136
|
end
|
data/lib/rsyntaxtree/element.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
# This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
|
11
11
|
# excellent program phpSyntaxTree.
|
12
12
|
#
|
13
|
-
# Copyright (c) 2007-
|
13
|
+
# Copyright (c) 2007-2018 Yoichiro Hasebe <yohasebe@gmail.com>
|
14
14
|
# Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
|
15
15
|
#
|
16
16
|
# This program is free software; you can redistribute it and/or modify
|
@@ -10,7 +10,7 @@
|
|
10
10
|
# This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
|
11
11
|
# excellent program phpSyntaxTree.
|
12
12
|
#
|
13
|
-
# Copyright (c) 2007-
|
13
|
+
# Copyright (c) 2007-2018 Yoichiro Hasebe <yohasebe@gmail.com>
|
14
14
|
# Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
|
15
15
|
#
|
16
16
|
# This program is free software; you can redistribute it and/or modify
|
@@ -134,4 +134,4 @@ class ElementList
|
|
134
134
|
end
|
135
135
|
|
136
136
|
end
|
137
|
-
|
137
|
+
|
@@ -10,7 +10,7 @@
|
|
10
10
|
# This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
|
11
11
|
# excellent program phpSyntaxTree.
|
12
12
|
#
|
13
|
-
# Copyright (c) 2007-
|
13
|
+
# Copyright (c) 2007-2018 Yoichiro Hasebe <yohasebe@gmail.com>
|
14
14
|
# Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
|
15
15
|
#
|
16
16
|
# This program is free software; you can redistribute it and/or modify
|
data/lib/rsyntaxtree/imgutils.rb
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
# This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
|
11
11
|
# excellent program phpSyntaxTree.
|
12
12
|
#
|
13
|
-
# Copyright (c) 2007-
|
13
|
+
# Copyright (c) 2007-2018 Yoichiro Hasebe <yohasebe@gmail.com>
|
14
14
|
# Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
|
15
15
|
#
|
16
16
|
# This program is free software; you can redistribute it and/or modify
|
@@ -11,7 +11,7 @@
|
|
11
11
|
# This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
|
12
12
|
# excellent program phpSyntaxTree.
|
13
13
|
#
|
14
|
-
# Copyright (c) 2007-
|
14
|
+
# Copyright (c) 2007-2018 Yoichiro Hasebe <yohasebe@gmail.com>
|
15
15
|
# Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
|
16
16
|
#
|
17
17
|
# This program is free software; you can redistribute it and/or modify
|
@@ -10,7 +10,7 @@
|
|
10
10
|
# This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
|
11
11
|
# excellent program phpSyntaxTree.
|
12
12
|
#
|
13
|
-
# Copyright (c) 2007-
|
13
|
+
# Copyright (c) 2007-2018 Yoichiro Hasebe <yohasebe@gmail.com>
|
14
14
|
# Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
|
15
15
|
#
|
16
16
|
# This program is free software; you can redistribute it and/or modify
|
@@ -10,7 +10,7 @@
|
|
10
10
|
# This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
|
11
11
|
# excellent program phpSyntaxTree.
|
12
12
|
#
|
13
|
-
# Copyright (c) 2007-
|
13
|
+
# Copyright (c) 2007-2018 Yoichiro Hasebe <yohasebe@gmail.com>
|
14
14
|
# Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
|
15
15
|
#
|
16
16
|
# This program is free software; you can redistribute it and/or modify
|
@@ -33,25 +33,27 @@ require 'elementlist'
|
|
33
33
|
require 'rmagick'
|
34
34
|
include Magick
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
# Double to make image retina ready
|
37
|
+
E_WIDTH = 60 * 2 # Element width
|
38
|
+
E_PADD = 7 * 2 # Element height padding
|
39
|
+
V_SPACE = 20 * 2
|
40
|
+
H_SPACE = 10 * 2
|
41
|
+
B_SIDE = 5 * 2
|
42
|
+
B_TOPBOT = 5 * 2
|
42
43
|
|
43
44
|
class TreeGraph
|
44
45
|
|
45
46
|
def initialize(e_list, symmetrize = true, color = true, terminal = "auto",
|
46
|
-
font = "Helvetica", font_size = 10, simple = false)
|
47
|
+
font = "Helvetica", font_size = 10, simple = false, margin = 0)
|
47
48
|
|
48
|
-
# Store parameters
|
49
|
+
# Store parameters (double font size and margin to make image retina ready)
|
49
50
|
@e_list = e_list
|
50
51
|
@font = font
|
51
|
-
@font_size = font_size
|
52
52
|
@terminal = terminal
|
53
53
|
@symmetrize = symmetrize
|
54
54
|
@simple = simple
|
55
|
+
@font_size = font_size * 2
|
56
|
+
@margin = margin * 2
|
55
57
|
|
56
58
|
# Element dimensions
|
57
59
|
@e_width = E_WIDTH
|
@@ -104,6 +106,7 @@ class TreeGraph
|
|
104
106
|
# by Geoffrey Grosenbach
|
105
107
|
def to_blob(fileformat='PNG')
|
106
108
|
draw
|
109
|
+
@im.border!(@margin, @margin, "white")
|
107
110
|
return @im.to_blob do
|
108
111
|
self.format = fileformat
|
109
112
|
end
|