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:KIDLYFactory.java

/**
 * Creates a pie chart with default settings.
 * <P>//from w w w .  j  a v  a 2s  .c  o m
 * The chart object returned by this method uses a {@link PiePlot} instance
 * as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param legend  a flag specifying whether or not a legend is required.
 * @param tooltips  configure chart to generate tool tips?
 * @param locale  the locale (<code>null</code> not permitted).
 *
 * @return A pie chart.
 *
 * @since 1.0.7
 */
public static JFreeChart createPieChart(String title, PieDataset dataset, boolean legend, boolean tooltips,
        Locale locale) {

    PiePlot plot = new PiePlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale));
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale));
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    currentTheme.apply(chart);
    return chart;

}

From source file:de.laures.cewolf.taglib.CewolfChartFactory.java

public static JFreeChart getCombinedChartInstance(String chartType, String title, String xAxisLabel,
        String yAxisLabel, List plotDefinitions, String layout)
        throws ChartValidationException, DatasetProduceException {
    final int chartTypeConst = getChartTypeConstant(chartType);
    switch (chartTypeConst) {
    case COMBINED_XY:
        final int layoutConst = getLayoutConstant(layout);
        Plot plot = null;//ww w.j a  va 2s .  c om
        switch (layoutConst) {
        case DOMAIN:
            ValueAxis domainAxis = new DateAxis(xAxisLabel);
            plot = new CombinedDomainXYPlot(domainAxis);
            for (int i = 0; i < plotDefinitions.size(); i++) {
                PlotDefinition pd = (PlotDefinition) plotDefinitions.get(i);
                check((Dataset) pd.getDataset(), XYDataset.class, chartType);
                XYPlot temp = (XYPlot) pd.getPlot(chartTypeConst);
                temp.setRangeAxis(new NumberAxis(pd.getYaxislabel()));
                ((CombinedDomainXYPlot) plot).add(temp);
            }
            return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
        case RANGE:
            ValueAxis rangeAxis = new NumberAxis(yAxisLabel);
            plot = new CombinedRangeXYPlot(rangeAxis);
            for (int i = 0; i < plotDefinitions.size(); i++) {
                PlotDefinition pd = (PlotDefinition) plotDefinitions.get(i);
                check((Dataset) pd.getDataset(), XYDataset.class, chartType);
                XYPlot temp = (XYPlot) pd.getPlot(chartTypeConst);
                temp.setDomainAxis(new DateAxis(pd.getXaxislabel()));
                ((CombinedRangeXYPlot) plot).add(temp);
            }
            return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
        default:
            throw new AttributeValidationException(layout, " any value");
        }
    default:
        throw new UnsupportedChartTypeException(chartType);
    }
}

From source file:org.jfree.chart.demo.SymbolicYPlotDemo.java

/**
 * Displays a vertically combined symbolic plot.
 * //from ww w .j  a  v  a 2s . c o m
 * @param frameTitle
 *           the frame title.
 * @param data1
 *           dataset 1.
 * @param data2
 *           dataset 2.
 */
