1 package tim.prune.function;
3 import javax.swing.AbstractListModel;
5 import tim.prune.gui.map.MapSource;
6 import tim.prune.gui.map.MapSourceLibrary;
9 * Class to act as list model for the map source list
11 public class MapSourceListModel extends AbstractListModel<String>
14 * @see javax.swing.ListModel#getSize()
18 return MapSourceLibrary.getNumSources();
22 * @see javax.swing.ListModel#getElementAt(int)
24 public String getElementAt(int inIndex)
26 if (inIndex < 0 || inIndex >= getSize()) return "";
27 return MapSourceLibrary.getSource(inIndex).getName();
31 * @param inIndex index in list
32 * @return corresponding map source object
34 public MapSource getSource(int inIndex)
36 if (inIndex < 0 || inIndex >= getSize()) return null;
37 return MapSourceLibrary.getSource(inIndex);
41 * Fire event to notify that contents have changed
43 public void fireChanged()
45 this.fireContentsChanged(this, 0, getSize()-1);