Example usage for org.jfree.chart JFreeChart DEFAULT_TITLE_FONT

List of usage examples for org.jfree.chart JFreeChart DEFAULT_TITLE_FONT

Introduction

In this page you can find the example usage for org.jfree.chart JFreeChart DEFAULT_TITLE_FONT.

Prototype

Font DEFAULT_TITLE_FONT

To view the source code for org.jfree.chart JFreeChart DEFAULT_TITLE_FONT.

Click Source Link

Document

The default font for titles.

Usage

From source file:org.jfree.eastwood.ChartEngine.java

/**
 * Creates a bar chart with the specified orientation and using the
 * specified renderer./*from   ww w .j av a  2s . com*/
 *
 * @param orientation  the plot orientation.
 * @param renderer     the renderer.
 *
 * @return A bar chart.
 */
private static JFreeChart createBarChart3D(PlotOrientation orientation, BarRenderer renderer) {
    GCategoryPlot plot = new GCategoryPlot();
    plot.setOrientation(orientation);
    if (orientation.equals(PlotOrientation.HORIZONTAL)) {
        plot.setColumnRenderingOrder(SortOrder.DESCENDING);
    }
    JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false);

    chart.setBackgroundPaint(Color.white);
    plot.setBackgroundPaint(null);
    plot.setRenderer(renderer);
    renderer.setBasePaint(new Color(0xFFCC33));
    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setBasePaint(new Color(0xFFCC33));
    renderer.setAutoPopulateSeriesPaint(false);
    renderer.setItemLabelsVisible(true);
    renderer.setItemLabelGenerator(new GCategoryPlot.LabelGenerator());
    renderer.setItemLabelPaint(new Color(0x333435));

    if (orientation == PlotOrientation.HORIZONTAL) {
        renderer.setPositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT));
        renderer.setPositiveItemLabelPositionFallback(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_RIGHT));
    } else {
        renderer.setPositiveItemLabelPosition(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER));
        renderer.setPositiveItemLabelPositionFallback(
                new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.TOP_CENTER));
    }

    GCategoryAxis3D xAxis = new GCategoryAxis3D();
    xAxis.setAxisLineVisible(true);
    xAxis.setTickLabelsVisible(false);
    xAxis.setMaximumCategoryLabelLines(5);
    plot.setDomainAxis(xAxis);
    GValueAxis3D yAxis = new GValueAxis3D();
    yAxis.setAxisLineVisible(true);
    yAxis.setTickLabelsVisible(false);
    yAxis.setTickMarksVisible(false);
    plot.setRangeAxis(yAxis);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);
    return chart;
}

From source file:edu.dlnu.liuwenpeng.ChartFactory.ChartFactory.java

/**    
* Creates a bar chart.  The chart object returned by this method uses a     
* {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis}     
* for the domain axis, a {@link NumberAxis} as the range axis, and a     
* {@link BarRenderer} as the renderer.    
*    //from  w  ww. j  a v  a2 s  .c  om
* @param title  the chart title (<code>null</code> permitted).    
* @param categoryAxisLabel  the label for the category axis     
*                           (<code>null</code> permitted).    
* @param valueAxisLabel  the label for the value axis     
*                        (<code>null</code> permitted).    
* @param dataset  the dataset for the chart (<code>null</code> permitted).    
* @param orientation  the plot orientation (horizontal or vertical)     
*                     (<code>null</code> not permitted).    
* @param legend  a flag specifying whether or not a legend is required.    
* @param tooltips  configure chart to generate tool tips?    
* @param urls  configure chart to generate URLs?    
*    
* @return A bar chart.    
*/
public static JFreeChart createBarChart(String title, String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }
    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis(valueAxisLabel);

    BarRenderer renderer = new BarRenderer();
    if (orientation == PlotOrientation.HORIZONTAL) {
        ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT);
        renderer.setBasePositiveItemLabelPosition(position1);
        ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER_RIGHT);
        renderer.setBaseNegativeItemLabelPosition(position2);
    } else if (orientation == PlotOrientation.VERTICAL) {
        ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
                TextAnchor.BOTTOM_CENTER);
        renderer.setBasePositiveItemLabelPosition(position1);
        ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER);
        renderer.setBaseNegativeItemLabelPosition(position2);
    }
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
    plot.setOrientation(orientation);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);

    return chart;

}

From source file:com.jtstand.swing.StatsPanel.java

