|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jickr.Photo
public class Photo
Encapsulates Photo information. Includes a few static methods to search for photos. Keeps a cache of the backing Images, adjustable in size by the user. Photo objects are typically created via a find method, via the search method, or, less commonly, by supplying the id (and possibly the secret) in a constructor.
Nested Class Summary | |
---|---|
static class |
Photo.Allowed
List of possible permissions allowed for a Photo. |
class |
Photo.PhotoSize
PhotoSize encapsulates information for a certain size of a photo. |
static class |
Photo.Size
List of possibly valid Photo sizes. |
Constructor Summary | |
---|---|
Photo(java.lang.String id)
Sometimes, all you know is the PhotoID - if you are authenticated, with READ privlege on the photo in question (or if the Photo is public), this is enough to get the Photo information. |
|
Photo(java.lang.String id,
java.lang.String secret)
If you know the ID and the Secret of a photo, you can use it to create a new Photo object. |
Method Summary | |
---|---|
java.lang.String |
addComment(java.lang.String commentText)
Adds a comment to this Photo, returns the new comment ID. |
void |
addFavorite()
Add this photo as favorite to the authenticated user. |
java.lang.String |
addNote(java.awt.Rectangle area,
java.lang.String text)
Add a Note to a Photo. |
void |
addTags(java.lang.String tags)
Adds tags to this Photo. |
boolean |
canAddMeta()
Returns whether someone with the authenticated user's permissions can add metadata to the photo. |
boolean |
canComment()
Returns whether someone with the authenticated user's permissions can comment on the photo. |
int |
compareTo(Photo p)
Compares a Photo's image. |
static Photo |
create(java.io.File imageFile,
java.lang.String title)
Create a new Photo on Flickr. |
static Photo |
create(java.io.File imageFile,
java.lang.String title,
java.lang.String desc,
java.lang.String tags,
boolean pub,
boolean friend,
boolean family)
Create a new Photo on Flickr. |
void |
delete()
Delete this photo from Flickr. |
boolean |
equals(java.lang.Object o)
Determine of a Photo is equal to another. |
static Photo |
findByID(java.lang.String id,
java.lang.String secret)
Get a photo, provided you have the Photo's id, and secret key. |
static java.util.List<Photo> |
findByTags(java.lang.String tags)
Get a list of photos that are tagged with the desired keywords. |
static java.util.List<Photo> |
findByTags(java.lang.String tags,
boolean join)
Get a list of Photos that are tagged with the desired keywords. |
java.util.List<Comment> |
getComments()
Get a list of comments for this photo. |
java.util.Date |
getDateTaken()
Get the date the photo was taken. |
java.lang.String |
getDateTakenGranularity()
Get the granularity (i.e., the precision) of the date the photo was taken. |
java.util.Date |
getDateUpdated()
Get the date the photo was last updated. |
java.util.Date |
getDateUploaded()
Get the date the photo was uploaded to Flickr. |
java.lang.String |
getDescription()
Get the description of the photo. |
org.jdom.Document |
getEXIF()
Get the EXIF data for this photo. |
java.lang.String |
getID()
Get the id of the photo. |
java.awt.image.BufferedImage |
getImage()
Get a BufferedImage of this photo (default size). |
java.awt.image.BufferedImage |
getImage(Photo.Size size)
Get a BufferedImage of this photo. |
static java.util.List<Photo> |
getInteresting()
Gets a list of Photos that Flickr users find interesting, for today. |
static org.jickr.PhotoList |
getInteresting(java.util.Calendar cal)
Gets a list of Photos that Flickr users find interesting, for today. |
License |
getLicense()
Get the license of the photo. |
java.util.List<Note> |
getNotes()
Get a list of notes for this Photo. |
int |
getNumComments()
Get the number of comments attached to this photo in Flickr. |
java.net.URL |
getPhotoPage()
Get the Flickr URL of the page where you can find this photo. |
java.util.List<Group> |
getPublicGroups()
Get a list of all public Groups this Photo belongs to. |
java.util.List<PhotoSet> |
getPublicSets()
Get a list of all public PhotoSets this Photo belongs to. |
static java.util.List<Photo> |
getRecentPhotos()
Gets a list of the most recent photos on Flickr. |
java.lang.String |
getSecret()
Get the secret key of the photo. |
java.util.Map<Photo.Size,Photo.PhotoSize> |
getSizes()
Get a Map of all valid PhotoSize values for this Photo. |
java.net.URL |
getStaticURL()
Get the static Flickr URL where you can find this photo. |
java.util.List<Tag> |
getTags()
Get a list of tags for this Photo. |
java.lang.String |
getTitle()
Get the title of the photo. |
int |
hashCode()
Get the hashcode for this object. |
boolean |
isFamily()
Returns whether the photo is visible to people marked as family of the authenticated user. |
boolean |
isFriend()
Returns whether the photo is visible to people marked as friends of the authenticated user. |
boolean |
isPublic()
Return whether the photo is publicly visible. |
void |
removeFavorite()
Remove this photo from the authenticated user's list of favorites. |
void |
replace(java.io.File imageFile)
Replaces the Photo on Flickr with the Image provided. |
void |
rotate(int amount)
Rotate the Photo on Flickr. |
static java.util.List<Photo> |
search(PhotoSearch search)
Get a list of Photos associated with the PhotoSearch term. |
void |
setDateTaken(java.util.Date dateTaken)
Update the date Flickr lists as the date taken for the Photo. |
void |
setDateTakenGranularity(java.lang.String granularity)
Update the date Flickr lists as the date taken for the Photo. |
void |
setDateUploaded(java.util.Date dateUploaded)
Update the date Flickr lists as the date the Photo was uploaded. |
void |
setLicense(License license)
Sets the license restrictions of this photo. |
void |
setPerms(boolean pub,
boolean friends,
boolean family,
Photo.Allowed comment,
Photo.Allowed addmeta)
Set permissions on a Photo. |
void |
setTags(java.lang.String tags)
Replace all tags on the Photo with the specified tags. |
java.lang.String |
toString()
Get the String representation of the URL for this photo. |
void |
updateTitleDesc(java.lang.String title,
java.lang.String desc)
Change the title text and description text associated with a Photo. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Photo(java.lang.String id, java.lang.String secret)
id
- ID of the photo. Must not be null.secret
- Secret string of the photo. Needed for private photos.public Photo(java.lang.String id)
id
- ID of the Photo. Must not be null.Method Detail |
---|
public static Photo findByID(java.lang.String id, java.lang.String secret) throws FlickrException
FlickrException
public static java.util.List<Photo> findByTags(java.lang.String tags) throws FlickrException
tags
- Comma separated list of tags
FlicrException
- For any error.
FlickrException
public static java.util.List<Photo> findByTags(java.lang.String tags, boolean join) throws FlickrException
tags
- Comma separated list of tagsjoin
- True joins the tags with AND, False joins the tags with OR
FlickrException
- For any error.public static java.util.List<Photo> search(PhotoSearch search) throws FlickrException
PhotoSearch
term.
Unauthenticated calls return only public photos. If authenticated at READ
level or above, private photos visible to the authenticated user can be
viewed as well.
search
- A PhotoSearch object describing the search to perform.
FlickrExcpetion
- For any error.
FlickrException
public static java.util.List<Photo> getRecentPhotos() throws FlickrException
PhotoList
of Flickr's recent photos
FlickrException
public static java.util.List<Photo> getInteresting() throws FlickrException
PhotoList
of Flickr's interesting photos.
FlickrException
public static org.jickr.PhotoList getInteresting(java.util.Calendar cal) throws FlickrException
cal
- - Used to specify what date to fetch interesting photos from.
PhotoList
of FJickrs interesting photos.
FlickrException
public static Photo create(java.io.File imageFile, java.lang.String title) throws FlickrException
imageFile
- Image to use as the basis for the Photo.title
- Title of the Photo. May be null.
FlickrException
- on any error.public static Photo create(java.io.File imageFile, java.lang.String title, java.lang.String desc, java.lang.String tags, boolean pub, boolean friend, boolean family) throws FlickrException
imageFile
- Image to use as the basis for the Photo. Must be a JPEG formatted file.title
- Title of the Photo. May be null.desc
- Description of the Photo. May be null.tags
- Space delimited list of tags for the Photo.pub
- Whether this photo is publicly viewable.friend
- Whether this photo is viewable by people marked as Friends.family
- Whether this photo is viewable by people marked as Family.
FlickrException
- on any error.public void replace(java.io.File imageFile) throws FlickrException
imageFile
- The new image to store for this Photo.
FlickrException
- on any error.public void delete() throws FlickrException
FlickrException
- on any error.public java.net.URL getStaticURL() throws FlickrException
PhotoSize.getPage()
. To get different sizes TODO: ADD CODE SNIP
Please note: Flickr requires that if you display
an image from this Photo in a webpage, that you make it a link to the URL returned
from Photo.getPhotoPage()
. Please do the right thing.
FlickrException
getPhotoPage()
public java.net.URL getPhotoPage() throws FlickrException
FlickrException
getStaticURL()
public java.lang.String getTitle() throws FlickrException
FlickrException
- on an access error to Flickr.public java.lang.String getSecret() throws FlickrException
FlickrException
public java.lang.String getID()
public java.lang.String getDescription() throws FlickrException
FlickrException
public License getLicense() throws FlickrException
FlickrException
public void setLicense(License license) throws FlickrException
Requires WRITE authentication and permission.
license
- License to use for this Photo.
FlickrException
- on any error.public int getNumComments() throws FlickrException
Photo
FlickrException
getComments()
public java.util.Date getDateUploaded() throws FlickrException
FlickrException
public java.util.Date getDateUpdated() throws FlickrException
FlickrException
public java.util.Date getDateTaken() throws FlickrException
FlickrException
public java.lang.String getDateTakenGranularity() throws FlickrException
Get the granularity (i.e., the precision) of the date the photo was taken.
Currently has three values: 0: granularity to the second, 4: granularity to the month, and 6: granularity to the year. Later updates to Flickr may return any value between 0 and 10.
Currently returned as a String. This may change to an int at some time in the future, if there's a need.
FlickrException
- on any error.public java.awt.image.BufferedImage getImage() throws java.io.IOException, FlickrException
java.io.IOException
FlickrException
getImage(Size)
public java.awt.image.BufferedImage getImage(Photo.Size size) throws FlickrException
size
- - Size of the image to fetch.
FlickrException
public org.jdom.Document getEXIF() throws FlickrException
This call is not cached, and goes out to Flickr every time to check data.
FlickrException
- on any error.public java.util.List<Comment> getComments() throws FlickrException
FlickrException
- in the event of any error.public java.util.Map<Photo.Size,Photo.PhotoSize> getSizes() throws FlickrException
FlickrException
- on any error.public java.lang.String addComment(java.lang.String commentText) throws FlickrException
Adds a comment to this Photo, returns the new comment ID. Since Flickr
doesn't offer a way to search for a comment via ID, the user will
have to do a getComments()
and search for the comment with
Comment.getID()
if they want a Comment object representing this
added comment.
This call requires that the user be authenticated at the WRITE level.
commentText
- Text for the comment to add.
FlickrException
- in the event of a failure. Note that if an exception is thrown, it's possible (thought unlikely) that a comment was added anyway.getComments()
,
Comment.getID()
public void addFavorite() throws FlickrException
FlickrException
- on any error.public void removeFavorite() throws FlickrException
FlickrException
- on any error.public java.util.List<PhotoSet> getPublicSets() throws FlickrException
FlickrException
- on any error.public java.util.List<Group> getPublicGroups() throws FlickrException
FlickrException
- on any error.public java.util.List<Tag> getTags() throws FlickrException
FlickrException
- on any error.public void addTags(java.lang.String tags) throws FlickrException
tags
- A comma delimited list of tags to add.
FlickrException
- on any error.public void setTags(java.lang.String tags) throws FlickrException
tags
- A comma delimited list of tags.
FlickrException
- on any error.public java.util.List<Note> getNotes() throws FlickrException
FlickrException
- on any error.public java.lang.String addNote(java.awt.Rectangle area, java.lang.String text) throws FlickrException
area
- Rectangle describing the area covered by the note. Must not be null.text
- Text of the note. Must not be null.
FlickrException
- on any error.public void updateTitleDesc(java.lang.String title, java.lang.String desc) throws FlickrException
title
- The new title for the photo. May not be null.desc
- The new description for the photo. May not be null.
FlickrException
- on any error.public void setDateUploaded(java.util.Date dateUploaded) throws FlickrException
dateUploaded
- The new date to list as the date uploaded. May not be null.
FlickrException
- on any error.public void setDateTaken(java.util.Date dateTaken) throws FlickrException
dateTaken
- The new date to list as the date uploaded. May not be null.
FlickrException
- on any error.public void setDateTakenGranularity(java.lang.String granularity) throws FlickrException
granularity
- The precision of the date taken on Flickr. May not be null. Must be one of 0, 4 or 6.
FlickrException
- on any error.public void rotate(int amount) throws FlickrException
Rotate the Photo on Flickr.
Requires authentication with WRITE access.
NOTE: This seems to be a very expensive call.
amount
- The amount, in degrees, to rotate the photo. Must be one of 90, 180, 270.
FlickrException
- on any error.public boolean isPublic() throws FlickrException
Requires authentication with read access.
FlickrException
- on any error.public boolean isFriend() throws FlickrException
Requires authentication with READ access.
FlickrException
- on any error.public boolean isFamily() throws FlickrException
Requires authentication with READ access.
FlickrException
- on any error.public boolean canComment() throws FlickrException
Requires authentication with READ access.
FlickrException
- on any error.public boolean canAddMeta() throws FlickrException
Requires authentication with READ access.
FlickrException
- on any error.public void setPerms(boolean pub, boolean friends, boolean family, Photo.Allowed comment, Photo.Allowed addmeta) throws FlickrException
Requires authentication with WRITE access.
pub
- Is the public allowed to view the photo?friends
- Are friends allowed to view the photo?family
- Are family allowed to view the photo?comment
- Who can comment on the photo?addmeta
- Who can add Notes and Tags to a photo?
FlickrException
- on any error.public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public int compareTo(Photo p)
compareTo
in interface java.lang.Comparable<Photo>
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |