]> gitweb.fperrin.net Git - GpsPrune.git/blob - tim/prune/gui/PhotoListModel.java
Version 2, March 2007
[GpsPrune.git] / tim / prune / gui / PhotoListModel.java
1 package tim.prune.gui;
2
3 import javax.swing.AbstractListModel;
4
5 import tim.prune.data.Photo;
6 import tim.prune.data.PhotoList;
7
8 /**
9  * Class to act as list model for the photo list
10  */
11 public class PhotoListModel extends AbstractListModel
12 {
13         PhotoList _photos = null;
14
15         /**
16          * Constructor giving PhotoList object
17          * @param inList PhotoList
18          */
19         public PhotoListModel(PhotoList inList)
20         {
21                 _photos = inList;
22         }
23
24         /**
25          * @see javax.swing.ListModel#getSize()
26          */
27         public int getSize()
28         {
29                 return _photos.getNumPhotos();
30         }
31
32         /**
33          * @see javax.swing.ListModel#getElementAt(int)
34          */
35         public Object getElementAt(int inIndex)
36         {
37                 return _photos.getPhoto(inIndex).getFile().getName();
38         }
39
40         /**
41          * Get the Photo at the given index
42          * @param inIndex index number, starting at 0
43          * @return Photo object
44          */
45         public Photo getPhoto(int inIndex)
46         {
47                 return _photos.getPhoto(inIndex);
48         }
49
50         /**
51          * Fire event to notify that contents have changed
52          */
53         public void fireChanged()
54         {
55                 this.fireContentsChanged(this, 0, getSize()-1);
56         }
57 }