Search in sources :

Example 1 with WFLine

use of org.compiere.apps.wf.WFLine in project adempiere by adempiere.

the class WFNodeContainer method createLines.

/**
	 * 	Create Lines.
	 * 	Called by WF Layout Manager
	 */
protected void createLines() {
    log.fine("Lines #" + m_lines.size());
    for (int i = 0; i < m_lines.size(); i++) {
        WFLine line = (WFLine) m_lines.get(i);
        Rectangle from = findBounds(line.getAD_WF_Node_ID());
        Rectangle to = findBounds(line.getAD_WF_Next_ID());
        line.setFromTo(from, to);
    //	same bounds as parent
    //	line.setBounds(0,0, width, height);
    }
//	for all lines
}
Also used : WFLine(org.compiere.apps.wf.WFLine) Rectangle(java.awt.Rectangle)

Example 2 with WFLine

use of org.compiere.apps.wf.WFLine in project adempiere by adempiere.

the class WFPanel method load.

//	dispose
/**
	 * 	Load Workflow & Nodes
	 * 	@param AD_Workflow_ID ID
	 */
public void load(int AD_Workflow_ID) {
    log.fine("AD_Workflow_ID=" + AD_Workflow_ID);
    if (AD_Workflow_ID == 0)
        return;
    int AD_Client_ID = Env.getAD_Client_ID(Env.getCtx());
    //	Get Workflow
    m_wf = new MWorkflow(Env.getCtx(), AD_Workflow_ID, null);
    nodeContainer.removeAll();
    nodeContainer.setWorkflow(m_wf);
    //	Add Nodes for Paint
    MWFNode[] nodes = m_wf.getNodes(true, AD_Client_ID);
    for (int i = 0; i < nodes.length; i++) {
        WFNode wfn = new WFNode(nodes[i]);
        nodeContainer.add(wfn);
        //	Add Lines
        MWFNodeNext[] nexts = nodes[i].getTransitions(AD_Client_ID);
        for (int j = 0; j < nexts.length; j++) nodeContainer.add(new WFLine(nexts[j]));
    }
    Dimension dimension = nodeContainer.getDimension();
    BufferedImage bi = new BufferedImage(dimension.width + 2, dimension.height + 2, BufferedImage.TYPE_INT_ARGB);
    nodeContainer.paint(bi.createGraphics());
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    try {
        ImageIO.write(bi, "png", os);
        AImage imageContent = new AImage("workflow.png", os.toByteArray());
        Imagemap image = new Imagemap();
        image.setWidth(dimension.width + "px");
        image.setHeight(dimension.height + "px");
        image.setContent(imageContent);
        contentPanel.appendChild(image);
        image.addEventListener(Events.ON_CLICK, this);
        for (WFNode node : nodeContainer.getNodes()) {
            Area area = new Area();
            Rectangle rect = node.getBounds();
            area.setCoords(rect.x + "," + rect.y + "," + (rect.x + rect.width) + "," + (rect.y + rect.height));
            image.appendChild(area);
            area.setId("WFN_" + node.getAD_WF_Node_ID());
            StringBuffer tooltip = new StringBuffer();
            String s = node.getNode().getDescription(true);
            if (s != null && s.trim().length() > 0)
                tooltip.append(s);
            String h = node.getNode().getHelp(true);
            if (h != null && h.trim().length() > 0) {
                if (tooltip.length() > 0)
                    tooltip.append(". ");
                tooltip.append(h);
            }
            area.setTooltiptext(tooltip.toString());
        }
    } catch (Exception e) {
        log.log(Level.SEVERE, e.getLocalizedMessage(), e);
    }
    //	Info Text
    StringBuffer msg = new StringBuffer("");
    msg.append("<H2>").append(m_wf.getName(true)).append("</H2>");
    String s = m_wf.getDescription(true);
    if (s != null && s.length() > 0)
        msg.append("<B>").append(s).append("</B>");
    s = m_wf.getHelp(true);
    if (s != null && s.length() > 0)
        msg.append("<BR>").append(s);
    infoTextPane.setContent(msg.toString());
}
Also used : MWFNode(org.compiere.wf.MWFNode) MWorkflow(org.compiere.wf.MWorkflow) Rectangle(java.awt.Rectangle) MWFNode(org.compiere.wf.MWFNode) Dimension(java.awt.Dimension) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MWFNodeNext(org.compiere.wf.MWFNodeNext) BufferedImage(java.awt.image.BufferedImage) ApplicationException(org.adempiere.webui.exception.ApplicationException) Area(org.zkoss.zul.Area) WFLine(org.compiere.apps.wf.WFLine) AImage(org.zkoss.image.AImage) Imagemap(org.zkoss.zul.Imagemap)

Example 3 with WFLine

use of org.compiere.apps.wf.WFLine in project adempiere by adempiere.

the class WFEditor method load.

