Package org.jdesktop.swingx.decorator
Class Sorter
- java.lang.Object
-
- org.jdesktop.swingx.decorator.Filter
-
- org.jdesktop.swingx.decorator.Sorter
-
- Direct Known Subclasses:
ShuttleSorter
public abstract class Sorter extends Filter
Pluggable sorting filter.
-
-
Field Summary
-
Fields inherited from class org.jdesktop.swingx.decorator.Filter
adapter, fromPrevious, pipeline
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
compare(int row1, int row2)
Compares and returns the entries in row1 vs row2 and returns -1, 0, -1 depending on their being <, ==, > in the current sort direction.protected java.text.Collator
getCollator()
exposed for testing only!java.util.Comparator
getComparator()
SortKey
getSortKey()
SortOrder
getSortOrder()
boolean
isAscending()
protected void
refresh(boolean reset)
Refreshes the internal state of the filter, optionally resetting the cache of existing row mappings from this filter to the previous filter.protected void
refreshCollator()
Subclasses must call this before filtering to guarantee the correct collator!void
setAscending(boolean ascending)
void
setComparator(java.util.Comparator comparator)
set the Comparator to use when comparing values.void
setSortKey(SortKey sortKey)
Updates itself according to the SortKey's properties.void
toggle()
-
Methods inherited from class org.jdesktop.swingx.decorator.Filter
assign, convertRowIndexToModel, convertRowIndexToView, filter, fireFilterChanged, getColumnIndex, getColumnName, getInputSize, getInputString, getInputValue, getMappingFilter, getPipeline, getSize, getStringAt, getValueAt, init, isCellEditable, mapTowardModel, mapTowardView, refresh, reset, setColumnIndex, setValueAt
-
-
-
-
Method Detail
-
refresh
protected void refresh(boolean reset)
Description copied from class:Filter
Refreshes the internal state of the filter, optionally resetting the cache of existing row mappings from this filter to the previous filter. Always performs thefilter
operation and regenerates row mappings from the previous filter. If this filter is bound to a filter pipeline (as most filters are), it also triggers afilterChanged
notification.
-
refreshCollator
protected void refreshCollator()
Subclasses must call this before filtering to guarantee the correct collator!
-
getCollator
protected java.text.Collator getCollator()
exposed for testing only!- Returns:
Collator
-
setComparator
public void setComparator(java.util.Comparator comparator)
set the Comparator to use when comparing values. If not null every compare will be delegated to it. If null the compare will follow the internal compare (no contract, but implemented here as: first check if the values are Comparable, if so delegate, then compare the String representation)- Parameters:
comparator
-
-
getComparator
public java.util.Comparator getComparator()
-
compare
protected int compare(int row1, int row2)
Compares and returns the entries in row1 vs row2 and returns -1, 0, -1 depending on their being <, ==, > in the current sort direction. PRE: getColumnIndex() valid. NOTE: this formerly was public ... and without precondition.- Parameters:
row1
-row2
-- Returns:
- returns -1, 0, -1 depending on row1/row2 being <, ==, > in the current sort direction
-
isAscending
public boolean isAscending()
-
setAscending
public void setAscending(boolean ascending)
-
getSortOrder
public SortOrder getSortOrder()
-
setSortKey
public void setSortKey(SortKey sortKey)
Updates itself according to the SortKey's properties.- Parameters:
sortKey
-- Throws:
java.lang.IllegalArgumentException
- if sortKey = nulljava.lang.IllegalArgumentException
- if !sortKey.sortOrder().isSorted
-
getSortKey
public SortKey getSortKey()
-
toggle
public void toggle()
-
-