org.pscode.ui.playlist
Class PlayListPanel

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 org.pscode.ui.playlist.PlayListPanel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class PlayListPanel
extends JPanel

PlayListPanel is a class for opening, parsing and presenting M3U style play lists. It is put in a GUI that implements a trackHandler method to deal with the tracks selected in the JTable of tracks. This component offers a text filter for the tracks, a 'random' check box to determine 'next track' behaviour, and keeps a history of tracks already provided to the trackHandler method. Name stop unfltr loop Filter TRUE TRUE TRUE All TRUE FALSE TRUE Versions:

  • 2009-10-20

    Version:
    2009-10-20
    Author:
    Andrew Thompson
    See Also:
    Serialized Form

    Nested Class Summary
     
    Nested classes/interfaces inherited from class javax.swing.JPanel
    JPanel.AccessibleJPanel
     
    Nested classes/interfaces inherited from class javax.swing.JComponent
    JComponent.AccessibleJComponent
     
    Nested classes/interfaces inherited from class java.awt.Container
    Container.AccessibleAWTContainer
     
    Nested classes/interfaces inherited from class java.awt.Component
    Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
     
    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
    PlayListPanel(File f, TrackHandler trackHandler)
               
    PlayListPanel(TrackHandler trackHandler)
               
    PlayListPanel(URL url, TrackHandler trackHandler)
               
    PlayListPanel(Vector<Track> tracks, TrackHandler trackHandler)
               
     
    Method Summary
     void act()
              Make an attempt to reselect any row that is already selected, after a filter is applied or removed.
     void addDudTrack(Track track)
               
     void clearTextFilter()
               
     void constructGUI()
               
     int getArtistCount()
              Provides a count of the artists listed in this playlist.This method ignores pre/suffix of 'the' and is case insensitive.
     int getAverageTrackLength()
              Calculates the average track length of this playlist.
     Track getCurrentTrack()
               
     String getDelim(ArrayList<String> trackStrings)
              An attempt to determine the delimiter used to separate the band from the track title.
     Vector<Track> getDisplayedTracks()
               
     ArrayList<Track> getDudTracks()
               
     ArrayList getHistory()
               
     Track getNextUnplayedFromIndex(Vector<Track> all, Vector<Track> unplayed, int index)
               
     void getTable()
               
     int getTotalLength()
              Calculates the total track duration of this playlist.
     Vector<Track> getUnplayedTracks()
               
     boolean isFiltered()
               
     boolean isRandom()
               
     void loadTracks(File file)
               
     void loadTracks(InputStream is)
               
     void loadTracks(URL url)
               
     URL next()
               
     void playTrack(Track track)
               
     void popNoTracksMessage()
               
     void promptClearHistory()
               
    static String secondsToTime(int seconds)
              Convert a raw count in seconds to the more conventional, hours/minutes/seconds
     void setSelectedIndex(int select)
               
     void setTable(Vector<Track> tableTracks)
               
     void showHistoryList()
               
     void showPlayListInfo()
              Show general information on this play list, and a button to open it.
     
    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
     

    Constructor Detail

    PlayListPanel

    public PlayListPanel(TrackHandler trackHandler)

    PlayListPanel

    public PlayListPanel(URL url,
                         TrackHandler trackHandler)

    PlayListPanel

    public PlayListPanel(File f,
                         TrackHandler trackHandler)

    PlayListPanel

    public PlayListPanel(Vector<Track> tracks,
                         TrackHandler trackHandler)
    Method Detail

    addDudTrack

    public void addDudTrack(Track track)

    getDudTracks

    public ArrayList<Track> getDudTracks()

    constructGUI

    public void constructGUI()

    isRandom

    public boolean isRandom()

    getTable

    public void getTable()

    act

    public void act()
    Make an attempt to reselect any row that is already selected, after a filter is applied or removed.


    loadTracks

    public void loadTracks(File file)

    loadTracks

    public void loadTracks(URL url)

    loadTracks

    public void loadTracks(InputStream is)

    setTable

    public void setTable(Vector<Track> tableTracks)

    popNoTracksMessage

    public void popNoTracksMessage()

    getNextUnplayedFromIndex

    public Track getNextUnplayedFromIndex(Vector<Track> all,
                                          Vector<Track> unplayed,
                                          int index)

    next

    public URL next()

    getDisplayedTracks

    public Vector<Track> getDisplayedTracks()

    promptClearHistory

    public void promptClearHistory()

    showHistoryList

    public void showHistoryList()

    playTrack

    public void playTrack(Track track)

    getUnplayedTracks

    public Vector<Track> getUnplayedTracks()

    isFiltered

    public boolean isFiltered()

    clearTextFilter

    public void clearTextFilter()

    getHistory

    public ArrayList getHistory()

    getArtistCount

    public int getArtistCount()
    Provides a count of the artists listed in this playlist.This method ignores pre/suffix of 'the' and is case insensitive.

    Returns:
    The total count of artists in this playlist.

    getAverageTrackLength

    public int getAverageTrackLength()
    Calculates the average track length of this playlist.

    Returns:
    The average duration of the tracks, in seconds.

    secondsToTime

    public static String secondsToTime(int seconds)
    Convert a raw count in seconds to the more conventional, hours/minutes/seconds

    Parameters:
    seconds -
    Returns:
    Formatted time as NhNNmNNs

    getTotalLength

    public int getTotalLength()
    Calculates the total track duration of this playlist.

    Returns:
    The total duration of the tracks, in seconds.

    showPlayListInfo

    public void showPlayListInfo()
    Show general information on this play list, and a button to open it.


    getCurrentTrack

    public Track getCurrentTrack()

    setSelectedIndex

    public void setSelectedIndex(int select)

    getDelim

    public String getDelim(ArrayList<String> trackStrings)
    An attempt to determine the delimiter used to separate the band from the track title. It splits the first records on " " and stores the count of the different parts. When it reaches a point that only one part occurs exactly as many times as the record count, that part is returned as the delimiter.

    Parameters:
    trackStrings -
    Returns:
    The delimiter used to separate track from title.