ctioga2 0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. data/COPYING +339 -0
  2. data/Changelog +6 -0
  3. data/bin/ctioga2 +26 -0
  4. data/lib/ctioga2/commands/arguments.rb +58 -0
  5. data/lib/ctioga2/commands/commands.rb +258 -0
  6. data/lib/ctioga2/commands/doc/doc.rb +118 -0
  7. data/lib/ctioga2/commands/doc/documentation-commands.rb +119 -0
  8. data/lib/ctioga2/commands/doc/help.rb +95 -0
  9. data/lib/ctioga2/commands/doc/html.rb +230 -0
  10. data/lib/ctioga2/commands/doc/introspection.rb +211 -0
  11. data/lib/ctioga2/commands/doc/man.rb +279 -0
  12. data/lib/ctioga2/commands/doc/markup.rb +359 -0
  13. data/lib/ctioga2/commands/general-commands.rb +119 -0
  14. data/lib/ctioga2/commands/general-types.rb +118 -0
  15. data/lib/ctioga2/commands/groups.rb +73 -0
  16. data/lib/ctioga2/commands/interpreter.rb +257 -0
  17. data/lib/ctioga2/commands/parsers/command-line.rb +187 -0
  18. data/lib/ctioga2/commands/parsers/file.rb +186 -0
  19. data/lib/ctioga2/commands/strings.rb +303 -0
  20. data/lib/ctioga2/commands/type.rb +100 -0
  21. data/lib/ctioga2/commands/variables.rb +101 -0
  22. data/lib/ctioga2/data/backends/backend.rb +260 -0
  23. data/lib/ctioga2/data/backends/backends.rb +39 -0
  24. data/lib/ctioga2/data/backends/backends/gnuplot.rb +140 -0
  25. data/lib/ctioga2/data/backends/backends/math.rb +121 -0
  26. data/lib/ctioga2/data/backends/backends/text.rb +335 -0
  27. data/lib/ctioga2/data/backends/description.rb +405 -0
  28. data/lib/ctioga2/data/backends/factory.rb +73 -0
  29. data/lib/ctioga2/data/backends/parameter.rb +109 -0
  30. data/lib/ctioga2/data/datacolumn.rb +245 -0
  31. data/lib/ctioga2/data/dataset.rb +233 -0
  32. data/lib/ctioga2/data/filters.rb +131 -0
  33. data/lib/ctioga2/data/merge.rb +43 -0
  34. data/lib/ctioga2/data/point.rb +72 -0
  35. data/lib/ctioga2/data/stack.rb +294 -0
  36. data/lib/ctioga2/graphics/coordinates.rb +73 -0
  37. data/lib/ctioga2/graphics/elements.rb +111 -0
  38. data/lib/ctioga2/graphics/elements/containers.rb +111 -0
  39. data/lib/ctioga2/graphics/elements/curve2d.rb +155 -0
  40. data/lib/ctioga2/graphics/elements/element.rb +90 -0
  41. data/lib/ctioga2/graphics/elements/primitive.rb +256 -0
  42. data/lib/ctioga2/graphics/elements/subplot.rb +140 -0
  43. data/lib/ctioga2/graphics/generator.rb +68 -0
  44. data/lib/ctioga2/graphics/legends.rb +108 -0
  45. data/lib/ctioga2/graphics/legends/area.rb +199 -0
  46. data/lib/ctioga2/graphics/legends/items.rb +183 -0
  47. data/lib/ctioga2/graphics/legends/provider.rb +58 -0
  48. data/lib/ctioga2/graphics/legends/storage.rb +65 -0
  49. data/lib/ctioga2/graphics/root.rb +209 -0
  50. data/lib/ctioga2/graphics/styles.rb +30 -0
  51. data/lib/ctioga2/graphics/styles/axes.rb +247 -0
  52. data/lib/ctioga2/graphics/styles/background.rb +122 -0
  53. data/lib/ctioga2/graphics/styles/base.rb +115 -0
  54. data/lib/ctioga2/graphics/styles/carrays.rb +53 -0
  55. data/lib/ctioga2/graphics/styles/curve.rb +101 -0
  56. data/lib/ctioga2/graphics/styles/drawable.rb +87 -0
  57. data/lib/ctioga2/graphics/styles/factory.rb +351 -0
  58. data/lib/ctioga2/graphics/styles/legend.rb +63 -0
  59. data/lib/ctioga2/graphics/styles/plot.rb +410 -0
  60. data/lib/ctioga2/graphics/styles/sets.rb +64 -0
  61. data/lib/ctioga2/graphics/styles/texts.rb +277 -0
  62. data/lib/ctioga2/graphics/subplot-commands.rb +141 -0
  63. data/lib/ctioga2/graphics/types.rb +188 -0
  64. data/lib/ctioga2/graphics/types/bijection.rb +79 -0
  65. data/lib/ctioga2/graphics/types/boundaries.rb +170 -0
  66. data/lib/ctioga2/graphics/types/boxes.rb +157 -0
  67. data/lib/ctioga2/graphics/types/dimensions.rb +157 -0
  68. data/lib/ctioga2/graphics/types/point.rb +247 -0
  69. data/lib/ctioga2/log.rb +97 -0
  70. data/lib/ctioga2/metabuilder/type.rb +316 -0
  71. data/lib/ctioga2/metabuilder/types.rb +39 -0
  72. data/lib/ctioga2/metabuilder/types/coordinates.rb +124 -0
  73. data/lib/ctioga2/metabuilder/types/dates.rb +43 -0
  74. data/lib/ctioga2/metabuilder/types/lists.rb +188 -0
  75. data/lib/ctioga2/metabuilder/types/numbers.rb +97 -0
  76. data/lib/ctioga2/metabuilder/types/strings.rb +93 -0
  77. data/lib/ctioga2/metabuilder/types/styles.rb +178 -0
  78. data/lib/ctioga2/plotmaker.rb +677 -0
  79. data/lib/ctioga2/postprocess.rb +115 -0
  80. data/lib/ctioga2/utils.rb +120 -0
  81. data/setup.rb +1586 -0
  82. metadata +144 -0
