Class: Glimmer::SWT::Custom::Shape::Polyline
Constant Summary
String
Instance Attribute Summary
#args, #drawable, #extent, #name, #options, #parent, #shapes
Instance Method Summary
collapse
#absolute_x, #absolute_y, #add_shape, #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?, #calculated_args_changed!, #calculated_args_changed_for_defaults!, #calculated_height, #calculated_width, #calculated_x, #calculated_y, 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=, #dispose, #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?, #initialize, #inspect, keywords, #location, #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
Instance Method Details
#[](index) ⇒ Object
48
49
50
51
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 48
def [](index)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 65
def absolute_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
87
88
89
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 87
def absolute_point_xy_array
absolute_x_array.zip(absolute_y_array)
end
|
#absolute_x_array ⇒ Object
79
80
81
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 79
def absolute_x_array
absolute_point_array.each_with_index.select {|pair| pair.last.even?}.map(&:first)
end
|
#absolute_y_array ⇒ Object
83
84
85
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 83
def absolute_y_array
absolute_point_array.each_with_index.select {|pair| pair.last.odd?}.map(&:first)
end
|
#bounds ⇒ Object
91
92
93
94
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 91
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
101
102
103
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 101
def geometry
java.awt.Polygon.new(absolute_x_array.to_java(:int), absolute_y_array.to_java(:int), point_count)
end
|
#height ⇒ Object
123
124
125
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 123
def height
bounds.height
end
|
#include?(x, y) ⇒ Boolean
Also known as:
contain?
127
128
129
130
131
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 127
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
138
139
140
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 138
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
134
135
136
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 134
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
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 44
def point_count
point_array.count / 2
end
|
#point_xy_array ⇒ Object
61
62
63
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 61
def point_xy_array
x_array.zip(y_array)
end
|
#size ⇒ Object
96
97
98
99
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 96
def size
shape_bounds = geometry.getBounds2D
org.eclipse.swt.graphics.Point.new(shape_bounds.width, shape_bounds.height)
end
|
#width ⇒ Object
119
120
121
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 119
def width
bounds.width
end
|
#x ⇒ Object
Logical x coordinate relative to parent
106
107
108
109
110
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 106
def x
x_value = bounds.x
x_value -= parent.absolute_x if parent.is_a?(Shape)
x_value
end
|
#x_array ⇒ Object
53
54
55
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 53
def x_array
point_array.each_with_index.select {|pair| pair.last.even?}.map(&:first)
end
|
#y ⇒ Object
Logical y coordinate relative to parent
113
114
115
116
117
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 113
def y
y_value = bounds.y
y_value -= parent.absolute_y if parent.is_a?(Shape)
y_value
end
|
#y_array ⇒ Object
57
58
59
|
# File 'lib/glimmer/swt/custom/shape/polyline.rb', line 57
def y_array
point_array.each_with_index.select {|pair| pair.last.odd?}.map(&:first)
end
|