⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tablexydatasettests.java

📁 Web图形化的Java库
💻 JAVA
字号:
/* ======================================
 * JFreeChart : a free Java chart library
 * ======================================
 *
 * Project Info:  http://www.jfree.org/jfreechart/index.html
 * Project Lead:  David Gilbert (david.gilbert@object-refinery.com);
 *
 * (C) Copyright 2000-2003, by Object Refinery Limited and Contributors.
 *
 * This library is free software; you can redistribute it and/or modify it under the terms
 * of the GNU Lesser General Public License as published by the Free Software Foundation;
 * either version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with this
 * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * ------------------------
 * TableXYDatasetTests.java
 * ------------------------
 * (C) Copyright 2003 by Richard Atkinson and Contributors.
 *
 * Original Author:  Richard Atkinson;
 * Contributor(s):   -;
 *
 * $Id: TableXYDatasetTests.java,v 1.5 2003/09/03 15:08:51 mungady Exp $
 *
 * Changes
 * -------
 * 11-Aug-2003 : Version 1 (RA);
 * 18-Aug-2003 : Added tests for event notification when removing and updating series (RA);
 *
 */
package org.jfree.data.junit;

import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;

import org.jfree.data.TableXYDataset;
import org.jfree.data.XYSeries;

/**
 * Tests for {@link TableXYDataset}.
 *
 * @author Richard Atkinson
 */
public class TableXYDatasetTests extends TestCase {

    /**
     * Returns the tests as a test suite.
     *
     * @return the test suite.
     */
    public static Test suite() {
        return new TestSuite(TableXYDatasetTests.class);
    }

    /**
     * Constructs a new set of tests.
     *
     * @param  name the name of the tests.
     */
    public TableXYDatasetTests(String name) {
        super(name);
    }

    /**
     * Assorted tests.
     */
    public void testTableXYDataset() {
        
        TableXYDataset tableXYDataSet = new TableXYDataset();
        XYSeries series1 = new XYSeries("Series 1");
        series1.add(1, 1);
        series1.add(2, 1);
        series1.add(4, 1);
        series1.add(5, 1);
        
        XYSeries series2 = new XYSeries("Series 2");
        series2.add(2, 2);
        series2.add(3, 2);
        series2.add(4, 2);
        series2.add(5, 2);
        series2.add(6, 2);

        tableXYDataSet.addSeries(series1);
        tableXYDataSet.addSeries(series2);

        //  Test that there are 6 X points and some specific values
        assertEquals(6, tableXYDataSet.getItemCount());
        assertEquals(6, tableXYDataSet.getXValue(0, 5).intValue());
        assertEquals(0, tableXYDataSet.getYValue(0, 5).intValue());
        assertEquals(6, tableXYDataSet.getXValue(1, 5).intValue());
        assertEquals(2, tableXYDataSet.getYValue(1, 5).intValue());

        series2.add(7, 2);
        //  Test that there are now 7 X points in both series
        assertEquals(7, tableXYDataSet.getItemCount());
        assertEquals(0, tableXYDataSet.getYValue(0, 6).intValue());
        assertEquals(2, tableXYDataSet.getYValue(1, 6).intValue());

        //  Remove series 2
        tableXYDataSet.removeSeries(series1);
        //  Test that there are still 7 X points
        assertEquals(7, tableXYDataSet.getItemCount());

        //  Remove series 1 and add new series
        tableXYDataSet.removeSeries(series2);
        series1 = new XYSeries("Series 1");
        series1.add(1, 1);
        series1.add(2, 1);
        series1.add(4, 1);
        series1.add(5, 1);
        tableXYDataSet.addSeries(series1);

        //  Test that there are now 4 X points
        assertEquals(4, tableXYDataSet.getItemCount());

    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -