org.pdfsam.guiclient.business.thumbnails.creators
Class AbstractThumbnailCreator

java.lang.Object
  extended by org.pdfsam.guiclient.business.thumbnails.creators.AbstractThumbnailCreator
All Implemented Interfaces:
ThumbnailsCreator

public abstract class AbstractThumbnailCreator
extends java.lang.Object
implements ThumbnailsCreator

Abstract thumbnail creator

Author:
Andrea Vacondio

Field Summary
 
Fields inherited from interface org.pdfsam.guiclient.business.thumbnails.creators.ThumbnailsCreator
DEFAULT_RESIZE_PERCENTAGE
 
Constructor Summary
AbstractThumbnailCreator()
           
 
Method Summary
 void clean(long id)
          clean the thumbnails generation with the given id
protected abstract  void finalizeThumbnailsCreation()
          generic finalization.
protected abstract  java.util.concurrent.Callable<java.lang.Boolean> getCloserTask()
           
protected  long getCurrentId()
           
protected abstract  DocumentInfo getDocumentInfo()
           
protected abstract  java.util.Vector<VisualPageListItem> getDocumentModel(java.util.List<DocumentPage> template)
          The model to set on thumbnails list before the thumbnails generation starts.
protected abstract  java.util.Collection<? extends java.util.concurrent.Callable<java.lang.Boolean>> getGenerationTasks(java.util.Vector<VisualPageListItem> modelList)
           
protected  java.io.File getInputFile()
           
 java.awt.image.BufferedImage getPageImage(java.io.File inputFile, java.lang.String password, int page)
           
 java.awt.image.BufferedImage getPageImage(java.lang.String fileName, java.lang.String password, int page)
           
 java.awt.image.BufferedImage getPageImage(java.lang.String fileName, java.lang.String password, int page, int rotation)
           
protected  JVisualPdfPageSelectionPanel getPanel()
           
protected  java.lang.String getProvidedPassword()
           
 java.awt.image.BufferedImage getThumbnail(java.lang.String fileName, java.lang.String password, int page, float resizePercentage)
           
protected abstract  void initThumbnailsCreation()
          initialization of the thumbnail creation process
 void initThumbnailsPanel(java.io.File inputFile, java.lang.String password, JVisualPdfPageSelectionPanel panel, long id, java.util.List<DocumentPage> template)
          Initialize the input panel.
 void initThumbnailsPanel(java.lang.String fileName, java.lang.String password, JVisualPdfPageSelectionPanel panel, long id, java.util.List<DocumentPage> template)
          Initialize the input panel.
protected abstract  boolean openInputDocument()
          Opens the input document
protected  void setProvidedPassword(java.lang.String providedPassword)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.pdfsam.guiclient.business.thumbnails.creators.ThumbnailsCreator
getCreatorIdentifier, getCreatorName, getPageImage, getResolution, getThumbnail
 

Constructor Detail

AbstractThumbnailCreator

public AbstractThumbnailCreator()
Method Detail

getPageImage

public java.awt.image.BufferedImage getPageImage(java.lang.String fileName,
                                                 java.lang.String password,
                                                 int page,
                                                 int rotation)
                                          throws ThumbnailCreationException
Specified by:
getPageImage in interface ThumbnailsCreator
rotation - page rotation in degrees
Returns:
the image
Throws:
ThumbnailCreationException

getPageImage

public java.awt.image.BufferedImage getPageImage(java.lang.String fileName,
                                                 java.lang.String password,
                                                 int page)
                                          throws ThumbnailCreationException
Specified by:
getPageImage in interface ThumbnailsCreator
Parameters:
fileName - pdf document
password - document password or null if no password is needed
Returns:
an image version of the given page
Throws:
ThumbnailCreationException

getThumbnail

public java.awt.image.BufferedImage getThumbnail(java.lang.String fileName,
                                                 java.lang.String password,
                                                 int page,
                                                 float resizePercentage)
                                          throws ThumbnailCreationException
Specified by:
getThumbnail in interface ThumbnailsCreator
Parameters:
fileName - pdf document
password - document password or null if no password is needed
page - page nmber
resizePercentage - resize level
Returns:
a thumbnail of the given page
Throws:
ThumbnailCreationException

clean

public void clean(long id)
Description copied from interface: ThumbnailsCreator
clean the thumbnails generation with the given id

