Example usage for org.jfree.chart ChartFactory setChartTheme

List of usage examples for org.jfree.chart ChartFactory setChartTheme

Introduction

In this page you can find the example usage for org.jfree.chart ChartFactory setChartTheme.

Prototype

public static void setChartTheme(ChartTheme theme) 

Source Link

Document

Sets the current chart theme.

Usage

From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java

/**
 *
 *///w  w w.  j av a 2s  .c  om
protected JFreeChart createStackedBarChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createStackedBarChart(
            evaluateTextExpression(getChart().getTitleExpression()),
            evaluateTextExpression(((JRBarPlot) getPlot()).getCategoryAxisLabelExpression()),
            evaluateTextExpression(((JRBarPlot) getPlot()).getValueAxisLabelExpression()),
            (CategoryDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(),
            true, false);

    configureChart(jfreeChart, getPlot());

    CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot();
    JRBarPlot barPlot = (JRBarPlot) getPlot();
    //plot.setNoDataMessage("No data to display");
    boolean isShowTickMarks = barPlot.getShowTickMarks() == null ? true : barPlot.getShowTickMarks();
    boolean isShowTickLabels = barPlot.getShowTickLabels() == null ? true : barPlot.getShowTickLabels();
    boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels();

    categoryPlot.getDomainAxis().setTickMarksVisible(isShowTickMarks);
    categoryPlot.getDomainAxis().setTickLabelsVisible(isShowTickLabels);
    ((NumberAxis) categoryPlot.getRangeAxis()).setTickMarksVisible(isShowTickMarks);
    ((NumberAxis) categoryPlot.getRangeAxis()).setTickLabelsVisible(isShowTickLabels);

    BarRenderer categoryRenderer = (BarRenderer) categoryPlot.getRenderer();
    categoryRenderer.setBaseItemLabelsVisible(isShowLabels);
    Comparable<?> rangeAxisMaxValue = (Comparable<?>) evaluateExpression(
            barPlot.getRangeAxisMaxValueExpression());
    if (isShowLabels) {
        if (rangeAxisMaxValue == null) {
            //in case the bars are horizontal and there was no range max value specified, 
            //we try to make the axis a little longer for labels to fit on the plot
            Axis axis = categoryPlot.getRangeAxis();
            if (axis instanceof ValueAxis) {
                if (!(axis instanceof DateAxis)) {
                    float rangeAxisMaxRatio = 1f;

                    if (barPlot.getOrientationValue() == PlotOrientationEnum.HORIZONTAL) {
                        rangeAxisMaxRatio = JRPropertiesUtil
                                .getInstance(getChartContext().getJasperReportsContext())
                                .getFloatProperty(getChart(),
                                        "net.sf.jasperreports.chart.bar.horizontal.range.max.value.ratio",
                                        1.25f);
                    } else {
                        rangeAxisMaxRatio = JRPropertiesUtil
                                .getInstance(getChartContext().getJasperReportsContext())
                                .getFloatProperty(getChart(),
                                        "net.sf.jasperreports.chart.bar.vertical.range.max.value.ratio", 1.1f);
                    }

                    ((ValueAxis) axis).setUpperBound(((ValueAxis) axis).getUpperBound() * rangeAxisMaxRatio);
                }
            }
        }

        JRItemLabel itemLabel = barPlot.getItemLabel();

        categoryRenderer.setBaseItemLabelFont(
                getFontUtil().getAwtFont(getFont(itemLabel == null ? null : itemLabel.getFont()), getLocale()));

        if (itemLabel != null) {
            if (itemLabel.getColor() != null) {
                categoryRenderer.setBaseItemLabelPaint(itemLabel.getColor());
            } else {
                categoryRenderer.setBaseItemLabelPaint(getChart().getForecolor());
            }
            //            categoryRenderer.setBaseFillPaint(itemLabel.getBackgroundColor());
            //            if(itemLabel.getMask() != null)
            //            {
            //               categoryRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(
            //                     StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, 
            //                     new DecimalFormat(itemLabel.getMask())));
            //            }
            //            else
            //            {
            categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator());
            //            }
        } else {
            categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator());
            categoryRenderer.setBaseItemLabelPaint(getChart().getForecolor());
        }
    }
    categoryRenderer.setShadowVisible(false);

    // Handle the axis formating for the category axis
    configureAxis(categoryPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(),
            barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(),
            barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(),
            barPlot.getCategoryAxisVerticalTickLabels(), barPlot.getOwnCategoryAxisLineColor(),
            getDomainAxisSettings(),
            (Comparable<?>) evaluateExpression(barPlot.getDomainAxisMinValueExpression()),
            (Comparable<?>) evaluateExpression(barPlot.getDomainAxisMaxValueExpression()));

    // Handle the axis formating for the value axis
    configureAxis(categoryPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(),
            barPlot.getValueAxisLabelColor(), barPlot.getValueAxisTickLabelFont(),
            barPlot.getValueAxisTickLabelColor(), barPlot.getValueAxisTickLabelMask(),
            barPlot.getValueAxisVerticalTickLabels(), barPlot.getOwnValueAxisLineColor(),
            getRangeAxisSettings(),
            (Comparable<?>) evaluateExpression(barPlot.getRangeAxisMinValueExpression()), rangeAxisMaxValue);

    return jfreeChart;
}

