Class AlbumCreator

java.lang.Object
  extended byjava.lang.Thread
      extended byAlbumCreator
All Implemented Interfaces:
java.lang.Runnable

public class AlbumCreator
extends java.lang.Thread

Master thread responsible for an album creation


Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
AlbumCreator(java.io.File sourceDir, java.io.File targetDir, int numWorkers, int maxFullSize, int maxThumbSize, int imagesPerRow, int imagesPerColumn)
          Create a new AlbumCreator
 
Method Summary
 void appendToConsole(java.lang.String s)
          Writes a string to the graphical console log
 java.lang.String convertPath(java.lang.String path)
          Converts a file's source path to a corresponding path where it's newly scaled version should be
 void copyMovieFiles()
          Copies all known movie files from their source path to their destination path, untouched
 void createErrorDialog(java.lang.String msg, java.awt.Frame lockMe)
          Generates a popup window (JDialog) with the approperiate warning
 void createSubdirs()
          Creates all directories found in source directory in target directory file structure
 void generateIndexHtml(java.io.File dir, boolean isRootDir)
          Called for each directory in the file structure to produce one or more index[2-9]*.html files.
 void generateMovieHtmlFile(java.io.File movie)
          Generates a suitable HTML file for movie watching
 java.io.File[] getData()
          Called by workers to fetch their workload.
 void parseDirectory(java.lang.String path)
          Recursively parses through a file structure, looking for files to include in the album generation
 void printHtmlIndexHeader(java.io.FileWriter fw, int pages, java.lang.String title, boolean isRootDir)
          Initiates an HTML index file with approperiate HTML code
 void run()
          Activates the AlbumCreator, causing it to spawn workers and begins creating the album
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AlbumCreator

public AlbumCreator(java.io.File sourceDir,
                    java.io.File targetDir,
                    int numWorkers,
                    int maxFullSize,
                    int maxThumbSize,
                    int imagesPerRow,
                    int imagesPerColumn)
Create a new AlbumCreator

Parameters:
sourceDir - Root directory of album repository
targetDir - Root directory of album output
numWorkers - The number of ImageScaleWorker threads to be launched
maxFullSize - Maximum picture width/height for large images
maxThumbSize - Maximum picture width/height for thumb images
imagesPerRow - Images per html page row
imagesPerColumn - Images per html page column
See Also:
ImageScaleWorker
Method Detail

run

public void run()
Activates the AlbumCreator, causing it to spawn workers and begins creating the album


appendToConsole

public void appendToConsole(java.lang.String s)
Writes a string to the graphical console log

Parameters:
s - String to be written to console
Returns:
void

generateIndexHtml

public void generateIndexHtml(java.io.File dir,
                              boolean isRootDir)
Called for each directory in the file structure to produce one or more index[2-9]*.html files.

Parameters:
dir - Directory to generate index file(s) in
isRootDir - true if this is the root directory. This will prevent creation of a hyperlink to parent directory
Returns:
void

printHtmlIndexHeader

public void printHtmlIndexHeader(java.io.FileWriter fw,
                                 int pages,
                                 java.lang.String title,
                                 boolean isRootDir)
Initiates an HTML index file with approperiate HTML code

Parameters:
fw - FileWriter to write HTML code onto
pages - Total number of index pages in this directory. Used to create links to index2.html if there are more than the maximum allowed images per page in this directory
title - Title of the index.html page
isRootDir - true if this is the root directory. This will prevent creation of a hyperlink to parent directory

getData

public java.io.File[] getData()
Called by workers to fetch their workload. Loops over the Vector of all known image files and assigns them to workers one by one. getData() is synchronized to make sure no two workers get the same file

Returns:
files File[] with two files in it. One is the source file to be scaled, the other is the file to write the scaled image to.
See Also:
ImageScaleWorker

convertPath

public java.lang.String convertPath(java.lang.String path)
Converts a file's source path to a corresponding path where it's newly scaled version should be

Parameters:
path - Path to file original
Returns:
newPath Path to where the scaled version should be written

copyMovieFiles

public void copyMovieFiles()
Copies all known movie files from their source path to their destination path, untouched


createErrorDialog

public void createErrorDialog(java.lang.String msg,
                              java.awt.Frame lockMe)
Generates a popup window (JDialog) with the approperiate warning

Parameters:
msg - The message you want to flag
lockMe - Frame to lock while error is visible
Returns:
null
See Also:
JDialog

generateMovieHtmlFile

public void generateMovieHtmlFile(java.io.File movie)
Generates a suitable HTML file for movie watching

Parameters:
movie - Movie File to generate HTML for

createSubdirs

public void createSubdirs()
Creates all directories found in source directory in target directory file structure


parseDirectory

public void parseDirectory(java.lang.String path)
Recursively parses through a file structure, looking for files to include in the album generation

Parameters:
path - Root path where search begins.