private static void displayYSymbolicCombinedVertically(final String frameTitle,
        final SampleYSymbolicDataset data1, final SampleYSymbolicDataset data2) {

    final String title = "Animals Vertically Combined";
    final String xAxisLabel = "Miles";
    final String yAxisLabel = null;

    // create master dataset...
    final CombinedDataset data = new CombinedDataset();
    data.add(data1);
    data.add(data2);

    // decompose data...
    final XYDataset series0 = new SubSeriesDataset(data, 0);
    final XYDataset series1 = new SubSeriesDataset(data, 1);
    final XYDataset series2 = new SubSeriesDataset(data, 2);
    final XYDataset series3 = new SubSeriesDataset(data, 3);
    final XYDataset series4 = new SubSeriesDataset(data, 4);
    final XYDataset series5 = new SubSeriesDataset(data, 5);
    final XYDataset series6 = new SubSeriesDataset(data, 6);
    final XYDataset series7 = new SubSeriesDataset(data, 7);

    // common horizontal and vertical axes
    final ValueAxis valueAxis = new NumberAxis(xAxisLabel);
    final SymbolicAxis symbolicAxis1 = new SymbolicAxis(yAxisLabel, ((YisSymbolic) data1).getYSymbolicValues());
    final SymbolicAxis symbolicAxis2 = new SymbolicAxis(yAxisLabel, ((YisSymbolic) data2).getYSymbolicValues());

    // create the main plot...
    final CombinedDomainXYPlot mainPlot = new CombinedDomainXYPlot(valueAxis);

    // and the sub-plots...
    final XYItemRenderer renderer0 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null);
    final XYPlot subplot0 = new XYPlot(series0, null, symbolicAxis1, renderer0);
    final XYItemRenderer renderer1 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null);
    final XYPlot subplot1 = new XYPlot(series1, null, symbolicAxis1, renderer1);
    final XYItemRenderer renderer2 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null);
    final XYPlot subplot2 = new XYPlot(series2, null, symbolicAxis1, renderer2);
    final XYItemRenderer renderer3 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null);
    final XYPlot subplot3 = new XYPlot(series3, null, symbolicAxis1, renderer3);
    final XYItemRenderer renderer4 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null);
    final XYPlot subplot4 = new XYPlot(series4, null, symbolicAxis2, renderer4);
    final XYItemRenderer renderer5 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null);
    final XYPlot subplot5 = new XYPlot(series5, null, symbolicAxis2, renderer5);
    final XYItemRenderer renderer6 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null);
    final XYPlot subplot6 = new XYPlot(series6, null, symbolicAxis2, renderer6);
    final XYItemRenderer renderer7 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null);
    final XYPlot subplot7 = new XYPlot(series7, null, symbolicAxis2, renderer7);

    // add the subplots to the main plot...
    mainPlot.add(subplot0, 1);
    mainPlot.add(subplot1, 1);
    mainPlot.add(subplot2, 1);
    mainPlot.add(subplot3, 1);
    mainPlot.add(subplot4, 1);
    mainPlot.add(subplot5, 1);
    mainPlot.add(subplot6, 1);
    mainPlot.add(subplot7, 1);

    // construct the chart...
    final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, mainPlot, true);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));

    // and present it in a frame...
    final JFrame frame = new ChartFrame(frameTitle, chart);
    frame.pack();
    RefineryUtilities.positionFrameRandomly(frame);
    frame.show();

}

From source file:org.gumtree.vis.plot1d.Plot1D.java

/**
 * Creates a line chart (based on an {@link XYDataset}) with default
 * settings.//from   ww w .  ja va  2s  .c om
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param xAxisLabel  a label for the X-axis (<code>null</code> permitted).
 * @param yAxisLabel  a label for the Y-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 The chart.
 */
public static JFreeChart createXYLineChart(String title, String xAxisLabel, String yAxisLabel,
        XYDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }
    //        NumberAxis xAxis = new NumberAxis(xAxisLabel);
    LogarithmizableAxis xAxis = new LogarithmizableAxis(xAxisLabel);

    xAxis.setLogarithmic(false);
    xAxis.setAutoRangeIncludesZero(false);
    xAxis.setAllowNegativesFlag(true);
    xAxis.setLowerMargin(0.02);
    xAxis.setUpperMargin(0.02);
    //        NumberAxis yAxis = new NumberAxis(yAxisLabel);
    LogarithmizableAxis yAxis = new LogarithmizableAxis(yAxisLabel);
    yAxis.setAllowNegativesFlag(true);
    yAxis.setAutoRangeNextLogFlag(false);
    yAxis.setLowerMargin(0.02);
    yAxis.setUpperMargin(0.02);
    yAxis.setLogarithmic(false);
    XYErrorRenderer renderer = new XYErrorRenderer();
    renderer.setBaseLinesVisible(true);
    renderer.setBaseShapesVisible(false);
    renderer.setDrawYError(true);
    //        XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false);
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(orientation);
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }

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

}

From source file:org.hxzon.demo.jfreechart.CategoryDatasetDemo2.java

private static JFreeChart createStackedBarChart3D(CategoryDataset dataset) {

    CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel);
    ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel);

    CategoryItemRenderer renderer = new StackedBarRenderer3D();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    }//www  .  ja v a 2s. c  om
    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.setColumnRenderingOrder(SortOrder.DESCENDING);
    }

    // create the chart...
    JFreeChart chart = new JFreeChart("StackedBar Chart 3D Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot,
            legend);
    chart.setBackgroundPaint(Color.white);

    valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64));
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0));
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0));
    renderer.setSeriesPaint(0, gp0);
    renderer.setSeriesPaint(1, gp1);
    renderer.setSeriesPaint(2, gp2);

    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    return chart;

}