From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java

protected JFreeChart createXyAreaChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createXYAreaChart(
            (String) evaluateExpression(getChart().getTitleExpression()),
            (String) evaluateExpression(((JRAreaPlot) getPlot()).getCategoryAxisLabelExpression()),
            (String) evaluateExpression(((JRAreaPlot) getPlot()).getValueAxisLabelExpression()),
            (XYDataset) getDataset(), getPlot().getOrientation(), isShowLegend(), true, false);

    configureChart(jfreeChart, getPlot());
    JRAreaPlot areaPlot = (JRAreaPlot) getPlot();

    // Handle the axis formating for the category axis
    configureAxis(jfreeChart.getXYPlot().getDomainAxis(), areaPlot.getCategoryAxisLabelFont(),
            areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(),
            areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(),
            areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getOwnCategoryAxisLineColor(),
            getDomainAxisSettings(),//from w  ww. ja va 2s  .  c  o m
            (Comparable) evaluateExpression(areaPlot.getDomainAxisMinValueExpression()),
            (Comparable) evaluateExpression(areaPlot.getDomainAxisMaxValueExpression()));

    // Handle the axis formating for the value axis
    configureAxis(jfreeChart.getXYPlot().getRangeAxis(), areaPlot.getValueAxisLabelFont(),
            areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(),
            areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(),
            areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getOwnValueAxisLineColor(),
            getRangeAxisSettings(), (Comparable) evaluateExpression(areaPlot.getRangeAxisMinValueExpression()),
            (Comparable) evaluateExpression(areaPlot.getRangeAxisMaxValueExpression()));

    return jfreeChart;
}

From source file:net.sf.fspdfs.chartthemes.spring.GenericChartTheme.java

/**
 *
 */// ww w.  j  a v  a 2  s  .  c om
