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 .java2s  .  co  m*/
protected JFreeChart createStackedBar3DChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createStackedBarChart3D(
            evaluateTextExpression(getChart().getTitleExpression()),
            evaluateTextExpression(((JRBar3DPlot) getPlot()).getCategoryAxisLabelExpression()),
            evaluateTextExpression(((JRBar3DPlot) getPlot()).getValueAxisLabelExpression()),
            (CategoryDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(),
            true, false);

    configureChart(jfreeChart, getPlot());

    CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot();
    JRBar3DPlot bar3DPlot = (JRBar3DPlot) getPlot();

    StackedBarRenderer3D stackedBarRenderer3D = new StackedBarRenderer3D(
            bar3DPlot.getXOffsetDouble() == null ? StackedBarRenderer3D.DEFAULT_X_OFFSET
                    : bar3DPlot.getXOffsetDouble(),
            bar3DPlot.getYOffsetDouble() == null ? StackedBarRenderer3D.DEFAULT_Y_OFFSET
                    : bar3DPlot.getYOffsetDouble());

    boolean isShowLabels = bar3DPlot.getShowLabels() == null ? false : bar3DPlot.getShowLabels();
    stackedBarRenderer3D.setBaseItemLabelsVisible(isShowLabels);
    if (isShowLabels) {
        JRItemLabel itemLabel = bar3DPlot.getItemLabel();

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

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

    categoryPlot.setRenderer(stackedBarRenderer3D);

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

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

    return jfreeChart;
}

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

/**
 *
 *///from   ww w.  ja  v a2  s.  co  m
protected JFreeChart createStackedAreaChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createStackedAreaChart(
            (String) evaluateExpression(getChart().getTitleExpression()),
            (String) evaluateExpression(((JRAreaPlot) getPlot()).getCategoryAxisLabelExpression()),
            (String) evaluateExpression(((JRAreaPlot) getPlot()).getValueAxisLabelExpression()),
            (CategoryDataset) getDataset(), getPlot().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.jasperreports.engine.fill.DefaultChartTheme.java

protected JFreeChart createScatterChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createScatterPlot(
            evaluateTextExpression(getChart().getTitleExpression()),
            evaluateTextExpression(((JRScatterPlot) getPlot()).getXAxisLabelExpression()),
            evaluateTextExpression(((JRScatterPlot) getPlot()).getYAxisLabelExpression()),
            (XYDataset) getDataset(), getPlot().getOrientationValue().getOrientation(), isShowLegend(), true,
            false);//w  w w . j av  a  2s. c o m

    configureChart(jfreeChart);
    XYLineAndShapeRenderer plotRenderer = (XYLineAndShapeRenderer) ((XYPlot) jfreeChart.getPlot())
            .getRenderer();

    JRScatterPlot scatterPlot = (JRScatterPlot) getPlot();
    boolean isShowLines = scatterPlot.getShowLines() == null ? true : scatterPlot.getShowLines();
    boolean isShowShapes = scatterPlot.getShowShapes() == null ? true : scatterPlot.getShowShapes();

    plotRenderer.setBaseLinesVisible(isShowLines);
    plotRenderer.setBaseShapesVisible(isShowShapes);

    // Handle the axis formating for the category axis
    configureAxis(jfreeChart.getXYPlot().getDomainAxis(), scatterPlot.getXAxisLabelFont(),
            scatterPlot.getXAxisLabelColor(), scatterPlot.getXAxisTickLabelFont(),
            scatterPlot.getXAxisTickLabelColor(), scatterPlot.getXAxisTickLabelMask(),
            scatterPlot.getXAxisVerticalTickLabels(), scatterPlot.getXAxisLineColor(), false,
            (Comparable<?>) evaluateExpression(scatterPlot.getDomainAxisMinValueExpression()),
            (Comparable<?>) evaluateExpression(scatterPlot.getDomainAxisMaxValueExpression()));

    // Handle the axis formating for the value axis
    configureAxis(jfreeChart.getXYPlot().getRangeAxis(), scatterPlot.getYAxisLabelFont(),
            scatterPlot.getYAxisLabelColor(), scatterPlot.getYAxisTickLabelFont(),
            scatterPlot.getYAxisTickLabelColor(), scatterPlot.getYAxisTickLabelMask(),
            scatterPlot.getYAxisVerticalTickLabels(), scatterPlot.getYAxisLineColor(), true,
            (Comparable<?>) evaluateExpression(scatterPlot.getRangeAxisMinValueExpression()),
            (Comparable<?>) evaluateExpression(scatterPlot.getRangeAxisMaxValueExpression()));

    return jfreeChart;
}

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

private boolean writeProbeCorrHistImage(OutputStream os, ExpressionExperiment ee) throws IOException {
    XYSeries series = this.getCorrelHist(ee);

    if (series == null || series.getItemCount() == 0) {
        return false;
    }/* w ww. java  2 s  .  c  om*/

    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    XYSeriesCollection xySeriesCollection = new XYSeriesCollection();
    xySeriesCollection.addSeries(series);
    JFreeChart chart = ChartFactory.createXYLineChart("", "Correlation", "Frequency", xySeriesCollection,
            PlotOrientation.VERTICAL, false, false, false);
    chart.getXYPlot().setRangeGridlinesVisible(false);
    chart.getXYPlot().setDomainGridlinesVisible(false);
    XYItemRenderer renderer = chart.getXYPlot().getRenderer();
    renderer.setBasePaint(Color.white);

    int size = (int) (ExpressionExperimentQCController.DEFAULT_QC_IMAGE_SIZE_PX * 0.8);
    ChartUtilities.writeChartAsPNG(os, chart, size, size);

    return true;
}

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

/**
 *
 */// w  w w.ja va2s.  co  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, 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(), 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.getOwnValueAxisLineColor(), true,
            (Comparable<?>) evaluateExpression(barPlot.getRangeAxisMinValueExpression()), rangeAxisMaxValue);

    return jfreeChart;
}

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

