prefuse.visual.sort
Class ItemSorter
java.lang.Object
prefuse.visual.sort.ItemSorter
- All Implemented Interfaces:
- java.util.Comparator
- Direct Known Subclasses:
- TreeDepthItemSorter
public class ItemSorter
- extends java.lang.Object
- implements java.util.Comparator
ItemSorter instances provide an integer score for each VisualItem;
these scores are then used to sort the items in ascending order of score.
ItemSorters are used to determine the rendering order of items in a
Display.
- Author:
- jeffrey heer
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface java.util.Comparator |
equals |
AGGREGATE
protected static final int AGGREGATE
- See Also:
- Constant Field Values
EDGE
protected static final int EDGE
- See Also:
- Constant Field Values
ITEM
protected static final int ITEM
- See Also:
- Constant Field Values
DECORATOR
protected static final int DECORATOR
- See Also:
- Constant Field Values
ItemSorter
public ItemSorter()
score
public int score(VisualItem item)
Return an ordering score for an item. The default scoring imparts
the following order:
hover items > highlighted items > items in the
Visualization.FOCUS_ITEMS
set >
Visualization.SEARCH_ITEMS
set >
DecoratorItem instances > normal VisualItem instances. A zero
score is returned for normal items, with scores starting at
1<<27 for other items, leaving the number range beneath that
value open for additional nuanced scoring.
Subclasses can override this method to provide custom sorting
criteria.
- Parameters:
item
- the VisualItem to provide an ordering score
- Returns:
- the ordering score
compare
public int compare(VisualItem v1,
VisualItem v2)
- Compare two items based on their ordering scores. Calls the
score(VisualItem)
on each item and compares the result.
- Parameters:
v1
- the first VisualItem to comparev2
- the second VisualItem to compare
- Returns:
- -1 if score(v1) < score(v2), 1 if score(v1) > score(v2)
and 0 if score(v1) == score(v2).
compare
public int compare(java.lang.Object o1,
java.lang.Object o2)
- Specified by:
compare
in interface java.util.Comparator
- See Also:
Comparator.compare(java.lang.Object, java.lang.Object)
,
compare(VisualItem, VisualItem)
Copyright © 2007 Regents of the University of California