ctioga2 0.3 → 0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. data/Changelog +18 -0
  2. data/lib/ctioga2/commands/arguments.rb +17 -2
  3. data/lib/ctioga2/commands/commands.rb +13 -5
  4. data/lib/ctioga2/commands/context.rb +53 -0
  5. data/lib/ctioga2/commands/doc/doc.rb +1 -1
  6. data/lib/ctioga2/commands/doc/documentation-commands.rb +1 -1
  7. data/lib/ctioga2/commands/doc/help.rb +1 -1
  8. data/lib/ctioga2/commands/doc/html.rb +1 -1
  9. data/lib/ctioga2/commands/doc/introspection.rb +16 -1
  10. data/lib/ctioga2/commands/doc/man.rb +1 -1
  11. data/lib/ctioga2/commands/doc/markup.rb +1 -1
  12. data/lib/ctioga2/commands/doc/wordwrap.rb +1 -1
  13. data/lib/ctioga2/commands/general-commands.rb +1 -1
  14. data/lib/ctioga2/commands/general-types.rb +1 -1
  15. data/lib/ctioga2/commands/groups.rb +1 -1
  16. data/lib/ctioga2/commands/interpreter.rb +22 -1
  17. data/lib/ctioga2/commands/parsers/command-line.rb +8 -1
  18. data/lib/ctioga2/commands/parsers/file.rb +2 -1
  19. data/lib/ctioga2/commands/strings.rb +1 -1
  20. data/lib/ctioga2/commands/type.rb +1 -1
  21. data/lib/ctioga2/commands/variables.rb +1 -1
  22. data/lib/ctioga2/data/backends/backend.rb +1 -1
  23. data/lib/ctioga2/data/backends/backends/gnuplot.rb +1 -1
  24. data/lib/ctioga2/data/backends/backends/math.rb +1 -1
  25. data/lib/ctioga2/data/backends/backends/text.rb +12 -2
  26. data/lib/ctioga2/data/backends/description.rb +1 -1
  27. data/lib/ctioga2/data/backends/factory.rb +1 -1
  28. data/lib/ctioga2/data/backends/parameter.rb +1 -1
  29. data/lib/ctioga2/data/datacolumn.rb +1 -1
  30. data/lib/ctioga2/data/dataset.rb +1 -1
  31. data/lib/ctioga2/data/filters.rb +1 -1
  32. data/lib/ctioga2/data/indexed-dtable.rb +1 -1
  33. data/lib/ctioga2/data/point.rb +1 -1
  34. data/lib/ctioga2/data/stack.rb +6 -6
  35. data/lib/ctioga2/graphics/coordinates.rb +1 -1
  36. data/lib/ctioga2/graphics/elements.rb +1 -1
  37. data/lib/ctioga2/graphics/elements/containers.rb +1 -1
  38. data/lib/ctioga2/graphics/elements/contour.rb +1 -1
  39. data/lib/ctioga2/graphics/elements/curve2d.rb +1 -1
  40. data/lib/ctioga2/graphics/elements/element.rb +1 -1
  41. data/lib/ctioga2/graphics/elements/gradient-region.rb +1 -1
  42. data/lib/ctioga2/graphics/elements/parametric2d.rb +1 -1
  43. data/lib/ctioga2/graphics/elements/primitive.rb +115 -69
  44. data/lib/ctioga2/graphics/elements/region.rb +1 -1
  45. data/lib/ctioga2/graphics/elements/subplot.rb +9 -3
  46. data/lib/ctioga2/graphics/elements/tangent.rb +1 -1
  47. data/lib/ctioga2/graphics/elements/xyz-map.rb +1 -1
  48. data/lib/ctioga2/graphics/generator.rb +1 -1
  49. data/lib/ctioga2/graphics/legends.rb +5 -7
  50. data/lib/ctioga2/graphics/legends/area.rb +8 -8
  51. data/lib/ctioga2/graphics/legends/items.rb +2 -2
  52. data/lib/ctioga2/graphics/legends/provider.rb +1 -1
  53. data/lib/ctioga2/graphics/legends/storage.rb +1 -1
  54. data/lib/ctioga2/graphics/root.rb +1 -1
  55. data/lib/ctioga2/graphics/styles.rb +5 -0
  56. data/lib/ctioga2/graphics/styles/arrows.rb +53 -0
  57. data/lib/ctioga2/graphics/styles/axes.rb +29 -23
  58. data/lib/ctioga2/graphics/styles/background.rb +12 -10
  59. data/lib/ctioga2/graphics/styles/base.rb +99 -5
  60. data/lib/ctioga2/graphics/styles/box.rb +67 -0
  61. data/lib/ctioga2/graphics/styles/carrays.rb +1 -1
  62. data/lib/ctioga2/graphics/styles/colormap.rb +1 -1
  63. data/lib/ctioga2/graphics/styles/curve.rb +7 -1
  64. data/lib/ctioga2/graphics/styles/drawable.rb +24 -11
  65. data/lib/ctioga2/graphics/styles/errorbar.rb +1 -1
  66. data/lib/ctioga2/graphics/styles/factory.rb +1 -1
  67. data/lib/ctioga2/graphics/styles/gradients.rb +3 -3
  68. data/lib/ctioga2/graphics/styles/legend.rb +20 -5
  69. data/lib/ctioga2/graphics/styles/location.rb +3 -3
  70. data/lib/ctioga2/graphics/styles/map-axes.rb +6 -7
  71. data/lib/ctioga2/graphics/styles/plot.rb +51 -26
  72. data/lib/ctioga2/graphics/styles/sets.rb +1 -1
  73. data/lib/ctioga2/graphics/styles/sheet.rb +348 -0
  74. data/lib/ctioga2/graphics/styles/texts.rb +45 -64
  75. data/lib/ctioga2/graphics/subplot-commands.rb +1 -1
  76. data/lib/ctioga2/graphics/types.rb +1 -3
  77. data/lib/ctioga2/graphics/types/bijection.rb +1 -1
  78. data/lib/ctioga2/graphics/types/boundaries.rb +1 -1
  79. data/lib/ctioga2/graphics/types/boxes.rb +1 -1
  80. data/lib/ctioga2/graphics/types/dimensions.rb +2 -2
  81. data/lib/ctioga2/graphics/types/grid.rb +1 -1
  82. data/lib/ctioga2/graphics/types/location.rb +2 -2
  83. data/lib/ctioga2/graphics/types/point.rb +1 -1
  84. data/lib/ctioga2/log.rb +10 -6
  85. data/lib/ctioga2/metabuilder/type.rb +1 -1
  86. data/lib/ctioga2/metabuilder/types/coordinates.rb +1 -1
  87. data/lib/ctioga2/metabuilder/types/data.rb +1 -1
  88. data/lib/ctioga2/metabuilder/types/dates.rb +1 -1
  89. data/lib/ctioga2/metabuilder/types/lists.rb +1 -1
  90. data/lib/ctioga2/metabuilder/types/numbers.rb +1 -1
  91. data/lib/ctioga2/metabuilder/types/strings.rb +1 -1
  92. data/lib/ctioga2/metabuilder/types/styles.rb +30 -3
  93. data/lib/ctioga2/plotmaker.rb +1 -1
  94. data/lib/ctioga2/postprocess.rb +1 -1
  95. data/lib/ctioga2/utils.rb +78 -3
  96. metadata +6 -5
  97. data/lib/ctioga2/git-fools-svn.rb +0 -7
  98. data/lib/ctioga2/graphics/elements/redirecting-container.rb~ +0 -123
  99. data/lib/ctioga2/metabuilder/types/generic.rb~ +0 -225
