Search in sources :

Example 6 with IPentahoRequestContext

use of org.pentaho.platform.api.engine.IPentahoRequestContext in project pentaho-platform by pentaho.

the class PieDatasetChartComponent method getXmlContent.

@Override
public Document getXmlContent() {
    // Create a document that describes the result
    Document result = DocumentHelper.createDocument();
    IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    setXslProperty("baseUrl", requestContext.getContextPath());
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    setXslProperty("fullyQualifiedServerUrl", PentahoSystem.getApplicationContext().getFullyQualifiedServerURL());
    // $NON-NLS-1$
    String mapName = "chart" + AbstractChartComponent.chartCount++;
    Document chartDefinition = jcrHelper.getSolutionDocument(definitionPath, RepositoryFilePermission.READ);
    if (chartDefinition == null) {
        // $NON-NLS-1$
        Element errorElement = result.addElement("error");
        errorElement.addElement("title").setText(// $NON-NLS-1$ //$NON-NLS-2$
        Messages.getInstance().getString("ABSTRACTCHARTEXPRESSION.ERROR_0001_ERROR_GENERATING_CHART"));
        // $NON-NLS-1$
        String message = Messages.getInstance().getString("CHARTS.ERROR_0001_CHART_DEFINIION_MISSING", definitionPath);
        // $NON-NLS-1$
        errorElement.addElement("message").setText(message);
        error(message);
        return result;
    }
    // create a pie definition from the XML definition
    dataDefinition = createChart(chartDefinition);
    if (dataDefinition == null) {
        // $NON-NLS-1$
        Element errorElement = result.addElement("error");
        errorElement.addElement("title").setText(// $NON-NLS-1$ //$NON-NLS-2$
        Messages.getInstance().getString("ABSTRACTCHARTEXPRESSION.ERROR_0001_ERROR_GENERATING_CHART"));
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        String message = Messages.getInstance().getString("CHARTS.ERROR_0002_CHART_DATA_MISSING", actionPath);
        // $NON-NLS-1$
        errorElement.addElement("message").setText(message);
        // System .out.println( result.asXML() );
        return result;
    }
    // create an image for the dial using the JFreeChart engine
    PrintWriter printWriter = new PrintWriter(new StringWriter());
    // we'll dispay the title in HTML so that the dial image does not have
    // to
    // accommodate it
    // $NON-NLS-1$
    String chartTitle = "";
    try {
        if (height == -1) {
            // $NON-NLS-1$
            height = Integer.parseInt(chartDefinition.selectSingleNode("/chart/height").getText());
        }
        if (width == -1) {
            // $NON-NLS-1$
            width = Integer.parseInt(chartDefinition.selectSingleNode("/chart/width").getText());
        }
    } catch (Exception e) {
    // go with the default
    }
    if (chartDefinition.selectSingleNode("/chart/urlTemplate") != null) {
        // $NON-NLS-1$
        // $NON-NLS-1$
        urlTemplate = chartDefinition.selectSingleNode("/chart/urlTemplate").getText();
    }
    if (chartDefinition.selectSingleNode("/chart/paramName") != null) {
        // $NON-NLS-1$
        // $NON-NLS-1$
        paramName = chartDefinition.selectSingleNode("/chart/paramName").getText();
    }
    // $NON-NLS-1$
    Element root = result.addElement("charts");
    DefaultPieDataset chartDataDefinition = (DefaultPieDataset) dataDefinition;
    // if (chartDataDefinition.getRowCount() > 0) {
    // create temporary file names
    String[] tempFileInfo = createTempFile();
    String fileName = tempFileInfo[AbstractChartComponent.FILENAME_INDEX];
    String filePathWithoutExtension = tempFileInfo[AbstractChartComponent.FILENAME_WITHOUT_EXTENSION_INDEX];
    ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
    JFreeChartEngine.saveChart(chartDataDefinition, chartTitle, "", filePathWithoutExtension, width, height, JFreeChartEngine.OUTPUT_PNG, printWriter, info, // $NON-NLS-1$
    this);
    applyOuterURLTemplateParam();
    populateInfo(info);
    // $NON-NLS-1$
    Element chartElement = root.addElement("chart");
    // $NON-NLS-1$
    chartElement.addElement("mapName").setText(mapName);
    // $NON-NLS-1$
    chartElement.addElement("width").setText(Integer.toString(width));
    // $NON-NLS-1$
    chartElement.addElement("height").setText(Integer.toString(height));
    // for (int row = 0; row < chartDataDefinition.getRowCount(); row++) {
    // for (int column = 0; column < chartDataDefinition.getColumnCount();
    // column++) {
    // Number value = chartDataDefinition.getValue(row, column);
    // Comparable rowKey = chartDataDefinition.getRowKey(row);
    // Comparable columnKey = chartDataDefinition.getColumnKey(column);
    // Element valueElement = chartElement.addElement("value2D");
    // //$NON-NLS-1$
    // valueElement.addElement("value").setText(value.toString());
    // //$NON-NLS-1$
    // valueElement.addElement("row-key").setText(rowKey.toString());
    // //$NON-NLS-1$
    // valueElement.addElement("column-key").setText(columnKey.toString());
    // //$NON-NLS-1$
    // }
    // }
    String mapString = ImageMapUtilities.getImageMap(mapName, info);
    // $NON-NLS-1$
    chartElement.addElement("imageMap").setText(mapString);
    // $NON-NLS-1$
    chartElement.addElement("image").setText(fileName);
    // }
    return result;
}
Also used : IPentahoRequestContext(org.pentaho.platform.api.engine.IPentahoRequestContext) DefaultPieDataset(org.jfree.data.general.DefaultPieDataset) StandardEntityCollection(org.jfree.chart.entity.StandardEntityCollection) StringWriter(java.io.StringWriter) Element(org.dom4j.Element) ChartRenderingInfo(org.jfree.chart.ChartRenderingInfo) Document(org.dom4j.Document) UnsupportedEncodingException(java.io.UnsupportedEncodingException) PrintWriter(java.io.PrintWriter)

