In other words, it is used to retrieve and store the opaque data as polymorphic thru the {@link org.zkoss.util.media.Media} interface.
To encode AWT image to an instance of {@link Image}, use {@link Images#encode}. @author tomyeh @see Images#encode
454455456457458459460461462463464
CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setForegroundAlpha(0.5f); BufferedImage bi = chart.createBufferedImage(chartWidth, chartHeight, BufferedImage.TRANSLUCENT, null); byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true); AImage chartImage = new AImage("Bar Chart 3D", bytes); Image img = new Image(); img.setContent(chartImage); img.setParent(div_chartArea);
517518519520521522523524525526527
CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setForegroundAlpha(0.5f); BufferedImage bi = chart.createBufferedImage(chartWidth, chartHeight, BufferedImage.TRANSLUCENT, null); byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true); AImage chartImage = new AImage("Stacked Bar Chart", bytes); Image img = new Image(); img.setContent(chartImage); img.setParent(div_chartArea);
581582583584585586587588589590591
CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setForegroundAlpha(0.5f); BufferedImage bi = chart.createBufferedImage(chartWidth, chartHeight, BufferedImage.TRANSLUCENT, null); byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true); AImage chartImage = new AImage("Stacked Bar Chart 3D", bytes); Image img = new Image(); img.setContent(chartImage); img.setParent(div_chartArea);
645646647648649650651652653654655
CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setForegroundAlpha(0.5f); BufferedImage bi = chart.createBufferedImage(chartWidth, chartHeight, BufferedImage.TRANSLUCENT, null); byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true); AImage chartImage = new AImage("Line Bar Chart", bytes); Image img = new Image(); img.setContent(chartImage); img.setParent(div_chartArea);
709710711712713714715716717718719
CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setForegroundAlpha(0.5f); BufferedImage bi = chart.createBufferedImage(chartWidth, chartHeight, BufferedImage.TRANSLUCENT, null); byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true); AImage chartImage = new AImage("Line Bar Chart 3D", bytes); Image img = new Image(); img.setContent(chartImage); img.setParent(div_chartArea);
570571572573574575576577578579580581582583584
Worksheet sheet = _spreadsheet.getSelectedSheet(); if (sheet != null) { if (!sheet.getProtect()) { final Media media = evt.getMedia(); if (media instanceof AImage) { AImage image = (AImage)media; Ranges .range(_spreadsheet.getSelectedSheet()) .addPicture(getClientAnchor(_insertPictureSelection.getTop(), _insertPictureSelection.getLeft(), image.getWidth(), image.getHeight()), image.getByteData(), getImageFormat(image)); } } else { showProtectMessage(); } }