Example usage for org.jfree.chart StandardChartTheme createLegacyTheme

List of usage examples for org.jfree.chart StandardChartTheme createLegacyTheme

Introduction

In this page you can find the example usage for org.jfree.chart StandardChartTheme createLegacyTheme.

Prototype

public static ChartTheme createLegacyTheme() 

Source Link

Document

Creates and returns a ChartTheme that doesn't apply any changes to the JFreeChart defaults.

Usage

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

/**
 *
 *//*  ww  w .j  a  v  a2 s. co m*/
protected JFreeChart createCandlestickChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createCandlestickChart(
            evaluateTextExpression(getChart().getTitleExpression()),
            evaluateTextExpression(((JRCandlestickPlot) getPlot()).getTimeAxisLabelExpression()),
            evaluateTextExpression(((JRCandlestickPlot) getPlot()).getValueAxisLabelExpression()),
            (DefaultHighLowDataset) getDataset(), isShowLegend());

    configureChart(jfreeChart);

    XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();
    JRCandlestickPlot candlestickPlot = (JRCandlestickPlot) getPlot();
    CandlestickRenderer candlestickRenderer = (CandlestickRenderer) xyPlot.getRenderer();
    boolean isShowVolume = candlestickPlot.getShowVolume() == null ? true : candlestickPlot.getShowVolume();
    candlestickRenderer.setDrawVolume(isShowVolume);

    // Handle the axis formating for the category axis
    configureAxis(xyPlot.getDomainAxis(), candlestickPlot.getTimeAxisLabelFont(),
            candlestickPlot.getTimeAxisLabelColor(), candlestickPlot.getTimeAxisTickLabelFont(),
            candlestickPlot.getTimeAxisTickLabelColor(), candlestickPlot.getTimeAxisTickLabelMask(),
            candlestickPlot.getTimeAxisVerticalTickLabels(), candlestickPlot.getTimeAxisLineColor(), false,
            (Comparable<?>) evaluateExpression(candlestickPlot.getDomainAxisMinValueExpression()),
            (Comparable<?>) evaluateExpression(candlestickPlot.getDomainAxisMaxValueExpression()));

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

    return jfreeChart;
}

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

protected JFreeChart createLineChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart freeChart = ChartFactory.createLineChart(evaluateTextExpression(getChart().getTitleExpression()),
            evaluateTextExpression(((JRLinePlot) getPlot()).getCategoryAxisLabelExpression()),
            evaluateTextExpression(((JRLinePlot) getPlot()).getValueAxisLabelExpression()),
            (CategoryDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(),
            true, false);/*from   w w  w .  j  a v a2  s .  c om*/

    configureChart(freeChart, getPlot());

    CategoryPlot categoryPlot = (CategoryPlot) freeChart.getPlot();
    JRLinePlot linePlot = (JRLinePlot) getPlot();

    LineAndShapeRenderer lineRenderer = (LineAndShapeRenderer) categoryPlot.getRenderer();
    boolean isShowShapes = linePlot.getShowShapes() == null ? true : linePlot.getShowShapes();
    boolean isShowLines = linePlot.getShowLines() == null ? true : linePlot.getShowLines();

    lineRenderer.setBaseShapesVisible(isShowShapes);//FIXMECHART check this
    lineRenderer.setBaseLinesVisible(isShowLines);

    //FIXME labels?

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

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

    return freeChart;
}

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

/**
 *
 */// ww  w. j  a  v  a2s . c o m
