當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyedObjects類代碼示例

本文整理匯總了Java中org.jfree.data.KeyedObjects的典型用法代碼示例。如果您正苦於以下問題:Java KeyedObjects類的具體用法?Java KeyedObjects怎麽用?Java KeyedObjects使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


KeyedObjects類屬於org.jfree.data包,在下文中一共展示了KeyedObjects類的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testGetIndex

import org.jfree.data.KeyedObjects; //導入依賴的package包/類
/**
 * Simple checks for the getIndex(Comparable) method.
 */
public void testGetIndex() {
    KeyedObjects ko1 = new KeyedObjects();
    ko1.addObject("Key 1", "Object 1");
    ko1.addObject("Key 2", null);
    ko1.addObject("Key 3", "Object 2");
    assertEquals(0, ko1.getIndex("Key 1"));
    assertEquals(1, ko1.getIndex("Key 2"));
    assertEquals(2, ko1.getIndex("Key 3"));

    // check null argument
    boolean pass = false;
    try {
        ko1.getIndex(null);
    }
    catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
開發者ID:SpoonLabs,項目名稱:astor,代碼行數:23,代碼來源:KeyedObjectsTests.java

示例2: testInsertAndRetrieve

import org.jfree.data.KeyedObjects; //導入依賴的package包/類
/**
 * Problem that inserting and retrieving values works as expected.
 */
public void testInsertAndRetrieve() {

    final KeyedObjects data = new KeyedObjects();
    data.addObject("A", new Double(1.0));
    data.addObject("B", new Double(2.0));
    data.addObject("C", new Double(3.0));
    data.addObject("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.getObject("A"), new Double(1.0));
    assertEquals(data.getObject("B"), new Double(2.0));
    assertEquals(data.getObject("C"), new Double(3.0));
    assertEquals(data.getObject("D"), null);
    assertEquals(data.getObject("Not a key"), null);

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

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:32,代碼來源:KeyedObjectsTests.java

示例3: testInsertAndRetrieve

import org.jfree.data.KeyedObjects; //導入依賴的package包/類
/**
 * Check that inserting and retrieving values works as expected.
 */
public void testInsertAndRetrieve() {

    KeyedObjects data = new KeyedObjects();
    data.addObject("A", new Double(1.0));
    data.addObject("B", new Double(2.0));
    data.addObject("C", new Double(3.0));
    data.addObject("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.getObject("A"), new Double(1.0));
    assertEquals(data.getObject("B"), new Double(2.0));
    assertEquals(data.getObject("C"), new Double(3.0));
    assertEquals(data.getObject("D"), null);
    assertEquals(data.getObject("Not a key"), null);

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

}
 
開發者ID:parabuild-ci,項目名稱:parabuild-ci,代碼行數:32,代碼來源:KeyedObjectsTests.java

示例4: testInsertAndRetrieve

import org.jfree.data.KeyedObjects; //導入依賴的package包/類
/**
 * Check that inserting and retrieving values works as expected.
 */
public void testInsertAndRetrieve() {

    KeyedObjects data = new KeyedObjects();
    data.addObject("A", new Double(1.0));
    data.addObject("B", new Double(2.0));
    data.addObject("C", new Double(3.0));
    data.addObject("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.getObject("A"), new Double(1.0));
    assertEquals(data.getObject("B"), new Double(2.0));
    assertEquals(data.getObject("C"), new Double(3.0));
    assertEquals(data.getObject("D"), null);

    boolean pass = false;
    try {
        data.getObject("Not a key");
    }
    catch (UnknownKeyException e) {
        pass = true;
    }
    assertTrue(pass);

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

}
 
開發者ID:SpoonLabs,項目名稱:astor,代碼行數:40,代碼來源:KeyedObjectsTests.java

示例5: testSetObject

import org.jfree.data.KeyedObjects; //導入依賴的package包/類
/**
 * Some checks for the setObject(Comparable, Object) method.
 */
public void testSetObject() {
    KeyedObjects ko1 = new KeyedObjects();
    ko1.setObject("Key 1", "Object 1");
    ko1.setObject("Key 2", null);
    ko1.setObject("Key 3", "Object 2");

    assertEquals("Object 1", ko1.getObject("Key 1"));
    assertEquals(null, ko1.getObject("Key 2"));
    assertEquals("Object 2", ko1.getObject("Key 3"));

    // replace an existing value
    ko1.setObject("Key 2", "AAA");
    ko1.setObject("Key 3", "BBB");
    assertEquals("AAA", ko1.getObject("Key 2"));
    assertEquals("BBB", ko1.getObject("Key 3"));

    // try a null key - should throw an exception
    boolean pass = false;
    try {
        ko1.setObject(null, "XX");
    }
    catch (IllegalArgumentException e) {
        pass = true;
    }
    assertTrue(pass);
}
 
開發者ID:SpoonLabs,項目名稱:astor,代碼行數:30,代碼來源:KeyedObjectsTests.java

示例6: testSortByKeyAscending

import org.jfree.data.KeyedObjects; //導入依賴的package包/類
/**
 * Tests sorting of data by key (ascending).
 */
public void testSortByKeyAscending() {
    KeyedObjects data = new KeyedObjects();
    data.addObject("C", new Double(1.0));
    data.addObject("B", null);
    data.addObject("D", new Double(3.0));
    data.addObject("A", new Double(2.0));

    data.sortByKeys(SortOrder.ASCENDING);

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

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

    // check retrieve value by index
    assertEquals(data.getObject(0), new Double(2.0));
    assertEquals(data.getObject(1), null);
    assertEquals(data.getObject(2), new Double(1.0));
    assertEquals(data.getObject(3), new Double(3.0));
}
 
開發者ID:SpoonLabs,項目名稱:astor,代碼行數:31,代碼來源:KeyedObjectsTests.java

示例7: testSortByKeyDescending

import org.jfree.data.KeyedObjects; //導入依賴的package包/類
/**
 * Tests sorting of data by key (descending).
 */
public void testSortByKeyDescending() {
    KeyedObjects data = new KeyedObjects();
    data.addObject("C", new Double(1.0));
    data.addObject("B", null);
    data.addObject("D", new Double(3.0));
    data.addObject("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.getObject("A"), new Double(2.0));
    assertEquals(data.getObject("B"), null);
    assertEquals(data.getObject("C"), new Double(1.0));
    assertEquals(data.getObject("D"), new Double(3.0));

    // check retrieve value by index
    assertEquals(data.getObject(0), new Double(3.0));
    assertEquals(data.getObject(1), new Double(1.0));
    assertEquals(data.getObject(2), null);
    assertEquals(data.getObject(3), new Double(2.0));
}
 
開發者ID:SpoonLabs,項目名稱:astor,代碼行數:31,代碼來源:KeyedObjectsTests.java

示例8: testSortByValueAscending

import org.jfree.data.KeyedObjects; //導入依賴的package包/類
/**
 * Tests sorting of data by value (ascending).
 */
public void testSortByValueAscending() {
    KeyedObjects data = new KeyedObjects();
    data.addObject("C", new Double(1.0));
    data.addObject("B", null);
    data.addObject("D", new Double(3.0));
    data.addObject("A", new Double(2.0));

    data.sortByObjects(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.getObject("A"), new Double(2.0));
    assertEquals(data.getObject("B"), null);
    assertEquals(data.getObject("C"), new Double(1.0));
    assertEquals(data.getObject("D"), new Double(3.0));

    // check retrieve value by index
    assertEquals(data.getObject(0), new Double(1.0));
    assertEquals(data.getObject(1), new Double(2.0));
    assertEquals(data.getObject(2), new Double(3.0));
    assertEquals(data.getObject(3), null);
}
 
開發者ID:SpoonLabs,項目名稱:astor,代碼行數:31,代碼來源:KeyedObjectsTests.java

示例9: testSortByValueDescending

import org.jfree.data.KeyedObjects; //導入依賴的package包/類
/**
 * Tests sorting of data by key (descending).
 */
public void testSortByValueDescending() {
    KeyedObjects data = new KeyedObjects();
    data.addObject("C", new Double(1.0));
    data.addObject("B", null);
    data.addObject("D", new Double(3.0));
    data.addObject("A", new Double(2.0));

    data.sortByObjects(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.getObject("A"), new Double(2.0));
    assertEquals(data.getObject("B"), null);
    assertEquals(data.getObject("C"), new Double(1.0));
    assertEquals(data.getObject("D"), new Double(3.0));

    // check retrieve value by index
    assertEquals(data.getObject(0), new Double(3.0));
    assertEquals(data.getObject(1), new Double(2.0));
    assertEquals(data.getObject(2), new Double(1.0));
    assertEquals(data.getObject(3), null);
}
 
開發者ID:SpoonLabs,項目名稱:astor,代碼行數:31,代碼來源:KeyedObjectsTests.java

示例10: DefaultPieDataset

import org.jfree.data.KeyedObjects; //導入依賴的package包/類
/**
 * Creates a new dataset by copying data from a {@link KeyedValues}
 * instance.
 *
 * @param data  the data (<code>null</code> not permitted).
 */
public DefaultPieDataset(KeyedValues data) {
    if (data == null) {
        throw new IllegalArgumentException("Null 'data' argument.");
    }
    this.data = new KeyedObjects();
    for (int i = 0; i < data.getItemCount(); i++) {
        SelectableValue dataItem = new SelectableValue(data.getValue(i));
        this.data.addObject(data.getKey(i), dataItem);
    }
}
 
開發者ID:SpoonLabs,項目名稱:astor,代碼行數:17,代碼來源:DefaultPieDataset.java


注:本文中的org.jfree.data.KeyedObjects類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。