Class: Archimate::DataModel::ViewNode
- Inherits:
-
Object
- Object
- Archimate::DataModel::ViewNode
- Includes:
- Comparison
- Defined in:
- lib/archimate/data_model/view_node.rb
Overview
Graphical node type. It can contain child node types. This can be specialized as Label and Container In the ArchiMate v3 Schema, the tree of these nodes is: ViewConceptType(
LabelGroup (name LangString)
PreservedLangString
style (optional)
viewRefs
id)
-
ViewNodeType(
LocationGroup (x, y) SizeGroup (width, height))
-
Label(
conceptRef attributeRef xpathPart (optional)
)
-
Container(
nodes (ViewNodeType)
-
Element(
elementRef)
-
-
Instance Attribute Summary collapse
- #bounds ⇒ Bounds, NilClass readonly
- #child_type ⇒ Int, NilClass readonly
- #concept_ref ⇒ String readonly
- #connections ⇒ Array<Connection> readonly
- #content ⇒ String, NilClass readonly
- #diagram ⇒ Diagram, NilClass readonly
- #documentation ⇒ PreservedLangString, NilClass readonly
- #element ⇒ Element, NilClass
- #id ⇒ String readonly
- #name ⇒ LangString, NilClass readonly
- #nodes ⇒ Array<ViewNode> readonly
- #parent ⇒ ViewNode readonly
- #properties ⇒ Array<Property> readonly
- #style ⇒ Style, NilClass readonly
- #type ⇒ String, NilClass readonly
- #view_refs ⇒ Diagram
- #xpath_path ⇒ String, NilClass readonly
Instance Method Summary collapse
- #absolute_position ⇒ Object
- #all_nodes ⇒ Object
- #child_id_hash ⇒ Object
- #description ⇒ Object
- #in_diagram ⇒ Object
-
#initialize(id:, name: nil, documentation: nil, type: nil, parent: nil, style: nil, view_refs: [], content: nil, bounds: nil, nodes: [], connections: [], properties: [], element: nil, child_type: nil, diagram:, concept_ref: nil, xpath_path: nil) ⇒ ViewNode
constructor
A new instance of ViewNode.
- #referenced_identified_nodes ⇒ Object
- #replace(entity, with_entity) ⇒ Object
- #target_connections ⇒ Object
- #to_s ⇒ Object
Methods included from Comparison
#==, #[], #dig, #each, #hash, included, #pretty_print, #to_h
Constructor Details
#initialize(id:, name: nil, documentation: nil, type: nil, parent: nil, style: nil, view_refs: [], content: nil, bounds: nil, nodes: [], connections: [], properties: [], element: nil, child_type: nil, diagram:, concept_ref: nil, xpath_path: nil) ⇒ ViewNode
Returns a new instance of ViewNode.
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/archimate/data_model/view_node.rb', line 119 def initialize(id:, name: nil, documentation: nil, type: nil, parent: nil, style: nil, view_refs: [], content: nil, bounds: nil, nodes: [], connections: [], properties: [], element: nil, child_type: nil, diagram:, concept_ref: nil, xpath_path: nil) @id = id @name = name @documentation = documentation @type = type @parent = parent @style = style @view_refs = view_refs @content = content @bounds = bounds @nodes = nodes @connections = connections @properties = properties @element = element @child_type = child_type @diagram = diagram @concept_ref = concept_ref @xpath_path = xpath_path end |
Instance Attribute Details
#bounds ⇒ Bounds, NilClass (readonly)
74 |
# File 'lib/archimate/data_model/view_node.rb', line 74 model_attr :bounds |
#child_type ⇒ Int, NilClass (readonly)
97 |
# File 'lib/archimate/data_model/view_node.rb', line 97 model_attr :child_type |
#concept_ref ⇒ String (readonly)
110 |
# File 'lib/archimate/data_model/view_node.rb', line 110 model_attr :concept_ref |
#connections ⇒ Array<Connection> (readonly)
82 |
# File 'lib/archimate/data_model/view_node.rb', line 82 model_attr :connections |
#content ⇒ String, NilClass (readonly)
64 |
# File 'lib/archimate/data_model/view_node.rb', line 64 model_attr :content |
#diagram ⇒ Diagram, NilClass (readonly)
101 |
# File 'lib/archimate/data_model/view_node.rb', line 101 model_attr :diagram, comparison_attr: :no_compare |
#documentation ⇒ PreservedLangString, NilClass (readonly)
40 |
# File 'lib/archimate/data_model/view_node.rb', line 40 model_attr :documentation |
#element ⇒ Element, NilClass
93 |
# File 'lib/archimate/data_model/view_node.rb', line 93 model_attr :element, writable: true, comparison_attr: :id |
#id ⇒ String (readonly)
34 |
# File 'lib/archimate/data_model/view_node.rb', line 34 model_attr :id |
#name ⇒ LangString, NilClass (readonly)
37 |
# File 'lib/archimate/data_model/view_node.rb', line 37 model_attr :name |
#nodes ⇒ Array<ViewNode> (readonly)
79 |
# File 'lib/archimate/data_model/view_node.rb', line 79 model_attr :nodes |
#parent ⇒ ViewNode (readonly)
69 |
# File 'lib/archimate/data_model/view_node.rb', line 69 model_attr :parent, writable: true, comparison_attr: :no_compare |
#properties ⇒ Array<Property> (readonly)
88 |
# File 'lib/archimate/data_model/view_node.rb', line 88 model_attr :properties |
#style ⇒ Style, NilClass (readonly)
53 |
# File 'lib/archimate/data_model/view_node.rb', line 53 model_attr :style |
#type ⇒ String, NilClass (readonly)
50 |
# File 'lib/archimate/data_model/view_node.rb', line 50 model_attr :type |
#view_refs ⇒ Diagram
59 |
# File 'lib/archimate/data_model/view_node.rb', line 59 model_attr :view_refs, comparison_attr: :id, writable: true |
#xpath_path ⇒ String, NilClass (readonly)
117 |
# File 'lib/archimate/data_model/view_node.rb', line 117 model_attr :xpath_path |
Instance Method Details
#absolute_position ⇒ Object
181 182 183 184 185 186 187 188 189 190 |
# File 'lib/archimate/data_model/view_node.rb', line 181 def absolute_position offset = bounds || Bounds.zero el = parent while el.respond_to?(:bounds) && el.bounds bounds = el.bounds offset = Bounds.new(offset.to_h.merge(x: (offset.x || 0) + (bounds.x || 0), y: (offset.y || 0) + (bounds.y || 0))) el = el.parent end offset end |
#all_nodes ⇒ Object
159 160 161 |
# File 'lib/archimate/data_model/view_node.rb', line 159 def all_nodes nodes.inject(Array.new(nodes)) { |child_ary, child| child_ary.concat(child.all_nodes) } end |
#child_id_hash ⇒ Object
163 164 165 |
# File 'lib/archimate/data_model/view_node.rb', line 163 def child_id_hash nodes.each_with_object(id => self) { |i, a| a.merge!(i.child_id_hash) } end |
#description ⇒ Object
151 152 153 154 155 156 157 |
# File 'lib/archimate/data_model/view_node.rb', line 151 def description [ name.nil? ? nil : name.to_s, element.nil? ? nil : element.name, element&.type.nil? ? nil : "(#{element.type})" ].compact.join(" ") end |
#in_diagram ⇒ Object
176 177 178 |
# File 'lib/archimate/data_model/view_node.rb', line 176 def in_diagram diagram # ||= ->(node) { node = node.parent until node.nil? || node.is_a?(Diagram) }.call(self) end |
#referenced_identified_nodes ⇒ Object
167 168 169 170 171 172 173 174 |
# File 'lib/archimate/data_model/view_node.rb', line 167 def referenced_identified_nodes (nodes + connections).reduce( [element] .compact ) do |a, e| a.concat(e.referenced_identified_nodes) end end |
#replace(entity, with_entity) ⇒ Object
142 143 144 145 |
# File 'lib/archimate/data_model/view_node.rb', line 142 def replace(entity, with_entity) @element = with_entity if element.id == entity.id @view_refs = with_entity if view_refs == entity end |
#target_connections ⇒ Object
192 193 194 195 196 197 |
# File 'lib/archimate/data_model/view_node.rb', line 192 def target_connections diagram .connections .select { |conn| conn.target&.id == id } .map(&:id) end |
#to_s ⇒ Object
147 148 149 |
# File 'lib/archimate/data_model/view_node.rb', line 147 def to_s "ViewNode[#{name || ''}](#{element if element})" end |