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.optaplanner.benchmark.impl.report.BenchmarkReport.java

private void writeTimeSpentScalabilitySummaryChart() {
    List<XYSeries> seriesList = new ArrayList<XYSeries>(
            plannerBenchmarkResult.getSolverBenchmarkResultList().size());
    for (SolverBenchmarkResult solverBenchmarkResult : plannerBenchmarkResult.getSolverBenchmarkResultList()) {
        String solverLabel = solverBenchmarkResult.getNameWithFavoriteSuffix();
        XYSeries series = new XYSeries(solverLabel);
        for (SingleBenchmarkResult singleBenchmarkResult : solverBenchmarkResult
                .getSingleBenchmarkResultList()) {
            if (singleBenchmarkResult.isSuccess()) {
                long problemScale = singleBenchmarkResult.getProblemBenchmarkResult().getProblemScale();
                long timeMillisSpent = singleBenchmarkResult.getTimeMillisSpent();
                series.add((Long) problemScale, (Long) timeMillisSpent);
            }/*from w  w  w.ja v a2 s .c o  m*/
        }
        seriesList.add(series);
    }
    XYPlot plot = createScalabilityPlot(seriesList, "Problem scale", NumberFormat.getInstance(locale),
            "Time spent", new MillisecondsSpentNumberFormat(locale));
    JFreeChart chart = new JFreeChart("Time spent scalability summary (lower is better)",
            JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    timeSpentScalabilitySummaryChartFile = writeChartToImageFile(chart, "timeSpentScalabilitySummary");
}

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

private static JFreeChart createGanttChart(CategoryDataset dataset) {

    CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel);
    DateAxis dateAxis = new DateAxis(valueAxisLabel);

    CategoryItemRenderer renderer = new GanttRenderer();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(
                new IntervalCategoryToolTipGenerator("{3} - {4}", DateFormat.getDateInstance()));
    }/*from   ww w.ja  va2s .c o m*/
    if (urls) {
        renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator());
    }

    CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, dateAxis, renderer);
    plot.setOrientation(PlotOrientation.HORIZONTAL);
    JFreeChart chart = new JFreeChart("Gantt Chart Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    chart.setBackgroundPaint(Color.white);

    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:org.hxzon.demo.jfreechart.OtherDatasetDemo.java

private static JFreeChart createWaferMapChart(WaferMapDataset dataset) {
    WaferMapPlot plot = new WaferMapPlot(dataset);
    WaferMapRenderer renderer = new WaferMapRenderer();
    plot.setRenderer(renderer);/*from  w  w  w.ja v a2s .  c o  m*/

    JFreeChart chart = new JFreeChart("WaferMap Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    chart.setBackgroundPaint(Color.white);

    plot.setBackgroundPaint(Color.lightGray);

    return chart;
}

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

/**
 * Render the rose plots for given datasets.
 *
 * @param datasets/*from  ww w  .j ava  2  s . c  om*/
 */
private void renderRosePlots(List<XYSeriesCollection> datasets) {
    rosePlotChartPanels.clear();
    turningAnglePanel.getRosePlotParentPanel().removeAll();
    for (int i = 0; i < datasets.size(); i++) {
        XYSeriesCollection dataset = datasets.get(i);
        // create a new polar plot with this dataset, and set the custom renderer
        PolarPlot rosePlot = new PolarPlot(dataset, new NumberAxis(), new AngularHistogramRenderer(i, 5));
        // create a new chart with this plot
        JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, rosePlot, false);
        JFreeChartUtils.setupPolarChart(chart, i);
        ChartPanel rosePlotChartPanel = new ChartPanel(chart);
        rosePlotChartPanels.add(rosePlotChartPanel);
        // compute the constraints
        GridBagConstraints tempConstraints = getGridBagConstraints(datasets.size(), i);
        turningAnglePanel.getRosePlotParentPanel().add(rosePlotChartPanel, tempConstraints);
        turningAnglePanel.getRosePlotParentPanel().revalidate();
        turningAnglePanel.getRosePlotParentPanel().repaint();
    }
}

From source file:bicat.gui.GraphicPane.java

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.");
    }/*from  ww w .  ja va  2  s.com*/
    NumberAxis xAxis = new NumberAxis(xAxisLabel);
    xAxis.setAutoRangeIncludesZero(false);
    NumberAxis yAxis = new NumberAxis(yAxisLabel);
    yAxis.setAutoRangeIncludesZero(false);
    XYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.LINES);

    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    for (int i = 0; i < marker.length; i++) {
        ValueMarker vm = new ValueMarker(marker[i]);
        vm.setPaint(Color.GRAY.brighter());
        // 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:org.hxzon.demo.jfreechart.OtherDatasetDemo.java

private static JFreeChart createWindChart(WindDataset dataset) {
    ValueAxis xAxis = new DateAxis(xAxisLabel);
    ValueAxis yAxis = new NumberAxis("Direction / Force");
    yAxis.setRange(-12.0, 12.0);/*from w ww .  j  a  va  2s  . co  m*/

    WindItemRenderer renderer = new WindItemRenderer();
    if (tooltips) {
        renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator());
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }
    XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer);
    JFreeChart chart = new JFreeChart("Wind 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);

    return chart;
}

