1 package com.opensymphony.webwork.webFlow.model; 2 3 import java.io.IOException ; 4 import java.util.*; 5 6 11 public class Graph extends SubGraph { 12 private Set links; 13 public static Map nodeMap = new TreeMap(); 14 15 public Graph() { 16 super(""); 17 this.links = new TreeSet(); 18 } 19 20 public void addLink(Link link) { 21 links.add(link); 22 } 23 24 public void render(IndentWriter writer) throws IOException { 25 writer.write("digraph mygraph {", true); 27 writer.write("fontsize=10;"); 28 writer.write("fontname=helvetica;"); 29 writer.write("node [fontsize=10, fontname=helvetica, style=filled, shape=rectangle]"); 30 writer.write("edge [fontsize=10, fontname=helvetica]"); 31 32 for (Iterator iterator = subGraphs.iterator(); iterator.hasNext();) { 34 SubGraph subGraph = (SubGraph) iterator.next(); 35 subGraph.render(new IndentWriter(writer)); 36 } 37 38 for (Iterator iterator = nodes.iterator(); iterator.hasNext();) { 40 WebFlowNode webFlowNode = (WebFlowNode) iterator.next(); 41 webFlowNode.render(writer); 42 } 43 44 for (Iterator iterator = links.iterator(); iterator.hasNext();) { 46 Link link = (Link) iterator.next(); 47 link.render(writer); 48 } 49 50 writer.write("}", true); 52 } 53 54 public WebFlowNode findNode(String location, WebFlowNode ref) { 55 if (location.startsWith("/")) { 56 location = location.substring(1); 57 } else { 58 String prefix = null; 60 if (ref.getParent() != null) { 61 prefix = ref.getParent().getPrefix(); 62 location = prefix + "_" + location; 63 } 64 } 65 66 location = location.replaceAll("[\\.\\/\\-\\$\\{\\}]", "_"); 67 68 return (WebFlowNode) nodeMap.get(location); 69 } 70 } 71 | Popular Tags |