Example usage for org.dom4j Node getText

List of usage examples for org.dom4j Node getText

Introduction

In this page you can find the example usage for org.dom4j Node getText.

Prototype

String getText();

Source Link

Document

Returns the text of this node.

Usage

From source file:com.google.code.pentahoflashcharts.charts.pfcxml.DefaultChartBuilder.java

License:Open Source License

protected void setTooltip(Node root, Element e) {
    Node tooltipNode = root.selectSingleNode("/chart/tooltip");
    if (tooltipNode != null && tooltipNode.getText().length() > 0) {
        String tooltip = tooltipNode.getText().trim();
        e.setTooltip(tooltip);/*from w  ww  .ja va  2  s. c o m*/
    } else {
        e.setTooltip("#val#");
    }
}

From source file:com.google.code.pentahoflashcharts.charts.pfcxml.DefaultChartBuilder.java

License:Open Source License

protected void setXAxisRange(Chart c, Node stepsNode, Node maxNode) {
    XAxis axis = c.getXAxis();/*from  w  ww  .  j  av  a2s. c o m*/
    if (axis == null) {
        axis = new XAxis();

        c.setXAxis(axis);
    }

    int max = 10000;
    int step = 10;
    if (stepsNode != null && stepsNode.getText().length() > 0) {
        step = Integer.parseInt(stepsNode.getText().trim());
    }

    if (maxNode != null && maxNode.getText().length() > 0) {
        max = Integer.parseInt(maxNode.getText().trim());
    }
    axis.setRange(0, max, step);

}

From source file:com.google.code.pentahoflashcharts.charts.pfcxml.DefaultChartBuilder.java

License:Open Source License

protected void setupYAxisLabels(Chart c, Node root, IPentahoResultSet data) {
    if (root.selectSingleNode("/chart/y-axis") != null) {

        YAxis axis = c.getYAxis();/* w ww .j a v  a2  s  . co  m*/
        if (axis == null) {
            axis = new YAxis();
            c.setYAxis(axis);
        }
        Node colIndexNode = root.selectSingleNode("/chart/y-axis/labels/sql-column-index");
        if (colIndexNode != null && colIndexNode.getText().length() > 0) {
            int index = Integer.parseInt(colIndexNode.getText().trim());
            int rowCount = data.getRowCount();
            String[] labels = new String[rowCount];
            for (int j = 0; j < rowCount; j++) {
                Object obj = data.getValueAt(j, index - 1);
                if (obj instanceof java.sql.Timestamp || obj instanceof java.util.Date) {
                    labels[j] = sf.format(obj);
                } else {
                    labels[j] = obj.toString();
                }
            }
            axis.setLabels(labels);
        } else if (getValue(root.selectSingleNode("/chart/y-axis/labels/values")) != null) {
            axis.setLabels(fillLabels(root.selectSingleNode("/chart/y-axis/labels/values")));
        }

        Node colorNode = root.selectSingleNode("/chart/y-axis/color");
        if (colorNode != null && colorNode.getText().length() > 2) {
            axis.setColour(colorNode.getText().trim());
        }

    }
}

From source file:com.google.code.pentahoflashcharts.charts.pfcxml.DefaultChartBuilder.java

License:Open Source License

protected static void setXAxisLabels(Chart c, Node root, IPentahoResultSet data) {
    if (root.selectSingleNode("/chart/x-axis") != null) {

        XAxis axis = c.getXAxis();/*from   w  w w . j  a va2  s .co  m*/
        if (axis == null) {
            axis = new XAxis();

            c.setXAxis(axis);
        }
        Node colIndexNode = root.selectSingleNode("/chart/x-axis/labels/sql-column-index");
        if (colIndexNode != null && colIndexNode.getText().length() > 0) {
            int index = Integer.parseInt(colIndexNode.getText().trim());
            int rowCount = data.getRowCount();
            String[] labels = new String[rowCount];
            for (int j = 0; j < rowCount; j++) {
                Object obj = data.getValueAt(j, index - 1);
                if (obj instanceof java.sql.Timestamp || obj instanceof java.util.Date) {
                    labels[j] = sf.format(obj);
                } else {
                    labels[j] = obj.toString();
                }
            }
            axis.setLabels(labels);
        } else if (getValue(root.selectSingleNode("/chart/x-axis/labels/values")) != null) {
            axis.setLabels(fillLabels(root.selectSingleNode("/chart/x-axis/labels/values")));
        }

        Node colorNode = root.selectSingleNode("/chart/x-axis/color");
        if (colorNode != null && colorNode.getText().length() > 2) {
            axis.setColour(colorNode.getText().trim());
        }

    }
}