Example 7 with IPentahoRequestContext

use of org.pentaho.platform.api.engine.IPentahoRequestContext in project pentaho-platform by pentaho.

the class CategoryDatasetChartComponent method getXmlContent.

@Override
public Document getXmlContent() {
    // Create a document that describes the result
    Document result = DocumentHelper.createDocument();
    IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    setXslProperty("baseUrl", requestContext.getContextPath());
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    setXslProperty("fullyQualifiedServerUrl", PentahoSystem.getApplicationContext().getFullyQualifiedServerURL());
    // $NON-NLS-1$
    String mapName = "chart" + AbstractChartComponent.chartCount++;
    Document chartDefinition = jcrHelper.getSolutionDocument(definitionPath, RepositoryFilePermission.READ);
    if (chartDefinition == null) {
        // $NON-NLS-1$
        Element errorElement = result.addElement("error");
        errorElement.addElement("title").setText(// $NON-NLS-1$ //$NON-NLS-2$
        Messages.getInstance().getString("ABSTRACTCHARTEXPRESSION.ERROR_0001_ERROR_GENERATING_CHART"));
        // $NON-NLS-1$
        String message = Messages.getInstance().getString("CHARTS.ERROR_0001_CHART_DEFINIION_MISSING", definitionPath);
        // $NON-NLS-1$
        errorElement.addElement("message").setText(message);
        error(message);
        return result;
    }
    // create a pie definition from the XML definition
    dataDefinition = createChart(chartDefinition);
    if (dataDefinition == null) {
        // $NON-NLS-1$
        Element errorElement = result.addElement("error");
        errorElement.addElement("title").setText(// $NON-NLS-1$ //$NON-NLS-2$
        Messages.getInstance().getString("ABSTRACTCHARTEXPRESSION.ERROR_0001_ERROR_GENERATING_CHART"));
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        String message = Messages.getInstance().getString("CHARTS.ERROR_0002_CHART_DATA_MISSING", actionPath);
        // $NON-NLS-1$
        errorElement.addElement("message").setText(message);
        // System .out.println( result.asXML() );
        return result;
    }
    // create an image for the dial using the JFreeChart engine
    PrintWriter printWriter = new PrintWriter(new StringWriter());
    // we'll dispay the title in HTML so that the dial image does not have
    // to
    // accommodate it
    // $NON-NLS-1$
    String chartTitle = "";
    try {
        if (width == -1) {
            // $NON-NLS-1$
            width = Integer.parseInt(chartDefinition.selectSingleNode("/chart/width").getText());
        }
    } catch (NumberFormatException ignored) {
    // go with the default
    }
    try {
        if (height == -1) {
            // $NON-NLS-1$
            height = Integer.parseInt(chartDefinition.selectSingleNode("/chart/height").getText());
        }
    } catch (NumberFormatException ignored) {
    // go with the default
    }
    if (chartDefinition.selectSingleNode("/chart/" + AbstractChartComponent.URLTEMPLATE_NODE_NAME) != null) {
        // $NON-NLS-1$
        urlTemplate = // $NON-NLS-1$
        chartDefinition.selectSingleNode("/chart/" + AbstractChartComponent.URLTEMPLATE_NODE_NAME).getText();
    }
    if (chartDefinition.selectSingleNode("/chart/paramName") != null) {
        // $NON-NLS-1$
        // $NON-NLS-1$
        paramName = chartDefinition.selectSingleNode("/chart/paramName").getText();
    }
    // $NON-NLS-1$
    Element root = result.addElement("charts");
    DefaultCategoryDataset chartDataDefinition = (DefaultCategoryDataset) dataDefinition;
    if (chartDataDefinition.getRowCount() > 0) {
        // create temporary file names
        String[] tempFileInfo = createTempFile();
        String fileName = tempFileInfo[AbstractChartComponent.FILENAME_INDEX];
        String filePathWithoutExtension = tempFileInfo[AbstractChartComponent.FILENAME_WITHOUT_EXTENSION_INDEX];
        ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());
        JFreeChartEngine.saveChart(chartDataDefinition, chartTitle, "", filePathWithoutExtension, width, height, JFreeChartEngine.OUTPUT_PNG, printWriter, info, // $NON-NLS-1$
        this);
        applyOuterURLTemplateParam();
        populateInfo(info);
        // $NON-NLS-1$
        Element chartElement = root.addElement("chart");
        // $NON-NLS-1$
        chartElement.addElement("mapName").setText(mapName);
        // $NON-NLS-1$
        chartElement.addElement("width").setText(Integer.toString(width));
        // $NON-NLS-1$
        chartElement.addElement("height").setText(Integer.toString(height));
        for (int row = 0; row < chartDataDefinition.getRowCount(); row++) {
            for (int column = 0; column < chartDataDefinition.getColumnCount(); column++) {
                Number value = chartDataDefinition.getValue(row, column);
                Comparable rowKey = chartDataDefinition.getRowKey(row);
                Comparable columnKey = chartDataDefinition.getColumnKey(column);
                // $NON-NLS-1$
                Element valueElement = chartElement.addElement("value2D");
                // $NON-NLS-1$
                valueElement.addElement("value").setText(value.toString());
                // $NON-NLS-1$
                valueElement.addElement("row-key").setText(rowKey.toString());
                // $NON-NLS-1$
                valueElement.addElement("column-key").setText(columnKey.toString());
            }
        }
        String mapString = ImageMapUtilities.getImageMap(mapName, info);
        // $NON-NLS-1$
        chartElement.addElement("imageMap").setText(mapString);
        // $NON-NLS-1$
        chartElement.addElement("image").setText(fileName);
    }
    return result;
}
Also used : Element(org.dom4j.Element) Document(org.dom4j.Document) IPentahoRequestContext(org.pentaho.platform.api.engine.IPentahoRequestContext) StandardEntityCollection(org.jfree.chart.entity.StandardEntityCollection) StringWriter(java.io.StringWriter) ChartRenderingInfo(org.jfree.chart.ChartRenderingInfo) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) PrintWriter(java.io.PrintWriter)