@@ -17,7 +17,7 @@ require 'ctioga2/log'
17
17
  # This module contains all the classes used by ctioga
18
18
  module CTioga2
19
19
 
20
- Version::register_svn_info('$Revision$', '$Date$')
20
+ Version::register_svn_info('$Revision: 161 $', '$Date: 2010-08-03 12:07:49 +0200 (Tue, 03 Aug 2010) $')
21
21
 
22
22
  module Graphics
23
23
 
@@ -0,0 +1,348 @@
1
+ # sheet.rb: handling of style sheets
2
+ # copyright (c) 2012 by 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 (in the COPYING file).
13
+
14
+ require 'ctioga2/utils'
15
+ require 'ctioga2/log'
16
+
17
+ require 'ctioga2/graphics/coordinates'
18
+
19
+ # This module contains all the classes used by ctioga
20
+ module CTioga2
21
+
22
+ Version::register_svn_info('$Revision$', '$Date$')
23
+
24
+ module Graphics
25
+
26
+ module Styles
27
+
28
+ # This is a style sheet, is a storage place for style
29
+ # objects. It has two related functions:
30
+ # * first, store the user-specified preferences
31
+ # * second, provide the appropriate default style for any given
32
+ # object, most probably at construction time (although that
33
+ # may get hard some times)
34
+ #
35
+ # The style are cascading and scoped. A scope should begin in
36
+ # each plot.
37
+ #
38
+ # Cascades happen in two ways:
39
+ #
40
+ # * more specific styles inherit from less specific (axis ->
41
+ # yaxis -> left)
42
+ # * children style inherit from parent style
43
+ class StyleSheet
44
+
45
+ # The parent of the style sheet, or nil if this is the top one.
46
+ attr_accessor :parent
47
+
48
+ # The styles, in form of a style class -> style name -> style
49
+ # object nested hash
50
+ #
51
+ # The style object is actually a hash ready to be fed to the
52
+ # BasicStyle#set_from_hash
53
+ attr_accessor :own_styles
54
+
55
+ def initialize(par = nil)
56
+ @parent = par
57
+ @own_styles = {}
58
+ end
59
+
60
+ # This hash contains the parent style for each of the style
61
+ # listed in
62
+ #
63
+ # Keyed by class -> style name -> parent name
64
+ @style_parent = {}
65
+
66
+ # Sets the parent for the given style
67
+ def self.set_parent(cls, style, parent)
68
+ @style_parent[cls] ||= {}
69
+ @style_parent[cls][style] = parent
70
+ end
71
+
72
+ # Returns the parent style for the style (or _nil_ should the
73
+ # style have no parent)
74
+ #
75
+ # All styles (but base) derive from the corresponding "base"
76
+ # style.
77
+ def self.get_parent(cls, style)
78
+ @style_parent[cls] ||= {}
79
+ stl = @style_parent[cls][style]
80
+ if (! stl) and (! (style == 'base'))
81
+ return 'base'
82
+ end
83
+ return stl
84
+ end
85
+
86
+ set_parent AxisStyle, "x", "base"
87
+ set_parent AxisStyle, "y", "base"
88
+
89
+ set_parent AxisStyle, "bottom", "x"
90
+ set_parent AxisStyle, "top", "x"
91
+ set_parent AxisStyle, "left", "y"
92
+ set_parent AxisStyle, "right", "y"
93
+
94
+
95
+ # This returns the style we have in this object for the given
96
+ # name. Inner cascading should take place (ie object
97
+ # hierarchy, but not scope hierarchy).
98
+ #
99
+ # This returns a hash that can be modified.
100
+ def own_style_hash_for(cls, name)
101
+ p = self.class.get_parent(cls, name)
102
+ base = {}
103
+ if p
104
+ base = own_style_hash_for(cls, p)
105
+ end
106
+ @own_styles[cls] ||= {}
107
+ style = @own_styles[cls][name]
108
+ if ! style
109
+ return base
110
+ end
111
+ style = style.dup
112
+ style.merge!(base) { |key, v1, v2| v1 }
113
+ return style
114
+ end
115
+
116
+ # The style for the given name, including all cascading
117
+ def get_style_hash_for(cls, name)
118
+ ps = {}
119
+ if @parent
120
+ ps = @parent.get_style_hash_for(cls, name);
121
+ end
122
+ style = own_style_hash_for(cls, name)
123
+ style.merge!(ps) { |key, v1, v2| v1 }
124
+ return style
125
+ end
126
+
127
+
128
+
129
+ # The current sheet
130
+ @sheet = StyleSheet.new
131
+
132
+ # Returns a suitable style object for the given style name, or
133
+ # crashes if the name isn't known.
134
+ #
135
+ # Additional arguments are passed to the constructor
136
+ def self.style_for(cls, name, *args)
137
+ a = cls.new(*args)
138
+ a.set_from_hash(@sheet.get_style_hash_for(cls, name))
139
+ return a
140
+ end
141
+
142
+ def self.enter_scope()
143
+ @sheet = StyleSheet.new(@sheet)
144
+ end
145
+
146
+ def self.leave_scope()
147
+ if @sheet.parent
148
+ @sheet = @sheet.parent
149
+ else
150
+ warn { "Trying to leave top-level stylesheet scope" }
151
+ end
152
+ end
153
+
154
+ def self.current_sheet()
155
+ return @sheet
156
+ end
157
+
158
+ end
159
+
160
+ StyleSheetGroup = CmdGroup.new('style-sheets',
161
+ "Default styles",
162
+ <<EOD, 40)
163
+ Commands for defining default styles.
164
+
165
+ All commands take the name of the style to redefine. Different styles
166
+ live in a different name space, so there is no risk naming an @axis@ and
167
+ a @text@ style with the same name. All styles for a given type inherit from
168
+ the style name @base@.
169
+
170
+ ctioga2 does not support changing a style after its use. It may
171
+ affect only the following objects or all the ones that were created
172
+ from the beginning, depending on the context. For safety, only define
173
+ style before issueing any graphics command.
174
+
175
+ ctioga2 may support at a later time loading style files, but that is
176
+ not the case for now.
177
+
178
+ EOD
179
+ # We create the commands programmatically
180
+ kinds = [
181
+ ['axis', AxisStyle, 'axis'],
182
+ ['background', BackgroundStyle, 'plot background'],
183
+ ['title', TextLabel, 'plot title'],
184
+ ['text', FullTextStyle, 'text'],
185
+ ['marker', MarkerStringStyle, 'marker'],
186
+ ['box', BoxStyle, 'boxes'],
187
+ ['arrow', ArrowStyle, 'arrows'],
188
+ ['line', StrokeStyle, 'lines']
189
+ ]
190
+
191
+ StyleSheetCommands = {}
192
+ StyleSheetPredefinedNames = {}
193
+
194
+ kinds.each do |k|
195
+ name, cls, desc = *k
196
+
197
+ StyleSheetCommands[name] =
198
+ Cmd.new("define-#{name}-style",nil,
199
+ "--define-#{name}-style",
200
+ [
201
+ CmdArg.new('text'),
202
+ ],
203
+ cls.options_hash
204
+ ) do |plotmaker, what, opts|
205
+ StyleSheet.current_sheet.own_styles[cls] ||= {}
206
+ StyleSheet.current_sheet.own_styles[cls][what] ||= {}
207
+ StyleSheet.current_sheet.own_styles[cls][what].merge!(opts)
208
+ end
209
+ StyleSheetCommands[name].
210
+ describe("Sets the default style for the given #{desc}.",
211
+ <<"EOH", StyleSheetGroup)
212
+ Sets the default style for the named #{desc}.
213
+ EOH
214
+ end
215
+
216
+ StyleSheetCommands['line'].long_description = <<EOD
217
+ Sets the default style for lines. All line styles descend from the
218
+ @base@ style. Use a style different than @base@ by passing its name as
219
+ the @/base-style@ option to the {command: draw-line} command.
220
+
221
+ Meaning of the style parameters:
222
+
223
+ * @color@: the color of the line, see {type: color}
224
+ * @style@: the line style, see {type: line-style}
225
+ * @width@: the line width (in points)
226
+
227
+ > --define-line-style base /color=Pink
228
+
229
+ makes all lines pink (unless overriden by the /color option to
230
+ {command: draw-line}), while
231
+
232
+ > --define-line-style line-pink /color=Pink
233
+
234
+ only affect those to which the /base-style=line-pink style option
235
+ was given.
236
+ EOD
237
+
238
+ StyleSheetCommands['arrow'].long_description = <<EOD
239
+ Sets the default style for arrows. All arrow styles descend from the
240
+ @base@ style. Use a style different than @base@ by passing its name as
241
+ the @/base-style@ option to the {command: draw-arrow} command.
242
+
243
+ Meaning of the style parameters:
244
+
245
+ * @color@, @style@ and @width@: same as in {command: define-line-style}
246
+ * @head_marker@, @tail_marker@: a {type: marker} to be used for the head
247
+ or for the tail
248
+ * @head_scale@, @tail_scale@: scale of the head or tail markers
249
+ * @head_angle@, @tail_angle@: rotate the head or the tail by that many
250
+ degrees
251
+ * @head_color@, @tail_color@: the {type: color} of the head or tail
252
+ EOD
253
+
254
+ StyleSheetCommands['box'].long_description = <<EOD
255
+ Sets the default style for boxes. All box styles descend from the
256
+ @base@ style. Use a style different than @base@ by passing its name as
257
+ the @/base-style@ option to the {command: draw-box} command.
258
+
259
+ Meaning of the style parameters:
260
+
261
+ * @color@, @style@ and @width@: same as in {command: define-line-style}
262
+ * @fill_color@: fill color for the box
263
+ * @fill_transparency@: the transparency for the fill, from 0 to 1
264
+ EOD
265
+
266
+ StyleSheetCommands['text'].long_description = <<EOD
267
+ Sets the default style for texts. All text styles descend from the
268
+ @base@ style. Use a style different than @base@ by passing its name as
269
+ the @/base-style@ option to the {command: draw-text} command.
270
+
271
+ Meaning of the style parameters:
272
+
273
+ * @alignment@: vertical alignment
274
+ * @justification@: horizontal alignment
275
+ * @angle@: angle in degrees to the horizontal (or default orientation in
276
+ some cases)
277
+ * @color@: text color
278
+ * @scale@: text scale
279
+ EOD
280
+
281
+ StyleSheetCommands['title'].long_description = <<EOD
282
+ Sets the style for title. All title styles descend from the
283
+ @base@ style. In addition, the title of a plot is addressed by the
284
+ style name @title@.
285
+
286
+ Meaning of the style parameters:
287
+
288
+ * @alignment@, @justification@, @angle@, @color@ and @scale@:
289
+ as in {command: define-text-style}
290
+ * @text@: sets the title text
291
+ * @loc@: the side on which to display the title, a {type: location}
292
+ * @shift@: the distance away from the plot in text size units
293
+ (maybe a dimension should be better later)
294
+ * @position@: shift from the center (parallel to the plot side)
295
+ EOD
296
+
297
+ StyleSheetCommands['marker'].long_description = <<EOD
298
+ Sets the style for marker and marker strings. All marker and marker
299
+ string styles descend from the @base@ style. Use a style different
300
+ than @base@ by passing its name as the @/base-style@ option to the
301
+ {command: draw-marker} or {command: draw-string-marker} commands.
302
+
303
+ Meaning of the style parameters:
304
+
305
+ * @alignment@, @justification@, @angle@, @color@ and @scale@:
306
+ as in {command: define-text-style}
307
+ * @fill_color@ and @stroke_color@: markers are both stroked and filled,
308
+ you can control all colors in one go using @color@ or specifying each
309
+ with @fill_color@ and @stroke_color@
310
+ * @font@: is a PDF font number (from 1 to 14), only used for marker
311
+ strings
312
+ * @horizontal_scale@, @vertical_scale@: scales the marker only
313
+ horizontally or vertically
314
+ EOD
315
+
316
+ StyleSheetCommands['background'].long_description = <<EOD
317
+ Sets the style for plot background. All background styles descend from the
318
+ @base@ style. In addition, the background of a plot is change by the
319
+ style name @background@.
320
+
321
+ Meaning of the style parameters:
322
+
323
+ * @watermark@: the text of the watermark
324
+ * all @watermark_@ styles have the same meaning as in
325
+ {command: define-text-style}, as the watermark is a string marker
326
+ * @background_color@: the color of the background
327
+ EOD
328
+
329
+ StyleSheetCommands['axis'].long_description = <<EOD
330
+ Sets the style for a whole axis. All axis styles descend from the
331
+ @base@ style. Horizontal and vertical axis styles descend from the
332
+ @x@ and @y@ styles, and plot sides are styled with the @left@, @right@,
333
+ @top@ and @bottom@ styles.
334
+
335
+ Axis styles have lots of parameters:
336
+
337
+ * @axis_label_@ and @tick_label_@ parameters are title style parameters
338
+ whose meaning is given in {command: define-title-style}, that affect
339
+ ticks and axis labels
340
+ * @decoration@: a {type: axis-decoration} that specify which ticks and
341
+ tick labels to draw
342
+ * @background_lines_@ parameters define the style of background lines,
343
+ as in {command: define-line-style}
344
+ EOD
345
+
346
+ end
347
+ end
348
+ end
@@ -17,7 +17,7 @@ require 'ctioga2/log'
17
17
  # This module contains all the classes used by ctioga
