Class: Lutaml::UmlRepository::Presenters::DiagramPresenter
- Inherits:
-
ElementPresenter
- Object
- ElementPresenter
- Lutaml::UmlRepository::Presenters::DiagramPresenter
- Defined in:
- lib/lutaml/uml_repository/presenters/diagram_presenter.rb
Overview
Presenter for UML Diagram elements
Coordinates the entire diagram rendering pipeline by:
-
Loading elements and connectors from the repository
-
Converting EA coordinates to SVG format
-
Using StyleResolver to merge EA data + config + defaults
-
Creating a DiagramRenderer wrapper
-
Generating SVG output via SvgRenderer
Defined Under Namespace
Classes: DiagramRendererWrapper
Instance Attribute Summary collapse
-
#config_path ⇒ Object
readonly
Returns the value of attribute config_path.
Attributes inherited from ElementPresenter
#context, #element, #repository
Instance Method Summary collapse
-
#connectors ⇒ Array<Hash>
Get connectors in the diagram.
-
#elements ⇒ Array<Hash>
Get elements in the diagram.
-
#initialize(diagram, repository, options = {}) ⇒ DiagramPresenter
constructor
A new instance of DiagramPresenter.
-
#svg_output(options = {}) ⇒ String
Generate SVG output for the diagram.
-
#to_hash ⇒ Object
Hash representation.
-
#to_table_row ⇒ Object
Table row for diagram.
-
#to_text ⇒ Object
Text output for diagram.
Constructor Details
#initialize(diagram, repository, options = {}) ⇒ DiagramPresenter
Returns a new instance of DiagramPresenter.
21 22 23 24 25 |
# File 'lib/lutaml/uml_repository/presenters/diagram_presenter.rb', line 21 def initialize(diagram, repository, = {}) super(diagram, repository) @config_path = [:config_path] @layout_engine = Ea::Diagram::LayoutEngine.new end |
Instance Attribute Details
#config_path ⇒ Object (readonly)
Returns the value of attribute config_path.
15 16 17 |
# File 'lib/lutaml/uml_repository/presenters/diagram_presenter.rb', line 15 def config_path @config_path end |
Instance Method Details
#connectors ⇒ Array<Hash>
Get connectors in the diagram
68 69 70 |
# File 'lib/lutaml/uml_repository/presenters/diagram_presenter.rb', line 68 def connectors build_connectors_data end |
#elements ⇒ Array<Hash>
Get elements in the diagram
61 62 63 |
# File 'lib/lutaml/uml_repository/presenters/diagram_presenter.rb', line 61 def elements build_elements_data end |
#svg_output(options = {}) ⇒ String
Generate SVG output for the diagram
Background color Enable interactive features
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/lutaml/uml_repository/presenters/diagram_presenter.rb', line 37 def svg_output( = {}) # rubocop:disable Metrics/MethodLength # Build diagram data structure diagram_data = { name: element.name, elements: build_elements_data, connectors: build_connectors_data, } # Create diagram renderer wrapper diagram_renderer = DiagramRendererWrapper.new(diagram_data, @layout_engine) # Create SVG renderer with configuration = .merge(config_path: config_path) svg_renderer = Ea::Diagram::SvgRenderer.new(diagram_renderer, ) # Generate and return SVG svg_renderer.render end |
#to_hash ⇒ Object
Hash representation
96 97 98 99 100 101 102 103 104 105 |
# File 'lib/lutaml/uml_repository/presenters/diagram_presenter.rb', line 96 def to_hash { type: "Diagram", name: element.name, diagram_type: element.diagram_type, package_name: element.package_name, elements_count: (element.diagram_objects || []).count, connectors_count: (element.diagram_links || []).count, } end |
#to_table_row ⇒ Object
Table row for diagram
86 87 88 89 90 91 92 93 |
# File 'lib/lutaml/uml_repository/presenters/diagram_presenter.rb', line 86 def to_table_row { type: "Diagram", name: element.name || "(unnamed)", details: "#{element.diagram_type} " \ "- #{(element.diagram_objects || []).count} elements", } end |
#to_text ⇒ Object
Text output for diagram
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/lutaml/uml_repository/presenters/diagram_presenter.rb', line 73 def to_text # rubocop:disable Metrics/AbcSize lines = [] lines << "Diagram: #{element.name}" lines << ("=" * 50) lines << "" lines << "Type: #{element.diagram_type}" lines << "Package: #{element.package_name || 'Unknown'}" lines << "Elements: #{(element.diagram_objects || []).count}" lines << "Connectors: #{(element.diagram_links || []).count}" lines.join("\n") end |