Class: Archimate::DataModel::ViewNode

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#boundsBounds, NilClass (readonly)

ViewNodeType

Returns:



74
# File 'lib/archimate/data_model/view_node.rb', line 74

model_attr :bounds, default: nil

#child_typeString, 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

Returns:

  • (String, NilClass)


98
# File 'lib/archimate/data_model/view_node.rb', line 98

model_attr :child_type, default: nil

#concept_refString (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.

Returns:

  • (String)


111
# File 'lib/archimate/data_model/view_node.rb', line 111

model_attr :concept_ref, default: nil

#connectionsArray<Connection> (readonly)

Returns:



82
# File 'lib/archimate/data_model/view_node.rb', line 82

model_attr :connections, default: [], referenceable_list: true

#contentString, NilClass (readonly)

TODO:

document where this comes from

Returns:

  • (String, NilClass)


64
# File 'lib/archimate/data_model/view_node.rb', line 64

model_attr :content, default: nil

#diagramDiagram, NilClass (readonly)

Returns:



102
# File 'lib/archimate/data_model/view_node.rb', line 102

model_attr :diagram, comparison_attr: :no_compare

#documentationPreservedLangString, NilClass (readonly)

Returns:



41
# File 'lib/archimate/data_model/view_node.rb', line 41

model_attr :documentation, default: nil

#elementElement, NilClass

Element

Returns:



93
# File 'lib/archimate/data_model/view_node.rb', line 93

model_attr :element, writable: true, comparison_attr: :id, default: nil, also_reference: [:diagram]

#idString (readonly)

ViewConceptType

Returns:

  • (String)


35
# File 'lib/archimate/data_model/view_node.rb', line 35

model_attr :id

#nameLangString, NilClass (readonly)

Returns:



38
# File 'lib/archimate/data_model/view_node.rb', line 38

model_attr :name, default: nil

#nodesArray<ViewNode> (readonly)

Container - container doesn’t distinguish between nodes and connections

Returns:



79
# File 'lib/archimate/data_model/view_node.rb', line 79

model_attr :nodes, default: [], referenceable_list: true, also_reference: [:diagram]

#parentViewNode (readonly)

This is needed for various calculations

Returns:



69
# File 'lib/archimate/data_model/view_node.rb', line 69

model_attr :parent, writable: true, comparison_attr: :no_compare, default: nil

#propertiesArray<Property> (readonly)

TODO:

Delete this - I think it’s not used

Note:

properties is not in the model under element, it’s added under Real Element

Returns:



88
# File 'lib/archimate/data_model/view_node.rb', line 88

model_attr :properties, default: []

#styleStyle, NilClass (readonly)

Returns:



54
# File 'lib/archimate/data_model/view_node.rb', line 54

model_attr :style, default: nil

#typeString, NilClass (readonly)

Note:

type here was used for the Element/Relationship/Diagram type

Returns:

  • (String, NilClass)


51
# File 'lib/archimate/data_model/view_node.rb', line 51

model_attr :type, default: nil

#view_refsDiagram

Note:

viewRefs are pointers to 0-* Diagrams for diagram drill in defined in abstract View Concept

Returns:



59
# File 'lib/archimate/data_model/view_node.rb', line 59

model_attr :view_refs, comparison_attr: :id, writable: true, default: nil

#xpath_pathString, 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.

Returns:

  • (String, NilClass)


118
# File 'lib/archimate/data_model/view_node.rb', line 118

model_attr :xpath_path, default: nil

Instance Method Details

#absolute_positionObject

TODO:

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_nodesObject



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

#centerObject



163
164
165
# File 'lib/archimate/data_model/view_node.rb', line 163

def center
  @bounds&.center
end

#child_id_hashObject



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

#descriptionObject



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_diagramObject



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_attributesArray<AnyAttribute>

# @!attribute [r] other_attributes

Returns:



47
# File 'lib/archimate/data_model/view_node.rb', line 47

model_attr :other_attributes, default: []

#other_elementsArray<AnyElement>

# @!attribute [r] other_elements

Returns:



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_connectionsObject



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_sObject



120
121
122
# File 'lib/archimate/data_model/view_node.rb', line 120

def to_s
  "ViewNode[#{name || ''}](#{element if element})"
end