dyi 1.1.1 → 1.1.2

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.
Files changed (48) hide show
  1. data/CHANGES +7 -1
  2. data/lib/dyi.rb +3 -1
  3. data/lib/dyi/animation.rb +5 -4
  4. data/lib/dyi/canvas.rb +5 -8
  5. data/lib/dyi/chart.rb +1 -1
  6. data/lib/dyi/chart/array_reader.rb +104 -10
  7. data/lib/dyi/chart/axis_util.rb +31 -17
  8. data/lib/dyi/chart/base.rb +104 -7
  9. data/lib/dyi/chart/csv_reader.rb +56 -8
  10. data/lib/dyi/chart/excel_reader.rb +27 -4
  11. data/lib/dyi/chart/legend.rb +10 -8
  12. data/lib/dyi/chart/line_chart.rb +29 -25
  13. data/lib/dyi/chart/pie_chart.rb +192 -29
  14. data/lib/dyi/chart/table.rb +12 -10
  15. data/lib/dyi/color.rb +9 -7
  16. data/lib/dyi/coordinate.rb +177 -61
  17. data/lib/dyi/drawing.rb +1 -1
  18. data/lib/dyi/drawing/clipping.rb +9 -3
  19. data/lib/dyi/drawing/color_effect.rb +7 -4
  20. data/lib/dyi/drawing/filter.rb +10 -7
  21. data/lib/dyi/drawing/pen.rb +421 -11
  22. data/lib/dyi/drawing/pen_3d.rb +12 -7
  23. data/lib/dyi/element.rb +5 -4
  24. data/lib/dyi/event.rb +3 -3
  25. data/lib/dyi/font.rb +6 -4
  26. data/lib/dyi/formatter.rb +1 -1
  27. data/lib/dyi/formatter/base.rb +24 -15
  28. data/lib/dyi/formatter/emf_formatter.rb +6 -5
  29. data/lib/dyi/formatter/eps_formatter.rb +15 -14
  30. data/lib/dyi/formatter/svg_formatter.rb +16 -14
  31. data/lib/dyi/formatter/svg_reader.rb +4 -3
  32. data/lib/dyi/formatter/xaml_formatter.rb +9 -7
  33. data/lib/dyi/length.rb +213 -114
  34. data/lib/dyi/matrix.rb +4 -2
  35. data/lib/dyi/painting.rb +161 -87
  36. data/lib/dyi/script.rb +1 -1
  37. data/lib/dyi/script/ecmascript.rb +18 -29
  38. data/lib/dyi/script/simple_script.rb +4 -8
  39. data/lib/dyi/shape.rb +1 -1
  40. data/lib/dyi/shape/base.rb +8 -17
  41. data/lib/dyi/shape/path.rb +102 -19
  42. data/lib/dyi/stylesheet.rb +4 -3
  43. data/lib/dyi/svg_element.rb +9 -7
  44. data/lib/dyi/type.rb +5 -2
  45. data/lib/dyi/util.rb +36 -1
  46. data/lib/ironruby.rb +1 -1
  47. data/lib/util.rb +53 -5
  48. metadata +4 -19
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: UTF-8 -*-
2
2
 
3
- # Copyright (c) 2009-2011 Sound-F Co., Ltd. All rights reserved.
3
+ # Copyright (c) 2009-2012 Sound-F Co., Ltd. All rights reserved.
4
4
  #
5
5
  # Author:: Mamoru Yuo
6
6
  #
@@ -19,8 +19,10 @@
19
19
  # You should have received a copy of the GNU General Public License
20
20
  # along with DYI. If not, see <http://www.gnu.org/licenses/>.
21
21
 
22
- module DYI #:nodoc:
22
+ #
23
+ module DYI
23
24
 
25
+ # @since 1.0.0
24
26
  class Matrix
25
27
  attr_accessor :xx, :yx, :xy, :yy, :x0, :y0
26
28
 
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: UTF-8 -*-
2
2
 
3
- # Copyright (c) 2009-2011 Sound-F Co., Ltd. All rights reserved.
3
+ # Copyright (c) 2009-2012 Sound-F Co., Ltd. All rights reserved.
4
4
  #
5
5
  # Author:: Mamoru Yuo
6
6
  #
@@ -19,60 +19,127 @@
19
19
  # You should have received a copy of the GNU General Public License
20
20
  # along with DYI. If not, see <http://www.gnu.org/licenses/>.
21
21
 
