Class: Mappum::MapServer::Graph
- Defined in:
- lib/mappum/mapserver/mapgraph.rb
Instance Attribute Summary collapse
-
#edge_maps ⇒ Object
readonly
Returns the value of attribute edge_maps.
Instance Method Summary collapse
- #getDot ⇒ Object
- #getPng ⇒ Object
- #getSvg ⇒ Object
-
#initialize(map) ⇒ Graph
constructor
A new instance of Graph.
Constructor Details
#initialize(map) ⇒ Graph
Returns a new instance of Graph.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/mappum/mapserver/mapgraph.rb', line 5 def initialize(map) @map = map @root = [] @struct_from = StrTree.new(nil,0,@root) @struct_from.name = "struct1" @struct_to = StrTree.new(nil,0,@root) @struct_to.name = "struct2" @edges = [] @edge_maps = {} init(@map,@struct_from, @struct_to) end |
Instance Attribute Details
#edge_maps ⇒ Object (readonly)
Returns the value of attribute edge_maps.
4 5 6 |
# File 'lib/mappum/mapserver/mapgraph.rb', line 4 def edge_maps @edge_maps end |
Instance Method Details
#getDot ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/mappum/mapserver/mapgraph.rb', line 36 def getDot str1 = makeStruct(@struct_from) str2 = makeStruct(@struct_to) edge = @edges.join return "digraph structs { node [shape=plaintext]; rankdir=LR; nodesep=0.1; \n struct1 [\n label=<\n \#{str1}\n >\n ]; \n struct2 [\n label=<\n \#{str2}\n >\n ];\n \#{@root.collect { |struct| struct.line}}\n \#{edge}\n \n } \n" end |
#getPng ⇒ Object
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/mappum/mapserver/mapgraph.rb', line 26 def getPng cmd = "dot" format = "png" xCmd = "#{cmd} -T#{format}" dot = getDot f = IO.popen( xCmd ,"r+") f.print(dot) f.close_write return f end |
#getSvg ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mappum/mapserver/mapgraph.rb', line 16 def getSvg cmd = "dot" format = "svg" xCmd = "#{cmd} -T#{format}" puts dot = getDot f = IO.popen( xCmd ,"r+") f.print(dot) f.close_write return f end |