Class: Lutaml::Ea::Diagram::DiagramRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/lutaml/ea/diagram.rb

Overview

Main entry point for diagram rendering

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(diagram_data) ⇒ DiagramRenderer

Returns a new instance of DiagramRenderer.



35
36
37
38
39
# File 'lib/lutaml/ea/diagram.rb', line 35

def initialize(diagram_data)
  @diagram_data = diagram_data
  @layout_engine = LayoutEngine.new
  @style_parser = StyleParser.new
end

Instance Attribute Details

#diagram_dataObject (readonly)

Returns the value of attribute diagram_data.



33
34
35
# File 'lib/lutaml/ea/diagram.rb', line 33

def diagram_data
  @diagram_data
end

#layout_engineObject (readonly)

Returns the value of attribute layout_engine.



33
34
35
# File 'lib/lutaml/ea/diagram.rb', line 33

def layout_engine
  @layout_engine
end

#style_parserObject (readonly)

Returns the value of attribute style_parser.



33
34
35
# File 'lib/lutaml/ea/diagram.rb', line 33

def style_parser
  @style_parser
end

Instance Method Details

#boundsHash

Get diagram bounds for viewport calculation

Returns:

  • (Hash)

    Bounds with x, y, width, height



50
51
52
# File 'lib/lutaml/ea/diagram.rb', line 50

def bounds
  layout_engine.calculate_bounds(diagram_data)
end

#connectorsArray

Get all connectors in the diagram

Returns:

  • (Array)

    Array of connector elements



62
63
64
# File 'lib/lutaml/ea/diagram.rb', line 62

def connectors
  diagram_data[:connectors] || []
end

#elementsArray

Get all elements in the diagram

Returns:

  • (Array)

    Array of diagram elements



56
57
58
# File 'lib/lutaml/ea/diagram.rb', line 56

def elements
  diagram_data[:elements] || []
end

#render_svg(options = {}) ⇒ String

Render the complete diagram as SVG

Returns:

  • (String)

    SVG content



43
44
45
46
# File 'lib/lutaml/ea/diagram.rb', line 43

def render_svg(options = {})
  svg_renderer = SvgRenderer.new(self, options)
  svg_renderer.render
end