Class: Glimmer::SWT::Custom::Shape::Path
Constant Summary
String
Instance Attribute Summary collapse
#args, #drawable, #extent, #name, #options, #parent, #shapes
Instance Method Summary
collapse
#add_to_swt_path, #first_path_segment?, #previous_path_segment, #previous_point_connected?
#absolute_x, #absolute_y, #amend_method_name_options_based_on_properties!, #apply_property_arg_conversions, #apply_shape_arg_conversions!, #apply_shape_arg_defaults!, arg_options, #background_pattern_args, #calculate_paint_args!, #calculated_args?, #calculated_args_changed_for_defaults!, #calculated_height, #calculated_width, #calculated_x, #calculated_y, #content, create, #current_parameter_name?, #default_height, #default_height?, #default_height_delta, #default_height_delta=, #default_width, #default_width?, #default_width_delta, #default_width_delta=, #default_x, #default_x?, #default_x_delta, #default_x_delta=, #default_y, #default_y?, #default_y_delta, #default_y_delta=, #draw?, #ensure_extent, #expanded_shapes, #fill?, flyweight_method_names, flyweight_patterns, #foreground_pattern_args, gc_instance_methods, #get_attribute, #gradient?, #has_attribute?, #has_some_background?, #has_some_foreground?, #inspect, keywords, #location, #location_parameter_names, #method_missing, method_name, #paint, #paint_children, #paint_self, #parameter_index, #parameter_name?, #parent_shape_absolute_location_changed?, #pattern, pattern, #pattern_args, #possible_parameter_names, #post_add_content, #respond_to?, #round?, #set_attribute, #set_parameter_attribute, #tolerate_shape_extra_args!, valid?
Methods included from Properties
attribute_getter, #attribute_getter, attribute_setter, #attribute_setter, normalized_attribute, #normalized_attribute, ruby_attribute_getter, #ruby_attribute_setter, ruby_attribute_setter
Methods included from Packages
included
Constructor Details
#initialize(parent, keyword, *args, &property_block) ⇒ Path
Returns a new instance of Path.
42
43
44
45
46
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 42
def initialize(parent, keyword, *args, &property_block)
super
@path_segments = []
@uncalculated_path_segments = []
end
|
Instance Attribute Details
#closed ⇒ Object
Returns the value of attribute closed.
39
40
41
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 39
def closed
@closed
end
|
#flatness ⇒ Object
Returns the value of attribute flatness.
39
40
41
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 39
def flatness
@flatness
end
|
#path_segments ⇒ Object
Returns the value of attribute path_segments.
40
41
42
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 40
def path_segments
@path_segments
end
|
#swt_path ⇒ Object
Returns the value of attribute swt_path.
40
41
42
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 40
def swt_path
@swt_path
end
|
Instance Method Details
#add_shape(shape) ⇒ Object
52
53
54
55
56
57
58
59
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 52
def add_shape(shape)
if shape.is_a?(PathSegment)
@path_segments << shape
@uncalculated_path_segments << shape
else
super
end
end
|
#bounds ⇒ Object
116
117
118
119
120
121
122
123
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 116
def bounds
if @path_segments != @bounds_path_segments
@bounds_path_segments = @path_segments
shape_bounds = geometry.getBounds2D
@bounds = org.eclipse.swt.graphics.Rectangle.new(shape_bounds.x, shape_bounds.y, shape_bounds.width, shape_bounds.height)
end
@bounds
end
|
#calculated_args ⇒ Object
99
100
101
102
103
104
105
106
107
108
109
110
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 99
def calculated_args
@swt_path ||= org.eclipse.swt.graphics.Path.new(Glimmer::SWT::DisplayProxy.instance.swt_display)
@args = [@swt_path]
@uncalculated_path_segments.dup.each do |path_segment|
path_segment.add_to_swt_path(@swt_path)
@uncalculated_path_segments.delete(path_segment)
end
super
rescue => e
Glimmer::Config.logger.error {e.full_message}
end
|
#calculated_args_changed!(children: true) ⇒ Object
95
96
97
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 95
def calculated_args_changed!(children: true)
super
end
|
#contain?(x, y) ⇒ Boolean
61
62
63
64
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 61
def contain?(x, y)
makeshift_gc = org.eclipse.swt.graphics.GC.new(Glimmer::SWT::DisplayProxy.instance.swt_display)
@swt_path.contains(x.to_f, y.to_f, makeshift_gc, false)
end
|
#dispose ⇒ Object
87
88
89
90
91
92
93
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 87
def dispose
@swt_path&.dispose
@swt_path = nil
@args = []
calculated_args_changed!(children: false)
super
end
|
#eql?(other) ⇒ Boolean
Also known as:
==
184
185
186
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 184
def eql?(other)
geometry.equals(other && other.respond_to?(:geometry) && other.geometry)
end
|
#geometry ⇒ Object
156
157
158
159
160
161
162
163
164
165
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 156
def geometry
if @path_segments != @geometry_path_segments
@geometry_path_segments = @path_segments
@geometry = Java::JavaAwtGeom::Path2D::Double.new
@path_segments.each do |path_segment|
@geometry.send(path_segment.path_segment_geometry_method_name, *path_segment.path_segment_geometry_args)
end
end
@geometry
end
|
#hash ⇒ Object
189
190
191
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 189
def hash
geometry.hashCode
end
|
#height ⇒ Object
152
153
154
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 152
def height
size.y
end
|
#include?(x, y, filled: nil) ⇒ Boolean
checks if drawn or filled rectangle includes the point denoted by x and y (if drawn, it only returns true if point lies on the edge)
71
72
73
74
75
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 71
def include?(x, y, filled: nil)
filled = filled? if filled.nil?
makeshift_gc = org.eclipse.swt.graphics.GC.new(Glimmer::SWT::DisplayProxy.instance.swt_display)
@swt_path.contains(x.to_f, y.to_f, makeshift_gc, !filled)
end
|
#irregular? ⇒ Boolean
77
78
79
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 77
def irregular?
true
end
|
#move_by(x_delta, y_delta) ⇒ Object
112
113
114
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 112
def move_by(x_delta, y_delta)
@path_segments.each {|path_segment| path_segment.move_by(x_delta, y_delta)}
end
|
#parameter_names ⇒ Object
48
49
50
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 48
def parameter_names
[:swt_path]
end
|
#path_segment_args ⇒ Object
171
172
173
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 171
def path_segment_args
@args
end
|
#path_segment_geometry_args ⇒ Object
179
180
181
182
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 179
def path_segment_geometry_args
[geometry, false]
end
|
#path_segment_geometry_method_name ⇒ Object
175
176
177
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 175
def path_segment_geometry_method_name
'append'
end
|
#path_segment_method_name ⇒ Object
167
168
169
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 167
def path_segment_method_name
'addPath'
end
|
#post_dispose_content(path_segment) ⇒ Object
81
82
83
84
85
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 81
def post_dispose_content(path_segment)
@path_segments.delete(path_segment)
@uncalculated_path_segments = @path_segments.dup
dispose
end
|
#size ⇒ Object
125
126
127
128
129
130
131
132
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 125
def size
if @path_segments != @size_path_segments
@size_path_segments = @path_segments
shape_bounds = geometry.getBounds2D
@size = org.eclipse.swt.graphics.Point.new(shape_bounds.width, shape_bounds.height)
end
@size
end
|
#width ⇒ Object
148
149
150
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 148
def width
size.x
end
|
#x ⇒ Object
Logical x coordinate relative to parent
135
136
137
138
139
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 135
def x
x_value = bounds.x
x_value -= parent.absolute_x if parent.is_a?(Shape)
x_value
end
|
#y ⇒ Object
Logical y coordinate relative to parent
142
143
144
145
146
|
# File 'lib/glimmer/swt/custom/shape/path.rb', line 142
def y
y_value = bounds.y
y_value -= parent.absolute_y if parent.is_a?(Shape)
y_value
end
|