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

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

Introduction

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

Prototype

public void setStandardTickUnits(TickUnitSource source) 

Source Link

Document

Sets the source for obtaining standard tick units for the axis and sends an AxisChangeEvent to all registered listeners.

Usage

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

private void createChart() {
    _chart = ChartFactory.createScatterPlot(Misc.getString("LIKES_VS_PLAYS"),
            Misc.getString("ALBUM_PLAY_COUNT"), Misc.getString("ALBUM_RATING"), _dataset,
            PlotOrientation.VERTICAL, false, true, false);

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

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

    ChartUtilities.applyCurrentTheme(_chart);

    plot.setDomainPannable(true);//from  w  w  w.j  a v  a2  s. co m
    plot.setRangePannable(true);
    plot.setDomainZeroBaselineVisible(true);
    plot.setRangeZeroBaselineVisible(true);

    plot.setDomainGridlinesVisible(false);
    plot.setRangeGridlinesVisible(false);

    // get rid of the little line above/next to the axis
    plot.setDomainZeroBaselinePaint(Color.white);
    plot.setRangeZeroBaselinePaint(Color.white);

    /*
     * NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
     * domainAxis.setAutoRangeIncludesZero(false);
     * 
     * domainAxis.setTickMarkInsideLength(2.0f);
     * domainAxis.setTickMarkOutsideLength(2.0f);
     * 
     * domainAxis.setMinorTickCount(2);
     * domainAxis.setMinorTickMarksVisible(true);
     */
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    /*
     * rangeAxis.setTickMarkInsideLength(2.0f);
     * rangeAxis.setTickMarkOutsideLength(2.0f);
     * rangeAxis.setMinorTickCount(2);
     * rangeAxis.setMinorTickMarksVisible(true);
     */
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // format the line renderer after applying the theme
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();

    renderer.setBaseShapesVisible(true);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);
    renderer.setBaseFillPaint(Color.white);
    renderer.setSeriesStroke(0, new BasicStroke(3.0f));
    renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f));
    renderer.setSeriesShape(0, new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0));

    Misc.formatChart(plot);
    renderer.setSeriesPaint(0, Theme.getColorSet()[1]);

}

From source file:org.agmip.ui.afsirs.frames.GraphOutput.java

