Search in sources :

Example 6 with Image

use of org.zkoss.zul.Image in project adempiere by adempiere.

the class WPOSKeyPanel method createButton.

/**
	 * Create Button
	 * @param C_POSKeyLayout_ID
	 * @return
	 * @return Panel
	 */
public Panel createButton(int C_POSKeyLayout_ID) {
    if (keymap.containsKey(C_POSKeyLayout_ID)) {
        return null;
    }
    Panel card = new Panel();
    card.setWidth("100%");
    MPOSKeyLayout keyLayout = MPOSKeyLayout.get(Env.getCtx(), C_POSKeyLayout_ID);
    Color stdColor = Color.lightGray;
    if (keyLayout.getAD_PrintColor_ID() != 0) {
        MPrintColor color = MPrintColor.get(Env.getCtx(), keyLayout.getAD_PrintColor_ID());
        stdColor = color.getColor();
    }
    if (keyLayout.get_ID() == 0)
        return null;
    MPOSKey[] keys = keyLayout.getKeys(false);
    HashMap<Integer, MPOSKey> map = new HashMap<Integer, MPOSKey>(keys.length);
    keymap.put(C_POSKeyLayout_ID, map);
    //	Min Columns
    int COLUMNS = 3;
    //	Min Rows
    int ROWS = 3;
    int noKeys = keys.length;
    int cols = keyLayout.getColumns();
    if (cols == 0)
        cols = COLUMNS;
    int buttons = 0;
    log.fine("PosSubFunctionKeys.init - NoKeys=" + noKeys + ", Cols=" + cols);
    //	Content
    Panel content = new Panel();
    for (MPOSKey key : keys) {
        if (!key.getName().equals("")) {
            map.put(key.getC_POSKey_ID(), key);
            Color keyColor = stdColor;
            if (key.getAD_PrintColor_ID() != 0) {
                MPrintColor color = MPrintColor.get(Env.getCtx(), key.getAD_PrintColor_ID());
                keyColor = color.getColor();
            }
            log.fine("#" + map.size() + " - " + keyColor);
            Panel button = new Panel();
            Label label = new Label(key.getName());
            Center nt = new Center();
            South st = new South();
            Borderlayout mainLayout = new Borderlayout();
            if (key.getAD_Image_ID() != 0) {
                MImage m_mImage = MImage.get(Env.getCtx(), key.getAD_Image_ID());
                AImage img = null;
                byte[] data = m_mImage.getData();
                if (data != null && data.length > 0) {
                    try {
                        img = new AImage(null, data);
                    } catch (Exception e) {
                    }
                }
                Image bImg = new Image();
                bImg.setContent(img);
                bImg.setWidth("66%");
                bImg.setHeight("80%");
                nt.appendChild(bImg);
            }
            label.setStyle("word-wrap: break-word; white-space: pre-line;margin: 25px 0px 0px 0px; top:20px; font-size:10pt; font-weight: bold;color: #FFF;");
            label.setHeight("100%");
            button.setHeight("100px");
            st.appendChild(label);
            button.setClass("z-button");
            button.setStyle("float:left; white-space: pre-line;text-align:center; margin:0.4% 1%; Background-color:rgb(" + keyColor.getRed() + "," + keyColor.getGreen() + "," + keyColor.getBlue() + "); border: 2px outset #CCC; " + "background: -moz-linear-gradient(top, rgba(247,247,247,1) 0%, rgba(255,255,255,0.93) 7%, rgba(186,186,186,0.25) 15%, rgba(" + keyColor.getRed() + "," + keyColor.getGreen() + "," + keyColor.getBlue() + ",1) 100%);" + "background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(247,247,247,1)), color-stop(7%, rgba(255,255,255,0.93)), color-stop(15%, rgba(186,186,186,0.25)), color-stop(100%, rgba(" + keyColor.getRed() + "," + keyColor.getGreen() + "," + keyColor.getBlue() + ",1)));" + "background: -webkit-linear-gradient(top, rgba(247,247,247,1) 0%, rgba(255,255,255,0.93) 7%, rgba(186,186,186,0.25) 15%, rgba(" + keyColor.getRed() + "," + keyColor.getGreen() + "," + keyColor.getBlue() + ",1) 100%);");
            mainLayout.appendChild(nt);
            mainLayout.appendChild(st);
            mainLayout.setStyle("background-color: transparent");
            nt.setStyle("background-color: transparent");
            st.setStyle("clear: both; background-color: #333; opacity: 0.6;");
            st.setZindex(99);
            button.appendChild(mainLayout);
            button.setId("" + key.getC_POSKey_ID());
            button.addEventListener("onClick", this);
            int size = 1;
            if (key.getSpanX() > 1) {
                size = key.getSpanX();
                button.setWidth("96%");
            } else
                button.setWidth(90 / cols + "%");
            if (key.getSpanY() > 1) {
                size = size * key.getSpanY();
            }
            buttons = buttons + size;
            content.appendChild(button);
        }
    }
    int rows = Math.max((buttons / cols), ROWS);
    if (buttons % cols > 0)
        rows = rows + 1;
    card.appendChild(content);
    return card;
}
Also used : Center(org.zkoss.zkex.zul.Center) HashMap(java.util.HashMap) MPOSKeyLayout(org.compiere.model.MPOSKeyLayout) Color(java.awt.Color) MPrintColor(org.compiere.print.MPrintColor) Label(org.adempiere.webui.component.Label) South(org.zkoss.zkex.zul.South) Borderlayout(org.adempiere.webui.component.Borderlayout) AImage(org.zkoss.image.AImage) Image(org.zkoss.zul.Image) MImage(org.compiere.model.MImage) Panel(org.adempiere.webui.component.Panel) MImage(org.compiere.model.MImage) MPrintColor(org.compiere.print.MPrintColor) AImage(org.zkoss.image.AImage) MPOSKey(org.compiere.model.MPOSKey)

