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
  #
@@ -18,15 +18,11 @@
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 event becomes
25
- # effective only when it is output by SVG format.
26
- #
27
- # @since 1.0.0
28
21
 
22
+ #
29
23
  module DYI
24
+
25
+ # @since 1.0.0
30
26
  module Script
31
27
 
32
28
  # Class representing a inline-client-script. The scripting becomes
@@ -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
  #
@@ -30,13 +30,9 @@ module DYI
30
30
  class Base < GraphicalElement
31
31
 
32
32
  # Returns painting status of the shape.
33
- # @attribute painting
34
- # @return [Painting] painting status
35
33
  attr_painting :painting
36
34
 
37
35
  # Returns font status of the shape.
38
- # @attribute font
39
- # @return [Font] font status
40
36
  attr_font :font
41
37
 
42
38
  # Returns optional attributes of the shape.
@@ -49,14 +45,17 @@ module DYI
49
45
 
50
46
  # Returns a parent element of the shape.
51
47
  # @return [GraphicalElement] a parent element
48
+ # @since 1.0.0
52
49
  attr_reader :parent
53
50
 
54
51
  # Returns a location of a reference of a source anchor for the link.
55
52
  # @return [String] a location of a reference
53
+ # @since 1.0.0
56
54
  attr_accessor :anchor_href
57
55
 
58
56
  # Returns a relevant presentation context when the link is activated.
59
57
  # @return [String] a relevant presentation context
58
+ # @since 1.0.0
60
59
  attr_accessor :anchor_target
61
60
 
62
61
  # Draws the shape on a parent element.
@@ -122,7 +121,7 @@ module DYI
122
121
  # Scales up (or down) this shape.
123
122
  # @param [Numeric] x scaled ratio along x-axis
124
123
  # @param [Numeric] y scaled ratio along y-axis. If this parameter is nil,
125
- # uses value that equals to parameter `x' value
124
+ # uses value that equals to parameter 'x' value
126
125
  # @param [Coordinate] base_point based coordinate of scaling up (or down)
127
126
  def scale(x, y=nil, base_point=Coordinate::ZERO)
128
127
  y ||= x
@@ -235,7 +234,7 @@ module DYI
235
234
  # animation end, in seconds
236
235
  # @option options [Event] :end_event an event that determine the animation
237
236
  # end
238
- # @option options [String] :fill `freeze' or `remove'
237
+ # @option options [String] :fill 'freeze' or 'remove'
239
238
  # @since 1.0.0
240
239
  def add_painting_animation(options)
241
240
  add_animation(Animation::PaintingAnimation.new(self, options))
@@ -255,7 +254,7 @@ module DYI
255
254
  # animation end, in seconds
256
255
  # @option options [Event] :end_event an event that determine the animation
257
256
  # end
258
- # @option options [String] :fill `freeze' or `remove'
257
+ # @option options [String] :fill 'freeze' or 'remove'
259
258
  # @since 1.0.0
260
259
  def add_transform_animation(type, options)
261
260
  add_animation(Animation::TransformAnimation.new(self, type, options))
@@ -303,13 +302,9 @@ module DYI
303
302
  class Rectangle < Base
304
303
 
305
304
  # Returns width of the rectangle.
306
- # @attribute width
307
- # @return [Length] width of the rectangle
308
305
  attr_length :width
309
306
 
310
307
  # Returns heigth of the rectangle.
311
- # @attribute height
312
- # @return [Length] heigth of the rectangle
313
308
  attr_length :height
314
309
 
315
310
  # @param [Coordinate] left_top a coordinate of a corner of the rectangle
@@ -411,13 +406,9 @@ module DYI
411
406
  class Circle < Base
412
407
 
413
408
  # Returns a center coordinate of the circle.
414
- # @attribute center
415
- # @return [Coordinate] a center coordinate of the circle
416
409
  attr_coordinate :center
417
410
 
418
411
  # Returns a radius of the circle.
419
- # @attribute radius
420
- # @return [Length] a radius of the circle
421
412
  attr_length :radius
422
413
 
423
414
  def initialize(center, radius, options={})
@@ -647,7 +638,7 @@ module DYI
647
638
 
648
639
  class Text < Base
649
640
  BASELINE_VALUES = ['baseline', 'top', 'middle', 'bottom']
