1 package tim.prune.data;
3 import java.util.ArrayList;
6 * Class to hold a list of Photos
10 private ArrayList _photos = null;
13 * @return the number of photos in the list
15 public int getNumPhotos()
17 if (_photos == null) return 0;
18 return _photos.size();
23 * Add a List of Photos
24 * @param inList List containing Photo objects
26 public void addPhoto(Photo inPhoto)
28 // Make sure array is initialised
31 _photos = new ArrayList();
42 * Checks if the specified Photo is already in the list
43 * @param inPhoto Photo object to check
44 * @return true if it's already in the list
46 public boolean contains(Photo inPhoto)
48 // Check if we need to check
49 if (getNumPhotos() <= 0 || inPhoto == null || inPhoto.getFile() == null)
51 // Loop around photos in list
52 for (int i=0; i<getNumPhotos(); i++)
54 if (getPhoto(i) != null && getPhoto(i).equals(inPhoto))
65 * Get the Photo at the given index
66 * @param inIndex index number, starting at 0
67 * @return specified Photo object
69 public Photo getPhoto(int inIndex)
71 if (inIndex < 0 || inIndex >= getNumPhotos()) return null;
72 return (Photo) _photos.get(inIndex);
77 * Crop the photo list to the specified size
78 * @param inIndex previous size
80 public void cropTo(int inIndex)
89 // delete photos to previous size
90 while (_photos.size() > inIndex)
92 _photos.remove(_photos.size()-1);
98 * @return array of file names
100 public String[] getNameList()
102 String[] names = new String[getNumPhotos()];
103 for (int i=0; i<getNumPhotos(); i++)
105 names[i] = getPhoto(i).getFile().getName();