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

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

Introduction

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

Prototype

public void setLabelFont(Font font) 

Source Link

Document

Sets the font for the axis label and sends an AxisChangeEvent to all registered listeners.

Usage

From source file:playground.dgrether.analysis.charts.DgDefaultAxisBuilder.java

public ValueAxis createValueAxis(String yLabel) {
    ValueAxis valueAxis = new NumberAxis(yLabel);
    valueAxis.setLabelFont(labelFont);
    valueAxis.setTickLabelFont(axisFont);
    return valueAxis;
}

From source file:net.relet.freimap.NodeInfo.java

private void sexupAxis(ValueAxis axis) {
    axis.setLabelFont(VisorFrame.smallerfont);
    axis.setLabelPaint(VisorFrame.fgcolor);
    axis.setTickLabelFont(VisorFrame.smallerfont);
    axis.setTickLabelPaint(VisorFrame.fgcolor);
}

From source file:com.tencent.wstt.apt.chart.CPURealTimeChart.java

@Override
public JFreeChart createChart() {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart("CPU", "", "CPU%", dataset,
            true, true, false);// w  w  w  .jav  a  2 s .c  o m

    //??
    chart.getTitle().setFont(new Font("", Font.BOLD, 20));

    XYPlot xyPlot = (XYPlot) chart.getXYPlot();
    ValueAxis domainAxis = xyPlot.getDomainAxis();
    ValueAxis rangeAxis = xyPlot.getRangeAxis();

    domainAxis.setLabelFont(new Font("", Font.BOLD, 14));
    domainAxis.setTickLabelFont(new Font("", Font.BOLD, 12));

    rangeAxis.setLabelFont(new Font("", Font.BOLD, 14));
    rangeAxis.setTickLabelFont(new Font("", Font.BOLD, 12));
    return chart;
}

From source file:com.tencent.wstt.apt.chart.MemoryRealTimeChart.java

@Override
public JFreeChart createChart() {
    final JFreeChart chart = ChartFactory.createTimeSeriesChart("", "",
            "kB", dataset, true, true, false);

    //??/*w ww .  j  a va  2s .  c  o m*/
    chart.getTitle().setFont(new Font("", Font.BOLD, 20));

    XYPlot xyPlot = (XYPlot) chart.getXYPlot();
    ValueAxis domainAxis = xyPlot.getDomainAxis();
    ValueAxis rangeAxis = xyPlot.getRangeAxis();

    domainAxis.setLabelFont(new Font("", Font.BOLD, 14));
    domainAxis.setTickLabelFont(new Font("", Font.BOLD, 12));

    rangeAxis.setLabelFont(new Font("", Font.BOLD, 14));
    rangeAxis.setTickLabelFont(new Font("", Font.BOLD, 12));
    //rangeAxis.setAutoRange(true);

    //rangeAxis.setAutoTickUnitSelection(true);

    return chart;
}

From source file:org.talend.dataprofiler.chart.ChartDecorator.java

/**
 * DOC bZhou Comment method "decorateCategoryPlot".
 * /*from  w w w. j  av a  2 s  . c om*/
 * @param chart
 */
