当前位置: 首页>>代码示例>>Java>>正文


Java PhotoList类代码示例

本文整理汇总了Java中com.flickr4java.flickr.photos.PhotoList的典型用法代码示例。如果您正苦于以下问题:Java PhotoList类的具体用法?Java PhotoList怎么用?Java PhotoList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PhotoList类属于com.flickr4java.flickr.photos包,在下文中一共展示了PhotoList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: invokeService

import com.flickr4java.flickr.photos.PhotoList; //导入依赖的package包/类
private PhotoList<Photo> invokeService(SectionInfo info, FlickrSearchEvent searchEvent) throws FlickrException
{
	FlickrSearchParameters params = searchEvent.getParams();
	PhotoList<Photo> photoList = null;
	int srchOffset = searchEvent.getOffset();
	// Offset is a zero-based logic but flickr uses ordinal page numbers
	// (ie, lowest is "1")
	int pagerCurrentPage = (srchOffset / FlickrUtils.PAGER_PER_PAGE) + 1;

	FlickrSettings flickrSettings = flickrHandler.getFlickrSettings();

	photoList = flickrService.searchOnParams(params, pagerCurrentPage, FlickrUtils.PAGER_PER_PAGE,
		flickrSettings.getApiKey(), flickrSettings.getApiSharedSecret());

	return photoList;
}
 
开发者ID:equella,项目名称:Equella,代码行数:17,代码来源:FlickrSearchResultsSection.java

示例2: testSearchPhotosNoPhotosFound

import com.flickr4java.flickr.photos.PhotoList; //导入依赖的package包/类
@Test
public void testSearchPhotosNoPhotosFound() throws FlickrException {

    PhotoList photoList = new PhotoList();
    Mockito.doReturn(photoList).when(flickrService).searchPhotosAtFlickr(Matchers.any());

    TestPhotoConsumer testPhotoConsumer = new TestPhotoConsumer();
    TestProgressConsumer testProgressConsumer = new TestProgressConsumer();
    TestErrorHandler testErrorHandler = new TestErrorHandler();

    Cancelable searchTask = flickrService.searchPhotos(new String[0], 0.0, 0.0, false, testPhotoConsumer, testProgressConsumer,
            testErrorHandler);

    awaitCompletion(searchTask);

    //make sure no exceptions occurred
    assertFalse(testErrorHandler.exceptionOccurred());

    //make sure that no photos were downloaded
    assertThat(testPhotoConsumer.getAccepted(),empty());

    //make sure accept method at the end was 1.0
    assertThat(testProgressConsumer.getAccepted().size(),is(1));
    assertThat(testProgressConsumer.getAccepted().get(0),is(1.0));
}
 
开发者ID:travelimg,项目名称:travelimg,代码行数:26,代码来源:FlickrServiceTest.java

示例3: flickrProcess

import com.flickr4java.flickr.photos.PhotoList; //导入依赖的package包/类
@Override
protected PhotoList<Photo> flickrProcess(String path) {
	try {
		final CollectionsInterface collectionsInterface = flickr.getCollectionsInterface();
		final Matcher matcher = r.matcher(path);
		matcher.find();
		final String userName = matcher.group(1);
		final String collectionsId = matcher.group(2);

		final List<Collection> collections = collectionsInterface.getTree(collectionsId, userName);

		final PhotoList<Photo> pl = new PhotoList<Photo>();
		for (final Collection c : collections)
			pl.addAll(c.getPhotos());

		return pl;
	} catch (final Exception e) {
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:22,代码来源:FlickrWebpageImageCollection.java

示例4: search

import com.flickr4java.flickr.photos.PhotoList; //导入依赖的package包/类
public List<PhotoDTO> search(String tags, Integer page, Integer perPage) throws HipstaException {
    List<PhotoDTO> list = new ArrayList<>();
    SearchParameters params = new SearchParameters();
    params.setTags(toArray(tags));
    params.setExtras(extras);

    try {
        long start = System.currentTimeMillis();
        PhotoList<Photo> searchResult = photoInterface.search(params, perPage, page);
        log.info("Reading 20 photos over interface took {} ms", (System.currentTimeMillis() - start));
        toTinyPhotoDTOs(list, searchResult);
        return list;
    } catch (FlickrException e) {
        throw new HipstaException(e.getMessage());
    }
}
 
开发者ID:eriklupander,项目名称:hipstacaster,代码行数:17,代码来源:FlickrController.java

示例5: 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);		
}
 
