本文整理汇总了Java中com.flickr4java.flickr.photos.Extras类的典型用法代码示例。如果您正苦于以下问题:Java Extras类的具体用法?Java Extras怎么用?Java Extras使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Extras类属于com.flickr4java.flickr.photos包,在下文中一共展示了Extras类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: flickrProcess
import com.flickr4java.flickr.photos.Extras; //导入依赖的package包/类
@Override
protected PhotoList<Photo> flickrProcess(String path) {
try {
final GalleriesInterface galleriesInterface = flickr.getGalleriesInterface();
final com.flickr4java.flickr.galleries.Gallery gallery = flickr.getUrlsInterface().lookupGallery(path);
return galleriesInterface.getPhotos(gallery.getId(), Extras.ALL_EXTRAS, 18, 0);
} catch (final Exception e) {
e.printStackTrace();
}
return null;
}
示例2: createFromGallery
import com.flickr4java.flickr.photos.Extras; //导入依赖的package包/类
/**
* Create an image dataset from a flickr gallery with the specified
* parameters. The number of images can be limited to a subset.
*
* @param reader
* the reader with which to load the images
* @param token
* the flickr api authentication token
* @param galleryId
* the Flickr gallery ID
* @param number
* the maximum number of images to add to the dataset. Setting to
* 0 or less will attempt to use all the images.
* @return a {@link FlickrImageDataset} created from the gallery described
* by the given parameters
* @throws Exception
* if an error occurs
*/
public static <IMAGE extends Image<?, IMAGE>> FlickrImageDataset<IMAGE> createFromGallery(
InputStreamObjectReader<IMAGE> reader,
FlickrAPIToken token,
String galleryId, int number) throws Exception
{
final Flickr flickr = makeFlickr(token);
List<Photo> photos = new ArrayList<Photo>();
final PhotoList<Photo> first = flickr.getGalleriesInterface().getPhotos(galleryId, Extras.ALL_EXTRAS, 250, 0);
photos.addAll(first);
if (number > 0)
number = Math.min(number, first.getTotal());
for (int page = 1, n = photos.size(); n < number; page++) {
final PhotoList<Photo> result = flickr.getGalleriesInterface().getPhotos(galleryId, Extras.ALL_EXTRAS, 250,
page);
photos.addAll(result);
n += result.size();
}
if (number > 0 && number < photos.size())
photos = photos.subList(0, number);
return new FlickrImageDataset<IMAGE>(reader, photos);
}
示例3: createFromPhotoset
import com.flickr4java.flickr.photos.Extras; //导入依赖的package包/类
/**
* Create an image dataset from a flickr photoset. The number of images can
* be limited to a subset.
*
* @param reader
* the reader with which to load the images
* @param token
* the flickr api authentication token
* @param setId
* the photoset identifier
* @param number
* the maximum number of images to add to the dataset. Setting to
* 0 or less will attempt to use all the images.
* @return a {@link FlickrImageDataset} created from the gallery described
* by the given parameters
* @throws Exception
* if an error occurs
*/
public static <IMAGE extends Image<?, IMAGE>> FlickrImageDataset<IMAGE> createFromPhotoset(
InputStreamObjectReader<IMAGE> reader,
FlickrAPIToken token,
String setId, int number) throws Exception
{
final Flickr flickr = makeFlickr(token);
final PhotosetsInterface setsInterface = flickr.getPhotosetsInterface();
List<Photo> photos = new ArrayList<Photo>();
final PhotoList<Photo> first = setsInterface.getPhotos(setId, Extras.ALL_EXTRAS, 0, 250, 0);
photos.addAll(first);
if (number > 0)
number = Math.min(number, first.getTotal());
for (int page = 1, n = photos.size(); n < number; page++) {
final PhotoList<Photo> result = setsInterface.getPhotos(setId, Extras.ALL_EXTRAS, 0, 250, page);
photos.addAll(result);
n += result.size();
}
if (number > 0 && number < photos.size())
photos = photos.subList(0, number);
return new FlickrImageDataset<IMAGE>(reader, photos);
}
示例4: retrieveAccountFeed
import com.flickr4java.flickr.photos.Extras; //导入依赖的package包/类
@Override
public Response retrieveAccountFeed(AccountFeed feed, Integer maxRequests) {
Response response = new Response();
List<Post> items = new ArrayList<Post>();
Date dateToRetrieve = feed.getSinceDate();
String label = feed.getLabel();
int page=1, pages=1; //pagination
int numberOfRequests = 0;
//Here we search the user by the userId given (NSID) -
// however we can get NSID via flickrAPI given user's username
String userID = feed.getId();
if(userID == null) {
logger.info("#Flickr : No source feed");
return response;
}
PhotosInterface photosInteface = flickr.getPhotosInterface();
SearchParameters params = new SearchParameters();
params.setUserId(userID);
params.setMinUploadDate(dateToRetrieve);
Set<String> extras = new HashSet<String>(Extras.ALL_EXTRAS);
extras.remove(Extras.MACHINE_TAGS);
params.setExtras(extras);
while(page<=pages && numberOfRequests<=maxRequests) {
PhotoList<Photo> photos;
try {
numberOfRequests++;
photos = photosInteface.search(params , PER_PAGE, page++);
} catch (Exception e) {
break;
}
pages = photos.getPages();
if(photos.isEmpty()) {
break;
}
for(Photo photo : photos) {
String userid = photo.getOwner().getId();
UserAccount streamUser = userMap.get(userid);
if(streamUser == null) {
streamUser = getStreamUser(userid);
userMap.put(userid, streamUser);
}
FlickrPost flickrItem = new FlickrPost(photo);
flickrItem.setLabel(label);
items.add(flickrItem);
}
}
response.setPosts(items);
response.setRequests(numberOfRequests);
return response;
}
示例5: retrieveUserFeeds
import com.flickr4java.flickr.photos.Extras; //导入依赖的package包/类
@Override
public List<Item> retrieveUserFeeds(SourceFeed feed) {
List<Item> items = new ArrayList<Item>();
long currRunningTime = System.currentTimeMillis();
Date dateToRetrieve = feed.getDateToRetrieve();
String label = feed.getLabel();
int page=1, pages=1; //pagination
int numberOfRequests = 0;
int numberOfResults = 0;
//Here we search the user by the userId given (NSID) -
// however we can get NSID via flickrAPI given user's username
Source source = feed.getSource();
String userID = source.getId();
if(userID == null) {
logger.info("#Flickr : No source feed");
return items;
}
PhotosInterface photosInteface = flickr.getPhotosInterface();
SearchParameters params = new SearchParameters();
params.setUserId(userID);
params.setMinUploadDate(dateToRetrieve);
Set<String> extras = new HashSet<String>(Extras.ALL_EXTRAS);
extras.remove(Extras.MACHINE_TAGS);
params.setExtras(extras);
while(page<=pages && numberOfRequests<=maxRequests && numberOfResults<=maxResults &&
(System.currentTimeMillis()-currRunningTime)<maxRunningTime) {
PhotoList<Photo> photos;
try {
numberOfRequests++;
photos = photosInteface.search(params , PER_PAGE, page++);
} catch (Exception e) {
break;
}
pages = photos.getPages();
numberOfResults += photos.size();
if(photos.isEmpty()) {
break;
}
for(Photo photo : photos) {
String userid = photo.getOwner().getId();
StreamUser streamUser = userMap.get(userid);
if(streamUser == null) {
streamUser = getStreamUser(userid);
userMap.put(userid, streamUser);
}
FlickrItem flickrItem = new FlickrItem(photo, streamUser);
flickrItem.setList(label);
items.add(flickrItem);
}
}
//logger.info("#Flickr : Done retrieving for this session");
// logger.info("#Flickr : Handler fetched " + items.size() + " photos from " + userID +
// " [ " + lastItemDate + " - " + new Date(System.currentTimeMillis()) + " ]");
// The next request will retrieve only items of the last day
dateToRetrieve = new Date(System.currentTimeMillis() - (24*3600*1000));
feed.setDateToRetrieve(dateToRetrieve);
return items;
}
示例6: retrieveLocationFeeds
import com.flickr4java.flickr.photos.Extras; //导入依赖的package包/类
@Override
public List<Item> retrieveLocationFeeds(LocationFeed feed){
List<Item> items = new ArrayList<Item>();
long currRunningTime = System.currentTimeMillis();
Date dateToRetrieve = feed.getDateToRetrieve();
String label = feed.getLabel();
Double[][] bbox = feed.getLocation().getbbox();
if(bbox == null || bbox.length==0)
return items;
int page=1, pages=1;
int numberOfRequests = 0;
int numberOfResults = 0;
PhotosInterface photosInteface = flickr.getPhotosInterface();
SearchParameters params = new SearchParameters();
params.setBBox(bbox[0][0].toString(), bbox[0][1].toString(), bbox[1][0].toString(), bbox[1][1].toString());
params.setMinUploadDate(dateToRetrieve);
Set<String> extras = new HashSet<String>(Extras.ALL_EXTRAS);
extras.remove(Extras.MACHINE_TAGS);
params.setExtras(extras);
while(page<=pages && numberOfRequests<=maxRequests && numberOfResults<=maxResults &&
(System.currentTimeMillis()-currRunningTime)<maxRunningTime) {
PhotoList<Photo> photos;
try {
photos = photosInteface.search(params , PER_PAGE, page++);
} catch (FlickrException e) {
break;
}
pages = photos.getPages();
numberOfResults += photos.size();
if(photos.isEmpty()) {
break;
}
for(Photo photo : photos) {
String userid = photo.getOwner().getId();
StreamUser streamUser = userMap.get(userid);
if(streamUser == null) {
streamUser = getStreamUser(userid);
userMap.put(userid, streamUser);
}
FlickrItem flickrItem = new FlickrItem(photo, streamUser);
flickrItem.setList(label);
items.add(flickrItem);
}
}
logger.info("#Flickr : Handler fetched " + items.size() + " photos "+
" [ " + dateToRetrieve + " - " + new Date(System.currentTimeMillis()) + " ]");
return items;
}