Example 7 with Image

use of org.zkoss.zul.Image in project adempiere by adempiere.

the class WPerformanceIndicator method init.

/**
	 * 	Init Graph Display
	 *  Kinamo (pelgrim)
	 */
private void init() {
    JFreeChart chart = createChart();
    chart.setBackgroundPaint(null);
    chart.setBorderVisible(true);
    chart.setBorderPaint(Color.LIGHT_GRAY);
    chart.setAntiAlias(true);
    BufferedImage bi = chart.createBufferedImage(200, 120, BufferedImage.TRANSLUCENT, null);
    try {
        byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);
        AImage image = new AImage("", bytes);
        Image myImage = new Image();
        myImage.setContent(image);
        appendChild(myImage);
    } catch (Exception e) {
    // TODO: handle exception
    }
    invalidate();
}
Also used : AImage(org.zkoss.image.AImage) AImage(org.zkoss.image.AImage) BufferedImage(java.awt.image.BufferedImage) Image(org.zkoss.zul.Image) JFreeChart(org.jfree.chart.JFreeChart) BufferedImage(java.awt.image.BufferedImage)

Example 8 with Image

use of org.zkoss.zul.Image in project spatial-portal by AtlasOfLivingAustralia.

the class LayerLegendGeneralComposer method setupForClassificationLayers.

