net.luniks.jtvd
Class TitleMenuPanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JPanel
                  extended bynet.luniks.jtvd.TitleMenuPanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class TitleMenuPanel
extends javax.swing.JPanel

JPanel providing the UI for JTVD with that a simple title menu can be created. It consists of a scrollable drawing area with a popup menu and some buttons. It contains the logic that creates the images for the menu and executes the command to create audio and video streams

Author:
Torsten Römer, luniks.net
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
private  javax.swing.JMenuItem addTextMenuItem
           
private  javax.swing.JButton addTitlesButton
           
private  javax.swing.ImageIcon addTitlesIcon
           
private  javax.swing.JMenuItem arrangeMenuItem
           
private  int aspect
           
static int ASPECT_16TO9
           
static int ASPECT_4TO3
           
private  javax.swing.JButton audioButton
           
private  TitleMenuAudioDialog audioDialog
           
private  javax.swing.ImageIcon audioIcon
           
private  javax.swing.JButton cancelButton
           
private  javax.swing.ImageIcon cancelIcon
           
private  javax.swing.JPanel controlPanel
           
private  boolean createMenuCanceled
           
private  boolean createMenuError
           
private  boolean createStartedLocally
           
private  javax.swing.JMenuItem deleteMenuItem
           
static java.lang.String FILE_AUDIO
           
static java.lang.String FILE_BACKGROUND
           
static java.lang.String FILE_HIGHLIGHT
           
static java.lang.String FILE_MENU
           
static java.lang.String FILE_MPEG2
           
static java.lang.String FILE_SELECT
           
static java.lang.String FILE_SPUCONF
           
static java.lang.String FILE_VIDEO
           
private  int imageHeight
           
private  ImagePanel imagePanel
           
private  int imageWidth
           
private  JTVDFrame mainFrame
           
static java.lang.String MENU
           
private  java.awt.event.MouseListener mousePressedListener
           
private  int norm
           
static int NORM_NTSC
           
static int NORM_PALSECAM
           
private  java.awt.Dimension panelSize
           
private  javax.swing.JPopupMenu popupMenu
           
private  java.awt.Point popupMenuLocation
           
private  javax.swing.JScrollPane scrollPane
           
static java.awt.Dimension SIZE_NTSC
           
static java.awt.Dimension SIZE_PAL
           
static java.awt.Dimension SIZE_SMALL
           
private  javax.swing.JMenuItem sizeNTSCMenuItem
           
private  javax.swing.JMenuItem sizePALMenuItem
           
private  javax.swing.JMenuItem sizeSmallMenuItem
           
private  javax.swing.JButton styleButton
           
private  TitleMenuStyleDialog styleDialog
           
private  javax.swing.ImageIcon styleIcon
           
private  javax.swing.JMenuItem styleMenuItem
           
private  javax.swing.JButton testButton
           
private  javax.swing.ImageIcon testIcon
           
private  javax.swing.JButton textButton
           
private  javax.swing.ImageIcon textIcon
           
private  javax.swing.JMenuItem textMenuItem
           
private  javax.swing.JMenuItem titleMenuItem
           
private  java.io.File workDir
           
 
Fields inherited from class javax.swing.JPanel
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Container
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TitleMenuPanel(JTVDFrame frame)
          Initializes the components, creates the layout, sets up action listeners and so on.
 
Method Summary
private  void addTextItemAction()
          Called when the user chooses "Add Text" from the popup menu and adds a (text) item at the location of the popup menu
private  void addTitlesAction()
          Called when the user clicks on the button "Add Titles" and prompts for confirmation if any existing menu items should be replaced, and then calls setTitlesFromTitlePanel()
private  void arrangeItemAction()
          Called when the user chooses "Arrange" from the popup menu and arranges the menu items
private  void audioAction()
          Called when the user chooses "Audio..." from the popup menu or clicks on the "Audio..." button and brings up the audio dialog
private  void calcPanelSize()
          Modifies the panelSize instance variable used for holding the size of the drawing area to fit the current aspect ratio by keeping the height and modifying the width accordingly
 void cancel()
          Canceles the current process and sets the instance variable createMenuCanceled to true
private  void cancelAction()
          Called when the user presses the "Cancel" button and cancels any menu-creating process immediately with exception for the creation of the images which cannot be cancelled.
 void create(boolean test)
          Calls the relevant methods in order to create the menu.
private  void createAction()
          Called when the users presses "Test" and starts the menu creation after checking if there is any other process running in which case it will pop up a message and return
private  void createImages()
          Calls the relevant methods to create the background, highlight and select images for the menu
