private void write(View view, Element clusterElement, Writer writer) { try { DotGraph graph = new DotGraph(view.getName()); DotGraph.Digraph digraph = graph.getDigraph(); DotGraph.Cluster cluster = null; cluster = digraph.addCluster(clusterElement.getId()); cluster.setLabel(clusterElement.getName()); cluster.addNode(element.getId()).setLabel(element.getName()); } else { digraph.addNode(element.getId()).setLabel(element.getName()); digraph.addAssociation( relationship.getSourceId(), relationship.getDestinationId()).setLabel(relationship.getDescription()); String output = graph.render().trim(); writer.write(output); writer.write(System.lineSeparator());
public Digraph(NodeRegistry registry, String title, String dir) { super(registry, title); this.dir = dir; setLabel(title); }
/** * All-in-on convenience method * * @return The filename of the dot-generated picture for the given content */ @Override public String toImage(String filename, String content) throws InterruptedException, IOException { write(filename, content); render(filename); return filename + getImageExtension(); } }
public String render() { final StringBuffer out = new StringBuffer(); out.append(DotRenderer.openGraph(label, dir)); renderNodes(out); renderAssociations(out); out.append(DotRenderer.closeGraph()); return out.toString(); }
public static String openGraph(String title, String dir) { final StringBuffer sb = new StringBuffer(); sb.append("# Class diagram "); sb.append(title); sb.append(NEWLINE); sb.append("digraph G {"); if (title != null) { sb.append(graphTitle(title, dir)); } sb.append(optionsEdge()); sb.append(optionsNode()); return sb.toString(); }
@Override public void render(String filename) throws InterruptedException, IOException { String dot = read(path + filename + ".dot"); HttpRequest httpRequest = HttpRequest.get(GOOGLE_CHART_API, true, "cht", "gv", "chl", dot); if (httpRequest.ok()) { try (InputStream is = httpRequest.stream()) { Files.copy(is, Paths.get(path + filename + getImageExtension())); } } else { throw new DotDiagramException("Errors calling Graphviz chart.googleapis.com"); } }
public Association addAssociation(Object sourceId, Object targetId) { final String uid = registry.nodeUniqueId(sourceId); final String uid2 = registry.nodeUniqueId(targetId); if (uid != null && uid2 != null) { final Association association = new Association(uid, uid2); associations.add(association); return association; } return null; }
public Association addExistingAssociation(Object sourceId, Object targetId) { final String uid = registry.existingUniqueId(sourceId); final String uid2 = registry.existingUniqueId(targetId); if (uid != null && uid2 != null) { final Association association = new Association(uid, uid2); associations.add(association); return association; } return null; }
public Node addPossibleNode(Object id) { final String uid = registry.existingUniqueId(id); if (uid == null) { return null; } Node node = (Node) nodes.get(uid); if (node == null) { node = new Node(registry, uid); nodes.put(uid, node); } return node; }
public Node addNode(Object id) { final String uid = registry.nodeUniqueId(id); Node node = (Node) nodes.get(uid); if (node == null) { node = new Node(registry, uid); nodes.put(uid, node); } return node; }
public Cluster addCluster(Object id) { final String uid = registry.nodeUniqueId(id); Cluster node = (Cluster) nodes.get(uid); if (node == null) { node = new Cluster(registry, uid); nodes.put(uid, node); } return node; }
public DotGraph(final String title, String direction) { this.root = new Digraph(registry, title, direction); }
public String toString() { return "GoogleChartDotWriter path=" + path + " imageExtension=" + getImageExtension(); } }
public String render() { return root.render(); }
public String preloadNode(Object id) { return registry.nodeUniqueId(id); }
public AbstractNode addStereotype(String stereotype) { stereotypes.add(DotRenderer.stereotype(stereotype)); return this; }
public String render() { final StringBuffer out = new StringBuffer(); final String displayLabel = label == null ? null : "label=\"" + label + "\""; out.append(DotRenderer.edge(sourceId, targetId, comment, displayLabel, options)); return out.toString(); }
public DotGraph(final String title) { this.root = new Digraph(registry, title); }