18
18
  module CTioga2
19
19
 
20
- Version::register_svn_info('$Revision$', '$Date$')
20
+ Version::register_svn_info('$Revision: 370 $', '$Date: 2012-12-28 17:40:18 +0100 (Fri, 28 Dec 2012) $')
21
21
 
22
22
  module Graphics
23
23
 
@@ -26,31 +26,36 @@ module CTioga2
26
26
  # The style of a text object. This class is suitable for
27
27
  # inclusion as a Hash to FigureMaker#show_axis, for the tick
28
28
  # labels.
29
+ #
30
+ # @todo alignement and justification are poor names. halign
31
+ # and/or valign would be better.
29
32
  class BaseTextStyle < BasicStyle
30
33
 
31
34
  # The angle of the text
32
- attr_accessor :angle
35
+ typed_attribute :angle, 'float'
33
36
 
34
37
  # The 'shift' of the text. Only meaningful for axes and tick
35
38
  # labels, where the position of the text is specified using a
36
- # side rather than a precise position
37
- attr_accessor :shift
39
+ # side rather than a precise position. In frame coordinates ?
40
+ typed_attribute :shift, 'float'
38
41
 
39
42
  # The scale of the text
40
- attr_accessor :scale
43
+ typed_attribute :scale, 'float'
41
44
 
