Module: Thinreports::BasicReport::Generator::PDF::DrawShape
- Included in:
- Document
- Defined in:
- lib/thinreports/basic_report/generator/pdf/document/draw_shape.rb
Instance Method Summary collapse
- #draw_shape_ellipse(shape) ⇒ Object
- #draw_shape_iblock(shape) ⇒ Object
- #draw_shape_image(shape) ⇒ Object
- #draw_shape_line(shape, dy1 = 0, dy2 = 0) ⇒ Object
- #draw_shape_pageno(shape, page_no, page_count) ⇒ Object
- #draw_shape_rect(shape, dheight = 0) ⇒ Object
- #draw_shape_tblock(shape, height: nil, overflow: nil, &block) ⇒ Object
- #draw_shape_text(shape, dheight = 0) ⇒ Object
- #shape_iblock_dimenions(shape) ⇒ Object
Instance Method Details
#draw_shape_ellipse(shape) ⇒ Object
85 86 87 88 |
# File 'lib/thinreports/basic_report/generator/pdf/document/draw_shape.rb', line 85 def draw_shape_ellipse(shape) cx, cy, rx, ry = shape.format.attributes.values_at('cx', 'cy', 'rx', 'ry') ellipse(cx, cy, rx, ry, build_graphic_attributes(shape.style.finalized_styles)) end |
#draw_shape_iblock(shape) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/thinreports/basic_report/generator/pdf/document/draw_shape.rb', line 47 def draw_shape_iblock(shape) return if blank_value?(shape.src) x, y, w, h = shape.format.attributes.values_at('x', 'y', 'width', 'height') style = shape.style.finalized_styles image_box( shape.src, x, y, w, h, position_x: image_position_x(style['position-x']), position_y: image_position_y(style['position-y']), offset_x: style['offset-x'], offset_y: style['offset-y'] ) end |
#draw_shape_image(shape) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/thinreports/basic_report/generator/pdf/document/draw_shape.rb', line 39 def draw_shape_image(shape) x, y, w, h = shape.format.attributes.values_at('x', 'y', 'width', 'height') image_data = shape.format.attributes['data'] base64image(image_data['base64'], x, y, w, h) end |
#draw_shape_line(shape, dy1 = 0, dy2 = 0) ⇒ Object
91 92 93 94 |
# File 'lib/thinreports/basic_report/generator/pdf/document/draw_shape.rb', line 91 def draw_shape_line(shape, dy1 = 0, dy2 = 0) x1, y1, x2, y2 = shape.format.attributes.values_at('x1', 'y1', 'x2', 'y2') line(x1, y1 + dy1, x2, y2 + dy2, build_graphic_attributes(shape.style.finalized_styles)) end |
#draw_shape_pageno(shape, page_no, page_count) ⇒ Object
31 32 33 34 35 36 |
# File 'lib/thinreports/basic_report/generator/pdf/document/draw_shape.rb', line 31 def draw_shape_pageno(shape, page_no, page_count) x, y, w, h = shape.format.attributes.values_at('x', 'y', 'width', 'height') attrs = build_text_attributes(shape.style.finalized_styles) text_box(shape.build_format(page_no, page_count), x, y, w, h, attrs) end |
#draw_shape_rect(shape, dheight = 0) ⇒ Object
97 98 99 100 101 102 103 |
# File 'lib/thinreports/basic_report/generator/pdf/document/draw_shape.rb', line 97 def draw_shape_rect(shape, dheight = 0) x, y, w, h = shape.format.attributes.values_at('x', 'y', 'width', 'height') rect_attributes = build_graphic_attributes(shape.style.finalized_styles) do |attrs| attrs[:radius] = shape.format.attributes['border-radius'] end rect(x, y, w, h + dheight, rect_attributes) end |
#draw_shape_tblock(shape, height: nil, overflow: nil, &block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/thinreports/basic_report/generator/pdf/document/draw_shape.rb', line 12 def draw_shape_tblock(shape, height: nil, overflow: nil, &block) x, y, w = shape.format.attributes.values_at('x', 'y', 'width') h = height || shape.format.attributes['height'] content = shape.real_value.to_s return if content.empty? attrs = build_text_attributes(shape.style.finalized_styles) attrs[:overflow] = overflow if overflow unless shape.multiple? content = content.tr("\n", ' ') attrs[:single] = true end text_box(content, x, y, w, h, attrs, &block) end |
#draw_shape_text(shape, dheight = 0) ⇒ Object
76 77 78 79 80 81 82 |
# File 'lib/thinreports/basic_report/generator/pdf/document/draw_shape.rb', line 76 def draw_shape_text(shape, dheight = 0) x, y, w, h = shape.format.attributes.values_at('x', 'y', 'width', 'height') text( shape.texts.join("\n"), x, y, w, h + dheight, build_text_attributes(shape.style.finalized_styles) ) end |
#shape_iblock_dimenions(shape) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/thinreports/basic_report/generator/pdf/document/draw_shape.rb', line 62 def shape_iblock_dimenions(shape) return nil if blank_value?(shape.src) x, y, w, h = shape.format.attributes.values_at('x', 'y', 'width', 'height') style = shape.style.finalized_styles image_dimensions( shape.src, x, y, w, h, position_x: image_position_x(style['position-x']), position_y: image_position_y(style['position-y']) ) end |