de.sciss.io
Class AudioFileFormatPane

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JPanel
                  extended by de.sciss.gui.SpringPanel
                      extended by de.sciss.io.AudioFileFormatPane
All Implemented Interfaces:
PreferenceNodeSync, java.awt.event.ItemListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class AudioFileFormatPane
extends SpringPanel
implements java.awt.event.ItemListener, PreferenceNodeSync

A multi component panel that provides gadgets for specification of the output format of an audio file, such as file format, resolution or sample rate. It implements the PreferenceNodeSync interface, allowing the automatic saving and recalling of its gadget's values from/to preferences.

Version:
0.70, 10-Mar-06
Author:
Hanns Holger Rutz
See Also:
PreferenceNodeSync, AudioFileDescr, Serialized Form
Synchronization:
all methods should be invoked only in the event thread
Todo:
sample rates should be user adjustable through a JComboBox with an editable field. this to-do has low priority since meloncillo is not really interested in audio files.

Nested Class Summary
 
Nested classes/interfaces inherited from class de.sciss.gui.SpringPanel
SpringPanel.ComponentHeightRatioSpring, SpringPanel.ComponentWidthRatioSpring, SpringPanel.RatioSpring
 
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int CHANNELS
          Constructor-Flag : create channel num gadgets
static int ENCODING
          Constructor-Flag : create sample encoding gadget
static int FORMAT
          Constructor-Flag : create file type gadget
static int FORMAT_ENCODING_RATE
          Constructor-Flag : conventient combination of FORMAT, ENCODING and RATE.
static int GAIN
          Constructor-Flag : create gain gadget
static int GAIN_NORMALIZE
          Constructor-Flag : conventient combination of GAIN and NORMALIZE.
static int NEW_FILE_FLAGS
          Constructor-Flag : conventient combination of FORMAT, ENCODING, RATE, CHANNELS.
static int NORMALIZE
          Constructor-Flag : create normalize option
static int RATE
          Constructor-Flag : create sample rate gadget
 
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.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
AudioFileFormatPane()
           
AudioFileFormatPane(int flags)
          Construct a new AudioFileFormatPane with the shown components specified by the given flags.
 
Method Summary
 void automaticFileSuffix(PathField ggPath)
          Registers a PathField to be updated upon format switches.
 void fromDescr(AudioFileDescr source)
          Copy a sound format from the given AudioFileDescr to the corresponding gadgets in the pane.
 java.lang.String getEncodingString()
          Returns a text representation of the encoding (integer/floating point and bit depth).
 int getFlags()
           
 java.lang.String getFormatString()
          Returns a text representation of the file format type.
 double getGain()
          Return the value of the gain gadget (in decibels).
 boolean getNormalized()
          Return the state of the 'normalized' checkbox of the pane.
 void itemStateChanged(java.awt.event.ItemEvent e)
           
 void setFlags(int flags)
           
 void setPreferences(java.util.prefs.Preferences prefs)
          Enables Preferences synchronization.
 void toDescr(AudioFileDescr target)
          Copy the internal state of the AudioFileFormatPane into the AudioFileDescr object.
 
Methods inherited from class de.sciss.gui.SpringPanel
gridAdd, gridAdd, gridAdd, makeCompactGrid, makeCompactGrid, makeGrid, setInitialX, setInitialY, setPadding, setTitle, setXPad, setYPad
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, 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

FORMAT

public static final int FORMAT
Constructor-Flag : create file type gadget

See Also:
Constant Field Values

ENCODING

public static final int ENCODING
Constructor-Flag : create sample encoding gadget

See Also:
Constant Field Values

RATE

public static final int RATE
Constructor-Flag : create sample rate gadget

See Also:
Constant Field Values

GAIN

public static final int GAIN
Constructor-Flag : create gain gadget

See Also:
Constant Field Values

NORMALIZE

public static final int NORMALIZE
Constructor-Flag : create normalize option

See Also:
Constant Field Values

CHANNELS

public static final int CHANNELS
Constructor-Flag : create channel num gadgets

See Also:
Constant Field Values

FORMAT_ENCODING_RATE

public static final int FORMAT_ENCODING_RATE
Constructor-Flag : conventient combination of FORMAT, ENCODING and RATE.

See Also:
Constant Field Values

NEW_FILE_FLAGS

public static final int NEW_FILE_FLAGS
Constructor-Flag : conventient combination of FORMAT, ENCODING, RATE, CHANNELS.

See Also:
Constant Field Values

GAIN_NORMALIZE

public static final int GAIN_NORMALIZE
Constructor-Flag : conventient combination of GAIN and NORMALIZE.

See Also:
Constant Field Values
Constructor Detail

AudioFileFormatPane

public AudioFileFormatPane()

AudioFileFormatPane

public AudioFileFormatPane(int flags)
Construct a new AudioFileFormatPane with the shown components specified by the given flags.

Parameters:
flags - a bitwise OR combination of gadget creation flags such as FORMAT or GAIN_NORMALIZE
Method Detail

setFlags

public void setFlags(int flags)

getFlags

public int getFlags()

toDescr

public void toDescr(AudioFileDescr target)
Copy the internal state of the AudioFileFormatPane into the AudioFileDescr object. This will fill in the type, bitsPerSample, sampleFormat, rate and channels fields, provided that the pane was specified to contain corresponding gadgets

Parameters:
target - the description whose format values are to be overwritten.

getGain

public double getGain()
Return the value of the gain gadget (in decibels). If the pane was not created without a dedicated gain gadget, this method returns 0.0.

Returns:
the pane's gain setting or 0.0 if no gain gadget exists.

getEncodingString

public java.lang.String getEncodingString()
Returns a text representation of the encoding (integer/floating point and bit depth). This String is compatible with SuperCollider's /b_write command.

Returns:
encoding string, such as "int16"

getFormatString

public java.lang.String getFormatString()
Returns a text representation of the file format type. This String is compatible with SuperCollider's /b_write command.

Returns:
file format string, such as "aiff"

getNormalized

public boolean getNormalized()
Return the state of the 'normalized' checkbox of the pane.

Returns:
true if the pane's 'normalized' checkbox was checked, false otherwise or if no checkbox gadget exists.

automaticFileSuffix

public void automaticFileSuffix(PathField ggPath)
Registers a PathField to be updated upon format switches. When the user selects a different format, the path's suffix will be updated accordingly.

Parameters:
ggPath - the path field to update or null to stop updating.

fromDescr

public void fromDescr(AudioFileDescr source)
Copy a sound format from the given AudioFileDescr to the corresponding gadgets in the pane.


itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent e)
Specified by:
itemStateChanged in interface java.awt.event.ItemListener

setPreferences

public void setPreferences(java.util.prefs.Preferences prefs)
Description copied from interface: PreferenceNodeSync
Enables Preferences synchronization. This method is not thread safe and must be called from the event thread. When a preference change is received, the GUI is updated and dispatches an event to registered listeners. Likewise, if the user adjusts the GUI value, the preference will be updated. The same is true, if you call one of the value changing methods.

Specified by:
setPreferences in interface PreferenceNodeSync
Parameters:
prefs - the preferences node in which the values are stored, or null to disable prefs sync.