650
- DEFAULT_LINE_HEIGHT = 1
641
+ DEFAULT_LINE_HEIGHT = 1.0
651
642
  attr_coordinate :point
652
643
  attr_accessor :line_height
653
644
  attr_accessor :text
@@ -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
  #
@@ -21,9 +21,39 @@
21
21
 
22
22
  require 'enumerator'
23
23
 
24
- module DYI #:nodoc:
25
- module Shape #:nodoc:
26
-
24
+ module DYI
25
+ module Shape
26
+
27
+ # +Path+ represent the outline of a shape.
28
+ #
29
+ # +Path+ object has a concept of a current point. In an analogy with drawing
30
+ # on paper, the current point can be thought of as the location of the pen.
31
+ # The position of the pen can be changed, and the outline of a shape (open
32
+ # or closed) can be traced by dragging the pen in either straight lines or
33
+ # curves.
34
+ #
35
+ # = Commands of Drawing Paths
36
+ #
37
+ # Lines or curves is drawn using following commad:
38
+ # * <b>_move_to_ commands</b> -- Method {#move_to} and {#rmove_to} establish
39
+ # a new current point. The effect is as if the "pen" were lifted and moved
40
+ # to a new location.
41
+ # * <b>_close_path_ command</b> -- Method {#close_path} ends the current
42
+ # subpath and causes an automatic straight line to be drawn from the
43
+ # current point to the initial point of the current subpath.
44
+ # * <b>_line_to_ commands</b> -- Method {#line_to} and {#rline_to} draw
45
+ # straight lines from the current point to a new point.
46
+ # * <b>Cubic Bézier Curve commands</b> -- Method {#curve_to} and {#rcurve_to}
47
+ # draw a cubic Bézier curve from the current point.
48
+ # * <b>Quadratic Bézier Curve commands</b> -- Method {#quadratic_curve_to}
49
+ # and {#rquadratic_curve_to} draw a quadratic Bézier curve from the
50
+ # current point.
51
+ # * <b>Elliptical Arc Curve commands</b> -- Method {#arc_to} and {#rarc_to}
52
+ # draw an elliptical arc from the current point.
53
+ #
54
+ # See the documentation of each method for more infomation.
55
+ #
56
+ # @since 0.0.0
27
57
  class Path < Base
28
58
 
29
59
  def initialize(start_point, options={})
@@ -32,20 +62,63 @@ module DYI #:nodoc:
32
62
  else PathData.new(start_point)
33
63
  end
34
64
  @attributes = init_attributes(options)
35
- end
36
-
65
+ @marker = {}
66
+ end
67
+
68
+ # Starts a new sub-path at a given point, which is specified a absolute
69
+ # coordinate. The new current points become the given point.
70
+ #
71
+ # When multiple points is given as arguments, starts a new sub-path at the
72
+ # first point and draws straight line to the subsequent points. (i.e.
73
+ # <tt>path.move_to(pt1,pt2,pt3,...)</tt> equals to <tt>path.move_to(pt1);
74
+ # path.line_to(pt2,pt3,...)</tt>)
75
+ # @param [Coordinate] point the absolute coordinate of the start point of
76
+ # the new sub-path. The second and subsequent arguments are the absolute
77
+ # point to which the line is drawn from previous point
78
+ # @see #rmove_to
37
79
  def move_to(*points)
38
80
  push_command(:move_to, *points)
39
81
  end
40
82
 
83
+ # Starts a new sub-path at a given point, which is specified a relative
84
+ # coordinate to current point. The new current point becomes the last
85
+ # given point.
86
+ #
87
+ # When multiple points is given as arguments, starts a new sub-path at the
88
+ # first point and draws straight line to the subsequent points. (i.e.
89
+ # <tt>path.move_to(pt1,pt2,pt3,...)</tt> equals to <tt>path.move_to(pt1);
90
+ # path.line_to(pt2,pt3,...)</tt>)
91
+ # @param [Coordinate] point the relative coordinate of the start point of
92
+ # the new sub-path. The second and subsequent arguments are the relative
93
+ # point to which the line is drawn from previous point
94
+ # @see #move_to
41
95
  def rmove_to(*points)
42
96
  push_command(:rmove_to, *points)
43
97
  end
44
98
 