@@ -0,0 +1,43 @@
1
+ # dates.rb: a Type to deal with dates
2
+ # Copyright (C) 2006, 2009 Vincent Fourmond
3
+ #
4
+ # This program is free software; you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program; if not, write to the Free Software
16
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
+
18
+ require 'time'
19
+ require 'ctioga2/utils'
20
+
21
+ module CTioga2
22
+ Version::register_svn_info('$Revision: 2 $', '$Date: 2009-04-25 14:03:30 +0200 (Sat, 25 Apr 2009) $')
23
+
24
+ module MetaBuilder
25
+
26
+ # The module Types should be used for all subclasses of Type, to
27
+ # keep the place clean and tidy.
28
+ module Types
29
+
30
+ # A combination date/time
31
+ class DateTimeParameter < Type
32
+
33
+ type_name :date_time, 'date', Time.new
34
+
35
+ def string_to_type_internal(str)
36
+ return Time.parse(str)
37
+ end
38
+
39
+ end
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,188 @@
1
+ # lists.rb : Different Types to deal with types where
2
+ # you can choose among several possibilities
3
+ # Copyright (C) 2006, 2009 Vincent Fourmond
4
+ #
5
+ # This program is free software; you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation; either version 2 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU General Public License
16
+ # along with this program; if not, write to the Free Software
17
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
+
19
+ require 'ctioga2/utils'
20
+
21
+ module CTioga2
22
+
23
+ Version::register_svn_info('$Revision: 2 $', '$Date: 2009-04-25 14:03:30 +0200 (Sat, 25 Apr 2009) $')
24
+
25
+
26
+ module MetaBuilder
27
+
28
+ # The module Types should be used for all subclasses of
29
+ # Type, to keep the place clean and tidy.
30
+ module Types
31
+
32
+ # A regular expression matching true
33
+ TRUE_RE = /^\s*(true|yes|on)\s*$/i
34
+
35
+ # A regular expression matching false
36
+ FALSE_RE = /^\s*(false|no(ne)?|off)\s*$/i
37
+
38
+
39
+ # A boolean parameter
40
+ class BooleanParameter < Type
41
+
42
+ type_name :boolean
43
+
44
+ def type_name
45
+ return 'bool'
46
+ end
47
+
48
+ # Yes, this *really* is a boolean !
49
+ def boolean?
50
+ return true
51
+ end
52
+
53
+ def string_to_type_internal(str)
54
+ if str == true or str =~ TRUE_RE
55
+ return true
56
+ else
57
+ return false
58
+ end
59
+ end
60
+
61
+ def type_to_string_internal(val)
62
+ if val
63
+ return "true"
64
+ else
65
+ return "false"
66
+ end
67
+ end
68
+
69
+ # Booleans are a special case for option parser, as they
70
+ # are handled completely differently
71
+ def option_parser_long_option(name, biniou = nil)
72
+ return "--[no-]#{name}"
73
+ end
74
+ end
75
+
76
+ # A list of symbols. A hash :list must be provided that states
77
+ # the correspondance between the legal symbols that can be
78
+ # accepted by this parameter and their "english" name.
79
+ # This parameter can typically be used to prompt the user
80
+ # for different choices.
81
+ class ListParameter < Type
82
+
83
+ type_name :list
84
+
85
+ def initialize(type)
86
+ super
87
+ raise "type must have a :list key" unless type.has_key?(:list)
88
+ # We make a copy for our own purposes.
89
+ @hash = type[:list].dup
90
+ end
91
+
92
+ def type_name
93
+ return 'list'
94
+ end
95
+
96
+ def string_to_type_internal(str)
97
+ if @hash.has_key?(str.to_sym)
98
+ return str.to_sym
99
+ else
100
+ raise IncorrectInput, "Invalid input: #{str} should be one of " +
101
+ @hash.keys.map {|s| s.to_s}.join(',')
102
+ end
103
+ end
104
+
105
+ def type_to_string_internal(val)
106
+ return val.to_s
107
+ end
108
+ end
109
+
110
+ # An array of identical elements of type specified by :subtype. Defaults
111
+ # to String
112
+ class ArrayParameter < Type
113
+ type_name :array
114
+
115
+ def initialize(type)
116
+ super
117
+ # We make a copy for our own purposes.
118
+ subtype = type[:subtype] || {:type => :string}
119
+ @subtype = Type.get_type(subtype)
120
+ @separator = /\s*,\s*/
121
+ @separator_out = ','
122
+ end
123
+
124
+ def type_name
125
+ return 'array'
126
+ end
127
+
128
+ def string_to_type_internal(str)
129
+ ary = str.split(@separator)
130
+ return ary.map do |a|
131
+ @subtype.string_to_type(a)
132
+ end
133
+ end
134
+
135
+ def type_to_string_internal(val)
136
+ return val.map do |a|
137
+ @subtype.type_to_string(a)
138
+ end.join(@separator_out)
139
+ end
140
+ end
141
+
142
+ # A Type used for sets for Graphics::Styles::CircularArray
143
+ # objects.
144
+ #
145
+ # TODO: write a gradient stuff !!!
146
+ class SetParameter < ArrayParameter
147
+ type_name :set
148
+
149
+ def initialize(type)
150
+ super
151
+ @separator = /\s*\|\s*/
152
+ @sepatarot_out = '|'
153
+ end
154
+
155
+ def type_name
156
+ return 'set'
157
+ end
158
+
159
+ def string_to_type_internal(str)
160
+ if str =~ /^\s*gradient:(.+)--(.+),(\d+)\s*$/
161
+ s,e,nb = $1, $2, $3.to_i
162
+ s,e = @subtype.string_to_type(s),@subtype.string_to_type(e)
163
+ fact = if nb > 1
164
+ 1.0/(nb - 1) # The famous off-by one...
165
+ else
166
+ warn "Incorrect gradient number: #{nb}"
167
+ 1.0
168
+ end
169
+ array = []
170
+ nb.times do |i|
171
+ a = []
172
+ f = i * fact
173
+ e.each_index do |c|
174
+ a << s[c] * (1 - f) + e[c] * f
175
+ end
176
+ array << a
177
+ end
178
+ return array
179
+ else
180
+ return super
181
+ end
182
+ end
183
+
184
+ end
185
+
186
+ end
187
+ end
188
+ end
@@ -0,0 +1,97 @@
1
+ # numbers.rb : Different Types to deal with numbers
2
+ # Copyright (C) 2006 Vincent Fourmond
3
+ #
4
+ # This program is free software; you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program; if not, write to the Free Software
16
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
+
18
+
19
+ require 'ctioga2/utils'
20
+
21
+ module CTioga2
22
+
23
+ Version::register_svn_info('$Revision: 2 $', '$Date: 2009-04-25 14:03:30 +0200 (Sat, 25 Apr 2009) $')
24
+
25
+ module MetaBuilder
26
+
27
+ # The module Types should be used for all subclasses of
28
+ # Type, to keep the place clean and tidy.
29
+ module Types
30
+
31
+ # An integer
32
+ class IntegerParameter < Type
33
+
34
+ type_name :integer, 'number', 0
35
+
36
+ def string_to_type_internal(str)
37
+ return Integer(str)
38
+ end
39
+
40
+ end
41
+
42
+ # A float
43
+ class FloatParameter < Type
44
+
45
+ type_name :float, 'number', 0.0
46
+
47
+ def string_to_type_internal(str)
48
+ return Float(str)
49
+ end
50
+
51
+ end
52
+
53
+ # A Float Range.
54
+ class FloatRangeParameter < Type
55
+
56
+ RANGE_RE = /([^:]+):([^:]+)/
57
+
58
+ type_name :float_range, 'range'
59
+
60
+ def string_to_type_internal(str)
61
+ raise IncorrectInput, "#{str} is not a valid range" unless
62
+ str =~ RANGE_RE
63
+ s,e = Float($1), Float($2)
64
+ return Range.new(s,e)
65
+ end
66
+
67
+ def type_to_string_internal(value)
68
+ return "#{value.first.to_s}:#{value.last.to_s}"
69
+ end
70
+
71
+ end
72
+
73
+ # Returns a [ start, end ] array where elements are either Float
74
+ # or _nil_.
75
+ class PartialFloatRangeType < Type
76
+
77
+ RANGE_RE = /([^:]+)?:([^:]+)?/
78
+
79
+ type_name :partial_float_range, 'range'
80
+
81
+ def string_to_type_internal(str)
82
+ raise IncorrectInput, "#{str} is not a valid range" unless
83
+ str =~ RANGE_RE
84
+ s,e = ($1 ? Float($1) : nil), ($2 ? Float($2) : nil)
85
+ return [s, e]
86
+ end
87
+
88
+ def type_to_string_internal(value)
89
+ return "#{value.first.to_s}:#{value.last.to_s}"
90
+ end
91
+
92
+ end
93
+
94
+ end
95
+
96
+ end
97
+ end
@@ -0,0 +1,93 @@
1
+ # strings.rb : Different Types to deal with strings
2
+ # Copyright (C) 2006 Vincent Fourmond
3
+ #
4
+ # This program is free software; you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program; if not, write to the Free Software
16
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
+
18
+ require 'ctioga2/utils'
19
+
20
+ module CTioga2
21
+
22
+ Version::register_svn_info('$Revision: 2 $', '$Date: 2009-04-25 14:03:30 +0200 (Sat, 25 Apr 2009) $')
23
+
24
+
25
+ module MetaBuilder
26
+
27
+ # The module Types should be used for all subclasses of
28
+ # Type, to keep the place clean and tidy.
29
+ module Types
30
+
31
+ # A String
32
+ class StringParameter < Type
33
+
34
+ type_name :string
35
+
36
+ def type_name
37
+ return 'text'
38
+ end
39
+
40
+ def string_to_type(str)
41
+ return str
42
+ end
43
+ end
44
+
45
+ # A piece of text representing the path to a file.
46
+ class FileParameter < StringParameter
47
+
48
+ type_name :file
49
+
50
+ # The file filters, Qt style.
51
+ attr_reader :filter
52
+
53
+ def initialize(type)
54
+ super(type)
55
+ @filter = @type[:filter]
56
+ end
57
+
58
+ def type_name
59
+ return 'file'
60
+ end
61
+
62
+ end
63
+
64
+ # A String or a regular expression
65
+ class StringOrRegexpParameter < Type
66
+
67
+ type_name :string_or_regexp
68
+
69
+ def type_name
70
+ return 'regexp'
71
+ end
72
+
73
+ def string_to_type(str)
74
+ if str =~ /^\/(.*)\/$/
75
+ return Regexp.new($1)
76
+ else
77
+ return str
78
+ end
79
+ end
80
+
81
+ def type_to_string(val)
82
+ if val.is_a? String
83
+ return val
84
+ else
85
+ return "/#{val}/"
86
+ end
87
+ end
88
+
89
+ end
90
+
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,178 @@
1
+ # styles.rb : Different Types to deal with various style arguments.
2
+ # Copyright (C) 2006, 2009 Vincent Fourmond
3
+ #
4
+ # This program is free software; you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation; either version 2 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program; if not, write to the Free Software
16
+ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17
+
18
+
19
+ require 'ctioga2/utils'
20
+
21
+ module CTioga2
22
+
23
+ Version::register_svn_info('$Revision: 96 $', '$Date: 2009-06-27 20:56:17 +0200 (Sat, 27 Jun 2009) $')
24
+
25
+ module MetaBuilder
26
+ module Types
27
+
28
+ # A color for use with Tioga, ie an [red, green, blue] array
29
+ # of values between 0 and 1.0. It accepts HTML-like colors, or
30
+ # three comma-separated values between 0 and 1.
31
+ class TiogaColorType < Type
32
+
33
+ type_name :tioga_color, 'color'
34
+
35
+ def string_to_type_internal(str)
36
+ if str =~ /^\s*#([0-9a-fA-F]{6})\s*$/
37
+ value = $1.scan(/../).map {
38
+ |i| i.to_i(16)/255.0
39
+ }
40
+ elsif str =~ /^\s*#([0-9a-fA-F]{3})\s*$/
41
+ value = $1.scan(/../).map {
42
+ |i| i.to_i(16)/15.0
43
+ }
44
+ else
45
+ value = str.split(/\s*,\s*/).map do |s|
46
+ s.to_f
47
+ end
48
+ end
49
+ if value.size != 3
50
+ raise IncorrectInput, "You need exactly three values to make up a color"
51
+ end
52
+ return value
53
+ end
54
+ end
55
+
56
+ # A line style for Tioga. It will be represented as:
57
+ #
58
+ # a,b,c,d,...:e
59
+ #
60
+ # This creates a line style of:
61
+ #
62
+ # [[a,b,c,d,...],e]
63
+ #
64
+ # If the :e is omitted 0 is used.
65
+ class LineStyleType < Type
66
+
67
+ type_name :tioga_line_style, 'line_style'
68
+
69
+ def string_to_type_internal(str)
70
+ specs = str.split(/\s*,\s*/)
71
+ if specs.last =~ /:(.*)$/
72
+ phase = $1.to_f
73
+ specs.last.gsub!(/:.*$/,'')
74
+ else
75
+ phase = 0
76
+ end
77
+ p specs
78
+ return [ specs.map { |s| s.to_f }, phase]
79
+ end
80
+ end
81
+
82
+ # A marker Type for Tioga. Input as
83
+ #
84
+ # a,b(,c)?
85
+ #
86
+ class MarkerType < Type
87
+
88
+ type_name :tioga_marker, 'marker'
89
+
90
+ def string_to_type_internal(str)
91
+ specs = str.split(/\s*,\s*/)
92
+ if specs.size == 2
93
+ return [specs[0].to_i, specs[1].to_i]
94
+ elsif specs.size == 3
95
+ return [specs[0].to_i, specs[1].to_i, specs[2].to_f]
96
+ else
97
+ raise IncorrectInput, "You need two or three values to make a marker"
98
+ end
99
+ end
100
+ end
101
+
102
+ # The type of edges/axis
103
+ class AxisType < Type
104
+
105
+ include Tioga::FigureConstants
106
+
107
+ ValidTypes = {
108
+ /hidden|off/i => AXIS_HIDDEN,
109
+ /line/i => AXIS_LINE_ONLY,
110
+ /ticks/i => AXIS_WITH_TICKS_ONLY,
111
+ /major/i => AXIS_WITH_MAJOR_TICKS_ONLY,
112
+ /major-num/i => AXIS_WITH_MAJOR_TICKS_AND_NUMERIC_LABELS,
113
+ /full/i => AXIS_WITH_TICKS_AND_NUMERIC_LABELS
114
+ }
115
+
116
+ type_name :tioga_axis_type, 'axis_type'
117
+
118
+ def string_to_type_internal(str)
119
+ for k,v in ValidTypes
120
+ if str =~ /^\s*#{k}\s*/
121
+ return v
122
+ end
123
+ end
124
+ raise IncorrectInput, "Not an axis type: #{str}"
125
+ end
126
+ end
127
+
128
+ # Justification (horizontal alignement)
129
+ class JustificationType < Type
130
+
131
+ include Tioga::FigureConstants
132
+
133
+ ValidTypes = {
134
+ /l(eft)?/i => LEFT_JUSTIFIED,
135
+ /c(enter)?/i => CENTERED,
136
+ /r(ight)?/ => RIGHT_JUSTIFIED
137
+ }
138
+
139
+ type_name :tioga_justification, 'halign'
140
+
141
+ def string_to_type_internal(str)
142
+ for k,v in ValidTypes
143
+ if str =~ /^\s*#{k}\s*/
144
+ return v
145
+ end
146
+ end
147
+ raise IncorrectInput, "Not a justification: #{str}"
148
+ end
149
+ end
150
+
151
+ # Vertical alignement
152
+ class AlignmentType < Type
153
+
154
+ include Tioga::FigureConstants
155
+
156
+ type_name :tioga_align, 'valign'
157
+
158
+ ValidTypes = {
159
+ /t(op)?/i => ALIGNED_AT_TOP,
160
+ /c(enter)|m(idheight)/i => ALIGNED_AT_MIDHEIGHT,
161
+ /B|Baseline|baseline/ => ALIGNED_AT_BASELINE,
162
+ /b(ottom)?/ => ALIGNED_AT_BOTTOM
163
+ }
164
+
165
+
166
+ def string_to_type_internal(str)
167
+ for k,v in ValidTypes
168
+ if str =~ /^\s*#{k}\s*/
169
+ return v
170
+ end
171
+ end
172
+ raise IncorrectInput, "Not a vertical alignment: #{str}"
173
+ end
174
+ end
175
+
176
+ end
177
+ end
178
+ end