42
45
  # The vertical alignment
43
- attr_accessor :alignement
46
+ typed_attribute :alignment, 'alignment'
44
47
 
45
48
  # The horizontal alignment
46
- attr_accessor :justification
49
+ typed_attribute :justification, 'justification'
47
50
 
48
51
  # Draw the _text_ at the given location with the given style.
49
52
  # If _y_ is _nil_, then _x_or_loc_ is taken to be a location
50
53
  # (see FigureMaker#show_text).
51
54
  def draw_text(t, text, x_or_loc, y = nil, measure = nil)
52
- dict = prepare_show_text_dict(text, x_or_loc, y, measure)
53
- t.show_text(dict)
55
+ t.context do
56
+ dict = prepare_show_text_dict(text, x_or_loc, y, measure)
57
+ t.show_text(dict)
58
+ end
54
59
  end
55
60
 
56
61
  protected
@@ -83,38 +88,35 @@ module CTioga2
83
88
  # The style of a full text object.
84
89
  class FullTextStyle < BaseTextStyle
85
90
  # The color of the text
86
- attr_accessor :color
91
+ typed_attribute :color, 'color'
87
92
 
88
93
  # The (horizontal) position with respect to a location. You'll
89
94
  # seldom need that.
90
- attr_accessor :position
95
+ #
96
+ # @todo Maybe this needs to fo in TextLabel rather than here ?
97
+ typed_attribute :position, 'float'
91
98
  end
