Java 类org.jfree.data.xy.VectorSeries 实例源码

项目:astor    文件:VectorSeriesTests.java   
/**
 * Some checks for the add() method for an UNSORTED series.
 */
public void testAdd() {
    VectorSeries series = new VectorSeries("Series", false, true);
    series.add(5.0, 5.50, 5.50, 5.50);
    series.add(5.1, 5.51, 5.51, 5.51);
    series.add(6.0, 6.6, 6.6, 6.6);
    series.add(3.0, 3.3, 3.3, 3.3);
    series.add(4.0, 4.4, 4.4, 4.4);
    series.add(2.0, 2.2, 2.2, 2.2);
    series.add(1.0, 1.1, 1.1, 1.1);
    assertEquals(5.5, series.getVectorXValue(0), EPSILON);
    assertEquals(5.51, series.getVectorXValue(1), EPSILON);
    assertEquals(6.6, series.getVectorXValue(2), EPSILON);
    assertEquals(3.3, series.getVectorXValue(3), EPSILON);
    assertEquals(4.4, series.getVectorXValue(4), EPSILON);
    assertEquals(2.2, series.getVectorXValue(5), EPSILON);
    assertEquals(1.1, series.getVectorXValue(6), EPSILON);
}
项目:astor    文件:VectorSeriesCollectionTests.java   
/**
 * Confirm that the equals method can distinguish all the required fields.
 */
public void testEquals() {
    VectorSeries s1 = new VectorSeries("Series");
    s1.add(1.0, 1.1, 1.2, 1.3);
    VectorSeriesCollection c1 = new VectorSeriesCollection();
    c1.addSeries(s1);
    VectorSeries s2 = new VectorSeries("Series");
    s2.add(1.0, 1.1, 1.2, 1.3);
    VectorSeriesCollection c2 = new VectorSeriesCollection();
    c2.addSeries(s2);
    assertTrue(c1.equals(c2));
    assertTrue(c2.equals(c1));

    c1.addSeries(new VectorSeries("Empty Series"));
    assertFalse(c1.equals(c2));

    c2.addSeries(new VectorSeries("Empty Series"));
    assertTrue(c1.equals(c2));
}
项目:astor    文件:VectorSeriesCollectionTests.java   
/**
 * Some checks for the removeSeries() method.
 */
public void testRemoveSeries() {
    VectorSeries s1 = new VectorSeries("S1");
    VectorSeries s2 = new VectorSeries("S2");
    VectorSeriesCollection vsc = new VectorSeriesCollection();
    vsc.addSeries(s1);
    vsc.addSeries(s2);
    assertEquals(2, vsc.getSeriesCount());
    boolean b = vsc.removeSeries(s1);
    assertTrue(b);
    assertEquals(1, vsc.getSeriesCount());
    assertEquals("S2", vsc.getSeriesKey(0));
    b = vsc.removeSeries(new VectorSeries("NotInDataset"));
    assertFalse(b);
    assertEquals(1, vsc.getSeriesCount());
    b = vsc.removeSeries(s2);
    assertTrue(b);
    assertEquals(0, vsc.getSeriesCount());
}
项目:astor    文件:VectorSeriesTests.java   
/**
 * Simple test for the indexOf() method.
 */
public void testIndexOf() {
    VectorSeries s1 = new VectorSeries("Series 1");
    s1.add(1.0, 1.0, 1.0, 2.0);
    s1.add(2.0, 2.0, 2.0, 3.0);
    s1.add(3.0, 3.0, 3.0, 4.0);
    assertEquals(0, s1.indexOf(new XYCoordinate(1.0, 1.0)));
}
项目:astor    文件:VectorSeriesTests.java   
/**
 * A check for the indexOf() method for an unsorted series.
 */
