2 # MakeGraph routine by eto 2003-0305
7 class MakeGraph #======================================================================実務的な処理を引き受ける。
8 #GRAPHVIZ_CMD = 0 # CLI
10 GRAPHVIZ_TYPE = Graphviz::TWOPI
11 #GRAPHVIZ_TYPE = Graphviz::NEATO
16 @kl = KanjiList.instance
17 @hn = KanjiNetwork.new
25 open("gakunen.html", "w"){|out|
29 out.print %Q|#{typestr}グラフ\n|
30 (1..6).each {|gakunen|
31 out.print %Q|小学#{gakunen}年生 |
32 base = "han-#{type}-#{gakunen}-all"
33 out.print %Q|<a href="#{base}.svg">all</a> |
35 base = "han-#{type}-#{gakunen}-#{kubun}"
36 out.print %Q|<a href="#{base}.svg">#{kubun}</a> |
41 out.print %Q|</pre>\n|
46 @hn.make_network(@kl.awase(0))
47 # @hn.make_network(@kl.awase(1))
48 @hn.out("min.dot") #途中状態を保存
49 #graphviz(Graphviz::NEATO, "min.dot", "min.svg")
50 graphviz(GRAPHVIZ_TYPE, "min.dot", "min.svg")
53 (START_GAKUNEN..END_GAKUNEN).each {|gakunen|
55 make_dot(gakunen, kubun)
57 make_svg(type, gakunen, kubun)
60 make_dot(gakunen, nil)
62 unless type == 2 && 5 <= gakunen
63 make_svg(type, gakunen, nil)
68 def gaku_name(gakunen, kubun=nil)
69 return "#{gakunen}nen-all" if kubun.nil?
70 return "#{gakunen}nen-#{kubun}"
72 def make_dot(gakunen, kubun=nil) #Graphvizのtype, 学年, 象形、指示などの区分
74 list = @kl.kyoiku(1..gakunen, kubun)
75 @hn.make_network(list)
76 dotf = "list-"+gaku_name(gakunen, kubun)+".dot"
77 @hn.out(dotf) #途中状態を保存する
80 def make_svg(type, gakunen, kubun=nil) #Graphvizのtype, 学年, 象形、指示などの区分
81 g = gaku_name(gakunen, kubun)
82 dotf = "list-"+g+".dot"
83 svgf = "han-"+g+"-"+GraphvizCLI::NAMES[type]+".svg"
84 graphviz(type, dotf, svgf)
88 Dir.glob("*.dot").each {|inf|
89 out = inf.sub(/.dot$/, '.svg')
90 type = 1 if inf =~ /^han-1/
91 type = 2 if inf =~ /^han-2/
92 graphviz(type, inf, out)
95 def graphviz(type, inf, out)
96 gv = GraphvizCLI.new() if GRAPHVIZ_CMD == 0
97 gv = GraphvizOLE.new() if GRAPHVIZ_CMD == 1
112 #----------------------------------------------------------------------end.