private void setupForClassificationLayers() {
    if (mapLayer.isPolygonLayer())
        return;
    String activeLayerName = StringConstants.NONE;
    JSONObject field = null;
    JSONObject layer = null;
    if (mapLayer != null && mapLayer.getUri() != null) {
        if (mapLayer.getBaseUri() != null) {
            activeLayerName = mapLayer.getBaseUri().replaceAll("^.*&style=", "").replaceAll("&.*", "").replaceAll("_style", "");
        } else {
            activeLayerName = mapLayer.getUri().replaceAll("^.*&style=", "").replaceAll("&.*", "").replaceAll("_style", "");
        }
        field = CommonData.getLayer(activeLayerName);
        if (field == null)
            return;
        layer = (JSONObject) field.get("layer");
    }
    LOGGER.debug("ACTIVE LAYER: " + activeLayerName);
    if (mapLayer != null && mapLayer.getSubType() == LayerUtilitiesImpl.ALOC) {
        divClassificationPicker.setVisible(true);
        // reset content
        Integer groupCount = mapLayer.getClassificationGroupCount();
        if (groupCount == null) {
            mapLayer.setClassificationGroupCount(getClassificationGroupCount(mapLayer.getName().replace("aloc_", "")));
            groupCount = 0;
        }
        for (int i = cbClassificationGroup.getItemCount() - 1; i >= 0; i--) {
            cbClassificationGroup.removeItemAt(i);
        }
        Comboitem ci = new Comboitem(StringConstants.NONE);
        ci.setParent(cbClassificationGroup);
        for (int i = 1; i <= groupCount; i++) {
            new Comboitem("Group " + i).setParent(cbClassificationGroup);
        }
        // is there a current selection?
        Integer groupSelection = mapLayer.getClassificationSelection();
        if (groupSelection == null) {
            groupSelection = 0;
            mapLayer.setClassificationSelection(groupSelection);
        }
        cbClassificationGroup.setSelectedIndex(groupSelection);
        getFellow("btnCreateArea").setVisible(false);
        cbClassificationGroup.setVisible(true);
        lbClassificationGroup.setVisible(false);
        hboxClassificationGroup.setVisible(false);
    } else if (layer != null && layer.containsKey("type") && layer.get("type").toString().equalsIgnoreCase("contextual")) {
        divClassificationPicker.setVisible(true);
        if (mapLayer.getClassificationGroupCount() == null || mapLayer.getClassificationGroupCount() == 0) {
            // build
            String fieldId = field.get(StringConstants.ID).toString();
            JSONParser jp = new JSONParser();
            JSONObject objJson = null;
            try {
                objJson = (JSONObject) jp.parse(Util.readUrl(CommonData.getLayersServer() + "/field/" + fieldId));
            } catch (ParseException e) {
                LOGGER.error("failed to parse for: " + fieldId);
            }
            JSONArray objects = (JSONArray) objJson.get("objects");
            // sort
            List<JSONObject> list = objects.subList(0, objects.size());
            Collections.sort(list, new Comparator<JSONObject>() {

                @Override
                public int compare(JSONObject o1, JSONObject o2) {
                    String s1 = (o1 == null || !o1.containsKey("name")) ? "" : o1.get("name").toString();
                    String s2 = (o2 == null || !o2.containsKey("name")) ? "" : o2.get("name").toString();
                    return s1.compareTo(s2);
                }
            });
            JSONArray obj = new JSONArray();
            obj.addAll(list);
            mapLayer.setClassificationGroupCount(obj.size());
            mapLayer.setClassificationObjects(obj);
        }
        // reset content
        Integer groupCount = mapLayer.getClassificationGroupCount();
        JSONArray groupObjects = mapLayer.getClassificationObjects();
        lbClassificationGroup.setItemRenderer(new ListitemRenderer<JSONObject>() {

            @Override
            public void render(Listitem item, JSONObject data, int index) throws Exception {
                Checkbox cb = new Checkbox();
                final int idx = index;
                cb.addEventListener("onCheck", new EventListener<Event>() {

                    @Override
                    public void onEvent(Event event) throws Exception {
                        if (mapLayer != null) {
                            lbClassificationGroup.setMultiple(true);
                            String v = ((Listcell) event.getTarget().getParent().getParent().getChildren().get(1)).getLabel();
                            if (((CheckEvent) event).isChecked()) {
                                selectedList.add(v);
                            } else {
                                selectedList.remove(v);
                            }
                            lblSelectedCount.setValue(selectedList.size() + " checked");
                            getFellow("clearSelection").setVisible(selectedList.size() > 0);
                            getFellow("createInGroup").setVisible(selectedList.size() > 0);
                            if (getFellowIfAny("createOutGroup") != null)
                                getFellow("createOutGroup").setVisible(selectedList.size() > 0);
                            highlightSelect(idx);
                        }
                    }
                });
                determineCheckboxState(cb, data.get("name").toString());
                Listcell lc;
                lc = new Listcell();
                cb.setParent(lc);
                lc.setParent(item);
                lc = new Listcell(data.get("name").toString());
                lc.setParent(item);
                lc = new Listcell();
                Image img = new Image();
                img.setTooltip("Create as an area layer");
                img.setClass("icon-plus-sign");
                img.setParent(lc);
                lc.setParent(item);
                final JSONObject j = data;
                img.addEventListener("onClick", new EventListener<Event>() {

                    @Override
                    public void onEvent(Event event) throws Exception {
                        createAreaEcho(j.get("pid").toString());
                    }
                });
                lc = new Listcell();
                img = new Image();
                img.setTooltip("Zoom to area");
                img.setClass("icon-zoom-in");
                img.setParent(lc);
                lc.setParent(item);
                img.addEventListener("onClick", new EventListener<Event>() {

                    @Override
                    public void onEvent(Event event) throws Exception {
                        List<Double> b = Util.getBoundingBox(j.get("bbox").toString());
                        BoundingBox bbox = new BoundingBox();
                        bbox.setMinLongitude(b.get(0).floatValue());
                        bbox.setMinLatitude(b.get(1).floatValue());
                        bbox.setMaxLongitude(b.get(2).floatValue());
                        bbox.setMaxLatitude(b.get(3).floatValue());
                        getMapComposer().getOpenLayersJavascript().execute(getMapComposer().getOpenLayersJavascript().zoomToBoundingBox(bbox, false));
                    }
                });
            }
        });
        lbClassificationGroup.addEventListener("onSelect", new EventListener<Event>() {

            @Override
            public void onEvent(Event event) throws Exception {
                if (mapLayer != null) {
                    highlightSelect(lbClassificationGroup.getSelectedIndex());
                }
            }
        });
        List<JSONObject> model = new ArrayList<JSONObject>();
        for (int i = 0; i < groupCount; i++) {
            model.add((JSONObject) groupObjects.get(i));
        }
        lbClassificationGroup.setModel(new SimpleListModel(model));
        // is there a current selection?
        Integer groupSelection = mapLayer.getClassificationSelection();
        if (groupSelection == null) {
            groupSelection = 0;
            mapLayer.setClassificationSelection(groupSelection);
        }
        getFellow("btnCreateArea").setVisible(true);
        getFellow("btnCreateArea").setVisible(false);
        cbClassificationGroup.setVisible(false);
        lbClassificationGroup.setVisible(true);
        hboxClassificationGroup.setVisible(true);
    } else {
        getFellow("btnCreateArea").setVisible(false);
        divClassificationPicker.setVisible(false);
    }
}
Also used : JSONArray(org.json.simple.JSONArray) Image(org.zkoss.zul.Image) ParseException(org.json.simple.parser.ParseException) JSONObject(org.json.simple.JSONObject) Checkbox(org.zkoss.zul.Checkbox) BoundingBox(au.org.emii.portal.value.BoundingBox) CheckEvent(org.zkoss.zk.ui.event.CheckEvent) Event(org.zkoss.zk.ui.event.Event) JSONParser(org.json.simple.parser.JSONParser) List(java.util.List) ParseException(org.json.simple.parser.ParseException) EventListener(org.zkoss.zk.ui.event.EventListener)