开发者ID:masneyb,项目名称:flickrdownload,代码行数:19,代码来源:Set.java

示例6: doSearch

import com.flickr4java.flickr.photos.PhotoList; //导入依赖的package包/类
protected SearchResults<Photo> doSearch(SectionInfo info, FlickrSearchEvent searchEvent)
{
	// Remove any selections on new search
	results.setSelectedStringValues(info, null);
	SimpleSearchResults<Photo> searchResults = null;
	try
	{
		PhotoList<Photo> photoList = invokeService(info, searchEvent);

		int queryTotal = 0, photoListSize = 0;

		if( photoList != null )
		{
			photoListSize = photoList.size();
			queryTotal = photoList.getTotal();
			searchResults = new SimpleSearchResults<Photo>(photoList, photoListSize, searchEvent.getOffset(),
				queryTotal);
		}
	}
	catch( FlickrException e )
	{
		searchResults = new SimpleSearchResults<Photo>(null, 0, 0, 0);
		String errorMessage = e.getMessage();
		searchResults.setErrorMessage(CurrentLocale.get(SEARCH_ERROR));
		LOGGER.error(errorMessage);
	}

	return searchResults;
}
 
开发者ID:equella,项目名称:Equella,代码行数:30,代码来源:FlickrSearchResultsSection.java

示例7: testSearchPhotos4FoundBut2DontHaveOriginalSecret

import com.flickr4java.flickr.photos.PhotoList; //导入依赖的package包/类
@Test
public void testSearchPhotos4FoundBut2DontHaveOriginalSecret() throws FlickrException {
    PhotoList photoList = new PhotoList();

    //the photos without original secret
    Photo photoWithoutOriginalSecret = new Photo();
    photoWithoutOriginalSecret.setOriginalSecret("");
    photoWithoutOriginalSecret.setTags(new HashSet<Tag>());
    Mockito.doReturn(photoWithoutOriginalSecret).when(flickrService).getInfoForFlickrPhoto(flickrPhotos.get(1));
    Mockito.doReturn(photoWithoutOriginalSecret).when(flickrService).getInfoForFlickrPhoto(flickrPhotos.get(3));

    //the photos with original secret
    Mockito.doReturn(flickrPhotos.get(0)).when(flickrService).getInfoForFlickrPhoto(flickrPhotos.get(0));
    Mockito.doReturn(flickrPhotos.get(2)).when(flickrService).getInfoForFlickrPhoto(flickrPhotos.get(2));

    photoList.addAll(flickrPhotos);
    Mockito.doReturn(photoList).when(flickrService).searchPhotosAtFlickr(Matchers.any());

    TestPhotoConsumer testPhotoConsumer = new TestPhotoConsumer();
    TestProgressConsumer testProgressConsumer = new TestProgressConsumer();
    TestErrorHandler testErrorHandler = new TestErrorHandler();

    Cancelable searchTask = flickrService.searchPhotos(new String[0], 0.0, 0.0, false, testPhotoConsumer, testProgressConsumer,
            testErrorHandler);

    awaitCompletion(searchTask);

    //make sure no exceptions occurred
    assertFalse(testErrorHandler.exceptionOccurred());

    //make sure 2 photos were accepted
    assertThat(testPhotoConsumer.getAccepted().size(),is(2));

    //make sure progress is 1.0 at the end
    assertThat(testProgressConsumer.getAccepted().size(),is(3));
    assertThat(testProgressConsumer.getAccepted().get(0),is(0.25));
    assertThat(testProgressConsumer.getAccepted().get(1),is(0.5));
    assertThat(testProgressConsumer.getAccepted().get(2),is(1.0));

}
 
开发者ID:travelimg,项目名称:travelimg,代码行数:41,代码来源:FlickrServiceTest.java

示例8: idsFromPhotoset

import com.flickr4java.flickr.photos.PhotoList; //导入依赖的package包/类
private Collection<String> idsFromPhotoset(Photoset photoset) throws FlickrException {
    PhotoList<Photo> photos = flickrFactory.getFlickr().getPhotosetsInterface().getPhotos(photoset.getId(), photoset.getPhotoCount(), 1);

    Set<String> ids = new HashSet<>();
    photos.stream().forEach((photo) -> {
        ids.add(photo.getId());
    });

    return ids;
}
 
开发者ID:sapka12,项目名称:mosaicmaker,代码行数:11,代码来源:FlickrCrawler.java

示例9: doInBackground

import com.flickr4java.flickr.photos.PhotoList; //导入依赖的package包/类
@Override
protected List<List<Size>> doInBackground(Void... params) {
    //Create search tags list
    ArrayList<String> searchTags = new ArrayList<String>(TAGS);
    searchTags.add(
            new StringBuilder("osm:")
                    .append((featurePoi.getWay()) ? "way" : "node")
                    .append("=")
                    .append(featurePoi.getBackendId())
                    .toString()
    );

    SearchParameters parameters = new SearchParameters();
    parameters.setLatitude(String.valueOf(latitude));
    parameters.setLongitude(String.valueOf(longitude));
    parameters.setRadius(RADIUS);
    parameters.setTags(searchTags.toArray(new String[searchTags.size()]));
    parameters.setSort(SearchParameters.INTERESTINGNESS_DESC);

    if (!isCancelled()) {
        try {
            PhotoList<Photo> photos = flickr.getPhotosInterface().search(parameters, limitPerPage, nbPage);
            List<List<Size>> photosList = new ArrayList<>();
            for (Photo photo : photos) {
                photosList.add((List<Size>) flickr.getPhotosInterface().getSizes(photo.getId()));
            }
            return photosList;
        } catch (FlickrException e) {
            e.printStackTrace();
        }
    }
    return null;
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:34,代码来源:GetFlickrPhotos.java

示例10: getFlickrPhotos

import com.flickr4java.flickr.photos.PhotoList; //导入依赖的package包/类
/**
	 * @param loc
	 * @return
	 * @throws Exception
	 */
	private static LocPhotoList getFlickrPhotos(Location loc) throws Exception{
		// init photolist
		LocPhotoList photoList = new LocPhotoList();

		// 2DO: Decide which technique should be used
//		PhotoList<Photo> listPhoto =  flickr.getPhotosInterface().search(searchByGeo(loc), 20, 0);
		PhotoList<Photo> listPhoto =  flkr.getPhotosInterface().search(searchByPlaceID(loc), 20, 0);
//		PhotoList<Photo> listPhoto =  flickr.getPhotosInterface().search(searchByFulltext(loc), 20, 0);
		
		// Iterate over all found photos
		for(Photo p:listPhoto){
			Size biggest = null;
			// Look for the biggest picture
			for(Size size:flkr.getPhotosInterface().getSizes(p.getId()))
				if(biggest==null || size.getWidth() > biggest.getWidth())
					biggest = size;
				
			// Add picture to photo-list
			photoList.addPhoto(
				new LocPhoto()
				.setHeight(biggest.getHeight())
				.setWidth(biggest.getWidth())
				.setTitle(p.getTitle())
				//.setURL(biggest.getSource())
			);
			
		}
		// Reverse to get the best picture on first place
		Collections.reverse(photoList.getPhotos());
		
		return photoList;
	}
 
开发者ID:Localizr,项目名称:Localizr,代码行数:38,代码来源:FlickrAPI.java

示例11: createFromGallery

import com.flickr4java.flickr.photos.PhotoList; //导入依赖的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);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:45,代码来源:FlickrImageDataset.java

示例12: createFromPhotoset

import com.flickr4java.flickr.photos.PhotoList; //导入依赖的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);
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:46,代码来源:FlickrImageDataset.java

示例13: 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()));
}
 
开发者ID:masneyb,项目名称:flickrdownload,代码行数:30,代码来源:PhotosNotInASet.java

示例14: findPhoto

import com.flickr4java.flickr.photos.PhotoList; //导入依赖的package包/类
private boolean findPhoto(PhotoList<Photo> photoList, String name) {
    if (photoList == null || name == null)
        return false;
    
    for (int i = 0; i < photoList.size(); i++) {
        if (photoList.get(i).getTitle().equals(name)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:entercritical,项目名称:SwanFlickrUploader,代码行数:12,代码来源:Upload.java

示例15: 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


注:本文中的com.flickr4java.flickr.photos.PhotoList类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。