public JFreeChart getChartDistribution(boolean horizontal) {
    //        System.out.println("Min: " + minValue());
    //        System.out.println("Max: " + maxValue());
    XYIntervalSeriesCollection datasetDistribution = createIntervalXYDatasetDistribution(horizontal);
    XYSeriesCollection dataset2 = createXYDatasetGauss(horizontal);
    // create the chart...
    NumberAxis xAxis = new NumberAxis(getValueString());
    xAxis.setAutoRangeIncludesZero(false);
    //        NumberAxis yAxis = new NumberAxis("Distribution");
    NumberAxis yAxis = new NumberAxis();
    yAxis.setAutoRangeIncludesZero(true);
    //XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer = new MyBarRenderer();
    XYPlot plot = new XYPlot(datasetDistribution, xAxis, yAxis, renderer);
    plot.setOrientation(horizontal ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL);
    renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, isGrouping());
    chart.setBackgroundPaint((Paint) UIManager.get("Panel.background"));
    //        plot.setBackgroundPaint(Color.white);
    plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    StandardXYItemLabelGenerator itemlabels = new StandardXYItemLabelGenerator();
    renderer.setBaseItemLabelGenerator(itemlabels);
    renderer.setBaseItemLabelsVisible(true);
    plot.setDataset(1, dataset2);//from  ww  w .j a v a 2  s  .c  om
    plot.mapDatasetToRangeAxis(1, 1);
    //        ValueAxis domainAxis = plot.getDomainAxis();
    //domainAxis.setCategoryLabelPositions(horizontal?CategoryLabelPositions.STANDARD:CategoryLabelPositions.UP_90);
    ValueAxis axis2 = new NumberAxis("Gaussian");
    plot.setRangeAxis(1, axis2);
    axis2.setVisible(false);
    final XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer();
    //renderer2.setShapesVisible(false);
    //renderer2.setSeriesVisibleInLegend(false);
    renderer2.setBaseSeriesVisibleInLegend(false);
    //renderer2.setToolTipGenerator(new StandardCategoryToolTipGenerator());
    plot.setRenderer(1, renderer2);
    renderer.setUseYInterval(true);
    renderer.setBaseSeriesVisibleInLegend(false);
    /* coloring */
    Color c;
    if (isMultipleCategorization()) {
        //            TreeMap<String, Color> cmap = new TreeMap<String, Color>();
        int i = 0;
        for (Iterator<String> it = catstats.keySet().iterator(); it.hasNext(); i++) {
            String groupName = it.next();
            c = ChartCategories.getColor(i);
            for (int j = 0; j < datasetDistribution.getSeriesCount(); j++) {
                XYIntervalSeries s = datasetDistribution.getSeries(j);
                if (s.getKey().equals(groupName)) {
                    GradientPaint gp = new GradientPaint(0.0f, 0.0f, c, 0.0f, 0.0f, c.darker().darker());
                    renderer.setSeriesPaint(j, gp);
                }
            }
            for (int j = 0; j < dataset2.getSeriesCount(); j++) {
                XYSeries s = dataset2.getSeries(j);
                if (s.getKey().equals(groupName)) {
                    renderer2.setSeriesPaint(j, c);
                    renderer2.setSeriesShapesVisible(j, false);
                    renderer2.setSeriesStroke(j, myStroke);
                }
            }
        }
        c = Color.black;
    } else {
        c = ChartCategories.getColor(0);
        GradientPaint gp = new GradientPaint(0.0f, 0.0f, c, 0.0f, 0.0f, c.darker().darker());
        renderer.setSeriesPaint(0, gp);
    }
    renderer2.setSeriesPaint(0, c);
    renderer2.setSeriesShapesVisible(0, false);
    renderer2.setSeriesStroke(0, myStroke);

    placeLimitMarkers(plot, false);
    //        renderer.setAutoPopulateSeriesOutlinePaint(true);
    //        renderer.setBaseOutlinePaint(Color.black);
    //        renderer.setSeriesOutlinePaint(0, Color.black, true);
    //        renderer.setDrawBarOutline(true);

    renderer.setHighlightedItem(0, 0);
    yAxis.setAutoRange(false);
    yAxis.setAutoRange(true);
    xAxis.setRange(leftValue(0), rightValue(numberOfCategories - 1));
    chart.setTextAntiAlias(false);
    return chart;
}

From source file:KIDLYFactory.java

/**
 * Creates a bar chart.  The chart object returned by this method uses a
 * {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis}
 * for the domain axis, a {@link NumberAxis} as the range axis, and a
 * {@link BarRenderer} as the renderer.//from w w  w  . j  a  va2s  .  c om
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  the label for the category axis
 *                           (<code>null</code> permitted).
 * @param valueAxisLabel  the label for the value axis
 *                        (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the plot orientation (horizontal or vertical)
 *                     (<code>null</code> not permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A bar chart.
 */
public static JFreeChart createBarChart(String title, String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }
    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis(valueAxisLabel);

    KIDLYRenderer renderer = new KIDLYRenderer();
    if (orientation == PlotOrientation.HORIZONTAL) {
        ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT);
        renderer.setBasePositiveItemLabelPosition(position1);
        ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER_RIGHT);
        renderer.setBaseNegativeItemLabelPosition(position2);
    } else if (orientation == PlotOrientation.VERTICAL) {
        ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
                TextAnchor.BOTTOM_CENTER);
        renderer.setBasePositiveItemLabelPosition(position1);
        ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER);
        renderer.setBaseNegativeItemLabelPosition(position2);
    }
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
    plot.setOrientation(orientation);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    currentTheme.apply(chart);
    return chart;

}

From source file:edu.dlnu.liuwenpeng.ChartFactory.ChartFactory.java

/**    
* Creates a stacked bar chart with default settings.  The chart object     
* returned by this method uses a {@link CategoryPlot} instance as the    
* plot, with a {@link CategoryAxis} for the domain axis, a     
* {@link NumberAxis} as the range axis, and a {@link StackedBarRenderer}     
* as the renderer.    // ww  w .j  a  v  a 2s .c o  m
*    
* @param title  the chart title (<code>null</code> permitted).    
* @param domainAxisLabel  the label for the category axis     
*                         (<code>null</code> permitted).    
* @param rangeAxisLabel  the label for the value axis     
*                        (<code>null</code> permitted).    
* @param dataset  the dataset for the chart (<code>null</code> permitted).    
* @param orientation  the orientation of the chart (horizontal or     
*                     vertical) (<code>null</code> not permitted).    
* @param legend  a flag specifying whether or not a legend is required.    
* @param tooltips  configure chart to generate tool tips?    
* @param urls  configure chart to generate URLs?    
*    
* @return A stacked bar chart.    
*/
public static JFreeChart createStackedBarChart(String title, String domainAxisLabel, String rangeAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }

    CategoryAxis categoryAxis = new CategoryAxis(domainAxisLabel);
    ValueAxis valueAxis = new NumberAxis(rangeAxisLabel);

    StackedBarRenderer renderer = new StackedBarRenderer();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
    plot.setOrientation(orientation);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);

    return chart;

}

From source file:KIDLYFactory.java

/**
 * Creates a stacked bar chart with default settings.  The chart object
 * returned by this method uses a {@link CategoryPlot} instance as the
 * plot, with a {@link CategoryAxis} for the domain axis, a
 * {@link NumberAxis} as the range axis, and a {@link StackedBarRenderer}
 * as the renderer./*  w w  w  .  j ava  2 s . com*/
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param domainAxisLabel  the label for the category axis
 *                         (<code>null</code> permitted).
 * @param rangeAxisLabel  the label for the value axis
 *                        (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the orientation of the chart (horizontal or
 *                     vertical) (<code>null</code> not permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A stacked bar chart.
 */
public static JFreeChart createStackedBarChart(String title, String domainAxisLabel, String rangeAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }

    CategoryAxis categoryAxis = new CategoryAxis(domainAxisLabel);
    ValueAxis valueAxis = new NumberAxis(rangeAxisLabel);

    StackedBarRenderer renderer = new StackedBarRenderer();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
    plot.setOrientation(orientation);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    currentTheme.apply(chart);
    return chart;

}

From source file:org.pentaho.platform.uifoundation.chart.JFreeChartEngine.java

private static JFreeChart createLineChart(final CategoryDatasetChartDefinition chartDefinition) {
    // TODO Make the following accessible from the chartDefinition
    String categoryAxisLabel = null;
    String valueAxisLabel = null;
    boolean tooltips = true;
    boolean urls = true;
    // -----------------------------------------------------------

    String title = chartDefinition.getTitle();
    boolean legend = chartDefinition.isLegendIncluded();

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
    LineAndShapeRenderer renderer = chartDefinition.isThreeD() ? new LineRenderer3D()
            : new LineAndShapeRenderer(true, false);
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    }/*from  w w w  . j  ava2s .co m*/
    if (urls) {
        renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
    }

    renderer.setStroke(JFreeChartEngine.getLineStyleStroke(chartDefinition.getLineStyle(),
            chartDefinition.getLineWidth()));
    renderer.setShapesVisible(chartDefinition.isMarkersVisible());
    renderer.setBaseShapesFilled(chartDefinition.isMarkersVisible());

    CategoryPlot plot = new CategoryPlot(chartDefinition, categoryAxis, valueAxis, renderer);
    JFreeChartEngine.updatePlot(plot, chartDefinition);

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);

    return chart;

}

From source file:edu.dlnu.liuwenpeng.ChartFactory.ChartFactory.java

