se.datadosen.jalbum
Class AlbumObjectImpl

java.lang.Object
  extended by se.datadosen.jalbum.AlbumObjectImpl
All Implemented Interfaces:
java.awt.datatransfer.Transferable, AlbumObject

public class AlbumObjectImpl
extends java.lang.Object
implements AlbumObject

Implementation of an AlbumObject.


Field Summary
static java.lang.String ALBUMFILES_FILE_NAME
           
static java.lang.String COMMENTS_FILE_NAME
           
static java.lang.String JALBUM_FOLDER_NAME
           
static java.lang.String META_FILE_NAME
           
static java.awt.Dimension THUMBNAIL_DIMENSION
           
static java.lang.String THUMBNAILS_FOLDER
           
 
Fields inherited from interface se.datadosen.jalbum.AlbumObject
albumObjectFlavor, FOLDER_ORDERING_KEY, FOLDERS_FIRST_KEY, ORDER_BY_CAMERA_DATE, ORDER_BY_DATE, ORDER_BY_NAME, ORDER_BY_RATING, ORDER_CUSTOM, ORDER_JALBUM, ORDERING_KEY, REVERSE_FOLDER_ORDERING_KEY, REVERSE_ORDERING_KEY
 
Method Summary
 void add(java.util.List<java.io.File> files)
           
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds a property change listener to album object.
 void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
           
 boolean containsName(java.lang.String name)
           
 AlbumObject createFolder(java.lang.String suggestedName)
          Create a folder (with some relevant backing) and make folder a child of this AlbumObject
 void delete()
           
 boolean equals(java.lang.Object o)
           
protected  void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
          Support for reporting bound property changes for Object properties.
 AlbumObject getChild(java.lang.String path)
           
 java.util.List<AlbumObject> getChildren()
           
 java.lang.String getComment()
           
 AlbumObjectFactory getFactory()
           
 java.io.File getFile()
           
 java.lang.String getFolderOrdering()
           
 long getLastModified()
           
 AlbumObjectMetadata getMetadata()
           
 java.lang.String getName()
           
 java.lang.String getOrdering()
           
 AlbumObject getParent()
           
 java.lang.String getPathFromRoot()
          Get the path to this AlbumObject in the form folder/subfolder/albumObject
 AlbumObjectProperties getProperties()
          Get properties bound to this object.
 AlbumObject getRepresentingAlbumObject()
          Since 8.1
 AlbumObject getRepresentingAlbumObject(boolean force)
           
 javax.swing.ImageIcon getRepresentingIcon(java.awt.Dimension bounds, boolean enlarge)
           
 javax.swing.ImageIcon getRepresentingIcon(java.awt.Dimension bounds, boolean cropToBounds, boolean enlarge)
           
 java.io.File getRepresentingIconFile()
          DOCUMENT ME!
 java.lang.String getThumbnailPath()
           
 java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor)
           
 java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
           
 int hashCode()
           
 void invalidate()
          Call if underlaying (file) structure has changed Will force synchronization with underlaying structure when getChildren is called
 boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
           
 boolean isDisplayableImage()
           
 boolean isFolder()
           
 boolean isFoldersFirst()
           
 boolean isIncluded()
           
 boolean isLink()
           
 boolean isReverseFolderOrdering()
           
 boolean isReverseOrdering()
           
 java.awt.Image loadImage()
           
 java.awt.Image loadImage(boolean useFastLoading, java.awt.Dimension imageDim)
           
 void moveTo(AlbumObject newParent)
           
 void moveTo(AlbumObject newParent, int position)
           
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Removes a PropertyChangeListener from the listener list.
 boolean repairLink(java.io.File newTarget)
           
 void rotateLeft()
           
 void rotateRight()
           
static javax.swing.ImageIcon scaleToFit(javax.swing.ImageIcon ii, java.awt.Dimension boundingBox, boolean enlarge)
           
 void setChildren(java.util.List<AlbumObject> children)
          Set List of children AlbumObjects if this is a directory/folder
 void setComment(java.lang.String newComment)
           
 void setFolderOrdering(java.lang.String folderOrdering)
           
 void setFoldersFirst(boolean foldersFirst)
           
 void setIncluded(boolean included)
           
 boolean setName(java.lang.String newName)
          Set the name of this AlbumObject
 void setOrdering(java.lang.String ordering)
           
 void setRepresentingAlbumObject(AlbumObject rep)
           
 void setRepresentingIcon(java.awt.image.BufferedImage thumbnail, boolean changed)
           
 void setReverseFolderOrdering(boolean reverseFolderOrdering)
           
 void setReverseOrdering(boolean reverseOrdering)
           
 java.lang.String toString()
           
 void updateRepresentingIcon()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

