class Thinreports::Generator::PDF::Drawer::Page
Public Class Methods
new(pdf, format)
click to toggle source
@param (see PDF::Drawer::Base#initialize)
Calls superclass method
Thinreports::Generator::PDF::Drawer::Base::new
# File lib/thinreports/generator/pdf/drawer/page.rb, line 9 def initialize(pdf, format) super @lists = {} end
Public Instance Methods
draw(page)
click to toggle source
@param [Thinreports::Report::Page] page
# File lib/thinreports/generator/pdf/drawer/page.rb, line 15 def draw(page) manager = page.manager manager.format.shapes.each_key do |id| shape = manager.final_shape(id) next unless shape shape = shape.internal if shape.type_of?(Core::Shape::PageNumber::TYPE_NAME) # Do not draw pageno if is not for Report draw_pageno_shape(shape, page) if page.count? && shape.for_report? else draw_shape(shape) end end end
Private Instance Methods
create_basic_shape_stamp(shape)
click to toggle source
@param [Thinreports::Core::Shape::Base::Internal] shape
# File lib/thinreports/generator/pdf/drawer/page.rb, line 73 def create_basic_shape_stamp(shape) if shape.type_of?('text') create_text_stamp(shape) elsif shape.type_of?('image') create_image_stamp(shape) elsif shape.type_of?('ellipse') create_ellipse_stamp(shape) elsif shape.type_of?('rect') create_rect_stamp(shape) elsif shape.type_of?('line') create_line_stamp(shape) end end
create_ellipse_stamp(shape)
click to toggle source
# File lib/thinreports/generator/pdf/drawer/page.rb, line 102 def create_ellipse_stamp(shape) create_pdf_stamp(shape) do @pdf.draw_shape_ellipse(shape) end end
create_image_stamp(shape)
click to toggle source
# File lib/thinreports/generator/pdf/drawer/page.rb, line 88 def create_image_stamp(shape) create_pdf_stamp(shape) do @pdf.draw_shape_image(shape) end end
create_line_stamp(shape)
click to toggle source
# File lib/thinreports/generator/pdf/drawer/page.rb, line 109 def create_line_stamp(shape) create_pdf_stamp(shape) do @pdf.draw_shape_line(shape) end end
create_rect_stamp(shape)
click to toggle source
# File lib/thinreports/generator/pdf/drawer/page.rb, line 95 def create_rect_stamp(shape) create_pdf_stamp(shape) do @pdf.draw_shape_rect(shape) end end
create_text_stamp(shape)
click to toggle source
# File lib/thinreports/generator/pdf/drawer/page.rb, line 116 def create_text_stamp(shape) create_pdf_stamp(shape) do @pdf.draw_shape_text(shape) end end
draw_iblock_shape(shape)
click to toggle source
@see draw_shape
# File lib/thinreports/generator/pdf/drawer/page.rb, line 68 def draw_iblock_shape(shape) @pdf.draw_shape_iblock(shape) end
draw_list_shape(shape)
click to toggle source
@see draw_shape
# File lib/thinreports/generator/pdf/drawer/page.rb, line 57 def draw_list_shape(shape) drawer = @lists[shape.id] ||= List.new(@pdf, shape.format) drawer.draw(shape) end
draw_pageno_shape(shape, page)
click to toggle source
# File lib/thinreports/generator/pdf/drawer/page.rb, line 52 def draw_pageno_shape(shape, page) @pdf.draw_shape_pageno(shape, page.no, page.report.page_count) end
draw_shape(shape)
click to toggle source
# File lib/thinreports/generator/pdf/drawer/page.rb, line 35 def draw_shape(shape) if shape.type_of?(Core::Shape::TextBlock::TYPE_NAME) draw_tblock_shape(shape) elsif shape.type_of?(Core::Shape::List::TYPE_NAME) draw_list_shape(shape) elsif shape.type_of?(Core::Shape::ImageBlock::TYPE_NAME) draw_iblock_shape(shape) else id = shape.identifier unless @stamps.include?(id) create_basic_shape_stamp(shape) @stamps << id end pdf_stamp(shape) end end
draw_tblock_shape(shape)
click to toggle source
@see draw_shape
# File lib/thinreports/generator/pdf/drawer/page.rb, line 63 def draw_tblock_shape(shape) @pdf.draw_shape_tblock(shape) end