/** * Constructs a new DOTExporter object with an integer name provider for the * vertex IDs and null providers for the vertex and edge labels. */ public DOTExporterTemp() { this(new IntegerNameProvider<V>(), null, null); }
@SuppressWarnings("unused") private static <V,E> void printGraph(Graph<V,E> graph) { DOTExporter<V,E> exp = new DOTExporter<V,E>(new StringNameProvider<V>(), null, null); exp.export(new BufferedWriter(new PrintWriter(System.out)), graph); }
@SuppressWarnings("unused") private static <V, E> void printGraph(final Graph<V, E> graph) { final DOTExporter<V, E> exp = new DOTExporter<>(new StringComponentNameProvider<V>(), null, null); exp.exportGraph(graph, new BufferedWriter(new PrintWriter(System.out))); }
public void doGetDot(StaplerRequest req, StaplerResponse rsp) throws IOException { new DOTExporter<JobInvocation, JobEdge>().export(rsp.getWriter(), jobsGraph); }
static public <V> void export(DiGraph<V> g, CharSink dest) throws IOException { final DOTExporterTemp<V, Edge<V>> exporter = new DOTExporterTemp<V, Edge<V>>(new IntegerNameProvider<V>(), new StringNameProvider<V>(), null); try (Writer writer = dest.openBufferedStream()) { exporter.export(writer, g.getGraph()); } }
/** * Draws a given graph with all its vertices and edges. * * @param graph the graph to be added to the existing graph. */ private void insertJGraphT(Graph<V, E> graph) { for (V vertex : graph.vertexSet()) { addJGraphTVertex(vertex); } for (E edge : graph.edgeSet()) { addJGraphTEdge(edge); } } }
/** * Constructs and draws a new mxGraph from a JGraphT graph. Changes on the JGraphT graph will * not edit this mxGraph any further; use the constructor with the ListenableGraph parameter * instead or use this graph as a normal mxGraph. Throws an IllegalArgumentException if the * parameter is null. * * @param graph is a graph */ public JGraphXAdapter(Graph<V, E> graph) { super(); // Don't accept null as jgrapht graph if (graph == null) { throw new IllegalArgumentException(); } else { this.graphT = graph; } // generate the drawing insertJGraphT(graph); setAutoSizeCells(true); }
@Override public void edgeAdded(GraphEdgeChangeEvent<V, E> e) { addJGraphTEdge(e.getEdge()); }
@Override public void edgeRemoved(GraphEdgeChangeEvent<V, E> e) { removeEdge(e.getEdge()); }
@Override public void vertexAdded(GraphVertexChangeEvent<V> e) { addJGraphTVertex(e.getVertex()); }
/** * Removes a jgrapht edge and its visual representation from this graph completely. * * @param edge The edge that will be removed */ private void removeEdge(E edge) { mxICell cell = edgeToCellMap.remove(edge); removeCells(new Object[] { cell }); // remove edge from hashmaps cellToEdgeMap.remove(cell); edgeToCellMap.remove(edge); }
@SuppressWarnings("unused") private static <V,E> void printGraph(Graph<V,E> graph) { DOTExporter<V,E> exp = new DOTExporter<V,E>(new StringNameProvider<V>(), null, null); exp.export(new BufferedWriter(new PrintWriter(System.out)), graph); }
public CondorDOTExporter() { this(new IntegerNameProvider<V>(), null, null, null); }
/** * Draws a given graph with all its vertices and edges. * * @param graph the graph to be added to the existing graph. */ private void insertJGraphT(Graph<V, E> graph) { for (V vertex : graph.vertexSet()) { addJGraphTVertex(vertex); } for (E edge : graph.edgeSet()) { addJGraphTEdge(edge); } } }
@Override public void edgeAdded(GraphEdgeChangeEvent<V, E> e) { addJGraphTEdge(e.getEdge()); }
@Override public void edgeRemoved(GraphEdgeChangeEvent<V, E> e) { removeEdge(e.getEdge()); }
@Override public void vertexAdded(GraphVertexChangeEvent<V> e) { addJGraphTVertex(e.getVertex()); }
/** * Removes a jgrapht edge and its visual representation from this graph completely. * * @param edge The edge that will be removed */ private void removeEdge(E edge) { mxICell cell = edgeToCellMap.remove(edge); removeCells(new Object[] { cell }); // remove edge from hashmaps cellToEdgeMap.remove(cell); edgeToCellMap.remove(edge); }
public void toDot(File dotFile) { try (FileOutputStream fileStream = new FileOutputStream(dotFile); OutputStreamWriter writer = new OutputStreamWriter(fileStream, "UTF-8");) { DOTExporter<CfgBlock, CfgEdge> dot = new DOTExporter<CfgBlock, CfgEdge>(new StringNameProvider<CfgBlock>(), null, null); dot.export(writer, this); } catch (IOException e) { e.printStackTrace(); } }
public void toSimpleDot(File dotFile) { try (FileOutputStream fileStream = new FileOutputStream(dotFile); OutputStreamWriter writer = new OutputStreamWriter(fileStream, "UTF-8");) { DOTExporter<CfgBlock, CfgEdge> dot = new DOTExporter<CfgBlock, CfgEdge>(new StringNameProvider<CfgBlock>() { @Override public String getVertexName(CfgBlock vertex) { StringBuilder sb = new StringBuilder(); sb.append("\""); sb.append(vertex.getLabel()); sb.append("\""); return sb.toString(); } }, null, null); dot.export(writer, this); } catch (IOException e) { e.printStackTrace(); } }