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.hxzon.demo.jfreechart.XYDatasetDemo2.java

private static JFreeChart createPolarChart(XYDataset dataset) {

    PolarPlot plot = new PolarPlot();
    plot.setDataset(dataset);/* ww w.j  a  v a  2  s. c o m*/
    NumberAxis rangeAxis = new NumberAxis();
    rangeAxis.setAxisLineVisible(false);
    rangeAxis.setTickMarksVisible(false);
    rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0));
    plot.setAxis(rangeAxis);
    plot.setRenderer(new DefaultPolarItemRenderer());
    JFreeChart chart = new JFreeChart("Polar Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    chart.setBackgroundPaint(Color.white);

    plot.setBackgroundPaint(Color.lightGray);

    return chart;
}

From source file:KIDLYFactory.java

/**
 * Creates a pie chart with default settings that compares 2 datasets.
 * The colour of each section will be determined by the move from the value
 * for the same key in <code>previousDataset</code>. ie if value1 > value2
 * then the section will be in green (unless <code>greenForIncrease</code>
 * is <code>false</code>, in which case it would be <code>red</code>).
 * Each section can have a shade of red or green as the difference can be
 * tailored between 0% (black) and percentDiffForMaxScale% (bright
 * red/green)./*from   www .jav a  2  s .  c om*/
 * <p>
 * For instance if <code>percentDiffForMaxScale</code> is 10 (10%), a
 * difference of 5% will have a half shade of red/green, a difference of
 * 10% or more will have a maximum shade/brightness of red/green.
 * <P>
 * The chart object returned by this method uses a {@link PiePlot} instance
 * as the plot.
 * <p>
 * Written by <a href="mailto:opensource@objectlab.co.uk">Benoit
 * Xhenseval</a>.
 *
 * @param title  the chart title (<code>null</code> permitted).
 * @param dataset  the dataset for the chart (<code>null</code> permitted).
 * @param previousDataset  the dataset for the last run, this will be used
 *                         to compare each key in the dataset
 * @param percentDiffForMaxScale scale goes from bright red/green to black,
 *                               percentDiffForMaxScale indicate the change
 *                               required to reach top scale.
 * @param greenForIncrease  an increase since previousDataset will be
 *                          displayed in green (decrease red) if true.
 * @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).
 * @param subTitle displays a subtitle with colour scheme if true
 * @param showDifference  create a new dataset that will show the %
 *                        difference between the two datasets.
 *
 * @return A pie chart.
 *
 * @since 1.0.7
 */
public static JFreeChart createPieChart(String title, PieDataset dataset, PieDataset previousDataset,
        int percentDiffForMaxScale, boolean greenForIncrease, boolean legend, boolean tooltips, Locale locale,
        boolean subTitle, boolean showDifference) {

    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));
    }

    List keys = dataset.getKeys();
    DefaultPieDataset series = null;
    if (showDifference) {
        series = new DefaultPieDataset();
    }

    double colorPerPercent = 255.0 / percentDiffForMaxScale;
    for (Iterator it = keys.iterator(); it.hasNext();) {
        Comparable key = (Comparable) it.next();
        Number newValue = dataset.getValue(key);
        Number oldValue = previousDataset.getValue(key);

        if (oldValue == null) {
            if (greenForIncrease) {
                plot.setSectionPaint(key, Color.green);
            } else {
                plot.setSectionPaint(key, Color.red);
            }
            if (showDifference) {
                series.setValue(key + " (+100%)", newValue);
            }
        } else {
            double percentChange = (newValue.doubleValue() / oldValue.doubleValue() - 1.0) * 100.0;
            double shade = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255
                    : Math.abs(percentChange) * colorPerPercent);
            if (greenForIncrease && newValue.doubleValue() > oldValue.doubleValue()
                    || !greenForIncrease && newValue.doubleValue() < oldValue.doubleValue()) {
                plot.setSectionPaint(key, new Color(0, (int) shade, 0));
            } else {
                plot.setSectionPaint(key, new Color((int) shade, 0, 0));
            }
            if (showDifference) {
                series.setValue(
                        key + " (" + (percentChange >= 0 ? "+" : "")
                                + NumberFormat.getPercentInstance().format(percentChange / 100.0) + ")",
                        newValue);
            }
        }
    }

    if (showDifference) {
        plot.setDataset(series);
    }

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

    if (subTitle) {
        TextTitle subtitle = null;
        subtitle = new TextTitle("Bright " + (greenForIncrease ? "red" : "green") + "=change >=-"
                + percentDiffForMaxScale + "%, Bright " + (!greenForIncrease ? "red" : "green") + "=change >=+"
                + percentDiffForMaxScale + "%", new Font("SansSerif", Font.PLAIN, 10));
        chart.addSubtitle(subtitle);
    }
    currentTheme.apply(chart);
    return chart;
}

