org.cdavies.applerecords
Class AppleRecordsControlPanel

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--org.cdavies.applerecords.AppleRecordsControlPanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class AppleRecordsControlPanel
extends javax.swing.JPanel
implements java.awt.event.ActionListener

This Panel contains swing controls for controlling playing behaviour of AppleRecords. In addition, this class controls the player thread, and has methods for manipulating it.

At present this class is perhaps the least "finalised" in the entire software. It has been evolved, not designed to control what the PlayerThread ought to be doing, and will continue to evolve as the PlayerThread is adapted to handle downloads also

It is entirely possible (probable?) that this class will be entirely rewritten in the next version. Don't bank on its interface.

See Also:
PlayerThread, Serialized Form

Field Summary
 
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
AppleRecordsControlPanel(javax.swing.JTable trackTable, TrackListTableModel model, AppleRecordsStatusPanel status)
          Constructs a new Control Panel, of which there will be only one in any given player.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
          This class also acts as its own ActionListener to detect events which occur on this Panel's buttons.
 boolean closeDownMode()
          Controls the execution of the player thread, if it becomes false the PlayerThread will terminate, which should only happen when the application terminates.
 boolean continuePlaying()
          Indicates whether or not the PlayerThread will continue playing after the current track ends.
 Track getNextTrack()
          Returns the next in the sequence of tracks that should be played, as indicated by the the TrackTable model.
 boolean isPlaying()
          Indicates whether the player thread is playing a track at the momeent.
 void noNextTrack()
          One of the various dodgy temporary methods that may or may not dissapear faily soon.
 void playSelectedTrack()
          Indicates the PlayerThread should begin playing the currently selected track immediately.
 void selectPlayingTrack()
          This method causes the TrackTable to highlight the currently playing track as inicated by the table model.
 void stopped()
          A dodgy temporary, misnamed method.
 void stopTrack()
          Stops the currently playing track and indicates the PlayerThread should wait for a further signal to begin playing once again.
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
 
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
 

Constructor Detail

AppleRecordsControlPanel

public AppleRecordsControlPanel(javax.swing.JTable trackTable,
                                TrackListTableModel model,
                                AppleRecordsStatusPanel status)
Constructs a new Control Panel, of which there will be only one in any given player. Constucts a Swing JPanel, loads various image resources for the buttons using the image locator, and constructs some buttons for it.

In addition, it constructs and runs a new PlayerThread which will be under the direct and exclusive control o this class, hopefully to avoid more significant thread safety issues (it doesn't at present ;)

Parameters:
trackTable - The table widget in the main display, from which we extract tracks
model - The table model for the above table
status - The status panel for status related messages
See Also:
ResourceLocator, PlayerThread
Method Detail

noNextTrack

public void noNextTrack()
One of the various dodgy temporary methods that may or may not dissapear faily soon.

This one indicates that the player message should not continue playing after the end of the present track, if indeed it is actually playing at present.


isPlaying

public boolean isPlaying()
Indicates whether the player thread is playing a track at the momeent.

Returns:
true if the player thread is playing a track at the moment, false otherwise.

stopped

public void stopped()
A dodgy temporary, misnamed method. It was originally supposed to allow the PlayerThread to indicate it had stopped playing for some reason or other.

As with other similar methods, it may or may not go away in the near future.


getNextTrack

public Track getNextTrack()
Returns the next in the sequence of tracks that should be played, as indicated by the the TrackTable model.

This method is used by the PlayerThread to get the next track to be played.

Returns:
The next Track to be played, or null if no track is to be played.

selectPlayingTrack

public void selectPlayingTrack()
This method causes the TrackTable to highlight the currently playing track as inicated by the table model.

This method may, or may not be integrated in to the getNextTrack() method in the near future, depending on how the download functionality evolves.

See Also:
getNextTrack()

continuePlaying

public boolean continuePlaying()
Indicates whether or not the PlayerThread will continue playing after the current track ends.

Returns:
true if the PlayerThread should continue playing after the end of the next track, false otherwise.

closeDownMode

public boolean closeDownMode()
Controls the execution of the player thread, if it becomes false the PlayerThread will terminate, which should only happen when the application terminates.

Returns:
false if the PlayerThread should continue, true otherwise.

playSelectedTrack

public void playSelectedTrack()
Indicates the PlayerThread should begin playing the currently selected track immediately.

This happens at the expense of the currently playing track, which is terminated, no matter what stage of execution it is currently at.


stopTrack

public void stopTrack()
Stops the currently playing track and indicates the PlayerThread should wait for a further signal to begin playing once again.


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
This class also acts as its own ActionListener to detect events which occur on this Panel's buttons.

Essentially, method controls the actions of the managed PlayerThread.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
e - The description of the event which has just occured