jaweController.openPackageFromStream(xpdl.getBytes("UTF-8"));
org.enhydra.shark.xpdl.elements.Package pkg = xpdlHandler.getPackageById(packageId);
org.enhydra.shark.xpdl.elements.WorkflowProcess wp = pkg.getWorkflowProcess(processDefId);
GraphController gc = (GraphController) jaweManager.getComponentManager().getComponent("GraphComponent");
gc.selectGraphForElement(wp);
Graph graph = gc.getGraph(wp);
// highlight running activities
if (runningActivityIds != null && runningActivityIds.length > 0) {
graph.clearSelection();
try {
for (int i = 0; i < runningActivityIds.length; i++) {
try {
GraphManager wm = graph.getGraphManager();
Object go = wm.getGraphActivity(runningActivityIds[i]);
if (go != null) {
graph.addSelectionCell(go);
}
} catch (Exception ex) {
LogFactory.getLog(Viewer.class.getName()).error(ex);
}
}
} catch (Exception ex) {
LogFactory.getLog(Viewer.class.getName()).error("Problems while updating selection", ex);
}
}
// generate image
BufferedImage img = null;
Object[] cells = graph.getRoots();
if (cells.length > 0) {
graph.setSize(graph.getPreferredSize());
Rectangle bounds = graph.getCellBounds(cells).getBounds();// HM, JGraph3.4.1
graph.toScreen(bounds);
// Create a Buffered Image
Dimension d = bounds.getSize();
img = new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = img.createGraphics();
graph.paint(graphics);
}
LogFactory.getLog(Viewer.class.getName()).info("Completed generating process image");
return img;