From source file:org.gridchem.client.gui.panels.myccg.resource.HPCChartPanel.java

private JFreeChart createChart(ComputeBean hpc, ChartType chartType, LoadType loadType) {

    JFreeChart chart = null;// w ww.ja  v  a 2 s  .  com
    Plot plot;
    if (chartType.equals(ChartType.SUMMARY)) {

        chart = ChartFactory.createBarChart("", // chart title
                "Resources", // domain axis label
                createTitle(loadType), // range axis label
                (CategoryDataset) ChartDataset.createDataset(hpc, chartType), // data
                PlotOrientation.VERTICAL, // orientation
                false, // include legend
                true, // tooltips?
                false // URLs?
        );

        renderBarChart(chart);

    } else if (chartType.equals(ChartType.PIE)) {

        chart = ChartFactory.createPieChart(createTitle(loadType), // chart title
                (DefaultPieDataset) ChartDataset.createDataset(hpc, chartType, loadType), // data
                false, // include legend
                true, // tooltips?
                false // URLs?
        );

    } else if (chartType.equals(ChartType.METER)) {

        plot = new MeterPlot((ValueDataset) ChartDataset.createDataset(hpc, chartType, loadType));

        chart = new JFreeChart(createTitle(loadType), JFreeChart.DEFAULT_TITLE_FONT, plot, false);

        renderMeterChart(chart, loadType, hpc);

    } else if (chartType.equals(ChartType.BAR)) {

        chart = ChartFactory.createBarChart("", // chart title
                "Resources", // domain axis label
                createTitle(loadType), // range axis label
                (CategoryDataset) ChartDataset.createDataset(hpc, chartType), // data
                PlotOrientation.VERTICAL, // orientation
                false, // include legend
                true, // tooltips?
                false // URLs?
        );

        renderBarChart(chart);

    } else if (chartType.equals(ChartType.LAYERED)) {

        plot = new CategoryPlot((CategoryDataset) ChartDataset.createDataset(hpc, chartType),
                new CategoryAxis("Resources"), new NumberAxis(createTitle(loadType)), new LayeredBarRenderer());

        ((CategoryPlot) plot).setOrientation(PlotOrientation.VERTICAL);

        chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, false);

        renderLayeredBarChart(chart);

    } else if (chartType.equals(ChartType.STACKED)) {

        chart = ChartFactory.createStackedBarChart("", // chart title
                "Resources", // domain axis label
                createTitle(loadType), // range axis label
                (CategoryDataset) ChartDataset.createDataset(hpc, chartType), // data
                PlotOrientation.VERTICAL, // orientation
                false, // include legend
                true, // tooltips?
                false // URLs?
        );

        renderStackedBarChart(chart);

    } else if (chartType.equals(ChartType.BAR)) {
        chart = ChartFactory.createBarChart("", // chart title
                "Resources", // domain axis label
                createTitle(loadType), // range axis label
                (CategoryDataset) ChartDataset.createDataset(hpc, chartType), // data
                PlotOrientation.VERTICAL, // orientation
                false, // include legend
                true, // tooltips?
                false // URLs?
        );

        renderBarChart(chart);
    }

    return chart;
}

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

private void writeTimeSpentSummaryChart() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (SolverBenchmarkResult solverBenchmarkResult : plannerBenchmarkResult.getSolverBenchmarkResultList()) {
        String solverLabel = solverBenchmarkResult.getNameWithFavoriteSuffix();
        for (SingleBenchmarkResult singleBenchmarkResult : solverBenchmarkResult
                .getSingleBenchmarkResultList()) {
            String planningProblemLabel = singleBenchmarkResult.getProblemBenchmarkResult().getName();
            if (singleBenchmarkResult.isSuccess()) {
                long timeMillisSpent = singleBenchmarkResult.getTimeMillisSpent();
                dataset.addValue(timeMillisSpent, solverLabel, planningProblemLabel);
            }/*from w  w w  . j a v a  2  s.  co m*/
        }
    }
    CategoryPlot plot = createBarChartPlot(dataset, "Time spent", new MillisecondsSpentNumberFormat(locale));
    JFreeChart chart = new JFreeChart("Time spent summary (lower time is better)",
            JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    timeSpentSummaryChartFile = writeChartToImageFile(chart, "timeSpentSummary");
}

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