protected JFreeChart createPie3DChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createPieChart3D(
            (String) evaluateExpression(getChart().getTitleExpression()), (PieDataset) getDataset(),
            isShowLegend(), true, false);

    configureChart(jfreeChart, getPlot());

    PiePlot3D piePlot3D = (PiePlot3D) jfreeChart.getPlot();
    //plot.setStartAngle(290);
    //plot.setDirection(Rotation.CLOCKWISE);
    //plot.setNoDataMessage("No data to display");
    JRPie3DPlot jrPlot = (JRPie3DPlot) getPlot();
    double depthFactor = jrPlot.getDepthFactorDouble() == null ? JRPie3DPlot.DEPTH_FACTOR_DEFAULT
            : jrPlot.getDepthFactorDouble().doubleValue();
    boolean isCircular = jrPlot.getCircular() == null ? false : jrPlot.getCircular().booleanValue();
    piePlot3D.setDepthFactor(depthFactor);
    piePlot3D.setCircular(isCircular);

    PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator) getLabelGenerator();
    JRItemLabel itemLabel = jrPlot.getItemLabel();
    if (labelGenerator != null) {
        piePlot3D.setLabelGenerator(labelGenerator);
    } else if (jrPlot.getLabelFormat() != null) {
        piePlot3D.setLabelGenerator(new StandardPieSectionLabelGenerator(jrPlot.getLabelFormat()));
    }
    //      else if (itemLabel != null && itemLabel.getMask() != null)
    //      {
    //         piePlot3D.setLabelGenerator(
    //               new StandardPieSectionLabelGenerator(itemLabel.getMask())
    //               );
    //      }

    if (jrPlot.getLegendLabelFormat() != null) {
        piePlot3D.setLegendLabelGenerator(new StandardPieSectionLabelGenerator(jrPlot.getLegendLabelFormat()));
    }

    if (itemLabel != null && itemLabel.getFont() != null) {
        piePlot3D.setLabelFont(JRFontUtil.getAwtFont(itemLabel.getFont(), getLocale()));
    } else {
        piePlot3D.setLabelFont(JRFontUtil.getAwtFont(new JRBaseFont(getChart(), null), getLocale()));
    }

    if (itemLabel != null && itemLabel.getColor() != null) {
        piePlot3D.setLabelPaint(itemLabel.getColor());
    } else {
        piePlot3D.setLabelPaint(getChart().getForecolor());
    }

    if (itemLabel != null && itemLabel.getBackgroundColor() != null) {
        piePlot3D.setLabelBackgroundPaint(itemLabel.getBackgroundColor());
    } else {
        piePlot3D.setLabelBackgroundPaint(getChart().getBackcolor());
    }

    return jfreeChart;
}

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

/**
 *
 *///from w  w  w. j a  va 2 s  .  co m
protected JFreeChart createPie3DChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createPieChart3D(
            evaluateTextExpression(getChart().getTitleExpression()), (PieDataset) getDataset(), isShowLegend(),
            true, false);

    configureChart(jfreeChart, getPlot());

    PiePlot3D piePlot3D = (PiePlot3D) jfreeChart.getPlot();
    //plot.setStartAngle(290);
    //plot.setDirection(Rotation.CLOCKWISE);
    //plot.setNoDataMessage("No data to display");
    JRPie3DPlot jrPie3DPlot = (JRPie3DPlot) getPlot();
    double depthFactor = jrPie3DPlot.getDepthFactorDouble() == null ? JRPie3DPlot.DEPTH_FACTOR_DEFAULT
            : jrPie3DPlot.getDepthFactorDouble();
    boolean isCircular = jrPie3DPlot.getCircular() == null ? false : jrPie3DPlot.getCircular();
    piePlot3D.setDepthFactor(depthFactor);
    piePlot3D.setCircular(isCircular);

    boolean isShowLabels = jrPie3DPlot.getShowLabels() == null ? true : jrPie3DPlot.getShowLabels();

    if (isShowLabels) {
        PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator) getLabelGenerator();
        JRItemLabel itemLabel = jrPie3DPlot.getItemLabel();
        if (labelGenerator != null) {
            piePlot3D.setLabelGenerator(labelGenerator);
        } else if (jrPie3DPlot.getLabelFormat() != null) {
            piePlot3D.setLabelGenerator(new StandardPieSectionLabelGenerator(jrPie3DPlot.getLabelFormat(),
                    NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale())));
        }
        //      else if (itemLabel != null && itemLabel.getMask() != null)
        //      {
        //         piePlot3D.setLabelGenerator(
        //            new StandardPieSectionLabelGenerator(itemLabel.getMask())
        //            );
        //      }
        else {
            piePlot3D.setLabelGenerator(new StandardPieSectionLabelGenerator());
        }

        Integer baseFontSize = (Integer) getDefaultValue(defaultChartPropertiesMap,
                ChartThemesConstants.BASEFONT_SIZE);
        JRFont font = itemLabel != null && itemLabel.getFont() != null ? itemLabel.getFont() : null;
        piePlot3D.setLabelFont(getFont(new JRBaseFont(getChart(), null), font, baseFontSize));

        if (itemLabel != null && itemLabel.getColor() != null) {
            piePlot3D.setLabelPaint(itemLabel.getColor());
        } else {
            piePlot3D.setLabelPaint(getChart().getForecolor());
        }

        if (itemLabel != null && itemLabel.getBackgroundColor() != null) {
            piePlot3D.setLabelBackgroundPaint(itemLabel.getBackgroundColor());
        } else {
            piePlot3D.setLabelBackgroundPaint(getChart().getBackcolor());
        }
    } else {
        piePlot3D.setLabelGenerator(null);
    }

    if (jrPie3DPlot.getLegendLabelFormat() != null) {
        piePlot3D.setLegendLabelGenerator(new StandardPieSectionLabelGenerator(
                jrPie3DPlot.getLegendLabelFormat(), NumberFormat.getNumberInstance(getLocale()),
                NumberFormat.getPercentInstance(getLocale())));
    }

    return jfreeChart;
}

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

