Class: Thinreports::SectionReport::Renderer::StackViewRenderer
- Inherits:
-
Object
- Object
- Thinreports::SectionReport::Renderer::StackViewRenderer
- Defined in:
- lib/thinreports/section_report/pdf/renderer/stack_view_renderer.rb
Defined Under Namespace
Classes: RowLayout
Instance Method Summary collapse
-
#initialize(pdf) ⇒ StackViewRenderer
constructor
A new instance of StackViewRenderer.
- #render(shape) ⇒ Object
- #section_height(shape) ⇒ Object
Constructor Details
#initialize(pdf) ⇒ StackViewRenderer
Returns a new instance of StackViewRenderer.
9 10 11 12 |
# File 'lib/thinreports/section_report/pdf/renderer/stack_view_renderer.rb', line 9 def initialize(pdf) @pdf = pdf @row_renderer = Renderer::StackViewRowRenderer.new(pdf) end |
Instance Method Details
#render(shape) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/thinreports/section_report/pdf/renderer/stack_view_renderer.rb', line 27 def render(shape) doc = pdf.pdf x, y, w = shape.format.attributes.values_at('x', 'y', 'width') doc.bounding_box([x, doc.bounds.height - y], width: w, height: section_height(shape)) do shape.rows.each do |row| row_renderer.render(row) end end end |
#section_height(shape) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/thinreports/section_report/pdf/renderer/stack_view_renderer.rb', line 16 def section_height(shape) row_layouts = build_row_layouts(shape.rows) total_row_height = row_layouts.sum(0, &:height) float_content_bottom = row_layouts .map { |l| row_renderer.calc_float_content_bottom(l.row) + l.top } .max.to_f [total_row_height, float_content_bottom].max end |