org.geotools.swing.dialog
Class CRSListModel

Object
  extended by AbstractListModel
      extended by CRSListModel
All Implemented Interfaces:
Serializable, ListModel

public class CRSListModel
extends AbstractListModel

List model class for JCRSChooser. Supports filtering by case-insensitive sub-string matching.

Since:
8.0
Author:
Michael Bedward
See Also:
Serialized Form

Field Summary
 
Fields inherited from class AbstractListModel
listenerList
 
Constructor Summary
CRSListModel(String authority)
          Constructor.
 
Method Summary
 int findCode(String code)
          Searches for the element with the given code.
 String getCodeAt(int i)
          Gets the code for the given element index.
 String getElementAt(int i)
          
 int getSize()
          
 void setFilter(String subStr)
          Filters the model items by searching for the given sub-string.
 
Methods inherited from class AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CRSListModel

public CRSListModel(String authority)
Constructor. Populates the model with available reference systems for the specified authority. If authority is null or empty, it defaults to JCRSChooser.DEFAULT_AUTHORITY.

Parameters:
authority - the authority name
showDefaults - show GeoTools default reference systems
Method Detail

getSize

public int getSize()

Returns:
the length of the list with the current filter applied

getElementAt

public String getElementAt(int i)

Returns:
a String of the form reference code: description

setFilter

public void setFilter(String subStr)
Filters the model items by searching for the given sub-string. Case is ignored for matching.

Parameters:
subStr - sub-string to filter on; or null or empty string for no filtering

getCodeAt

public String getCodeAt(int i)
Gets the code for the given element index.

Parameters:
i - the index
Returns:
the code

findCode

public int findCode(String code)
Searches for the element with the given code. The search is undertaken on the filtered items.

Parameters:
code - the code to match; may be null or empty in which case -1 is returned
Returns:
index of the matching element or -1 if not found.


Copyright © 1996-2014 Geotools. All Rights Reserved.