Class: Ea::Svg::EaEmitter::Element::PackageShapeRenderer
- Inherits:
-
Object
- Object
- Ea::Svg::EaEmitter::Element::PackageShapeRenderer
- Defined in:
- lib/ea/svg/ea_emitter/element/package_shape_renderer.rb
Overview
Emits the shape <g> for a Package element: a rectangular
body polygon plus a "tab" polygon on top. EA renders every
Package as this folder-like silhouette regardless of diagram
type.
Layout (element bounds cover tab + body together):
┌───┐
│tab│ ← top TAB_HEIGHT_SINGLE rows ABOVE element bounds;
│ │ when a stereotype is present, the tab grows to
└───┴──────────┐ TAB_HEIGHT_DOUBLE rows and extends INTO
│ │ the bounds; the name renders bold,
│ body │ left-aligned. The body always starts
│ │ where the tab ends.
└───────────────┘
Constant Summary collapse
- TAB_HEIGHT_SINGLE =
20- TAB_HEIGHT_DOUBLE =
36- TAB_LABEL_PADDING =
10- TAB_LABEL_X_OFFSET =
5- TAB_LABEL_Y_OFFSET =
13- TAB_LINE_OFFSET =
13- DEFAULT_TAB_WIDTH =
105
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(bounds, fill, stroke, stroke_width, label, stereotype, family, size, size_unit, text_fill) ⇒ PackageShapeRenderer
constructor
A new instance of PackageShapeRenderer.
- #to_svg ⇒ Object
Constructor Details
#initialize(bounds, fill, stroke, stroke_width, label, stereotype, family, size, size_unit, text_fill) ⇒ PackageShapeRenderer
Returns a new instance of PackageShapeRenderer.
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ea/svg/ea_emitter/element/package_shape_renderer.rb', line 39 def initialize(bounds, fill, stroke, stroke_width, label, stereotype, family, size, size_unit, text_fill) @bounds = bounds @fill = fill @stroke = stroke @stroke_width = stroke_width @label = label @stereotype = stereotype @family = family @size = size @size_unit = size_unit @text_fill = text_fill end |
Class Method Details
.render(bounds, fill:, stroke:, stroke_width:, label: nil, stereotype: nil, family: "Carlito", size: 7, size_unit: "pt", text_fill: "#000000") ⇒ Object
32 33 34 35 36 37 |
# File 'lib/ea/svg/ea_emitter/element/package_shape_renderer.rb', line 32 def self.render(bounds, fill:, stroke:, stroke_width:, label: nil, stereotype: nil, family: "Carlito", size: 7, size_unit: "pt", text_fill: "#000000") new(bounds, fill, stroke, stroke_width, label, stereotype, family, size, size_unit, text_fill).to_svg end |
Instance Method Details
#to_svg ⇒ Object
53 54 55 56 57 |
# File 'lib/ea/svg/ea_emitter/element/package_shape_renderer.rb', line 53 def to_svg parts = [" #{body_polygon}", " #{tab_polygon}"] parts += header_text_blocks if has_label? %(<g style="#{group_style}">\n#{parts.join("\n")}\n</g>) end |