private void load(int workflowId) {
    //	Get Workflow
    MWorkflow wf = new MWorkflow(Env.getCtx(), workflowId, null);
    WFNodeContainer nodeContainer = new WFNodeContainer();
    nodeContainer.setWorkflow(wf);
    //	Add Nodes for Paint
    MWFNode[] nodes = wf.getNodes(true, Env.getAD_Client_ID(Env.getCtx()));
    for (int i = 0; i < nodes.length; i++) {
        WFNode wfn = new WFNode(nodes[i]);
        nodeContainer.add(wfn);
        //	Add Lines
        MWFNodeNext[] nexts = nodes[i].getTransitions(Env.getAD_Client_ID(Env.getCtx()));
        for (int j = 0; j < nexts.length; j++) nodeContainer.add(new WFLine(nexts[j]));
    }
    Dimension dimension = nodeContainer.getDimension();
    BufferedImage bi = new BufferedImage(dimension.width + 2, dimension.height + 2, BufferedImage.TYPE_INT_ARGB);
    nodeContainer.paint(bi.createGraphics());
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    try {
        ImageIO.write(bi, "png", os);
        AImage imageContent = new AImage("workflow.png", os.toByteArray());
        imageMap.setWidth(dimension.width + "px");
        imageMap.setHeight(dimension.height + "px");
        imageMap.setContent(imageContent);
    } catch (Exception e) {
        logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
    }
}
Also used : MWFNode(org.compiere.wf.MWFNode) MWorkflow(org.compiere.wf.MWorkflow) MWFNode(org.compiere.wf.MWFNode) Dimension(java.awt.Dimension) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MWFNodeNext(org.compiere.wf.MWFNodeNext) BufferedImage(java.awt.image.BufferedImage) WFLine(org.compiere.apps.wf.WFLine) AImage(org.zkoss.image.AImage)

Example 4 with WFLine

use of org.compiere.apps.wf.WFLine in project adempiere by adempiere.

the class WFNodeContainer method paint.

/**************************************************************************
	 * 	Paint Component.
	 * 	Paint Lines directly as not added.
	 *	@param g graphics
	 */
public void paint(Graphics2D g) {
    for (int i = 0; i < m_nodes.size(); i++) {
        WFNode node = m_nodes.get(i);
        Rectangle rect = node.getBounds();
        g.setColor(Color.BLACK);
        g.drawRect(rect.x, rect.y, rect.width, rect.height);
        Graphics2D t = (Graphics2D) g.create(rect.x, rect.y, rect.width, rect.height);
        node.paint(t);
        t.dispose();
    }
    //	for all components
    createLines();
    //	Paint Lines
    for (int i = 0; i < m_lines.size(); i++) {
        WFLine line = (WFLine) m_lines.get(i);
        line.paint(g);
    }
}
Also used : WFLine(org.compiere.apps.wf.WFLine) Rectangle(java.awt.Rectangle) Graphics2D(java.awt.Graphics2D)

Example 5 with WFLine

use of org.compiere.apps.wf.WFLine in project adempiere by adempiere.

the class WWFPanelManufacturing method load.

private void load(int workflowId) {
    //	Get Workflow
    MWorkflow wf = new MWorkflow(Env.getCtx(), workflowId, null);
    WFNodeContainer nodeContainer = new WFNodeContainer();
    nodeContainer.setWorkflow(wf);
    //	Add Nodes for Paint
    MWFNode[] nodes = wf.getNodes(true, Env.getAD_Client_ID(Env.getCtx()));
    for (int i = 0; i < nodes.length; i++) {
        WFNode wfn = new WFNode(nodes[i]);
        nodeContainer.add(wfn);
        //	Add Lines
        MWFNodeNext[] nexts = nodes[i].getTransitions(Env.getAD_Client_ID(Env.getCtx()));
        for (int j = 0; j < nexts.length; j++) nodeContainer.add(new WFLine(nexts[j]));
    }
    Dimension dimension = nodeContainer.getDimension();
    BufferedImage bi = new BufferedImage(dimension.width + 2, dimension.height + 2, BufferedImage.TYPE_INT_ARGB);
    nodeContainer.paint(bi.createGraphics());
    ByteArrayOutputStream os = new ByteArrayOutputStream();
    try {
        ImageIO.write(bi, "png", os);
        AImage imageContent = new AImage("workflow.png", os.toByteArray());
        imageMap.setWidth(dimension.width + "px");
        imageMap.setHeight(dimension.height + "px");
        imageMap.setContent(imageContent);
    } catch (Exception e) {
        logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
    }
}
Also used : WFNode(org.adempiere.webui.apps.wf.WFNode) MWFNode(org.compiere.wf.MWFNode) MWorkflow(org.compiere.wf.MWorkflow) MWFNode(org.compiere.wf.MWFNode) ByteArrayOutputStream(java.io.ByteArrayOutputStream) MWFNodeNext(org.compiere.wf.MWFNodeNext) BufferedImage(java.awt.image.BufferedImage) WFLine(org.compiere.apps.wf.WFLine) AImage(org.zkoss.image.AImage) WFNodeContainer(org.adempiere.webui.apps.wf.WFNodeContainer)

Aggregations

WFLine (org.compiere.apps.wf.WFLine)5 Rectangle (java.awt.Rectangle)3 BufferedImage (java.awt.image.BufferedImage)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 MWFNode (org.compiere.wf.MWFNode)3 MWFNodeNext (org.compiere.wf.MWFNodeNext)3 MWorkflow (org.compiere.wf.MWorkflow)3 AImage (org.zkoss.image.AImage)3 Dimension (java.awt.Dimension)2 Graphics2D (java.awt.Graphics2D)1 WFNode (org.adempiere.webui.apps.wf.WFNode)1 WFNodeContainer (org.adempiere.webui.apps.wf.WFNodeContainer)1 ApplicationException (org.adempiere.webui.exception.ApplicationException)1 Area (org.zkoss.zul.Area)1 Imagemap (org.zkoss.zul.Imagemap)1