public class IlpListModelSorter extends AbstractListModel implements ListModel
ListModel
implementation is used to sort the items
in a list.
It encapsulates the ListModel
to be sorted,
as described in the decoration design pattern.
IlpListModelSorter
listens to the model it encapsulates and forwards
the model changes to its own listeners according to the sorting
parameters.
listenerList
Constructor and Description |
---|
IlpListModelSorter()
Default constructor.
|
IlpListModelSorter(ListModel model)
Creates a model sorter using the specified model.
|
Modifier and Type | Method and Description |
---|---|
int |
convertRowIndexToModel(int viewRowIndex)
Maps the row in the view located at
viewRowIndex to the index
of the row in the list data source. |
int |
convertRowIndexToView(int modelRowIndex)
Maps the row in the list data source located at
modelRowIndex
to the index of the row in the view. |
IlpMutableComparator |
getComparator()
Returns the comparator used to sort the underlying model.
|
Object |
getElementAt(int index)
Returns the value at the specified index.
|
ListModel |
getModel()
Retrieves the list model sorted by the model sorter.
|
int |
getSize()
Returns the length of the list.
|
void |
setComparator(IlpMutableComparator comparator)
Sets the comparator used to sort the underlying model.
|
void |
setModel(ListModel model)
Sets the list model to be sorted by the model sorter.
|
String |
toString()
Converts the object into a human-readable format.
|
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addListDataListener, removeListDataListener
public IlpListModelSorter()
public IlpListModelSorter(ListModel model)
model
- The list model this sorter uses.public ListModel getModel()
ListModel
encapsulated by the model sorter.public void setModel(ListModel model)
model
- The list model to be sorted.public IlpMutableComparator getComparator()
null
.setComparator(IlpMutableComparator)
public void setComparator(IlpMutableComparator comparator)
comparator
- The comparator. May be null
. In this case,
the model is not sorted, that is, this model exactly reflects the underlying
model.public int convertRowIndexToModel(int viewRowIndex)
viewRowIndex
to the index
of the row in the list data source.
Returns the index of the corresponding row in the list data source.
If viewRowIndex
is less than zero, returns
viewRowIndex
.viewRowIndex
- The index of the row in the view.public int convertRowIndexToView(int modelRowIndex)
modelRowIndex
to the index of the row in the view.
Returns the index of the corresponding row in the view; returns -1
if the
row is not displayed.
If modelRowIndex
is less than zero, returns
modelRowIndex
.modelRowIndex
- The index of the row in the data source.public int getSize()
public Object getElementAt(int index)
getElementAt
in interface ListModel
© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.