X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=tim%2Fprune%2Fdata%2FPhotoList.java;h=454055309285340476057efe4a51ad86a152ec74;hb=f35b6d628f68e3b5ef19965ad8988d0dd1eb8efa;hp=ac10edfafd8d3335dd87f50fb48c4b0e46f0637a;hpb=23959e65a6a0d581e657b07186d18b7a1ac5afeb;p=GpsPrune.git diff --git a/tim/prune/data/PhotoList.java b/tim/prune/data/PhotoList.java index ac10edf..4540553 100644 --- a/tim/prune/data/PhotoList.java +++ b/tim/prune/data/PhotoList.java @@ -3,107 +3,97 @@ package tim.prune.data; import java.util.ArrayList; /** - * Class to hold a list of Photos + * Class to hold a list of Photos, using the MediaList superclass */ -public class PhotoList +public class PhotoList extends MediaList { - private ArrayList _photos = null; + /** + * Empty constructor + */ + public PhotoList() { + this(null); + } /** - * @return the number of photos in the list + * Constructor + * @param inList ArrayList containing Photo objects */ - public int getNumPhotos() + private PhotoList(ArrayList inList) { + super(inList); + } + + /** + * @return clone of list contents + */ + public PhotoList cloneList() { - if (_photos == null) return 0; - return _photos.size(); + if (getNumMedia() == 0) return this; + ArrayList listCopy = new ArrayList(); + listCopy.addAll(_media); + return new PhotoList(listCopy); } + /** + * @return the number of photos in the list + */ + public int getNumPhotos() { + return getNumMedia(); + } /** - * Add a List of Photos - * @param inList List containing Photo objects + * Add a Photo to the list + * @param inPhoto Photo object to add */ - public void addPhoto(Photo inPhoto) - { - // Make sure array is initialised - if (_photos == null) - { - _photos = new ArrayList(); - } - // Add the photo - if (inPhoto != null) - { - _photos.add(inPhoto); - } + public void addPhoto(Photo inPhoto) { + addMedia(inPhoto); } + /** + * Add a Photo to the list + * @param inPhoto Photo object to add + * @param inIndex index at which to add photo + */ + public void addPhoto(Photo inPhoto, int inIndex) { + addMedia(inPhoto, inIndex); + } /** - * Checks if the specified Photo is already in the list - * @param inPhoto Photo object to check - * @return true if it's already in the list + * Remove the selected photo from the list + * @param inIndex index number to remove */ - public boolean contains(Photo inPhoto) - { - // Check if we need to check - if (getNumPhotos() <= 0 || inPhoto == null || inPhoto.getFile() == null) - return false; - // Loop around photos in list - for (int i=0; i= getNumPhotos()) return null; - return (Photo) _photos.get(inIndex); + public Photo getPhoto(int inIndex) { + return (Photo) getMedia(inIndex); } - /** - * Crop the photo list to the specified size - * @param inIndex previous size + * @return true if photo list contains correlated photos */ - public void cropTo(int inIndex) - { - if (inIndex <= 0) - { - // delete whole list - _photos.clear(); - } - else - { - // delete photos to previous size - while (_photos.size() > inIndex) - { - _photos.remove(_photos.size()-1); - } - } + public boolean hasCorrelatedPhotos() { + return hasCorrelatedMedia(); } /** - * @return array of file names + * Remove all correlated photos from the list */ - public String[] getNameList() - { - String[] names = new String[getNumPhotos()]; - for (int i=0; i