1 /* $Id: MapDotVisitor.java 1 2010-02-24 13:03:05Z haidw $ */
2 package dol.visitor.dot;
4 import java.util.Iterator;
6 import dol.datamodel.architecture.Processor;
7 import dol.datamodel.mapping.Mapping;
8 import dol.datamodel.pn.Channel;
9 import dol.util.CodePrintStream;
10 import dol.visitor.MapVisitor;
13 * This class is a class for a visitor that is used to generate
14 * ".dot" output in order to visualize a mapping using the DOTTY tool.
16 public class MapDotVisitor extends MapVisitor {
21 * @param printStream print stream to which the contents is written
23 public MapDotVisitor(CodePrintStream printStream) {
24 _printStream = printStream;
25 _pnVisitor = new PNDotVisitor(printStream);
26 _archiVisitor = new ArchDotVisitor(printStream);
30 * Print a .dot file in the correct format for DOTTY.
32 * @param map process network that needs to be rendered
34 public void visitComponent(Mapping map) {
35 _printStream.printPrefixln("digraph mapping {");
36 _printStream.println();
37 _printStream.prefixInc();
38 _printStream.printPrefixln("ratio = auto;");
39 _printStream.printPrefixln("rankdir = LR;");
40 _printStream.printPrefixln("ranksep = 0.3;");
41 _printStream.printPrefixln("nodesep = 0.2;");
42 _printStream.printPrefixln("center = true;");
43 _printStream.printPrefixln("");
44 _printStream.printPrefixln("node [ fontsize=12, height=0.4, "
45 + "width=0.4, style=filled, color=\"0.65 0.20 1.00\" ];");
46 _printStream.printPrefixln("edge [ fontsize=10, arrowhead=normal, "
47 + "arrowsize=0.8, style=\"setlinewidth(2)\" ];");
48 _printStream.println();
50 //visit all processors
52 Iterator<Processor> processorIter = map.getProcessorList().iterator();
53 while( processorIter.hasNext() )
55 processor = processorIter.next();
56 processor.accept(_archiVisitor);
59 //visit all channels (from PN)
60 _pnVisitor.setMapping(map);
62 Iterator<Channel> chanIter = map.getPN().getChannelList().iterator();
63 while (chanIter.hasNext() )
65 chan = chanIter.next();
66 chan.accept(_pnVisitor);
69 _printStream.prefixDec();
70 _printStream.println();
71 _printStream.printPrefixln("}");
75 /** DOT Visitor to visit process network resources */
76 protected PNDotVisitor _pnVisitor = null;
78 /** DOT Visitor to visit architecture resources */
79 protected ArchDotVisitor _archiVisitor = null;