Module: Glimmer::SWT::Custom::Shape::PathSegment
Overview
Represents path segments like point, line, quad, and cubic curves Shapes could mix in
Instance Method Summary collapse
- #add_to_swt_path(swt_path) ⇒ Object
- #dispose ⇒ Object
- #first_path_segment? ⇒ Boolean
-
#path_segment_args ⇒ Object
Subclasses must override and implement to indicate args to pass when invoking SWT Path object method.
-
#path_segment_geometry_args ⇒ Object
Subclasses must override and implement to indicate args to pass when invoking SWT Path object method.
-
#path_segment_geometry_method_name ⇒ Object
Subclasses may override to provide name of method to invoke for geometry object obtained from the Java AWT library java.awt.geom.Path2D.Double (e.g. curveTo vs cubicTo).
-
#path_segment_method_name ⇒ Object
Subclasses must override and implement to indicate method name to invoke on SWT Path object to add segment.
- #previous_path_segment ⇒ Object
-
#previous_point_connected? ⇒ Boolean
Subclasses must override to indicate otherwise.
Instance Method Details
#add_to_swt_path(swt_path) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/glimmer/swt/custom/shape/path_segment.rb', line 66 def add_to_swt_path(swt_path) if @swt_path != swt_path @swt_path = swt_path the_path_segment_args = path_segment_args.dup if !previous_point_connected? && !is_a?(Point) if the_path_segment_args.count > 2 point = the_path_segment_args.shift, the_path_segment_args.shift @swt_path.moveTo(*point) elsif first_path_segment? && self.class != Path point = the_path_segment_args[0..1] @swt_path.moveTo(*point) end end @swt_path.send(path_segment_method_name, *the_path_segment_args) end end |
#dispose ⇒ Object
54 55 56 |
# File 'lib/glimmer/swt/custom/shape/path_segment.rb', line 54 def dispose parent.post_dispose_content(self) if parent.is_a?(Path) end |
#first_path_segment? ⇒ Boolean
58 59 60 |
# File 'lib/glimmer/swt/custom/shape/path_segment.rb', line 58 def first_path_segment? parent.path_segments.first == self end |
#path_segment_args ⇒ Object
Subclasses must override and implement to indicate args to pass when invoking SWT Path object method
38 39 40 |
# File 'lib/glimmer/swt/custom/shape/path_segment.rb', line 38 def path_segment_args [] end |
#path_segment_geometry_args ⇒ Object
Subclasses must override and implement to indicate args to pass when invoking SWT Path object method
46 47 48 |
# File 'lib/glimmer/swt/custom/shape/path_segment.rb', line 46 def path_segment_geometry_args path_segment_args end |
#path_segment_geometry_method_name ⇒ Object
Subclasses may override to provide name of method to invoke for geometry object obtained from the Java AWT library java.awt.geom.Path2D.Double (e.g. curveTo vs cubicTo)
42 43 44 |
# File 'lib/glimmer/swt/custom/shape/path_segment.rb', line 42 def path_segment_geometry_method_name path_segment_method_name end |
#path_segment_method_name ⇒ Object
Subclasses must override and implement to indicate method name to invoke on SWT Path object to add segment
34 35 36 |
# File 'lib/glimmer/swt/custom/shape/path_segment.rb', line 34 def path_segment_method_name nil end |
#previous_path_segment ⇒ Object
62 63 64 |
# File 'lib/glimmer/swt/custom/shape/path_segment.rb', line 62 def previous_path_segment parent.path_segments[parent.path_segments.index(self) - 1] || self end |
#previous_point_connected? ⇒ Boolean
Subclasses must override to indicate otherwise
50 51 52 |
# File 'lib/glimmer/swt/custom/shape/path_segment.rb', line 50 def previous_point_connected? true end |