From source file:com.google.code.pentahoflashcharts.charts.pfcxml.LineChartBuilder.java

License:Open Source License

protected void setupElements(Chart c, Node root, IPentahoResultSet data) {
    Style lineStyle = setupLineStyle(root);
    int columnCount = data.getMetaData().getColumnCount();
    LineChart[] elements = null;/* w  w  w  .j  a v a  2s  .  co m*/
    if (columnCount > 1) {
        elements = new LineChart[columnCount - 1];
        int rowCount = data.getRowCount();
        List colors = root.selectNodes("/chart/color-palette/color");
        for (int i = 1; i <= columnCount - 1; i++) {
            LineChart e = new LineChart(lineStyle);
            Number[] datas = new Number[rowCount];

            for (int j = 0; j < rowCount; j++) {
                datas[j] = (Number) data.getValueAt(j, i);
                e.addValues(datas[j].doubleValue());
            }
            String colour;
            if (colors != null && colors.size() > 1) {
                colour = ((Node) colors.get(i - 1)).getText().trim();
                e.setColour(colour);
            }
            e.setText((String) data.getMetaData().getColumnHeaders()[0][i]);
            setLink(e, root, "/chart/link");
            setOnClick(e, root, "/chart/on-click");
            elements[i - 1] = e;
        }
        setupXAxisLabels(data, c, rowCount);

    } else {
        elements = new LineChart[columnCount];
        LineChart e = new LineChart(setupLineStyle(root));

        Node chartBackGround = root.selectSingleNode("/chart/chart-background");
        if (chartBackGround != null) {

            e.setColour(chartBackGround.getText());
        }
        int rowCount = data.getRowCount();
        Number[] datas = new Number[rowCount];
        for (int i = 0; i < rowCount; i++) {
            datas[i] = (Number) data.getValueAt(i, 0);
        }
        e.addValues(datas);
        elements[0] = e;
        setLink(e, root, "/chart/link");
        setOnClick(e, root, "/chart/on-click");
    }
    c.addElements(elements);
}

From source file:com.google.code.pentahoflashcharts.charts.pfcxml.OFC4JHelper.java

License:Open Source License

public static String generateChartJson(Node chartNode, IPentahoResultSet data, boolean byRow, Log log) {

    Chart c = new Chart();
    Node root = chartNode;/* ww w .j a v  a2  s . c  om*/

    IPentahoResultSet chartdata;

    if (byRow) {
        chartdata = PentahoDataTransmuter.pivot(data);
    } else {
        chartdata = data;
    }
    Node chartType = root.selectSingleNode("/chart/chart-type");
    String cType = chartType.getText().trim();

    Node is_3DNode = root.selectSingleNode("/chart/is-3D");
    Node is_glassNode = root.selectSingleNode("/chart/is-glass");
    Node is_sketchNode = root.selectSingleNode("/chart/is-sketch");

    if (cType.equalsIgnoreCase("BarChart")) {
        boolean isDone = false;
        if (is_3DNode != null && is_3DNode.getText().length() > 0) {
            String str = is_3DNode.getText().trim();
            if (str.equalsIgnoreCase("true")) {

                ThreeDBarChartBuilder builder = new ThreeDBarChartBuilder();
                c = builder.build(root, chartdata);
                isDone = true;
            }
        }
        if (isDone != true && is_glassNode != null && is_glassNode.getText().length() > 0) {
            String str = is_glassNode.getText().trim();
            if (str.equalsIgnoreCase("true")) {

                GlassBarChartBuilder builder = new GlassBarChartBuilder();
                c = builder.build(root, chartdata);
                isDone = true;
            }
        }

        if (isDone != true && is_sketchNode != null && is_sketchNode.getText().length() > 0) {
            String str = is_sketchNode.getText().trim();
            if (str.equalsIgnoreCase("true")) {

                SketchBarChartBuilder builder = new SketchBarChartBuilder();
                c = builder.build(root, chartdata);
                isDone = true;
            }
        }
        Node isStackedNode = root.selectSingleNode("/chart/is-stacked");
        if (isDone != true && isStackedNode != null && isStackedNode.getText().length() > 0) {
            String str = isStackedNode.getText().trim();
            if (str.equalsIgnoreCase("true")) {

                StackedBarChartBuilder builder = new StackedBarChartBuilder();
                c = builder.build(root, chartdata);
                isDone = true;
            }
        }

        Node orientationNode = root.selectSingleNode("/chart/orientation");
        if (isDone != true && orientationNode != null && orientationNode.getText().length() > 0) {
            String str = orientationNode.getText().trim();
            if (str.equalsIgnoreCase("horizontal")) {

                HorizontalBarChartBuilder builder = new HorizontalBarChartBuilder();
                c = builder.build(root, chartdata);
                isDone = true;
            }
        }
        if (isDone != true) {
            BarChartBuilder builder = new BarChartBuilder();
            c = builder.build(root, chartdata);
        }
    } else if (cType.equalsIgnoreCase("AreaChart")) {
        AreaChartBuilder builder = new AreaChartBuilder();
        c = builder.build(root, chartdata);

    } else if (cType.equalsIgnoreCase("LineChart")) {

        LineChartBuilder builder = new LineChartBuilder();
        c = builder.build(root, chartdata);
    } else if (cType.equalsIgnoreCase("PieChart")) {

        PieChartBuilder builder = new PieChartBuilder();
        c = builder.build(root, chartdata);
    } else if (cType.equalsIgnoreCase("BarLineChart")) {
        BarLineChartBuilder builder = new BarLineChartBuilder();
        c = builder.build(root, chartdata);
    } else if (cType.equalsIgnoreCase("ScatterChart")) {
        ScatterChartBuilder builder = new ScatterChartBuilder();
        c = builder.build(root, chartdata);
    }

    return c.toString();

}