protected JFreeChart createXYBarChart() throws JRException {
    IntervalXYDataset tmpDataset = (IntervalXYDataset) getDataset();

    boolean isDate = true;
    if (getChart().getDataset().getDatasetType() == JRChartDataset.XY_DATASET) {
        isDate = false;
    }

    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createXYBarChart(
            (String) evaluateExpression(getChart().getTitleExpression()),
            (String) evaluateExpression(((JRBarPlot) getPlot()).getCategoryAxisLabelExpression()), isDate,
            (String) evaluateExpression(((JRBarPlot) getPlot()).getValueAxisLabelExpression()), tmpDataset,
            getPlot().getOrientation(), isShowLegend(), true, false);

    configureChart(jfreeChart, getPlot());

    XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();
    //plot.setNoDataMessage("No data to display");
    //      ((XYPlot)plot.getDomainAxis()).setTickMarksVisible(
    //         ((JRBarPlot)getPlot()).isShowTickMarks()
    //         );
    //      ((CategoryAxis)plot.getDomainAxis()).setTickLabelsVisible(
    //            ((JRBarPlot)getPlot()).isShowTickLabels()
    //            );
    //      ((NumberAxis)plot.getRangeAxis()).setTickMarksVisible(
    //            ((JRBarPlot)getPlot()).isShowTickMarks()
    //            );
    //      ((NumberAxis)plot.getRangeAxis()).setTickLabelsVisible(
    //            ((JRBarPlot)getPlot()).isShowTickLabels()
    //            );

    XYBarRenderer itemRenderer = (XYBarRenderer) xyPlot.getRenderer();
    itemRenderer.setBaseItemLabelGenerator((XYItemLabelGenerator) getLabelGenerator());
    itemRenderer.setShadowVisible(false);

    JRBarPlot barPlot = (JRBarPlot) getPlot();
    boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels().booleanValue();

    itemRenderer.setBaseItemLabelsVisible(isShowLabels);

    // Handle the axis formating for the category axis
    configureAxis(xyPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(),
            barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(),
            barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(),
            barPlot.getCategoryAxisVerticalTickLabels(), barPlot.getOwnCategoryAxisLineColor(), false,
            (Comparable) evaluateExpression(barPlot.getDomainAxisMinValueExpression()),
            (Comparable) evaluateExpression(barPlot.getDomainAxisMaxValueExpression()));

    // Handle the axis formating for the value axis
    configureAxis(xyPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(), barPlot.getValueAxisLabelColor(),
            barPlot.getValueAxisTickLabelFont(), barPlot.getValueAxisTickLabelColor(),
            barPlot.getValueAxisTickLabelMask(), barPlot.getValueAxisVerticalTickLabels(),
            barPlot.getOwnValueAxisLineColor(), true,
            (Comparable) evaluateExpression(barPlot.getRangeAxisMinValueExpression()),
            (Comparable) evaluateExpression(barPlot.getRangeAxisMaxValueExpression()));

    return jfreeChart;
}

From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java

/**
 *
 *//* w  w  w.  ja  v  a2 s.  co  m*/
protected JFreeChart createXYBarChart() throws JRException {
    IntervalXYDataset tmpDataset = (IntervalXYDataset) getDataset();

    boolean isDate = true;
    if (getChart().getDataset().getDatasetType() == JRChartDataset.XY_DATASET) {
        isDate = false;
    }

    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createXYBarChart(
            (String) evaluateExpression(getChart().getTitleExpression()),
            (String) evaluateExpression(((JRBarPlot) getPlot()).getCategoryAxisLabelExpression()), isDate,
            (String) evaluateExpression(((JRBarPlot) getPlot()).getValueAxisLabelExpression()), tmpDataset,
            getPlot().getOrientation(), isShowLegend(), true, false);

    configureChart(jfreeChart, getPlot());

    XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();
    //plot.setNoDataMessage("No data to display");
    //      ((XYPlot)plot.getDomainAxis()).setTickMarksVisible(
    //         ((JRBarPlot)getPlot()).isShowTickMarks()
    //         );
    //      ((CategoryAxis)plot.getDomainAxis()).setTickLabelsVisible(
    //            ((JRBarPlot)getPlot()).isShowTickLabels()
    //            );
    //      ((NumberAxis)plot.getRangeAxis()).setTickMarksVisible(
    //            ((JRBarPlot)getPlot()).isShowTickMarks()
    //            );
    //      ((NumberAxis)plot.getRangeAxis()).setTickLabelsVisible(
    //            ((JRBarPlot)getPlot()).isShowTickLabels()
    //            );

    XYBarRenderer itemRenderer = (XYBarRenderer) xyPlot.getRenderer();
    itemRenderer.setBaseItemLabelGenerator((XYItemLabelGenerator) getLabelGenerator());
    itemRenderer.setShadowVisible(false);

    JRBarPlot barPlot = (JRBarPlot) getPlot();
    boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels().booleanValue();

    itemRenderer.setBaseItemLabelsVisible(isShowLabels);

    // Handle the axis formating for the category axis
    configureAxis(xyPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(),
            barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(),
            barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(),
            barPlot.getCategoryAxisVerticalTickLabels(), barPlot.getOwnCategoryAxisLineColor(),
            getDomainAxisSettings(), DateTickUnit.DAY,
            (Comparable) evaluateExpression(barPlot.getDomainAxisMinValueExpression()),
            (Comparable) evaluateExpression(barPlot.getDomainAxisMaxValueExpression()));

    // Handle the axis formating for the value axis
    configureAxis(xyPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(), barPlot.getValueAxisLabelColor(),
            barPlot.getValueAxisTickLabelFont(), barPlot.getValueAxisTickLabelColor(),
            barPlot.getValueAxisTickLabelMask(), barPlot.getValueAxisVerticalTickLabels(),
            barPlot.getOwnValueAxisLineColor(), getRangeAxisSettings(), DateTickUnit.DAY,
            (Comparable) evaluateExpression(barPlot.getRangeAxisMinValueExpression()),
            (Comparable) evaluateExpression(barPlot.getRangeAxisMaxValueExpression()));

    return jfreeChart;
}

