ilog.cpl.list
Class IlpListModelSorter

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by ilog.cpl.list.IlpListModelSorter
All Implemented Interfaces:
Serializable, ListModel

public class IlpListModelSorter
extends AbstractListModel
implements ListModel

This 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.

Since:
JTGO 3.0
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
IlpListModelSorter()
          Default constructor.
IlpListModelSorter(ListModel model)
          Creates a model sorter using the specified model.
 
Method Summary
 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()
           
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface javax.swing.ListModel
addListDataListener, removeListDataListener
 

Constructor Detail

IlpListModelSorter

public IlpListModelSorter()
Default constructor.


IlpListModelSorter

public IlpListModelSorter(ListModel model)
Creates a model sorter using the specified model. The model sorter listens to the given model.

Parameters:
model - The list model this sorter uses.
Method Detail

getModel

public ListModel getModel()
Retrieves the list model sorted by the model sorter.

Returns:
The ListModel encapsulated by the model sorter.

setModel

public void setModel(ListModel model)
Sets the list model to be sorted by the model sorter.

Parameters:
model - The list model to be sorted.

getComparator

public IlpMutableComparator getComparator()
Returns the comparator used to sort the underlying model.

Returns:
The comparator. May be null.
See Also:
setComparator(IlpMutableComparator)

setComparator

public void setComparator(IlpMutableComparator comparator)
Sets the comparator used to sort the underlying model.

Parameters:
comparator - The comparator. May be null. In this case, the model is not sorted, that is, this model exactly reflects the underlying model.

convertRowIndexToModel

public int convertRowIndexToModel(int viewRowIndex)
Maps the row in the view located at 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.

Parameters:
viewRowIndex - The index of the row in the view.
Returns:
The index of the corresponding row in the data source.

convertRowIndexToView

public int convertRowIndexToView(int modelRowIndex)
Maps the row in the list data source located at 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.

Parameters:
modelRowIndex - The index of the row in the data source.
Returns:
The index of the corresponding row in the view.

getSize

public int getSize()
Returns the length of the list.

Specified by:
getSize in interface ListModel

getElementAt

public Object getElementAt(int index)
Returns the value at the specified index.

Specified by:
getElementAt in interface ListModel

toString

public String toString()
Overrides:
toString in class Object


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.   . All Rights Reserved.