public static void decorateCategoryPlot(JFreeChart chart, PlotOrientation orientation) {

    CategoryPlot plot = chart.getCategoryPlot();
    CategoryItemRenderer render = plot.getRenderer();
    CategoryAxis domainAxis = plot.getDomainAxis();
    // ADD msjian TDQ-5111 2012-4-9: set something look it well
    domainAxis.setCategoryMargin(0.1);
    domainAxis.setUpperMargin(0.05);
    domainAxis.setLowerMargin(0.05);
    domainAxis.setCategoryLabelPositionOffset(10);
    // TDQ-5111~

    ValueAxis valueAxis = plot.getRangeAxis();

    Font font = new Font("Tahoma", Font.BOLD, BASE_ITEM_LABEL_SIZE);//$NON-NLS-1$

    render.setBaseItemLabelFont(font);
    // MOD zshen 10998: change the font name 2010-01-16
    font = new Font("sans-serif", Font.BOLD, BASE_LABEL_SIZE);//$NON-NLS-1$
    domainAxis.setLabelFont(font);

    font = new Font("sans-serif", Font.BOLD, BASE_LABEL_SIZE);//$NON-NLS-1$
    valueAxis.setLabelFont(font);

    font = new Font("sans-serif", Font.PLAIN, BASE_TICK_LABEL_SIZE);//$NON-NLS-1$
    domainAxis.setTickLabelFont(font);
    valueAxis.setTickLabelFont(font);

    setLegendFont(chart);

    font = new Font("sans-serif", Font.BOLD, BASE_TITLE_LABEL_SIZE);//$NON-NLS-1$
    TextTitle title = chart.getTitle();
    if (title != null) {
        title.setFont(font);
    }

    font = null;

    if (render instanceof BarRenderer) {
        CategoryDataset dataset = chart.getCategoryPlot().getDataset();
        if (dataset != null) {
            int rowCount = dataset.getRowCount();
            List<?> columnKeys = dataset.getColumnKeys();
            if (!isContainCJKCharacter(columnKeys.toArray())) {
                domainAxis.setTickLabelFont(new Font("Tahoma", Font.PLAIN, 10));//$NON-NLS-1$
            }
            ((BarRenderer) render).setItemMargin(-0.40 * rowCount);

            // TDQ-12621 add Tooltip for Lable
            for (Object colKey : columnKeys) {
                domainAxis.addCategoryLabelToolTip(colKey.toString(), colKey.toString());
            }
        }
        domainAxis.setUpperMargin(0.1);
        // TDQ-12621 Only display in 1 line for the label, other chars will be displayed as "..."
        domainAxis.setMaximumCategoryLabelLines(1);

        // ADD msjian TDQ-5111 2012-4-9: set Bar Width and let it look well
        // not do this when the bar is horizontal Orientation
        if (orientation == null) {
            ((BarRenderer) render).setMaximumBarWidth(0.2);
        }
        // TDQ-5111~
    }
    // ~10998
}

From source file:net.relet.freimap.LinkInfo.java

private void sexupAxis(ValueAxis axis) {
    axis.setLabelFont(VisorFrame.smallerfont);
    axis.setLabelPaint(VisorFrame.fgcolor2);
    axis.setTickLabelFont(VisorFrame.smallerfont);
    axis.setTickLabelPaint(VisorFrame.fgcolor2);
}

From source file:net.bioclipse.jasper.charCustomizers.DoseResponseChartCustomizer.java

@Override
public void customize(JFreeChart chart, JRChart jasperchart) {
    ValueAxis domainAxis = new LogarithmicAxis("Concentration");
    ValueAxis rangeAxis = new NumberAxis("SI%");
    domainAxis.setTickLabelFont(small);//  www.  java  2s . c om
    rangeAxis.setTickLabelFont(small);
    domainAxis.setLabelFont(normalsize);
    rangeAxis.setLabelFont(normalsize);
    rangeAxis.setRange(0, 110);
    chart.getXYPlot().setDomainAxis(domainAxis);
    chart.getXYPlot().setRangeAxis(rangeAxis);
    chart.getXYPlot().setDomainGridlinesVisible(false);
    chart.getXYPlot().getRenderer().setSeriesShape(0, new Ellipse2D.Double(-1, -1, 2, 2));
}

From source file:fr.ign.cogit.simplu3d.rjmcmc.generic.visitor.StatsVisitor.java

/**
 * Creates a sample chart./*w  w w  .  j av  a2s .c  om*/
 * 
 * @param dataset
 *            the dataset.
 * @return A sample chart.
 */
