本文整理汇总了Java中com.flickr4java.flickr.photos.Size类的典型用法代码示例。如果您正苦于以下问题:Java Size类的具体用法?Java Size怎么用?Java Size使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Size类属于com.flickr4java.flickr.photos包,在下文中一共展示了Size类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPhotosFoundEvent
import com.flickr4java.flickr.photos.Size; //导入依赖的package包/类
/**
* Event called when GetFlickrPhotos AsyncTask is done.
*
* @param photosFoundEvent event with photos found
*/
@Subscribe(threadMode = ThreadMode.MAIN)
public void onPhotosFoundEvent(PhotosFoundEvent photosFoundEvent) {
List<List<Size>> photos = photosFoundEvent.getPhotos();
if (photos != null && !photos.isEmpty() && photosFoundEvent.getPoiId().equals(poiId)) {
noPhotos.setVisibility(View.INVISIBLE);
gridPhotos.setVisibility(View.VISIBLE);
imageAdapter = new ImageAdapter(this, poiId);
gridPhotos.setAdapter(imageAdapter);
for (List<Size> size : photos) {
imageAdapter.addPhoto(size.get(Size.SQUARE).getSource(), poiId, Size.SQUARE);
imageAdapter.addPhoto(size.get(Size.ORIGINAL).getSource(), poiId, Size.ORIGINAL);
}
} else {
noPhotos.setVisibility(View.VISIBLE);
gridPhotos.setVisibility(View.INVISIBLE);
}
loadingImage.setVisibility(View.INVISIBLE);
}
示例2: getOriginalVideoUrl
import com.flickr4java.flickr.photos.Size; //导入依赖的package包/类
private static String getOriginalVideoUrl(Flickr flickr, String photoId) throws IOException, FlickrException, SAXException {
String origUrl = null;
String hdUrl = null;
String siteUrl = null;
for (Size size : (Collection<Size>) flickr.getPhotosInterface().getSizes(photoId, true)) {
if (size.getSource().contains("/play/orig"))
origUrl = size.getSource();
else if (size.getSource().contains("/play/hd"))
hdUrl = size.getSource();
else if (size.getSource().contains("/play/site"))
siteUrl = size.getSource();
}
if (origUrl != null)
return origUrl;
else if (hdUrl != null)
return hdUrl;
else if (siteUrl != null)
return siteUrl;
else
return null;
}
示例3: displaySizes
import com.flickr4java.flickr.photos.Size; //导入依赖的package包/类
public void displaySizes(Photo photo) {
out.println("---Sizes----");
Collection<Size> sizes = photo.getSizes();
for (Size size : sizes) {
out.println(size.getLabel());
}
}
开发者ID:PacktPublishing,项目名称:Machine-Learning-End-to-Endguide-for-Java-developers,代码行数:8,代码来源:FindPicture.java
示例4: ImageSizes
import com.flickr4java.flickr.photos.Size; //导入依赖的package包/类
public ImageSizes() {
suffix = new HashMap<>();
suffix.put(Size.SQUARE, "_s");
suffix.put(Size.SQUARE_LARGE, "_q");
suffix.put(Size.THUMB, "_t");
suffix.put(Size.SMALL, "_m");
suffix.put(Size.SMALL_320, "_n");
suffix.put(Size.MEDIUM, "");
suffix.put(Size.MEDIUM_640, "_z");
suffix.put(Size.MEDIUM_800, "_c");
suffix.put(Size.LARGE, "_b");
suffix.put(Size.LARGE_1600, "_h");
suffix.put(Size.LARGE_2048, "_k");
suffix.put(Size.ORIGINAL, "_o");
}
示例5: generateFilename
import com.flickr4java.flickr.photos.Size; //导入依赖的package包/类
private String generateFilename(Photo p, int size) {
String suffix = sizes.getSuffix(size);
if (size == Size.ORIGINAL) {
return p.getId() + "_" + p.getOriginalSecret() + suffix + "." + p.getOriginalFormat();
}
else {
return p.getId() + "_" + p.getSecret() + suffix + ".jpg";
}
}
示例6: getBy
import com.flickr4java.flickr.photos.Size; //导入依赖的package包/类
private BufferedImage getBy(IndexData indexData) {
try {
PhotosInterface photosInterface = flickrFactory.getFlickr().getPhotosInterface();
Photo photo = photosInterface.getPhoto(indexData.getId().getPictureId());
return photosInterface.getImage(photo, Size.SQUARE);
} catch (FlickrException e) {
throw new RuntimeException(e);
}
}
示例7: doInBackground
import com.flickr4java.flickr.photos.Size; //导入依赖的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;
}
示例8: addPhoto
import com.flickr4java.flickr.photos.Size; //导入依赖的package包/类
/**
* Add photo if not in the cache.
* @param url photo url to add.
*/
public void addPhoto(String url, Long poiId, int size) {
if (size == Size.SQUARE && !photoUrlsCachedThumbs.get(poiId).contains(url)) {
photoUrlsCachedThumbs.get(poiId).add(url);
notifyDataSetChanged();
} else if (size == Size.ORIGINAL && !photoUrlsCachedOriginal.get(poiId).contains(url)) {
photoUrlsCachedOriginal.get(poiId).add(url);
}
}
示例9: getFlickrPhotos
import com.flickr4java.flickr.photos.Size; //导入依赖的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;
}
示例10: fetchAndApplySizes
import com.flickr4java.flickr.photos.Size; //导入依赖的package包/类
private void fetchAndApplySizes(String photoId, PhotoDTO dto) throws FlickrException {
Collection<Size> sizes = photoInterface.getSizes(photoId);
for(Size size : sizes) {
if(size.getLabel() == Size.SQUARE) {
dto.setSquareUrl(size.getSource());
}
if(size.getLabel() == Size.MEDIUM_800) {
dto.setFullsizeUrl(size.getSource());
}
}
}
示例11: FindPicture
import com.flickr4java.flickr.photos.Size; //导入依赖的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
示例12: run
import com.flickr4java.flickr.photos.Size; //导入依赖的package包/类
@Override
public void run() {
this.statusLabel.setText("Initializing download process...");
progressBar.setValue(0);
File directory = this.getBackupDirectory();
if (!directory.mkdirs()) {
}
PeopleInterface peopleInt = flickr.getPeopleInterface();
PhotosInterface photoInt = flickr.getPhotosInterface();
int pages = 1;
int page = 1;
int total = 0;
int current = 0;
int error = 0;
Set<String> options = new HashSet<>();
options.add("original_format");
Integer size = Size.ORIGINAL;
try {
do {
RequestContext.getRequestContext().setAuth(this.getAuth());
PhotoList<Photo> list = peopleInt.getPhotos("me", null, null, null, null, null, null, null, options, 500, page);
if (page == 1) {
pages = list.getPages();
total = list.getTotal();
progressBar.setMinimum(0);
progressBar.setMaximum(total);
progressBar.setValue(0);
}
Iterator<Photo> it = list.iterator();
while (it.hasNext() && isRunning) {
current++;
Photo p = it.next();
this.statusLabel.setText("Photo " + current + " of " + total + ": Downloading");
try {
File newFile = new File(directory, this.generateFilename(p, size));
if (!newFile.exists()) {
BufferedInputStream bis = new BufferedInputStream(photoInt.getImageAsStream(p, size));
FileOutputStream fos = new FileOutputStream(newFile);
int read;
byte[] buffer = new byte[100 * 1024];
while ((read = bis.read(buffer)) != -1) {
fos.write(buffer, 0, read);
}
fos.flush();
fos.close();
bis.close();
}
} catch (Exception e) {
error++;
}
progressBar.setValue(current);
}
page++;
} while (page <= pages && isRunning);
statusLabel.setText(isRunning ? "Download of " + total + " photos finished. " + (error == 0 ? "No" : error) + " errors occured!" : "Stopped downloading process. You can resume it at any time.");
} catch (FlickrException ex) {
statusLabel.setText(ex.getMessage());
}
isRunning = false;
updateComponents();
}
示例13: getImage
import com.flickr4java.flickr.photos.Size; //导入依赖的package包/类
private BufferedImage getImage(String pictureId) throws FlickrException {
final PhotosInterface photosInterface = flickrFactory.getFlickr().getPhotosInterface();
Photo photo = photosInterface.getPhoto(pictureId);
return photosInterface.getImage(photo, Size.SQUARE);
}
示例14: onPostExecute
import com.flickr4java.flickr.photos.Size; //导入依赖的package包/类
@Override
protected void onPostExecute(List<List<Size>> photos) {
EventBus.getDefault().post(new PhotosFoundEvent(photos, featurePoi.getId()));
}
示例15: PhotosFoundEvent
import com.flickr4java.flickr.photos.Size; //导入依赖的package包/类
public PhotosFoundEvent(List<List<Size>> photos, Long poiId) {
this.photos = photos;
this.poiId = poiId;
}