/**
 *
 *//*  ww  w  .j a  v  a  2s.c  om*/
protected JFreeChart createHighLowChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createHighLowChart(
            evaluateTextExpression(getChart().getTitleExpression()),
            evaluateTextExpression(((JRHighLowPlot) getPlot()).getTimeAxisLabelExpression()),
            evaluateTextExpression(((JRHighLowPlot) getPlot()).getValueAxisLabelExpression()),
            (DefaultHighLowDataset) getDataset(), isShowLegend());

    configureChart(jfreeChart);

    XYPlot xyPlot = (XYPlot) jfreeChart.getPlot();
    JRHighLowPlot highLowPlot = (JRHighLowPlot) getPlot();
    HighLowRenderer hlRenderer = (HighLowRenderer) xyPlot.getRenderer();
    boolean isShowOpenTicks = highLowPlot.getShowOpenTicks() == null ? false : highLowPlot.getShowOpenTicks();
    boolean isShowCloseTicks = highLowPlot.getShowCloseTicks() == null ? false
            : highLowPlot.getShowCloseTicks();

    hlRenderer.setDrawOpenTicks(isShowOpenTicks);
    hlRenderer.setDrawCloseTicks(isShowCloseTicks);

    // Handle the axis formating for the category axis
    configureAxis(xyPlot.getDomainAxis(), highLowPlot.getTimeAxisLabelFont(),
            highLowPlot.getTimeAxisLabelColor(), highLowPlot.getTimeAxisTickLabelFont(),
            highLowPlot.getTimeAxisTickLabelColor(), highLowPlot.getTimeAxisTickLabelMask(),
            highLowPlot.getTimeAxisVerticalTickLabels(), highLowPlot.getTimeAxisLineColor(), false,
            (Comparable<?>) evaluateExpression(highLowPlot.getDomainAxisMinValueExpression()),
            (Comparable<?>) evaluateExpression(highLowPlot.getDomainAxisMaxValueExpression()));

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

    return jfreeChart;
}

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

/**
 *
 *///w  w  w.  j  a va  2  s. c o m
