Class: Glimmer::SWT::Custom::Shape::Arc

Inherits:
Glimmer::SWT::Custom::Shape show all
Defined in:
lib/glimmer/swt/custom/shape/arc.rb

Constant Summary

Constants inherited from Glimmer::SWT::Custom::Shape

String

Constants inherited from WidgetProxy

WidgetProxy::DEFAULT_INITIALIZERS, WidgetProxy::JS_KEY_CODE_TO_SWT_KEY_CODE_MAP, WidgetProxy::JS_LOCATION_TO_SWT_KEY_LOCATION_MAP, WidgetProxy::SWT_CURSOR_TO_CSS_CURSOR_MAP

Instance Attribute Summary

Attributes inherited from WidgetProxy

#args, #background, #children, #cursor, #disposed?, #enabled, #focus, #font, #foreground, #menu, #menu_requested, #menu_x, #menu_y, #parent, #path, #rendered

Instance Method Summary collapse

Methods inherited from Glimmer::SWT::Custom::Shape

#attach, create, #current_parameter_name?, #dom, #element, #foreground=, #get_attribute, #get_parameter_attribute, #has_attribute?, keywords, #location_parameter_names, #method_missing, #parameter_index, #parameter_name?, #possible_parameter_names, #respond_to?, #set_attribute, #set_parameter_attribute, valid?

Methods included from PropertyOwner

#attribute_getter, #attribute_setter, #get_attribute, #set_attribute

Methods inherited from WidgetProxy

#add_content_on_render, #add_css_class, #add_css_classes, #add_observer, #apply_property_type_converters, #attach, #build_dom, #can_handle_observation_request?, #clear_css_classes, #content, #content_on_render_blocks, #css_classes, #default_observation_request_to_event_mapping, #dialog_ancestor, #dispose, #dom_element, #effective_observation_request_to_event_mapping, #element, #event_handling_suspended?, #event_listener_proxies, for, #get_data, #handle_javascript_observation_request, #handle_observation_request, #has_style?, #id, #id=, #initialize, #listener_dom_element, #listener_path, #listeners, #listeners_for, max_id_number_for, max_id_numbers, #method_missing, #name, next_id_number_for, #observation_request_to_event_mapping, #observation_requests, #parent_dom_element, #parent_path, #parents, #post_dispose_child, #post_initialize_child, #print, #property_type_converters, #reattach, #remove_all_listeners, #remove_css_class, #remove_css_classes, #remove_event_listener_proxies, reset_max_id_numbers!, #resume_event_handling, #selector, #set_attribute, #set_data, #set_focus, #shell, #skip_content_on_render_blocks?, #style_element, #suspend_event_handling, #swt_data, #swt_widget, underscored_widget_name, widget_class, widget_exists?, widget_handling_listener, #widget_property_listener_installers

Constructor Details

This class inherits a constructor from Glimmer::SWT::WidgetProxy

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Glimmer::SWT::Custom::Shape

Instance Method Details

#background=(value) ⇒ Object



43
44
45
46
# File 'lib/glimmer/swt/custom/shape/arc.rb', line 43

def background=(value)
  super(value)
  self.foreground = value
end

#parameter_namesObject



33
34
35
# File 'lib/glimmer/swt/custom/shape/arc.rb', line 33

def parameter_names
  [:x, :y, :width, :height, :start_angle, :arc_angle]
end

#post_add_contentObject



37
38
39
40
41
# File 'lib/glimmer/swt/custom/shape/arc.rb', line 37

def post_add_content
  @performing_post_add_content = true
  render
  @performing_post_add_content = false
end

#render(custom_parent_dom_element: nil, brand_new: false) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/glimmer/swt/custom/shape/arc.rb', line 48

def render(custom_parent_dom_element: nil, brand_new: false)
  return unless @performing_post_add_content
  the_parent_element = Native(`document.getElementById(#{parent.id})`)
  params = { type: `Two.Types.svg` }
  two = Native(`new Two(#{params})`)
  two.appendTo(the_parent_element)
  x = @args[0]
  y = @args[1]
  width = @args[2]
  height = @args[3]
  start_angle = -1*@args[4]
  arc_angle = -1*@args[5]
  end_angle = start_angle + arc_angle
  rx = width / 2.0
  ry = height / 2.0
  cx = x + rx
  cy = y + ry
  arc = two.makeArcSegment(cx, cy, 0, ry, 2*`Math.PI`*(start_angle)/360.0, 2*`Math.PI`*(end_angle)/360.0);
  arc.fill = background.to_css unless background.nil?
  arc.stroke = foreground.to_css unless foreground.nil?
  two.update
end