/**    
* Creates a bar chart with a 3D effect. The chart object returned by this     
* method uses a {@link CategoryPlot} instance as the plot, with a     
* {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as     
* the range axis, and a {@link BarRenderer3D} as the renderer.    
*    // w  w w . j  a v a2 s.  c o  m
* @param title  the chart title (<code>null</code> permitted).    
* @param categoryAxisLabel  the label for the category axis     
*                           (<code>null</code> permitted).    
* @param valueAxisLabel  the label for the value axis (<code>null</code>     
*                        permitted).    
* @param dataset  the dataset for the chart (<code>null</code> permitted).    
* @param orientation  the plot orientation (horizontal or vertical)     
*                     (<code>null</code> not permitted).    
* @param legend  a flag specifying whether or not a legend is required.    
* @param tooltips  configure chart to generate tool tips?    
* @param urls  configure chart to generate URLs?    
*    
* @return A bar chart with a 3D effect.    
*/
public static JFreeChart createBarChart3D(String title, String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }
    CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);

    BarRenderer3D renderer = new BarRenderer3D();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
    plot.setOrientation(orientation);
    if (orientation == PlotOrientation.HORIZONTAL) {
        // change rendering order to ensure that bar overlapping is the     
        // right way around    
        plot.setRowRenderingOrder(SortOrder.DESCENDING);
        plot.setColumnRenderingOrder(SortOrder.DESCENDING);
    }
    plot.setForegroundAlpha(0.75f);

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);

    return chart;

}

From source file:KIDLYFactory.java

/**
 * Creates a bar chart with a 3D effect. The chart object returned by this
 * method uses a {@link CategoryPlot} instance as the plot, with a
 * {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as
 * the range axis, and a {@link BarRenderer3D} as the renderer.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param categoryAxisLabel  the label for the category axis
 *                           (<code>null</code> permitted).
 * @param valueAxisLabel  the label for the value axis (<code>null</code>
 *                        permitted).//  w ww  .  j a v  a 2 s.  co m
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param orientation  the plot orientation (horizontal or vertical)
 *                     (<code>null</code> not permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param urls  configure chart to generate URLs?
 *
 * @return A bar chart with a 3D effect.
 */
public static JFreeChart createBarChart3D(String title, String categoryAxisLabel, String valueAxisLabel,
        CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }
    CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);

    BarRenderer3D renderer = new BarRenderer3D();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
    plot.setOrientation(orientation);
    if (orientation == PlotOrientation.HORIZONTAL) {
        // change rendering order to ensure that bar overlapping is the
        // right way around
        plot.setRowRenderingOrder(SortOrder.DESCENDING);
        plot.setColumnRenderingOrder(SortOrder.DESCENDING);
    }
    plot.setForegroundAlpha(0.75f);

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    currentTheme.apply(chart);
    return chart;

}

From source file:org.pentaho.platform.uifoundation.chart.JFreeChartEngine.java

private static JFreeChart createBarChart(final CategoryDatasetChartDefinition chartDefinition) {
    // TODO Make the following accessible from the chartDefinition
    String categoryAxisLabel = null;
    String valueAxisLabel = null;
    boolean tooltips = true;
    boolean urls = true;
    // -----------------------------------------------------------

    String title = chartDefinition.getTitle();
    boolean legend = chartDefinition.isLegendIncluded();
    PlotOrientation orientation = chartDefinition.getOrientation();

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis(valueAxisLabel);
    BarRenderer renderer = null;//from w ww  .ja v a2 s  .c  o m
    // Determine the type of renderer to use
    if (chartDefinition.isStacked() || chartDefinition.isThreeD()) {
        if (chartDefinition.isStacked() && chartDefinition.isThreeD()) {
            renderer = new StackedBarRenderer3D();
        } else if (chartDefinition.isStacked()) {
            renderer = new StackedBarRenderer();
        } else {
            renderer = new BarRenderer3D();
        }
    } else {
        renderer = new BarRenderer();
    }
    if (orientation == PlotOrientation.HORIZONTAL) {
        ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT);
        renderer.setPositiveItemLabelPosition(position1);
        ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER_RIGHT);
        renderer.setNegativeItemLabelPosition(position2);
    } else if (orientation == PlotOrientation.VERTICAL) {
        ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
                TextAnchor.BOTTOM_CENTER);
        renderer.setPositiveItemLabelPosition(position1);
        ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER);
        renderer.setNegativeItemLabelPosition(position2);
    }
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    }
    if (urls) {
        renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
    }

    if (chartDefinition.getMaxBarWidth() != null) {
        renderer.setMaximumBarWidth(chartDefinition.getMaxBarWidth().doubleValue());
    }

    CategoryPlot plot = new CategoryPlot(chartDefinition, categoryAxis, valueAxis, renderer);
    JFreeChartEngine.updatePlot(plot, chartDefinition);

    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);

    return chart;

}