private static JFreeChart createBoxAndWhiskerChart(BoxAndWhiskerCategoryDataset dataset) {
    CategoryAxis categoryAxis = new CategoryAxis(xAxisLabel);
    NumberAxis valueAxis = new NumberAxis(yAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false);

    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator());

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
    JFreeChart chart = new JFreeChart("BoxAndWhiskerCategory Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot,
            legend);/*from  w w w  . j  a v  a  2 s.co m*/
    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);

    return chart;
}

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

private static JFreeChart createStackedAreaChart(CategoryDataset dataset) {

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    categoryAxis.setCategoryMargin(0.0);
    ValueAxis valueAxis = new NumberAxis(valueAxisLabel);

    StackedAreaRenderer renderer = new StackedAreaRenderer();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    }/*from  www  .j  av a 2  s.  c o m*/
    if (urls) {
        renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer);
    plot.setOrientation(orientation);
    JFreeChart chart = new JFreeChart("StackedArea Chart Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    chart.setBackgroundPaint(Color.white);

    valueAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    //        renderer.setRenderAsPercentages(true);

    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:tools.descartes.bungee.chart.ChartGenerator.java

public static JFreeChart createTimeSeriesChart(final List<XYPlot> plots) {
    final CombinedDomainXYPlot plot = createRelativeTimeSeriesPlot();
    plot.setGap(20);/*from  ww w . j a  v  a  2 s  .  c  o  m*/
    JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    boolean manyCharts = plots.size() > 3;
    int num = 0;
    for (XYPlot xyPlot : plots) {
        num++;
        if (manyCharts && xyPlot.getRangeAxis().getLabel() == "Arrival Rate [1/s]") {
            plot.add(xyPlot, 3);
        } else {
            plot.add(xyPlot, 1);
        }

        chart.setBackgroundPaint(Color.white);
        customizePlot(xyPlot);
        if (manyCharts && xyPlot.getRangeAxis().getLabel() != "Arrival Rate [1/s]" && num != 4 && num != 7) {
            xyPlot.getRangeAxis().setLabel("");
        }
    }
    return chart;
}

From source file:bicat.gui.GraphicPane.java

/**
 * Creates a line chart with//from  w w  w.j  av a 2 s.c om
 * default settings.
 *
 * @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 myCreateXYLineChart(String title, String xAxisLabel, String yAxisLabel,
        org.jfree.data.xy.XYDataset dataset, double marker, org.jfree.chart.plot.PlotOrientation orientation,
        boolean legend, boolean tooltips, boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.LINES);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    ValueMarker vm = new ValueMarker(marker);
    vm.setPaint(Color.GRAY);
    // plot.addRangeMarker(vm, Layer.FOREGROUND); //.setPaint(Color.PINK));
    plot.addDomainMarker(vm, Layer.FOREGROUND);

    plot.setOrientation(orientation);
    if (tooltips) {
        renderer.setToolTipGenerator(new StandardXYToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }

    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);

}

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.AngleDirectController.java

/**
 * Render polar plots for given datasets.
 *
 * @param datasets//ww  w. j  a va 2  s. c  om
 */
private void renderPolarPlots(List<XYSeriesCollection> datasets) {
    turningAnglePanel.getPolarPlotParentPanel().removeAll();
    for (int i = 0; i < datasets.size(); i++) {
        XYSeriesCollection dataset = datasets.get(i);
        // create a new polar plot with this dataset
        PolarPlot polarPlot = new PolarPlot(dataset, new NumberAxis(), new DefaultPolarItemRenderer());
        // create a new chart with this plot
        JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, polarPlot, true);
        JFreeChartUtils.setupPolarChart(chart, i);
        ChartPanel polarChartPanel = new ChartPanel(chart);
        // compute the constraints
        GridBagConstraints tempConstraints = getGridBagConstraints(datasets.size(), i);
        turningAnglePanel.getPolarPlotParentPanel().add(polarChartPanel, tempConstraints);
        turningAnglePanel.getPolarPlotParentPanel().revalidate();
        turningAnglePanel.getPolarPlotParentPanel().repaint();
    }
}

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

private static JFreeChart createBoxAndWhiskerChart(BoxAndWhiskerXYDataset dataset) {
    ValueAxis timeAxis = new DateAxis(xAxisLabel);
    NumberAxis valueAxis = new NumberAxis(yAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false);

    XYBoxAndWhiskerRenderer renderer = new XYBoxAndWhiskerRenderer(10.0);
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer);
    JFreeChart chart = new JFreeChart("BoxAndWhiskerXY Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot,
            legend);//from  w w w .  ja  va  2  s.co m
    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);

    return chart;
}