Class: Glimmer::SWT::Custom::Shape::Rectangle
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, #bounds, #calculate_paint_args!, #calculated_args, #calculated_args?, #calculated_args_changed!, #calculated_args_changed_for_defaults!, #calculated_height, #calculated_width, #calculated_x, #calculated_y, #contain?, #content, create, #current_parameter_name?, #default_height, #default_height?, #default_width, #default_width?, #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?, #height_delta, #height_delta=, #initialize, #inspect, #irregular?, keywords, #location, #location_parameter_names, #max_height, #max_height?, #max_width, #max_width?, #method_missing, method_name, #move_by, #paint, #paint_children, #paint_self, #parameter_name?, #parent_shape_absolute_location_changed?, #parent_shape_composites, #parent_shapes, #pattern, pattern, #pattern_args, #post_add_content, #respond_to?, #round?, #set_attribute, #set_parameter_attribute, #shape_composite?, #size, #tolerate_shape_extra_args!, valid?, #width_delta, #width_delta=
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
#absolute_point_xy_array ⇒ Object
88
89
90
|
# File 'lib/glimmer/swt/custom/shape/rectangle.rb', line 88
def absolute_point_xy_array
[[absolute_x, absolute_y], [absolute_x + calculated_width, absolute_y], [absolute_x + calculated_width, absolute_y + calculated_height], [absolute_x, absolute_y + calculated_height]]
end
|
#include?(x, y) ⇒ 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)
93
94
95
96
97
98
99
100
|
# File 'lib/glimmer/swt/custom/shape/rectangle.rb', line 93
def include?(x, y)
if filled?
contain?(x, y)
else
comparison_lines = absolute_point_xy_array.zip(absolute_point_xy_array.rotate(1))
comparison_lines.any? {|line| Line.include?(line.first.first, line.first.last, line.last.first, line.last.last, x, y)}
end
end
|
#parameter_index(attribute_name) ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/glimmer/swt/custom/shape/rectangle.rb', line 71
def parameter_index(attribute_name)
if rectangle_round_parameter_names.map(&:to_s).include?(attribute_name.to_s)
rectangle_round_parameter_names.map(&:to_s).index(attribute_name.to_s)
elsif rectangle_gradient_parameter_names.map(&:to_s).include?(attribute_name.to_s)
rectangle_gradient_parameter_names.map(&:to_s).index(attribute_name.to_s)
elsif rectangle_parameter_names.map(&:to_s).include?(attribute_name.to_s)
rectangle_parameter_names.map(&:to_s).index(attribute_name.to_s)
elsif rectangle_rectangle_parameter_names.map(&:to_s).include?(attribute_name.to_s)
rectangle_rectangle_parameter_names.map(&:to_s).index(attribute_name.to_s)
end
end
|
#parameter_names ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/glimmer/swt/custom/shape/rectangle.rb', line 36
def parameter_names
if @args.to_a.size >= 6
rectangle_round_parameter_names
elsif @args.to_a.size == 5
rectangle_gradient_parameter_names
elsif @args.to_a.size == 1
rectangle_rectangle_parameter_names
else
rectangle_parameter_names
end
end
|
#point_xy_array ⇒ Object
84
85
86
|
# File 'lib/glimmer/swt/custom/shape/rectangle.rb', line 84
def point_xy_array
[[x, y], [x + calculated_width, y], [x + calculated_width, y + calculated_height], [x, y + calculated_height]]
end
|
#possible_parameter_names ⇒ Object
49
50
51
52
|
# File 'lib/glimmer/swt/custom/shape/rectangle.rb', line 49
def possible_parameter_names
(rectangle_round_parameter_names + rectangle_gradient_parameter_names + rectangle_parameter_names + rectangle_rectangle_parameter_names).uniq
end
|
#rectangle_gradient_parameter_names ⇒ Object
58
59
60
|
# File 'lib/glimmer/swt/custom/shape/rectangle.rb', line 58
def rectangle_gradient_parameter_names
[:x, :y, :width, :height, :vertical]
end
|
#rectangle_parameter_names ⇒ Object
62
63
64
|
# File 'lib/glimmer/swt/custom/shape/rectangle.rb', line 62
def rectangle_parameter_names
[:x, :y, :width, :height]
end
|
#rectangle_rectangle_parameter_names ⇒ Object
66
67
68
69
|
# File 'lib/glimmer/swt/custom/shape/rectangle.rb', line 66
def rectangle_rectangle_parameter_names
[:rectangle]
end
|
#rectangle_round_parameter_names ⇒ Object
54
55
56
|
# File 'lib/glimmer/swt/custom/shape/rectangle.rb', line 54
def rectangle_round_parameter_names
[:x, :y, :width, :height, :arc_width, :arc_height]
end
|