Specified by:
clean in interface ThumbnailsCreator

initThumbnailsPanel

public void initThumbnailsPanel(java.lang.String fileName,
                                java.lang.String password,
                                JVisualPdfPageSelectionPanel panel,
                                long id,
                                java.util.List<DocumentPage> template)
                         throws ThumbnailCreationException
Description copied from interface: ThumbnailsCreator
Initialize the input panel. Set the document properties on the panel and starts previews generation.

Specified by:
initThumbnailsPanel in interface ThumbnailsCreator
password - document password or null if no password is needed
id - Id for this thumbnails generation
template - template for the document pages (order, rotation infos..)
Throws:
ThumbnailCreationException

initThumbnailsPanel

public void initThumbnailsPanel(java.io.File inputFile,
                                java.lang.String password,
                                JVisualPdfPageSelectionPanel panel,
                                long id,
                                java.util.List<DocumentPage> template)
                         throws ThumbnailCreationException
Description copied from interface: ThumbnailsCreator
Initialize the input panel. Set the document properties on the panel and starts previews generation.

Specified by:
initThumbnailsPanel in interface ThumbnailsCreator
Parameters:
inputFile - pdf document
password - document password or null if no password is needed
id - Id for this thumbnails generation
template - template for the document pages (order, rotation infos..)
Throws:
ThumbnailCreationException

getPageImage

public java.awt.image.BufferedImage getPageImage(java.io.File inputFile,
                                                 java.lang.String password,
                                                 int page)
                                          throws ThumbnailCreationException
Specified by:
getPageImage in interface ThumbnailsCreator
Parameters:
inputFile - pdf document
password - document password or null if no password is needed
Returns:
an image version of the given page
Throws:
ThumbnailCreationException

initThumbnailsCreation

protected abstract void initThumbnailsCreation()
                                        throws ThumbnailCreationException
initialization of the thumbnail creation process

Throws:
ThumbnailCreationException

openInputDocument

protected abstract boolean openInputDocument()
                                      throws ThumbnailCreationException
Opens the input document

Returns:
true if opened correctly
Throws:
ThumbnailCreationException

getDocumentInfo

protected abstract DocumentInfo getDocumentInfo()
                                         throws ThumbnailCreationException
Returns:
the DocumentiInfo to set on the thumbnails panel
Throws:
ThumbnailCreationException

getDocumentModel

protected abstract java.util.Vector<VisualPageListItem> getDocumentModel(java.util.List<DocumentPage> template)
                                                                  throws ThumbnailCreationException
The model to set on thumbnails list before the thumbnails generation starts. This is used to show hourglasses images as thumbnails.

Parameters:
template - Pages template. Used when loading an environment to set rotation and other informations
Returns:
a Vector of VisualPageListItem
Throws:
ThumbnailCreationException

getCloserTask

protected abstract java.util.concurrent.Callable<java.lang.Boolean> getCloserTask()
                                                                           throws ThumbnailCreationException
Returns:
The Collable that is submitted when all the thumbnails generation tasks are terminated. Used to close the document or other clean operations.
Throws:
ThumbnailCreationException

getGenerationTasks

protected abstract java.util.Collection<? extends java.util.concurrent.Callable<java.lang.Boolean>> getGenerationTasks(java.util.Vector<VisualPageListItem> modelList)
                                                                                                                throws ThumbnailCreationException
Parameters:
modelList - the model list set on the Visual List Component
Returns:
a Collection of tasks that will run the thumbnails generation
Throws:
ThumbnailCreationException

finalizeThumbnailsCreation

protected abstract void finalizeThumbnailsCreation()
                                            throws ThumbnailCreationException
generic finalization. It shouldn't clean resources used by the Thumbnails Generation Tasks (Callable).

Throws:
ThumbnailCreationException

getProvidedPassword

protected java.lang.String getProvidedPassword()
Returns:
the providedPassword

setProvidedPassword

protected void setProvidedPassword(java.lang.String providedPassword)
Parameters:
providedPassword - the providedPassword to set

getInputFile

protected java.io.File getInputFile()
Returns:
the inputFile

getPanel

protected JVisualPdfPageSelectionPanel getPanel()
Returns:
the panel

getCurrentId

protected long getCurrentId()
Returns:
the currentId