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