From source file:charts.Chart.java

public static void ScatterPlot(XYSeriesCollection dataset, String title, String xAxisLabel, String yAxisLabel) {
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setAutoRangeIncludesZero(false);
    XYToolTipGenerator toolTipGenerator = new StandardXYToolTipGenerator();
    XYURLGenerator urlGenerator = new StandardXYURLGenerator();
    XYItemRenderer renderer = new XYLineAndShapeRenderer(false, true);//(boolean lines, boolean shapes)
    renderer.setBaseToolTipGenerator(toolTipGenerator);
    renderer.setURLGenerator(urlGenerator);
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    //plot.setDataset(dataset);
    //plot.setDomainAxis(xAxis);
    //plot.setRangeAxis(yAxis);
    //plot.setRenderer(renderer);
    plot.setOrientation(PlotOrientation.VERTICAL);
    plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
    plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);//true==legend
    //INVERTER AS CORES DOS PONTOS E LEGENDA.
    if (dataset.getSeriesCount() > 1) {
        Shape s0 = plot.getLegendItems().get(0).getShape();
        Shape s1 = plot.getLegendItems().get(1).getShape();
        renderer.setSeriesShape(0, s1);/*  w  ww  .j  a va2  s .  co  m*/
        renderer.setSeriesShape(1, s0);
        Paint p0 = plot.getLegendItems().get(0).getLinePaint();
        Paint p1 = plot.getLegendItems().get(1).getLinePaint();
        renderer.setSeriesPaint(0, p1);
        renderer.setSeriesPaint(1, p0);
    }
    //FIM DA INVERSAO.

    JFrame chartwindow = new JFrame(title);
    JPanel jpanel = new ChartPanel(chart);
    jpanel.setPreferredSize(new Dimension(defaultwidth, defaultheight));
    chartwindow.setContentPane(jpanel);
    chartwindow.pack();
    RefineryUtilities.centerFrameOnScreen(chartwindow);
    chartwindow.setVisible(true);
}

From source file:org.optaplanner.benchmark.impl.report.BenchmarkReport.java

private void writeWinningScoreDifferenceSummaryChart() {
    // Each scoreLevel has it's own dataset and chartFile
    List<DefaultCategoryDataset> datasetList = new ArrayList<DefaultCategoryDataset>(CHARTED_SCORE_LEVEL_SIZE);
    for (SolverBenchmarkResult solverBenchmarkResult : plannerBenchmarkResult.getSolverBenchmarkResultList()) {
        String solverLabel = solverBenchmarkResult.getNameWithFavoriteSuffix();
        for (SingleBenchmarkResult singleBenchmarkResult : solverBenchmarkResult
                .getSingleBenchmarkResultList()) {
            String planningProblemLabel = singleBenchmarkResult.getProblemBenchmarkResult().getName();
            if (singleBenchmarkResult.isSuccess()) {
                double[] levelValues = ScoreUtils
                        .extractLevelDoubles(singleBenchmarkResult.getWinningScoreDifference());
                for (int i = 0; i < levelValues.length && i < CHARTED_SCORE_LEVEL_SIZE; i++) {
                    if (i >= datasetList.size()) {
                        datasetList.add(new DefaultCategoryDataset());
                    }/*ww w.ja  v  a2  s.co m*/
                    datasetList.get(i).addValue(levelValues[i], solverLabel, planningProblemLabel);
                }
            }
        }
    }
    winningScoreDifferenceSummaryChartFileList = new ArrayList<File>(datasetList.size());
    int scoreLevelIndex = 0;
    for (DefaultCategoryDataset dataset : datasetList) {
        CategoryPlot plot = createBarChartPlot(dataset, "Winning score difference level " + scoreLevelIndex,
                NumberFormat.getInstance(locale));
        JFreeChart chart = new JFreeChart(
                "Winning score difference level " + scoreLevelIndex + " summary (higher is better)",
                JFreeChart.DEFAULT_TITLE_FONT, plot, true);
        winningScoreDifferenceSummaryChartFileList
                .add(writeChartToImageFile(chart, "winningScoreDifferenceSummaryLevel" + scoreLevelIndex));
        scoreLevelIndex++;
    }
}

