Search in sources :

Example 21 with Node

use of org.dom4j.Node in project pentaho-platform by pentaho.

the class TimeSeriesCollectionChartDefinition method setPaintSequence.

public void setPaintSequence(final Node paletteNode) {
    if (paletteNode != null) {
        List colorNodes = paletteNode.selectNodes(ChartDefinition.COLOR_NODE_NAME);
        Paint[] paints = new Paint[colorNodes.size()];
        for (int i = 0; i < colorNodes.size(); i++) {
            paints[i] = JFreeChartEngine.getPaint((Node) colorNodes.get(i));
        }
        setPaintSequence(paints);
    }
}
Also used : Node(org.dom4j.Node) ArrayList(java.util.ArrayList) List(java.util.List) Paint(java.awt.Paint) Paint(java.awt.Paint)

Example 22 with Node

use of org.dom4j.Node in project pentaho-platform by pentaho.

the class TimeSeriesCollectionChartDefinition method setChartAttributes.

private void setChartAttributes(final Node chartAttributes) {
    if (chartAttributes == null) {
        return;
    }
    // get the chart type from the chart node -- this overrides the current
    // chart type
    setChartType(chartAttributes.selectSingleNode(ChartDefinition.TYPE_NODE_NAME));
    // set the chart background
    setChartBackground(chartAttributes.selectSingleNode(ChartDefinition.CHART_BACKGROUND_NODE_NAME));
    // set the plot background
    setPlotBackground(chartAttributes.selectSingleNode(ChartDefinition.PLOT_BACKGROUND_NODE_NAME));
    // set the orientation
    setOrientation(chartAttributes.selectSingleNode(XYChartDefinition.ORIENTATION_NODE_NAME));
    // do we want a legend
    setLegendIncluded(chartAttributes.selectSingleNode(ChartDefinition.INCLUDE_LEGEND_NODE_NAME));
    // get the chart title
    setTitle(chartAttributes.selectSingleNode(ChartDefinition.TITLE_NODE_NAME));
    // A list of <subtitle> nodes should not be allowed to exist as a child of the main XML element (for XML schema
    // to
    // be well constructed and validate the XML .
    // We have deprecated <subtitle> as a child of the main node , and now require a <subtitles> parent node
    // under which <subtitle> can exist.
    List subtitles = chartAttributes.selectNodes(ChartDefinition.SUBTITLE_NODE_NAME);
    if ((subtitles == null) || (subtitles.isEmpty())) {
        Node subTitlesNode = chartAttributes.selectSingleNode(ChartDefinition.SUBTITLES_NODE_NAME);
        if (subTitlesNode != null) {
            subtitles = subTitlesNode.selectNodes(ChartDefinition.SUBTITLE_NODE_NAME);
        }
    } else {
        // log a deprecation warning for this property...
        getLogger().warn(Messages.getInstance().getString("CHART.WARN_DEPRECATED_CHILD", ChartDefinition.SUBTITLE_NODE_NAME, // $NON-NLS-1$
        ChartDefinition.SUBTITLES_NODE_NAME));
        getLogger().warn(Messages.getInstance().getString("CHART.WARN_PROPERTY_WILL_NOT_VALIDATE", // $NON-NLS-1$
        ChartDefinition.SUBTITLE_NODE_NAME));
    }
    if (subtitles != null) {
        addSubTitles(subtitles);
    }
    // get the paint sequence
    setPaintSequence(chartAttributes.selectSingleNode(ChartDefinition.PALETTE_NODE_NAME));
    Node backgroundAlphaNode = chartAttributes.selectSingleNode(ChartDefinition.BACKGROUND_ALPHA_NODE_NAME);
    Node foregroundAlphaNode = chartAttributes.selectSingleNode(ChartDefinition.FOREGROUND_ALPHA_NODE_NAME);
    if (backgroundAlphaNode != null) {
        setBackgroundAlpha(chartAttributes.selectSingleNode(ChartDefinition.BACKGROUND_ALPHA_NODE_NAME));
    }
    if (foregroundAlphaNode != null) {
        setForegroundAlpha(chartAttributes.selectSingleNode(ChartDefinition.FOREGROUND_ALPHA_NODE_NAME));
    }
    // get the stacked value
    setStacked(chartAttributes.selectSingleNode(ChartDefinition.STACKED_NODE_NAME));
    // get the 3D value
    setThreeD(chartAttributes.selectSingleNode(ChartDefinition.THREED_NODE_NAME));
    // set the width
    setWidth(chartAttributes.selectSingleNode(ChartDefinition.WIDTH_NODE_NAME));
    // set the height
    setHeight(chartAttributes.selectSingleNode(ChartDefinition.HEIGHT_NODE_NAME));
    // set the dot width
    setDotWidth(chartAttributes.selectSingleNode(ChartDefinition.DOT_WIDTH_NODE_NAME));
    // set the dot height
    setDotHeight(chartAttributes.selectSingleNode(ChartDefinition.DOT_HEIGHT_NODE_NAME));
    // set vertical tick labels flag
    setDomainVerticalTickLabels(chartAttributes.selectSingleNode(XYChartDefinition.DOMAIN_VERTICAL_TICK_LABELS_NODE_NAME));
    // set the border on or off
    setBorderVisible(chartAttributes.selectSingleNode(ChartDefinition.CHART_BORDER_VISIBLE_NODE_NAME));
    // set the border Paint
    setBorderPaint(JFreeChartEngine.getPaint(chartAttributes.selectSingleNode(XYChartDefinition.CHART_BORDER_PAINT_NODE_NAME)));
    // set the title location
    setTitlePosition(chartAttributes.selectSingleNode(ChartDefinition.TITLE_POSITION_NODE_NAME));
    // set the legend location
    setLegendPosition(chartAttributes.selectSingleNode(ChartDefinition.LEGEND_POSITION_NODE_NAME));
    // set the title font
    setTitleFont(chartAttributes.selectSingleNode(ChartDefinition.TITLE_FONT_NODE_NAME));
    // set the domain title
    setDomainTitle(chartAttributes.selectSingleNode(XYChartDefinition.DOMAIN_TITLE_NODE_NAME));
    // set the domain font
    setDomainTitleFont(chartAttributes.selectSingleNode(XYChartDefinition.DOMAIN_TITLE_FONT_NODE_NAME));
    // set the range title
    setRangeTitle(chartAttributes.selectSingleNode(XYChartDefinition.RANGE_TITLE_NODE_NAME));
    // the the range font
    setRangeTitleFont(chartAttributes.selectSingleNode(XYChartDefinition.RANGE_TITLE_FONT_NODE_NAME));
    // set the range minimum
    setRangeMinimum(chartAttributes.selectSingleNode(XYChartDefinition.RANGE_MINIMUM_NODE_NAME));
    // set the range minimum
    setRangeMaximum(chartAttributes.selectSingleNode(XYChartDefinition.RANGE_MAXIMUM_NODE_NAME));
    // set the date minimum
    setDateMinimum(chartAttributes.selectSingleNode(TimeSeriesCollectionChartDefinition.DATE_MINIMUM_NODE_NAME));
    // set the date minimum
    setDateMaximum(chartAttributes.selectSingleNode(TimeSeriesCollectionChartDefinition.DATE_MAXIMUM_NODE_NAME));
    // set the Period type
    setDomainPeriodType(chartAttributes.selectSingleNode(XYChartDefinition.DOMAIN_PERIOD_TYPE_NODE_NAME));
    // set the line style
    setLineStyle(chartAttributes.selectSingleNode(ChartDefinition.LINE_STYLE_NODE_NAME));
    // set the line width
    setLineWidth(chartAttributes.selectSingleNode(ChartDefinition.LINE_WIDTH_NODE_NAME));
    // set the marker visibility
    setMarkersVisible(chartAttributes.selectSingleNode(ChartDefinition.MARKER_VISIBLE_NODE_NAME));
    // set legend font
    setLegendFont(chartAttributes.selectSingleNode(ChartDefinition.LEGEND_FONT_NODE_NAME));
    // set legend border visible
    setLegendBorderVisible(chartAttributes.selectSingleNode(ChartDefinition.DISPLAY_LEGEND_BORDER_NODE_NAME));
    setTooltipContent(chartAttributes.selectSingleNode(XYChartDefinition.TOOLTIP_CONTENT_NODE_NAME));
    setTooltipYFormat(chartAttributes.selectSingleNode(XYChartDefinition.TOOLTIP_Y_FORMAT_NODE_NAME));
    setTooltipXFormat(chartAttributes.selectSingleNode(XYChartDefinition.TOOLTIP_X_FORMAT_NODE_NAME));
}
Also used : Node(org.dom4j.Node) ArrayList(java.util.ArrayList) List(java.util.List)