22
- module DYI #:nodoc:
22
+ #
23
+ module DYI
23
24
 
25
+ # +Painting+ is used to specify how the drawing of the interior and the
26
+ # outline of the shape. {Shape::Base} objects (or objects of its subclass)
27
+ # have +painting+ attribute whose value is instance of this class.
28
+ # @since 0.0.0
24
29
  class Painting
25
- IMPLEMENT_ATTRIBUTES = [:opacity,:fill,:fill_opacity,:fill_rule,:stroke,:stroke_dasharray,:stroke_dashoffset,:stroke_linecap,:stroke_linejoin,:stroke_miterlimit,:stroke_opacity,:stroke_width,:display,:visibility]
26
- VALID_VALUES = {
27
- :fill_rule => ['nonzero','evenodd'],
28
- :stroke_linecap => ['butt','round','square'],
29
- :stroke_linejoin => ['miter','round','bevel'],
30
- :display => ['block','none'],
31
- :visibility => ['visible','hidden']
32
- }
33
-
34
- ##
35
- # :method: fill
36
-
37
- ##
38
- # :method: fill_opacity
39
-
40
- ##
41
- # :method: fill_rule
42
-
43
- ##
44
- # :method: stroke
45
-
46
- ##
47
- # :method: stroke_dasharray
48
-
49
- ##
50
- # :method: stroke_dashoffset
51
-
52
- ##
53
- # :method: stroke_linecap
54
30
 
55
- ##
56
- # :method: stroke_linejoin
57
-
58
- ##
59
- # :method: stroke_miterlimit
60
-
61
- ##
62
- # :method: stroke_opacity
63
-
64
- ##
65
- # :method: stroke_width
66
-
67
- ##
68
- # :method: display
69
-
70
- ##
71
- # :method: visibility
72
-
73
- ##
31
+ # @private
32
+ IMPLEMENT_ATTRIBUTES = [:opacity, :fill, :fill_opacity, :fill_rule,
33
+ :stroke, :stroke_dasharray, :stroke_dashoffset,
34
+ :stroke_linecap, :stroke_linejoin, :stroke_miterlimit,
35
+ :stroke_opacity, :stroke_width,
36
+ :display, :visibility]
37
+ # @private
38
+ VALID_VALUES = {:fill_rule => ['nonzero','evenodd'],
39
+ :stroke_linecap => ['butt','round','square'],
40
+ :stroke_linejoin => ['miter','round','bevel'],
41
+ :display => ['block','none'],
42
+ :visibility => ['visible','hidden']}
43
+
44
+ # @attribute opacity
45
+ # Returns or sets opacity of the paiting operation. Opacity of Both +stroke+
46
+ # and +fill+ is set at the same time by this attribute.
47
+ # @return [Float] the value of attribute opacity
48
+ # @since 1.0.0
49
+ #+++
50
+ # @attribute fill
51
+ # Returns or sets the interior painting of the shape.
52
+ # @return [Color, #write_as] the value of attribute fill
53
+ #+++
54
+ # @attribute fill_opacity
55
+ # Returns or sets the opacity of the paiting operation used to paint the
56
+ # interior of the shape.
57
+ # @return [Float] the value of attribute fill_opacity
58
+ #+++
59
+ # @attribute fill_rule
60
+ # Returns or sets the rule which is to be used to detemine what parts of the
61
+ # canvas are included inside the shape. specifies one of the following
62
+ # values: <tt>"nonzero"</tt>, <tt>"evenodd"</tt>
63
+ # @return [String] the value of attribute fill_rule
64
+ #+++
65
+ # @attribute stroke
66
+ # Returns or sets the painting along the outline of the shape.
67
+ # @return [Color, #write_as] the value of attribute stroke
68
+ #+++
69
+ # @attribute stroke_dasharray
70
+ # Returns or sets the pattern of dashes and gaps used to stroke paths.
71
+ # @return [Array<Length>] the value of attribute stroke_dasharray
72
+ #+++
73
+ # @attribute stroke_dashoffset
74
+ # Returns or sets the distance into the dash pattern to start the dash.
75
+ # @return [Length] the value of attribute stroke_dashoffset
76
+ #+++
77
+ # @attribute stroke_linecap
78
+ # Returns or sets the shape to be used at the end of open subpaths when they
79
+ # are stroked. specifies one of the following values: <tt>"butt"</tt>,
80
+ # <tt>"round"</tt>, <tt>"square"</tt>
81
+ # @return [String] the value of attribute stroke_linecap
82
+ #+++
83
+ # @attribute stroke_linejoin
84
+ # Returns or sets the shape to be used at the corners of paths or basic
85
+ # shapes when they are stroked. specifies one of the following vlaues:
86
+ # <tt>"miter"</tt>, <tt>"round"</tt>, <tt>"bevel"</tt>
87
+ # @return [String] the value of attribute stroke_linejoin
88
+ #+++
89
+ # @attribute stroke_miterlimit
90
+ # Returns or sets the limit value on the ratio of the miter length to the
91
+ # value of +stroke_width+ attribute. When the ratio exceeds this attribute
92
+ # value, the join is converted from a _miter_ to a _bevel_.
93
+ # @return [Float] the value of attribute stroke_mitterlimit
94
+ #+++
95
+ # @attribute stroke_opacity
96
+ # Returns or sets the opacity of the painting operation used to stroke.
97
+ # @return [Float] the value of attribute stroke_opacity
98
+ #+++
99
+ # @attribute stroke_width
100
+ # Returns or sets the width of the stroke.
101
+ # @return [Length] the value of attribute stroke_width
102
+ #+++
103
+ # @attribute display
104
+ # Returns or sets whether the shape is displayed. specifies one of the
105
+ # following vlaues: <tt>"block"</tt>, <tt>"none"</tt>
106
+ # @return [String] the value of attribute display
107
+ #+++
108
+ # @attribute visibility
109
+ # Returns or sets whether the shape is hidden. specifies one of the
110
+ # following vlaues: <tt>"visible"</tt>, <tt>"hidden"</tt>
111
+ # @return [String] the value of attribute visibility
74
112
  attr_reader *IMPLEMENT_ATTRIBUTES