92
99
 
93
100
  # A hash that can be used as a base for optional arguments to
94
101
  # things that take texts.
95
- FullTextStyleOptions = {
96
- 'angle' => CmdArg.new('float'),
97
- 'shift' => CmdArg.new('float'),
98
- 'scale' => CmdArg.new('float'),
99
- 'justification' => CmdArg.new('justification'),
100
- 'color' => CmdArg.new('color'),
101
- 'align' => CmdArg.new('alignment'),
102
- }
102
+ FullTextStyleOptions = FullTextStyle.options_hash()
103
103
 
104
104
  # A label.
105
105
  class TextLabel < FullTextStyle
106
106
  # The text of the label. _nil_ or _false_ means there will be
107
107
  # no text displayed
108
- attr_accessor :text
108
+ typed_attribute :text, "text"
109
109
 
110
110
  # The location of the label.
111
111
  #
112
112
  # @todo This will have to eventually use PlotLocation, as it
113
113
  # makes much more sense.
114
- attr_accessor :loc
114
+ typed_attribute :loc, "location"
115
115
 
116
- def initialize(text = nil)
116
+ def initialize(text = nil, loc = nil)
117
+ super()
117
118
  @text = text
119
+ @loc = loc
118
120
  end
119
121
 
120
122
  # Draw the label, if #text is not _nil_ or _false_.