COMMENTS_FILE_NAME

public static final java.lang.String COMMENTS_FILE_NAME
See Also:
Constant Field Values

META_FILE_NAME

public static final java.lang.String META_FILE_NAME
See Also:
Constant Field Values

ALBUMFILES_FILE_NAME

public static final java.lang.String ALBUMFILES_FILE_NAME
See Also:
Constant Field Values

JALBUM_FOLDER_NAME

public static final java.lang.String JALBUM_FOLDER_NAME
See Also:
Constant Field Values

THUMBNAIL_DIMENSION

public static final java.awt.Dimension THUMBNAIL_DIMENSION

THUMBNAILS_FOLDER

public static final java.lang.String THUMBNAILS_FOLDER
See Also:
Constant Field Values
Method Detail

getRepresentingAlbumObject

public AlbumObject getRepresentingAlbumObject()
Since 8.1

Specified by:
getRepresentingAlbumObject in interface AlbumObject

getRepresentingAlbumObject

public AlbumObject getRepresentingAlbumObject(boolean force)
Specified by:
getRepresentingAlbumObject in interface AlbumObject

getParent

public AlbumObject getParent()
Specified by:
getParent in interface AlbumObject
Returns:
parent AlbumObject or null if no parent

getFile

public java.io.File getFile()
Specified by:
getFile in interface AlbumObject
Returns:
backing File or null if no backing file

getLastModified

public long getLastModified()
Specified by:
getLastModified in interface AlbumObject
Returns:
last modified date of file or applied filters, whatever is latest

loadImage

public java.awt.Image loadImage()
                         throws java.io.IOException
Specified by:
loadImage in interface AlbumObject
Returns:
backing Image or null if not displayable. Use isDisplayable() to check
Throws:
java.io.IOException

loadImage

public java.awt.Image loadImage(boolean useFastLoading,
                                java.awt.Dimension imageDim)
                         throws java.io.IOException
Specified by:
loadImage in interface AlbumObject
Parameters:
useFastLoading - enable fast loading.
imageDim - Dimension used to calculate scale for fast loading.
Returns:
backing Image or null if not displayable. Use isDisplayable() to check
Throws:
java.io.IOException

getFactory

public AlbumObjectFactory getFactory()
Specified by:
getFactory in interface AlbumObject

rotateLeft

public void rotateLeft()
                throws java.io.IOException
Specified by:
rotateLeft in interface AlbumObject
Throws:
java.io.IOException

rotateRight

public void rotateRight()
                 throws java.io.IOException
Specified by:
rotateRight in interface AlbumObject
Throws:
java.io.IOException

delete

public void delete()
            throws java.io.IOException,
                   PermissionException
Specified by:
delete in interface AlbumObject
Throws:
java.io.IOException
PermissionException

createFolder

public AlbumObject createFolder(java.lang.String suggestedName)
                         throws java.io.IOException
Create a folder (with some relevant backing) and make folder a child of this AlbumObject

Specified by:
createFolder in interface AlbumObject
Parameters:
suggestedName - String
Returns:
AlbumObject for newly created folder
Throws:
java.io.IOException

getName

public java.lang.String getName()
Specified by:
getName in interface AlbumObject
Returns:
String name of AlbumObject

setName

public boolean setName(java.lang.String newName)
Description copied from interface: AlbumObject
Set the name of this AlbumObject

Specified by:
setName in interface AlbumObject
Parameters:
newName - String
Returns:

getComment

public java.lang.String getComment()
Specified by:
getComment in interface AlbumObject

setComment

public void setComment(java.lang.String newComment)
                throws java.io.IOException
Specified by:
setComment in interface AlbumObject
Throws:
java.io.IOException

getPathFromRoot

public java.lang.String getPathFromRoot()
Get the path to this AlbumObject in the form folder/subfolder/albumObject

