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

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

Introduction

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

Prototype

public void setTickLabelFont(Font font) 

Source Link

Document

Sets the font for the tick labels and sends an AxisChangeEvent to all registered listeners.

Usage

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: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);/* www  .jav  a2  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.n52.io.img.ChartRenderer.java

private void configureDomainAxis(XYPlot xyPlot) {
    ValueAxis domainAxis = xyPlot.getDomainAxis();
    domainAxis.setTickLabelFont(FONT_LABEL);
    domainAxis.setLabelFont(FONT_LABEL);
    domainAxis.setTickLabelPaint(COLOR);
    domainAxis.setLabelPaint(COLOR);// w  w w .j  ava 2 s . com
}

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

/**
 * DOC bZhou Comment method "decorateCategoryPlot".
 * //w  ww.j a v  a2 s  .c o  m
 * @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:org.psystems.dicom.browser.server.stat.StatDailyLoadChartServlet2.java

private JFreeChart getChart(CategoryDataset dataset) {

    final JFreeChart chart = ChartFactory.createStackedBarChart("Stacked Bar Chart Demo 4", // chart title
            "Category", // domain axis label
            "", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // the plot orientation
            true, // legend
            true, // tooltips
            false // urls
    );//from w ww.  jav  a 2  s.  c om

    TextTitle title = new TextTitle("   ()", labelFont);
    title.setPaint(new Color(68, 99, 156));
    chart.setTitle(title);

    GroupedStackedBarRenderer renderer = new GroupedStackedBarRenderer();
    KeyToGroupMap map = new KeyToGroupMap("G1");
    map.mapKeyToGroup("product 1 (US)", "G1");
    map.mapKeyToGroup("product 1 (Europe)", "G1");

    renderer.setSeriesToGroupMap(map);

    BarPainter b = new StandardBarPainter();
    //        BarPainter b = new GradientBarPainter(0,0.9,0.9);

    renderer.setBarPainter(b);

    renderer.setSeriesPaint(0, color1);
    renderer.setSeriesPaint(1, color2);

    SubCategoryAxis domainAxis = new SubCategoryAxis("DCM  / JPG ");
    domainAxis.setCategoryMargin(0.05);
    domainAxis.setTickLabelFont(dateFont);
    //        domainAxis.addSubCategory("Product 1");
    //        domainAxis.addSubCategory("Product 2");
    //        domainAxis.addSubCategory("Product 3");

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setDomainAxis(domainAxis);
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.red);
    plot.setRangeGridlinePaint(Color.lightGray);

    ValueAxis v = plot.getRangeAxis();
    v.setTickLabelFont(dateFont);
    //      plot.setRangeAxis(ValueAxis);

    //plot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
    plot.setRenderer(renderer);
    plot.setFixedLegendItems(createLegendItems());
    return chart;

}

From source file:org.psystems.dicom.browser.server.stat.StatClientRequestsChartServlet2.java

private JFreeChart getChart(CategoryDataset dataset) {

    final JFreeChart chart = ChartFactory.createStackedBarChart("Stacked Bar Chart Demo 4", // chart title
            "Category", // domain axis label
            "", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // the plot orientation
            true, // legend
            true, // tooltips
            false // urls
    );/*from  w w w.  j ava2  s . c o m*/

    TextTitle title = new TextTitle("? ? ? (.)",
            labelFont);
    title.setPaint(new Color(68, 99, 156));
    chart.setTitle(title);

    GroupedStackedBarRenderer renderer = new GroupedStackedBarRenderer();
    KeyToGroupMap map = new KeyToGroupMap("G1");
    map.mapKeyToGroup("product 1 (US)", "G1");
    map.mapKeyToGroup("product 1 (Europe)", "G1");

    renderer.setSeriesToGroupMap(map);

    BarPainter b = new StandardBarPainter();
    //        BarPainter b = new GradientBarPainter(0,0.9,0.9);

    renderer.setBarPainter(b);

    renderer.setSeriesPaint(0, color1);
    renderer.setSeriesPaint(1, color2);

    SubCategoryAxis domainAxis = new SubCategoryAxis(" / ");
    domainAxis.setCategoryMargin(0.05);
    domainAxis.setTickLabelFont(dateFont);
    //        domainAxis.addSubCategory("Product 1");
    //        domainAxis.addSubCategory("Product 2");
    //        domainAxis.addSubCategory("Product 3");

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setDomainAxis(domainAxis);
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.red);
    plot.setRangeGridlinePaint(Color.lightGray);

    ValueAxis v = plot.getRangeAxis();
    v.setTickLabelFont(dateFont);
    //      plot.setRangeAxis(ValueAxis);

    //plot.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT);
    plot.setRenderer(renderer);
    plot.setFixedLegendItems(createLegendItems());
    return chart;

}