Example 8 with IPentahoRequestContext

use of org.pentaho.platform.api.engine.IPentahoRequestContext in project pentaho-platform by pentaho.

the class ChartHelper method doPieChart.

/**
 * doPieChart generates the images and html necessary to render pie charts. It provides a simple wrapper around
 * the class org.pentaho.ui.component.charting.PieDatasetChartComponent
 *
 * @param solutionName
 *          the solution name
 * @param actionPath
 *          the action path
 * @param chartName
 *          the xml file describing the chart
 * @param parameterProvider
 *          the collection of parameters to customize the chart
 * @param outputStream
 *          the output string buffer for the content
 * @param userSession
 *          the user session object
 * @param messages
 *          a collection to store error and logging messages
 * @param logger
 *          logging object
 *
 * @return true if successful
 * @deprecated use doChart instead
 */
@Deprecated
public static boolean doPieChart(final String actionPath, final IParameterProvider parameterProvider, final StringBuffer outputStream, final IPentahoSession userSession, final ArrayList messages, final ILogger logger) {
    deprecateWarning();
    boolean result = true;
    // $NON-NLS-1$
    String outerParams = parameterProvider.getStringParameter("outer-params", null);
    // $NON-NLS-1$
    String innerParam = parameterProvider.getStringParameter("inner-param", null);
    // $NON-NLS-1$
    String urlDrillTemplate = parameterProvider.getStringParameter("drill-url", null);
    // $NON-NLS-1$
    String imageUrl = parameterProvider.getStringParameter("image-url", null);
    IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
    if (imageUrl == null) {
        // $NON-NLS-1$
        imageUrl = requestContext.getContextPath();
    }
    if (urlDrillTemplate == null) {
        // $NON-NLS-1$
        urlDrillTemplate = "";
    }
    // $NON-NLS-1$
    int width = (int) parameterProvider.getLongParameter("image-width", 150);
    // $NON-NLS-1$
    int height = (int) parameterProvider.getLongParameter("image-height", 150);
    SimpleUrlFactory urlFactory = new SimpleUrlFactory(urlDrillTemplate);
    PieDatasetChartComponent chartComponent = null;
    try {
        chartComponent = new PieDatasetChartComponent(JFreeChartEngine.PIE_CHART_TYPE, actionPath, width, height, urlFactory, messages);
        if (logger != null) {
            chartComponent.setLoggingLevel(logger.getLoggingLevel());
        }
        chartComponent.validate(userSession, null);
        chartComponent.setUrlTemplate(urlDrillTemplate);
        if (outerParams != null) {
            // $NON-NLS-1$
            StringTokenizer tokenizer = new StringTokenizer(outerParams, ";");
            while (tokenizer.hasMoreTokens()) {
                chartComponent.addOuterParamName(tokenizer.nextToken());
            }
        }
        chartComponent.setParamName(innerParam);
        chartComponent.setDataAction(actionPath);
        chartComponent.setParameterProvider(IParameterProvider.SCOPE_REQUEST, parameterProvider);
        // $NON-NLS-1$
        String content = chartComponent.getContent("text/html");
        if ((content == null) || content.equals("")) {
            // $NON-NLS-1$
            // $NON-NLS-1$
            content = "&nbsp;";
        }
        outputStream.append(content);
    } finally {
        if (chartComponent != null) {
            chartComponent.dispose();
        }
    }
    return result;
}
Also used : IPentahoRequestContext(org.pentaho.platform.api.engine.IPentahoRequestContext) StringTokenizer(java.util.StringTokenizer) SimpleUrlFactory(org.pentaho.platform.util.web.SimpleUrlFactory)

