use of com.centurylink.mdw.designer.runtime.RunTimeDesignerImage in project mdw-designer by CenturyLinkCloud.
the class ImageServletHelper method generateImage.
/**
* Generate a process image from the designer server.
*/
private BufferedImage generateImage(ProcessInstanceVO pProcInst, DesignerDataAccess dao) throws ServletException {
try {
log("Loading Process " + pProcInst.getProcessId());
NodeMetaInfo metainfo = new NodeMetaInfo();
metainfo.init(dao.getActivityImplementors(), DataAccess.currentSchemaVersion);
ProcessVO processVO = dao.getProcess(new Long(pProcInst.getProcessId()), null);
new ProcessWorker().convert_to_designer(processVO);
pProcInst.setProcessName(processVO.getProcessName());
Graph graph = loadCompletionMap(processVO, pProcInst, dao, metainfo);
Dimension graphsize = graph.getGraphSize();
RunTimeDesignerImage canvas = new RunTimeDesignerImage(graph, dao);
int hMargin = 72, vMargin = 72;
BufferedImage image = new BufferedImage(graphsize.width + hMargin, graphsize.height + vMargin, BufferedImage.TYPE_INT_RGB);
Graphics2D g2 = image.createGraphics();
g2.setBackground(Color.WHITE);
g2.clearRect(0, 0, image.getWidth(), image.getHeight());
canvas.paintComponent(g2);
g2.dispose();
return image;
} catch (Throwable t) {
log(t);
if (t.getCause() != null) {
log(t.getCause());
}
throw new ServletException(t);
}
}
Aggregations