use of org.zkoss.zul.Imagemap in project adempiere by adempiere.
the class WChartEditor method render.
private void render(JFreeChart chart) {
ChartRenderingInfo info = new ChartRenderingInfo();
int width = 400;
int height = chartModel.getWinHeight();
BufferedImage bi = chart.createBufferedImage(width, height, BufferedImage.TRANSLUCENT, info);
try {
byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);
AImage image = new AImage("", bytes);
Imagemap myImage = new Imagemap();
Panel panel = getComponent();
myImage.setContent(image);
if (panel.getPanelchildren() != null) {
panel.getPanelchildren().getChildren().clear();
panel.getPanelchildren().appendChild(myImage);
} else {
Panelchildren pc = new Panelchildren();
panel.appendChild(pc);
pc.appendChild(myImage);
}
int count = 0;
for (Iterator<?> it = info.getEntityCollection().getEntities().iterator(); it.hasNext(); ) {
ChartEntity entity = (ChartEntity) it.next();
String key = null;
String seriesName = null;
if (entity instanceof CategoryItemEntity) {
CategoryItemEntity item = ((CategoryItemEntity) entity);
Comparable<?> colKey = item.getColumnKey();
Comparable<?> rowKey = item.getRowKey();
if (colKey != null && rowKey != null) {
key = colKey.toString();
seriesName = rowKey.toString();
}
} else if (entity instanceof PieSectionEntity) {
Comparable<?> sectionKey = ((PieSectionEntity) entity).getSectionKey();
if (sectionKey != null) {
key = sectionKey.toString();
}
}
if (entity instanceof XYItemEntity) {
XYItemEntity item = ((XYItemEntity) entity);
if (item.getDataset() instanceof TimeSeriesCollection) {
TimeSeriesCollection data = (TimeSeriesCollection) item.getDataset();
TimeSeries series = data.getSeries(item.getSeriesIndex());
TimeSeriesDataItem dataitem = series.getDataItem(item.getItem());
seriesName = series.getKey().toString();
key = dataitem.getPeriod().toString();
}
}
if (key == null)
continue;
Area area = new Area();
myImage.appendChild(area);
area.setCoords(entity.getShapeCoords());
area.setShape(entity.getShapeType());
area.setTooltiptext(entity.getToolTipText());
area.setId(count + "_WG__" + seriesName + "__" + key);
count++;
}
myImage.addEventListener(Events.ON_CLICK, new EventListener() {
public void onEvent(Event event) throws Exception {
MouseEvent me = (MouseEvent) event;
String areaId = me.getArea();
if (areaId != null) {
String[] strs = areaId.split("__");
if (strs.length == 3) {
chartMouseClicked(strs[2], strs[1]);
}
}
}
});
} catch (Exception e) {
log.log(Level.SEVERE, "", e);
}
}
use of org.zkoss.zul.Imagemap 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.zkoss.zul.Imagemap in project adempiere by adempiere.
the class WGraph method render.
// loadData
private void render(JFreeChart chart) {
ChartRenderingInfo info = new ChartRenderingInfo();
int width = 560;
int height = 400;
if (zoomFactor > 0) {
width = width * zoomFactor / 100;
height = height * zoomFactor / 100;
}
if (m_hideTitle) {
chart.setTitle("");
}
BufferedImage bi = chart.createBufferedImage(width, height, BufferedImage.TRANSLUCENT, info);
try {
byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);
AImage image = new AImage("", bytes);
Imagemap myImage = new Imagemap();
myImage.setContent(image);
if (panel.getPanelchildren() != null) {
panel.getPanelchildren().getChildren().clear();
panel.getPanelchildren().appendChild(myImage);
} else {
Panelchildren pc = new Panelchildren();
panel.appendChild(pc);
pc.appendChild(myImage);
}
int count = 0;
for (Iterator<?> it = info.getEntityCollection().getEntities().iterator(); it.hasNext(); ) {
ChartEntity entity = (ChartEntity) it.next();
String key = null;
if (entity instanceof CategoryItemEntity) {
Comparable<?> colKey = ((CategoryItemEntity) entity).getColumnKey();
if (colKey != null) {
key = colKey.toString();
}
} else if (entity instanceof PieSectionEntity) {
Comparable<?> sectionKey = ((PieSectionEntity) entity).getSectionKey();
if (sectionKey != null) {
key = sectionKey.toString();
}
}
if (key == null) {
continue;
}
Area area = new Area();
myImage.appendChild(area);
area.setCoords(entity.getShapeCoords());
area.setShape(entity.getShapeType());
area.setTooltiptext(entity.getToolTipText());
area.setId(count + "_WG_" + key);
count++;
}
myImage.addEventListener(Events.ON_CLICK, new EventListener() {
public void onEvent(Event event) throws Exception {
MouseEvent me = (MouseEvent) event;
String areaId = me.getArea();
if (areaId != null) {
for (int i = 0; i < list.size(); i++) {
String s = "_WG_" + list.get(i).getLabel();
if (areaId.endsWith(s)) {
chartMouseClicked(i);
return;
}
}
}
}
});
} catch (Exception e) {
log.log(Level.SEVERE, "", e);
}
}
use of org.zkoss.zul.Imagemap in project adempiere by adempiere.
the class WFEditor method initForm.
@Override
protected void initForm() {
this.setHeight("100%");
Borderlayout layout = new Borderlayout();
layout.setStyle("width: 100%; height: 100%; position: absolute;");
appendChild(layout);
String sql = MRole.getDefault().addAccessSQL("SELECT AD_Workflow_ID, Name FROM AD_Workflow ORDER BY 2", "AD_Workflow", MRole.SQL_NOTQUALIFIED, // all
MRole.SQL_RO);
KeyNamePair[] pp = DB.getKeyNamePairs(sql, true);
workflowList = ListboxFactory.newDropdownListbox();
for (KeyNamePair knp : pp) {
workflowList.addItem(knp);
}
workflowList.addEventListener(Events.ON_SELECT, this);
North north = new North();
layout.appendChild(north);
north.appendChild(workflowList);
workflowList.setStyle("margin-left: 10px; margin-top: 5px;");
north.setHeight("30px");
imageMap = new Imagemap();
Center center = new Center();
layout.appendChild(center);
center.setAutoscroll(true);
// center.setHflex("true");
center.setVflex("true");
center.appendChild(imageMap);
ConfirmPanel confirmPanel = new ConfirmPanel(true);
confirmPanel.addActionListener(this);
South south = new South();
layout.appendChild(south);
south.appendChild(confirmPanel);
south.setHeight("36px");
}
use of org.zkoss.zul.Imagemap in project adempiere by adempiere.
the class WWFPanelManufacturing method initForm.
@Override
protected void initForm() {
this.setHeight("100%");
Borderlayout layout = new Borderlayout();
layout.setStyle("width: 100%; height: 100%; position: absolute;");
appendChild(layout);
String sql = MRole.getDefault().addAccessSQL("SELECT AD_Workflow_ID, Name FROM AD_Workflow WHERE " + WF_WhereClause + " ORDER BY 2", "AD_Workflow", MRole.SQL_NOTQUALIFIED, // all
MRole.SQL_RO);
KeyNamePair[] pp = DB.getKeyNamePairs(sql, true);
workflowList = ListboxFactory.newDropdownListbox();
for (KeyNamePair knp : pp) {
workflowList.addItem(knp);
}
workflowList.addEventListener(Events.ON_SELECT, this);
North north = new North();
layout.appendChild(north);
north.appendChild(workflowList);
workflowList.setStyle("margin-left: 10px; margin-top: 5px;");
north.setHeight("30px");
imageMap = new Imagemap();
Center center = new Center();
layout.appendChild(center);
center.setAutoscroll(true);
// center.setFlex(true);
center.appendChild(imageMap);
ConfirmPanel confirmPanel = new ConfirmPanel(true);
confirmPanel.addActionListener(this);
South south = new South();
layout.appendChild(south);
south.appendChild(confirmPanel);
south.setHeight("36px");
}
Aggregations