X-Git-Url: http://sraa.de/git/?a=blobdiff_plain;f=dol%2Fsrc%2Fdol%2Fvisitor%2Fdot%2FMapDotVisitor.java;fp=dol%2Fsrc%2Fdol%2Fvisitor%2Fdot%2FMapDotVisitor.java;h=581c61504892bb847a09ecc6b78dc983cd4b4637;hb=8c411cf24ed0eb889191aaeafd8fa1e69081df42;hp=0000000000000000000000000000000000000000;hpb=dea7a4fb1ed110d3ce6e6d9255103d724bd66c0e;p=jump.git diff --git a/dol/src/dol/visitor/dot/MapDotVisitor.java b/dol/src/dol/visitor/dot/MapDotVisitor.java new file mode 100644 index 0000000..581c615 --- /dev/null +++ b/dol/src/dol/visitor/dot/MapDotVisitor.java @@ -0,0 +1,80 @@ +/* $Id: MapDotVisitor.java 1 2010-02-24 13:03:05Z haidw $ */ +package dol.visitor.dot; + +import java.util.Iterator; + +import dol.datamodel.architecture.Processor; +import dol.datamodel.mapping.Mapping; +import dol.datamodel.pn.Channel; +import dol.util.CodePrintStream; +import dol.visitor.MapVisitor; + +/** + * This class is a class for a visitor that is used to generate + * ".dot" output in order to visualize a mapping using the DOTTY tool. + */ +public class MapDotVisitor extends MapVisitor { + + /** + * Constructor. + * + * @param printStream print stream to which the contents is written + */ + public MapDotVisitor(CodePrintStream printStream) { + _printStream = printStream; + _pnVisitor = new PNDotVisitor(printStream); + _archiVisitor = new ArchDotVisitor(printStream); + } + + /** + * Print a .dot file in the correct format for DOTTY. + * + * @param map process network that needs to be rendered + */ + public void visitComponent(Mapping map) { + _printStream.printPrefixln("digraph mapping {"); + _printStream.println(); + _printStream.prefixInc(); + _printStream.printPrefixln("ratio = auto;"); + _printStream.printPrefixln("rankdir = LR;"); + _printStream.printPrefixln("ranksep = 0.3;"); + _printStream.printPrefixln("nodesep = 0.2;"); + _printStream.printPrefixln("center = true;"); + _printStream.printPrefixln(""); + _printStream.printPrefixln("node [ fontsize=12, height=0.4, " + + "width=0.4, style=filled, color=\"0.65 0.20 1.00\" ];"); + _printStream.printPrefixln("edge [ fontsize=10, arrowhead=normal, " + + "arrowsize=0.8, style=\"setlinewidth(2)\" ];"); + _printStream.println(); + + //visit all processors + Processor processor; + Iterator processorIter = map.getProcessorList().iterator(); + while( processorIter.hasNext() ) + { + processor = processorIter.next(); + processor.accept(_archiVisitor); + } + + //visit all channels (from PN) + _pnVisitor.setMapping(map); + Channel chan; + Iterator chanIter = map.getPN().getChannelList().iterator(); + while (chanIter.hasNext() ) + { + chan = chanIter.next(); + chan.accept(_pnVisitor); + } + + _printStream.prefixDec(); + _printStream.println(); + _printStream.printPrefixln("}"); + } + + + /** DOT Visitor to visit process network resources */ + protected PNDotVisitor _pnVisitor = null; + + /** DOT Visitor to visit architecture resources */ + protected ArchDotVisitor _archiVisitor = null; +}