mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
Initial commit of redesigned internal processing and audio management.
Note: Several of the decoders are currently non-functioning in this commit. If you want the latest functioning codebase, please checkout the commit prior to this one. All decoders will eventually be updated with this new architecture. Currently broken: - Logging and recording - Aux decoders (Fleetsync/MDC/LoJack/Tait) - LTR/Passport decoders Changes in this commit: - Module architecture for decoders and components with central provisioning by the DecoderFactory - Transition from Complex sample stream processing to float buffer processing for improved memory management - Redesigned filter structures - to support buffers and streams - Resolved several memory leak issues - Universal sharing of the thread pool manager - Added centralized audio management with call/user prioritization and new gui with mute/volume controls - Embedded audio metadata for eventual streaming support - Redesigned ProcessingChain to support independent re-use - Added new TrafficChannelManager to handle traffic channel allocations - Traffic Channel pool size and Call timeout available in P25 and MPT1327 configs - Redesigned channel and decoder gui components
This commit is contained in:
304
src/module/decode/state/ChannelList.java
Normal file
304
src/module/decode/state/ChannelList.java
Normal file
@@ -0,0 +1,304 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package module.decode.state;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.util.HashMap;
|
||||
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.SwingUtilities;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import playlist.PlaylistManager;
|
||||
import settings.ColorSetting.ColorSettingName;
|
||||
import settings.ColorSettingMenuItem;
|
||||
import settings.ColorSettingResetMenuItem;
|
||||
import settings.SettingsManager;
|
||||
import controller.channel.Channel;
|
||||
import controller.channel.ChannelEvent;
|
||||
import controller.channel.ChannelEventListener;
|
||||
|
||||
/**
|
||||
* Gui wrapper for the list of currently processing primary channels
|
||||
*/
|
||||
public class ChannelList extends JPanel implements ChannelEventListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final static Logger mLog = LoggerFactory.getLogger( ChannelList.class );
|
||||
|
||||
private HashMap<Channel,ChannelCollectionPanel> mDisplayedPanels =
|
||||
new HashMap<Channel,ChannelCollectionPanel>();
|
||||
|
||||
private PlaylistManager mPlaylistManager;
|
||||
private SettingsManager mSettingsManager;
|
||||
|
||||
public ChannelList( PlaylistManager playlistManager,
|
||||
SettingsManager settingsManager )
|
||||
{
|
||||
mPlaylistManager = playlistManager;
|
||||
mSettingsManager = settingsManager;
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[]0[]") );
|
||||
setBackground( Color.BLACK );
|
||||
|
||||
addMouseListener( new ListSelectionListener() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelChanged( ChannelEvent event )
|
||||
{
|
||||
switch( event.getEvent() )
|
||||
{
|
||||
case CHANNEL_PROCESSING_STARTED:
|
||||
addChannelPanel( event.getChannel() );
|
||||
break;
|
||||
case CHANNEL_PROCESSING_STOPPED:
|
||||
removeChannelPanel( event.getChannel() );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void addChannelPanel( Channel channel )
|
||||
{
|
||||
if( !mDisplayedPanels.containsKey( channel ) )
|
||||
{
|
||||
ChannelCollectionPanel panel = new ChannelCollectionPanel(
|
||||
mPlaylistManager, mSettingsManager, channel );
|
||||
|
||||
add( panel, "wrap" );
|
||||
|
||||
mDisplayedPanels.put( channel, panel );
|
||||
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
public void removeChannelPanel( Channel channel )
|
||||
{
|
||||
if( mDisplayedPanels.containsKey( channel ) )
|
||||
{
|
||||
ChannelCollectionPanel panel = mDisplayedPanels.remove( channel );
|
||||
|
||||
if( panel != null )
|
||||
{
|
||||
remove( panel );
|
||||
|
||||
panel.dispose();
|
||||
}
|
||||
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
public void setSelectedChannel( Channel channel )
|
||||
{
|
||||
/* Send channel selection to each channel panel */
|
||||
for( ChannelCollectionPanel panel: mDisplayedPanels.values() )
|
||||
{
|
||||
panel.setSelectedChannel( channel );
|
||||
}
|
||||
}
|
||||
|
||||
public class ListSelectionListener implements MouseListener
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked( MouseEvent e )
|
||||
{
|
||||
Component component = getComponentAt( e.getPoint() );
|
||||
|
||||
if( component instanceof ChannelCollectionPanel )
|
||||
{
|
||||
ChannelCollectionPanel panel = (ChannelCollectionPanel)component;
|
||||
|
||||
Point translatedPoint = SwingUtilities
|
||||
.convertPoint( e.getComponent(), e.getPoint(), panel );
|
||||
|
||||
Channel channel = panel.getChannelAt( translatedPoint );
|
||||
|
||||
if( e.getButton() == MouseEvent.BUTTON1 )
|
||||
{
|
||||
setSelectedChannel( channel );
|
||||
}
|
||||
else if( e.getButton() == MouseEvent.BUTTON3 )
|
||||
{
|
||||
JPopupMenu popupMenu = new JPopupMenu();
|
||||
|
||||
JMenu menu = panel.getContextMenu();
|
||||
|
||||
if( menu != null )
|
||||
{
|
||||
popupMenu.add( menu );
|
||||
}
|
||||
|
||||
JMenu colorMenu = new JMenu( "Color" );
|
||||
popupMenu.add( colorMenu );
|
||||
|
||||
JMenu backgroundMenu = new JMenu( "Background" );
|
||||
colorMenu.add( backgroundMenu );
|
||||
|
||||
backgroundMenu.add( new ColorSettingMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_BACKGROUND ) );
|
||||
backgroundMenu.add( new ColorSettingResetMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_BACKGROUND ) );
|
||||
|
||||
JMenu channelsMenu = new JMenu( "Channel State" );
|
||||
colorMenu.add( channelsMenu );
|
||||
|
||||
JMenu callMenu = new JMenu( "Call" );
|
||||
channelsMenu.add( callMenu );
|
||||
|
||||
callMenu.add( new ColorSettingMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_CALL ) );
|
||||
callMenu.add( new ColorSettingResetMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_CALL ) );
|
||||
callMenu.add( new JSeparator() );
|
||||
|
||||
callMenu.add( new ColorSettingMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_CALL ) );
|
||||
callMenu.add( new ColorSettingResetMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_CALL ) );
|
||||
|
||||
JMenu controlMenu = new JMenu( "Control" );
|
||||
channelsMenu.add( controlMenu );
|
||||
|
||||
controlMenu.add( new ColorSettingMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_CONTROL ) );
|
||||
controlMenu.add( new ColorSettingResetMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_CONTROL ) );
|
||||
controlMenu.add( new JSeparator() );
|
||||
|
||||
controlMenu.add( new ColorSettingMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_CONTROL ) );
|
||||
controlMenu.add( new ColorSettingResetMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_CONTROL ) );
|
||||
|
||||
JMenu dataMenu = new JMenu( "Data" );
|
||||
channelsMenu.add( dataMenu );
|
||||
|
||||
dataMenu.add( new ColorSettingMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_DATA ) );
|
||||
dataMenu.add( new ColorSettingResetMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_DATA ) );
|
||||
dataMenu.add( new JSeparator() );
|
||||
|
||||
dataMenu.add( new ColorSettingMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_DATA ) );
|
||||
dataMenu.add( new ColorSettingResetMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_DATA ) );
|
||||
|
||||
JMenu fadeMenu = new JMenu( "Fade" );
|
||||
channelsMenu.add( fadeMenu );
|
||||
|
||||
fadeMenu.add( new ColorSettingMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_FADE ) );
|
||||
fadeMenu.add( new ColorSettingResetMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_FADE ) );
|
||||
fadeMenu.add( new JSeparator() );
|
||||
|
||||
fadeMenu.add( new ColorSettingMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_FADE ) );
|
||||
fadeMenu.add( new ColorSettingResetMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_FADE ) );
|
||||
|
||||
JMenu idleMenu = new JMenu( "Idle" );
|
||||
channelsMenu.add( idleMenu );
|
||||
|
||||
idleMenu.add( new ColorSettingMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_IDLE ) );
|
||||
idleMenu.add( new ColorSettingResetMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_IDLE ) );
|
||||
idleMenu.add( new JSeparator() );
|
||||
|
||||
idleMenu.add( new ColorSettingMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_IDLE ) );
|
||||
idleMenu.add( new ColorSettingResetMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_IDLE ) );
|
||||
|
||||
JMenu noTunerMenu = new JMenu( "No Tuner" );
|
||||
channelsMenu.add( noTunerMenu );
|
||||
|
||||
noTunerMenu.add( new ColorSettingMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_NO_TUNER ) );
|
||||
noTunerMenu.add( new ColorSettingResetMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_NO_TUNER ) );
|
||||
noTunerMenu.add( new JSeparator() );
|
||||
|
||||
noTunerMenu.add( new ColorSettingMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_NO_TUNER ) );
|
||||
noTunerMenu.add( new ColorSettingResetMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_NO_TUNER ) );
|
||||
|
||||
JMenu labelMenu = new JMenu( "Labels" );
|
||||
colorMenu.add( labelMenu );
|
||||
|
||||
labelMenu.add( new ColorSettingMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_LABEL_AUX_DECODER ) );
|
||||
labelMenu.add( new ColorSettingResetMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_LABEL_AUX_DECODER ) );
|
||||
labelMenu.add( new JSeparator() );
|
||||
|
||||
labelMenu.add( new ColorSettingMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_LABEL_DECODER ) );
|
||||
labelMenu.add( new ColorSettingResetMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_LABEL_DECODER ) );
|
||||
labelMenu.add( new JSeparator() );
|
||||
|
||||
labelMenu.add( new ColorSettingMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_LABEL_DETAILS ) );
|
||||
labelMenu.add( new ColorSettingResetMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_LABEL_DETAILS ) );
|
||||
|
||||
JMenu selectedMenu = new JMenu( "Selected" );
|
||||
colorMenu.add( selectedMenu );
|
||||
|
||||
selectedMenu.add( new ColorSettingMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_SELECTED_CHANNEL ) );
|
||||
selectedMenu.add( new ColorSettingResetMenuItem( mSettingsManager,
|
||||
ColorSettingName.CHANNEL_STATE_SELECTED_CHANNEL ) );
|
||||
|
||||
popupMenu.show( ChannelList.this, e.getX(), e.getY() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void mousePressed( MouseEvent e ) {}
|
||||
public void mouseReleased( MouseEvent e ) {}
|
||||
public void mouseEntered( MouseEvent e ) {}
|
||||
public void mouseExited( MouseEvent e ) {}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user