Example 9 with IPentahoRequestContext

use of org.pentaho.platform.api.engine.IPentahoRequestContext in project pentaho-platform by pentaho.

the class ChartHelper method doDial.

/**
 * doDial generates the images and html necessary to render dials. It provides a simple wrapper around the class
 * org.pentaho.ui.component.DashboardWidgetComponent
 *
 * @param solutionName
 *          the solution name
 * @param actionPath
 *          the action path
 * @param chartName
 *          the xml file describing the chart
 * @param parameterProvider
 *          the collection of parameters to customize the chart
 * @param outputStream
 *          the output string buffer for the content
 * @param userSession
 *          the user session object
 * @param messages
 *          a collection to store error and logging messages
 * @param logger
 *          logging object
 *
 * @return true if successful
 * @deprecated use doChart() instead
 */
@Deprecated
public static boolean doDial(final String solutionName, final String actionPath, final String chartName, final IParameterProvider parameterProvider, final StringBuffer outputStream, final IPentahoSession userSession, final ArrayList messages, final ILogger logger) {
    deprecateWarning();
    boolean result = true;
    // $NON-NLS-1$
    String linkUrl = parameterProvider.getStringParameter("drill-url", null);
    // $NON-NLS-1$
    String imageUrl = parameterProvider.getStringParameter("image-url", null);
    IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
    if (imageUrl == null) {
        // $NON-NLS-1$
        imageUrl = requestContext.getContextPath();
    }
    if (linkUrl == null) {
        // $NON-NLS-1$
        linkUrl = "";
    }
    // $NON-NLS-1$
    int width = (int) parameterProvider.getLongParameter("image-width", 150);
    // $NON-NLS-1$
    int height = (int) parameterProvider.getLongParameter("image-height", 150);
    SimpleUrlFactory urlFactory = new SimpleUrlFactory(linkUrl);
    DashboardWidgetComponent widget = null;
    try {
        widget = new DashboardWidgetComponent(DashboardWidgetComponent.TYPE_DIAL, solutionName + File.separator + actionPath + File.separator + chartName, width, height, urlFactory, messages);
        if (logger != null) {
            widget.setLoggingLevel(logger.getLoggingLevel());
        }
        widget.validate(userSession, null);
        widget.setParameterProvider(IParameterProvider.SCOPE_REQUEST, parameterProvider);
        // $NON-NLS-1$//$NON-NLS-2$
        String value = parameterProvider.getStringParameter("value", "0");
        Number numericValue = DataUtilities.toNumber(value, LocaleHelper.getCurrencyFormat(), LocaleHelper.getNumberFormat());
        widget.setValue(numericValue.doubleValue());
        // $NON-NLS-1$ //$NON-NLS-2$
        String title = parameterProvider.getStringParameter("title", "");
        widget.setTitle(title);
        // $NON-NLS-1$
        String content = widget.getContent("text/html");
        if (content == null) {
            StringBuffer buffer = new StringBuffer();
            PentahoSystem.get(IMessageFormatter.class, userSession).formatErrorMessage("text/html", Messages.getInstance().getString("Widget.ERROR_0001_COULD_NOT_CREATE_WIDGET"), messages, // $NON-NLS-1$ //$NON-NLS-2$
            buffer);
            content = buffer.toString();
            result = false;
        }
        if ((content == null) || content.equals("")) {
            // $NON-NLS-1$
            // $NON-NLS-1$
            content = "&nbsp;";
        }
        outputStream.append(content);
    } finally {
        if (widget != null) {
            widget.dispose();
        }
    }
    return result;
}
Also used : IPentahoRequestContext(org.pentaho.platform.api.engine.IPentahoRequestContext) IMessageFormatter(org.pentaho.platform.api.engine.IMessageFormatter) SimpleUrlFactory(org.pentaho.platform.util.web.SimpleUrlFactory)