/**
 *
 *//*from ww  w . j  a  v  a2  s. co  m*/
protected JFreeChart createStackedAreaChart() throws JRException {
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart jfreeChart = ChartFactory.createStackedAreaChart(
            (String) evaluateExpression(getChart().getTitleExpression()),
            (String) evaluateExpression(((JRAreaPlot) getPlot()).getCategoryAxisLabelExpression()),
            (String) evaluateExpression(((JRAreaPlot) getPlot()).getValueAxisLabelExpression()),
            (CategoryDataset) getDataset(), getPlot().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:ubic.gemma.web.controller.expression.experiment.ExpressionExperimentQCController.java

/**
 * Has to handle the situation where there might be more than one ResultSet.
 *///from   www  .  jav a2  s .  c om
private boolean writePValueHistImage(OutputStream os, ExpressionExperiment ee, Long analysisId, Long rsId,
        String factorName) throws IOException {

    XYSeries series = this.getDiffExPvalueHistXYSeries(ee, analysisId, rsId, factorName);

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

    XYSeriesCollection xySeriesCollection = new XYSeriesCollection(series);

    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart chart = ChartFactory.createXYLineChart("", "P-value", "Frequency", xySeriesCollection,
            PlotOrientation.VERTICAL, false, false, false);
    chart.getXYPlot().setRangeGridlinesVisible(false);
    chart.getXYPlot().setDomainGridlinesVisible(false);
    XYItemRenderer renderer = chart.getXYPlot().getRenderer();
    renderer.setBasePaint(Color.white);

    ChartUtilities.writeChartAsPNG(os, chart,
            (int) (ExpressionExperimentQCController.DEFAULT_QC_IMAGE_SIZE_PX * 1.4),
            ExpressionExperimentQCController.DEFAULT_QC_IMAGE_SIZE_PX);
    return true;
}

From source file:net.sf.fspdfs.chartthemes.spring.GenericChartTheme.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(), 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;
}

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

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

    configureChart(jfreeChart);

    CategoryPlot categoryPlot = (CategoryPlot) jfreeChart.getPlot();
    JRBar3DPlot bar3DPlot = (JRBar3DPlot) getPlot();

    StackedBarRenderer3D stackedBarRenderer3D = new StackedBarRenderer3D(
            bar3DPlot.getXOffsetDouble() == null ? StackedBarRenderer3D.DEFAULT_X_OFFSET
                    : bar3DPlot.getXOffsetDouble(),
            bar3DPlot.getYOffsetDouble() == null ? StackedBarRenderer3D.DEFAULT_Y_OFFSET
                    : bar3DPlot.getYOffsetDouble());
    boolean isShowLabels = bar3DPlot.getShowLabels() == null ? false : bar3DPlot.getShowLabels();
    stackedBarRenderer3D.setBaseItemLabelsVisible(isShowLabels);
    if (isShowLabels) {
        JRItemLabel itemLabel = bar3DPlot.getItemLabel();

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

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

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

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

    return jfreeChart;
}

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

/**
 * Write p-value histogram thumbnail image.
 *///  w  ww. ja v  a  2 s  .com
private boolean writePValueHistThumbnailImage(OutputStream os, ExpressionExperiment ee, Long analysisId,
        Long rsId, String factorName, int size) throws IOException {
    XYSeries series = this.getDiffExPvalueHistXYSeries(ee, analysisId, rsId, factorName);

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

    series.add(-0.01, 0.0);

    XYSeriesCollection xySeriesCollection = new XYSeriesCollection(series);

    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());
    JFreeChart chart = ChartFactory.createXYLineChart("", "", "", xySeriesCollection, PlotOrientation.VERTICAL,
            false, false, false);

    chart.getXYPlot().setBackgroundPaint(new Color(230, 230, 230));
    chart.getXYPlot().setRangeGridlinesVisible(false);
    chart.getXYPlot().setDomainGridlinesVisible(false);
    chart.getXYPlot().setOutlineVisible(false); // around the plot
    chart.getXYPlot().getRangeAxis().setTickMarksVisible(false);
    chart.getXYPlot().getRangeAxis().setTickLabelsVisible(false);
    chart.getXYPlot().getRangeAxis().setAxisLineVisible(false);
    chart.getXYPlot().getDomainAxis().setTickMarksVisible(false);
    chart.getXYPlot().getDomainAxis().setTickLabelsVisible(false);
    chart.getXYPlot().getDomainAxis().setAxisLineVisible(false);
    chart.getXYPlot().getRenderer().setSeriesPaint(0, Color.RED);
    // chart.getXYPlot().getRenderer().setSeriesStroke( 0, new BasicStroke( 1 ) );

    // Make the chart a bit bigger to account for the empty space around the generated image.
    // If we can find a way to remove this empty space, we don't need to make the chart bigger.
    ChartUtilities.writeChartAsPNG(os, chart, size + 16, size + 9);

    return true;
}