99
+ # Draws straight lines from the current point, which is specified a
100
+ # absolute coordinate. The new current point becomes the last given point.
101
+ #
102
+ # When multiple points is given as argument, draws a polyline. (i.e.
103
+ # <tt>path.line_to(pt1,pt2,pt3,...)</tt> equals to <tt>path.line_to(pt1);
104
+ # path.line_to(pt2); path.line_to(pt3); ...</tt>)
105
+ # @param [Coordinate] point the absolute coordinate which the line is
106
+ # drawn from current point to
107
+ # @see #rline_to
45
108
  def line_to(*points)
46
109
  push_command(:line_to, *points)
47
110
  end
48
111
 
112
+ # Draws straight lines from the current point, which is specified a
113
+ # relative coordinate to current point. The new current point becomes the
114
+ # last given point.
115
+ #
116
+ # When multiple points is given as arguments, draws a polyline. (i.e.
117
+ # <tt>path.rline_to(pt1,pt2,pt3,...)</tt> equals to <tt>path.rline_to(pt1);
118
+ # path.rline_to(pt2); path.rline_to(pt3); ...</tt>)
119
+ # @param [Coordinate] point the relavive coordinate which the line is
120
+ # drawn from current point to
121
+ # @see #line_to
49
122
  def rline_to(*points)
50
123
  push_command(:rline_to, *points)
51
124
  end
@@ -141,6 +214,16 @@ module DYI #:nodoc:
141
214
  def bottom
142
215
  edge_coordinate(:bottom)
143
216
  end
217
+
218
+ # Returns whether this shape has a marker symbol.
219
+ # @param [Symbol] point_type the type of marker point. Specifies the
220
+ # following values: +:start+, +:mid+, +:end+
221
+ # @return [Boolean] true if the shape has a marker at the cpecified point,
222
+ # false otherwise
223
+ # @since 1.2.0
224
+ def has_marker?(point_type)
225
+ !@marker[point_type].nil?
226
+ end
144
227
  =begin
145
228
  def line_bezier_paths
146
229
  start_point = Coordinate::ZERO
@@ -313,7 +396,7 @@ module DYI #:nodoc:
313
396
  end
314
397
  end
315
398
 
316
- class PathData #:nodoc:
399
+ class PathData
317
400
  include Enumerable
318
401
 
319
402
  def initialize(*points)
@@ -428,7 +511,7 @@ module DYI #:nodoc:
428
511
  end
429
512
  end
430
513
 
431
- class CommandBase #:nodoc:
514
+ class CommandBase
432
515
  attr_reader :preceding_command, :point
433
516
 
434
517
  def initialize(relative, preceding_command, point)
@@ -484,7 +567,7 @@ module DYI #:nodoc:
484
567
  end
485
568
  end
486
569
 
487
- class MoveCommand < CommandBase #:nodoc:
570
+ class MoveCommand < CommandBase
488
571
 
489
572
  def start_point
490
573
  last_point
@@ -517,7 +600,7 @@ module DYI #:nodoc:
517
600
  end
518
601
  end
519
602
 
520
- class CloseCommand < CommandBase #:nodoc:
603
+ class CloseCommand < CommandBase
521
604
  def initialize(preceding_command)
522
605
  raise ArgumentError, 'preceding_command is nil' if preceding_command.nil?
523
606
  @relative = nil
@@ -554,7 +637,7 @@ module DYI #:nodoc:
554
637
  end
555
638
  end
556
639
 
557
- class LineCommand < CommandBase #:nodoc:
640
+ class LineCommand < CommandBase
558
641
  def initialize(relative, preceding_command, point)
559
642
  raise ArgumentError, 'preceding_command is nil' if preceding_command.nil?
560
643
  super
@@ -579,7 +662,7 @@ module DYI #:nodoc:
579
662
  end
580
663
  end
581
664
 
582
- class HorizontalLineCommand < LineCommand #:nodoc:
665
+ class HorizontalLineCommand < LineCommand
583
666
  def initialize(relative, preceding_command, x)
584
667
  super(relative, preceding_command, Coordinate.new(x, relative ? 0 : preceding_command.last_point.y))
585
668
  end
@@ -597,7 +680,7 @@ module DYI #:nodoc:
597
680
  end
598
681
  end
599
682
 
600
- class VerticalLineCommand < LineCommand #:nodoc:
683
+ class VerticalLineCommand < LineCommand
601
684
  def initialize(relative, preceding_command, y)
