Package org.openfaces.component.chart

Examples of org.openfaces.component.chart.Chart


    }

    @Override
    public void setComponentProperties(FacesContext context, UIComponent component) {
        super.setComponentProperties(context, component);
        Chart chart = (Chart) component;

        setStringProperty(chart, "textStyle");
        setValueExpressionProperty(chart, "model");
        setEnumerationProperty(chart, "view", ChartViewType.class);

        String titleText = getPropertyValue("titleText");
        if (titleText != null) {
            ChartTitle title = new ChartTitle();
            title.setId(Components.generateIdWithSuffix(chart, "chartTitle"));
            setStringProperty(title, "text", titleText, "titleText");
            chart.getChildren().add(title);
            title.setTextStyle("font-size: 14pt;");
        }

        setIntProperty(chart, "height");
        setIntProperty(chart, "width");
View Full Code Here


    @Override
    public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {
        Components.generateIdIfNotSpecified(component);
        ResponseWriter writer = facesContext.getResponseWriter();
        Chart chart = (Chart) component;

        ChartView view = chart.getChartView();
        if (!chart.isRendered() || view == null)
            return;

        writer.startElement("div", chart);
        writeIdAttribute(facesContext, chart);
        Rendering.writeComponentClassAttribute(writer, chart);
        writer.writeAttribute("style", "width: " + chart.getWidth() + "px;" + " height:" + chart.getHeight() + "px;", "style");

        String actionFiledId = chart.getClientId(facesContext) + MapRenderUtilities.ACTION_FIELD_SUFFIX;
        Rendering.writeNewLine(writer);
        Rendering.renderHiddenField(writer, actionFiledId, null);
        Rendering.writeNewLine(writer);

        BufferedImage image = chart.make();
        final byte[] imageAsByteArray = Rendering.encodeAsPNG(image);

        final JfcRenderHints renderHints = chart.getRenderHints();
        final ChartRenderingInfo renderingInfo = renderHints.getRenderingInfo();
        String mapId = renderHints.getMapId(chart);
        String map = MapRenderUtilities.getImageMapExt(chart, mapId, renderingInfo,
                new StandardToolTipTagFragmentGenerator(), new StandardURLTagFragmentGenerator());
        renderHints.setMap(map);
        if (view.getChartPopup() != null) {
            encodeChartPopup(facesContext, chart, view, renderingInfo);
        }

        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"));
        }
        encodeScripts(facesContext, chart, dynamicImage);
View Full Code Here

    @Override
    public void decode(FacesContext context, UIComponent component) {
        super.decode(context, component);
        Map requestParameterMap = context.getExternalContext().getRequestParameterMap();

        Chart chart = (Chart) component;
        String name = chart.getClientId(FacesContext.getCurrentInstance()) + MapRenderUtilities.ACTION_FIELD_SUFFIX;
        String actionValue = (String) requestParameterMap.get(name);

        if (actionValue != null && !actionValue.equals("")) {
            if (actionValue.equals("title")) {
                //   chart.setAction(chart.getTitle().getActionExpression());
                chart.getTitle().decodeAction(actionValue);
            } else {
                //   chart.setAction(chart.getChartView().getActionExpression());
                chart.getChartView().decodeAction(actionValue);
                // chart.getChartView().queueEvent(event);
            }
        }
        chart.setModel(null);
    }
View Full Code Here

        final ChartPopup popup = (ChartPopup) component;
        final String clientId = popup.getClientId(context);
        final boolean clientLoadingMode = popup.getLoadingMode().equals(LoadingMode.CLIENT);

        final UIComponent chartView = popup.getParent();
        final Chart chart = (Chart) chartView.getParent();
        final Integer entityIndex = chart.getEntityIndex();
        chart.setEntityIndex(-1);
        final String chartId = chart.getClientId(context);
        chart.setEntityIndex(entityIndex);

        ScriptBuilder buf = new ScriptBuilder();
        buf.functionCall("O$.ChartPopup._init", clientId, popup.getLoadingMode().toString(), chartId).semicolon();

        Rendering.renderInitScript(context, buf,
View Full Code Here

        if (!portionName.equals("content"))
            throw new IllegalArgumentException("Unknown portionName: " + portionName);

        renderPopupContent(context, component);
        final UIComponent chartView = component.getParent();
        final Chart chart = (Chart) chartView.getParent();
        chart.setEntityIndex(-1);

        return null;
    }
View Full Code Here

TOP

Related Classes of org.openfaces.component.chart.Chart

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.