Example 23 with Node

use of org.dom4j.Node in project pentaho-platform by pentaho.

the class TimeSeriesCollectionChartDefinition method setPlotBackground.

public void setPlotBackground(final Node plotBackgroundNode) {
    if (plotBackgroundNode != null) {
        Node backgroundTypeNode = plotBackgroundNode.selectSingleNode(ChartDefinition.BACKGROUND_TYPE_ATTRIBUTE_NAME);
        if (backgroundTypeNode != null) {
            String backgroundTypeStr = backgroundTypeNode.getText();
            if (ChartDefinition.COLOR_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
                setPlotBackgroundPaint(JFreeChartEngine.getPaint(plotBackgroundNode));
                setPlotBackgroundImage((Image) null);
            } else if (ChartDefinition.IMAGE_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
                setPlotBackgroundImage(plotBackgroundNode);
                setPlotBackgroundPaint(null);
            } else if (ChartDefinition.TEXTURE_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
                setPlotBackgroundPaint(JFreeChartEngine.getTexturePaint(plotBackgroundNode, getWidth(), getHeight(), getSession()));
                setPlotBackgroundImage((Image) null);
            } else if (ChartDefinition.GRADIENT_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
                setPlotBackgroundPaint(JFreeChartEngine.getGradientPaint(plotBackgroundNode, getWidth(), getHeight()));
                setPlotBackgroundImage((Image) null);
            }
        }
    }
}
Also used : Node(org.dom4j.Node) Image(java.awt.Image)

