uk.co.silentsoftware.ui
Class ImageToZxSpec

java.lang.Object
  extended by uk.co.silentsoftware.ui.ImageToZxSpec

public class ImageToZxSpec
extends java.lang.Object

Very simple and noddy image to zx spectrum compatible image converter.


Field Summary
private static java.lang.String ANIM_GIF_NAME
          The ZX icon for the window
private static javax.swing.JPanel bottomPane
          The bottom pane for holding the stauts and convert button
private static javax.swing.JButton convertButton
          The convert image button
static java.lang.String DEFAULT_STATUS_MESSAGE
          The message to show when idle
private static javax.swing.JMenuItem folder
          The input folder menu item
private static float fps
          Actual frames per second for impressing your mates ;)
private static java.lang.Thread fpsThread
          The debug frames per second counter
private static javax.swing.JFrame frame
          The main UI frame
private static int frameCounter
          The total number of frames/images converted in this session
private static GifConverter gifConverter
          The ".gif" file converter
static javax.swing.ImageIcon IMAGE_ICON
          Icon for all frames
private static java.io.File[] inFiles
          Input folders to process
private static javax.swing.JMenuBar menubar
          The menu bar
private static java.io.File outFolder
          Destination folder to output files to
private static javax.swing.JMenuItem outputFolder
          The output folder menu item
private static javax.swing.JPanel p
          The panel for rendering the images
private static PreferencesDialog preferences
          The options dialog
private static PreviewFrame preview
          The preview window
private static java.awt.image.BufferedImage specLogo
          The spectrum logo when no images are loaded
private static javax.swing.JTextField statusBox
          The status box
private static java.lang.String TAP_SLIDESHOW_NAME
          The ZX icon for the window
private static TapeConverter tapeConverter
          The ".tap" file converter
 
Constructor Summary
ImageToZxSpec()
           
 
Method Summary
static void createUserInterface()
          Create the natty UI/preview window.
(package private) static void disableInput()
          Disable the UI state to prevent input
static void enableInput()
          Reset's the UI state to enable input
(package private) static javax.swing.JFrame getFrame()
           
(package private) static boolean isSupported(java.io.File f)
           
static void main(java.lang.String[] args)
          Create a single thread for the rendering and inits the UI
static void processFiles()
          Method to begin the WIP preview which submits work to the work engine and controls the UI settings and validates the content being loaded.
(package private) static void processPreview()
          Method to begin the (multi dither, not WIP) preview which submits work to the work engine and controls the UI settings and validates the content being loaded.
private static void processSingleFiles()
          Inner core method for the process files method that specifically deals with a single files.
private static void processVideo(java.io.File f)
          Inner core method for the process files method that specifically deals with a video file.
(package private) static void setInFiles(java.io.File[] inFiles)
           
(package private) static void setOutFolder(java.io.File outFolder)
           
static void setStatusMessage(java.lang.String message)
          Sets a status or error message above the convert button
(package private) static void showPreview()
           
private static void startFpsCalculator()
          A simple implementation of an FPS calculator that uses actual time difference rather than expected sleep time to determine the real FPS.
private static void startPreviewWaiter(java.util.List<java.util.concurrent.Future<WorkContainer>> futures)
          A "waiter" which waits for the work engine (the WorkDispatcher) to return a result so it can be displayed in the dither preview dialog when it is ready.
private static void startWaiter(java.util.List<java.util.concurrent.Future<WorkContainer>> futures, java.lang.String videoName)
          A "waiter" which waits for the work engine (the WorkDispatcher) to return a result so it can be displayed in the WIP preview when it is ready.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IMAGE_ICON

public static final javax.swing.ImageIcon IMAGE_ICON
Icon for all frames


DEFAULT_STATUS_MESSAGE

public static final java.lang.String DEFAULT_STATUS_MESSAGE
The message to show when idle

See Also:
Constant Field Values

frameCounter

private static int frameCounter
The total number of frames/images converted in this session


fps

private static volatile float fps
Actual frames per second for impressing your mates ;)


inFiles

private static java.io.File[] inFiles
Input folders to process


outFolder

private static java.io.File outFolder
Destination folder to output files to


specLogo

private static volatile java.awt.image.BufferedImage specLogo
The spectrum logo when no images are loaded


tapeConverter

private static final TapeConverter tapeConverter
The ".tap" file converter


gifConverter

private static final GifConverter gifConverter
The ".gif" file converter


TAP_SLIDESHOW_NAME

private static final java.lang.String TAP_SLIDESHOW_NAME
The ZX icon for the window

See Also:
Constant Field Values

ANIM_GIF_NAME