Example 9 with Image

use of org.zkoss.zul.Image in project adempiere by adempiere.

the class WCRP method renderChart.

private void renderChart(JFreeChart jchart) {
    BufferedImage bi = jchart.createBufferedImage(700, 500, Transparency.TRANSLUCENT, null);
    try {
        byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);
        AImage image = new AImage("", bytes);
        chartPanel.removeChild(chart);
        chart = new Image();
        chart.setContent(image);
        chartPanel.appendChild(chart);
        chartPanel.setVisible(true);
    } catch (Exception e) {
    }
}
Also used : AImage(org.zkoss.image.AImage) AImage(org.zkoss.image.AImage) BufferedImage(java.awt.image.BufferedImage) Image(org.zkoss.zul.Image) BufferedImage(java.awt.image.BufferedImage)

Example 10 with Image

use of org.zkoss.zul.Image in project adempiere by adempiere.

the class WCRPDetail method renderChart.

private void renderChart(JFreeChart jchart) {
    BufferedImage bi = jchart.createBufferedImage(700, 500, Transparency.TRANSLUCENT, null);
    try {
        byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true);
        AImage image = new AImage("", bytes);
        mainLayout.removeChild(west);
        chartPanel = new Hbox();
        chart = new Image();
        chart.setContent(image);
        chartPanel.appendChild(chart);
        west = new West();
        west.appendChild(chartPanel);
        west.setSplittable(true);
        west.setSize("70%");
        west.setAutoscroll(true);
        west.setOpen(true);
        mainLayout.appendChild(west);
    } catch (Exception e) {
        log.log(Level.SEVERE, "WCRP.init", e.getMessage());
    }
}
Also used : Hbox(org.zkoss.zul.Hbox) West(org.zkoss.zul.West) AImage(org.zkoss.image.AImage) AImage(org.zkoss.image.AImage) BufferedImage(java.awt.image.BufferedImage) Image(org.zkoss.zul.Image) BufferedImage(java.awt.image.BufferedImage)

Aggregations

Image (org.zkoss.zul.Image)14 AImage (org.zkoss.image.AImage)5 BufferedImage (java.awt.image.BufferedImage)3 Label (org.adempiere.webui.component.Label)3 Borderlayout (org.adempiere.webui.component.Borderlayout)2 Button (org.adempiere.webui.component.Button)2 ConfirmPanel (org.adempiere.webui.component.ConfirmPanel)2 ParseException (org.json.simple.parser.ParseException)2 Table (org.zkoss.zhtml.Table)2 Td (org.zkoss.zhtml.Td)2 Tr (org.zkoss.zhtml.Tr)2 Component (org.zkoss.zk.ui.Component)2 Event (org.zkoss.zk.ui.event.Event)2 BoundingBox (au.org.emii.portal.value.BoundingBox)1 Color (java.awt.Color)1 HashMap (java.util.HashMap)1 List (java.util.List)1 ProductInfo (org.adempiere.pos.service.ProductInfo)1 Panel (org.adempiere.webui.component.Panel)1 Tabpanel (org.adempiere.webui.component.Tabpanel)1