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
BasicStyle::AllStyles, BasicStyle::OldAttrAccessor
Instance Method Summary collapse
-
#draw(t, default = nil, measure = nil) ⇒ Object
Draw the label, if #text is not nil or false.
-
#initialize(text = nil, loc = 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
#draw_text, #hash_for_tioga, #scale_dy, #shift_dy
Methods inherited from BasicStyle
attr_accessor, attribute_type, attribute_types, attributes, deprecated_attribute, from_hash, inherited, #instance_variable_defined?, options_hash, #set_from_hash, sub_style, sub_styles, #to_hash, typed_attribute, #update_from_other
Constructor Details
#initialize(text = nil, loc = nil) ⇒ TextLabel
Returns a new instance of TextLabel.
151 152 153 154 155 |
# File 'lib/ctioga2/graphics/styles/texts.rb', line 151 def initialize(text = nil, loc = nil) super() @text = text @loc = loc 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.
160 161 162 163 164 165 |
# File 'lib/ctioga2/graphics/styles/texts.rb', line 160 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.
170 171 172 173 174 175 176 177 178 179 180 181 |
# File 'lib/ctioga2/graphics/styles/texts.rb', line 170 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 |