private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createXYLineChart("volution de l'nergie", "Itration",
            "nergie", dataset, PlotOrientation.VERTICAL, true, true, true);

    result.setBorderPaint(Color.white);

    result.setBackgroundPaint(Color.white);

    final XYPlot plot = result.getXYPlot();

    Font font = new Font("Verdana", Font.PLAIN, 32);
    Font font2 = new Font("Verdana", Font.PLAIN, 28);

    // axe x
    ValueAxis axis = plot.getDomainAxis();

    axis.setLabelFont(font);
    axis.setTickLabelFont(font2);

    axis.setAutoRange(true);
    // axis.setFixedAutoRange(60000.0); // 60 seconds
    axis = plot.getRangeAxis();

    // axe y
    ValueAxis axis2 = plot.getRangeAxis();

    axis2.setLabelFont(font);
    axis2.setTickLabelFont(font2);

    axis2.setAutoRange(true);
    // axis.setFixedAutoRange(60000.0); // 60 seconds
    axis2 = plot.getRangeAxis();

    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setBackgroundPaint(Color.white);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();

    renderer.setSeriesPaint(0, new Color(255, 0, 0));
    renderer.setSeriesStroke(0, new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f));

    renderer.setLegendTextFont(0, font2);

    renderer.setSeriesPaint(1, new Color(2, 157, 116));
    renderer.setSeriesStroke(1, new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f));

    renderer.setLegendTextFont(1, font2);

    renderer.setSeriesPaint(2, new Color(112, 147, 219));
    renderer.setSeriesStroke(2, new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f));

    renderer.setLegendTextFont(2, font2);

    renderer.setSeriesPaint(3, new Color(140, 23, 23));
    renderer.setSeriesStroke(3, new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 6.0f, 6.0f }, 0.0f));

    renderer.setLegendTextFont(3, font2);

    // axis.setRange(0.0, 200.0);
    return result;
}

From source file:imageviewer.tools.HistogramTool.java

public void plot(MouseEvent e) {

    if (e.getSource() instanceof ImagePanel) {
        Image image = ((ImagePanel) e.getSource()).getSource();
        Histogram h = image.getHistogram();
        SimpleHistogramDataset shd = new SimpleHistogramDataset("Voxel distribution");
        for (int i = 0, numBands = h.getNumBands(); i < numBands; i++) {
            int[] binData = h.getBins(i);
            for (int j = 0; j < binData.length; j++) {
                SimpleHistogramBin shb = new SimpleHistogramBin(j - 0.5, j + 0.5, true, false);
                shb.setItemCount(binData[j]);
                shd.addBin(shb);//from   w w w. ja  v a 2  s .  c  o m
            }
        }
        double[] domainBounds = null, rangeBounds = null;
        if (chart != null) {
            ValueAxis va = chart.getXYPlot().getDomainAxis();
            domainBounds = new double[] { va.getLowerBound(), va.getUpperBound() };
            va = chart.getXYPlot().getRangeAxis();
            rangeBounds = new double[] { va.getLowerBound(), va.getUpperBound() };
        }
        chart = ChartFactory.createHistogram(null, "Voxel value", "Count", shd, PlotOrientation.VERTICAL, false,
                true, false);
        chart.setBackgroundPaint(new Color(20, 30, 45));
        chart.setAntiAlias(true);
        ValueAxis domainAxis = chart.getXYPlot().getDomainAxis();
        domainAxis.setLabelFont(axisFont);
        domainAxis.setTickLabelFont(tickFont);
        domainAxis.setAxisLinePaint(Color.white);
        domainAxis.setTickLabelPaint(Color.white);
        domainAxis.setLabelPaint(Color.white);
        if (domainBounds != null) {
            domainAxis.setAutoRange(false);
            domainAxis.setLowerBound(domainBounds[0]);
            domainAxis.setUpperBound(domainBounds[1]);
        } else {
            domainAxis.setLowerBound(0);
        }
        ValueAxis rangeAxis = chart.getXYPlot().getRangeAxis();
        rangeAxis.setLabelFont(axisFont);
        rangeAxis.setTickLabelFont(tickFont);
        rangeAxis.setAxisLinePaint(Color.white);
        rangeAxis.setTickLabelPaint(Color.white);
        rangeAxis.setLabelPaint(Color.white);
        if (rangeBounds != null) {
            rangeAxis.setAutoRange(false);
            rangeAxis.setLowerBound(rangeBounds[0]);
            rangeAxis.setUpperBound(rangeBounds[1]);
        }
        chart.getXYPlot().getRenderer().setSeriesPaint(0, new Color(0, 51, 113));
        ((XYBarRenderer) chart.getXYPlot().getRenderer()).setDrawBarOutline(false);
        chart.getXYPlot().setBackgroundAlpha(0.05f);

        double[] mean = h.getMean();
        double[] sd = h.getStandardDeviation();
        IntervalMarker im = new IntervalMarker(mean[0] - sd[0] / 2, mean[0] + sd[0] / 2);
        im.setPaint(new Color(200, 200, 200, 128));
        chart.getXYPlot().addDomainMarker(0, im, Layer.BACKGROUND);
        cp.setChart(chart);
    }
}