public void testIndexOf2() {
    VectorSeries s1 = new VectorSeries("Series 1");
    s1.add(1.0, 1.0, 1.0, 2.0);
    s1.add(3.0, 3.0, 3.0, 3.0);
    s1.add(2.0, 2.0, 2.0, 2.0);
    assertEquals(0, s1.indexOf(new XYCoordinate(1.0, 1.0)));
    assertEquals(1, s1.indexOf(new XYCoordinate(3.0, 3.0)));
    assertEquals(2, s1.indexOf(new XYCoordinate(2.0, 2.0)));
}
项目:astor    文件:VectorSeriesTests.java   
/**
 * Simple test for the remove() method.
 */
public void testRemove() {
    VectorSeries s1 = new VectorSeries("Series 1");
    s1.add(1.0, 1.0, 1.0, 2.0);
    s1.add(3.0, 3.0, 3.0, 3.0);
    s1.add(2.0, 2.0, 2.0, 2.0);
    assertEquals(3, s1.getItemCount());

    s1.remove(new XYCoordinate(2.0, 2.0));
    assertEquals(3.0, s1.getXValue(1), EPSILON);

    s1.remove(new XYCoordinate(1.0, 1.0));
    assertEquals(3.0, s1.getXValue(0), EPSILON);
}
项目:astor    文件:VectorSeriesTests.java   
/**
 * When items are added with duplicate x-values, we expect them to remain
 * in the order they were added.
 */
public void testAdditionOfDuplicateXValues() {
    VectorSeries s1 = new VectorSeries("Series 1");
    s1.add(1.0, 1.0, 1.0, 1.0);
    s1.add(2.0, 2.0, 2.0, 2.0);
    s1.add(2.0, 2.0, 3.0, 3.0);
    s1.add(2.0, 3.0, 4.0, 4.0);
    s1.add(3.0, 5.0, 5.0, 5.0);
    assertEquals(1.0, s1.getVectorXValue(0), EPSILON);
    assertEquals(2.0, s1.getVectorXValue(1), EPSILON);
    assertEquals(3.0, s1.getVectorXValue(2), EPSILON);
    assertEquals(4.0, s1.getVectorXValue(3), EPSILON);
    assertEquals(5.0, s1.getVectorXValue(4), EPSILON);
}
项目:astor    文件:VectorSeriesTests.java   
/**
 * A simple check that the maximumItemCount attribute is working.
 */
public void testSetMaximumItemCount() {
    VectorSeries s1 = new VectorSeries("S1");
    assertEquals(Integer.MAX_VALUE, s1.getMaximumItemCount());
    s1.setMaximumItemCount(2);
    assertEquals(2, s1.getMaximumItemCount());
    s1.add(1.0, 1.1, 1.1, 1.1);
    s1.add(2.0, 2.2, 2.2, 2.2);
    s1.add(3.0, 3.3, 3.3, 3.3);
    assertEquals(2.0, s1.getXValue(0), EPSILON);
    assertEquals(3.0, s1.getXValue(1), EPSILON);
}
项目:astor    文件:VectorSeriesTests.java   
/**
 * Check that the maximum item count can be applied retrospectively.
 */
public void testSetMaximumItemCount2() {
    VectorSeries s1 = new VectorSeries("S1");
    s1.add(1.0, 1.1, 1.1, 1.1);
    s1.add(2.0, 2.2, 2.2, 2.2);
    s1.add(3.0, 3.3, 3.3, 3.3);
    s1.setMaximumItemCount(2);
    assertEquals(2.0, s1.getXValue(0), EPSILON);
    assertEquals(3.0, s1.getXValue(1), EPSILON);
}
项目:astor    文件:VectorSeriesTests.java   
/**
 * Some checks for the clear() method.
 */
public void testClear() {
    VectorSeries s1 = new VectorSeries("S1");
    s1.addChangeListener(this);
    s1.clear();
    assertNull(this.lastEvent);
    assertTrue(s1.isEmpty());
    s1.add(1.0, 2.0, 3.0, 4.0);
    assertFalse(s1.isEmpty());
    s1.clear();
    assertNotNull(this.lastEvent);
    assertTrue(s1.isEmpty());
}