Search in sources :

Example 1 with Imagemap

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);
    }
}
Also used : TimeSeries(org.jfree.data.time.TimeSeries) MouseEvent(org.zkoss.zk.ui.event.MouseEvent) TimeSeriesDataItem(org.jfree.data.time.TimeSeriesDataItem) Panelchildren(org.zkoss.zul.Panelchildren) BufferedImage(java.awt.image.BufferedImage) XYItemEntity(org.jfree.chart.entity.XYItemEntity) Panel(org.zkoss.zul.Panel) Area(org.zkoss.zul.Area) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) ChartRenderingInfo(org.jfree.chart.ChartRenderingInfo) AImage(org.zkoss.image.AImage) ValueChangeEvent(org.adempiere.exceptions.ValueChangeEvent) Event(org.zkoss.zk.ui.event.Event) MouseEvent(org.zkoss.zk.ui.event.MouseEvent) ChartEntity(org.jfree.chart.entity.ChartEntity) EventListener(org.zkoss.zk.ui.event.EventListener) CategoryItemEntity(org.jfree.chart.entity.CategoryItemEntity) PieSectionEntity(org.jfree.chart.entity.PieSectionEntity) Imagemap(org.zkoss.zul.Imagemap)

Example 2 with Imagemap

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

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);
    }
}
Also used : MouseEvent(org.zkoss.zk.ui.event.MouseEvent) ChartMouseEvent(org.jfree.chart.ChartMouseEvent) Panelchildren(org.zkoss.zul.Panelchildren) Point(java.awt.Point) BufferedImage(java.awt.image.BufferedImage) Area(org.zkoss.zul.Area) ChartRenderingInfo(org.jfree.chart.ChartRenderingInfo) AImage(org.zkoss.image.AImage) ValueChangeEvent(org.adempiere.exceptions.ValueChangeEvent) Event(org.zkoss.zk.ui.event.Event) MouseEvent(org.zkoss.zk.ui.event.MouseEvent) ChartMouseEvent(org.jfree.chart.ChartMouseEvent) ChartEntity(org.jfree.chart.entity.ChartEntity) EventListener(org.zkoss.zk.ui.event.EventListener) CategoryItemEntity(org.jfree.chart.entity.CategoryItemEntity) PieSectionEntity(org.jfree.chart.entity.PieSectionEntity) Imagemap(org.zkoss.zul.Imagemap)

Example 4 with Imagemap

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");
}
Also used : Center(org.zkoss.zul.Center) ConfirmPanel(org.adempiere.webui.component.ConfirmPanel) South(org.zkoss.zul.South) North(org.zkoss.zul.North) Borderlayout(org.zkoss.zul.Borderlayout) KeyNamePair(org.compiere.util.KeyNamePair) Imagemap(org.zkoss.zul.Imagemap)

Example 5 with Imagemap

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");
}
Also used : Center(org.zkoss.zul.Center) ConfirmPanel(org.adempiere.webui.component.ConfirmPanel) South(org.zkoss.zul.South) North(org.zkoss.zul.North) Borderlayout(org.zkoss.zul.Borderlayout) KeyNamePair(org.compiere.util.KeyNamePair) Imagemap(org.zkoss.zul.Imagemap)

Aggregations

Imagemap (org.zkoss.zul.Imagemap)5 BufferedImage (java.awt.image.BufferedImage)3 AImage (org.zkoss.image.AImage)3 Area (org.zkoss.zul.Area)3 ValueChangeEvent (org.adempiere.exceptions.ValueChangeEvent)2 ConfirmPanel (org.adempiere.webui.component.ConfirmPanel)2 KeyNamePair (org.compiere.util.KeyNamePair)2 ChartRenderingInfo (org.jfree.chart.ChartRenderingInfo)2 CategoryItemEntity (org.jfree.chart.entity.CategoryItemEntity)2 ChartEntity (org.jfree.chart.entity.ChartEntity)2 PieSectionEntity (org.jfree.chart.entity.PieSectionEntity)2 Event (org.zkoss.zk.ui.event.Event)2 EventListener (org.zkoss.zk.ui.event.EventListener)2 MouseEvent (org.zkoss.zk.ui.event.MouseEvent)2 Borderlayout (org.zkoss.zul.Borderlayout)2 Center (org.zkoss.zul.Center)2 North (org.zkoss.zul.North)2 Panelchildren (org.zkoss.zul.Panelchildren)2 South (org.zkoss.zul.South)2 Dimension (java.awt.Dimension)1