Example usage for org.jfree.chart.axis NumberAxis getTickLabelFont

List of usage examples for org.jfree.chart.axis NumberAxis getTickLabelFont

Introduction

In this page you can find the example usage for org.jfree.chart.axis NumberAxis getTickLabelFont.

Prototype

public Font getTickLabelFont() 

Source Link

Document

Returns the font used for the tick labels (if showing).

Usage

From source file:org.webcat.grader.graphs.BoxAndWhiskerChart.java

@Override
protected JFreeChart generateChart(WCChartTheme chartTheme) {
    setChartHeight(36);//www  .  j  a va 2  s.  c  o  m

    JFreeChart chart = ChartFactory.createBoxAndWhiskerChart(null, null, yAxisLabel(), boxAndWhiskerXYDataset(),
            false);
    chart.getXYPlot().setOrientation(PlotOrientation.HORIZONTAL);
    chart.setPadding(new RectangleInsets(0, 6, 0, 6));

    XYPlot plot = chart.getXYPlot();
    plot.setInsets(RectangleInsets.ZERO_INSETS);
    plot.setOutlineVisible(false);
    plot.setBackgroundPaint(new Color(0, 0, 0, 0));
    XYBoxAndWhiskerRenderer renderer = (XYBoxAndWhiskerRenderer) plot.getRenderer();
    renderer.setAutoPopulateSeriesOutlinePaint(true);

    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setVisible(false);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setRange(-0.5, assignmentOffering.assignment().submissionProfile().availablePoints() + 0.5);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    Font oldFont = rangeAxis.getTickLabelFont();
    rangeAxis.setTickLabelFont(oldFont.deriveFont(oldFont.getSize2D() * 0.8f));

    return chart;
}

From source file:desmoj.extensions.grafic.util.Plotter.java

/**
 * configure range axis ( lowerBound, upperBound, label, format ticks)
 * of time-series chart/*w w  w  .  j ava 2s.com*/
 * @param numberAxis
 * @param label
 */
private void configureRangeAxis(NumberAxis numberAxis, String label) {
    double min = numberAxis.getLowerBound();
    double max = numberAxis.getUpperBound();
    Double delta = 0.01 * (max - min);
    numberAxis.setLowerBound(min - delta);
    numberAxis.setUpperBound(max + delta);

    numberAxis.setLabel(label);

    // format Ticks
    double fontHeight = numberAxis.getTickLabelFont().getLineMetrics("X", this.frc).getHeight();
    double maxTicks = this.paintPanel.getSize().height / fontHeight;
    int digits = Math.max(0, (int) -Math.floor(Math.log10((max - min) / maxTicks)));
    //System.out.println(fontHeight+"  "+digits+"  "+Math.log10((max - min)/ maxTicks));
    NumberFormat formatter = NumberFormat.getNumberInstance(this.locale);
    formatter.setMinimumFractionDigits(digits);
    formatter.setMaximumFractionDigits(digits);
    formatter.setGroupingUsed(true);
    numberAxis.setNumberFormatOverride(formatter);
}

From source file:org.forester.archaeopteryx.TreePanel.java

private static JFreeChart createChart(CategoryDataset dataset, String branch_name) {
    // create the chart
    JFreeChart chart = ChartFactory.createBarChart("RAxML Weights Histogram " + branch_name, // chart title
            "RAxML Weights", // domain axis label
            "Placements", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            false, // include legend
            true, // tooltips?
            false // URLs?
    );//from ww w . ja va2 s.  c  o  m

    // set the background color for the chart and title colors & font
    chart.setBackgroundPaint(Color.black);
    chart.setTextAntiAlias(true);
    chart.setBorderPaint(Color.green);
    chart.getTitle().setPaint(Color.white);
    chart.getTitle().setFont(chart.getTitle().getFont().deriveFont(12.0f));

    // get a reference to the plot for further customisation
    CategoryPlot plot = chart.getCategoryPlot();
    plot.setForegroundAlpha(0.7f);
    plot.setBackgroundPaint(Color.black);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    // set the range axis to display integers only, set colors & font
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLabelPaint(Color.white);
    rangeAxis.setLabelFont(rangeAxis.getLabelFont().deriveFont(10.0f));
    rangeAxis.setAxisLinePaint(new Color(226, 236, 243));
    rangeAxis.setTickLabelFont(rangeAxis.getTickLabelFont().deriveFont(8.0f));
    rangeAxis.setTickLabelPaint(Color.white);

    // Custom renderer to display each bar in another color
    final BarRenderer renderer = new CustomRenderer(new Paint[] { new Color(255, 0, 0), new Color(227, 28, 0),
            new Color(199, 56, 0), new Color(171, 84, 0), new Color(143, 112, 0), new Color(115, 140, 0),
            new Color(87, 168, 0), new Color(59, 196, 0), new Color(31, 224, 0), new Color(0, 255, 0) });

    // shadow effect off
    renderer.setShadowVisible(false);

    //make custom renderer the new renderer for the barchart
    plot.setRenderer(renderer);

    // set x axis label rotation, font and color
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 4));
    domainAxis.setLabelPaint(Color.white);
    domainAxis.setLabelFont(domainAxis.getLabelFont().deriveFont(10.0f));
    domainAxis.setTickLabelPaint(Color.white);
    domainAxis.setTickLabelFont(domainAxis.getTickLabelFont().deriveFont(8.0f));
    domainAxis.setAxisLinePaint(new Color(226, 236, 243));
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}