To prevent spam users, you can only post on this forum after registration, which is by invitation. If you want to post on the forum, please send me a mail (h DOT m DOT w DOT verbeek AT tue DOT nl) and I'll send you an invitation in return for an account.

Export graph image when using command line

Michel
edited December 2011 in - Development

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

Best Answer

  • JBuijs
    Accepted Answer
    Hi Michel,

    First of all: welcome on the ProM forum!

    I know that some visualizers (for instance the PetriNet and Heuristic net)  use the 'freehep' library to allow for exporting of the visualization.
    This is build in the framework so the library is available on all ProM installations.

    I would suggest that you investigate how you can automatically execute a conversion. I think that it should be possible.

    Let us know if you got it to work. And good luck on your plugin.
    Joos Buijs

    Senior Data Scientist and process mining expert at APG (Dutch pension fund executor).
    Previously Assistant Professor in Process Mining at Eindhoven University of Technology

Answers

  • Michel
    edited January 2012

    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();
       }
    }

  • Hi Michel,

    Thank you for sharing the solution! This helps others who are trying to achieve the same.
    Joos Buijs

    Senior Data Scientist and process mining expert at APG (Dutch pension fund executor).
    Previously Assistant Professor in Process Mining at Eindhoven University of Technology
Sign In or Register to comment.