本文整理汇总了Java中org.jfree.data.DefaultKeyedValues.sortByValues方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultKeyedValues.sortByValues方法的具体用法?Java DefaultKeyedValues.sortByValues怎么用?Java DefaultKeyedValues.sortByValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jfree.data.DefaultKeyedValues
的用法示例。
在下文中一共展示了DefaultKeyedValues.sortByValues方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: testSortByValueAscending
import org.jfree.data.DefaultKeyedValues; //导入方法依赖的package包/类
/**
* Tests sorting of data by value (ascending).
*/
public void testSortByValueAscending() {
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);
}
示例4: testSortByValueDescending
import org.jfree.data.DefaultKeyedValues; //导入方法依赖的package包/类
/**
* Tests sorting of data by key (descending).
*/
public void testSortByValueDescending() {
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);
}
示例5: testSortByValueAscending
import org.jfree.data.DefaultKeyedValues; //导入方法依赖的package包/类
/**
* Tests sorting of data by value (ascending).
*/
public void testSortByValueAscending() {
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);
}
示例6: testSortByValueDescending
import org.jfree.data.DefaultKeyedValues; //导入方法依赖的package包/类
/**
* Tests sorting of data by key (descending).
*/
public void testSortByValueDescending() {
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);
}