Class: Glimmer::SWT::Custom::Shape::Polyline
Constant Summary
String
Instance Attribute Summary
#args, #drawable, #extent, #name, #options, #parent, #properties, #shapes
Instance Method Summary
collapse
#absolute_x, #absolute_y, #add_shape, #all_parent_properties, #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_args!, #calculate_paint_args!, #calculated_args?, #calculated_args_changed!, #calculated_args_changed_for_defaults!, #calculated_height, #calculated_width, #calculated_x, #calculated_y, #clear_shapes, #composite?, #container?, #content, #convert_properties!, #converted_properties, create, #current_parameter_name?, #default_height, #default_height?, #default_width, #default_width?, #default_x, #default_x?, #default_y, #default_y?, #dispose, #draw?, #ensure_extent, #expanded_shapes, #fill?, flyweight_method_names, flyweight_patterns, #foreground_pattern_args, gc_instance_methods, #get_attribute, #get_data, #get_parameter_attribute, #gradient?, #has_attribute?, #has_some_background?, #has_some_foreground?, #height_delta, #height_delta=, #initialize, #inspect, keywords, #location, #max_height, #max_height?, #max_width, #max_width?, #method_missing, method_name, #paint, #paint_children, #paint_self, #parameter_index, #parameter_name?, #parent_shape_composites, #parent_shape_containers, #parent_shapes, #pattern, pattern, #pattern_args, #possible_parameter_names, #post_add_content, #respond_to?, #round?, #set_attribute, #set_data, #set_parameter_attribute, #tolerate_shape_extra_args!, valid?, #width_delta, #width_delta=, #x_delta, #x_delta=, #x_end, #y_delta, #y_delta=, #y_end
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
Instance Method Details
#[](index) ⇒ Object
49
50
51
52
53
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 49
def [](index)
point_array = args.size > 1 ? args : self.point_array
index = 0 if index == point_count
org.eclipse.swt.graphics.Point.new(point_array[index * 2], point_array[index * 2 + 1])
end
|
#absolute_point_array ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 69
def absolute_point_array
point_array = args.size > 1 ? args : self.point_array
if parent.is_a?(Shape)
point_array.each_with_index.map do |coordinate, i|
if i.even?
parent.absolute_x + coordinate
else
parent.absolute_y + coordinate
end
end
else
point_array
end
end
|
#absolute_point_xy_array ⇒ Object
92
93
94
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 92
def absolute_point_xy_array
absolute_x_array.zip(absolute_y_array)
end
|
#absolute_x_array ⇒ Object
84
85
86
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 84
def absolute_x_array
absolute_point_array.each_with_index.select {|pair| pair.last.even?}.map(&:first)
end
|
#absolute_y_array ⇒ Object
88
89
90
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 88
def absolute_y_array
absolute_point_array.each_with_index.select {|pair| pair.last.odd?}.map(&:first)
end
|
#bounds ⇒ Object
96
97
98
99
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 96
def bounds
shape_bounds = geometry.getBounds2D
org.eclipse.swt.graphics.Rectangle.new(shape_bounds.x, shape_bounds.y, shape_bounds.width, shape_bounds.height)
end
|
#geometry ⇒ Object
106
107
108
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 106
def geometry
java.awt.Polygon.new(absolute_x_array.to_java(:int), absolute_y_array.to_java(:int), point_count)
end
|
#height ⇒ Object
128
129
130
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 128
def height
bounds.height
end
|
#include?(x, y) ⇒ Boolean
Also known as:
contain?
132
133
134
135
136
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 132
def include?(x, y)
comparison_lines = absolute_point_xy_array.zip(absolute_point_xy_array.rotate(1))
comparison_lines.pop comparison_lines.any? {|line| Line.include?(line.first.first, line.first.last, line.last.first, line.last.last, x, y)}
end
|
#irregular? ⇒ Boolean
143
144
145
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 143
def irregular?
true
end
|
#location_parameter_names ⇒ Object
40
41
42
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 40
def location_parameter_names
parameter_names
end
|
#move_by(x_delta, y_delta) ⇒ Object
139
140
141
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 139
def move_by(x_delta, y_delta)
self.point_array = point_array.each_with_index.map {|coordinate, i| i.even? ? coordinate + x_delta : coordinate + y_delta}
end
|
#parameter_names ⇒ Object
36
37
38
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 36
def parameter_names
[:point_array]
end
|
#point_count ⇒ Object
44
45
46
47
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 44
def point_count
point_array = args.size > 1 ? args : self.point_array
point_array.count / 2
end
|
#point_xy_array ⇒ Object
65
66
67
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 65
def point_xy_array
x_array.zip(y_array)
end
|
#size ⇒ Object
101
102
103
104
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 101
def size
shape_bounds = geometry.getBounds2D
org.eclipse.swt.graphics.Point.new(shape_bounds.width, shape_bounds.height)
end
|
#width ⇒ Object
124
125
126
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 124
def width
bounds.width
end
|
#x ⇒ Object
Logical x coordinate relative to parent
111
112
113
114
115
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 111
def x
x_value = bounds.x
x_value -= parent.absolute_x if parent.is_a?(Shape)
x_value
end
|
#x_array ⇒ Object
55
56
57
58
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 55
def x_array
point_array = args.size > 1 ? args : self.point_array
point_array.each_with_index.select {|pair| pair.last.even?}.map(&:first)
end
|
#y ⇒ Object
Logical y coordinate relative to parent
118
119
120
121
122
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 118
def y
y_value = bounds.y
y_value -= parent.absolute_y if parent.is_a?(Shape)
y_value
end
|
#y_array ⇒ Object
60
61
62
63
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 60
def y_array
point_array = args.size > 1 ? args : self.point_array
point_array.each_with_index.select {|pair| pair.last.odd?}.map(&:first)
end
|