Class: Ea::Diagram::ElementRenderers::PackageRenderer
- Inherits:
-
BaseRenderer
- Object
- BaseRenderer
- Ea::Diagram::ElementRenderers::PackageRenderer
- Defined in:
- lib/ea/diagram/element_renderers/package_renderer.rb
Overview
Renderer for UML package elements
Instance Attribute Summary
Attributes inherited from BaseRenderer
Instance Method Summary collapse
-
#render_label(style) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity.
-
#render_shape(style) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity.
Methods inherited from BaseRenderer
#escape_text, #initialize, #render
Methods included from Util
#parse_ea_geometry, #parse_geometry_offsets, #style_to_css
Constructor Details
This class inherits a constructor from Ea::Diagram::ElementRenderers::BaseRenderer
Instance Method Details
#render_label(style) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ea/diagram/element_renderers/package_renderer.rb', line 35 def render_label(style) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity x = element[:x] || 0 y = element[:y] || 0 # Package name positioned in the tab area tab_height = 20 text_x = x + 30 # Center in the tab text_y = y + (tab_height / 2) + 5 <<~SVG <text x="#{text_x}" y="#{text_y}" text-anchor="middle" dominant-baseline="middle" font-family="#{style[:font_family]}" font-size="#{style[:font_size]}" font-weight="#{style[:font_weight] || 'bold'}" fill="#{style[:text_color] || '#000000'}" class="lutaml-diagram-package-name"> #{escape_text(element[:name])} </text> SVG end |
#render_shape(style) ⇒ Object
rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/ea/diagram/element_renderers/package_renderer.rb', line 8 def render_shape(style) # rubocop:disable Metrics/AbcSize,Metrics/CyclomaticComplexity x = element[:x] || 0 y = element[:y] || 0 width = element[:width] || 120 height = element[:height] || 80 # Package tab height tab_height = 20 # Draw package shape with tab <<~SVG <!-- Main package body --> <polygon points="#{x},#{y + tab_height} #{x + width},#{y + tab_height} #{x + width},#{y + height} #{x},#{y + height}" fill="#{style[:fill]}" stroke="#{style[:stroke]}" stroke-width="#{style[:stroke_width] || 2}" class="lutaml-diagram-package-shape" /> <!-- Package tab --> <polygon points="#{x + 10},#{y + tab_height} #{x + 50},#{y + tab_height} #{x + 50},#{y} #{x + 10},#{y}" fill="#{style[:fill]}" stroke="#{style[:stroke]}" stroke-width="#{style[:stroke_width] || 2}" class="lutaml-diagram-package-tab" /> SVG end |