From source file:net.sf.jasperreports.engine.fill.DefaultChartTheme.java

/**
 *
 *///www  . j  a  v a 2  s  .c  o  m
protected JFreeChart createStackedBarChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createStackedBarChart(
            evaluateTextExpression(getChart().getTitleExpression()),
            evaluateTextExpression(((JRBarPlot) getPlot()).getCategoryAxisLabelExpression()),
            evaluateTextExpression(((JRBarPlot) getPlot()).getValueAxisLabelExpression()),
            (CategoryDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(),
            true, false);

    configureChart(jfreeChart);

    CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot();
    JRBarPlot barPlot = (JRBarPlot) getPlot();
    //plot.setNoDataMessage("No data to display");
    boolean isShowTickMarks = barPlot.getShowTickMarks() == null ? true : barPlot.getShowTickMarks();
    boolean isShowTickLabels = barPlot.getShowTickLabels() == null ? true : barPlot.getShowTickLabels();
    boolean isShowLabels = barPlot.getShowLabels() == null ? false : barPlot.getShowLabels();

    categoryPlot.getDomainAxis().setTickMarksVisible(isShowTickMarks);
    categoryPlot.getDomainAxis().setTickLabelsVisible(isShowTickLabels);
    ((NumberAxis) categoryPlot.getRangeAxis()).setTickMarksVisible(isShowTickMarks);
    ((NumberAxis) categoryPlot.getRangeAxis()).setTickLabelsVisible(isShowTickLabels);

    BarRenderer categoryRenderer = (BarRenderer) categoryPlot.getRenderer();
    categoryRenderer.setBaseItemLabelsVisible(isShowLabels);
    Comparable<?> rangeAxisMaxValue = (Comparable<?>) evaluateExpression(
            barPlot.getRangeAxisMaxValueExpression());
    if (isShowLabels) {
        if (rangeAxisMaxValue == null) {
            //in case the bars are horizontal and there was no range max value specified, 
            //we try to make the axis a little longer for labels to fit on the plot
            Axis axis = categoryPlot.getRangeAxis();
            if (axis instanceof ValueAxis) {
                if (!(axis instanceof DateAxis)) {
                    float rangeAxisMaxRatio = 1f;

                    if (barPlot.getOrientationValue() == PlotOrientationEnum.HORIZONTAL) {
                        rangeAxisMaxRatio = JRPropertiesUtil.getInstance(chartContext.getJasperReportsContext())
                                .getFloatProperty(getChart(),
                                        "net.sf.jasperreports.chart.bar.horizontal.range.max.value.ratio",
                                        1.25f);
                    } else {
                        rangeAxisMaxRatio = JRPropertiesUtil.getInstance(chartContext.getJasperReportsContext())
                                .getFloatProperty(getChart(),
                                        "net.sf.jasperreports.chart.bar.vertical.range.max.value.ratio", 1.1f);
                    }

                    ((ValueAxis) axis).setUpperBound(((ValueAxis) axis).getUpperBound() * rangeAxisMaxRatio);
                }
            }
        }

        JRItemLabel itemLabel = barPlot.getItemLabel();

        categoryRenderer.setBaseItemLabelFont(
                fontUtil.getAwtFont(getFont(itemLabel == null ? null : itemLabel.getFont()), getLocale()));

        if (itemLabel != null) {
            if (itemLabel.getColor() != null) {
                categoryRenderer.setBaseItemLabelPaint(itemLabel.getColor());
            } else {
                categoryRenderer.setBaseItemLabelPaint(getChart().getForecolor());
            }
            //            categoryRenderer.setBaseFillPaint(itemLabel.getBackgroundColor());
            //            if (itemLabel.getMask() != null)
            //            {
            //               categoryRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(
            //                     StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, 
            //                     new DecimalFormat(itemLabel.getMask())));
            //            }
            //            else
            //            {
            categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator());
            //            }
        } else {
            categoryRenderer.setBaseItemLabelGenerator((CategoryItemLabelGenerator) getLabelGenerator());
            categoryRenderer.setBaseItemLabelPaint(getChart().getForecolor());
        }
    }
    categoryRenderer.setShadowVisible(false);

    // Handle the axis formating for the category axis
    configureAxis(categoryPlot.getDomainAxis(), barPlot.getCategoryAxisLabelFont(),
            barPlot.getCategoryAxisLabelColor(), barPlot.getCategoryAxisTickLabelFont(),
            barPlot.getCategoryAxisTickLabelColor(), barPlot.getCategoryAxisTickLabelMask(),
            barPlot.getCategoryAxisVerticalTickLabels(), barPlot.getCategoryAxisLineColor(), false,
            (Comparable<?>) evaluateExpression(barPlot.getDomainAxisMinValueExpression()),
            (Comparable<?>) evaluateExpression(barPlot.getDomainAxisMaxValueExpression()));

    // Handle the axis formating for the value axis
    configureAxis(categoryPlot.getRangeAxis(), barPlot.getValueAxisLabelFont(),
            barPlot.getValueAxisLabelColor(), barPlot.getValueAxisTickLabelFont(),
            barPlot.getValueAxisTickLabelColor(), barPlot.getValueAxisTickLabelMask(),
            barPlot.getValueAxisVerticalTickLabels(), barPlot.getValueAxisLineColor(), true,
            (Comparable<?>) evaluateExpression(barPlot.getRangeAxisMinValueExpression()), rangeAxisMaxValue);

    return jfreeChart;
}

