edu.washington.biostr.sig.brainj3d.shwing.swing
Class AutoCompleteModel

java.lang.Object
  extended by edu.washington.biostr.sig.brainj3d.shwing.swing.AutoCompleteModel
All Implemented Interfaces:
Comparator<String>, ListModel

public class AutoCompleteModel
extends Object
implements ListModel, Comparator<String>

An AutoCompleteModel is a ListModel for the autocomplete. It is backed by a set that does not allow duplicate values and it only ever shows a portion of backing data based on the prefix passed to it.

Author:
eider

Constructor Summary
AutoCompleteModel()
           
 
Method Summary
 void addElement(String str)
          Add the element to the set of possibilities and if the element would be shown, add it to the current set and fire an event.
 void addListDataListener(ListDataListener l)
           
 int compare(String o1, String o2)
           
 boolean equals(Object obj)
           
 boolean filter(String prefix)
          Filter the current list model so that only those items that start with prefix are shown.
protected  void filterCurrent(String prefix)
           
protected  void fireIntervalAdded(int start, int end)
           
protected  void fireIntervalChanged(int start, int end)
           
protected  void fireIntervalRemove(int start, int end)
           
 Object getElementAt(int index)
           
static AutoCompleteModel getModelForDomain(String domain)
          Get the model for the given domain or create a new one.
 int getSize()
           
 int hashCode()
           
 void removeListDataListener(ListDataListener l)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AutoCompleteModel

public AutoCompleteModel()
Method Detail

getModelForDomain

public static AutoCompleteModel getModelForDomain(String domain)
Get the model for the given domain or create a new one. The domain should be a keyword that is unique for a given name.

Parameters:
domain -
Returns:
Throws:
IllegalArgumentException - if domain is null or "" or it starts with a digit.

getSize

public int getSize()
Specified by:
getSize in interface ListModel

getElementAt

public Object getElementAt(int index)
Specified by:
getElementAt in interface ListModel

addListDataListener

public void addListDataListener(ListDataListener l)
Specified by:
addListDataListener in interface ListModel

removeListDataListener

public void removeListDataListener(ListDataListener l)
Specified by:
removeListDataListener in interface ListModel

addElement

public void addElement(String str)
Add the element to the set of possibilities and if the element would be shown, add it to the current set and fire an event.

Parameters:
str -

fireIntervalAdded

protected void fireIntervalAdded(int start,
                                 int end)

fireIntervalChanged

protected void fireIntervalChanged(int start,
                                   int end)

fireIntervalRemove

protected void fireIntervalRemove(int start,
                                  int end)

filter

public boolean filter(String prefix)
Filter the current list model so that only those items that start with prefix are shown. Return true if there is any data left in the model and false otherwise.

Parameters:
prefix -
Returns:

filterCurrent

protected void filterCurrent(String prefix)

compare

public int compare(String o1,
                   String o2)
Specified by:
compare in interface Comparator<String>

equals

public boolean equals(Object obj)
Specified by:
equals in interface Comparator<String>
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2006 University of Washington. All Rights Reserved.