75
113
 
114
+ # Creates and returns a new instace of Paintng. If the argutment is a
115
+ # instance of Painting, returns a copy of the argument.
116
+ # @option options [String] :display the value of attribute {#display display};
117
+ # one of following values: <tt>"block"</tt>, <tt>"none"</tt>
118
+ # @option options [Color, #write_as] :fill the value of attribute {#fill fill}
119
+ # @option options [#to_f] :fill_opacity the value of attribute fill_opacity
120
+ # @option options [String] :fill_rule the value of attribute {#fill_rule
121
+ # fill_rule}; one of following values: <tt>"nonzero"</tt>, <tt>"evenodd"</tt>
122
+ # @option options [#to_f] :opacity the value of attribute {#opacity opacity}
123
+ # @option options [Color, #write_as] :stroke the value of attribute {#stroke
124
+ # stroke}
125
+ # @option options [Array<Length>, String] :stroke_dasharray the value of
126
+ # attribute {#stroke_dasharray stroke_dasharray}
127
+ # @option options [Length] :stroke_dashoffset the value of attribute
128
+ # {#stroke_dashoffset stroke_dashoffset}
129
+ # @option options [String] :stroke_linecap the value of attribute
130
+ # {#stroke_linecap stroke_linecap}; one of following values:
131
+ # <tt>"butt"</tt>, <tt>"round"</tt>, <tt>"square"</tt>
132
+ # @option options [String] :stroke_linejoin the value of attribute
133
+ # {#stroke_linejoin stroke_linejoin}; one of following values:
134
+ # <tt>"miter"</tt>, <tt>"round"</tt>, <tt>"bevel"</tt>
135
+ # @option options [#to_f] :stroke_miterlimit the value of attribute
136
+ # {#stroke_miterlimit stroke_miterlimit}
137
+ # @option options [#to_f] :stroke_opacity the value of attribute
138
+ # {#stroke_opacity stroke_opacity}
139
+ # @option options [Length] :stroke_width the value of attribute
140
+ # {#stroke_width stroke_width}
141
+ # @option options [String] :visible the value of attribute {#visibility
142
+ # visibility}; one of following values: <tt>"visible"</tt>, <tt>"hidden"</tt>
76
143
  def initialize(options={})
77
144
  case options
78
145
  when Painting
@@ -88,42 +155,20 @@ module DYI #:nodoc:
88
155
  end
89
156
  end
90
157
 
