It looks like you're new here. If you want to get involved, click one of these buttons!
Hey,
For my master thesis project I have created a plug-in for ProM 6 that mines a log, resulting in a graph which extends an AbstractDirectedGraph, which is then visualized in ProM. The plug-in itself is working fine.
However, the idea now is that the plug-in should also be able to run through command line, which (for the mining part) it does. But, I would also like to output an image of the graph to disk (in any (common) format) when running it through the command line.
So my question is: Does anyone know if there is a way to export a graph to disk (as an image) without using the GUI of ProM?
Regards,
Michel
Answers
First of all: Best wishes to everyone at this forum!
<SOLVED>
Using the freehep library works. However, I can't seem to get the graph visualized.
I use the following call to get the visualization panel:
mainPanel = ProMJGraphVisualizer.instance().visualizeGraph(pluginContext, pdmmodel); //pdmmodel extends AbstractDirectedGraph<...>
After which I am able to print the main visualization panel, but not the graph itself.
So either I'm missing something or the visualizeGraph() doesn't actually visualize the graph on the panel (that it returns) and I need to do something else in order to get the graph visualized (which I can't seem to figure out)...
Edit: Seems the size of the graph was not set:
ProMJGraph graph = (ProMJGraph) mainPanel.getComponent();
graph.setSize(new Dimension(500,500)
Did the trick, together with printing this component using freehep.
Code to output a .pdf file:
public static void visualize2(PDMModel pdmmodel) {
CLIContext context = new CLIContext();
CLIPluginContext pluginContext = new CLIPluginContext(context, "test");
ProMJGraphPanel mainPanel = ProMJGraphVisualizer.instance().visualizeGraph(pluginContext, pdmmodel); //pdmmodel extends AbstractDirectedGraph
mainPanel.setSize(new Dimension(500,500));
// Get graph
ProMJGraph graph = (ProMJGraph) mainPanel.getComponent();
graph.setSize(new Dimension(500,500));
try {
VectorGraphics g = new PDFGraphics2D(new File("output.pdf"), new Dimension(500,500));
g.setProperties(new Properties());
g.startExport();
graph.print(g);
g.endExport();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Thank you for sharing the solution! This helps others who are trying to achieve the same.
Senior Data Scientist and process mining expert at APG (Dutch pension fund executor).
Previously Assistant Professor in Process Mining at Eindhoven University of Technology