Package org.openfaces.component.output

Examples of org.openfaces.component.output.DynamicImage


    @Override
    public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
        if (!component.isRendered())
            return;

        DynamicImage dynamicImage = (DynamicImage) component;
        ValueExpression dataExpression = dynamicImage.getDataExpression();
        ELContext elContext = FacesContext.getCurrentInstance().getELContext();
        Object data = dataExpression.getValue(elContext);

        if (data == null)
            return;

        ImageDataModel model = Rendering.getDataModel(data);

        String extension = DIMG_EXTENSION;
        if (dynamicImage.getImageType() != null)
            extension = dynamicImage.getImageType().getExtension();

        ResponseWriter writer = facesContext.getResponseWriter();
        Rendering.startWriteIMG(writer, facesContext, dynamicImage, extension, model, null);

        writeAttribute(writer, "style", dynamicImage.getStyle());
        writeAttribute(writer, "class", Styles.mergeClassNames(dynamicImage.getStyleClass(), (String) dynamicImage.getAttributes().get(DEFAULT_STYLE_ATTR)));
        writeAttribute(writer, "width", dynamicImage.getWidth(), -1);
        writeAttribute(writer, "height", dynamicImage.getHeight(), -1);
        writeAttribute(writer, "alt", dynamicImage.getAlt());

        Rendering.writeStandardEvents(writer, dynamicImage);

        String mapId = dynamicImage.getMapId();
        if (mapId != null)
            writer.writeAttribute("usemap", "#" + mapId, null);

        Rendering.encodeInitComponentCall(facesContext, dynamicImage, true);

        writer.endElement("img");

        if (dynamicImage.getMap() != null) {
            Rendering.writeNewLine(writer);
            writer.write(dynamicImage.getMap());
        }
    }
View Full Code Here


        }

        chart.setImageBytes(imageAsByteArray);
        final Integer oldEntityIndex = chart.getEntityIndex();
        chart.setEntityIndex(-1);
        DynamicImage dynamicImage = new DynamicImage();
        ValueExpression ve = new ByteArrayValueExpression(imageAsByteArray);
        dynamicImage.setValueExpression("data", ve);
        dynamicImage.setId("img");
        dynamicImage.setParent(chart);
        dynamicImage.setMapId(mapId);
        dynamicImage.setMap(map);
        dynamicImage.getAttributes().put(DynamicImageRenderer.DEFAULT_STYLE_ATTR, "o_chart");
        dynamicImage.setWidth(chart.getWidth());
        dynamicImage.setHeight(chart.getHeight());
        copyAttributes(dynamicImage, chart, "onclick", "ondblclick", "onmousedown", "onmouseup",
                "onmousemove", "onmouseover", "onmouseout");

        dynamicImage.setImageType(ImageType.PNG);
        dynamicImage.encodeAll(facesContext);
        chart.setEntityIndex(oldEntityIndex);
        if (map != null) {
            Resources.renderJSLinkIfNeeded(facesContext, Resources.utilJsURL(facesContext));
            Resources.renderJSLinkIfNeeded(facesContext, Resources.internalURL(facesContext, "chart/chart.js"));
        }
View Full Code Here

TOP

Related Classes of org.openfaces.component.output.DynamicImage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.