Example #1
0
  private JFreeChart createChart(XYDataset dataset) {
    JFreeChart chart =
        ChartFactory.createXYLineChart(
            Setting.getString("/bat/isotope/graph/bg/title"), // chart title
            Setting.getString("/bat/isotope/graph/bg/x_axes"), // x axis label
            Setting.getString("/bat/isotope/graph/bg/y_axes"), // y axis label
            dataset, // data
            PlotOrientation.VERTICAL,
            false, // include legend
            true, // tooltips
            false // urls
            );

    chart.setBackgroundPaint(Setting.getColor("/bat/isotope/graph/background"));
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Setting.getColor("/bat/isotope/graph/background"));
    plot.setRangeGridlinePaint(Setting.getColor("/bat/isotope/graph/background"));
    plot.setDomainCrosshairVisible(true);
    plot.setRangeCrosshairVisible(true);

    plot.getDomainAxis().getUpperBound();
    plot.setDataset(1, Func.xYSlope(slope, plot.getDomainAxis().getUpperBound()));

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseSeriesVisible(true);
    renderer.setBaseShapesFilled(true);
    renderer.setBaseShapesVisible(true);
    renderer.setDrawOutlines(true);
    renderer.setSeriesItemLabelFont(0, fText);
    renderer.setBaseItemLabelFont(fText);
    chart.getTitle().setFont(fTitel);

    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesLinesVisible(1, true);
    renderer.setSeriesShapesVisible(1, true);

    NumberAxis axis = (NumberAxis) plot.getRangeAxis();
    axis.setAutoRangeIncludesZero(true);
    axis.setLabelFont(fAxes);
    plot.getDomainAxis().setLabelFont(fAxes);

    return chart;
  }