From source file:net.sf.fspdfs.chartthemes.spring.GenericChartTheme.java

protected JFreeChart createXyLineChart() throws JRException {
    JRLinePlot linePlot = (JRLinePlot) getPlot();

    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createXYLineChart(
            (String) evaluateExpression(getChart().getTitleExpression()),
            (String) evaluateExpression(linePlot.getCategoryAxisLabelExpression()),
            (String) evaluateExpression(linePlot.getValueAxisLabelExpression()), (XYDataset) getDataset(),
            linePlot.getOrientation(), isShowLegend(), true, false);

    configureChart(jfreeChart, getPlot());

    // Handle the axis formating for the category axis
    configureAxis(jfreeChart.getXYPlot().getDomainAxis(), linePlot.getCategoryAxisLabelFont(),
            linePlot.getCategoryAxisLabelColor(), linePlot.getCategoryAxisTickLabelFont(),
            linePlot.getCategoryAxisTickLabelColor(), linePlot.getCategoryAxisTickLabelMask(),
            linePlot.getCategoryAxisVerticalTickLabels(), linePlot.getOwnCategoryAxisLineColor(), false,
            (Comparable) evaluateExpression(linePlot.getDomainAxisMinValueExpression()),
            (Comparable) evaluateExpression(linePlot.getDomainAxisMaxValueExpression()));

    // Handle the axis formating for the value axis
    configureAxis(jfreeChart.getXYPlot().getRangeAxis(), linePlot.getValueAxisLabelFont(),
            linePlot.getValueAxisLabelColor(), linePlot.getValueAxisTickLabelFont(),
            linePlot.getValueAxisTickLabelColor(), linePlot.getValueAxisTickLabelMask(),
            linePlot.getValueAxisVerticalTickLabels(), linePlot.getOwnValueAxisLineColor(), true,
            (Comparable) evaluateExpression(linePlot.getRangeAxisMinValueExpression()),
            (Comparable) evaluateExpression(linePlot.getRangeAxisMaxValueExpression()));

    XYLineAndShapeRenderer lineRenderer = (XYLineAndShapeRenderer) jfreeChart.getXYPlot().getRenderer();
    boolean isShowShapes = linePlot.getShowShapes() == null ? true : linePlot.getShowShapes().booleanValue();
    boolean isShowLines = linePlot.getShowLines() == null ? true : linePlot.getShowLines().booleanValue();
    lineRenderer.setBaseShapesVisible(isShowShapes);
    lineRenderer.setBaseLinesVisible(isShowLines);

    return jfreeChart;
}

