Example usage for org.jfree.chart.axis ValueAxis getLabelFont

List of usage examples for org.jfree.chart.axis ValueAxis getLabelFont

Introduction

In this page you can find the example usage for org.jfree.chart.axis ValueAxis getLabelFont.

Prototype

public Font getLabelFont() 

Source Link

Document

Returns the font for the axis label.

Usage

From source file:com.griddynamics.jagger.reporting.chart.ChartHelper.java

public static JFreeChart createXYChart(String title, XYDataset data, String xLabel, String yLabel,
        int pointRadius, int lineThickness, ColorTheme theme) {
    JFreeChart chart = ChartFactory.createXYLineChart(title, xLabel, yLabel, data, PlotOrientation.VERTICAL,
            true, false, false);//w  ww .  j a va  2  s  .c o  m

    formatColorTheme(chart, theme);

    XYPlot plot = (XYPlot) chart.getPlot();
    Shape icon = new Ellipse2D.Double(-pointRadius, -pointRadius, pointRadius * 2, pointRadius * 2);

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    plot.setRenderer(renderer);

    Color[] colors = generateJetSpectrum(data.getSeriesCount());
    for (int i = 0; i < data.getSeriesCount(); i++) {
        plot.getRenderer().setSeriesStroke(i, new BasicStroke(lineThickness));
        plot.getRenderer().setSeriesShape(i, icon);
        ((XYLineAndShapeRenderer) plot.getRenderer()).setSeriesShapesVisible(i, true);
        ((XYLineAndShapeRenderer) plot.getRenderer()).setSeriesShapesFilled(i, true);
        plot.getRenderer().setSeriesPaint(i, colors[i]);
    }

    LegendTitle legend = chart.getLegend();
    Font legendFont = legend.getItemFont();
    float legendFontSize = legendFont.getSize();
    Font newLegendFont = legendFont.deriveFont(legendFontSize * 0.6f);
    legend.setItemFont(newLegendFont);

    ValueAxis domainAxis = ((XYPlot) chart.getPlot()).getDomainAxis();
    Font domainAxisLabelFont = domainAxis.getLabelFont();
    float domainAxisLabelFontSize = domainAxisLabelFont.getSize();
    domainAxis.setLabelFont(domainAxisLabelFont.deriveFont(domainAxisLabelFontSize * 0.6f));

    Font domainAxisTickLabelFont = domainAxis.getTickLabelFont();
    float domainAxisTickLabelFontSize = domainAxisTickLabelFont.getSize();
    domainAxis.setTickLabelFont(domainAxisTickLabelFont.deriveFont(domainAxisTickLabelFontSize * 0.6f));

    ValueAxis rangeAxis = ((XYPlot) chart.getPlot()).getRangeAxis();
    Font rangeAxisLabelFont = rangeAxis.getLabelFont();
    float rangeAxisLabelFontSize = rangeAxisLabelFont.getSize();
    rangeAxis.setLabelFont(rangeAxisLabelFont.deriveFont(rangeAxisLabelFontSize * 0.6f));

    Font rangeAxisTickLabelFont = rangeAxis.getTickLabelFont();
    float rangeAxisTickLabelFontSize = rangeAxisTickLabelFont.getSize();
    rangeAxis.setTickLabelFont(rangeAxisTickLabelFont.deriveFont(rangeAxisTickLabelFontSize * 0.6f));

    return chart;
}

From source file:org.gumtree.vis.awt.PlotFactory.java

public static JFreeChart createTimeChart(ITimeSeriesSet timeSeriesSet) {
    //      TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    JFreeChart chart = ChartFactory.createTimeSeriesChart(timeSeriesSet.getTitle(), null,
            timeSeriesSet.getYTitle()/*from   ww w .j  av  a 2 s .c  o  m*/
                    + (timeSeriesSet.getYUnits() != null ? " (" + timeSeriesSet.getYUnits() + ")" : ""),
            timeSeriesSet, true, true, false);
    XYPlot xyplot = chart.getXYPlot();
    ValueAxis valueaxis = xyplot.getDomainAxis();
    valueaxis.setAutoRange(true);
    //        valueaxis.setFixedAutoRange(60000D);   
    valueaxis = xyplot.getRangeAxis();
    valueaxis.setRange(0.0D, 200D);
    valueaxis.setAutoRange(true);
    XYItemRenderer renderer = xyplot.getRenderer();
    if (renderer instanceof XYLineAndShapeRenderer) {
        ((XYLineAndShapeRenderer) renderer).setBaseShapesVisible(false);
    }
    chartTheme.apply(chart);
    Font font = valueaxis.getLabelFont();
    valueaxis.setLabelFont(font.deriveFont(Font.PLAIN));
    return chart;
}