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.drools.planner.benchmark.statistic.BestScoreStatistic.java

private CharSequence writeGraphStatistic(File solverStatisticFilesDirectory, String baseName) {
    XYSeriesCollection seriesCollection = new XYSeriesCollection();
    for (Map.Entry<String, BestScoreStatisticListener> listenerEntry : bestScoreStatisticListenerMap
            .entrySet()) {//from   ww w .j a va 2s .  c om
        String configName = listenerEntry.getKey();
        XYSeries configSeries = new XYSeries(configName);
        List<BestScoreStatisticPoint> statisticPointList = listenerEntry.getValue()
                .getBestScoreStatisticPointList();
        for (BestScoreStatisticPoint statisticPoint : statisticPointList) {
            long timeMillisSpend = statisticPoint.getTimeMillisSpend();
            Score score = statisticPoint.getScore();
            Double scoreGraphValue = scoreDefinition.translateScoreToGraphValue(score);
            if (scoreGraphValue != null) {
                configSeries.add(timeMillisSpend, scoreGraphValue);
            }
        }
        seriesCollection.addSeries(configSeries);
    }
    NumberAxis xAxis = new NumberAxis("Time millis spend");
    xAxis.setNumberFormatOverride(new MillisecondsSpendNumberFormat());
    NumberAxis yAxis = new NumberAxis("Score");
    yAxis.setAutoRangeIncludesZero(false);
    XYItemRenderer renderer = new XYStepRenderer();
    XYPlot plot = new XYPlot(seriesCollection, xAxis, yAxis, renderer);
    plot.setOrientation(PlotOrientation.VERTICAL);
    JFreeChart chart = new JFreeChart(baseName + " best score statistic", JFreeChart.DEFAULT_TITLE_FONT, plot,
            true);
    BufferedImage chartImage = chart.createBufferedImage(1024, 768);
    File graphStatisticFile = new File(solverStatisticFilesDirectory, baseName + "Statistic.png");
    OutputStream out = null;
    try {
        out = new FileOutputStream(graphStatisticFile);
        ImageIO.write(chartImage, "png", out);
    } catch (IOException e) {
        throw new IllegalArgumentException("Problem writing graphStatisticFile: " + graphStatisticFile, e);
    } finally {
        IOUtils.closeQuietly(out);
    }
    return "  <img src=\"" + graphStatisticFile.getName() + "\"/>\n";
}

From source file:org.optaplanner.benchmark.impl.statistic.single.constraintmatchtotalstepscore.ConstraintMatchTotalStepScoreSingleStatistic.java

@Override
public void writeGraphFiles(BenchmarkReport benchmarkReport) {
    List<Map<String, XYSeries>> constraintIdToWeightSeriesMapList = new ArrayList<Map<String, XYSeries>>(
            BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE);
    for (ConstraintMatchTotalStepScoreStatisticPoint point : getPointList()) {
        int scoreLevel = point.getScoreLevel();
        if (scoreLevel >= BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE) {
            continue;
        }//from   w w w.  j  av a  2 s .  co m
        while (scoreLevel >= constraintIdToWeightSeriesMapList.size()) {
            constraintIdToWeightSeriesMapList.add(new LinkedHashMap<String, XYSeries>());
        }
        Map<String, XYSeries> constraintIdToWeightSeriesMap = constraintIdToWeightSeriesMapList.get(scoreLevel);
        if (constraintIdToWeightSeriesMap == null) {
            constraintIdToWeightSeriesMap = new LinkedHashMap<String, XYSeries>();
            constraintIdToWeightSeriesMapList.set(scoreLevel, constraintIdToWeightSeriesMap);
        }
        String constraintId = point.getConstraintPackage() + ":" + point.getConstraintName();
        XYSeries weightSeries = constraintIdToWeightSeriesMap.get(constraintId);
        if (weightSeries == null) {
            weightSeries = new XYSeries(point.getConstraintName() + " weight");
            constraintIdToWeightSeriesMap.put(constraintId, weightSeries);
        }
        long timeMillisSpent = point.getTimeMillisSpent();
        weightSeries.add(timeMillisSpent, point.getWeightTotal());
    }
    graphFileList = new ArrayList<File>(constraintIdToWeightSeriesMapList.size());
    for (int scoreLevelIndex = 0; scoreLevelIndex < constraintIdToWeightSeriesMapList
            .size(); scoreLevelIndex++) {
        XYPlot plot = createPlot(benchmarkReport, scoreLevelIndex);
        // No direct ascending lines between 2 points, but a stepping line instead
        XYItemRenderer renderer = new XYStepRenderer();
        plot.setRenderer(renderer);
        XYSeriesCollection seriesCollection = new XYSeriesCollection();
        for (XYSeries series : constraintIdToWeightSeriesMapList.get(scoreLevelIndex).values()) {
            seriesCollection.addSeries(series);
        }
        plot.setDataset(seriesCollection);
        JFreeChart chart = new JFreeChart(singleBenchmarkResult.getName()
                + " constraint match total step score diff level " + scoreLevelIndex + " statistic",
                JFreeChart.DEFAULT_TITLE_FONT, plot, true);
        graphFileList.add(
                writeChartToImageFile(chart, "ConstraintMatchTotalStepScoreStatisticLevel" + scoreLevelIndex));
    }
}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.reporting.ProfilesComparisonReportChartCanvas.java

