Class: Glimmer::SWT::Custom::Shape::Line
Constant Summary
String
Instance Attribute Summary
#args, #drawable, #extent, #name, #options, #parent, #shapes
Class Method Summary
collapse
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
Class Method Details
.include?(x1, y1, x2, y2, x, y) ⇒ Boolean
37
38
39
40
41
42
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 37
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
89
90
91
92
93
94
95
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 89
def absolute_x1
if parent.is_a?(Shape)
parent.absolute_x + x1
else
x1
end
end
|
#absolute_x2 ⇒ Object
105
106
107
108
109
110
111
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 105
def absolute_x2
if parent.is_a?(Shape)
parent.absolute_x + x2
else
x2
end
end
|
#absolute_y1 ⇒ Object
97
98
99
100
101
102
103
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 97
def absolute_y1
if parent.is_a?(Shape)
parent.absolute_y + y1
else
y1
end
end
|
#absolute_y2 ⇒ Object
113
114
115
116
117
118
119
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 113
def absolute_y2
if parent.is_a?(Shape)
parent.absolute_y + y1
else
y2
end
end
|
#bounds ⇒ Object
53
54
55
56
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 53
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
63
64
65
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 63
def geometry
java.awt.geom.Line2D::Double.new(absolute_x1, absolute_y1, absolute_x2, absolute_y2)
end
|
#height ⇒ Object
85
86
87
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 85
def height
bounds.height
end
|
#include?(x, y) ⇒ Boolean
Also known as:
contain?
121
122
123
124
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 121
def include?(x, y)
Line.include?(absolute_x1, absolute_y1, absolute_x2, absolute_y2, x, y)
end
|
#irregular? ⇒ Boolean
134
135
136
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 134
def irregular?
true
end
|
#location_parameter_names ⇒ Object
49
50
51
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 49
def location_parameter_names
parameter_names
end
|
#move_by(x_delta, y_delta) ⇒ Object
127
128
129
130
131
132
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 127
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
45
46
47
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 45
def parameter_names
[:x1, :y1, :x2, :y2]
end
|
#size ⇒ Object
58
59
60
61
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 58
def size
shape_bounds = geometry.getBounds2D
org.eclipse.swt.graphics.Point.new(shape_bounds.width, shape_bounds.height)
end
|
#width ⇒ Object
81
82
83
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 81
def width
bounds.width
end
|
#x ⇒ Object
Logical x coordinate relative to parent
68
69
70
71
72
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 68
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
75
76
77
78
79
|
# File 'lib/glimmer/swt/custom/shape/line.rb', line 75
def y
y_value = bounds.y
y_value -= parent.absolute_y if parent.is_a?(Shape)
y_value
end
|