Class: CTioga2::Graphics::Elements::Container
- Inherits:
-
TiogaElement
- Object
- TiogaElement
- CTioga2::Graphics::Elements::Container
- Defined in:
- lib/ctioga2/graphics/elements/containers.rb
Overview
A Container is a drawable object that contains several others, its #elements.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#elements ⇒ Object
All drawable Element contained in this object.
-
#legend_area ⇒ Object
The Legends::LegendArea dedicated to the display of the legend of this object and its children, or nil if the parent should handle the display.
-
#legend_storage ⇒ Object
The Legends::LegendStorage that holds all the legends of the object.
-
#root_object ⇒ Object
A reference to the RootObject.
-
#subframe ⇒ Object
The subframe position of this element with respect to its parent.
Attributes inherited from TiogaElement
Instance Method Summary collapse
-
#actual_subframe(t) ⇒ Object
Sometimes, the value of the subframe is nil and determined during the plot.
-
#add_element(element) ⇒ Object
Adds an element.
-
#add_legend_item(item) ⇒ Object
Adds a legend item to the #associated_legend_storage.
-
#initialize(parent = nil, root = nil) ⇒ Container
constructor
Creates an empty new Container with the given parent.
-
#size ⇒ Object
Returns the number of child elements.
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) ⇒ Container
Creates an empty new Container with the given parent.
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/ctioga2/graphics/elements/containers.rb', line 51 def initialize(parent = nil, root = nil) @parent = parent # elements to be given to tioga @elements = [] # By default the frame takes up all the space. @subframe = Types::MarginsBox.new(0, 0, 0, 0) @root_object = root @legend_storage = Legends::LegendStorage.new # By default, don't display legends. @legend_area = nil end |
Instance Attribute Details
#elements ⇒ Object
All drawable Element contained in this object. It may contain other Container subobjects.
32 33 34 |
# File 'lib/ctioga2/graphics/elements/containers.rb', line 32 def elements @elements end |
#legend_area ⇒ Object
The Legends::LegendArea dedicated to the display of the legend of this object and its children, or nil if the parent should handle the display.
44 45 46 |
# File 'lib/ctioga2/graphics/elements/containers.rb', line 44 def legend_area @legend_area end |
#legend_storage ⇒ Object
The Legends::LegendStorage that holds all the legends of the object
48 49 50 |
# File 'lib/ctioga2/graphics/elements/containers.rb', line 48 def legend_storage @legend_storage end |
#root_object ⇒ Object
A reference to the RootObject
39 40 41 |
# File 'lib/ctioga2/graphics/elements/containers.rb', line 39 def root_object @root_object end |
#subframe ⇒ Object
The subframe position of this element with respect to its parent. It is a Types::Box object.
36 37 38 |
# File 'lib/ctioga2/graphics/elements/containers.rb', line 36 def subframe @subframe end |
Instance Method Details
#actual_subframe(t) ⇒ Object
Sometimes, the value of the subframe is nil and determined during the plot. This function is guaranteed to return the correct value. It takes a reference to a FigureMaker object.
76 77 78 |
# File 'lib/ctioga2/graphics/elements/containers.rb', line 76 def actual_subframe(t) return @subframe end |
#add_element(element) ⇒ Object
Adds an element
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/ctioga2/graphics/elements/containers.rb', line 81 def add_element(element) element.parent = self @elements << element # If the element has a curve_style, we add it as a # CurveLegend if element.respond_to?(:curve_style) and element.curve_style.has_legend? add_legend_item(Legends::CurveLegend.new(element.curve_style)) elsif element.is_a? Container add_legend_item(element) end # We call LocationStyle#finalize! if possible if(self.respond_to?(:style) and element.respond_to?(:location)) element.location.finalize!(self.style) end end |
#add_legend_item(item) ⇒ Object
Adds a legend item to the #associated_legend_storage
102 103 104 |
# File 'lib/ctioga2/graphics/elements/containers.rb', line 102 def add_legend_item(item) @legend_storage.add_item(item) end |
#size ⇒ Object
Returns the number of child elements
69 70 71 |
# File 'lib/ctioga2/graphics/elements/containers.rb', line 69 def size return @elements.size end |