protected JFreeChart createPieChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createPieChart(
            (String) evaluateExpression(getChart().getTitleExpression()), (PieDataset) getDataset(),
            isShowLegend(), true, false);

    configureChart(jfreeChart, getPlot());
    PiePlot piePlot = (PiePlot) jfreeChart.getPlot();
    //plot.setStartAngle(290);
    //plot.setDirection(Rotation.CLOCKWISE);
    //plot.setNoDataMessage("No data to display");
    JRPiePlot jrPlot = (JRPiePlot) getPlot();
    boolean isCircular = jrPlot.getCircular() == null ? true : jrPlot.getCircular().booleanValue();
    piePlot.setCircular(isCircular);

    PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator) getLabelGenerator();
    JRItemLabel itemLabel = jrPlot.getItemLabel();

    if (labelGenerator != null) {
        piePlot.setLabelGenerator(labelGenerator);
    } else if (jrPlot.getLabelFormat() != null) {
        piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator(jrPlot.getLabelFormat()));
    }
    //      else if (itemLabel != null && itemLabel.getMask() != null)
    //      {
    //         piePlot.setLabelGenerator(
    //               new StandardPieSectionLabelGenerator(itemLabel.getMask())
    //               );
    //
    //      }

    if (jrPlot.getLegendLabelFormat() != null) {
        piePlot.setLegendLabelGenerator(new StandardPieSectionLabelGenerator(jrPlot.getLegendLabelFormat()));
    }

    Integer baseFontSize = (Integer) getDefaultValue(defaultChartPropertiesMap,
            ChartThemesConstants.BASEFONT_SIZE);
    JRFont font = itemLabel != null && itemLabel.getFont() != null ? itemLabel.getFont() : null;

    piePlot.setLabelFont(getFont(new JRBaseFont(getChart(), null), font, baseFontSize));

    if (itemLabel != null && itemLabel.getColor() != null) {
        piePlot.setLabelPaint(itemLabel.getColor());
    } else {
        piePlot.setLabelPaint(getChart().getForecolor());
    }

    if (itemLabel != null && itemLabel.getBackgroundColor() != null) {
        piePlot.setLabelBackgroundPaint(itemLabel.getBackgroundColor());
    } else {
        piePlot.setLabelBackgroundPaint(getChart().getBackcolor());
    }

    return jfreeChart;
}

From source file:ubic.gemma.web.controller.expression.experiment.ExpressionExperimentQCController.java

/**
 * @param os response output stream/*www.jav a2 s.c  o  m*/
 * @param mvr MeanVarianceRelation object to plot
 * @return true if mvr data points were plotted
 */
private boolean writeMeanVariance(OutputStream os, MeanVarianceRelation mvr, Double size) throws Exception {
    // if number of datapoints > THRESHOLD then alpha = TRANSLUCENT, else alpha = OPAQUE
    final int THRESHOLD = 1000;
    final int TRANSLUCENT = 50;
    final int OPAQUE = 255;

    // Set maximum plot range to Y_MAX + YRANGE * OFFSET to leave some extra white space
    final double OFFSET_FACTOR = 0.05f;

    // set the final image size to be the minimum of MAX_IMAGE_SIZE_PX or size
    final int MAX_IMAGE_SIZE_PX = 5;

    if (mvr == null) {
        return false;
    }

    // get data points
    XYSeriesCollection collection = this.getMeanVariance(mvr);

    if (collection.getSeries().size() == 0) {
        return false;
    }

    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart chart = ChartFactory.createScatterPlot("", "mean (log2)", "variance (log2)", collection,
            PlotOrientation.VERTICAL, false, false, false);

    // adjust colors and shapes
    XYRegressionRenderer renderer = new XYRegressionRenderer();
    renderer.setBasePaint(Color.white);
    XYSeries series = collection.getSeries(0);
    int alpha = series.getItemCount() > THRESHOLD ? TRANSLUCENT : OPAQUE;
    renderer.setSeriesPaint(0, new Color(0, 0, 0, alpha));
    renderer.setSeriesPaint(1, Color.red);
    renderer.setSeriesStroke(1, new BasicStroke(1));
    renderer.setSeriesShape(0, new Ellipse2D.Double(4, 4, 4, 4));
    renderer.setSeriesShapesFilled(0, false);
    renderer.setSeriesLinesVisible(0, false);
    renderer.setSeriesLinesVisible(1, true);
    renderer.setSeriesShapesVisible(1, false);

    XYPlot plot = chart.getXYPlot();
    plot.setRenderer(renderer);
    plot.setRangeGridlinesVisible(false);
    plot.setDomainGridlinesVisible(false);

    // adjust the chart domain and ranges
    double yRange = series.getMaxY() - series.getMinY();
    double xRange = series.getMaxX() - series.getMinX();
    if (xRange < 0) {
        log.warn("Min X was greater than Max X: Max=" + series.getMaxY() + " Min= " + series.getMinY());
        return false;
    }
    double ybuffer = (yRange) * OFFSET_FACTOR;
    double xbuffer = (xRange) * OFFSET_FACTOR;
    double newYMin = series.getMinY() - ybuffer;
    double newYMax = series.getMaxY() + ybuffer;
    double newXMin = series.getMinX() - xbuffer;
    double newXMax = series.getMaxX() + xbuffer;

    ValueAxis yAxis = new NumberAxis("Variance");
    yAxis.setRange(newYMin, newYMax);
    ValueAxis xAxis = new NumberAxis("Mean");
    xAxis.setRange(newXMin, newXMax);
    chart.getXYPlot().setRangeAxis(yAxis);
    chart.getXYPlot().setDomainAxis(xAxis);

    int finalSize = (int) Math.min(
            MAX_IMAGE_SIZE_PX * ExpressionExperimentQCController.DEFAULT_QC_IMAGE_SIZE_PX,
            size * ExpressionExperimentQCController.DEFAULT_QC_IMAGE_SIZE_PX);

    ChartUtilities.writeChartAsPNG(os, chart, finalSize, finalSize);

    return true;
}

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

