本文整理汇总了Java中com.flickr4java.flickr.photos.PhotoList.get方法的典型用法代码示例。如果您正苦于以下问题:Java PhotoList.get方法的具体用法?Java PhotoList.get怎么用?Java PhotoList.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.flickr4java.flickr.photos.PhotoList
的用法示例。
在下文中一共展示了PhotoList.get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: download
import com.flickr4java.flickr.photos.PhotoList; //导入方法依赖的package包/类
@Override
protected void download(Flickr flickr, Element setXml) throws IOException, SAXException, FlickrException {
int pageNum = 1;
int retrievedPhotos = 0;
int totalPhotos = 0;
do {
PhotoList photos = flickr.getPhotosetsInterface().getPhotos(getSetId(), 500, pageNum++);
totalPhotos = photos.getTotal();
for (int i = 0; i < photos.size(); i++) {
retrievedPhotos++;
Photo photo = (Photo) photos.get(i);
Logger.getLogger(Set.class).info("Processing photo " + retrievedPhotos + " of " + totalPhotos + ": " + photo.getUrl());
processPhoto(photo, flickr, setXml);
}
} while (retrievedPhotos < totalPhotos);
}
示例2: PhotosNotInASet
import com.flickr4java.flickr.photos.PhotoList; //导入方法依赖的package包/类
public PhotosNotInASet(Configuration configuration, Flickr flickr) throws IOException, SAXException, FlickrException {
super(configuration);
if(configuration.limitDownloadsToSets.size() > 0) {
return;
}
Logger.getLogger(getClass()).info("Downloading list of photos that are not in a set");
int pageNum = 1;
while (true) {
PhotoList photos = flickr.getPhotosInterface().getNotInSet(500, pageNum);
if (photos.size() == 0)
break;
for (int i = 0; i < photos.size(); i++) {
Photo photo = (Photo) photos.get(i);
if (this.primaryPhotoId == null) {
this.primaryPhotoId = photo.getId();
this.primaryPhotoSmallSquareUrl = photo.getSmallSquareUrl();
}
this.photoSet.add(photo);
}
pageNum++;
}
Logger.getLogger(getClass()).info(String.format("There are a total of %s photos that are not in a set", this.photoSet.size()));
}
示例3: FindPicture
import com.flickr4java.flickr.photos.PhotoList; //导入方法依赖的package包/类
public FindPicture() {
try {
String apikey = "Your API key";
String secret = "Your secret";
Flickr flickr = new Flickr(apikey, secret, new REST());
SearchParameters searchParameters = new SearchParameters();
searchParameters.setBBox("-180", "-90", "180", "90");
searchParameters.setMedia("photos");
PhotoList<Photo> list = flickr.getPhotosInterface().search(searchParameters, 10, 0);
out.println("Image List");
for (int i = 0; i < list.size(); i++) {
Photo photo = list.get(i);
out.println("Image: " + i
+ "\nTitle: " + photo.getTitle()
+ "\nMedia: " + photo.getOriginalFormat()
+ "\nPublic: " + photo.isPublicFlag()
+ "\nPublic: " + photo.isPublicFlag()
+ "\nUrl: " + photo.getUrl()
+ "\n");
}
out.println();
PhotosInterface pi = new PhotosInterface(apikey, secret, new REST());
out.println("pi: " + pi);
Photo currentPhoto = list.get(0);
out.println("currentPhoto url: " + currentPhoto.getUrl());
// Get image using URL
BufferedImage bufferedImage = pi.getImage(currentPhoto.getUrl());
out.println("bi: " + bufferedImage);
// Get image using Photo instance
bufferedImage = pi.getImage(currentPhoto, Size.SMALL);
// Save image to file
out.println("bufferedImage: " + bufferedImage);
File outputfile = new File("image.jpg");
ImageIO.write(bufferedImage, "jpg", outputfile);
} catch (FlickrException | IOException ex) {
ex.printStackTrace();
}
}
开发者ID:PacktPublishing,项目名称:Machine-Learning-End-to-Endguide-for-Java-developers,代码行数:46,代码来源:FindPicture.java