From source file:com.google.code.pentahoflashcharts.charts.pfcxml.PieChartBuilder.java

License:Open Source License

protected void setupElements(Chart c, Node root, IPentahoResultSet data) {
    PieChart e = new PieChart();
    int rowCount = data.getRowCount();
    Node colIndexNode = root.selectSingleNode("/chart/slice/datas/sql-column-index");
    Node labelIndexNode = root.selectSingleNode("/chart/slice/labels/sql-column-index");
    if (colIndexNode != null && colIndexNode.getText().length() > 0) {
        int index = Integer.parseInt(colIndexNode.getText().trim());
        int labelindex = Integer.parseInt(labelIndexNode.getText().trim());
        for (int j = 0; j < rowCount; j++) {
            Object obj = data.getValueAt(j, labelindex - 1);
            Number value = (Number) data.getValueAt(j, index - 1);
            if (obj instanceof java.sql.Timestamp || obj instanceof java.util.Date) {
                e.addSlice(value.doubleValue(), sf.format(obj));
            } else {
                Slice s = new Slice(value.doubleValue(), obj.toString());
                e.addSlices(s);//from  www .jav a2  s.  co m
            }
        }
    }
    c.addElements(e);
}

From source file:com.google.code.pentahoflashcharts.charts.pfcxml.PieChartBuilder.java

License:Open Source License

protected void setTooltip(Node root, Element e) {
    Node tooltipNode = root.selectSingleNode("/chart/tooltip");
    if (tooltipNode != null && tooltipNode.getText().length() > 0) {
        String tooltip = tooltipNode.getText().trim();
        e.setTooltip(tooltip);//w  w  w  .j a v a 2 s.  co m
    } else {
        e.setTooltip("#val# of #total#<br>#percent# of 100%");
    }
}

From source file:com.google.code.pentahoflashcharts.charts.pfcxml.PieChartBuilder.java

License:Open Source License

protected void setColorPalette(Node root, PieChart e) {
    Node colorsNode = root.selectSingleNode("/chart/slice/color-palette");
    if (colorsNode != null && colorsNode.getText().length() > 0) {
        String[] colors = null;/*from w  w w  .  j  a  v a  2 s  .  c om*/

        colors = fillLabels(colorsNode);
        e.setColours(colors);

    }
}

From source file:com.google.code.pentahoflashcharts.charts.pfcxml.PieChartBuilder.java

License:Open Source License

protected void setIsAnimated(Node root, PieChart e) {
    Node isAnimateNode = root.selectSingleNode("/chart/isAnimate");
    if (isAnimateNode != null && isAnimateNode.getText().length() > 0) {
        String str = isAnimateNode.getText().trim();
        if ("true".equalsIgnoreCase(str)) {
            e.setAnimate(true);/*from www.ja v  a 2s.co m*/
        } else
            e.setAnimate(false);
    }
}