/**
 *
 *///from ww  w .jav a 2  s. c om
protected JFreeChart createPie3DChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createPieChart3D(
            evaluateTextExpression(getChart().getTitleExpression()), (PieDataset) getDataset(), isShowLegend(),
            true, false);

    configureChart(jfreeChart, getPlot());

    PiePlot3D piePlot3D = (PiePlot3D) jfreeChart.getPlot();
    //plot.setStartAngle(290);
    //plot.setDirection(Rotation.CLOCKWISE);
    //plot.setNoDataMessage("No data to display");
    JRPie3DPlot jrPie3DPlot = (JRPie3DPlot) getPlot();
    double depthFactor = jrPie3DPlot.getDepthFactorDouble() == null ? JRPie3DPlot.DEPTH_FACTOR_DEFAULT
            : jrPie3DPlot.getDepthFactorDouble();
    boolean isCircular = jrPie3DPlot.getCircular() == null ? false : jrPie3DPlot.getCircular();
    piePlot3D.setDepthFactor(depthFactor);
    piePlot3D.setCircular(isCircular);

    boolean isShowLabels = jrPie3DPlot.getShowLabels() == null ? true : jrPie3DPlot.getShowLabels();

    if (isShowLabels) {
        PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator) getLabelGenerator();
        JRItemLabel itemLabel = jrPie3DPlot.getItemLabel();
        if (labelGenerator != null) {
            piePlot3D.setLabelGenerator(labelGenerator);
        } else if (jrPie3DPlot.getLabelFormat() != null) {
            piePlot3D.setLabelGenerator(new StandardPieSectionLabelGenerator(jrPie3DPlot.getLabelFormat(),
                    NumberFormat.getNumberInstance(getLocale()), NumberFormat.getPercentInstance(getLocale())));
        }
        //      else if (itemLabel != null && itemLabel.getMask() != null)
        //      {
        //         piePlot3D.setLabelGenerator(
        //               new StandardPieSectionLabelGenerator(itemLabel.getMask())
        //               );
        //      }

        if (itemLabel != null && itemLabel.getFont() != null) {
            piePlot3D.setLabelFont(getFontUtil().getAwtFont(itemLabel.getFont(), getLocale()));
        } else {
            piePlot3D.setLabelFont(getFontUtil().getAwtFont(new JRBaseFont(getChart(), null), getLocale()));
        }

        if (itemLabel != null && itemLabel.getColor() != null) {
            piePlot3D.setLabelPaint(itemLabel.getColor());
        } else {
            piePlot3D.setLabelPaint(getChart().getForecolor());
        }

        if (itemLabel != null && itemLabel.getBackgroundColor() != null) {
            piePlot3D.setLabelBackgroundPaint(itemLabel.getBackgroundColor());
        } else {
            piePlot3D.setLabelBackgroundPaint(getChart().getBackcolor());
        }
    } else {
        piePlot3D.setLabelGenerator(null);
    }

    if (jrPie3DPlot.getLegendLabelFormat() != null) {
        piePlot3D.setLegendLabelGenerator(new StandardPieSectionLabelGenerator(
                jrPie3DPlot.getLegendLabelFormat(), NumberFormat.getNumberInstance(getLocale()),
                NumberFormat.getPercentInstance(getLocale())));
    }

    return jfreeChart;
}

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