public void addWeather() {
    int nyr = utils.getNYR();
    XYSeries etSeries = new XYSeries("ET");
    double[][] ET = utils.getET();
    for (int i = 0; i < 10/*ET.length*/; i++) {
        for (int j = 0; j < 10/*ET[0].length*/; j++) {
            etSeries.add(i * ET[0].length + j, ET[i][j]);
        }//from  w  w w  .j ava  2 s.  co m
    }

    XYSeries rainSeries = new XYSeries("RAIN");
    double[][] RAIN = utils.getRain();
    for (int i = 0; i < 10/*RAIN.length*/; i++) {
        for (int j = 0; j < 10/*RAIN[0].length*/; j++) {
            rainSeries.add(i * RAIN[0].length + j, RAIN[i][j]);
        }
    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(etSeries);
    dataset.addSeries(rainSeries);

    JFreeChart chart = ChartFactory.createXYLineChart("Weather Data", "Days", "Inches",
            dataset/*,
                   PlotOrientation.VERTICAL, true, true, false*/);
    chart.setBackgroundPaint(Color.white);

    XYPlot plot = chart.getXYPlot();
    plot.setBackgroundPaint(Color.GRAY);
    plot.setDomainGridlinePaint(Color.WHITE);
    plot.setRangeGridlinePaint(Color.white);

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

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

    ChartPanel panel = new ChartPanel(chart);
    jTabbedPane1.addTab("Weather", panel);

}

From source file:edu.ku.brc.specify.toycode.BugParse.java

/**
 * @param lines/*from   w  ww  . j  a  v a2  s  . co m*/
 */
protected void createChart(final List<String> lines, final String engineer) {

    int[] mins = new int[lines.size() - 1];
    for (int index = 1; index < lines.size(); index++) {
        String line = lines.get(index);
        String[] values = StringUtils.splitPreserveAllTokens(line, ",");
        int inx = 0;
        while (inx < values.length && values[inx].equals("0")) {
            inx++;
        }
        mins[index - 1] = inx < values.length ? inx : Integer.MAX_VALUE;
        System.err.println(mins[index - 1]);
    }

    int startInx = Integer.MAX_VALUE;
    for (int min : mins) {
        startInx = Math.min(startInx, min);
        System.out.println(min + "  " + startInx);
    }

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    String[] headers = StringUtils.split(lines.get(0), ",");
    int len = headers.length - startInx;
    System.out.println(headers.length + "  " + len);
    List<double[]> valArray = new Vector<double[]>();

    for (int i = 1; i < lines.size(); i++) {
        String[] values = StringUtils.splitPreserveAllTokens(lines.get(i), ",");
        double[] vals = new double[len];
        int inx = 0;
        double prev = -1;
        for (int j = startInx; j < headers.length; j++) {
            if (StringUtils.isNotEmpty(values[j])) {
                prev = Double.parseDouble(values[j]);
                vals[inx++] = prev;
            } else {
                vals[inx++] = 0.0;
            }
        }
        valArray.add(vals);
    }

    double[] vals = valArray.get(0);
    for (int i = 0; i < vals.length; i++) {
        dataset.addValue(vals[i], "Bugs", headers[i + startInx]);
    }
    vals = valArray.get(1);
    for (int i = 0; i < vals.length; i++) {
        dataset.addValue(vals[i], "Resolved", headers[i + startInx]);
    }

    vals = valArray.get(2);
    for (int i = 0; i < vals.length; i++) {
        dataset.addValue(vals[i], "Open", headers[i + startInx]);
    }

    JFreeChart chart = ChartFactory.createLineChart("Bugs - " + engineer, "Time", "Bugs", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    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(false);
    rangeAxis.setAxisLineVisible(true);

    CategoryAxis catAxis = plot.getDomainAxis();
    catAxis.setAxisLineVisible(true);
    catAxis.setTickMarksVisible(true);

    ChartFrame frame = new ChartFrame("", chart, false);
    frame.setBackground(Color.WHITE);
    frame.setSize(500, 500);
    frame.setVisible(true);
}

From source file:org.hsh.bfr.db.gui.dbtable.editoren.MyChartDialog.java

/**
 * Creates a chart./* w w w  .j a v a2 s .  co m*/
 * 
 * @param dataset  the data for the chart.
 * 
 * @return a chart.
 */
private JFreeChart createChart(final XYDataset dataset, String xAxis, String yAxis) {

    // create the chart...
    final JFreeChart chart = ChartFactory.createXYLineChart("", // chart title
            xAxis, // x axis label
            yAxis, // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, false, // 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.lightGray);
    //plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, 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;

}

From source file:mediamatrix.gui.JVMMemoryProfilerPanel.java

public JVMMemoryProfilerPanel() {
    initComponents();/*w  w w . j  av  a 2 s.c o m*/
    profiler = new JVMMemoryProfiler(frequency);
    profiler.addListener(new JVMMemoryProfilerListener() {

        @Override
        public void addScore(long t, long f) {
            total.add(new Millisecond(), t);
            free.add(new Millisecond(), f);
        }
    });

    total = new TimeSeries("Total Memory");
    total.setMaximumItemCount(historyCount);
    free = new TimeSeries("Free Memory");
    free.setMaximumItemCount(historyCount);

    final TimeSeriesCollection dataset = new TimeSeriesCollection();
    dataset.addSeries(total);
    dataset.addSeries(free);

    final DateAxis domain = new DateAxis("Time");
    final NumberAxis range = new NumberAxis("Memory");
    domain.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    domain.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
    range.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));
    range.setLabelFont(new Font("SansSerif", Font.PLAIN, 14));
    range.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    final XYItemRenderer renderer = new DefaultXYItemRenderer();
    renderer.setSeriesPaint(0, Color.red);
    renderer.setSeriesPaint(1, Color.green);
    renderer.setBaseStroke(new BasicStroke(3f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));

    final XYPlot plot = new XYPlot(dataset, domain, range, renderer);
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    domain.setAutoRange(true);
    domain.setLowerMargin(0.0);
    domain.setUpperMargin(0.0);
    domain.setTickLabelsVisible(true);

    final JFreeChart chart = new JFreeChart("JVM Memory Usage", new Font("SansSerif", Font.BOLD, 24), plot,
            true);
    chart.setBackgroundPaint(Color.white);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4),
            BorderFactory.createLineBorder(Color.black)));
    chart.getLegend().setItemFont(new Font("SansSerif", Font.PLAIN, 12));

    add(chartPanel, BorderLayout.CENTER);
}