private  void createMenu(boolean test)
          Creates and runs the processes for creating an audio and video stream, multiplexing audio and video and adding the subtitles.
private  void createSpuconf()
          Creates the configuration file for spuconf
private  void deleteItemAction()
          Called when the user chooses "Delete" while a "deleteable" item is selected and deletes that item
 ImagePanel getImagePanel()
          Returns the reference to the ImagePanel used as drawing area
private  void popupAction(java.awt.event.MouseEvent me)
          Called when when the user right-clicks on the drawing.
 void setAspect(int aspect)
          Sets the aspect ratio of the panel used as drawing area to the ratio given as argument after calculating the dimensions according to the current size
 void setNorm(int norm)
          Sets the size of the menu images according to the video norm given as argument.
 void setPanelSize(java.awt.Dimension size)
          Sets the size of the panel used as drawing area to the size given as argument after calculating the dimensions according to the current aspect ratio
 void setTitlesFromTitlePanel()
          Creates one menu item for each title the user has marked to be included in the DVD, adds them to the drawing area and arranges them.
 void setWorkDir(java.io.File dir)
          Sets the directory in which the menu and all temporary files are created.
private  void styleAction()
          Called when the user chooses "Style..." from the popup menu or clicks on the "Style..." button and brings up the style dialog
private  void textAction()
          Called when the user chooses "Text..." from the popup menu or clicks on the "Text..." button while an item is selected and brings up the dialog prompting the user for the new text for the item.
 void updateUI()
          Updates the current look and feel by calling SwingUtilities.updateComponentTreeUI() for all components in this class that are not affected by the same call for this class because they are not child components of this class
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mainFrame

private JTVDFrame mainFrame

MENU

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

FILE_BACKGROUND

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

FILE_HIGHLIGHT

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

FILE_SELECT

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

FILE_SPUCONF

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

FILE_AUDIO

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

FILE_VIDEO

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

FILE_MPEG2

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

FILE_MENU

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

SIZE_SMALL

public static final java.awt.Dimension SIZE_SMALL

SIZE_NTSC

public static final java.awt.Dimension SIZE_NTSC

SIZE_PAL

public static final java.awt.Dimension SIZE_PAL

ASPECT_4TO3

public static final int ASPECT_4TO3
See Also:
Constant Field Values

ASPECT_16TO9

public static final int ASPECT_16TO9
See Also:
Constant Field Values

NORM_PALSECAM

public static final int NORM_PALSECAM
See Also:
Constant Field Values

NORM_NTSC

public static final int NORM_NTSC
See Also:
Constant Field Values

imagePanel

private ImagePanel imagePanel

controlPanel

private javax.swing.JPanel controlPanel

scrollPane

private javax.swing.JScrollPane scrollPane

popupMenu

private javax.swing.JPopupMenu popupMenu

titleMenuItem

private javax.swing.JMenuItem titleMenuItem

addTextMenuItem

private javax.swing.JMenuItem addTextMenuItem

textMenuItem

private javax.swing.JMenuItem textMenuItem

styleMenuItem

private javax.swing.JMenuItem styleMenuItem

arrangeMenuItem

private javax.swing.JMenuItem arrangeMenuItem

sizeSmallMenuItem

private javax.swing.JMenuItem sizeSmallMenuItem

sizeNTSCMenuItem

private javax.swing.JMenuItem sizeNTSCMenuItem

sizePALMenuItem

private javax.swing.JMenuItem sizePALMenuItem

deleteMenuItem

private javax.swing.JMenuItem deleteMenuItem

popupMenuLocation

private java.awt.Point popupMenuLocation

styleDialog

private TitleMenuStyleDialog styleDialog

audioDialog

private TitleMenuAudioDialog audioDialog

addTitlesButton

private javax.swing.JButton addTitlesButton

textButton

private javax.swing.JButton textButton

styleButton

private javax.swing.JButton styleButton

audioButton

private javax.swing.JButton audioButton

testButton

private javax.swing.JButton testButton

cancelButton

private javax.swing.JButton cancelButton

addTitlesIcon

private javax.swing.ImageIcon addTitlesIcon

textIcon

private javax.swing.ImageIcon textIcon

styleIcon

private javax.swing.ImageIcon styleIcon

audioIcon

private javax.swing.ImageIcon audioIcon

testIcon

private javax.swing.ImageIcon testIcon

cancelIcon

private javax.swing.ImageIcon cancelIcon

mousePressedListener

private java.awt.event.MouseListener mousePressedListener

imageWidth

private int imageWidth

imageHeight

private int imageHeight

panelSize