@@ -159,10 +161,8 @@ module CTioga2
159
161
 
160
162
  end
161
163
 
162
- # Same thing as FullTextStyleOptions, but also permits to
163
- # override the #text part of the whole stuff..
164
- FullTextLabelOptions = FullTextStyleOptions.dup
165
- FullTextLabelOptions['text'] = CmdArg.new('text')
164
+
165
+ FullTextLabelOptions = TextLabel.options_hash()
166
166
 
167
167
 
168
168
 
@@ -171,44 +171,32 @@ module CTioga2
171
171
  # like that.
172
172
  class MarkerStringStyle < BasicStyle
173
173
 
174
- MarkerOptions = {
175
- 'color' => 'color',
176
- 'stroke_color' => 'color',
177
- 'fill_color' => 'color',
178
- 'scale' => 'float',
179
- 'horizontal_scale' => 'float',
180
- 'vertical_scale' => 'float',
181
- 'angle' => 'float',
182
- 'justification' => 'justification',
183
- 'alignment' => 'alignment',
184
- }
185
-
186
-
187
174
  # The angle of the text
188
- attr_accessor :angle
175
+ typed_attribute :angle, 'float'
189
176
 
190
177
  # The scale of the text
191
- attr_accessor :scale
178
+ typed_attribute :scale, "float"
192
179
 