From source file:edu.ku.brc.specify.plugins.ipadexporter.ChartHelper.java

/**
 * @param list//from   ww w  .  j a v a  2 s  .  co m
 * @param title
 * @param xAxisTitle
 * @param yAxisTitle
 * @param isVertical
 * @param width
 * @param height
 */
public JFreeChart createLineChart(final List<Object> list, final String title, final String xAxisTitle,
        final String yAxisTitle, final boolean isVertical, final int width, final int height) {
    DefaultCategoryDataset catDataSet = new DefaultCategoryDataset();
    for (int i = 0; i < list.size(); i++) {
        Object xVal = list.get(i++);
        Object yVal = list.get(i);

        double xv = getDbl(xVal);
        numMin = Math.min(numMin, xv);
        numMax = Math.max(numMax, xv);

        catDataSet.addValue(getDbl(yVal), "X", xVal.toString());
    }

    /*XYDataset dataset = createXYDataSet(list);
    JFreeChart chart = ChartFactory.createXYLineChart( 
        title,      // chart title 
        xAxisTitle, // domain axis label 
        yAxisTitle, // range axis label 
        dataset,    // data 
        isVertical ? PlotOrientation.VERTICAL : PlotOrientation.HORIZONTAL, 
        false,       // include legend 
        true,       // tooltips? 
        false       // URLs? 
    ); 
            
    XYPlot xyplot = chart.getXYPlot();
    NumberAxis numberAxis = (NumberAxis) xyplot.getDomainAxis();
    numberAxis.setRange(numMin, numMax);
            
    //ValueAxis axis = xyplot.getDomainAxis();
    //axis = xyplot.getRangeAxis();
    //((NumberAxis) axis).setTickUnit(new NumberTickUnit(1));
    //axis.setRange(1870,2010);*/

    /*
    JFreeChart jfreechart = ChartFactory.createLineChart3D(
        title, 
        xAxisTitle, 
        yAxisTitle, 
        catDataSet, 
        PlotOrientation.VERTICAL, 
        false, 
        true, 
        false);
    jfreechart.setBackgroundPaint(new Color(187, 187, 221));
    CategoryPlot categoryplot = (CategoryPlot)jfreechart.getPlot();
            
    NumberAxis numberaxis = (NumberAxis)categoryplot.getRangeAxis();
    numberaxis.setAutoRangeIncludesZero(false);
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
            
    CategoryItemRenderer renderer = categoryplot.getRenderer(); 
    renderer.setSeriesPaint(0, new Color(95, 158, 160)); 
    renderer.setSeriesOutlinePaint(0, Color.DARK_GRAY); 
    */
    JFreeChart jfreechart = ChartFactory.createLineChart(title, xAxisTitle, yAxisTitle, catDataSet,
            PlotOrientation.VERTICAL, false, true, false);

    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setRangeGridlinePaint(Color.DARK_GRAY);
    categoryplot.setBackgroundPaint(null);

    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setAutoRangeIncludesZero(false);
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    CategoryItemRenderer renderer = categoryplot.getRenderer();
    renderer.setSeriesPaint(0, new Color(95, 158, 160));
    renderer.setSeriesOutlinePaint(0, Color.DARK_GRAY);

    BasicStroke lineStroke = new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND);
    renderer.setBaseStroke(lineStroke);
    renderer.setBaseOutlineStroke(lineStroke);
    renderer.setSeriesStroke(0, lineStroke);

    //renderer.setOutlineStroke(lineStroke);
    //renderer.setStroke(lineStroke);

    return jfreechart;
}

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.  ja v  a 2 s  .co  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:org.sbml.bargraph.MainWindow.java

