class CTioga2::Graphics::Styles::TextLabel
A label.
Public Class Methods
new(text = nil, loc = nil)
click to toggle source
Calls superclass method
# File lib/ctioga2/graphics/styles/texts.rb, line 194 def initialize(text = nil, loc = nil) super() @text = text @loc = loc end
Public Instance Methods
draw(t, default = nil, measure = nil)
click to toggle source
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.
# File lib/ctioga2/graphics/styles/texts.rb, line 203 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)
click to toggle source
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.
# File lib/ctioga2/graphics/styles/texts.rb, line 213 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
Protected Instance Methods
prepare_label_dict(t, default = nil, measure = nil)
click to toggle source
# File lib/ctioga2/graphics/styles/texts.rb, line 228 def prepare_label_dict(t, default = nil, measure = nil) dict = prepare_show_text_dict(t, @text, @loc, nil, measure) if default for attribute in %w(scale angle shift) if ! dict.key?(attribute) dict[attribute] = t.send("#{default}_#{attribute}") end end end return dict end