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.
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, #legend_area, #legend_storage, #root_object, #subframe
Attributes inherited from TiogaElement
Instance Method Summary collapse
-
#add_element(element) ⇒ Object
Adds an element.
-
#initialize(parent = nil, root = nil) ⇒ Region
constructor
Creates a new empty region.
-
#set_from_hash(hash) ⇒ Object
Sets the various things from hash.
Methods inherited from RedirectingContainer
#add_legend_item, #legend_area=, #style
Methods inherited from Container
#actual_subframe, #add_legend_item, #size
Methods inherited from TiogaElement
Methods included from Log
debug, error, fatal, #format_exception, #identify, info, init_logger, logger, set_level, #spawn, warn
Constructor Details
#initialize(parent = nil, root = nil) ⇒ Region
Creates a new empty region
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ctioga2/graphics/elements/region.rb', line 44 def initialize(parent = nil, root = nil) @parent = parent # 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.
62 63 64 65 66 67 68 |
# File 'lib/ctioga2/graphics/elements/region.rb', line 62 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.
71 72 73 74 75 |
# File 'lib/ctioga2/graphics/elements/region.rb', line 71 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 |