Class: CTioga2::Graphics::Elements::Region
- Inherits:
-
RedirectingContainer
- Object
- TiogaElement
- Container
- RedirectingContainer
- CTioga2::Graphics::Elements::Region
- Defined in:
- lib/ctioga2/graphics/elements/region.rb
Overview
A Region is an object that draws filled regions among its “elements”. It is a fake container in the sense that all the elements are actually forwarded to the parent.
Constant Summary
Constants inherited from TiogaElement
TiogaElement::StyleBaseOptions
Instance Attribute Summary collapse
-
#curves ⇒ Object
The curves which delimit the region.
-
#fill_style ⇒ Object
The fill style.
-
#reversed_fill_style ⇒ Object
The fill style for reversed polarity.
Attributes inherited from Container
#elements, #gp_cache, #legend_area, #legend_item_target, #legend_storage, #root_object, #subframe
Attributes inherited from TiogaElement
#clipped, #depth, #hidden, #location, #object_classes, #object_id, #object_parent, #parent
Instance Method Summary collapse
-
#add_element(element) ⇒ Object
Adds an element.
-
#initialize(parent, root, opts) ⇒ Region
constructor
Creates a new empty region.
-
#set_from_hash(hash) ⇒ Object
Sets the various things from hash.
Methods inherited from RedirectingContainer
Methods inherited from Container
#actual_subframe, #add_legend_item, #do, #each_item, #enter_legend_subcontainer, #size
Methods inherited from TiogaElement
all_styles, base_style, #check_styled, define_style, #do, find_object, find_objects, #get_style, #has_style?, inherited, #inspect, register_object, register_style, #setup_style, #style_class, style_class, style_name, #style_name, styled_classes, #update_style
Methods included from Log
context, counts, debug, error, fatal, #format_exception, #identify, info, init_logger, log_to, logger, set_level, #spawn, warn
Constructor Details
#initialize(parent, root, opts) ⇒ Region
Creates a new empty region
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/ctioga2/graphics/elements/region.rb', line 44 def initialize(parent, root, opts) setup_style(parent, opts) # A reason why we don't use the superclass constructor ? @parent = parent @clipped = true # clipped by default ! # elements to be given to tioga @curves = [] @root_object = root @legend_area = nil @fill_style = Styles::FillStyle.new @fill_style.color = [0.7,0.7,0.7] # For reversed polarity @reversed_fill_style = Styles::FillStyle.new end |
Instance Attribute Details
#curves ⇒ Object
The curves which delimit the region
35 36 37 |
# File 'lib/ctioga2/graphics/elements/region.rb', line 35 def curves @curves end |
#fill_style ⇒ Object
The fill style
38 39 40 |
# File 'lib/ctioga2/graphics/elements/region.rb', line 38 def fill_style @fill_style end |
#reversed_fill_style ⇒ Object
The fill style for reversed polarity
41 42 43 |
# File 'lib/ctioga2/graphics/elements/region.rb', line 41 def reversed_fill_style @reversed_fill_style end |
Instance Method Details
#add_element(element) ⇒ Object
Adds an element. Actually forwards it to the parent.
66 67 68 69 70 71 72 |
# File 'lib/ctioga2/graphics/elements/region.rb', line 66 def add_element(element) parent.add_element(element) if element.respond_to?(:curve_style) && element.curve_style.region_position @curves << element end end |
#set_from_hash(hash) ⇒ Object
Sets the various things from hash.
75 76 77 78 79 |
# File 'lib/ctioga2/graphics/elements/region.rb', line 75 def set_from_hash(hash) @fill_style.set_from_hash(hash) # Reversed isn't what I want... @reversed_fill_style.set_from_hash(hash, 'reversed_%s') end |