Specified by:
getPathFromRoot in interface AlbumObject
Returns:
Path to AlbumObject
Since:
8.0

getMetadata

public AlbumObjectMetadata getMetadata()
Specified by:
getMetadata in interface AlbumObject

getProperties

public AlbumObjectProperties getProperties()
Get properties bound to this object. AlbumObjectProperties are not just plain strings.

Specified by:
getProperties in interface AlbumObject
Returns:
AlbumObjectProperties
Since:
8.0
See Also:
AlbumObjectProperties

isDisplayableImage

public boolean isDisplayableImage()
Specified by:
isDisplayableImage in interface AlbumObject
Returns:
boolean true if this album object is displayable in an album

isLink

public boolean isLink()
Specified by:
isLink in interface AlbumObject
Returns:
boolean true if this AlbumObject represents a folder/directory that is physically linked

isFolder

public boolean isFolder()
Specified by:
isFolder in interface AlbumObject
Returns:
boolean true if this AlbumObject represents a folder/directory

isIncluded

public boolean isIncluded()
Specified by:
isIncluded in interface AlbumObject

setIncluded

public void setIncluded(boolean included)
Specified by:
setIncluded in interface AlbumObject

getChildren

public java.util.List<AlbumObject> getChildren()
Specified by:
getChildren in interface AlbumObject
Returns:
List of Children AlbumObjects of this AlbumObject or null if this is not a directory/folder. Will return an empty list if this is an empty directory/folder

getChild

public AlbumObject getChild(java.lang.String path)
Specified by:
getChild in interface AlbumObject
Since:
8.1

setChildren

public void setChildren(java.util.List<AlbumObject> children)
                 throws java.io.IOException
Description copied from interface: AlbumObject
Set List of children AlbumObjects if this is a directory/folder

Specified by:
setChildren in interface AlbumObject
Throws:
java.io.IOException

containsName

public boolean containsName(java.lang.String name)
Specified by:
containsName in interface AlbumObject

moveTo

public void moveTo(AlbumObject newParent)
            throws java.io.IOException
Specified by:
moveTo in interface AlbumObject
Throws:
java.io.IOException

repairLink

public boolean repairLink(java.io.File newTarget)
                   throws java.io.IOException
Specified by:
repairLink in interface AlbumObject
Throws:
java.io.IOException

moveTo

public void moveTo(AlbumObject newParent,
                   int position)
            throws java.io.IOException
Specified by:
moveTo in interface AlbumObject
Throws:
java.io.IOException

add

public void add(java.util.List<java.io.File> files)
         throws java.io.IOException
Specified by:
add in interface AlbumObject
Throws:
java.io.IOException

getOrdering

public java.lang.String getOrdering()
Specified by:
getOrdering in interface AlbumObject

setOrdering

public void setOrdering(java.lang.String ordering)
                 throws java.io.IOException
Specified by:
setOrdering in interface AlbumObject
Throws:
java.io.IOException

getFolderOrdering

public java.lang.String getFolderOrdering()
Specified by:
getFolderOrdering in interface AlbumObject

setFolderOrdering

public void setFolderOrdering(java.lang.String folderOrdering)
                       throws java.io.IOException
Specified by:
setFolderOrdering in interface AlbumObject
Throws:
java.io.IOException

isFoldersFirst

public boolean isFoldersFirst()
Specified by:
isFoldersFirst in interface AlbumObject

setFoldersFirst

public void setFoldersFirst(boolean foldersFirst)
                     throws java.io.IOException
Specified by:
setFoldersFirst in interface AlbumObject
Throws:
java.io.IOException

isReverseOrdering

public boolean isReverseOrdering()
Specified by:
isReverseOrdering in interface AlbumObject

setReverseOrdering

public void setReverseOrdering(boolean reverseOrdering)
                        throws java.io.IOException
Specified by:
setReverseOrdering in interface AlbumObject
Throws:
java.io.IOException

isReverseFolderOrdering

public boolean isReverseFolderOrdering()
Specified by:
isReverseFolderOrdering in interface AlbumObject

setReverseFolderOrdering

public void setReverseFolderOrdering(boolean reverseFolderOrdering)
                              throws java.io.IOException
Specified by:
setReverseFolderOrdering in interface AlbumObject
Throws:
java.io.IOException

