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
ConstructorsConstructorDescriptionConstructor without options.PictureInfo(File imageFile, String description) Constructor with just filename as option. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the supplied Object to the categoryAssignment HashSet.voidaddCategoryAssignment(String string) Adds to the index number received as a string to the Set of categoriesvoidaddPictureInfoChangeListener(PictureInfoChangeListener pictureInfoChangeListener) Registers a listener for picture info change eventsbooleanChecks whether the searchString parameter is contained in any of the fields.voidappendToCategoryAssignment(String string) Appends the text fragment to the categoryAssignmentString field.voidappendToComment(String textFragment) Appends the text fragment to the comment.voidappendToCopyrightHolder(String textFragment) appends the text fragment to the copyright holder field.voidappendToCreationTime(String textFragment) appends the text fragment to the creation time.voidAppends the text fragment to the description.voidAppends the string to the filmReference field.voidappendToImageFile(String s, Path baseDir) Appends the text to the field (used by XML parser).voidAppends the text to the field (used by XML parser).voidappendToLatLng(String textFragment) appends the text fragment to the latlng string.voidappendToPhotographer(String textFragment) Appends the text fragment to the photographer field.voidappendToRotation(String textFragment) Appends the text fragment to the rotation field.voidAppends the text fragment to the sha256 field.static StringcalculateSha256(File file) calculates the SHA-256 hash of the picture.voidremoves all category AssignmentsintcompareTo(@NotNull PictureInfo otherPictureInfo, Settings.FieldCodes sortField) Defines how PictureInfo objects compare themselvesbooleancontainsCategory(Integer key) Returns whether the category is part of the attributes of the picturebooleandescriptionContains(String searchString) Checks whether the searchString parameter is contained in the description.voiddumpToXml(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 StringgetFormattedCreationTime(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 PathgetRelativePath(File imageFile, Path baseDir) doubleReturns the rotation.Returns the SHA-256 of the contents of the filevoidConverts the temporary categoryAssignmentString to a categoryAssignment and calls addCategoryAssignmentvoidConverts the temporary latLngString to a LatLng Point.voidConverts the temporary rotationString to the rotation double.voidremoveCategory(Object key) Removes the supplied category from the picture if it was therevoidremovePictureInfoChangeListener(PictureInfoChangeListener pictureInfoChangeListener) Removes the supplied listenervoidrotate(double angle) Changes the angle by the supplied angle the picture by an angle.voidCreates a PictureChangedEvent and sends it to inform listening objects that the node was mailSelected.voidCreates a PictureChangedEvent and sends it to inform listening objects that the node was mailUnselected.voidCreates a PictureChangedEvent and sends it to inform listening objects that the node was selected.voidCreates a PictureChangedEvent and sends it to inform listening objects that the node was unselected.voidsetCategoryAssignment(@NotNull Collection<Integer> ca) Sets the supplied Collection as the categories of the picture, clearing out any pre-existing ones.voidsetComment(String newComment) Sets the comment.voidsetCopyrightHolder(String newCopyrightHolder) Sets the copyright holder.voidsetCreationTime(String newCreationTime) Sets the creationTime.voidsetDescription(String desc) Sets the description of the image.voidsetFilmReference(String newFilmReference) Sets the film reference.voidsetImageLocation(@NotNull File file) Sets the image location and sends a sendImageLocationChangedEvent.voidsetLatLng(Point2D.Double newLatLng) Sets the Latitude and Longitude.voidSets the Latitude and Longitude.voidsetOwningNode(SortableDefaultMutableTreeNode sortableDefaultMutableTreeNode) A GroupOrPicture must be able to remember the node that owns it to facilitate traversalvoidsetPhotographer(String newPhotographer) Sets the Photographer.voidsetRotation(double rotation) Sets the rotation.voidsetRotation(int rotation) Sets the rotation.voidcalculates the SHA-256 hash of the picture and saves it to the sha256 member variable.voidcalculates the SHA-256 hash of the picture and saves it to the fileHash member variable.toString()returns the description of the image in the defaulttoStringmethod.
-
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 defaulttoStringmethod. -
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:GroupOrPictureA GroupOrPicture must be able to remember the node that owns it to facilitate traversal- Specified by:
setOwningNodein interfaceGroupOrPicture- Parameters:
sortableDefaultMutableTreeNode- The owning node
-
getOwningNode
Description copied from interface:GroupOrPictureReturns the node that owns this object- Specified by:
getOwningNodein interfaceGroupOrPicture- Returns:
- the node that owns this object
-