private void createChart() {

    // create dataset
    theDataset = createDataset();/*from w  w w . j  a  v  a  2 s .c o m*/

    // create axis
    CategoryAxis categoryAxis = new CategoryAxis("");
    categoryAxis.setCategoryLabelPositions(org.jfree.chart.axis.CategoryLabelPositions.UP_45);
    ValueAxis valueAxis = new NumberAxis("Normalized Intensities");

    // create renderer
    CategoryItemRenderer renderer = null;
    if (theOptions.REPRESENTATION == theOptions.BARS)
        renderer = new org.jfree.chart.renderer.category.BarRenderer();
    else if (theOptions.REPRESENTATION == theOptions.ERRORBARS)
        renderer = new org.jfree.chart.renderer.category.StatisticalBarRenderer();
    else if (theOptions.REPRESENTATION == theOptions.DISTRIBUTIONS)
        renderer = new org.jfree.chart.renderer.category.ScatterRenderer();

    ItemLabelPosition position1 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER);
    renderer.setBasePositiveItemLabelPosition(position1);
    ItemLabelPosition position2 = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER);
    renderer.setBaseNegativeItemLabelPosition(position2);

    // create plot
    thePlot = new CategoryPlot(theDataset, categoryAxis, valueAxis, renderer);
    thePlot.setOrientation(org.jfree.chart.plot.PlotOrientation.VERTICAL);

    // add mean values 
    if (theOptions.REPRESENTATION == theOptions.DISTRIBUTIONS) {
        thePlot.setDataset(1, createMeansDataset());
        thePlot.mapDatasetToRangeAxis(1, 0);

        CategoryItemRenderer lr = new org.jfree.chart.renderer.category.LevelRenderer();
        lr.setPaint(Color.black);
        thePlot.setRenderer(1, lr);
    }

    // create chart
    theChart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, thePlot, true);
    theChart.setBackgroundPaint(Color.white);
    theChart.setBorderVisible(false);

}

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

private static JFreeChart createTimeSeriesChart2(XYDataset dataset) {

    DateAxis timeAxis = new DateAxis(xAxisLabel);
    timeAxis.setLowerMargin(0.02); // reduce the default margins
    timeAxis.setUpperMargin(0.02);//from w  w w .  java2 s  . c o  m
    NumberAxis valueAxis = new NumberAxis(yAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false); // override default
    XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null);

    XYToolTipGenerator toolTipGenerator = null;
    if (tooltips) {
        toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance();
    }

    XYURLGenerator urlGenerator = null;
    if (urls) {
        urlGenerator = new StandardXYURLGenerator();
    }

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);
    renderer.setBaseToolTipGenerator(toolTipGenerator);
    renderer.setURLGenerator(urlGenerator);
    plot.setRenderer(renderer);

    JFreeChart chart = new JFreeChart("TimeSeries 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);

    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setDrawSeriesLineAsPath(true);

    timeAxis.setDateFormatOverride(new SimpleDateFormat("MM-yyyy"));

    return chart;
}

From source file:org.optaplanner.benchmark.impl.statistic.subsingle.constraintmatchtotalstepscore.ConstraintMatchTotalStepScoreSubSingleStatistic.java

