Class CRSListModel

All Implemented Interfaces:
Serializable, ListModel<String>

public class CRSListModel extends AbstractListModel<String>
List model class for JCRSChooser. Supports filtering by case-insensitive sub-string matching.
Since:
8.0
Author:
Michael Bedward
See Also:
  • Constructor Details

    • 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
  • Method Details

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