From source file:com.xpn.xwiki.plugin.charts.ChartCustomizer.java

public static void customizeTitle(TextTitle title, ChartParams params, String prefix) {
    if (params.get(prefix + ChartParams.TITLE_FONT_SUFFIX) != null) {
        title.setFont(params.getFont(prefix + ChartParams.TITLE_FONT_SUFFIX));
    } else {// ww  w.java2s . c  o  m
        title.setFont(JFreeChart.DEFAULT_TITLE_FONT);
    }

    if (params.get(prefix + ChartParams.TITLE_POSITION_SUFFIX) != null) {
        title.setPosition(params.getRectangleEdge(prefix + ChartParams.TITLE_POSITION_SUFFIX));
    }

    if (params.get(prefix + ChartParams.TITLE_HORIZONTAL_ALIGNMENT_SUFFIX) != null) {
        title.setHorizontalAlignment(
                params.getHorizontalAlignment(prefix + ChartParams.TITLE_HORIZONTAL_ALIGNMENT_SUFFIX));
    }

    if (params.get(prefix + ChartParams.TITLE_VERTICAL_ALIGNMENT_SUFFIX) != null) {
        title.setVerticalAlignment(
                params.getVerticalAlignment(prefix + ChartParams.TITLE_VERTICAL_ALIGNMENT_SUFFIX));
    }

    if (params.get(prefix + ChartParams.TITLE_COLOR_SUFFIX) != null) {
        title.setPaint(params.getColor(prefix + ChartParams.TITLE_COLOR_SUFFIX));
    }

    if (params.get(prefix + ChartParams.TITLE_BACKGROUND_COLOR_SUFFIX) != null) {
        title.setBackgroundPaint(params.getColor(prefix + ChartParams.TITLE_BACKGROUND_COLOR_SUFFIX));
    }

    if (params.get(prefix + ChartParams.TITLE_PADDING_SUFFIX) != null) {
        title.setPadding(params.getRectangleInsets(prefix + ChartParams.TITLE_PADDING_SUFFIX));
    }

    if (params.get(prefix + ChartParams.TITLE_URL_SUFFIX) != null) {
        title.setURLText(params.getString(prefix + ChartParams.TITLE_URL_SUFFIX));
    }
}

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

/**
 *
 * @param datasets//  w  w  w . jav a 2 s. c  o  m
 */
private void renderCompassPlots(List<XYSeriesCollection> datasets) {
    turningAnglePanel.getCompassPlotParentPanel().removeAll();
    for (int i = 0; i < datasets.size(); i++) {
        XYSeriesCollection dataset = datasets.get(i);
        // create a new polar plot with this dataset, and set the custom renderer
        PolarPlot polarPlot = new PolarPlot(dataset, new NumberAxis(), new CompassRenderer(i));
        // create a new chart with this plot
        JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, polarPlot, true);
        JFreeChartUtils.setupPolarChart(chart, i);
        ChartPanel compassChartPanel = new ChartPanel(chart);
        // compute the constraints
        GridBagConstraints tempConstraints = getGridBagConstraints(datasets.size(), i);
        turningAnglePanel.getCompassPlotParentPanel().add(compassChartPanel, tempConstraints);
        turningAnglePanel.getCompassPlotParentPanel().revalidate();
        turningAnglePanel.getCompassPlotParentPanel().repaint();
    }
}

From source file:edu.dlnu.liuwenpeng.ChartFactory.ChartFactory.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  w  w w .j  a v  a  2s .c  o m
* <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 urls  configure chart to generate URLs?    
* @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.    
*/
public static JFreeChart createPieChart(String title, PieDataset dataset, PieDataset previousDataset,
        int percentDiffForMaxScale, boolean greenForIncrease, boolean legend, boolean tooltips, boolean urls,
        boolean subTitle, boolean showDifference) {

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

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

    return chart;
}

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

private static JFreeChart createPolarChart(XYDataset dataset) {

    PolarPlot plot = new PolarPlot();
    plot.setDataset(dataset);/*from   w  ww  .ja  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);

    plot.setAngleGridlinesVisible(true);
    plot.setAngleLabelsVisible(true);
    plot.setAngleTickUnit(new NumberTickUnit(5));

    return chart;
}