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.
26 27 28 29 30 |
# File 'lib/lutaml/uml_repository/presenters/diagram_presenter.rb', line 26 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.
20 21 22 |
# File 'lib/lutaml/uml_repository/presenters/diagram_presenter.rb', line 20 def config_path @config_path end |
Instance Method Details
#connectors ⇒ Array<Hash>
Get connectors in the diagram
73 74 75 |
# File 'lib/lutaml/uml_repository/presenters/diagram_presenter.rb', line 73 def connectors build_connectors_data end |
#elements ⇒ Array<Hash>
Get elements in the diagram
66 67 68 |
# File 'lib/lutaml/uml_repository/presenters/diagram_presenter.rb', line 66 def elements build_elements_data end |
#svg_output(options = {}) ⇒ String
Generate SVG output for the diagram
Background color Enable interactive features
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/lutaml/uml_repository/presenters/diagram_presenter.rb', line 42 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
101 102 103 104 105 106 107 108 109 110 |
# File 'lib/lutaml/uml_repository/presenters/diagram_presenter.rb', line 101 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
91 92 93 94 95 96 97 98 |
# File 'lib/lutaml/uml_repository/presenters/diagram_presenter.rb', line 91 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
78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/lutaml/uml_repository/presenters/diagram_presenter.rb', line 78 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 |