Skip to content

Commit

Permalink
Working on new visualization of BPMN models
Browse files Browse the repository at this point in the history
  • Loading branch information
delas committed Oct 30, 2018
1 parent bb0c4af commit c9970cf
Show file tree
Hide file tree
Showing 24 changed files with 579 additions and 231 deletions.
2 changes: 1 addition & 1 deletion libPlg/src/plg/generator/log/LogGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private XLog unfinishedLogGeneration() throws Exception {
progress.start();

// define the number of CPU cores to use
int coresToUse = (parameters.useMultithreading())? CPUUtils.CPUAvailable() : 1;
int coresToUse = 1; //(parameters.useMultithreading())? CPUUtils.CPUAvailable() : 1;
Logger.instance().info("Starting simulation with " + coresToUse + " cores");

// prepare the engine
Expand Down
58 changes: 30 additions & 28 deletions libPlg/src/plg/generator/scriptexecuter/IntegerScriptExecutor.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
package plg.generator.scriptexecuter;

import plg.exceptions.InvalidScript;

/**
* This class describes a script executor that will generate an integer value
*
* @author Andrea Burattin
*/
public class IntegerScriptExecutor extends ScriptExecutor {

/**
* Script constructor
*
* @param script a Python script
*/
public IntegerScriptExecutor(String script) {
super(script);
}

@Override
public Integer getValue() throws InvalidScript {
if (result == null) {
return null;
}
return (Integer) result.__tojava__(Integer.class);
}
}
package plg.generator.scriptexecuter;

import org.python.core.Py;

import plg.exceptions.InvalidScript;

/**
* This class describes a script executor that will generate an integer value
*
* @author Andrea Burattin
*/
public class IntegerScriptExecutor extends ScriptExecutor {

/**
* Script constructor
*
* @param script a Python script
*/
public IntegerScriptExecutor(String script) {
super(script);
}

@Override
public Integer getValue() throws InvalidScript {
if (result == null) {
return null;
}
return Py.py2int(result);
}
}
58 changes: 30 additions & 28 deletions libPlg/src/plg/generator/scriptexecuter/StringScriptExecutor.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
package plg.generator.scriptexecuter;

import plg.exceptions.InvalidScript;

/**
* This class describes a script executor that will generate a string value
*
* @author Andrea Burattin
*/
public class StringScriptExecutor extends ScriptExecutor {

/**
* Script constructor
*
* @param script a Python script
*/
public StringScriptExecutor(String script) {
super(script);
}

@Override
public String getValue() throws InvalidScript {
if (result == null) {
return null;
}
return (String) result.__tojava__(String.class);
}
}
package plg.generator.scriptexecuter;

import org.python.antlr.adapter.AstAdapters;

import plg.exceptions.InvalidScript;

/**
* This class describes a script executor that will generate a string value
*
* @author Andrea Burattin
*/
public class StringScriptExecutor extends ScriptExecutor {

/**
* Script constructor
*
* @param script a Python script
*/
public StringScriptExecutor(String script) {
super(script);
}

@Override
public String getValue() throws InvalidScript {
if (result == null) {
return null;
}
return result.__tojava__(Object.class).toString();
}
}
20 changes: 12 additions & 8 deletions libPlg/src/plg/test/LogGeneratorMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,22 @@
import plg.generator.ProgressAdapter;
import plg.generator.log.LogGenerator;
import plg.generator.log.SimulationConfiguration;
import plg.generator.log.noise.NoiseConfiguration;
import plg.io.importer.BPMNImporter;
import plg.io.importer.PLGImporter;
import plg.model.Process;

public class LogGeneratorMain {

public static void main(String[] args) throws Exception {
if (args.length != 3) {
System.err.println("Please use: java -jar LogGenerator.jar MODEL_FILE LOG_DESTINATION NO_TRACES");
System.exit(-1);
}
// if (args.length != 3) {
// System.err.println("Please use: java -jar LogGenerator.jar MODEL_FILE LOG_DESTINATION NO_TRACES");
// System.exit(-1);
// }

String modelFile = args[0];
String logDestination = args[1];
Integer noTraces = Integer.parseInt(args[2]);
String modelFile = "C:\\Users\\andbur\\Desktop\\authorization-request-extension.plg"; //args[0];
String logDestination = "C:\\Users\\andbur\\Desktop\\extension-log.xes"; //args[1];
Integer noTraces = 1000;

System.out.println("Welcome!");

Expand All @@ -32,7 +34,8 @@ public static void main(String[] args) throws Exception {
System.out.println("No. of traces: " + noTraces);

System.out.print("1. Importing model... ");
BPMNImporter importer = new BPMNImporter();
// BPMNImporter importer = new BPMNImporter();
PLGImporter importer = new PLGImporter();
Process p = importer.importModel(modelFile, new ProgressAdapter());
System.out.println("done!");

Expand All @@ -42,6 +45,7 @@ public static void main(String[] args) throws Exception {

System.out.print("3. Generating log... ");
SimulationConfiguration sc = new SimulationConfiguration(noTraces);
sc.setNoiseConfiguration(NoiseConfiguration.NO_NOISE);
LogGenerator generator = new LogGenerator(p, sc, new ProgressAdapter());
XLog log = generator.generateLog();
System.out.println("done!");
Expand Down
22 changes: 13 additions & 9 deletions libPlgVisualizer/.classpath
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry combineaccessrules="false" kind="src" path="/libPlg"/>
<classpathentry kind="lib" path="lib/jgraphx/jgraphx.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/plgResources"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry combineaccessrules="false" kind="src" path="/libPlg"/>
<classpathentry kind="lib" path="lib/jgraphx/jgraphx.jar"/>
<classpathentry kind="lib" path="lib/GraphViz-latest.jar"/>
<classpathentry kind="lib" path="lib/KitFox.jar"/>
<classpathentry kind="lib" path="lib/commons-lang3-3.8.1.jar"/>
<classpathentry kind="lib" path="lib/commons-io-2.6.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/plgResources"/>
<classpathentry kind="output" path="bin"/>
</classpath>
Binary file added libPlgVisualizer/lib/GraphViz-latest.jar
Binary file not shown.
Binary file added libPlgVisualizer/lib/KitFox.jar
Binary file not shown.
Binary file added libPlgVisualizer/lib/commons-io-2.6.jar
Binary file not shown.
Binary file added libPlgVisualizer/lib/commons-lang3-3.8.1.jar
Binary file not shown.
30 changes: 30 additions & 0 deletions libPlgVisualizer/src/plg/visualizer/BPMNVisualizer2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package plg.visualizer;

import java.awt.Color;

import org.processmining.plugins.graphviz.visualisation.DotPanel;

import plg.model.Process;
import plg.visualizer.model.DotModel;

/**
* This widget is used to visualize a BPMN model.
*
* @author Andrea Burattin
*/
public class BPMNVisualizer2 extends DotPanel {

private static final long serialVersionUID = -8441909033110442685L;

/**
* Class constructor
*
* @param process the process graph to show
*/
public BPMNVisualizer2(Process process) {
super(new DotModel(process));

setOpaque(true);
setBackground(Color.WHITE);
}
}
72 changes: 72 additions & 0 deletions libPlgVisualizer/src/plg/visualizer/model/DotModel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package plg.visualizer.model;

import java.util.HashMap;
import java.util.Map;

import org.processmining.plugins.graphviz.dot.Dot;
import org.processmining.plugins.graphviz.dot.DotNode;

import plg.model.Component;
import plg.model.FlowObject;
import plg.model.Process;
import plg.model.data.DataObject;
import plg.model.data.IDataObjectOwner.DATA_OBJECT_DIRECTION;
import plg.model.sequence.Sequence;
import plg.visualizer.model.edges.DotDataObjectConnection;
import plg.visualizer.model.edges.DotSequence;
import plg.visualizer.model.nodes.DotNodesFactory;

/**
*
* @author Andrea Burattin
*/
public class DotModel extends Dot {

private Process model;

public DotModel(Process model) {
this.model = model;

// setOption("splines", "ortho");
// setOption("nodesep", "0.5");
setOption("rankdir", "LR");

realize();
}

private void realize() {
Map<String, DotNode> idToNodes = new HashMap<String, DotNode>();

// adding all nodes
for (Component node : model.getComponents()) {
if (node instanceof FlowObject || node instanceof DataObject) {
DotNode dotNode = DotNodesFactory.construct(node);
idToNodes.put(node.getId(), dotNode);
addNode(dotNode);
}
}

// adding all edges
for (Sequence sequence : model.getSequences()) {
DotNode source = idToNodes.get(sequence.getSource().getId());
DotNode sink = idToNodes.get(sequence.getSink().getId());
addEdge(new DotSequence(source, sink));
}

// connecting all data objects
for (DataObject dobj : model.getDataObjects()) {
if (dobj.getObjectOwner() != null) {
DotNode source = null;
DotNode sink = null;
if (dobj.getDirectionOwner() == DATA_OBJECT_DIRECTION.GENERATED) {
source = idToNodes.get(dobj.getObjectOwner().getId());
sink = idToNodes.get(dobj.getId());
} else {
source = idToNodes.get(dobj.getId());
sink = idToNodes.get(dobj.getObjectOwner().getId());
}
addEdge(new DotDataObjectConnection(source, sink));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package plg.visualizer.model.edges;

import org.processmining.plugins.graphviz.dot.DotEdge;
import org.processmining.plugins.graphviz.dot.DotNode;

/**
*
* @author Andrea Burattin
*/
public class DotDataObjectConnection extends DotEdge {

public DotDataObjectConnection(DotNode source, DotNode target) {
super(source, target);

setOption("color", "#666666");
setOption("style", "dashed");
setOption("arrowhead", "open");
}
}
17 changes: 17 additions & 0 deletions libPlgVisualizer/src/plg/visualizer/model/edges/DotSequence.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package plg.visualizer.model.edges;

import org.processmining.plugins.graphviz.dot.DotEdge;
import org.processmining.plugins.graphviz.dot.DotNode;

/**
*
* @author Andrea Burattin
*/
public class DotSequence extends DotEdge {

public DotSequence(DotNode source, DotNode target) {
super(source, target);

setOption("color", "#5a677b");
}
}
29 changes: 29 additions & 0 deletions libPlgVisualizer/src/plg/visualizer/model/nodes/DotDataObject.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package plg.visualizer.model.nodes;

import org.processmining.plugins.graphviz.dot.DotNode;

import plg.model.data.DataObject;

/**
*
* @author Andrea Burattin
*/
public class DotDataObject extends DotNode {

public DotDataObject(DataObject node) {
super(node.getName(), null);

setSelectable(true);

setOption("shape", "note");
setOption("fontsize", "10");
setOption("width", "0.5");
setOption("height", "0.5");
setOption("style", "filled");
setOption("fillcolor", "#ffffff");
setOption("color", "#666666");
setOption("fontcolor", "#666666");
setOption("fontname", "sans-serif");
}

}
28 changes: 28 additions & 0 deletions libPlgVisualizer/src/plg/visualizer/model/nodes/DotEndEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package plg.visualizer.model.nodes;

import org.processmining.plugins.graphviz.dot.DotNode;

/**
*
* @author Andrea Burattin
*/
public class DotEndEvent extends DotNode {

public DotEndEvent() {
super("", null);

setSelectable(true);

setOption("shape", "circle");
setOption("style", "filled");
setOption("fillcolor", "#e46e60:#ffc5c1");
setOption("gradientangle", "270");
setOption("color", "#630000");
setOption("width", ".3");
setOption("fontcolor", "#630000");
setOption("fontname", "sans-serif");
setOption("fontsize", "12.0");
setOption("penwidth", "2");
}

}
Loading

0 comments on commit c9970cf

Please sign in to comment.