91
- ##
92
- # :method: fill_rule=
93
- #
94
- # :call-seq:
95
- # fill_rule= (value)
96
- #
97
-
98
- ##
99
- # :method: stroke_linecap=
100
- #
101
- # :call-seq:
102
- # stroke_linecap= (value)
103
- #
104
-
105
- ##
106
- # :method: stroke_linejoin=
107
- #
108
- # :call-seq:
109
- # stroke_linejoin= (value)
110
- #
111
-
112
- ##
113
- # :method: display=
114
- #
115
- # :call-seq:
116
- # display= (value)
117
- #
118
-
119
- ##
120
- # :method: visibility=
121
- #
122
- # :call-seq:
123
- # visibility= (value)
124
- #
125
-
126
- ##
158
+ # @attribute [w] fill_rule
159
+ # @param [String] value the value of attribute fill_rule
160
+ #+++
161
+ # @attribute [w] stroke_linecap
162
+ # @param [String] value the value of attribute stroke_linecap
163
+ #+++
164
+ # @attribute [w] stroke_linejoin
165
+ # @param [String] value the value of attribute stroke_linejoin
166
+ #+++
167
+ # @attribute [w] display
168
+ # @param [String] value the value of attribute display
169
+ #+++
170
+ # @attribute [w] visibility
171
+ # @param [String] value the value of attribute visibility
127
172
  VALID_VALUES.each do |attr, valid_values|
128
173
  define_method("#{attr.to_s}=") {|value|
129
174
  if (value = value.to_s).size == 0
@@ -135,35 +180,51 @@ module DYI #:nodoc:
135
180
  }
136
181
  end
137
182
 
183
+ # @attribute
184
+ # @param [Color, #write_as] color the value of attribute fill
138
185
  def fill=(color)
139
186
  @fill = color.respond_to?(:color?) && color.color? ? color : Color.new_or_nil(color)
140
187
  end
141
188
 
189
+ # @attribute
190
+ # @param [Color, #write_as] color the value of attribute stroke
142
191
  def stroke=(color)
143
192
  @stroke = color.respond_to?(:color?) && color.color? ? color : Color.new_or_nil(color)
144
193
  end
145
194
 
195
+ # @attribute
196
+ # @param [Float] opacity the value of attribute opacity
146
197
  # @since 1.0.0
147
198
  def opacity=(opacity)
148
199
  @opacity = opacity.nil? ? nil : opacity.to_f
149
200
  end
150
201
 
202
+ # @attribute
203
+ # @param [Float] opacity the value of attribute fill_opacity
151
204
  def fill_opacity=(opacity)
152
205
  @fill_opacity = opacity.nil? ? nil : opacity.to_f
153
206
  end
154
207
 
208
+ # @attribute
209
+ # @param [Float] opacity the value of attribute stroke_opacity
155
210
  def stroke_opacity=(opacity)
156
211
  @stroke_opacity = opacity.nil? ? nil : opacity.to_f
157
212
  end
158
213
 
214
+ # @attribute
215
+ # @param [Length] width the value of attribute stroke_width
159
216
  def stroke_width=(width)
160
217
  @stroke_width = Length.new_or_nil(width)
161
218
  end
162
219
 
220
+ # @attribute
221
+ # @param [Float] miterlimit the value of attribute stroke_miterlimit
163
222
  def stroke_miterlimit=(miterlimit)
164
223
  @stroke_miterlimit = miterlimit.nil? ? nil : [miterlimit.to_f, 1].max
165
224
  end
166
225
 
226
+ # @attribute
227
+ # @param [Array<Legth>, String] array the value of attribute stroke_dasharray
167
228
  def stroke_dasharray=(array)
168
229
  if (array.nil? || array.empty?)
169
230
  @stroke_dasharray = nil
@@ -174,20 +235,28 @@ module DYI #:nodoc:
174
235
  end
175
236
  end
176
237
 
238
+ # @attribute
239
+ # @param [Length] offset the value of attribute stroke_dashoffset
177
240
  def stroke_dashoffset=(offset)
178
241
  @stroke_dashoffset = Length.new_or_nil(offset)
179
242
  end
180
243
 
244
+ # Returns the hash of the attribute values. Even if the return value of this
245
+ # method is modified, the attribute value of the object is not modify.
246
+ # @return [Hash{Symbol => Object}] the copy of the attribute values
181
247
  def attributes
182
248
  IMPLEMENT_ATTRIBUTES.inject({}) do |hash, attr|
183
249
  value = instance_variable_get("@#{attr}")
184
250
  unless value.nil?
185
- hash[attr] = value # value.respond_to?(:join) ? value.join(',') : value.to_s
251
+ hash[attr] = value
186
252
  end
187
253
  hash