Example 24 with Node

use of org.dom4j.Node in project pentaho-platform by pentaho.

the class AbstractJFreeChartComponent method setDataAction.

@Override
public boolean setDataAction(final String chartDefinition) {
    try {
        Document dataActionDocument = jcrHelper.getSolutionDocument(chartDefinition, RepositoryFilePermission.READ);
        if (dataActionDocument == null) {
            return false;
        }
        // $NON-NLS-1$
        Node dataNode = dataActionDocument.selectSingleNode("chart/data");
        if (dataNode == null) {
            // No data here
            return false;
        }
        // $NON-NLS-1$
        chartType = (int) XmlDom4JHelper.getNodeText("chart-type", dataNode, -1);
        // $NON-NLS-1$
        actionPath = XmlDom4JHelper.getNodeText("data-path", dataNode);
        // $NON-NLS-1$
        actionOutput = XmlDom4JHelper.getNodeText("data-output", dataNode);
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        byRow = XmlDom4JHelper.getNodeText("data-orientation", dataNode, "rows").equals("rows");
        if (width == 0) {
            // $NON-NLS-1$
            width = (int) XmlDom4JHelper.getNodeText("chart/width", dataActionDocument, DEFAULT_WIDTH);
        }
        if (height == 0) {
            // $NON-NLS-1$
            height = (int) XmlDom4JHelper.getNodeText("chart/height", dataActionDocument, DEFAULT_HEIGHT);
        }
    } catch (Exception e) {
        error(Messages.getInstance().getString("CategoryDatasetChartComponent.ERROR_0001_INVALID_CHART_DEFINITION", chartDefinition), // $NON-NLS-1$
        e);
        return false;
    }
    return true;
}
Also used : Node(org.dom4j.Node) Document(org.dom4j.Document)

Example 25 with Node

use of org.dom4j.Node in project pentaho-platform by pentaho.

the class CategoryDatasetChartDefinition method setPlotBackground.

public void setPlotBackground(final Node plotBackgroundNode) {
    if (plotBackgroundNode != null) {
        Node backgroundTypeNode = plotBackgroundNode.selectSingleNode(ChartDefinition.BACKGROUND_TYPE_ATTRIBUTE_NAME);
        if (backgroundTypeNode != null) {
            String backgroundTypeStr = backgroundTypeNode.getText();
            if (ChartDefinition.COLOR_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
                setPlotBackgroundPaint(JFreeChartEngine.getPaint(plotBackgroundNode));
                setPlotBackgroundImage((Image) null);
            } else if (ChartDefinition.IMAGE_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
                setPlotBackgroundImage(plotBackgroundNode);
                setPlotBackgroundPaint(null);
            } else if (ChartDefinition.TEXTURE_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
                setPlotBackgroundPaint(JFreeChartEngine.getTexturePaint(plotBackgroundNode, getWidth(), getHeight(), getSession()));
                setPlotBackgroundImage((Image) null);
            } else if (ChartDefinition.GRADIENT_TYPE_NAME.equalsIgnoreCase(backgroundTypeStr)) {
                setPlotBackgroundPaint(JFreeChartEngine.getGradientPaint(plotBackgroundNode, getWidth(), getHeight()));
                setPlotBackgroundImage((Image) null);
            }
        }
    }
}
Also used : Node(org.dom4j.Node) Image(java.awt.Image)

Aggregations

Node (org.dom4j.Node)253 Document (org.dom4j.Document)83 Element (org.dom4j.Element)61 ArrayList (java.util.ArrayList)56 List (java.util.List)54 Test (org.junit.Test)40 SAXReader (org.dom4j.io.SAXReader)28 File (java.io.File)25 Iterator (java.util.Iterator)18 ReturnedDocument (org.collectionspace.chain.csp.persistence.services.connection.ReturnedDocument)18 IPentahoResultSet (org.pentaho.commons.connection.IPentahoResultSet)18 HashMap (java.util.HashMap)16 URL (java.net.URL)15 ReturnedMultipartDocument (org.collectionspace.chain.csp.persistence.services.connection.ReturnedMultipartDocument)15 InputStream (java.io.InputStream)14 Attribute (org.dom4j.Attribute)14 Image (java.awt.Image)12 ConnectionException (org.collectionspace.chain.csp.persistence.services.connection.ConnectionException)11 VFSItem (org.olat.core.util.vfs.VFSItem)10 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)10