Class: Archimate::DataModel::ViewNode
- Inherits:
-
Object
- Object
- Archimate::DataModel::ViewNode
- Includes:
- Comparison, Referenceable
- 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
ViewNodeType.
-
#child_type ⇒ String, NilClass
readonly
Archi format, selects the shape of element (for elements that can have two or more shapes) A nil value indicates the standard representation, a value of “1” indicates the alternate.
-
#concept_ref ⇒ String
readonly
conceptRef is a reference to an concept for this particular label, along with the attributeRef which references the particular concept’s part which this label represents.
- #connections ⇒ Array<Connection> readonly
- #content ⇒ String, NilClass readonly
- #diagram ⇒ Diagram, NilClass readonly
- #documentation ⇒ PreservedLangString, NilClass readonly
-
#element ⇒ Element, NilClass
Element.
-
#id ⇒ String
readonly
ViewConceptType.
- #name ⇒ LangString, NilClass readonly
-
#nodes ⇒ Array<ViewNode>
readonly
Container - container doesn’t distinguish between nodes and connections.
-
#parent ⇒ ViewNode
readonly
This is needed for various calculations.
- #properties ⇒ Array<Property> readonly
- #style ⇒ Style, NilClass readonly
- #type ⇒ String, NilClass readonly
- #view_refs ⇒ Diagram
-
#xpath_path ⇒ String, NilClass
readonly
conceptRef is a reference to an concept for this particular label, along with the partRef which references the particular concept’s part which this label represents.
Instance Method Summary collapse
- #absolute_position ⇒ Object
- #all_nodes ⇒ Object
- #center ⇒ Object
- #child_id_hash ⇒ Object
- #description ⇒ Object
- #in_diagram ⇒ Object
-
#other_attributes ⇒ Array<AnyAttribute>
# @!attribute [r] other_attributes.
-
#other_elements ⇒ Array<AnyElement>
# @!attribute [r] other_elements.
- #replace_item_with(item, replacement) ⇒ Object
- #target_connections ⇒ Object
- #to_s ⇒ Object
Methods included from Referenceable
#add_reference, #destroy, #model, #references, #remove_reference, #replace_with
Methods included from Comparison
#==, #[], #dig, #each, #hash, included, #initialize, #inspect, #pretty_print, #to_h
Instance Attribute Details
#bounds ⇒ Bounds, NilClass (readonly)
ViewNodeType
74 |
# File 'lib/archimate/data_model/view_node.rb', line 74 model_attr :bounds, default: nil |
#child_type ⇒ String, NilClass (readonly)
Archi format, selects the shape of element (for elements that can have two or more shapes) A nil value indicates the standard representation, a value of “1” indicates the alternate
98 |
# File 'lib/archimate/data_model/view_node.rb', line 98 model_attr :child_type, default: nil |
#concept_ref ⇒ String (readonly)
conceptRef is a reference to an concept for this particular label, along with the attributeRef which references the particular concept’s part which this label represents.
111 |
# File 'lib/archimate/data_model/view_node.rb', line 111 model_attr :concept_ref, default: nil |
#connections ⇒ Array<Connection> (readonly)
82 |
# File 'lib/archimate/data_model/view_node.rb', line 82 model_attr :connections, default: [], referenceable_list: true |
#content ⇒ String, NilClass (readonly)
document where this comes from
64 |
# File 'lib/archimate/data_model/view_node.rb', line 64 model_attr :content, default: nil |
#diagram ⇒ Diagram, NilClass (readonly)
102 |
# File 'lib/archimate/data_model/view_node.rb', line 102 model_attr :diagram, comparison_attr: :no_compare |
#documentation ⇒ PreservedLangString, NilClass (readonly)
41 |
# File 'lib/archimate/data_model/view_node.rb', line 41 model_attr :documentation, default: nil |
#element ⇒ Element, NilClass
Element
93 |
# File 'lib/archimate/data_model/view_node.rb', line 93 model_attr :element, writable: true, comparison_attr: :id, default: nil, also_reference: [:diagram] |
#id ⇒ String (readonly)
ViewConceptType
35 |
# File 'lib/archimate/data_model/view_node.rb', line 35 model_attr :id |
#name ⇒ LangString, NilClass (readonly)
38 |
# File 'lib/archimate/data_model/view_node.rb', line 38 model_attr :name, default: nil |
#nodes ⇒ Array<ViewNode> (readonly)
Container - container doesn’t distinguish between nodes and connections
79 |
# File 'lib/archimate/data_model/view_node.rb', line 79 model_attr :nodes, default: [], referenceable_list: true, also_reference: [:diagram] |
#parent ⇒ ViewNode (readonly)
This is needed for various calculations
69 |
# File 'lib/archimate/data_model/view_node.rb', line 69 model_attr :parent, writable: true, comparison_attr: :no_compare, default: nil |
#properties ⇒ Array<Property> (readonly)
Delete this - I think it’s not used
properties is not in the model under element, it’s added under Real Element
88 |
# File 'lib/archimate/data_model/view_node.rb', line 88 model_attr :properties, default: [] |
#style ⇒ Style, NilClass (readonly)
54 |
# File 'lib/archimate/data_model/view_node.rb', line 54 model_attr :style, default: nil |
#type ⇒ String, NilClass (readonly)
type here was used for the Element/Relationship/Diagram type
51 |
# File 'lib/archimate/data_model/view_node.rb', line 51 model_attr :type, default: nil |
#view_refs ⇒ Diagram
viewRefs are pointers to 0-* Diagrams for diagram drill in defined in abstract View Concept
59 |
# File 'lib/archimate/data_model/view_node.rb', line 59 model_attr :view_refs, comparison_attr: :id, writable: true, default: nil |
#xpath_path ⇒ String, NilClass (readonly)
conceptRef is a reference to an concept for this particular label, along with the partRef which references the particular concept’s part which this label represents. If this attribute is set, then there is no need to add a label tag in the Label parent (since it is contained in the model). the XPATH statement is meant to be interpreted in the context of what the conceptRef points to.
118 |
# File 'lib/archimate/data_model/view_node.rb', line 118 model_attr :xpath_path, default: nil |
Instance Method Details
#absolute_position ⇒ Object
Is this true for all or only Archi models?
145 146 147 148 149 150 151 152 153 154 |
# File 'lib/archimate/data_model/view_node.rb', line 145 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
132 133 134 |
# File 'lib/archimate/data_model/view_node.rb', line 132 def all_nodes nodes.inject(Array.new(nodes)) { |child_ary, child| child_ary.concat(child.all_nodes) } end |
#center ⇒ Object
163 164 165 |
# File 'lib/archimate/data_model/view_node.rb', line 163 def center @bounds&.center end |
#child_id_hash ⇒ Object
136 137 138 |
# File 'lib/archimate/data_model/view_node.rb', line 136 def child_id_hash nodes.each_with_object(id => self) { |i, a| a.merge!(i.child_id_hash) } end |
#description ⇒ Object
124 125 126 127 128 129 130 |
# File 'lib/archimate/data_model/view_node.rb', line 124 def description [ name&.to_s, element&.name, element ? "(#{element.type})" : nil ].compact.join(" ") end |
#in_diagram ⇒ Object
140 141 142 |
# File 'lib/archimate/data_model/view_node.rb', line 140 def in_diagram diagram # ||= ->(node) { node = node.parent until node.nil? || node.is_a?(Diagram) }.call(self) end |
#other_attributes ⇒ Array<AnyAttribute>
# @!attribute [r] other_attributes
47 |
# File 'lib/archimate/data_model/view_node.rb', line 47 model_attr :other_attributes, default: [] |
#other_elements ⇒ Array<AnyElement>
# @!attribute [r] other_elements
44 |
# File 'lib/archimate/data_model/view_node.rb', line 44 model_attr :other_elements, default: [] |
#replace_item_with(item, replacement) ⇒ Object
167 168 169 170 171 172 173 174 175 176 |
# File 'lib/archimate/data_model/view_node.rb', line 167 def replace_item_with(item, replacement) super item.remove_reference(self) case item when element @element = replacement else raise "Trying to replace #{item} that I don't reference" end end |
#target_connections ⇒ Object
156 157 158 159 160 161 |
# File 'lib/archimate/data_model/view_node.rb', line 156 def target_connections diagram .connections .select { |conn| conn.target&.id == id } .map(&:id) end |
#to_s ⇒ Object
120 121 122 |
# File 'lib/archimate/data_model/view_node.rb', line 120 def to_s "ViewNode[#{name || ''}](#{element if element})" end |