当前位置: 首页>>代码示例>>Java>>正文


Java DefaultKeyedValues类代码示例

本文整理汇总了Java中org.jfree.data.DefaultKeyedValues的典型用法代码示例。如果您正苦于以下问题:Java DefaultKeyedValues类的具体用法?Java DefaultKeyedValues怎么用?Java DefaultKeyedValues使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DefaultKeyedValues类属于org.jfree.data包,在下文中一共展示了DefaultKeyedValues类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGetIndex

import org.jfree.data.DefaultKeyedValues; //导入依赖的package包/类
/**
 * Some checks for the getIndex() methods.
 */
public void testGetIndex() {
    DefaultKeyedValues v1 = new DefaultKeyedValues();
    assertEquals(-1, v1.getIndex("K1"));

    DefaultKeyedValues v2 = new DefaultKeyedValues();
    v2.addValue("K1", new Integer(1));
    v2.addValue("K2", new Integer(2));
    v2.addValue("K3", new Integer(3));
    assertEquals(2, v2.getIndex("K3"));
    
    // try null
    boolean pass = false;
    try {
        v2.getIndex(null);
    }
    catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:24,代码来源:DefaultKeyedValuesTests.java

示例2: testRemoveValue

import org.jfree.data.DefaultKeyedValues; //导入依赖的package包/类
/**
 * Some tests for the removeValue() method.
 */
public void testRemoveValue() {
    DefaultKeyedValues data = new DefaultKeyedValues();
    data.addValue("A", new Double(1.0));
    data.addValue("B", null);
    data.addValue("C", new Double(3.0));
    data.addValue("D", new Double(2.0));
    assertEquals(1, data.getIndex("B"));
    data.removeValue("B");
    assertEquals(-1, data.getIndex("B"));
    
    boolean pass = true;
    try {
        data.removeValue("XXX");
    }
    catch (Exception e) {
        pass = false;   
    }
    assertTrue(pass);
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:23,代码来源:DefaultKeyedValuesTests.java

示例3: testGetKeys

import org.jfree.data.DefaultKeyedValues; //导入依赖的package包/类
/**
 * Some checks for the getKeys() method.
 */
public void testGetKeys() {
    DefaultKeyedValues d = new DefaultKeyedValues();
    List keys = d.getKeys();
    assertTrue(keys.isEmpty());
    d.addValue("A", 1.0);
    keys = d.getKeys();
    assertEquals(1, keys.size());
    assertTrue(keys.contains("A"));
    d.addValue("B", 2.0);
    keys = d.getKeys();
    assertEquals(2, keys.size());
    assertTrue(keys.contains("A"));
    assertTrue(keys.contains("B"));
    d.clear();
    keys = d.getKeys();
    assertEquals(0, keys.size());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:21,代码来源:DefaultKeyedValuesTests.java

示例4: testGetIndex

import org.jfree.data.DefaultKeyedValues; //导入依赖的package包/类
/**
 * Some checks for the getIndex() methods.
 */
public void testGetIndex() {
    DefaultKeyedValues v1 = new DefaultKeyedValues();
    assertEquals(-1, v1.getIndex("K1"));

    DefaultKeyedValues v2 = new DefaultKeyedValues();
    v2.addValue("K1", new Integer(1));
    v2.addValue("K2", new Integer(2));
    v2.addValue("K3", new Integer(3));
    assertEquals(2, v2.getIndex("K3"));

    // try null
    boolean pass = false;
    try {
        v2.getIndex(null);
    }
    catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:24,代码来源:DefaultKeyedValuesTests.java

示例5: testAddValue

import org.jfree.data.DefaultKeyedValues; //导入依赖的package包/类
/**
 * Some checks for the addValue() method.
 */
public void testAddValue() {
    DefaultKeyedValues v1 = new DefaultKeyedValues();
    v1.addValue("A", 1.0);
    assertEquals(new Double(1.0), v1.getValue("A"));
    v1.addValue("B", 2.0);
    assertEquals(new Double(2.0), v1.getValue("B"));
    v1.addValue("B", 3.0);
    assertEquals(new Double(3.0), v1.getValue("B"));
    assertEquals(2, v1.getItemCount());
    v1.addValue("A", null);
    assertNull(v1.getValue("A"));
    assertEquals(2, v1.getItemCount());

    boolean pass = false;
    try {
        v1.addValue(null, 99.9);
    }
    catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:26,代码来源:DefaultKeyedValuesTests.java

示例6: testInsertValue

import org.jfree.data.DefaultKeyedValues; //导入依赖的package包/类
/**
 * Some checks for the insertValue() method.
 */
public void testInsertValue() {
    DefaultKeyedValues v1 = new DefaultKeyedValues();
    v1.insertValue(0, "A", 1.0);
    assertEquals(new Double(1.0), v1.getValue(0));
    v1.insertValue(0, "B", 2.0);
    assertEquals(new Double(2.0), v1.getValue(0));
    assertEquals(new Double(1.0), v1.getValue(1));

    // it's OK to use an index equal to the size of the list
    v1.insertValue(2, "C", 3.0);
    assertEquals(new Double(2.0), v1.getValue(0));
    assertEquals(new Double(1.0), v1.getValue(1));
    assertEquals(new Double(3.0), v1.getValue(2));

    // try replacing an existing value
    v1.insertValue(2, "B", 4.0);
    assertEquals(new Double(1.0), v1.getValue(0));
    assertEquals(new Double(3.0), v1.getValue(1));
    assertEquals(new Double(4.0), v1.getValue(2));
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:24,代码来源:DefaultKeyedValuesTests.java

示例7: testInsertAndRetrieve

import org.jfree.data.DefaultKeyedValues; //导入依赖的package包/类
/**
 * Check that inserting and retrieving values works as expected.
 */
public void testInsertAndRetrieve() {
    DefaultKeyedValues data = new DefaultKeyedValues();
    data.addValue("A", new Double(1.0));
    data.addValue("B", new Double(2.0));
    data.addValue("C", new Double(3.0));
    data.addValue("D", null);

    // check key order
    assertEquals(data.getKey(0), "A");
    assertEquals(data.getKey(1), "B");
    assertEquals(data.getKey(2), "C");
    assertEquals(data.getKey(3), "D");

    // check retrieve value by key
    assertEquals(data.getValue("A"), new Double(1.0));
    assertEquals(data.getValue("B"), new Double(2.0));
    assertEquals(data.getValue("C"), new Double(3.0));
    assertEquals(data.getValue("D"), null);

    // check retrieve value by index
    assertEquals(data.getValue(0), new Double(1.0));
    assertEquals(data.getValue(1), new Double(2.0));
    assertEquals(data.getValue(2), new Double(3.0));
    assertEquals(data.getValue(3), null);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:29,代码来源:DefaultKeyedValuesTests.java

示例8: testRemoveValue

import org.jfree.data.DefaultKeyedValues; //导入依赖的package包/类
/**
 * Some tests for the removeValue() method.
 */
public void testRemoveValue() {
    DefaultKeyedValues data = new DefaultKeyedValues();
    data.addValue("A", new Double(1.0));
    data.addValue("B", null);
    data.addValue("C", new Double(3.0));
    data.addValue("D", new Double(2.0));
    assertEquals(1, data.getIndex("B"));
    data.removeValue("B");
    assertEquals(-1, data.getIndex("B"));

    boolean pass = false;
    try {
        data.removeValue("XXX");
    }
    catch (UnknownKeyException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:23,代码来源:DefaultKeyedValuesTests.java

示例9: createDataset

import org.jfree.data.DefaultKeyedValues; //导入依赖的package包/类
protected XYDataset createDataset() 
{
	TimeSeriesCollection dataset = new TimeSeriesCollection();        
	DefaultKeyedValues data = new DefaultKeyedValues();		
	Date date = new Date();

	dataset.addSeries(timeSeries);

	return dataset;	
}
 
开发者ID:Will30,项目名称:MonitorYourLAN,代码行数:11,代码来源:Historic.java

示例10: DefaultPieDataset

import org.jfree.data.DefaultKeyedValues; //导入依赖的package包/类
/**
 * Creates a new dataset that uses the data from a {@link KeyedValues} instance.
 *
 * @param data  the data.
 */
public DefaultPieDataset(final KeyedValues data) {

    this.data = new DefaultKeyedValues();
    for (int i = 0; i < data.getItemCount(); i++) {
        this.data.addValue(data.getKey(i), data.getValue(i));
    }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:13,代码来源:DefaultPieDataset.java

示例11: testInsertAndRetrieve

import org.jfree.data.DefaultKeyedValues; //导入依赖的package包/类
/**
 * Problem that inserting and retrieving values works as expected.
 */
public void testInsertAndRetrieve() {

    final DefaultKeyedValues data = new DefaultKeyedValues();
    data.addValue("A", new Double(1.0));
    data.addValue("B", new Double(2.0));
    data.addValue("C", new Double(3.0));
    data.addValue("D", null);

    // check key order
    assertEquals(data.getKey(0), "A");
    assertEquals(data.getKey(1), "B");
    assertEquals(data.getKey(2), "C");
    assertEquals(data.getKey(3), "D");

    // check retrieve value by key
    assertEquals(data.getValue("A"), new Double(1.0));
    assertEquals(data.getValue("B"), new Double(2.0));
    assertEquals(data.getValue("C"), new Double(3.0));
    assertEquals(data.getValue("D"), null);

    // check retrieve value by index
    assertEquals(data.getValue(0), new Double(1.0));
    assertEquals(data.getValue(1), new Double(2.0));
    assertEquals(data.getValue(2), new Double(3.0));
    assertEquals(data.getValue(3), null);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:31,代码来源:DefaultKeyedValuesTests.java

示例12: testSortByKeyAscending

import org.jfree.data.DefaultKeyedValues; //导入依赖的package包/类
/**
 * Tests sorting of data by key (ascending).
 */
public void testSortByKeyAscending() {

    final DefaultKeyedValues data = new DefaultKeyedValues();
    data.addValue("C", new Double(1.0));
    data.addValue("B", null);
    data.addValue("D", new Double(3.0));
    data.addValue("A", new Double(2.0));

    data.sortByKeys(SortOrder.ASCENDING);

    // check key order
    assertEquals(data.getKey(0), "A");
    assertEquals(data.getKey(1), "B");
    assertEquals(data.getKey(2), "C");
    assertEquals(data.getKey(3), "D");

    // check retrieve value by key
    assertEquals(data.getValue("A"), new Double(2.0));
    assertEquals(data.getValue("B"), null);
    assertEquals(data.getValue("C"), new Double(1.0));
    assertEquals(data.getValue("D"), new Double(3.0));

    // check retrieve value by index
    assertEquals(data.getValue(0), new Double(2.0));
    assertEquals(data.getValue(1), null);
    assertEquals(data.getValue(2), new Double(1.0));
    assertEquals(data.getValue(3), new Double(3.0));

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:33,代码来源:DefaultKeyedValuesTests.java

示例13: testSortByKeyDescending

import org.jfree.data.DefaultKeyedValues; //导入依赖的package包/类
/**
 * Tests sorting of data by key (descending).
 */
public void testSortByKeyDescending() {

    final DefaultKeyedValues data = new DefaultKeyedValues();
    data.addValue("C", new Double(1.0));
    data.addValue("B", null);
    data.addValue("D", new Double(3.0));
    data.addValue("A", new Double(2.0));

    data.sortByKeys(SortOrder.DESCENDING);

    // check key order
    assertEquals(data.getKey(0), "D");
    assertEquals(data.getKey(1), "C");
    assertEquals(data.getKey(2), "B");
    assertEquals(data.getKey(3), "A");

    // check retrieve value by key
    assertEquals(data.getValue("A"), new Double(2.0));
    assertEquals(data.getValue("B"), null);
    assertEquals(data.getValue("C"), new Double(1.0));
    assertEquals(data.getValue("D"), new Double(3.0));

    // check retrieve value by index
    assertEquals(data.getValue(0), new Double(3.0));
    assertEquals(data.getValue(1), new Double(1.0));
    assertEquals(data.getValue(2), null);
    assertEquals(data.getValue(3), new Double(2.0));

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:33,代码来源:DefaultKeyedValuesTests.java

示例14: testSortByValueAscending

import org.jfree.data.DefaultKeyedValues; //导入依赖的package包/类
/**
 * Tests sorting of data by value (ascending).
 */
public void testSortByValueAscending() {

    final DefaultKeyedValues data = new DefaultKeyedValues();
    data.addValue("C", new Double(1.0));
    data.addValue("B", null);
    data.addValue("D", new Double(3.0));
    data.addValue("A", new Double(2.0));

    data.sortByValues(SortOrder.ASCENDING);

    // check key order
    assertEquals(data.getKey(0), "C");
    assertEquals(data.getKey(1), "A");
    assertEquals(data.getKey(2), "D");
    assertEquals(data.getKey(3), "B");

    // check retrieve value by key
    assertEquals(data.getValue("A"), new Double(2.0));
    assertEquals(data.getValue("B"), null);
    assertEquals(data.getValue("C"), new Double(1.0));
    assertEquals(data.getValue("D"), new Double(3.0));

    // check retrieve value by index
    assertEquals(data.getValue(0), new Double(1.0));
    assertEquals(data.getValue(1), new Double(2.0));
    assertEquals(data.getValue(2), new Double(3.0));
    assertEquals(data.getValue(3), null);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:33,代码来源:DefaultKeyedValuesTests.java

示例15: testSortByValueDescending

import org.jfree.data.DefaultKeyedValues; //导入依赖的package包/类
/**
 * Tests sorting of data by key (descending).
 */
public void testSortByValueDescending() {

    final DefaultKeyedValues data = new DefaultKeyedValues();
    data.addValue("C", new Double(1.0));
    data.addValue("B", null);
    data.addValue("D", new Double(3.0));
    data.addValue("A", new Double(2.0));

    data.sortByValues(SortOrder.DESCENDING);

    // check key order
    assertEquals(data.getKey(0), "D");
    assertEquals(data.getKey(1), "A");
    assertEquals(data.getKey(2), "C");
    assertEquals(data.getKey(3), "B");

    // check retrieve value by key
    assertEquals(data.getValue("A"), new Double(2.0));
    assertEquals(data.getValue("B"), null);
    assertEquals(data.getValue("C"), new Double(1.0));
    assertEquals(data.getValue("D"), new Double(3.0));

    // check retrieve value by index
    assertEquals(data.getValue(0), new Double(3.0));
    assertEquals(data.getValue(1), new Double(2.0));
    assertEquals(data.getValue(2), new Double(1.0));
    assertEquals(data.getValue(3), null);

}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:33,代码来源:DefaultKeyedValuesTests.java


注:本文中的org.jfree.data.DefaultKeyedValues类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。