Class: CTioga2::Graphics::Legends::LegendLine
- Inherits:
-
LegendItem
- Object
- LegendItem
- CTioga2::Graphics::Legends::LegendLine
- Defined in:
- lib/ctioga2/graphics/legends/items.rb
Overview
A class representing the style of a single legend line (unrelated to a curve)
Instance Attribute Summary collapse
-
#style ⇒ Object
The style of the text, a Styles.FullTextStyle object.
-
#text ⇒ Object
The text of the line.
Instance Method Summary collapse
-
#draw(t, legend_style, x, y) ⇒ Object
Draw one single text line.
-
#initialize(text = "", style = {}) ⇒ LegendLine
constructor
A new instance of LegendLine.
-
#size(t, legend_style) ⇒ Object
Computes the size of the line.
Constructor Details
#initialize(text = "", style = {}) ⇒ LegendLine
Returns a new instance of LegendLine.
105 106 107 108 109 110 111 |
# File 'lib/ctioga2/graphics/legends/items.rb', line 105 def initialize(text = "", style = {}) super() @text = text @style = Styles::FullTextStyle.from_hash(style) @style.justification ||= Tioga::FigureConstants::LEFT_JUSTIFIED end |
Instance Attribute Details
#style ⇒ Object
The style of the text, a Styles.FullTextStyle object.
103 104 105 |
# File 'lib/ctioga2/graphics/legends/items.rb', line 103 def style @style end |
#text ⇒ Object
The text of the line
100 101 102 |
# File 'lib/ctioga2/graphics/legends/items.rb', line 100 def text @text end |
Instance Method Details
#draw(t, legend_style, x, y) ⇒ Object
Draw one single text line.
114 115 116 117 |
# File 'lib/ctioga2/graphics/legends/items.rb', line 114 def draw(t, legend_style, x, y) y = get_baseline_y(t, legend_style, y) @style.draw_text(t, @text, x, y, legend_name) end |
#size(t, legend_style) ⇒ Object
Computes the size of the line. Height should always be accurate, but width can be 0 sometimes…
121 122 123 |
# File 'lib/ctioga2/graphics/legends/items.rb', line 121 def size(t, legend_style) return text_size(t, legend_style) end |