Class: Phenomenal::Viewer::Graphical

Inherits:
Object
  • Object
show all
Defined in:
lib/phenomenal/viewer/graphical.rb

Overview

Define the way to generate a representation of the system using the graphical library graphviz

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(destination_file) ⇒ Graphical

Returns a new instance of Graphical.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/phenomenal/viewer/graphical.rb', line 14

def initialize(destination_file)
  if !@@graphviz
    raise(Phenomenal::Error,
      "The 'ruby-graphviz' gem isn't available. Please install it to generate graphic visualisations\n"+
      " Otherwise use the text version: phen_textual_view"
    )
  end
  
  @manager=Phenomenal::Manager.instance
  @rmanager=Phenomenal::RelationshipManager.instance
  @destination_file=destination_file
  @main_graph=nil
  @feature_nodes={}
  @r_feature_nodes={}
  @context_nodes={}
end

Instance Attribute Details

#context_nodesObject

Returns the value of attribute context_nodes.



12
13
14
# File 'lib/phenomenal/viewer/graphical.rb', line 12

def context_nodes
  @context_nodes
end

#destination_fileObject

Returns the value of attribute destination_file.



12
13
14
# File 'lib/phenomenal/viewer/graphical.rb', line 12

def destination_file
  @destination_file
end

#feature_nodesObject

Returns the value of attribute feature_nodes.



12
13
14
# File 'lib/phenomenal/viewer/graphical.rb', line 12

def feature_nodes
  @feature_nodes
end

#main_graphObject

Returns the value of attribute main_graph.



12
13
14
# File 'lib/phenomenal/viewer/graphical.rb', line 12

def main_graph
  @main_graph
end

#managerObject (readonly)

Returns the value of attribute manager.



11
12
13
# File 'lib/phenomenal/viewer/graphical.rb', line 11

def manager
  @manager
end

#r_feature_nodesObject

Returns the value of attribute r_feature_nodes.



12
13
14
# File 'lib/phenomenal/viewer/graphical.rb', line 12

def r_feature_nodes
  @r_feature_nodes
end

#rmanagerObject (readonly)

Returns the value of attribute rmanager.



11
12
13
# File 'lib/phenomenal/viewer/graphical.rb', line 11

def rmanager
  @rmanager
end

Instance Method Details

#generateObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/phenomenal/viewer/graphical.rb', line 31

def generate()
  set_options()
  # Add nodes to the graph
  self.manager.contexts.each do |key,context|
    if !feature_nodes.include?(context) && !context_nodes.include?(context)
      add_node_for(context)
    end
  end
  # Create a relationship links
  self.manager.contexts.each do |key,context|
    add_edges_for(context)
  end
  self.main_graph.output(:png => destination_file)
  nil
end