From source file:net.sf.jasperreports.chartthemes.spring.GenericChartTheme.java

/**
 *
 *///from ww  w  .java  2s . c o  m
protected JFreeChart createStackedAreaChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createStackedAreaChart(
            evaluateTextExpression(getChart().getTitleExpression()),
            evaluateTextExpression(((JRAreaPlot) getPlot()).getCategoryAxisLabelExpression()),
            evaluateTextExpression(((JRAreaPlot) getPlot()).getValueAxisLabelExpression()),
            (CategoryDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(),
            true, false);

    configureChart(jfreeChart, getPlot());
    JRAreaPlot areaPlot = (JRAreaPlot) getPlot();

    // Handle the axis formating for the category axis
    configureAxis(((CategoryPlot) jfreeChart.getPlot()).getDomainAxis(), areaPlot.getCategoryAxisLabelFont(),
            areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(),
            areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(),
            areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getOwnCategoryAxisLineColor(), false,
            (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMinValueExpression()),
            (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMaxValueExpression()));

    // Handle the axis formating for the value axis
    configureAxis(((CategoryPlot) jfreeChart.getPlot()).getRangeAxis(), areaPlot.getValueAxisLabelFont(),
            areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(),
            areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(),
            areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getOwnValueAxisLineColor(), true,
            (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMinValueExpression()),
            (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMaxValueExpression()));

    ((CategoryPlot) jfreeChart.getPlot()).getDomainAxis().setCategoryMargin(0);

    return jfreeChart;
}

From source file:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java

protected JFreeChart createXyLineChart() throws JRException {
    JRLinePlot linePlot = (JRLinePlot) getPlot();

    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createXYLineChart(
            (String) evaluateExpression(getChart().getTitleExpression()),
            (String) evaluateExpression(linePlot.getCategoryAxisLabelExpression()),
            (String) evaluateExpression(linePlot.getValueAxisLabelExpression()), (XYDataset) getDataset(),
            linePlot.getOrientation(), isShowLegend(), true, false);

    configureChart(jfreeChart, getPlot());

    // Handle the axis formating for the category axis
    configureAxis(jfreeChart.getXYPlot().getDomainAxis(), linePlot.getCategoryAxisLabelFont(),
            linePlot.getCategoryAxisLabelColor(), linePlot.getCategoryAxisTickLabelFont(),
            linePlot.getCategoryAxisTickLabelColor(), linePlot.getCategoryAxisTickLabelMask(),
            linePlot.getCategoryAxisVerticalTickLabels(), linePlot.getOwnCategoryAxisLineColor(),
            getDomainAxisSettings(),// ww w  .j  a  v a  2  s. c  om
            (Comparable) evaluateExpression(linePlot.getDomainAxisMinValueExpression()),
            (Comparable) evaluateExpression(linePlot.getDomainAxisMaxValueExpression()));

    // Handle the axis formating for the value axis
    configureAxis(jfreeChart.getXYPlot().getRangeAxis(), linePlot.getValueAxisLabelFont(),
            linePlot.getValueAxisLabelColor(), linePlot.getValueAxisTickLabelFont(),
            linePlot.getValueAxisTickLabelColor(), linePlot.getValueAxisTickLabelMask(),
            linePlot.getValueAxisVerticalTickLabels(), linePlot.getOwnValueAxisLineColor(),
            getRangeAxisSettings(), (Comparable) evaluateExpression(linePlot.getRangeAxisMinValueExpression()),
            (Comparable) evaluateExpression(linePlot.getRangeAxisMaxValueExpression()));

    XYLineAndShapeRenderer lineRenderer = (XYLineAndShapeRenderer) jfreeChart.getXYPlot().getRenderer();
    boolean isShowShapes = linePlot.getShowShapes() == null ? true : linePlot.getShowShapes().booleanValue();
    boolean isShowLines = linePlot.getShowLines() == null ? true : linePlot.getShowLines().booleanValue();
    lineRenderer.setBaseShapesVisible(isShowShapes);
    lineRenderer.setBaseLinesVisible(isShowLines);

    return jfreeChart;
}