/**
 * Creates an empty bar graph./* w  w w.j a v a2s  .  co  m*/
 * @return
 */
public JFreeChart createModelBarGraph() {
    // Initialize the style. Have to do this before creating charts.

    BarRenderer.setDefaultShadowsVisible(false);
    ChartFactory.setChartTheme(StandardChartTheme.createLegacyTheme());

    // Create the actual chart.

    chartData = new DefaultCategoryDataset();
    JFreeChart chart = ChartFactory.createBarChart(null, // chart title
            null, // domain axis label
            "Total count", // range axis label
            chartData, // data
            PlotOrientation.HORIZONTAL, // orientation
            false, // include legend
            false, // tooltips?
            false // URLs?
    );

    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.lightGray);
    plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));

    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 12));

    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setSeriesPaint(0, new Color(0, 101, 178));

    return chart;
}

From source file:org.glotaran.core.datadisplayers.common.ImageSVDPanel.java

public void createSVDPlots() {

    int maxSpinnerNumberModel = Math.min(MAX_NUMBER_SINGULAR_VALUES, (int) svdResult[1].getRowCount());
    jTFtotalNumSV//from   w  w  w  .  j  a v  a 2s .co m
            .setText("Max " + maxSpinnerNumberModel + " of  " + String.valueOf(svdResult[1].getRowCount()));
    jSnumSV.setModel(new SpinnerNumberModel((int) 1, (int) 0, maxSpinnerNumberModel, (int) 1));

    //creare collection with first 2 LSV
    XYSeriesCollection lSVCollection = new XYSeriesCollection();
    XYSeries seria;
    seria = new XYSeries("LSV1");
    for (int i = 0; i < timeSteps; i++) {
        seria.add(timeAxe[i], svdResult[0].getAsDouble((long) i, 0));
    }
    lSVCollection.addSeries(seria);

    //creare chart for 2 LSV
    leftSVChart = ChartFactory.createXYLineChart("Left singular vectors", "Time (~s)", null, lSVCollection,
            PlotOrientation.VERTICAL, false, false, false);
    //leftSVChart.getTitle().setFont(new Font(leftSVChart.getTitle().getFont().getFontName(), Font.PLAIN, 12));
    leftSVChart.setBackgroundPaint(JFreeChart.DEFAULT_BACKGROUND_PAINT);
    GraphPanel chpan = new GraphPanel(leftSVChart);
    jPLeftSingVectors.removeAll();
    jPLeftSingVectors.add(chpan);

    //creare collection with first RSV
    double[] tempRsingVec = null;
    double minVal = 0;
    double maxVal = 0;

    //            seria = new XYSeries("RSV" + (j + 1));
    tempRsingVec = new double[imageWitdth * imageHeight];
    double tempValue;
    for (int i = 0; i < imageWitdth * imageHeight; i++) {
        tempValue = svdResult[2].getAsDouble(i, 0);
        tempRsingVec[i] = tempValue;
        minVal = minVal > tempValue ? tempValue : minVal;
        maxVal = maxVal < tempValue ? tempValue : maxVal;
    }

    IntensImageDataset rSingVec = new IntensImageDataset(imageWitdth, imageHeight, tempRsingVec);
    PaintScale ps = new RedGreenPaintScale(minVal, maxVal);
    JFreeChart rSingVect = CommonDataDispTools
            .createScatChart(ImageUtilities.createColorCodedImage(rSingVec, ps), ps, imageWitdth, imageHeight);
    //            rSingVect.setTitle("R Singular vector " + String.valueOf(j + 1));
    //rSingVect.getTitle().setFont(new Font(tracechart.getTitle().getFont().getFontName(), Font.PLAIN, 12));
    ChartPanel rSingVectPanel = new ChartPanel(rSingVect);
    rSingVectPanel.setFillZoomRectangle(true);
    rSingVectPanel.setMouseWheelEnabled(true);

    jPRightSingVectors.removeAll();
    jPRightSingVectors.add(rSingVectPanel);

    //creare collection with singular values
    XYSeriesCollection sVCollection = new XYSeriesCollection();
    seria = new XYSeries("SV");
    for (int i = 0; i < maxSpinnerNumberModel; i++) {
        seria.add(i + 1, svdResult[1].getAsDouble((long) i, (long) i));
    }
    sVCollection.addSeries(seria);

    //create chart for singular values
    JFreeChart tracechart = ChartFactory.createXYLineChart("Screeplot", "Singular Value index (n)", null,
            sVCollection, PlotOrientation.VERTICAL, false, false, false);
    LogAxis logAxe = new LogAxis("Log(SVn)");
    final NumberAxis domainAxis = (NumberAxis) tracechart.getXYPlot().getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    tracechart.getXYPlot().setRangeAxis(logAxe);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) tracechart.getXYPlot().getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setDrawOutlines(true);
    renderer.setUseFillPaint(true);
    renderer.setBaseFillPaint(Color.white);
    renderer.setSeriesStroke(0, new BasicStroke(1.0f));
    renderer.setSeriesOutlineStroke(0, new BasicStroke(1.0f));
    renderer.setSeriesShape(0, new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0));

    //tracechart.getTitle().setFont(new Font(tracechart.getTitle().getFont().getFontName(), Font.PLAIN, 12));
    tracechart.setBackgroundPaint(JFreeChart.DEFAULT_BACKGROUND_PAINT);

    chpan = new GraphPanel(tracechart);
    //add chart with 2 RSV to JPannel
    jPSingValues.removeAll();
    jPSingValues.add(chpan);
}

