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

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

Introduction

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

Prototype

public static TickUnitSource createIntegerTickUnits() 

Source Link

Document

Returns a collection of tick units for integer values.

Usage

From source file:CargarEntrenamiento.grafica2.java

private void configurarDomainAxis(NumberAxis domainAxis) {
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    domainAxis.setTickUnit(new NumberTickUnit(1));
}

From source file:statistic.graph.gui.Charts.java

private static void initXAxis(XYPlot plot, XYDataset dataset) {
    plot.setDomainAxis(new NumberAxis(plot.getDomainAxis().getLabel()));
    XYSeriesCollection collection = (XYSeriesCollection) dataset;
    double max = Double.NEGATIVE_INFINITY;
    double min = Double.POSITIVE_INFINITY;
    if (collection != null) {
        for (int s = 0; s < collection.getSeriesCount(); s++) {
            for (int d = 0; d < collection.getItemCount(s); d++) {
                XYDataItem data = collection.getSeries(s).getDataItem(d);
                if (data.getX().longValue() == Integer.MAX_VALUE
                        || data.getX().longValue() == Integer.MIN_VALUE) {
                    continue;
                }/*from w  w  w. ja v  a 2 s .  co m*/
                if (data.getX().doubleValue() > max) {
                    max = data.getX().doubleValue();
                }
                if (data.getX().doubleValue() < min) {
                    min = data.getX().doubleValue();
                }
            }
        }
        if (min < max) {
            plot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            plot.getDomainAxis().setRange(min - 0.5, max + 0.5);
            for (int s = 0; s < collection.getSeriesCount(); s++) {
                XYSeries series = collection.getSeries(s);
                if (series.indexOf(Integer.MIN_VALUE) >= 0) {
                    XYDataItem item = series.remove((Number) Integer.MIN_VALUE);
                    if (series.indexOf(min) < 0) {
                        series.add(min, item.getY());
                    }
                }
                if (series.indexOf(Integer.MAX_VALUE) >= 0) {
                    XYDataItem item = series.remove((Number) Integer.MAX_VALUE);
                    if (series.indexOf(max) < 0) {
                        series.add(max, item.getY());
                    }
                }
            }
        } else {
            plot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            plot.getDomainAxis().setRange(0 - 0.5, 1 + 0.5);
        }
    } else {
        plot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
        plot.getDomainAxis().setRange(0 - 0.5, 1 + 0.5);
    }
}

From source file:org.ow2.clif.jenkins.chart.FixedSliceSizeDistributionChart.java

@Override
protected JFreeChart createChart() {
    JFreeChart chart = ChartFactory.createHistogram(getBasicTitle(),
            Messages.FixedSliceSizeDistributionChart_ResponseTime(),
            Messages.FixedSliceSizeDistributionChart_NumberOfCalls(), data, PlotOrientation.VERTICAL, true,
            true, false);//  w ww. j  a va2 s  .c  om

    if (data.getSeriesCount() != 0 && data.getItemCount(0) > 0) {

        double rangeStart = data.getStartX(0, 0).doubleValue();
        double rangeEnd = data.getEndX(0, data.getItemCount(0) - 1).doubleValue();

        NumberAxis domainAxis = new HistogramAxis(data, 0);
        domainAxis.setAutoRangeIncludesZero(false);
        domainAxis.setVerticalTickLabels(true);
        domainAxis.setTickLabelsVisible(true);
        domainAxis.setTickMarksVisible(true);

        domainAxis.setRange(rangeStart, rangeEnd);
        chart.getXYPlot().setDomainAxis(domainAxis);

        NumberAxis rangeAxis = (NumberAxis) chart.getXYPlot().getRangeAxis();
        rangeAxis.setAutoRangeIncludesZero(true);
        rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    }

    chart.getXYPlot().setRangeGridlinesVisible(true);
    chart.getXYPlot().setDomainGridlinesVisible(false);
    return chart;
}

From source file:net.nosleep.superanalyzer.analysis.views.WordView.java

public void createChart() {

    _chart = ChartFactory.createBarChart3D(Misc.getString("SONG_WORDS"), // chart title
            Misc.getString("WORD"), // domain axis label
            Misc.getString("SONG_COUNT"), // range axis label
            _dataset, // data
            PlotOrientation.HORIZONTAL, // orientation
            false, // include legend
            true, // tooltips?
            false // URLs?
    );/*from ww  w .  ja v a2  s .c  o m*/

    _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("SONG_WORDS_TOOLTIP")));

    CategoryPlot plot = (CategoryPlot) _chart.getPlot();
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    plot.getRangeAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    ChartUtilities.applyCurrentTheme(_chart);
    Misc.formatChart(plot);

    CategoryItemRenderer renderer = plot.getRenderer();
    BarRenderer3D barRenderer = (BarRenderer3D) renderer;
    barRenderer.setWallPaint(Color.white);
    barRenderer.setSeriesPaint(0, Theme.getColorSet()[1]);
}

From source file:wef.articulab.view.ui.BNCategoryPlot.java

/**
 * Creates a chart.//from   w  w  w.ja  v a 2  s.c o  m
 *
 * @return A chart.
 */