From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java

/**
 *
 *//*from w ww. ja  v  a 2s  .c  om*/
protected JFreeChart createStackedAreaChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createStackedAreaChart(
            evaluateTextExpression(getChart().getTitleExpression()),
            evaluateTextExpression(((JRAreaPlot) getPlot()).getCategoryAxisLabelExpression()),
            evaluateTextExpression(((JRAreaPlot) getPlot()).getValueAxisLabelExpression()),
            (CategoryDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(),
            true, false);

    configureChart(jfreeChart, getPlot());
    JRAreaPlot areaPlot = (JRAreaPlot) getPlot();

    // Handle the axis formating for the category axis
    configureAxis(((CategoryPlot) jfreeChart.getPlot()).getDomainAxis(), areaPlot.getCategoryAxisLabelFont(),
            areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(),
            areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(),
            areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getOwnCategoryAxisLineColor(),
            getDomainAxisSettings(),
            (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMinValueExpression()),
            (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMaxValueExpression()));

    // Handle the axis formating for the value axis
    configureAxis(((CategoryPlot) jfreeChart.getPlot()).getRangeAxis(), areaPlot.getValueAxisLabelFont(),
            areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(),
            areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(),
            areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getOwnValueAxisLineColor(),
            getRangeAxisSettings(),
            (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMinValueExpression()),
            (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMaxValueExpression()));

    ((CategoryPlot) jfreeChart.getPlot()).getDomainAxis().setCategoryMargin(0);

    return jfreeChart;
}

From source file:net.sf.jasperreports.chartthemes.spring.GenericChartTheme.java

protected JFreeChart createXyAreaChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createXYAreaChart(
            evaluateTextExpression(getChart().getTitleExpression()),
            evaluateTextExpression(((JRAreaPlot) getPlot()).getCategoryAxisLabelExpression()),
            evaluateTextExpression(((JRAreaPlot) getPlot()).getValueAxisLabelExpression()),
            (XYDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true,
            false);/*from www  .  ja v  a2s.co m*/

    configureChart(jfreeChart, getPlot());
    JRAreaPlot areaPlot = (JRAreaPlot) getPlot();

    // Handle the axis formating for the category axis
    configureAxis(jfreeChart.getXYPlot().getDomainAxis(), areaPlot.getCategoryAxisLabelFont(),
            areaPlot.getCategoryAxisLabelColor(), areaPlot.getCategoryAxisTickLabelFont(),
            areaPlot.getCategoryAxisTickLabelColor(), areaPlot.getCategoryAxisTickLabelMask(),
            areaPlot.getCategoryAxisVerticalTickLabels(), areaPlot.getOwnCategoryAxisLineColor(), false,
            (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMinValueExpression()),
            (Comparable<?>) evaluateExpression(areaPlot.getDomainAxisMaxValueExpression()));

    // Handle the axis formating for the value axis
    configureAxis(jfreeChart.getXYPlot().getRangeAxis(), areaPlot.getValueAxisLabelFont(),
            areaPlot.getValueAxisLabelColor(), areaPlot.getValueAxisTickLabelFont(),
            areaPlot.getValueAxisTickLabelColor(), areaPlot.getValueAxisTickLabelMask(),
            areaPlot.getValueAxisVerticalTickLabels(), areaPlot.getOwnValueAxisLineColor(), true,
            (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMinValueExpression()),
            (Comparable<?>) evaluateExpression(areaPlot.getRangeAxisMaxValueExpression()));

    return jfreeChart;
}