Example 10 with IPentahoRequestContext

use of org.pentaho.platform.api.engine.IPentahoRequestContext in project pentaho-platform by pentaho.

the class DashboardWidgetComponent method getXmlContent.

/**
 * Create a dial image.
 * <ul>
 * <li>Load the specified XML document describing the dial definition</li>
 * <li>Create a dial definition object from the XML definition</li>
 * <li>Use the JFreeChartEngine to create a dial image</li>
 * <li>Create an XML document describing the dial</li>
 * <li>Return the XML document</li>
 * </ul>
 *
 * @return The XML document describing this dial
 */
@Override
public Document getXmlContent() {
    WidgetDefinition widget = null;
    if (type == DashboardWidgetComponent.TYPE_DIAL) {
        // load the XML document that defines the dial
        IActionSequenceResource resource = new // $NON-NLS-1$
        ActionSequenceResource(// $NON-NLS-1$
        title, // $NON-NLS-1$
        IActionSequenceResource.SOLUTION_FILE_RESOURCE, // $NON-NLS-1$
        "text/xml", definitionPath);
        Document dialDefinition = null;
        try {
            org.dom4j.io.SAXReader reader = XMLParserFactoryProducer.getSAXReader(new SolutionURIResolver());
            dialDefinition = reader.read(resource.getInputStream(RepositoryFilePermission.READ, LocaleHelper.getLocale()));
        } catch (Throwable t) {
        // XML document can't be read. We'll just return a null document.
        }
        if (dialDefinition == null) {
            // $NON-NLS-1$
            error(Messages.getInstance().getErrorString("Widget.ERROR_0002_INVALID_RESOURCE", definitionPath));
            return null;
        }
        // create a dial definition from the XML definition
        widget = new DialWidgetDefinition(dialDefinition, 0, width, height, getSession());
        if (widget != null) {
            // set the value to be displayed on the dial
            widget.setValue(new Double(value));
        }
    }
    /*
     * else if( type == TYPE_THERMOMETER ) { // load the XML document that defines the thermometer
     * 
     * ActionResource resource = new ActionResource( title, IActionResource.SOLUTION_FILE_RESOURCE, "text/xml",
     * //$NON-NLS-1$ PentahoSystem.getApplicationContext().getSolutionPath( definitionPath ) ); //$NON-NLS-1$
     * Document thermometerDefinition = null; try { thermometerDefinition = PentahoSystem.getResourceAsDocument(
     * resource ); } catch (IOException e) {} // create a dial definition from the XML definition widget =
     * createThermometer( thermometerDefinition );
     * 
     * if( widget != null ) { // set the value to be displayed on the dial widget.setValue( new Double(value) ); //
     * Set the XSL file to be used to generate the HTML setXsl( "text/html", "DialWidget.xsl" ); //$NON-NLS-1$
     * //$NON-NLS-2$ } else { error( Messages.getInstance().getString("Widget.ERROR_0001_COULD_NOT_CREATE") );
     * //$NON-NLS-1$ return null; } }
     */
    if (widget == null) {
        // $NON-NLS-1$
        error(Messages.getInstance().getString("Widget.ERROR_0001_COULD_NOT_CREATE"));
        return null;
    }
    // create an image for the dial using the JFreeChart engine
    StringWriter stringWriter = new StringWriter();
    PrintWriter printWriter = new PrintWriter(stringWriter);
    // create temporary file names
    // $NON-NLS-1$
    String solutionDir = "system/tmp/";
    // $NON-NLS-1$
    String fileNamePrefix = "tmp_pie_";
    // $NON-NLS-1$
    String extension = ".png";
    String fileName = null;
    String filePathWithoutExtension = null;
    try {
        File file = PentahoSystem.getApplicationContext().createTempFile(getSession(), fileNamePrefix, extension, true);
        fileName = file.getName();
        filePathWithoutExtension = solutionDir + fileName.substring(0, fileName.indexOf('.'));
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    // $NON-NLS-1$
    String dialTitle = "";
    JFreeChartEngine.saveChart(widget, dialTitle, units, filePathWithoutExtension, width, height, JFreeChartEngine.OUTPUT_PNG, printWriter, this);
    // Create a document that describes the result
    Document result = DocumentHelper.createDocument();
    IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    setXslProperty("baseUrl", requestContext.getContextPath());
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    setXslProperty("fullyQualifiedServerUrl", PentahoSystem.getApplicationContext().getFullyQualifiedServerURL());
    // $NON-NLS-1$
    Element root = result.addElement("widget");
    // $NON-NLS-1$
    root.addElement("title").setText(title);
    // $NON-NLS-1$
    root.addElement("units").setText(units);
    // $NON-NLS-1$
    root.addElement("width").setText(Integer.toString(width));
    // $NON-NLS-1$
    root.addElement("height").setText(Integer.toString(height));
    // $NON-NLS-1$
    Element valueNode = root.addElement("value");
    valueNode.setText(Double.toString(value));
    // $NON-NLS-1$
    valueNode.addAttribute("in-image", Boolean.toString(widget.getValueFont() != null));
    // $NON-NLS-1$
    root.addElement("image").setText(fileName);
    return result;
}
Also used : Element(org.dom4j.Element) IOException(java.io.IOException) Document(org.dom4j.Document) IActionSequenceResource(org.pentaho.platform.api.engine.IActionSequenceResource) SolutionURIResolver(org.pentaho.platform.engine.services.SolutionURIResolver) IPentahoRequestContext(org.pentaho.platform.api.engine.IPentahoRequestContext) StringWriter(java.io.StringWriter) IActionSequenceResource(org.pentaho.platform.api.engine.IActionSequenceResource) ActionSequenceResource(org.pentaho.platform.engine.services.actionsequence.ActionSequenceResource) File(java.io.File) PrintWriter(java.io.PrintWriter)

Aggregations

IPentahoRequestContext (org.pentaho.platform.api.engine.IPentahoRequestContext)32 SimpleUrlFactory (org.pentaho.platform.util.web.SimpleUrlFactory)11 ArrayList (java.util.ArrayList)9 Document (org.dom4j.Document)9 Element (org.dom4j.Element)9 IOException (java.io.IOException)8 PrintWriter (java.io.PrintWriter)8 StringWriter (java.io.StringWriter)8 ByteArrayOutputStream (java.io.ByteArrayOutputStream)7 ChartRenderingInfo (org.jfree.chart.ChartRenderingInfo)7 StandardEntityCollection (org.jfree.chart.entity.StandardEntityCollection)7 UnsupportedEncodingException (java.io.UnsupportedEncodingException)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 File (java.io.File)5 OutputStream (java.io.OutputStream)5 List (java.util.List)5 IParameterProvider (org.pentaho.platform.api.engine.IParameterProvider)5 SimpleParameterProvider (org.pentaho.platform.engine.core.solution.SimpleParameterProvider)5 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)4 IPentahoUrlFactory (org.pentaho.platform.api.engine.IPentahoUrlFactory)4