class DYI::Shape::Text
Constants
- BASELINE_VALUES
- DEFAULT_LINE_HEIGHT
Attributes
format[R]
line_height[RW]
text[RW]
Public Class Methods
new(point, text=nil, options={})
click to toggle source
@param [Coordinate] point a start coordinate of the text @param [String] text a text that is displayed @option options [Painting] :painting painting status of the shape @option options [Font] :font font status of the text @option options [String] :description the description of this shape @option options [String] :title the title of this shape
# File lib/dyi/shape/base.rb, line 784 def initialize(point, text=nil, options={}) @point = Coordinate.new(point || [0,0]) @text = text @attributes = init_attributes(options) end
Public Instance Methods
dy()
click to toggle source
# File lib/dyi/shape/base.rb, line 798 def dy font_height * (line_height || DEFAULT_LINE_HEIGHT) end
font_height()
click to toggle source
# File lib/dyi/shape/base.rb, line 794 def font_height font.draw_size end
format=(value)
click to toggle source
# File lib/dyi/shape/base.rb, line 790 def format=(value) @format = value && value.to_s end
formated_text()
click to toggle source
# File lib/dyi/shape/base.rb, line 802 def formated_text if @format if @text.kind_of?(Numeric) @text.strfnum(@format) elsif @text.respond_to?(:strftime) @text.strftime(@format) else @text.to_s end else @text.to_s end end
string_format()
click to toggle source
# File lib/ironruby.rb, line 137 def string_format format = System::Drawing::StringFormat.new format.alignment = case attributes[:text_anchor] when 'start' then System::Drawing::StringAlignment.near when 'middle' then System::Drawing::StringAlignment.center when 'end' then System::Drawing::StringAlignment.far else System::Drawing::StringAlignment.near end format.line_alignment = case attributes[:alignment_baseline] when 'baseline' then System::Drawing::StringAlignment.far when 'top' then System::Drawing::StringAlignment.near when 'middle' then System::Drawing::StringAlignment.center when 'bottom' then System::Drawing::StringAlignment.far else System::Drawing::StringAlignment.far end format end
write_as(formatter, io=$>)
click to toggle source
# File lib/dyi/shape/base.rb, line 816 def write_as(formatter, io=$>) formatter.write_text(self, io, &(block_given? ? Proc.new : nil)) end
Private Instance Methods
init_attributes(options)
click to toggle source
Calls superclass method
DYI::Shape::Base#init_attributes
# File lib/dyi/shape/base.rb, line 822 def init_attributes(options) options = super format = options.delete(:format) @format = format && format.to_s line_height = options.delete(:line_height) @line_height = line_height || DEFAULT_LINE_HEIGHT options end