java.lang.Object
org.jpo.datamodel.PictureInfo
- All Implemented Interfaces:
Serializable
,GroupOrPicture
Objects of this type represent a single picture in the collection. Since
SortableDefaultMutableTreeNodes allow user objects to be attached to the node
this is a convenient place to store all the information that we have about a
picture.
The class provides several convenience methods to access the information.
This class must implement the Serializable interface or Drag and Drop will not work.
- See Also:
-
Constructor Summary
ConstructorDescriptionConstructor without options.PictureInfo
(File imageFile, String description) Constructor with just filename as option. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds the supplied Object to the categoryAssignment HashSet.void
addCategoryAssignment
(String string) Adds to the index number received as a string to the Set of categoriesvoid
addPictureInfoChangeListener
(PictureInfoChangeListener pictureInfoChangeListener) Registers a listener for picture info change eventsboolean
Checks whether the searchString parameter is contained in any of the fields.void
appendToCategoryAssignment
(String string) Appends the text fragment to the categoryAssignmentString field.void
appendToComment
(String textFragment) Appends the text fragment to the comment.void
appendToCopyrightHolder
(String textFragment) appends the text fragment to the copyright holder field.void
appendToCreationTime
(String textFragment) appends the text fragment to the creation time.void
Appends the text fragment to the description.void
Appends the string to the filmReference field.void
appendToImageFile
(String s, Path baseDir) Appends the text to the field (used by XML parser).void
Appends the text to the field (used by XML parser).void
appendToLatLng
(String textFragment) appends the text fragment to the latlng string.void
appendToPhotographer
(String textFragment) Appends the text fragment to the photographer field.void
appendToRotation
(String textFragment) Appends the text fragment to the rotation field.void
Appends the text fragment to the sha256 field.static String
calculateSha256
(File file) calculates the SHA-256 hash of the picture.void
removes all category Assignmentsint
compareTo
(@NotNull PictureInfo otherPictureInfo, Settings.FieldCodes sortField) Defines how PictureInfo objects compare themselvesboolean
containsCategory
(Integer key) Returns whether the category is part of the attributes of the pictureboolean
descriptionContains
(String searchString) Checks whether the searchString parameter is contained in the description.void
dumpToXml
(BufferedWriter out, Path baseDir) this method writes all attributes of the picture in the JPO xml data format with the highres and lowres locations passed in as parameters.Returns a Set of categories that have been applied to this picturegetClone()
Returns a new PictureInfo object which is identical to the current one.Returns the comment.returns the copyright holder.Returns the creation Time.Returns the creationTime as a Date object or null if the parsing failed.Returns the description of the image.Returns the film reference.Returns the creationTime as a string after it has been parsed.static String
getFormattedCreationTime
(Calendar dateTime) Returns the creationTime as a formatted String.Returns the creationTime as a formatted String.returns the file handle to the highres picture.Returns the full path to the highres picture.returns the URI handle to the picture.returns the Latitude and Longitude.returns the Latitude and Longitude as a StringReturns the node that owns this objectReturns the photographer.static Path
getRelativePath
(File imageFile, Path baseDir) double
Returns the rotation.Returns the SHA-256 of the contents of the filevoid
Converts the temporary categoryAssignmentString to a categoryAssignment and calls addCategoryAssignmentvoid
Converts the temporary latLngString to a LatLng Point.void
Converts the temporary rotationString to the rotation double.void
removeCategory
(Object key) Removes the supplied category from the picture if it was therevoid
removePictureInfoChangeListener
(PictureInfoChangeListener pictureInfoChangeListener) Removes the supplied listenervoid
rotate
(double angle) Changes the angle by the supplied angle the picture by an angle.void
Creates a PictureChangedEvent and sends it to inform listening objects that the node was mailSelected.void
Creates a PictureChangedEvent and sends it to inform listening objects that the node was mailUnselected.void
Creates a PictureChangedEvent and sends it to inform listening objects that the node was selected.void
Creates a PictureChangedEvent and sends it to inform listening objects that the node was unselected.void
setCategoryAssignment
(@NotNull Collection<Integer> ca) Sets the supplied Collection as the categories of the picture, clearing out any pre-existing ones.void
setComment
(String newComment) Sets the comment.void
setCopyrightHolder
(String newCopyrightHolder) Sets the copyright holder.void
setCreationTime
(String newCreationTime) Sets the creationTime.void
setDescription
(String desc) Sets the description of the image.void
setFilmReference
(String newFilmReference) Sets the film reference.void
setImageLocation
(@NotNull File file) Sets the image location and sends a sendImageLocationChangedEvent.void
setLatLng
(Point2D.Double newLatLng) Sets the Latitude and Longitude.void
Sets the Latitude and Longitude.void
setOwningNode
(SortableDefaultMutableTreeNode sortableDefaultMutableTreeNode) A GroupOrPicture must be able to remember the node that owns it to facilitate traversalvoid
setPhotographer
(String newPhotographer) Sets the Photographer.void
setRotation
(double rotation) Sets the rotation.void
setRotation
(int rotation) Sets the rotation.void
calculates the SHA-256 hash of the picture and saves it to the sha256 member variable.void
calculates the SHA-256 hash of the picture and saves it to the fileHash member variable.toString()
returns the description of the image in the defaulttoString
method.
-
Constructor Details
-
PictureInfo
public PictureInfo()Constructor without options. All strings are set to blanks -
PictureInfo
Constructor with just filename as option.- Parameters:
imageFile
- The file of the imagedescription
- Description
-
-
Method Details
-
getFormattedCreationTime
Returns the creationTime as a formatted String. If the dateTime is null a polite "Failed to Parse" string is returned- Parameters:
dateTime
- the Calendar to format- Returns:
- the creation time as a formatted string
-
getFormattedCreationTimeForTimestamp
Returns the creationTime as a formatted String. If parsing doesn't work it returns an empty string- Returns:
- the creation time as a formatted string
-
toString
returns the description of the image in the defaulttoString
method. -
dumpToXml
this method writes all attributes of the picture in the JPO xml data format with the highres and lowres locations passed in as parameters. This became necessary because when the XmlDistiller copies the pictures to a new location we don't want to write the URLs of the original pictures whilst all other attributes are retained.- Parameters:
out
- The Buffered Writer receiving the xml data- Throws:
IOException
- If there was an IO error
-
getRelativePath
-
getDescription
Returns the description of the image.- Returns:
- The description of the image.
- See Also:
-
setDescription
Sets the description of the image.- Parameters:
desc
- New description of the image.- See Also:
-
appendToDescription
Appends the text fragment to the description.- Parameters:
s
- The text fragment to append.
-
descriptionContains
Checks whether the searchString parameter is contained in the description. The search is case-insensitive.- Parameters:
searchString
- The string to search for.- Returns:
- true if found. false if not.
-
getImageLocation
Returns the full path to the highres picture. If the PictureInto doesn't have an image location an empty String is returned.- Returns:
- The highres location
- See Also:
-
setImageLocation
Sets the image location and sends a sendImageLocationChangedEvent.- Parameters:
file
- The new file of the picture.
-
getImageFile
returns the file handle to the highres picture.- Returns:
- the highres location or null if there is a failure
-
getImageURIOrNull
returns the URI handle to the picture.- Returns:
- The image location
-
appendToImageLocation
Appends the text to the field (used by XML parser).- Parameters:
s
- The text fragment to be added to the image Location
-
appendToImageFile
Appends the text to the field (used by XML parser).- Parameters:
s
- The text fragment to be added to the image Location
-
getSha256
Returns the SHA-256 of the contents of the file- Returns:
- the SHA-256 of the image file or null if not calculated
-
calculateSha256
calculates the SHA-256 hash of the picture.- Returns:
- returns a HashCode object containing the SHA256 of the Image File
- Throws:
IOException
- if the underlying library encounters andIOException
-
setSha256
public void setSha256()calculates the SHA-256 hash of the picture and saves it to the sha256 member variable. If the value changes it sends a PictureInfoChangedEvent -
setSha256
calculates the SHA-256 hash of the picture and saves it to the fileHash member variable. If the value changes it sends a PictureInfoChangedEvent -
appendToSha256
Appends the text fragment to the sha256 field.- Parameters:
s
- Text fragment
-
appendToFilmReference
Appends the string to the filmReference field.- Parameters:
s
- Fragment to append to Film Reference
-
getFilmReference
Returns the film reference.- Returns:
- the film reference
-
setFilmReference
Sets the film reference.- Parameters:
newFilmReference
- The new film reference.
-
appendToCreationTime
appends the text fragment to the creation time.- Parameters:
textFragment
- The text fragment to add.
-
getCreationTime
Returns the creation Time.- Returns:
- the creation Time
-
setCreationTime
Sets the creationTime.- Parameters:
newCreationTime
- The new creation time.
-
getCreationTimeAsDate
Returns the creationTime as a Date object or null if the parsing failed.- Returns:
- the creation time
-
getFormattedCreationTime
Returns the creationTime as a string after it has been parsed. Essentially this is a utility method to identify what the Date parser is doing.- Returns:
- the creation time
-
appendToComment
Appends the text fragment to the comment.- Parameters:
textFragment
- the text fragment
-
getComment
Returns the comment.- Returns:
- The comment.
-
setComment
Sets the comment.- Parameters:
newComment
- The new comment
-
appendToPhotographer
Appends the text fragment to the photographer field.- Parameters:
textFragment
- The photographer.
-
getPhotographer
Returns the photographer.- Returns:
- The Photographer.
-
setPhotographer
Sets the Photographer.- Parameters:
newPhotographer
- The new Photographer
-
appendToCopyrightHolder
appends the text fragment to the copyright holder field.- Parameters:
textFragment
- The text fragment.
-
getCopyrightHolder
returns the copyright holder.- Returns:
- The copyright holder
-
setCopyrightHolder
Sets the copyright holder.- Parameters:
newCopyrightHolder
- The copyright holder
-
appendToRotation
Appends the text fragment to the rotation field. does not send a rotationChangedEvent as the rotation has not yet been parsed- Parameters:
textFragment
- Text fragment
-
parseRotation
public void parseRotation()Converts the temporary rotationString to the rotation double. -
getRotation
public double getRotation()Returns the rotation.- Returns:
- The rotation of the image.
-
setRotation
public void setRotation(double rotation) Sets the rotation.- Parameters:
rotation
- The new rotation for the PictureInfo.
-
setRotation
public void setRotation(int rotation) Sets the rotation.- Parameters:
rotation
- The new rotation for the PictureInfo.
-
rotate
public void rotate(double angle) Changes the angle by the supplied angle the picture by an angle.- Parameters:
angle
- the new angle
-
appendToLatLng
appends the text fragment to the latlng string.- Parameters:
textFragment
- The text fragment.
-
parseLatLng
public void parseLatLng()Converts the temporary latLngString to a LatLng Point. -
getLatLng
returns the Latitude and Longitude.- Returns:
- The Latitude and Longitude
-
setLatLng
Sets the Latitude and Longitude.- Parameters:
newLatLng
- The latitude and longitude holder
-
setLatLng
Sets the Latitude and Longitude.- Parameters:
newLatLng
- The latitude and longitude in the format of 2 doubles with an x
-
getLatLngString
returns the Latitude and Longitude as a String- Returns:
- The latitude and longitude in the format of 2 doubles with an x
-
getCategoryAssignments
Returns a Set of categories that have been applied to this picture- Returns:
- the Set of categories
-
clearCategoryAssignments
public void clearCategoryAssignments()removes all category Assignments -
appendToCategoryAssignment
Appends the text fragment to the categoryAssignmentString field.- Parameters:
string
- Text fragment
-
addCategoryAssignment
Adds to the index number received as a string to the Set of categories- Parameters:
string
- Text fragment
-
addCategoryAssignment
Adds the supplied Object to the categoryAssignment HashSet. If the Object already existed it doesn't get added a second time.- Parameters:
key
- the key to add
-
setCategoryAssignment
Sets the supplied Collection as the categories of the picture, clearing out any pre-existing ones.- Parameters:
ca
- the supplied hash set
-
parseCategoryAssignment
public void parseCategoryAssignment()Converts the temporary categoryAssignmentString to a categoryAssignment and calls addCategoryAssignment -
containsCategory
Returns whether the category is part of the attributes of the picture- Parameters:
key
- the key- Returns:
- true if the key was in the categories
-
removeCategory
Removes the supplied category from the picture if it was there- Parameters:
key
- the key to search for
-
sendWasSelectedEvent
public void sendWasSelectedEvent()Creates a PictureChangedEvent and sends it to inform listening objects that the node was selected. Strictly speaking this is not a PictureInfo level event but a node level event. However, because I have the PictureInfoChangeEvent structure in place this is a good place to put this notification. -
sendWasUnselectedEvent
public void sendWasUnselectedEvent()Creates a PictureChangedEvent and sends it to inform listening objects that the node was unselected. Strictly speaking this is not a PictureInfo level event but a node level event. However, because I have the PictureInfoChangeEvent structure in place this is a good place to put this notification. -
sendWasMailSelectedEvent
public void sendWasMailSelectedEvent()Creates a PictureChangedEvent and sends it to inform listening objects that the node was mailSelected. Strictly speaking this is not a PictureInfo level event but a node level event. However, because I have the PictureInfoChangeEvent structure in place this is a good place to put this notification. -
sendWasMailUnselectedEvent
public void sendWasMailUnselectedEvent()Creates a PictureChangedEvent and sends it to inform listening objects that the node was mailUnselected. Strictly speaking this is not a PictureInfo level event but a node level event. However, because I have the PictureInfoChangeEvent structure in place this is a good place to put this notification. -
getClone
Returns a new PictureInfo object which is identical to the current one.- Returns:
- a clone of the current PictureInfo object.
-
addPictureInfoChangeListener
Registers a listener for picture info change events- Parameters:
pictureInfoChangeListener
- The object that will receive notifications.
-
removePictureInfoChangeListener
Removes the supplied listener- Parameters:
pictureInfoChangeListener
- The listener that doesn't want to notifications anymore.
-
anyMatch
Checks whether the searchString parameter is contained in any of the fields. It doesn't check the checksum or rotation. It does check the description, highres name, film reference, creation time, comment and copyright holder- Parameters:
searchString
- The string to search for.- Returns:
- true if found. false if not.
-
compareTo
Defines how PictureInfo objects compare themselves- Parameters:
otherPictureInfo
- The other GroupInfo objectsortField
- which attribute to use in the comparison- Returns:
- negative number if this is less than or Zero if same or positive number if other is less than this
-
setOwningNode
Description copied from interface:GroupOrPicture
A GroupOrPicture must be able to remember the node that owns it to facilitate traversal- Specified by:
setOwningNode
in interfaceGroupOrPicture
- Parameters:
sortableDefaultMutableTreeNode
- The owning node
-
getOwningNode
Description copied from interface:GroupOrPicture
Returns the node that owns this object- Specified by:
getOwningNode
in interfaceGroupOrPicture
- Returns:
- the node that owns this object
-