-
1. Re: showing image of current process stage
heinerniehues Aug 6, 2007 10:10 AM (in response to yairfr)Hi,
I intend to create a similar program. Maybe you can give me a tip how you realized to show the red rectangle. Would be very nice.
Heiner -
2. Re: showing image of current process stage
yairfr Aug 6, 2007 10:25 AM (in response to yairfr)here it is.
you need to print via JSPout the output. to see.
th function get the process instance idpublic StringBuffer showProcessImage (long processInstanceId) { byte[] gpdBytes = null; byte[] imageBytes = null; Token currentToken=null; String currentTokenColor = "red"; long taskInstanceId=0; StringBuffer Sb = new StringBuffer(); TaskInstance taskInstance=null; JbpmContext context = conf.createJbpmContext(); GraphSession graphSession = context.getGraphSession(); ProcessInstance pi = graphSession.loadProcessInstance(processInstanceId); TaskMgmtInstance tmi = pi.getTaskMgmtInstance(); try { Collection tis = tmi.getUnfinishedTasks(pi.getRootToken()); Iterator taskInstances = tis.iterator(); if (taskInstances.hasNext()) { TaskInstance ti = (TaskInstance)taskInstances.next(); taskInstanceId = ti.getId(); taskInstance = context.getTaskMgmtSession().loadTaskInstance(taskInstanceId); } else //process has finished { Collection allTasks = tmi.getTaskInstances(); Iterator AlltaskInstances = allTasks.iterator(); TaskInstance LastInstance=null; while (AlltaskInstances.hasNext()) { LastInstance = (TaskInstance)AlltaskInstances.next(); } taskInstanceId = LastInstance.getId(); taskInstance = context.getTaskMgmtSession().loadTaskInstance(taskInstanceId); } currentToken = taskInstance.getToken(); ProcessDefinition processDefinition = currentToken.getProcessInstance().getProcessDefinition(); //String NodeName = currentToken.getProcessInstance().getRootToken().getNode().getName(); FileDefinition fileDefinition = processDefinition.getFileDefinition(); if (fileDefinition == null) { fileDefinition = new FileDefinition(); processDefinition.addDefinition(fileDefinition); } String Path = Configuration.instance().GetParameter("","ProcessPath"); Path += processDefinition.getName(); addFileResourceToFileDefinition(fileDefinition, Path, "processimage.jpg"); addFileResourceToFileDefinition(fileDefinition, Path, "gpd.xml"); if (new File(Path + "\\gpd.xml").exists()) { //if(fileDefinition!=null) //{ //gpdBytes = fileDefinition.getBytes("gpd.xml"); gpdBytes = processDefinition.getFileDefinition().getBytes("gpd.xml"); imageBytes = processDefinition.getFileDefinition().getBytes("processimage.jpg"); if (gpdBytes != null && imageBytes != null) { int borderWidth = 4; Element rootDiagramElement = DocumentHelper.parseText(new String(gpdBytes)).getRootElement(); int[] boxConstraint; int[] imageDimension = extractImageDimension(rootDiagramElement); //String imageLink = "processimage?definitionId="+ processDefinition.getId(); String imageLink = Path + "\\processimage.jpg"; //jspOut.println("</div>"); //} //else { boxConstraint = extractBoxConstraint(rootDiagramElement,currentToken); Sb.append("<script language='javascript'>"); Sb.append("window.contentHeight = " + imageDimension[1] +";"); Sb.append("window.contentWidth=" + imageDimension[0]+";"); Sb.append("</script>"); Sb.append("<table border=0 cellspacing=0 cellpadding=0 width=" + imageDimension[0] + " height=" + imageDimension[1] + ">"); Sb.append(" <tr>"); Sb.append(" <td width=" + imageDimension[0] + " height=" + imageDimension[1] + " style=\"background-image:url(" + imageLink + ")\" valign=top>"); Sb.append(" <table border=0 cellspacing=0 cellpadding=0>"); Sb.append(" <tr>"); Sb.append(" <td width=" + (boxConstraint[0] - borderWidth) + " height=" + (boxConstraint[1] - borderWidth) + " style=\"background-color:transparent;\"></td>"); Sb.append(" </tr>"); Sb.append(" <tr>"); Sb.append(" <td style=\"background-color:transparent;\"></td>"); Sb.append(" <td style=\"border-color:" + currentTokenColor + "; border-width:" + borderWidth + "px; border-style:groove; background-color:transparent;\" width=" + boxConstraint[2] + " height=" + (boxConstraint[3] + (2 * borderWidth)) + "> </td>"); Sb.append(" </tr>"); Sb.append(" </table>"); Sb.append(" </td>"); Sb.append(" </tr>"); Sb.append("</table>"); } } } catch (Exception e) { e.printStackTrace(); //throw new JspException("table couldn't be displayed", e); } context.close(); taskInstanceId = -1; gpdBytes = null; imageBytes = null; currentToken = null; return Sb; }
-
3. Re: showing image of current process stage
heinerniehues Aug 6, 2007 10:47 AM (in response to yairfr)Thanks a lot - I will try it..
Heiner -
4. Re: showing image of current process stage
heinerniehues Aug 6, 2007 5:04 PM (in response to yairfr)I have also this problem.. that the rectangle are not at the right place.
But i used a javascript library (http://www.walterzorn.com/jsgraphics/jsgraphics_e.htm)
to create the rectangle.
I use a offset to fix it. I will take a look tomorrow more.<html> <head><title>Show the Picture</title> <script type="text/javascript" src="js/wz_jsgraphics.js"></script> </head> <body> <div style="left:0px; top:0px; position:absolute;"> <img src="img\processimage.jpg" alt=""> </div> <script type="text/javascript"> <!-- function drawRect(x,y,width, height) { jg_doc.setColor("red"); jg_doc.setStroke(4); jg_doc.drawRect(x, y, width, height); jg_doc.paint(); } var jg_doc = new jsGraphics(); drawRect(${coord[0]} + 217,${coord[1]} - 2 ,${coord[2]},${coord[3]}); //--> </script> </body> </html>
Heiner -
5. Re: showing image of current process stage
dleerob Sep 14, 2007 8:43 AM (in response to yairfr)Try this thread. I posted my solution there which works perfectly for me: http://www.jboss.com/index.html?module=bb&op=viewtopic&t=102817
-
6. Re: showing image of current process stage
rajeshvcpp Mar 17, 2009 10:50 AM (in response to yairfr)Hi...
really a nice post...
i am working on the same example but i know very little about java
the line "Configuration.instance().GetParameter("","ProcessPath");" is not compiling as i am unable to find any class with name configuration....
please help me regarding some file inclusions sso that the code will get compiled....
thanks in advance...
Raje