From source file:org.n52.io.type.quantity.handler.img.ChartIoHandler.java

private void configureDomainAxis(XYPlot plot) {
    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setTickLabelFont(LabelConstants.FONT_LABEL);
    domainAxis.setLabelFont(LabelConstants.FONT_LABEL);
    domainAxis.setTickLabelPaint(LabelConstants.COLOR);
    domainAxis.setLabelPaint(LabelConstants.COLOR);
}

From source file:com.rapidminer.gui.viewer.ROCChartPlotter.java

private JFreeChart createChart(XYDataset dataset) {
    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title
            null, // x axis label
            null, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );/*  w w w . j a v a2  s  .co  m*/

    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

    ValueAxis valueAxis = plot.getRangeAxis();
    valueAxis.setLabelFont(PlotterAdapter.LABEL_FONT_BOLD);
    valueAxis.setTickLabelFont(PlotterAdapter.LABEL_FONT);

    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setLabelFont(PlotterAdapter.LABEL_FONT_BOLD);
    domainAxis.setTickLabelFont(PlotterAdapter.LABEL_FONT);

    DeviationRenderer renderer = new DeviationRenderer(true, false);
    Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
    if (dataset.getSeriesCount() == 1) {
        renderer.setSeriesStroke(0, stroke);
        renderer.setSeriesPaint(0, Color.RED);
        renderer.setSeriesFillPaint(0, Color.RED);
    } else if (dataset.getSeriesCount() == 2) {
        renderer.setSeriesStroke(0, stroke);
        renderer.setSeriesPaint(0, Color.RED);
        renderer.setSeriesFillPaint(0, Color.RED);

        renderer.setSeriesStroke(1, stroke);
        renderer.setSeriesPaint(1, Color.BLUE);
        renderer.setSeriesFillPaint(1, Color.BLUE);
    } else {
        for (int i = 0; i < dataset.getSeriesCount(); i++) {
            renderer.setSeriesStroke(i, stroke);
            Color color = colorProvider.getPointColor((double) i / (double) (dataset.getSeriesCount() - 1));
            renderer.setSeriesPaint(i, color);
            renderer.setSeriesFillPaint(i, color);
        }
    }
    renderer.setAlpha(0.12f);
    plot.setRenderer(renderer);

    // legend settings
    LegendTitle legend = chart.getLegend();
    if (legend != null) {
        legend.setPosition(RectangleEdge.TOP);
        legend.setFrame(BlockBorder.NONE);
        legend.setHorizontalAlignment(HorizontalAlignment.LEFT);
        legend.setItemFont(PlotterAdapter.LABEL_FONT);
    }
    return chart;
}

From source file:com.rapidminer.gui.plotter.charts.DeviationChartPlotter.java

private JFreeChart createChart(XYDataset dataset, boolean createLegend) {

    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title
            null, // x axis label
            null, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, createLegend, // include legend
            true, // tooltips
            false // urls
    );/* w w w.j  a  va 2  s . c om*/

    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customization...
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

    DeviationRenderer renderer = new DeviationRenderer(true, false);
    Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
    if (dataset.getSeriesCount() == 1) {
        renderer.setSeriesStroke(0, stroke);
        renderer.setSeriesPaint(0, Color.RED);
        renderer.setSeriesFillPaint(0, Color.RED);
    } else {
        for (int i = 0; i < dataset.getSeriesCount(); i++) {
            renderer.setSeriesStroke(i, stroke);
            Color color = getColorProvider()
                    .getPointColor((double) i / (double) (dataset.getSeriesCount() - 1));
            renderer.setSeriesPaint(i, color);
            renderer.setSeriesFillPaint(i, color);
        }
    }
    renderer.setAlpha(0.12f);

    plot.setRenderer(renderer);

    ValueAxis valueAxis = plot.getRangeAxis();
    valueAxis.setLabelFont(LABEL_FONT_BOLD);
    valueAxis.setTickLabelFont(LABEL_FONT);

    return chart;
}

From source file:edu.msu.cme.rdp.classifier.train.validation.distance.TaxaSimilarityMain.java