private static final java.lang.String ANIM_GIF_NAME
The ZX icon for the window

See Also:
Constant Field Values

frame

private static final javax.swing.JFrame frame
The main UI frame


p

private static javax.swing.JPanel p
The panel for rendering the images


bottomPane

private static javax.swing.JPanel bottomPane
The bottom pane for holding the stauts and convert button


convertButton

private static javax.swing.JButton convertButton
The convert image button


statusBox

private static javax.swing.JTextField statusBox
The status box


folder

private static javax.swing.JMenuItem folder
The input folder menu item


outputFolder

private static javax.swing.JMenuItem outputFolder
The output folder menu item


menubar

private static javax.swing.JMenuBar menubar
The menu bar


preferences

private static final PreferencesDialog preferences
The options dialog


preview

private static final PreviewFrame preview
The preview window


fpsThread

private static java.lang.Thread fpsThread
The debug frames per second counter

Constructor Detail

ImageToZxSpec

public ImageToZxSpec()
Method Detail

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Create a single thread for the rendering and inits the UI

Parameters:
args -
Throws:
java.lang.Exception

createUserInterface

public static void createUserInterface()
Create the natty UI/preview window. Very monolithic but I don't intend to change this much, and if I do I'll be sure to rewrite 8P


isSupported

static boolean isSupported(java.io.File f)

processPreview

static void processPreview()
Method to begin the (multi dither, not WIP) preview which submits work to the work engine and controls the UI settings and validates the content being loaded.


startPreviewWaiter

private static void startPreviewWaiter(java.util.List<java.util.concurrent.Future<WorkContainer>> futures)
A "waiter" which waits for the work engine (the WorkDispatcher) to return a result so it can be displayed in the dither preview dialog when it is ready. The list of futures contains the work dispatcher's work in progress Future tasks.

Parameters:
futures -

processFiles

public static void processFiles()
Method to begin the WIP preview which submits work to the work engine and controls the UI settings and validates the content being loaded. In particular if a video is found in the input only this file is processed.


processVideo

private static void processVideo(java.io.File f)
                          throws java.lang.InterruptedException,
                                 javax.media.NoPlayerException,
                                 java.io.IOException,
                                 java.util.concurrent.ExecutionException,
                                 java.lang.InstantiationException,
                                 java.lang.IllegalAccessException,
                                 java.lang.ClassNotFoundException
Inner core method for the process files method that specifically deals with a video file. The file is converted to a number of images and this work is put into the work engine as per the usual procedure for images. A waiter thread is initialised to pick the completed work up and as the images are loaded in order the future tasks' results remain correctly ordered when they are collected.

Parameters:
f -
Throws:
java.lang.InterruptedException
javax.media.NoPlayerException
java.io.IOException
java.util.concurrent.ExecutionException
java.lang.InstantiationException
java.lang.IllegalAccessException
java.lang.ClassNotFoundException

processSingleFiles

private static void processSingleFiles()
                                throws java.lang.InterruptedException,
                                       javax.media.NoPlayerException,
                                       java.io.IOException,
                                       java.util.concurrent.ExecutionException
Inner core method for the process files method that specifically deals with a single files. The files are loaded as images and these are put into the work engine for processing. A waiter thread is initialised to pick the completed work up and as the images are loaded in order the future tasks' results remain correctly ordered when they are collected.

Throws:
java.lang.InterruptedException
javax.media.NoPlayerException
java.io.IOException
java.util.concurrent.ExecutionException

startWaiter

private static void startWaiter(java.util.List<java.util.concurrent.Future<WorkContainer>> futures,
                                java.lang.String videoName)
A "waiter" which waits for the work engine (the WorkDispatcher) to return a result so it can be displayed in the WIP preview when it is ready. The list of futures contains the work dispatcher's work in progress Future tasks. When the results are returned as buffered images or scrs the relevant scr, tap, png, jpg etc is created. In the case of video the videoName is used for the file name base.

Parameters:
futures -

startFpsCalculator

private static void startFpsCalculator()
A simple implementation of an FPS calculator that uses actual time difference rather than expected sleep time to determine the real FPS. finalised variables in the vague hope these will be optimised and GC cleaned up in the young generation.


setStatusMessage

public static void setStatusMessage(java.lang.String message)
Sets a status or error message above the convert button

Parameters:
message -

enableInput

public static void enableInput()
Reset's the UI state to enable input


disableInput

static void disableInput()
Disable the UI state to prevent input


setInFiles

static void setInFiles(java.io.File[] inFiles)

setOutFolder

static void setOutFolder(java.io.File outFolder)

showPreview

static void showPreview()

getFrame

static javax.swing.JFrame getFrame()