Graphviz/gvedit

Last-modified: 2009-11-18 (水) 08:00:44

#!/bin/ruby

require 'nkf'
prologue = <<EOP
graph[fontname="MS GOTHIC"];
edge[fontname="MS GOTHIC"];
node[fontname="MS GOTHIC"];
EOP
conv = {
'DFD:Entity' => '[shape="box",style="filled",fillcolor="#FFFFDD"]',
'DFD:Process' => '[shape="circle",style="filled",fillcolor="#DDDDFF",width=0.7,fixedsize=true]',
'DFD:IF' => '[shape="box",style="filled",fillcolor="#DDFFDD",width=0.3,height=0.3,fixedsize=true]',
'UML:Class' => '[shape="record",fillcolor="lightyellow",style="filled"]',
'UML:Extends' => '[arrowtail="none",arrowhead="onormal"]',
'UML:Implements' => '[arrowtail="none",arrowhead="onormal",style="dashed"]',
'UML:Uses' => '[arrowtail="none",arrowhead="vee",style="dashed",label="<<use>>"]',
#その他色々マクロを定義
}
File.open('c:/progra~1/graphv~1.21/bin/__temp3.dot','w+'){|fd|
	ARGF.each{|e|
		if /digraph/.match(e)
			e.gsub!(/digraph\s+\{/, 'digraph{'+prologue)
		end
		conv.each{|k,v|
			e.gsub!(k,v)
		}
		fd.print NKF.nkf('-Sw', e)
	}
}