Class: Glimmer::SWT::Custom::Shape::Line
Constant Summary
String
Instance Attribute Summary
#args, #disposed, #drawable, #extent, #name, #options, #parent, #properties, #shapes, #widget_listener_proxies
Class Method Summary
collapse
Instance Method Summary
collapse
#add_to_geometry, #add_to_swt_path, #dispose, #first_path_segment?, #part_of_path?, #path, #path_segment_geometry_method_name, #previous_path_segment, #root_path
#absolute_x, #absolute_y, #add_shape, #all_parent_properties, #amend_method_name_options_based_on_properties!, #any_potential_drop_targets?, #apply_property_arg_conversions, #apply_shape_arg_conversions!, #apply_shape_arg_defaults!, arg_options, #background_pattern_args, #bounds_contain?, #calculate_args!, #calculate_paint_args!, #calculated_args?, #calculated_args_changed!, #calculated_args_changed_for_defaults!, #calculated_height, #calculated_paint_args_changed!, #calculated_width, #calculated_x, #calculated_y, #can_handle_observation_request?, #cancel_dragging!, #center_x, #center_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?, #deregister_drag_listeners, #dispose, #drag_and_move, #drag_and_move=, #drag_source, #drag_source=, #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?, #handle_observation_request, #has_attribute?, #has_some_background?, #has_some_foreground?, #height_delta, #height_delta=, #include_shape?, #include_with_children?, #initialize, #inspect, #inverse_transform_point, 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, #remove_shape_disposed_listener, #respond_to?, #rotate, #rotation_angle, #round?, #set_attribute, #set_data, #set_parameter_attribute, #shell_proxy, #tolerate_shape_extra_args!, #transform_point, 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
Class Method Details
.include?(x1, y1, x2, y2, x, y) ⇒ Boolean
40
41
42
43
44
45
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 40
def include?(x1, y1, x2, y2, x, y)
distance1 = Math.sqrt((x - x1)**2 + (y - y1)**2)
distance2 = Math.sqrt((x2 - x)**2 + (y2 - y)**2)
distance = Math.sqrt((x2 - x1)**2 + (y2 - y1)**2)
(distance1 + distance2).to_i == distance.to_i
end
|
Instance Method Details
#absolute_x1 ⇒ Object
92
93
94
95
96
97
98
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 92
def absolute_x1
if parent.is_a?(Shape) && parent.class != Shape
parent.absolute_x + x1
else
x1
end
end
|
#absolute_x2 ⇒ Object
108
109
110
111
112
113
114
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 108
def absolute_x2
if parent.is_a?(Shape) && parent.class != Shape
parent.absolute_x + x2.to_f
else
x2
end
end
|
#absolute_y1 ⇒ Object
100
101
102
103
104
105
106
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 100
def absolute_y1
if parent.is_a?(Shape) && parent.class != Shape
parent.absolute_y + y1
else
y1
end
end
|
#absolute_y2 ⇒ Object
116
117
118
119
120
121
122
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 116
def absolute_y2
if parent.is_a?(Shape) && parent.class != Shape
parent.absolute_y + y2.to_f
else
y2
end
end
|
#bounds ⇒ Object
56
57
58
59
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 56
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
|
#default_connected_path_segment_arg_count ⇒ Object
155
156
157
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 155
def default_connected_path_segment_arg_count
2
end
|
#default_path_segment_arg_count ⇒ Object
151
152
153
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 151
def default_path_segment_arg_count
4
end
|
#eql?(other) ⇒ Boolean
Also known as:
==
168
169
170
171
172
173
174
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 168
def eql?(other)
other.is_a?(Line) &&
x1 == (other && other.respond_to?(:x1) && other.x1) &&
y1 == (other && other.respond_to?(:y1) && other.y1) &&
x2 == (other && other.respond_to?(:x2) && other.x2) &&
y2 == (other && other.respond_to?(:y2) && other.y2)
end
|
#geometry ⇒ Object
66
67
68
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 66
def geometry
java.awt.geom.Line2D::Double.new(absolute_x1, absolute_y1, absolute_x2, absolute_y2)
end
|
#hash ⇒ Object
177
178
179
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 177
def hash
[x1, y1, x2, y2].hash
end
|
#height ⇒ Object
88
89
90
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 88
def height
size.y
end
|
#include?(x, y) ⇒ Boolean
Also known as:
contain?
124
125
126
127
128
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 124
def include?(x, y)
x, y = inverse_transform_point(x, y)
Line.include?(absolute_x1, absolute_y1, absolute_x2, absolute_y2, x, y)
end
|
#irregular? ⇒ Boolean
138
139
140
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 138
def irregular?
true
end
|
#location_parameter_names ⇒ Object
52
53
54
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 52
def location_parameter_names
parameter_names
end
|
#move_by(x_delta, y_delta) ⇒ Object
131
132
133
134
135
136
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 131
def move_by(x_delta, y_delta)
self.x1 += x_delta
self.y1 += y_delta
self.x2 += x_delta
self.y2 += y_delta
end
|
#parameter_names ⇒ Object
48
49
50
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 48
def parameter_names
[:x1, :y1, :x2, :y2]
end
|
#path_segment_args ⇒ Object
146
147
148
149
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 146
def path_segment_args
@args
end
|
#path_segment_geometry_args ⇒ Object
159
160
161
162
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 159
def path_segment_geometry_args
@args
end
|
#path_segment_method_name ⇒ Object
142
143
144
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 142
def path_segment_method_name
'lineTo'
end
|
#previous_point_connected? ⇒ Boolean
164
165
166
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 164
def previous_point_connected?
@args.compact.count == 2 && !first_path_segment?
end
|
#size ⇒ Object
61
62
63
64
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 61
def size
shape_bounds = geometry.getBounds2D
org.eclipse.swt.graphics.Point.new(shape_bounds.width, shape_bounds.height)
end
|
#width ⇒ Object
84
85
86
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 84
def width
size.x
end
|
#x ⇒ Object
Logical x coordinate relative to parent
71
72
73
74
75
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 71
def x
x_value = bounds.x
x_value -= parent.absolute_x if parent.is_a?(Shape) && parent.class != Shape
x_value
end
|
#y ⇒ Object
Logical y coordinate relative to parent
78
79
80
81
82
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 78
def y
y_value = bounds.y
y_value -= parent.absolute_y if parent.is_a?(Shape) && parent.class != Shape
y_value
end
|