private java.awt.Dimension panelSize

aspect

private int aspect

norm

private int norm

workDir

private java.io.File workDir

createMenuError

private boolean createMenuError

createMenuCanceled

private boolean createMenuCanceled

createStartedLocally

private boolean createStartedLocally
Constructor Detail

TitleMenuPanel

public TitleMenuPanel(JTVDFrame frame)
Initializes the components, creates the layout, sets up action listeners and so on. The frame argument is used as a handle to other components of the application.

Parameters:
frame - reference to the main application window
Method Detail

setNorm

public void setNorm(int norm)
Sets the size of the menu images according to the video norm given as argument. The norm is also used for creating the video streams.

Parameters:
norm - the norm of the menu to be created

setPanelSize

public void setPanelSize(java.awt.Dimension size)
Sets the size of the panel used as drawing area to the size given as argument after calculating the dimensions according to the current aspect ratio

Parameters:
size - the new size of the drawing area

setAspect

public void setAspect(int aspect)
Sets the aspect ratio of the panel used as drawing area to the ratio given as argument after calculating the dimensions according to the current size

Parameters:
aspect - the new aspect ration of the drawing area

getImagePanel

public ImagePanel getImagePanel()
Returns the reference to the ImagePanel used as drawing area

Returns:
reference to the ImagePanel instance

calcPanelSize

private void calcPanelSize()
Modifies the panelSize instance variable used for holding the size of the drawing area to fit the current aspect ratio by keeping the height and modifying the width accordingly


setWorkDir

public void setWorkDir(java.io.File dir)
Sets the directory in which the menu and all temporary files are created.

Parameters:
dir - the working directory used for the menu creation

setTitlesFromTitlePanel

public void setTitlesFromTitlePanel()
Creates one menu item for each title the user has marked to be included in the DVD, adds them to the drawing area and arranges them.


popupAction

private void popupAction(java.awt.event.MouseEvent me)
Called when when the user right-clicks on the drawing. Updates and pops up the popup menu


addTitlesAction

private void addTitlesAction()
Called when the user clicks on the button "Add Titles" and prompts for confirmation if any existing menu items should be replaced, and then calls setTitlesFromTitlePanel()


addTextItemAction

private void addTextItemAction()
Called when the user chooses "Add Text" from the popup menu and adds a (text) item at the location of the popup menu


arrangeItemAction

private void arrangeItemAction()
Called when the user chooses "Arrange" from the popup menu and arranges the menu items


deleteItemAction

private void deleteItemAction()
Called when the user chooses "Delete" while a "deleteable" item is selected and deletes that item


styleAction

private void styleAction()
Called when the user chooses "Style..." from the popup menu or clicks on the "Style..." button and brings up the style dialog


audioAction

private void audioAction()
Called when the user chooses "Audio..." from the popup menu or clicks on the "Audio..." button and brings up the audio dialog


textAction

private void textAction()
Called when the user chooses "Text..." from the popup menu or clicks on the "Text..." button while an item is selected and brings up the dialog prompting the user for the new text for the item.


cancelAction

private void cancelAction()
Called when the user presses the "Cancel" button and cancels any menu-creating process immediately with exception for the creation of the images which cannot be cancelled.


createAction

private void createAction()
Called when the users presses "Test" and starts the menu creation after checking if there is any other process running in which case it will pop up a message and return


create

public void create(boolean test)
Calls the relevant methods in order to create the menu. Runs some checks first. The argument is used to indicate if the purpose of this method call is just a test or if it should be followed by authoring and burning the DVD.

Parameters:
test - if this is a test or not

cancel

public void cancel()
Canceles the current process and sets the instance variable createMenuCanceled to true


createImages

private void createImages()
                   throws java.lang.Exception
Calls the relevant methods to create the background, highlight and select images for the menu

Throws:
java.lang.Exception

createSpuconf

private void createSpuconf()
                    throws java.lang.Exception
Creates the configuration file for spuconf

Throws:
java.lang.Exception

createMenu

private void createMenu(boolean test)
                 throws java.lang.Exception
Creates and runs the processes for creating an audio and video stream, multiplexing audio and video and adding the subtitles. The commandlines are created by methods in the class TitleMenuCommands The boolean argument is used to indicate if after menu creation has completed, the user should be asked if he/she wants to view the created video or not.

Throws:
java.lang.Exception

updateUI

public void updateUI()
Updates the current look and feel by calling SwingUtilities.updateComponentTreeUI() for all components in this class that are not affected by the same call for this class because they are not child components of this class



Copyright (c) 2004, 2005 Torsten Römer, dode@luniks.net