Search code examples
javajgraph

Jgraph (vanilla): how to set edge label, ProM-specific


I'm currently writing a plugin for ProM in case someone is familiar with it. In general, there is a graph, represented as ProMJGraph, which is directly derived from JGraph.

This graph contains:

  • ProMGraphEdge's (direct child of org.jgraph.graph.DefaultEdge) and
  • ProMGraphCell's (direct child of org.jgraph.graph.DefaultGraphCell).

I have to put labels onto the edges. For example I stored a pointer to the first edge of the graph named jgraph to the variable e0, of type ProMGraphEdge.

I failed to google out, where and what should I now call in order to set the label «hello» for the edge e0?


If anyone at list has a link to JGraph manual, please post it here. I failed to find a referencebook for jgraph and NOT JGraphX, nor JGraphT.

upd. Found it: http://touchflow.googlecode.com/hg-history/75fada644b2a19c744130923cbd34747fba861a2/doc/jgraphmanual.pdf

upd2. I found chapter 3.5.2 «Using edges» which should contain the answer to my question. It's probably ProM-specific that the source provided in the pdf does not work for me. Maybe if there is anyone exprienced in the Process Miner (ProM), he/she can give me some hint if there is something tricky about ProMJGraph.


Solution

  • It occured to be ProM-specific.

    The section 3.5.2 of the pdf mentioned in the question contains the answer about how to add a label to a plain JGraph, and I had to use a bit different code to get any effect:

    newArc = addArc(places.get(src), transitions.get(dest));
    if (label != null) {        
        AttributeMap amap = newArc.getAttributeMap();
        amap.put(AttributeMap.LABEL, "Hello world");
        amap.put(AttributeMap.SHOWLABEL, true);
        amap.put(AttributeMap.LABELALONGEDGE, true);
    }
    

    This code resides in a class derived from AbstractResetInhibitorNet, the instance of which is called graph. This instance is later converted to a JGraph with a code

    ProMJGraphPanel visualizeGraph(PluginContext context,
                                   CPNGraph graph, // instanceof AbstractResetInhibitorNet
                                   ViewSpecificAttributeMap map) {
        ProMGraphModel model = new ProMGraphModel(graph);
        GraphLayoutConnection layoutConnection = new GraphLayoutConnection(graph);
        layoutConnection.expandAll();
        ProMJGraph jgraph = new ProMJGraph(model, map, layoutConnection);
        ...
    }