ccs.audio.gui
Class AudioControlPanel

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 ccs.audio.gui.AudioControlPanel
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class AudioControlPanel
extends javax.swing.JPanel

A panel containing a set of controls which allow the user to control the behaviour of the audio system. During initialisation, use the setter methods here to set the state of the various non-pushbutton controls; these will set the corresponding state in the AudioController. Changes to the states of these controls (including changes generated programmatically, NB.) are notified to interested third parties as PropertyChangeEvents. (NB. If you register as one of these, expect to see lots of AWT / Swing-level change events too; you may do better to register for control changes by name rather than for all property changes.

See Also:
Serialized Form

Nested Class Summary
 class AudioControlPanel.ActionCatcher
          Undocumented.
 
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.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static java.lang.String AUTOSTART
          The name of the auto-start property.
static java.lang.String MASTERGAIN
          The name of the master gain property.
static java.lang.String TRACKMODE
          The name of the track-mode property.
 
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
AudioControlPanel(AudioController ctrl)
          An AudioControlPanel which controls the specified AudioController.
 
Method Summary
protected  void addCustomControls(javax.swing.JPanel p)
          Add custom controls to the controls sub-panel.
protected  void customiseButtonList(java.util.List<I18Action> buttons)
          Override this to customise the default list of buttons.
protected  java.awt.GridBagConstraints getButtonConstraints(int x, javax.swing.JButton button)
          Define a custom set of constraints for the specified button.
 void init()
          Call this in the dispatch thread before attempting to display the GUI.
 void setAutoStart(boolean isAuto)
          Set programmatically whether a newly-loaded track should start playing automatically.
 void setEmptyPlaylist(boolean isEmpty)
          Set whether to be in empty-playlist mode (all buttons are disabled - there's nothing to do.
 void setGain(int dB)
          Set the master gain programmatically.
 void setTracking(TrackMode tracking)
          Set the tracking mode programmatically.
 
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, getBaseline, getBaselineResizeBehavior, 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, isPaintingForPrint, 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

MASTERGAIN

public static final java.lang.String MASTERGAIN
The name of the master gain property. NB. When receiving property-change events for this property, the old-value parameter is NOT reliable.

See Also:
Constant Field Values

TRACKMODE

public static final java.lang.String TRACKMODE
The name of the track-mode property. NB. When receiving property-change events for this property, the old-value parameter is NOT reliable.

See Also:
Constant Field Values

AUTOSTART

public static final java.lang.String AUTOSTART
The name of the auto-start property. NB. When receiving property-change events for this property, the old-value parameter is NOT reliable.

See Also:
Constant Field Values
Constructor Detail

AudioControlPanel

public AudioControlPanel(AudioController ctrl)
An AudioControlPanel which controls the specified AudioController. MT-Safe.

Parameters:
ctrl - The AudioController which we control.
Method Detail

init

public void init()
Call this in the dispatch thread before attempting to display the GUI. You can use SwingUtilities.invokeAndWait(java.lang.Runnable) to do this. MT-UNSAFE - dispatch thread only.


setTracking

public void setTracking(TrackMode tracking)
Set the tracking mode programmatically. You must call this during initialisation.

Parameters:
tracking - The new tracking mode.

setAutoStart

public void setAutoStart(boolean isAuto)
Set programmatically whether a newly-loaded track should start playing automatically. If not, the track will stay paused until the user presses play. You must call this during initialisation.

Parameters:
isAuto - Whether to auto-start.

setGain

public void setGain(int dB)
Set the master gain programmatically. You must call this during initialisation.

Parameters:
dB - The new master gain. Allowed values are -12 to +12.

setEmptyPlaylist

public void setEmptyPlaylist(boolean isEmpty)
Set whether to be in empty-playlist mode (all buttons are disabled - there's nothing to do.

Parameters:
isEmpty - Whether to act as though the playlist is empty.

customiseButtonList

protected void customiseButtonList(java.util.List<I18Action> buttons)
Override this to customise the default list of buttons.

Parameters:
buttons - The I18Actions corresponding to the list of default buttons. These are, in order: first (track), previous, PPL (play/pause/loop), stop, next, and last (track). Add any customisation you need. DON'T remove the play button! You'll need to create your own I18NDispatcher to create suitable I18Actions.

getButtonConstraints

protected java.awt.GridBagConstraints getButtonConstraints(int x,
                                                           javax.swing.JButton button)
Define a custom set of constraints for the specified button. If your custom buttons need special handling, override this. You can also use this as a hook to modify the layout of the default buttons, although this is generally not recommended.

Parameters:
x - The X coord of the button. Your return must obey this.
button - The button which will be added. Use button.getAction() to get the action which identifies the button.

addCustomControls

protected void addCustomControls(javax.swing.JPanel p)
Add custom controls to the controls sub-panel. (This contains the gain slider and checkboxes; the "tape-deck" push-buttons are handled via customiseButtons / getButtonConstraints.) This is purely a visual hook; you are responsible for making any extra elements you add here actually work. RTFS to find out where the current controls are located, or make an educated guess (this should work).