@Override
public void writeGraphFiles(BenchmarkReport benchmarkReport) {
    List<Map<String, XYSeries>> constraintIdToWeightSeriesMapList = new ArrayList<Map<String, XYSeries>>(
            BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE);
    for (ConstraintMatchTotalStepScoreStatisticPoint point : getPointList()) {
        int scoreLevel = point.getScoreLevel();
        if (scoreLevel >= BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE) {
            continue;
        }//from w  w w . j a  va 2  s .com
        while (scoreLevel >= constraintIdToWeightSeriesMapList.size()) {
            constraintIdToWeightSeriesMapList.add(new LinkedHashMap<String, XYSeries>());
        }
        Map<String, XYSeries> constraintIdToWeightSeriesMap = constraintIdToWeightSeriesMapList.get(scoreLevel);
        if (constraintIdToWeightSeriesMap == null) {
            constraintIdToWeightSeriesMap = new LinkedHashMap<String, XYSeries>();
            constraintIdToWeightSeriesMapList.set(scoreLevel, constraintIdToWeightSeriesMap);
        }
        String constraintId = point.getConstraintPackage() + ":" + point.getConstraintName();
        XYSeries weightSeries = constraintIdToWeightSeriesMap.get(constraintId);
        if (weightSeries == null) {
            weightSeries = new XYSeries(point.getConstraintName() + " weight");
            constraintIdToWeightSeriesMap.put(constraintId, weightSeries);
        }
        long timeMillisSpent = point.getTimeMillisSpent();
        weightSeries.add(timeMillisSpent, point.getWeightTotal());
    }
    graphFileList = new ArrayList<File>(constraintIdToWeightSeriesMapList.size());
    for (int scoreLevelIndex = 0; scoreLevelIndex < constraintIdToWeightSeriesMapList
            .size(); scoreLevelIndex++) {
        XYPlot plot = createPlot(benchmarkReport, scoreLevelIndex);
        // No direct ascending lines between 2 points, but a stepping line instead
        XYItemRenderer renderer = new XYStepRenderer();
        plot.setRenderer(renderer);
        XYSeriesCollection seriesCollection = new XYSeriesCollection();
        for (XYSeries series : constraintIdToWeightSeriesMapList.get(scoreLevelIndex).values()) {
            seriesCollection.addSeries(series);
        }
        plot.setDataset(seriesCollection);
        JFreeChart chart = new JFreeChart(subSingleBenchmarkResult.getName()
                + " constraint match total step score diff level " + scoreLevelIndex + " statistic",
                JFreeChart.DEFAULT_TITLE_FONT, plot, true);
        graphFileList.add(
                writeChartToImageFile(chart, "ConstraintMatchTotalStepScoreStatisticLevel" + scoreLevelIndex));
    }
}

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

/**
 * Displays an overlaid XYPlot with X and Y symbolic data.
 * //from  w ww  .  jav  a 2  s. co  m
 * @param frameTitle
 *           the frame title.
 * @param data1
 *           the dataset 1.
 * @param data2
 *           the dataset 2.
 */
private static void displayXYSymbolicOverlaid(final String frameTitle, final XYDataset data1,
        final XYDataset data2) {

    final String title = "Pollutant Overlaid";
    final String xAxisLabel = "Contamination and Type";
    final String yAxisLabel = "Pollutant";

    // combine the x symbolic values of the two data sets
    final String[] combinedXSymbolicValues = SampleXYSymbolicDataset
            .combineXSymbolicDataset((XisSymbolic) data1, (XisSymbolic) data2);

    // combine the y symbolic values of the two data sets
    final String[] combinedYSymbolicValues = SampleXYSymbolicDataset
            .combineYSymbolicDataset((YisSymbolic) data1, (YisSymbolic) data2);

    // make 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);

    // create overlaid plot...
    final SymbolicAxis hsymbolicAxis = new SymbolicAxis(xAxisLabel, combinedXSymbolicValues);
    final SymbolicAxis vsymbolicAxis = new SymbolicAxis(yAxisLabel, combinedYSymbolicValues);

    final XYItemRenderer renderer1 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null);
    final XYPlot plot = new XYPlot(series0, hsymbolicAxis, vsymbolicAxis, renderer1);

    final XYItemRenderer renderer2 = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES, null);
    plot.setDataset(1, series1);
    plot.setRenderer(1, renderer2);

    // make the chart...
    final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, 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.drools.planner.benchmark.core.statistic.PlannerStatistic.java

private void writeWinningScoreDifferenceSummaryChart() {
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();
    for (SolverBenchmark solverBenchmark : plannerBenchmark.getSolverBenchmarkList()) {
        ScoreDefinition scoreDefinition = solverBenchmark.getSolverConfig().getScoreDirectorFactoryConfig()
                .buildScoreDefinition();
        for (SingleBenchmark singleBenchmark : solverBenchmark.getSingleBenchmarkList()) {
            if (singleBenchmark.isSuccess()) {
                Score score = singleBenchmark.getWinningScoreDifference();
                Double scoreGraphValue = scoreDefinition.translateScoreToGraphValue(score);
                String solverLabel = solverBenchmark.getName();
                if (solverBenchmark.isRankingBest()) {
                    solverLabel += " (winner)";
                }/*from   ww  w. j ava2  s  . com*/
                String planningProblemLabel = singleBenchmark.getProblemBenchmark().getName();
                dataset.addValue(scoreGraphValue, solverLabel, planningProblemLabel);
            }
        }
    }
    CategoryAxis xAxis = new CategoryAxis("Data");
    xAxis.setCategoryMargin(0.40);
    NumberAxis yAxis = new NumberAxis("Winning score difference");
    BarRenderer renderer = new BarRenderer();
    ItemLabelPosition positiveItemLabelPosition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12,
            TextAnchor.BOTTOM_CENTER);
    renderer.setBasePositiveItemLabelPosition(positiveItemLabelPosition);
    ItemLabelPosition negativeItemLabelPosition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE6,
            TextAnchor.TOP_CENTER);
    renderer.setBaseNegativeItemLabelPosition(negativeItemLabelPosition);
    renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    renderer.setBaseItemLabelsVisible(true);
    CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer);
    plot.setOrientation(PlotOrientation.VERTICAL);
    JFreeChart chart = new JFreeChart("Winning score difference summary (higher is better)",
            JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    BufferedImage chartImage = chart.createBufferedImage(1024, 768);
    winningScoreDifferenceSummaryFile = new File(plannerBenchmark.getBenchmarkReportDirectory(),
            "winningScoreDifferenceSummary.png");
    OutputStream out = null;
    try {
        out = new FileOutputStream(winningScoreDifferenceSummaryFile);
        ImageIO.write(chartImage, "png", out);
    } catch (IOException e) {
        throw new IllegalArgumentException(
                "Problem writing winningScoreDifferenceSummaryFile: " + winningScoreDifferenceSummaryFile, e);
    } finally {
        IOUtils.closeQuietly(out);
    }
}