From source file:gg.view.categoriesbalances.GraphCategoriesBalancesTopComponent.java

/**
 * Displays the categories/sub-categories' balances by period
 * @param balances Categories' balances//from   w ww.  j  av  a 2 s.  c  o  m
 */
private void displayData(Map<Long, Map<SearchCriteria, BigDecimal>> balances) {
    log.info("Categories' balances graph computed and displayed");

    // Display hourglass cursor
    Utilities.changeCursorWaitStatus(true);

    // Create the dataset (that will contain the categories/sub-categories' balances)
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    // Create an empty chart
    JFreeChart chart = ChartFactory.createLineChart("", // chart title
            "", // x axis label
            NbBundle.getMessage(GraphCategoriesBalancesTopComponent.class,
                    "GraphAccountsBalancesTopComponent.Amount"), // y axis label
            dataset, // data displayed in the chart
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );

    // Chart color
    chart.setBackgroundPaint(jPanelCategoriesBalances.getBackground());
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);

    // Grid lines
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

    // Set the orientation of the categories on the domain axis (X axis)
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    // Add the series on the chart for each category/sub-category displayed in the table
    for (Long categoryId : balances.keySet()) {
        Category category = Wallet.getInstance().getCategoriesWithId().get(categoryId);
        assert (category != null);

        SortedSet<SearchCriteria> sortedSearchCriteria = new TreeSet<SearchCriteria>(
                balances.get(categoryId).keySet());
        for (SearchCriteria searchCriteria : sortedSearchCriteria) {

            if ((!searchCriteria.hasCategoriesFilter() && category.isTopCategory()
                    && !category.getSystemProperty()) || searchCriteria.getCategories().contains(category)) {

                BigDecimal balance = new BigDecimal(0);
                if (balances.get(categoryId) != null && balances.get(categoryId).get(searchCriteria) != null) {
                    balance = balances.get(categoryId).get(searchCriteria);
                }

                dataset.addValue(balance, category.getName(), searchCriteria.getPeriod());
            }
        }
    }

    // Series' shapes
    LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer();
    for (int i = 0; i < dataset.getRowCount(); i++) {
        renderer.setSeriesShapesVisible(i, true);
        renderer.setSeriesShape(i, ShapeUtilities.createDiamond(2F));
    }
    // Set the scale of the chart
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setAutoRange(true);
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // Create the chart panel that contains the chart
    ChartPanel chartPanel = new ChartPanel(chart);

    // Display the chart
    jPanelCategoriesBalances.removeAll();
    jPanelCategoriesBalances.add(chartPanel, BorderLayout.CENTER);
    jPanelCategoriesBalances.updateUI();

    // Display normal cursor
    Utilities.changeCursorWaitStatus(false);
}