Class: CTioga2::Graphics::Styles::TextLabel
- Inherits:
-
FullTextStyle
- Object
- BasicStyle
- BaseTextStyle
- FullTextStyle
- CTioga2::Graphics::Styles::TextLabel
- Defined in:
- lib/ctioga2/graphics/styles/texts.rb
Overview
A label.
Constant Summary
Constants inherited from BasicStyle
Instance Attribute Summary collapse
-
#loc ⇒ Object
The location of the label.
-
#text ⇒ Object
The text of the label.
Attributes inherited from FullTextStyle
Attributes inherited from BaseTextStyle
#alignement, #angle, #justification, #scale, #shift
Instance Method Summary collapse
-
#draw(t, default = nil, measure = nil) ⇒ Object
Draw the label, if #text is not nil or false.
-
#initialize(text = nil) ⇒ TextLabel
constructor
A new instance of TextLabel.
-
#label_extension(t, default = nil, location = nil) ⇒ Object
Gets the extension of the label, in units of text height.
Methods inherited from BaseTextStyle
Methods inherited from BasicStyle
attr_accessor, attributes, from_hash, #instance_variable_defined?, #set_from_hash, #to_hash, #update_from_other
Constructor Details
#initialize(text = nil) ⇒ TextLabel
Returns a new instance of TextLabel.
116 117 118 |
# File 'lib/ctioga2/graphics/styles/texts.rb', line 116 def initialize(text = nil) @text = text end |
Instance Attribute Details
#loc ⇒ Object
This will have to eventually use PlotLocation, as it
The location of the label.
makes much more sense.
114 115 116 |
# File 'lib/ctioga2/graphics/styles/texts.rb', line 114 def loc @loc end |
#text ⇒ Object
The text of the label. nil or false means there will be no text displayed
108 109 110 |
# File 'lib/ctioga2/graphics/styles/texts.rb', line 108 def text @text end |
Instance Method Details
#draw(t, default = nil, measure = nil) ⇒ Object
Draw the label, if #text is not nil or false. Attributes such as scale, shift and angle are taken from the corresponding default if default isn’t nil.
123 124 125 126 127 128 |
# File 'lib/ctioga2/graphics/styles/texts.rb', line 123 def draw(t, default = nil, measure = nil) if @text dict = prepare_label_dict(t, default, measure) t.show_text(dict) end end |
#label_extension(t, default = nil, location = nil) ⇒ Object
Gets the extension of the label, in units of text height. Default values for the various parameters are taken from the default parameter if they are not specified.
133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/ctioga2/graphics/styles/texts.rb', line 133 def label_extension(t, default = nil, location = nil) if @text dict = prepare_label_dict(t, default, nil) extra = 0 if location extra = location.label_extra_space(t) end return (dict['shift'] + extra) * dict['scale'] else return 0 end end |