texturesynthesis
Class JTexSynth

java.lang.Object
  extended by texturesynthesis.JTexSynth
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.event.ItemListener, java.awt.event.WindowListener, java.util.EventListener

public class JTexSynth
extends java.lang.Object
implements java.awt.event.ActionListener, java.awt.event.ItemListener, java.awt.event.WindowListener

The main program class of JTexSynth. This class starts the application, creates the GUI and initializes all needed parts.

Author:
Aki Koskinen

Field Summary
private  int _VERSION_MAJOR
          Application major version number.
private  int _VERSION_MICRO
          Application micro version number.
private  int _VERSION_MINOR
          Application minor version number.
private  FileExtensionFilter allImagesFileFilter
           
private  javax.swing.JButton browseButton
          Source image browsing button.
private  javax.swing.JFileChooser fileChooser
          File chooser for source image and synthesized image saving.
private  javax.swing.JFrame frame
          The main application window.
private  java.awt.Image generatedTexture
          The synthesized image.
private  ImageWindow generatedTextureIW
          A window to show the synthesized image.
private  FileExtensionFilter gifFileFilter
           
private  javax.swing.JFormattedTextField imageHeight
          Target image dimensions.
private  javax.swing.JFormattedTextField imageWidth
          Target image dimensions.
private  FileExtensionFilter jpgFileFilter
          File filters
private  javax.swing.JComboBox pluginSelection
          Selector for different plugins.
private  FileExtensionFilter pngFileFilter
           
private  javax.swing.JPanel settingsPanel
          Algorithm specific settings.
private  ImageWindow sourceImageIW
          A window to show the source image.
private  javax.swing.JTextField sourceImageTextField
          Source image file name.
private  javax.swing.JButton startButton
          Texture generation start button.
private  java.util.Hashtable<java.lang.String,TextureSynthesizer> synthesizerPlugins
          Synthesizer plugins.
private  java.lang.String version
          A string representation of the version number.
 
Constructor Summary
JTexSynth()
          Constructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          Responses to actions.
private  void browseSourceImage()
          Shows the user a file chooser to choose a source image.
private  void createGui()
          Generates the user interface.
private  javax.swing.JMenuBar createMenuBar()
          Generates the menu bar to the main application window.
private  TextureSynthesizer getPlugin(java.lang.String name)
          Gets a plugin with the given name.
private  java.util.Hashtable<java.lang.String,TextureSynthesizer> getPlugins()
          Searches the available synthesizer plugins and places an instance of each plugin to a Hashtable.
 void itemStateChanged(java.awt.event.ItemEvent event)
          Responses to item state change events.
static void main(java.lang.String[] args)
          The main method.
private  void quitProgram()
          Exits the program.
private  void saveGeneratedImage()
          Asks the user to select a file name and saves the synthesized image with this name.
private  void setSourceImageVisibility(boolean value)
          Shows or hides the window showing the source image.
private  void setSynthesizedImageVisibility(boolean value)
          Shows or hides the window showing the synthesized image.
private  void showAboutDialog()
          Shows the about dialog that tells about this program.
