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
}
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());
}
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);
}
}
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);
}
}
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);
}
}
Aggregations