public void createPlot(String plotTitle, File outdir) throws IOException {
    XYSeriesCollection dataset = new XYSeriesCollection();
    DefaultBoxAndWhiskerCategoryDataset scatterDataset = new DefaultBoxAndWhiskerCategoryDataset();

    PrintStream boxchart_dataStream = new PrintStream(new File(outdir, plotTitle + ".boxchart.txt"));

    boxchart_dataStream.println(/*from   ww w .  ja  va 2 s .c  o  m*/
            "#\tkmer" + "\trank" + "\t" + "max" + "\t" + "avg" + "\t" + "min" + "\t" + "Q1" + "\t" + "median"
                    + "\t" + "Q3" + "\t" + "98Pct" + "\t" + "2Pct" + "\t" + "comparisons" + "\t" + "sum");
    for (int i = 0; i < ranks.size(); i++) {
        long[] countArray = sabCoutMap.get(ranks.get(i));
        if (countArray == null)
            continue;

        double sum = 0.0;
        int max = 0;
        int min = 100;
        double mean = 0;
        int Q1 = -1;
        int median = -1;
        int Q3 = -1;
        int pct_98 = -1;
        int pct_2 = -1;
        long comparisons = 0;
        int minOutlier = 0; // we don't care about the outliers
        int maxOutlier = 0; //

        XYSeries series = new XYSeries(ranks.get(i));

        for (int c = 0; c < countArray.length; c++) {
            if (countArray[c] == 0)
                continue;
            comparisons += countArray[c];
            sum += countArray[c] * c;
            if (c < min) {
                min = c;
            }
            if (c > max) {
                max = c;
            }
        }

        // create series
        double cum = 0;
        for (int c = 0; c < countArray.length; c++) {
            if (countArray[c] == 0)
                continue;
            cum += countArray[c];
            int pct = (int) Math.floor(100 * cum / comparisons);
            series.add(c, pct);

            if (pct_2 == -1 && pct >= 5) {
                pct_2 = c;
            }
            if (Q3 == -1 && pct >= 25) {
                Q3 = c;
            }
            if (median == -1 && pct >= 50) {
                median = c;
            }
            if (Q1 == -1 && pct >= 75) {
                Q1 = c;
            }
            if (pct_98 == -1 && pct >= 98) {
                pct_98 = c;
            }
        }
        if (!series.isEmpty()) {
            dataset.addSeries(series);

            BoxAndWhiskerItem item = new BoxAndWhiskerItem(sum / comparisons, median, Q1, Q3, pct_2, pct_98,
                    minOutlier, maxOutlier, new ArrayList());
            scatterDataset.add(item, ranks.get(i), "");

            boxchart_dataStream.println("#\t" + GoodWordIterator.getWordsize() + "\t" + ranks.get(i) + "\t"
                    + max + "\t" + format.format(sum / comparisons) + "\t" + min + "\t" + Q1 + "\t" + median
                    + "\t" + Q3 + "\t" + pct_98 + "\t" + pct_2 + "\t" + comparisons + "\t" + sum);
        }
    }
    boxchart_dataStream.close();
    Font lableFont = new Font("Helvetica", Font.BOLD, 28);

    JFreeChart chart = ChartFactory.createXYLineChart(plotTitle, "Similarity%", "Percent Comparisions", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    ((XYPlot) chart.getPlot()).getRenderer().setStroke(new BasicStroke(2.0f));
    chart.getLegend().setItemFont(new Font("Helvetica", Font.BOLD, 24));
    chart.getTitle().setFont(lableFont);
    ((XYPlot) chart.getPlot()).getDomainAxis().setLabelFont(lableFont);
    ((XYPlot) chart.getPlot()).getDomainAxis().setTickLabelFont(lableFont);
    ValueAxis rangeAxis = ((XYPlot) chart.getPlot()).getRangeAxis();
    rangeAxis.setRange(0, 100);
    rangeAxis.setTickLabelFont(lableFont);
    rangeAxis.setLabelFont(lableFont);
    ((NumberAxis) rangeAxis).setTickUnit(new NumberTickUnit(5));
    ChartUtilities.writeScaledChartAsPNG(new PrintStream(new File(outdir, plotTitle + ".linechart.png")), chart,
            800, 1000, 3, 3);

    BoxPlotUtils.createBoxplot(scatterDataset, new PrintStream(new File(outdir, plotTitle + ".boxchart.png")),
            plotTitle, "Rank", "Similarity%", lableFont);

}