From source file:org.yardstickframework.report.jfreechart.JFreeChartGraphPlotter.java

/**
 * @param folderToWrite Folder to write the resulted charts.
 * @param plots Collections of plots.//from  w ww . j  a v a 2 s.  c  om
 * @param infoMap Map with additional plot info.
 * @param mode Generation mode.
 * @throws Exception If failed.
 */
private static void processPlots(File folderToWrite, Collection<List<PlotData>> plots,
        Map<String, List<JFreeChartPlotInfo>> infoMap, JFreeChartGenerationMode mode) throws Exception {
    ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection());

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false);

    int idx = -1;

    while (true) {
        idx++;

        DefaultXYDataset dataSet = new DefaultXYDataset();

        List<JFreeChartPlotInfo> infoList = new ArrayList<>();

        String xAxisLabel = "";
        String yAxisLabel = "";
        String plotName = "";

        int cnt = 0;

        for (List<PlotData> plotData0 : plots) {
            if (plotData0.size() <= idx)
                continue;

            PlotData plotData = plotData0.get(idx);

            dataSet.addSeries(plotData.plotName() + "_" + cnt++, plotData.series().data);

            xAxisLabel = plotData.xAxisLabel;
            yAxisLabel = plotData.yAxisLabel;
            plotName = plotData.plotName();

            infoList.add(info(plotData.series(), mode));
        }

        if (infoList.isEmpty())
            break;

        JFreeChart chart = ChartFactory.createXYLineChart("", xAxisLabel, yAxisLabel, dataSet,
                PlotOrientation.VERTICAL, false, false, false);

        AxisSpace as = new AxisSpace();

        as.add(150, RectangleEdge.LEFT);

        XYPlot plot = (XYPlot) chart.getPlot();

        BasicStroke stroke = new BasicStroke(1);

        plot.setRenderer(renderer);
        plot.setBackgroundPaint(WHITE);
        plot.setRangeGridlinePaint(GRAY);
        plot.setDomainGridlinePaint(GRAY);
        plot.setFixedRangeAxisSpace(as);
        plot.setOutlineStroke(stroke);

        for (int i = 0; i < infoList.size(); i++) {
            Color color = PLOT_COLORS[i % PLOT_COLORS.length];

            renderer.setSeriesPaint(i, color);
            renderer.setSeriesStroke(i, new BasicStroke(3)); // Line thickness.

            infoList.get(i).color(Integer.toHexString(color.getRGB()).substring(2));
        }

        ValueAxis axis = plot.getRangeAxis();

        Font font = new Font("Helvetica,Arial,sans-serif", Font.BOLD, axis.getTickLabelFont().getSize() + 5);

        axis.setTickLabelFont(font);
        axis.setLabelFont(font);
        plot.getDomainAxis().setTickLabelFont(font);
        plot.getDomainAxis().setLabelFont(font);

        chart.setTitle(new TextTitle(yAxisLabel, new Font(font.getName(), font.getStyle(), 30)));

        File res = new File(folderToWrite, plotName + ".png");

        ChartUtilities.saveChartAsPNG(res, chart, 1000, 500, info);

        infoMap.put(res.getAbsolutePath(), infoList);

        println("Chart is saved to file: ", res);
    }
}