602
685
  super(relative, preceding_command, Coordinate.new(relative ? 0 : preceding_command.last_point.x, y))
603
686
  end
@@ -615,7 +698,7 @@ module DYI #:nodoc:
615
698
  end
616
699
  end
617
700
 
618
- class CurveCommandBase < CommandBase #:nodoc:
701
+ class CurveCommandBase < CommandBase
619
702
  def initialize(relative, preceding_command, *points)
620
703
  raise ArgumentError, "wrong number of arguments (2 for #{pt_cnt + 2})" if points.size != pt_cnt
621
704
  raise ArgumentError, 'preceding_command is nil' if preceding_command.nil?
@@ -656,7 +739,7 @@ module DYI #:nodoc:
656
739
  end
657
740
  end
658
741
 
659
- class CurveCommand < CurveCommandBase #:nodoc:
742
+ class CurveCommand < CurveCommandBase
660
743
  def preceding_control_point
661
744
  if preceding_command.is_a?(CurveCommand)
662
745
  preceding_command.last_control_point
@@ -684,7 +767,7 @@ module DYI #:nodoc:
684
767
  end
685
768
  end
686
769
 
687
- class ShorthandCurveCommand < CurveCommand #:nodoc:
770
+ class ShorthandCurveCommand < CurveCommand
688
771
  def control_point1
689
772
  if relative?
690
773
  preceding_point - preceding_control_point
@@ -712,7 +795,7 @@ module DYI #:nodoc:
712
795
  end
713
796
  end
714
797
 
715
- class QuadraticCurveCommand < CurveCommandBase #:nodoc:
798
+ class QuadraticCurveCommand < CurveCommandBase
716
799
  def preceding_control_point
717
800
  if preceding_command.is_a?(QuadraticCurveCommand)
718
801
  preceding_command.last_control_point
@@ -742,7 +825,7 @@ module DYI #:nodoc:
742
825
  end
743
826
  end
744
827
 
745
- class ShorthandQuadraticCurveCommand < QuadraticCurveCommand #:nodoc:
828
+ class ShorthandQuadraticCurveCommand < QuadraticCurveCommand
746
829
  def control_point
747
830
  if relative?
748
831
  preceding_point - preceding_control_point
@@ -766,7 +849,7 @@ module DYI #:nodoc:
766
849
  end
767
850
  end
768
851
 
769
- class ArcCommand < CommandBase #:nodoc:
852
+ class ArcCommand < CommandBase
770
853
  attr_reader :rx, :ry, :rotation
771
854
 
772
855
  def initialize(relative, preceding_command, rx, ry, rotation, is_large_arc, is_clockwise, point)
@@ -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
  #
@@ -23,10 +23,11 @@
23
23
  #
24
24
  # This file provides the classes of client side scripting. The event becomes
25
25
  # effective only when it is output by SVG format.
26
- #
27
- # @since 1.0.0
28
26
 
27
+ #
29
28
  module DYI
29
+
30
+ # @since 1.0.0
30
31
  module Stylesheet
31
32
 
32
33
  class Style
@@ -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 0.0.0
24
26
  module SvgElement
25
27
 
26
28
  def draw_on(canvas)
@@ -111,11 +113,11 @@ module DYI #:nodoc:
111
113
 
112
114
  private
113
115
 
114
- def draw_children? #:nodoc:
116
+ def draw_children?
115
117
  not child_elements.empty?
116
118
  end
117
119
 
118
- def svg_attributes #:nodoc:
120
+ def svg_attributes
119
121
  attrs =
120
122
  attributes.inject({}) do |hash, (key, value)|
121
123
  hash[name_to_attribute(key).to_sym] = value if value
@@ -132,15 +134,15 @@ module DYI #:nodoc:
132
134
  attrs
133
135
  end
134
136
 
135
- def name_to_attribute(name) #:nodoc:
137
+ def name_to_attribute(name)
136
138
  name.to_s.gsub(/_/,'-')
137
139
  end
138
140
 
139
- def root_attributes #:nodoc:
141
+ def root_attributes
140
142
  {}
141
143
  end
142
144
 
143
- def child_elements_to_svg(xml) #:nodoc:
145
+ def child_elements_to_svg(xml)
144
146
  child_elements.each {|child|
145
147
  child.to_svg(xml)
146
148
  }