188
254
  end
189
255
  end
190
256
 
257
+ # Returns whether a value has been set some attribute in this object.
258
+ # @return [Boolean] true if a value has been set some attribute in this
259
+ # object, false otherwise
191
260
  def empty?
192
261
  IMPLEMENT_ATTRIBUTES.all? do |attr|
193
262
  not instance_variable_get("@#{attr}")
@@ -196,6 +265,11 @@ module DYI #:nodoc:
196
265
 
197
266
  class << self
198
267
 
268
+ # Returns a new instace of +Painting+ if the argments is not +nil+ (calls
269
+ # +Painting.new+ method), but returns +nil+ if the argument is +nil+.
270
+ # @return [Painting, nil] a new instace of Painting if the argments is not
271
+ # nil, nil otherwise
272
+ # @see #initialize
199
273
  def new_or_nil(*args)
200
274
  (args.size == 1 && args.first.nil?) ? nil : new(*args)
201
275
  end
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: UTF-8 -*-
2
2
 
3
- # Copyright (c) 2009-2011 Sound-F Co., Ltd. All rights reserved.
3
+ # Copyright (c) 2009-2012 Sound-F Co., Ltd. All rights reserved.
4
4
  #
5
5
  # Author:: Mamoru Yuo
6
6
  #
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: UTF-8 -*-
2
2
 
3
- # Copyright (c) 2009-2011 Sound-F Co., Ltd. All rights reserved.
3
+ # Copyright (c) 2009-2012 Sound-F Co., Ltd. All rights reserved.
4
4
  #
5
5
  # Author:: Mamoru Yuo
6
6
  #
@@ -18,25 +18,21 @@
18
18
  #
19
19
  # You should have received a copy of the GNU General Public License
20
20
  # along with DYI. If not, see <http://www.gnu.org/licenses/>.
21
- #
22
- # == Overview
23
- #
24
- # This file provides the classes of client side scripting. The script becomes
25
- # effective only when it is output by SVG format.
26
- #
27
- # @since 1.0.0
28
21
 
22
+ #
29
23
  module DYI
30
24
  module Script
25
+
31
26
  # Module for using ECMAScript. The script generated by this module comfirms
32
27
  # to ECMAScript 5.1 (Ecma International Standard ECMA-262).
28
+ # @since 1.0.0
33
29
  module EcmaScript
34
30
 
35
31
  # This Module includes helper methods for generating a client-script.
36
32
  # These methods generate a script that conforms to DOM Level 2 (W3C
37
33
  # Recommendation).
38
34
  #
39
- # All the methods defined by the module are `module functions', which are
35
+ # All the methods defined by the module are 'module functions', which are
40
36
  # called as private instance methods and are also called as public class
41
37
  # methods (they are methods of Math Module like).
42
38
  # In the following example, +get_element+ method is called as a
@@ -50,37 +46,22 @@ module DYI
50
46
  # At the toplevel, it is able to include the module.
51
47
  # include DYI::Script::EcmaScript::DomLevel2
52
48
  # puts get_element('el_id') # => "document.getElementById(\"el_id\")"
53
- # In the Next example, +get_element+ method is called as a public class
49
+ # In the next example, +get_element+ method is called as a public class
54
50
  # method.
55
51
  # puts DYI::Script::EcmaScript::DomLevel2.get_element('el_id')
56
52
  # # => "document.getElementById(\"el_id\")"
57
- #
58
- #= Module Function List
59
- #
60
- # {#add_event_listener}, {#draw_text_border}, {#form_legend_labels},
61
- # {#get_attribute}, {#get_element}, {#metadata_parse_json},
62
- # {#rewrite_text}, {#set_attribute}, {#to_ecmascript_string}
63
- #
64
- # {render:#add_event_listener}
65
- # {render:#dispatch_evnet}
66
- # {render:#draw_text_border}
67
- # {render:#form_legend_labels}
68
- # {render:#get_attribute}
69
- # {render:#get_element}
70
- # {render:#metadata_parse_json}
71
- # {render:#rewrite_text}
72
- # {render:#set_attribute}
73
- # {render:#to_ecmascript_string}
74
53
  module DomLevel2
75
54
 
76
55
  private
77
56
 
57
+ # @function
78
58
  def get_element(element)
79
59
  parts = []
80
60
  parts << 'document.getElementById("' << (element.respond_to?(:publish_id) ? element.id : element) << '")'
81
61
  parts.join
82
62
  end
