Class: Ea::Svg::ElementBox
- Inherits:
-
Object
- Object
- Ea::Svg::ElementBox
- Defined in:
- lib/ea/svg/element_box.rb
Overview
Renders one DiagramElement as a 3-compartment UML class box, matching EA's drawing convention:
┌─────────────────────────┐
│ «Stereotype» │ ← header (stereotype + name)
│ qualified::Name │
├─────────────────────────┤
│ + attr1: Type [0..1] │ ← attributes
│ + attr2: Type [0..*] │
├─────────────────────────┤
│ + op1(arg: T): T │ ← operations
└─────────────────────────┘
The stored element bounds are honored as the outer rectangle; internal layout (header / attrs / ops heights) is computed proportionally based on line count.
Constant Summary collapse
- HEADER_LINE_HEIGHT =
17- ATTR_LINE_HEIGHT =
17- OP_LINE_HEIGHT =
17- TOP_PADDING =
17- STEREOTYPE_COLORS =
{ "featuretype" => "#FFFFCC", # yellow "feature" => "#FFFFCC", "type" => "#CCFFCC", # green "datatype" => "#FFCCFF", # pink "basictype" => "#FFCCFF", "codelist" => "#FFCCFF", "enumeration" => "#FFCCFF", "union" => "#F0E68C", # khaki "adeelement" => "#F5F5DC" # beige }.freeze
- DEFAULT_FILL =
beige
"#FFFFFF"
Instance Attribute Summary collapse
-
#element ⇒ Object
readonly
Returns the value of attribute element.
-
#model_index ⇒ Object
readonly
Returns the value of attribute model_index.
Instance Method Summary collapse
-
#initialize(element, model_index:) ⇒ ElementBox
constructor
A new instance of ElementBox.
- #render ⇒ Object
Constructor Details
#initialize(element, model_index:) ⇒ ElementBox
Returns a new instance of ElementBox.
44 45 46 47 |
# File 'lib/ea/svg/element_box.rb', line 44 def initialize(element, model_index:) @element = element @model_index = model_index end |
Instance Attribute Details
#element ⇒ Object (readonly)
Returns the value of attribute element.
42 43 44 |
# File 'lib/ea/svg/element_box.rb', line 42 def element @element end |
#model_index ⇒ Object (readonly)
Returns the value of attribute model_index.
42 43 44 |
# File 'lib/ea/svg/element_box.rb', line 42 def model_index @model_index end |
Instance Method Details
#render ⇒ Object
49 50 51 52 53 54 55 56 57 |
# File 'lib/ea/svg/element_box.rb', line 49 def render return "" unless element.bounds b = normalize_bounds(element.bounds) classifier = bound_classifier return render_simple_box(b) unless classifier render_class_box(b, classifier) end |