From source file:i2p.bote.web.PeerInfoTag.java

private String createRelayChart(RelayPeer[] relayPeers) throws IOException {
    RingPlot plot;/* www.  j  a  v a2s .c o  m*/
    if (relayPeers.length == 0) {
        DefaultPieDataset dataset = new DefaultPieDataset();
        dataset.setValue("", 100);

        plot = new RingPlot(dataset);
        plot.setSectionPaint("", Color.gray);
    } else {
        int good = 0;
        int untested = 0;
        for (RelayPeer relayPeer : relayPeers) {
            int reachability = relayPeer.getReachability();
            if (reachability == 0)
                untested += 1;
            else if (reachability > 80)
                good += 1;
        }
        int bad = relayPeers.length - good - untested;

        DefaultPieDataset dataset = new DefaultPieDataset();
        if (good > 0)
            dataset.setValue(_t("Good"), good);
        if (bad > 0)
            dataset.setValue(_t("Unreliable"), bad);
        if (untested > 0)
            dataset.setValue(_t("Untested"), untested);

        plot = new RingPlot(dataset);
        plot.setSectionPaint(_t("Good"), Color.green);
        plot.setSectionPaint(_t("Unreliable"), Color.red);
        plot.setSectionPaint(_t("Untested"), Color.orange);
    }
    plot.setLabelGenerator(null);
    plot.setShadowGenerator(null);

    JFreeChart chart = new JFreeChart(_t("Relay Peers:"), JFreeChart.DEFAULT_TITLE_FONT, plot,
            relayPeers.length == 0 ? false : true);
    return ServletUtilities.saveChartAsPNG(chart, 400, 300, null);
}

From source file:org.pentaho.plugin.jfreereport.reportcharts.XYBarChartExpression.java

private static JFreeChart createStackedXYBarChart(final String title, final String xAxisLabel,
        final boolean dateAxis, final String yAxisLabel, final TableXYDataset dataset,
        final PlotOrientation orientation, final boolean legend, final boolean tooltips, final boolean urls) {

    if (orientation == null) {
        throw new IllegalArgumentException("Null 'orientation' argument.");
    }/*from  www. jav a 2s.c o m*/
    ValueAxis domainAxis = null;
    if (dateAxis) {
        domainAxis = new DateAxis(xAxisLabel);
    } else {
        final NumberAxis axis = new NumberAxis(xAxisLabel);
        axis.setAutoRangeIncludesZero(false);
        domainAxis = axis;
    }
    final ValueAxis valueAxis = new NumberAxis(yAxisLabel);

    final StackedXYBarRenderer renderer = new StackedXYBarRenderer();
    renderer.setUseYInterval(true);
    if (tooltips) {
        final XYToolTipGenerator tt;
        if (dateAxis) {
            tt = StandardXYToolTipGenerator.getTimeSeriesInstance();
        } else {
            tt = new StandardXYToolTipGenerator();
        }
        renderer.setBaseToolTipGenerator(tt);
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }

    final XYPlot plot = new XYPlot(dataset, domainAxis, valueAxis, renderer);
    plot.setOrientation(orientation);

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

From source file:pisco.batch.visu.BatchingChartFactory.java

private static JFreeChart createCombinedChart(String title, XYPlot batchplot, XYPlot objPlot) {
    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(createDateAxis());
    plot.setGap(10.0);/*from w  w  w.  j  a  v a2s.  co  m*/
    plot.add(objPlot, 1);
    plot.add(batchplot, 2);
    plot.setOrientation(PlotOrientation.VERTICAL);
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    CHOCO_THEME.apply(chart);
    return chart;
}