private  void startPlugin()
          Starts a texture synthesis plugin.
 void windowActivated(java.awt.event.WindowEvent arg0)
          Does nothing.
 void windowClosed(java.awt.event.WindowEvent arg0)
          Does nothing.
 void windowClosing(java.awt.event.WindowEvent event)
          Hides (but doesn't destroy) the image windows if they are closed.
 void windowDeactivated(java.awt.event.WindowEvent arg0)
          Does nothing.
 void windowDeiconified(java.awt.event.WindowEvent arg0)
          Does nothing.
 void windowIconified(java.awt.event.WindowEvent arg0)
          Does nothing.
 void windowOpened(java.awt.event.WindowEvent arg0)
          Does nothing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_VERSION_MAJOR

private final int _VERSION_MAJOR
Application major version number.

See Also:
Constant Field Values

_VERSION_MINOR

private final int _VERSION_MINOR
Application minor version number.

See Also:
Constant Field Values

_VERSION_MICRO

private final int _VERSION_MICRO
Application micro version number.

See Also:
Constant Field Values

version

private java.lang.String version
A string representation of the version number.


frame

private javax.swing.JFrame frame
The main application window.


pluginSelection

private javax.swing.JComboBox pluginSelection
Selector for different plugins.


imageWidth

private javax.swing.JFormattedTextField imageWidth
Target image dimensions.


imageHeight

private javax.swing.JFormattedTextField imageHeight
Target image dimensions.


sourceImageTextField

private javax.swing.JTextField sourceImageTextField
Source image file name.


browseButton

private javax.swing.JButton browseButton
Source image browsing button.


startButton

private javax.swing.JButton startButton
Texture generation start button.


settingsPanel

private javax.swing.JPanel settingsPanel
Algorithm specific settings.


fileChooser

private javax.swing.JFileChooser fileChooser
File chooser for source image and synthesized image saving.


jpgFileFilter

private FileExtensionFilter jpgFileFilter
File filters


pngFileFilter

private FileExtensionFilter pngFileFilter

gifFileFilter

private FileExtensionFilter gifFileFilter

allImagesFileFilter

private FileExtensionFilter allImagesFileFilter

synthesizerPlugins

private java.util.Hashtable<java.lang.String,TextureSynthesizer> synthesizerPlugins
Synthesizer plugins.


sourceImageIW

private ImageWindow sourceImageIW
A window to show the source image.


generatedTexture

private java.awt.Image generatedTexture
The synthesized image.


generatedTextureIW

private ImageWindow generatedTextureIW
A window to show the synthesized image.

Constructor Detail

JTexSynth

public JTexSynth()
Constructor. Finds the installed plugins and creates and shows the user interface.

Method Detail

getPlugins

private java.util.Hashtable<java.lang.String,TextureSynthesizer> getPlugins()
Searches the available synthesizer plugins and places an instance of each plugin to a Hashtable. The plugins must be in the package texturesynthesis.synthesizer and they must implement the interface texturesynthesis.TextureSynthesizer.


getPlugin

private TextureSynthesizer getPlugin(java.lang.String name)
Gets a plugin with the given name.

Parameters:
name - the name of the plugin.
Returns:
an instance of the named plugin or null if no such plugin exists.

browseSourceImage

private void browseSourceImage()
Shows the user a file chooser to choose a source image. Updates the source image and source image window according to the user selection.


setSourceImageVisibility

private void setSourceImageVisibility(boolean value)
Shows or hides the window showing the source image. Also sets the tick mark in the menus accordingly.

Parameters:
value - true to show the image window, false to hide it.

setSynthesizedImageVisibility

private void setSynthesizedImageVisibility(boolean value)
Shows or hides the window showing the synthesized image. Also sets the tick mark in the menus accordingly.

Parameters:
value - true to show the image window, false to hide it.

saveGeneratedImage

private void saveGeneratedImage()
Asks the user to select a file name and saves the synthesized image with this name. Shows an error message if no image is synthesized. So far only JPEG images are supported.


createGui

private void createGui()
Generates the user interface.


createMenuBar

private javax.swing.JMenuBar createMenuBar()
Generates the menu bar to the main application window.

Returns:
the menu bar.

startPlugin

private void startPlugin()
Starts a texture synthesis plugin.


showAboutDialog

private void showAboutDialog()
Shows the about dialog that tells about this program.


quitProgram

private void quitProgram()
Exits the program.


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Responses to actions. Mainly chooses an appropriate (private) method to call.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
event - the event fired.

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent event)
Responses to item state change events.

Specified by:
itemStateChanged in interface java.awt.event.ItemListener
Parameters:
event - the event fired.

main

public static void main(java.lang.String[] args)
The main method.

Parameters:
args - the command line arguments

windowClosing

public void windowClosing(java.awt.event.WindowEvent event)
Hides (but doesn't destroy) the image windows if they are closed.

Specified by:
windowClosing in interface java.awt.event.WindowListener
See Also:
WindowListener.windowClosing(java.awt.event.WindowEvent)

windowOpened

public void windowOpened(java.awt.event.WindowEvent arg0)
Does nothing. Method exists only to implement the interface.

Specified by:
windowOpened in interface java.awt.event.WindowListener
See Also:
WindowListener.windowOpened(java.awt.event.WindowEvent)

windowClosed

public void windowClosed(java.awt.event.WindowEvent arg0)
Does nothing. Method exists only to implement the interface.

Specified by:
windowClosed in interface java.awt.event.WindowListener
See Also:
WindowListener.windowClosed(java.awt.event.WindowEvent)

windowIconified

public void windowIconified(java.awt.event.WindowEvent arg0)
Does nothing. Method exists only to implement the interface.

Specified by:
windowIconified in interface java.awt.event.WindowListener
See Also:
WindowListener.windowIconified(java.awt.event.WindowEvent)

windowDeiconified

public void windowDeiconified(java.awt.event.WindowEvent arg0)
Does nothing. Method exists only to implement the interface.

Specified by:
windowDeiconified in interface java.awt.event.WindowListener
See Also:
WindowListener.windowDeiconified(java.awt.event.WindowEvent)

windowActivated

public void windowActivated(java.awt.event.WindowEvent arg0)
Does nothing. Method exists only to implement the interface.

Specified by:
windowActivated in interface java.awt.event.WindowListener
See Also:
WindowListener.windowActivated(java.awt.event.WindowEvent)

windowDeactivated

public void windowDeactivated(java.awt.event.WindowEvent arg0)
Does nothing. Method exists only to implement the interface.

Specified by:
windowDeactivated in interface java.awt.event.WindowListener
See Also:
WindowListener.windowDeactivated(java.awt.event.WindowEvent)