invalidate

public void invalidate()
Description copied from interface: AlbumObject
Call if underlaying (file) structure has changed Will force synchronization with underlaying structure when getChildren is called

Specified by:
invalidate in interface AlbumObject

getRepresentingIcon

public javax.swing.ImageIcon getRepresentingIcon(java.awt.Dimension bounds,
                                                 boolean enlarge)
                                          throws java.io.IOException
Specified by:
getRepresentingIcon in interface AlbumObject
Returns:
small Icon representing this AlbumObject (be it a thumbnail or icon)
Throws:
java.io.IOException

getRepresentingIcon

public javax.swing.ImageIcon getRepresentingIcon(java.awt.Dimension bounds,
                                                 boolean cropToBounds,
                                                 boolean enlarge)
                                          throws java.io.IOException
Specified by:
getRepresentingIcon in interface AlbumObject
Returns:
small Image representing this AlbumObject (be it a thumbnail or icon)
Throws:
java.io.IOException

getRepresentingIconFile

public java.io.File getRepresentingIconFile()
DOCUMENT ME!

Specified by:
getRepresentingIconFile in interface AlbumObject
Returns:
File reference to image representing this AlbumObject or null there is no special representation

setRepresentingAlbumObject

public void setRepresentingAlbumObject(AlbumObject rep)
Specified by:
setRepresentingAlbumObject in interface AlbumObject
Since:
8.1

getThumbnailPath

public java.lang.String getThumbnailPath()
Specified by:
getThumbnailPath in interface AlbumObject

scaleToFit

public static javax.swing.ImageIcon scaleToFit(javax.swing.ImageIcon ii,
                                               java.awt.Dimension boundingBox,
                                               boolean enlarge)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Description copied from interface: AlbumObject
Adds a property change listener to album object. To get alerted on comment changes for now Uses weak references so will not prevent listeners from being garbage collected

Specified by:
addPropertyChangeListener in interface AlbumObject

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list. This method should be used to remove PropertyChangeListeners that were registered for all bound properties of this class.

If listener is null, no exception is thrown and no action is performed.

Specified by:
removePropertyChangeListener in interface AlbumObject
Parameters:
listener - the PropertyChangeListener to be removed
See Also:
addPropertyChangeListener(java.beans.PropertyChangeListener), #getPropertyChangeListeners, #removePropertyChangeListener(java.lang.String,java.beans.PropertyChangeListener)

addPropertyChangeListener

public void addPropertyChangeListener(java.lang.String propertyName,
                                      java.beans.PropertyChangeListener listener)
Specified by:
addPropertyChangeListener in interface AlbumObject

firePropertyChange

protected void firePropertyChange(java.lang.String propertyName,
                                  java.lang.Object oldValue,
                                  java.lang.Object newValue)
Support for reporting bound property changes for Object properties. This method can be called when a bound property has changed and it will send the appropriate PropertyChangeEvent to any registered PropertyChangeListeners.

Parameters:
propertyName - the property whose value has changed
oldValue - the property's previous value
newValue - the property's new value

getTransferDataFlavors

public java.awt.datatransfer.DataFlavor[] getTransferDataFlavors()
Specified by:
getTransferDataFlavors in interface java.awt.datatransfer.Transferable

isDataFlavorSupported

public boolean isDataFlavorSupported(java.awt.datatransfer.DataFlavor flavor)
Specified by:
isDataFlavorSupported in interface java.awt.datatransfer.Transferable

getTransferData

public java.lang.Object getTransferData(java.awt.datatransfer.DataFlavor flavor)
                                 throws java.awt.datatransfer.UnsupportedFlavorException,
                                        java.io.IOException
Specified by:
getTransferData in interface java.awt.datatransfer.Transferable
Throws:
java.awt.datatransfer.UnsupportedFlavorException
java.io.IOException

setRepresentingIcon

public void setRepresentingIcon(java.awt.image.BufferedImage thumbnail,
                                boolean changed)
                         throws java.io.IOException
Specified by:
setRepresentingIcon in interface AlbumObject
Throws:
java.io.IOException

updateRepresentingIcon

public void updateRepresentingIcon()
                            throws java.io.IOException
Specified by:
updateRepresentingIcon in interface AlbumObject
Throws:
java.io.IOException