/**
 *
 *//*  www.ja v  a2s  .  com*/
protected JFreeChart createPieChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createPieChart(
            (String) evaluateExpression(getChart().getTitleExpression()), (PieDataset) getDataset(),
            isShowLegend(), true, false);

    configureChart(jfreeChart, getPlot());
    PiePlot piePlot = (PiePlot) jfreeChart.getPlot();
    //plot.setStartAngle(290);
    //plot.setDirection(Rotation.CLOCKWISE);
    //plot.setNoDataMessage("No data to display");
    JRPiePlot jrPlot = (JRPiePlot) getPlot();
    boolean isCircular = jrPlot.getCircular() == null ? true : jrPlot.getCircular().booleanValue();
    piePlot.setCircular(isCircular);

    PieSectionLabelGenerator labelGenerator = (PieSectionLabelGenerator) getLabelGenerator();
    JRItemLabel itemLabel = jrPlot.getItemLabel();
    if (labelGenerator != null) {
        piePlot.setLabelGenerator(labelGenerator);
    } else if (jrPlot.getLabelFormat() != null) {
        piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator(jrPlot.getLabelFormat()));
    }
    //      else if (itemLabel != null && itemLabel.getMask() != null)
    //      {
    //         piePlot.setLabelGenerator(
    //               new StandardPieSectionLabelGenerator(itemLabel.getMask())
    //               );
    //      }

    if (jrPlot.getLegendLabelFormat() != null) {
        piePlot.setLegendLabelGenerator(
                new StandardPieSectionLabelGenerator(((JRPie3DPlot) getPlot()).getLegendLabelFormat()));
    }

    if (itemLabel != null && itemLabel.getFont() != null) {
        piePlot.setLabelFont(JRFontUtil.getAwtFont(itemLabel.getFont(), getLocale()));
    } else {
        piePlot.setLabelFont(JRFontUtil.getAwtFont(new JRBaseFont(getChart(), null), getLocale()));
    }

    if (itemLabel != null && itemLabel.getColor() != null) {
        piePlot.setLabelPaint(itemLabel.getColor());
    } else {
        piePlot.setLabelPaint(getChart().getForecolor());
    }

    if (itemLabel != null && itemLabel.getBackgroundColor() != null) {
        piePlot.setLabelBackgroundPaint(itemLabel.getBackgroundColor());
    } else {
        piePlot.setLabelBackgroundPaint(getChart().getBackcolor());
    }

    return jfreeChart;
}

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

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

    configureChart(jfreeChart);

    CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot();
    JRLinePlot linePlot = (JRLinePlot) getPlot();

    LineAndShapeRenderer lineRenderer = (LineAndShapeRenderer) categoryPlot.getRenderer();
    boolean isShowShapes = linePlot.getShowShapes() == null ? true : linePlot.getShowShapes();
    boolean isShowLines = linePlot.getShowLines() == null ? true : linePlot.getShowLines();

    lineRenderer.setBaseShapesVisible(isShowShapes);//FIXMECHART check this
    lineRenderer.setBaseLinesVisible(isShowLines);

    //FIXME labels?

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

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

    return jfreeChart;
}