File: PhotoListModel.java

package info (click to toggle)
gpsprune 10-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 2,220 kB
  • ctags: 3,013
  • sloc: java: 22,662; sh: 23; makefile: 16; python: 15
file content (57 lines) | stat: -rw-r--r-- 1,034 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package tim.prune.gui;

import javax.swing.AbstractListModel;

import tim.prune.data.Photo;
import tim.prune.data.PhotoList;

/**
 * Class to act as list model for the photo list
 */
public class PhotoListModel extends AbstractListModel
{
	PhotoList _photos = null;

	/**
	 * Constructor giving PhotoList object
	 * @param inList PhotoList
	 */
	public PhotoListModel(PhotoList inList)
	{
		_photos = inList;
	}

	/**
	 * @see javax.swing.ListModel#getSize()
	 */
	public int getSize()
	{
		return _photos.getNumPhotos();
	}

	/**
	 * @see javax.swing.ListModel#getElementAt(int)
	 */
	public Object getElementAt(int inIndex)
	{
		return _photos.getPhoto(inIndex).getFile().getName();
	}

	/**
	 * Get the Photo at the given index
	 * @param inIndex index number, starting at 0
	 * @return Photo object
	 */
	public Photo getPhoto(int inIndex)
	{
		return _photos.getPhoto(inIndex);
	}

	/**
	 * Fire event to notify that contents have changed
	 */
	public void fireChanged()
	{
		this.fireContentsChanged(this, 0, getSize()-1);
	}
}