private static JFreeChart createChart() {

    dataset = createDataset();
    NumberAxis rangeAxis1 = new NumberAxis("Value");
    rangeAxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    LineAndShapeRenderer renderer = new LineAndShapeRenderer();
    renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    CategoryPlot subplot = new CategoryPlot(dataset, null, rangeAxis1, renderer);
    subplot.setDomainGridlinesVisible(true);

    CategoryAxis domainAxis = new CategoryAxis("Time");
    CombinedCategoryPlot plot = new CombinedCategoryPlot(domainAxis, new NumberAxis("Activation"));
    plot.add(subplot);

    return new JFreeChart("Social Reasoner Plot", new Font("SansSerif", Font.BOLD, 12), plot, true);
}

From source file:org.hammurapi.inspectors.metrics.reporting.LocCharts.java

private void customizeChartBars(JFreeChart chart) {
    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    // set the background color for the chart...
    chart.setBackgroundPaint(new Color(0xBBBBDD));
    // get a reference to the plot for further customisation...
    XYPlot plot = chart.getXYPlot();/* ww w. j  a va 2 s .  c o m*/
    // set the range axis to display integers only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // disable bar outlines...
    XYItemRenderer renderer = (XYItemRenderer) plot.getRenderer();
    // renderer.ssetDrawBarOutline(false);
    GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray);
    GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray);
    renderer.setSeriesPaint(0, gp1);
    renderer.setSeriesPaint(1, gp2);
    ValueAxis domainAxis = plot.getDomainAxis();
    //domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    //domainAxis.setMaxCategoryLabelWidthRatio(5.0f);
    // OPTIONAL CUSTOMISATION COMPLETED.
}

From source file:pt.ist.expenditureTrackingSystem.presentationTier.actions.statistics.ChartGenerator.java

protected static JFreeChart createBarChart(final CategoryDataset categoryDataset, final String title) {
    final JFreeChart chart = ChartFactory.createBarChart3D(title, "", "", categoryDataset,
            PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(new Color(0xF5, 0xF5, 0xF5));

    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    return chart;
}

From source file:edu.coeia.charts.LineChartPanel.java

/**
 * Creates a sample chart.//from   w ww.java2  s.c o  m
 *
 * @param dataset  a dataset.
 *
 * @return The chart.
 */
private static JFreeChart createChart(final CategoryDataset dataset) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createLineChart("Frequency of Messages", // chart title
            "Time of Messages", // domain axis label
            "Number of Messages", // range axis label
            dataset, // data
            PlotOrientation.VERTICAL, // orientation
            true, // include legend
            true, // tooltips
            false // urls
    );

    chart.setBackgroundPaint(Color.white);

    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setRangeGridlinePaint(Color.white);

    // customise the range axis...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(true);

    // customise the renderer...
    final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    renderer.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 10.0f, 6.0f }, 0.0f));

    renderer.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 6.0f, 6.0f }, 0.0f));

    renderer.setSeriesStroke(2, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 2.0f, 6.0f }, 0.0f));

    return chart;
}

From source file:org.javarebel.chart.generator.ChartGenerator.java

protected void configureChart(JFreeChart chart, ChartData data) {
    ChartConfig config = data.getConfig();
    chart.setBackgroundPaint(/*from   w  w w.  j a v  a 2s.  c o m*/
            (config == null || config.getBackground() == null) ? Color.WHITE : config.getBackground());

    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    PlotConfig plotConfig = new DefaultPlotConfig();
    if (config != null && config.getPlotConfig() != null)
        plotConfig = config.getPlotConfig();
    configurePlot(plot, plotConfig);

    final CategoryItemRenderer renderer = plot.getRenderer();
    ItemLabelConfig labelConfig = new DefaultItemLabelConfig();
    if (config != null && config.getLabelConfig() != null)
        labelConfig = config.getLabelConfig();
    configureBaseItemLabel(renderer, labelConfig);

    renderer.setBaseSeriesVisibleInLegend(data.isLegendVisible());
    if (config != null && config.getForeground() != null)
        renderer.setSeriesPaint(0, config.getForeground());
    else
        renderer.setSeriesPaint(0, data.getSeriesColor());

    DefaultAxisConfig axisConfig = new DefaultAxisConfig();
    if (config != null && config.getAxisConfig() != null)
        axisConfig = config.getAxisConfig();
    configureAxis(plot.getDomainAxis(), axisConfig);

    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
}

From source file:etssi.Graphique.java

/**
 * Creates a chart.//w  ww . ja v  a  2  s.c  o m
 * 
 * @param dataset  the data for the chart.
 * 
 * @return a chart.
 */
private JFreeChart createChart(final XYDataset dataset) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createXYLineChart("Graphique", // chart title
            "Tranche Horaire (0 avant 6h, 1 de 6h  10h, 2 de 10h  16h, 3 de 16h  20h, 4 aprs 20h ", // x axis label
            "Montant passagers", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);

    //        final StandardLegend legend = (StandardLegend) chart.getLegend();
    //      legend.setDisplaySeriesShapes(true);

    // get a reference to the plot for further customisation...
    final XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.black);
    plot.setRangeGridlinePaint(Color.black);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    //renderer.setSeriesLinesVisible(0, false);
    //renderer.setSeriesShapesVisible(1, false);
    //plot.setRenderer(renderer);

    // change the auto tick unit selection to integer units only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}