Search in sources :

Example 1 with RunTimeDesignerImage

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);
    }
}
Also used : NodeMetaInfo(com.centurylink.mdw.designer.utils.NodeMetaInfo) ServletException(javax.servlet.ServletException) ProcessWorker(com.centurylink.mdw.designer.utils.ProcessWorker) ProcessVO(com.centurylink.mdw.model.value.process.ProcessVO) RunTimeDesignerImage(com.centurylink.mdw.designer.runtime.RunTimeDesignerImage) Dimension(java.awt.Dimension) BufferedImage(java.awt.image.BufferedImage) Graphics2D(java.awt.Graphics2D)

Aggregations

RunTimeDesignerImage (com.centurylink.mdw.designer.runtime.RunTimeDesignerImage)1 NodeMetaInfo (com.centurylink.mdw.designer.utils.NodeMetaInfo)1 ProcessWorker (com.centurylink.mdw.designer.utils.ProcessWorker)1 ProcessVO (com.centurylink.mdw.model.value.process.ProcessVO)1 Dimension (java.awt.Dimension)1 Graphics2D (java.awt.Graphics2D)1 BufferedImage (java.awt.image.BufferedImage)1 ServletException (javax.servlet.ServletException)1