193
180
  # The horizontal scale of the text
194
- attr_accessor :horizontal_scale
181
+ typed_attribute :horizontal_scale, "float"
195
182
 
196
183
  # The vertical scale of the text
197
- attr_accessor :vertical_scale
184
+ typed_attribute :vertical_scale, "float"
198
185
 
199
186
  # The vertical alignment
200
- attr_accessor :alignement
187
+ typed_attribute :alignment, "alignment"
201
188
 
202
189
  # The horizontal alignment
203
- attr_accessor :justification
190
+ typed_attribute :justification, "justification"
204
191
 
205
192
  # Colors
206
- attr_accessor :color
207
- attr_accessor :stroke_color
208
- attr_accessor :fill_color
193
+ typed_attribute :color, 'color-or-false'
194
+ typed_attribute :stroke_color, 'color-or-false'
195
+ typed_attribute :fill_color, 'color-or-false'
196
+
209
197
 
210
198
  # A number between 1 to 14 -- a PDF font
211
- attr_accessor :font
199
+ typed_attribute :font, "pdf-font"
212
200
 
213
201
  # The rendering mode.
214
202
  attr_accessor :mode
@@ -226,8 +214,14 @@ module CTioga2
226
214
  dict = self.to_hash
227
215
  dict['text'] = text
228
216
  dict['at'] = [x, y]
229
- # TODO !
230
- dict['mode'] =
217
+ t.show_marker(dict)
218
+ end
219
+
220
+ # Draws the string marker at the given location
221
+ def draw_marker(t, marker, x, y)
222
+ dict = self.to_hash
223
+ dict['marker'] = marker
224
+ dict['at'] = [x, y]
231
225
  t.show_marker(dict)
232
226
  end
233
227
 
@@ -237,19 +231,6 @@ module CTioga2
237
231
  end
238
232
  end
239
233
 
240
- StringMarkerOptions = {
241
- 'color' => CmdArg.new('color'),
242
- 'stroke_color' => CmdArg.new('color'),
243
- 'fill_color' => CmdArg.new('color'),
244
- 'scale' => CmdArg.new('float'),
245
- 'horizontal_scale' => CmdArg.new('float'),
246
- 'vertical_scale' => CmdArg.new('float'),
247
- 'angle' => CmdArg.new('float'),
248
- 'justification' => CmdArg.new('justification'),
249
- 'alignment' => CmdArg.new('alignment'),
250
- 'font' => CmdArg.new('pdf-font')
251
- }
252
-
253
234
  # A LaTeX font. It should be applied to text using the function
254
235
  # #fontify.
255
236
  #