Class: Ea::Sources::Qea::DiagramBuilder
- Inherits:
-
Object
- Object
- Ea::Sources::Qea::DiagramBuilder
- Defined in:
- lib/ea/sources/qea/diagram_builder.rb
Overview
Translates EA t_diagram + t_diagramlinks + t_diagramobjects into Ea::Model::Diagram with placed DiagramElements and DiagramConnectors (including pixel coordinates and parsed styles).
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
Instance Method Summary collapse
- #build_all ⇒ Object
- #build_one(diagram_row) ⇒ Object
-
#hand_draw_enabled?(diagram_row) ⇒ Boolean
HandDraw=1 in t_diagram.StyleEx triggers EA's wavy hand-drawn border style for every element on the diagram.
-
#initialize(database) ⇒ DiagramBuilder
constructor
A new instance of DiagramBuilder.
-
#package_contents_enabled?(diagram_row) ⇒ Boolean
EA encodes "show package contents" as a non-zero integer in t_diagram.ShowPackageContents (1 in basic.qea, 255 in test.qea).
-
#show_notes_enabled?(diagram_row) ⇒ Boolean
ShowNotes=1 in t_diagram.StyleEx renders the classifier's documentation note as wrapped text in the element body.
-
#show_parents_enabled?(diagram_row) ⇒ Boolean
HideParents=1 in t_diagram.PDATA suppresses EA's "off-canvas parent class" ghost line — the italic parent name that EA normally prepends to a placed element's header when its generalization parent is not placed on the diagram.
Constructor Details
#initialize(database) ⇒ DiagramBuilder
Returns a new instance of DiagramBuilder.
13 14 15 |
# File 'lib/ea/sources/qea/diagram_builder.rb', line 13 def initialize(database) @database = database end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
11 12 13 |
# File 'lib/ea/sources/qea/diagram_builder.rb', line 11 def database @database end |
Instance Method Details
#build_all ⇒ Object
17 18 19 20 |
# File 'lib/ea/sources/qea/diagram_builder.rb', line 17 def build_all diagrams = database.collections[:diagrams] || [] diagrams.map { |row| build_one(row) } end |
#build_one(diagram_row) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ea/sources/qea/diagram_builder.rb', line 22 def build_one(diagram_row) Ea::Model::Diagram.new( id: IdNormalizer.from_guid(diagram_row.ea_guid), name: diagram_row.name, package_id: package_id_for(diagram_row), diagram_type: diagram_row.diagram_type, bounds: bounds_for(diagram_row), style: diagram_row.pdata, style_ex: diagram_row.styleex, show_package_contents: package_contents_enabled?(diagram_row), hand_draw: hand_draw_enabled?(diagram_row), show_notes: show_notes_enabled?(diagram_row), show_parents: show_parents_enabled?(diagram_row), elements: build_elements(diagram_row), connectors: build_connectors(diagram_row), annotations: AnnotationBuilder.from_note(diagram_row.notes, diagram_row.ea_guid, kind: "documentation") ) end |
#hand_draw_enabled?(diagram_row) ⇒ Boolean
HandDraw=1 in t_diagram.StyleEx triggers EA's wavy hand-drawn border style for every element on the diagram.
55 56 57 58 59 |
# File 'lib/ea/sources/qea/diagram_builder.rb', line 55 def hand_draw_enabled?(diagram_row) style_ex = diagram_row.styleex.to_s match = style_ex.match(/HandDraw=(\d)/) match && match[1] == "1" end |
#package_contents_enabled?(diagram_row) ⇒ Boolean
EA encodes "show package contents" as a non-zero integer in t_diagram.ShowPackageContents (1 in basic.qea, 255 in test.qea). When true, the package body lists its child classifiers/sub-packages as "+ Name" rows.
47 48 49 50 51 |
# File 'lib/ea/sources/qea/diagram_builder.rb', line 47 def package_contents_enabled?(diagram_row) return false if diagram_row.showpackagecontents.nil? diagram_row.showpackagecontents.to_i.nonzero? end |
#show_notes_enabled?(diagram_row) ⇒ Boolean
ShowNotes=1 in t_diagram.StyleEx renders the classifier's documentation note as wrapped text in the element body.
63 64 65 66 67 |
# File 'lib/ea/sources/qea/diagram_builder.rb', line 63 def show_notes_enabled?(diagram_row) style_ex = diagram_row.styleex.to_s match = style_ex.match(/ShowNotes=(\d)/) match && match[1] == "1" end |
#show_parents_enabled?(diagram_row) ⇒ Boolean
HideParents=1 in t_diagram.PDATA suppresses EA's "off-canvas parent class" ghost line — the italic parent name that EA normally prepends to a placed element's header when its generalization parent is not placed on the diagram.
73 74 75 76 77 |
# File 'lib/ea/sources/qea/diagram_builder.rb', line 73 def show_parents_enabled?(diagram_row) pdata = diagram_row.pdata.to_s match = pdata.match(/HideParents=(\d)/) match ? match[1] != "1" : true end |