83
63
 
64
+ # @function
84
65
  def add_event_listener(event, listener)
85
66
  parts = []
86
67
  parts << get_element(event.target)
@@ -91,6 +72,7 @@ module DYI
91
72
  parts.join
92
73
  end
93
74
 
75
+ # @function
94
76
  def dispatch_evnet(event)
95
77
  parts = []
96
78
  parts << get_element(event.target)
@@ -100,8 +82,8 @@ module DYI
100
82
 
101
83
  # Returns an ECMAScript value of a metadata that this image has.
102
84
  # @return [String] a string that means
85
+ # @function
103
86
  # @since 1.1.1
104
- # @api function
105
87
  def metadata_parse_json
106
88
  =begin
107
89
  script =<<-EOS
@@ -130,10 +112,12 @@ EOS
130
112
  # element
131
113
  # @param [String|Symbol] attribute_name the name of attribute
132
114
  # @return [String] ECMAScript string
115
+ # @function
133
116
  # @example
134
117
  # rect = pen.draw_rectange(canvas, [0, 0], 20, 30, :id => "rect1")
135
118
  # get_attribute(rect, "width")
136
119
  # # => "document.getElementById(\"rect1\").getAttribute(\"width\")"
120
+ # @function
137
121
  # @since 1.1.0
138
122
  def get_attribute(element, attribute_name)
139
123
  "#{get_element(element)}.getAttribute(\"#{attribute_name}\")"
@@ -147,8 +131,9 @@ EOS
147
131
  # @return [String] ECMAScript string
148
132
  # @example
149
133
  # rect = pen.draw_rectange(canvas, [0, 0], 20, 30, :id => "rect1")
150
- # get_attribute(rect, "width", 50)
134
+ # set_attribute(rect, "width", 50)
151
135
  # # => "document.getElementById(\"rect1\").setAttribute(\"x\",\"50\")"
136
+ # @function
152
137
  # @since 1.1.0
153
138
  def set_attribute(element, attribute_name, value)
154
139
  "#{get_element(element)}.setAttribute(\"#{attribute_name}\",\"#{value.to_s}\")"
@@ -159,6 +144,7 @@ EOS
159
144
  # @param [Shape::Text] text_element the target element
160
145
  # @param [String] text new contents of the text element
161
146
  # @return [String] ECMAScript string
147
+ # @function
162
148
  # @since 1.1.0
163
149
  def rewrite_text(text_element, text)
164
150
  lines = text.split(/(?:\r\n|\n|\r)/).map{|line| to_ecmascript_string(line)}
@@ -188,6 +174,7 @@ EOS
188
174
  # #=> "\"This figure is made using \\\"DYI\\\".\""
189
175
  # to_ecmascript_string("\346\227\245\346\234\254\350\252\236")
190
176
  # #=> "\"\\u65E5\\u672C\\u8A9E\"" (encoding: utf-8)
177
+ # @function
191
178
  # @since 1.1.0
192
179
  def to_ecmascript_string(obj)
193
180
  chars = []
@@ -210,6 +197,7 @@ EOS
210
197
  chars.join
211
198
  end
212
199
 
200
+ # @function
213
201
  def draw_text_border(*elements)
214
202
  elements_js_variable = []
215
203
  elements_js_variable << "var a=["
@@ -265,6 +253,7 @@ EOS
265
253
  "(function(){#{elements_js_variable.join}for(var b=0;b<#{elements.size};b++){var c=a[b];var d=null,right=null,bottom=null,left=null,rect=null;for(var e=0,len=c.a.childNodes.length;e<len;e++){var f=c.a.childNodes.item(e);if(f.localName==\"text\"){var g=f.getComputedTextLength();if(f.getNumberOfChars()>0){var h=f.getExtentOfChar(0);if(d==null||h.y<d)d=h.y;if(right==null||right<h.x+g)right=h.x+g;if(bottom==null||bottom<h.y+h.height)bottom=h.y+h.height;if(left==null||h.x<left)left=h.x;}}else if(f.localName==\"rect\")rect=f;}rect.setAttribute(\"x\",left-c.b);rect.setAttribute(\"y\",d-c.c);rect.setAttribute(\"width\",right-left+c.b*2);rect.setAttribute(\"height\",bottom-d+c.c*2);}})();"
266
254
  end
267
255
 
256
+ # @function
268
257
  def form_legend_labels(legend)
269
258
  =begin
270
259
  script =<<-EOS