From source file:org.drools.planner.benchmark.core.report.BenchmarkReport.java

private void writeWorstScoreDifferencePercentageSummaryChart() {
    // Each scoreLevel has it's own dataset and chartFile
    List<DefaultCategoryDataset> datasetList = new ArrayList<DefaultCategoryDataset>(CHARTED_SCORE_LEVEL_SIZE);
    for (SolverBenchmark solverBenchmark : plannerBenchmark.getSolverBenchmarkList()) {
        String solverLabel = solverBenchmark.getNameWithFavoriteSuffix();
        for (SingleBenchmark singleBenchmark : solverBenchmark.getSingleBenchmarkList()) {
            String planningProblemLabel = singleBenchmark.getProblemBenchmark().getName();
            if (singleBenchmark.isSuccess()) {
                double[] levelValues = singleBenchmark.getWorstScoreDifferencePercentage()
                        .getPercentageLevels();
                for (int i = 0; i < levelValues.length && i < CHARTED_SCORE_LEVEL_SIZE; i++) {
                    if (i >= datasetList.size()) {
                        datasetList.add(new DefaultCategoryDataset());
                    }/* ww w.ja va2 s. c om*/
                    datasetList.get(i).addValue(levelValues[i], solverLabel, planningProblemLabel);
                }
            }
        }
    }
    worstScoreDifferencePercentageSummaryChartFileList = new ArrayList<File>(datasetList.size());
    int scoreLevelIndex = 0;
    for (DefaultCategoryDataset dataset : datasetList) {
        CategoryPlot plot = createBarChartPlot(dataset,
                "Worst score difference percentage level " + scoreLevelIndex,
                NumberFormat.getPercentInstance(locale));
        JFreeChart chart = new JFreeChart(
                "Worst score difference percentage level " + scoreLevelIndex + " summary (higher is better)",
                JFreeChart.DEFAULT_TITLE_FONT, plot, true);
        worstScoreDifferencePercentageSummaryChartFileList.add(
                writeChartToImageFile(chart, "worstScoreDifferencePercentageSummaryLevel" + scoreLevelIndex));
        scoreLevelIndex++;
    }
}

From source file:org.hxzon.demo.jfreechart.XYDatasetDemo2.java

private static JFreeChart createXYStepAreaChart(XYDataset dataset) {

    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);

    XYToolTipGenerator toolTipGenerator = null;
    if (tooltips) {
        toolTipGenerator = new StandardXYToolTipGenerator();
    }//  w w  w . j a va2  s.  co m

    XYURLGenerator urlGenerator = null;
    if (urls) {
        urlGenerator = new StandardXYURLGenerator();
    }
    XYItemRenderer renderer = new XYStepAreaRenderer(XYStepAreaRenderer.AREA_AND_SHAPES, toolTipGenerator,
            urlGenerator);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null);
    plot.setRenderer(renderer);
    plot.setOrientation(orientation);
    plot.setDomainCrosshairVisible(false);
    plot.setRangeCrosshairVisible(false);
    JFreeChart chart = new JFreeChart("XYStepArea Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    chart.setBackgroundPaint(Color.white);

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    yAxis.setNumberFormatOverride(MyNumberFormat.getMyNumberFormat());

    return chart;
}

From source file:KIDLYFactory.java

/**
 * Creates a pie chart with default settings.
 * <P>/*from   ww w.  ja v  a 2  s .  c o  m*/
 * The chart object returned by this method uses a {@link PiePlot} instance
 * as the plot.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> 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 pie chart.
 */
public static JFreeChart createPieChart(String title, PieDataset dataset, boolean legend, boolean tooltips,
        boolean urls) {

    PiePlot plot = new PiePlot(dataset);
    plot.setLabelGenerator(new StandardPieSectionLabelGenerator());
    plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0));
    if (tooltips) {
        plot.setToolTipGenerator(new StandardPieToolTipGenerator());
    }
    if (urls) {
        plot.setURLGenerator(new StandardPieURLGenerator());
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    currentTheme.apply(chart);
    return chart;
}