public class ItemSorter
extends java.lang.Object
implements java.util.Comparator
Modifier and Type | Field and Description |
---|---|
protected static int |
AGGREGATE |
protected static int |
DECORATOR |
protected static int |
EDGE |
protected static int |
ITEM |
Constructor and Description |
---|
ItemSorter() |
Modifier and Type | Method and Description |
---|---|
int |
compare(java.lang.Object o1,
java.lang.Object o2) |
int |
compare(VisualItem v1,
VisualItem v2)
Compare two items based on their ordering scores.
|
int |
score(VisualItem item)
Return an ordering score for an item.
|
protected static final int AGGREGATE
protected static final int EDGE
protected static final int ITEM
protected static final int DECORATOR
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.
item
- the VisualItem to provide an ordering scorepublic int compare(VisualItem v1, VisualItem v2)
score(VisualItem)
on each item and compares the result.v1
- the first VisualItem to comparev2
- the second VisualItem to comparepublic int compare(java.lang.Object o1, java.lang.Object o2)
compare
in interface java.util.Comparator
Comparator.compare(java.lang.Object, java.lang.Object)
,
compare(VisualItem, VisualItem)
Copyright ? 2013 Regents of the University of California