diff --git a/src/alias/AliasNameEditor.java b/src/alias/AliasNameEditor.java
index 06fb6881..6d2729aa 100644
--- a/src/alias/AliasNameEditor.java
+++ b/src/alias/AliasNameEditor.java
@@ -1,3 +1,21 @@
+/*******************************************************************************
+ * sdrtrunk
+ * Copyright (C) 2014-2017 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
+ *
+ ******************************************************************************/
package alias;
import alias.AliasEvent.Event;
@@ -5,9 +23,9 @@ import gui.editor.Editor;
import icon.Icon;
import icon.IconCellRenderer;
import icon.IconManager;
+import icon.IconModel;
import map.MapIcon;
import net.miginfocom.swing.MigLayout;
-import settings.SettingsManager;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
@@ -43,8 +61,7 @@ public class AliasNameEditor extends Editor
private void init()
{
- setLayout(new MigLayout("fill,wrap 2", "[right][grow,fill]",
- "[][][][][][][grow]"));
+ setLayout(new MigLayout("fill,wrap 2", "[right][grow,fill]", "[][][][][][][grow]"));
add(new JLabel("Name:"));
mName = new JTextField();
@@ -140,7 +157,7 @@ public class AliasNameEditor extends Editor
IconCellRenderer renderer = new IconCellRenderer(mIconManager);
renderer.setPreferredSize(new Dimension(200, 30));
- mIconCombo.setRenderer( renderer );
+ mIconCombo.setRenderer(renderer);
mIconCombo.addActionListener(new ActionListener()
{
@Override
@@ -179,6 +196,8 @@ public class AliasNameEditor extends Editor
{
mName.setText(alias.getName());
+ mIconCombo.setModel(new DefaultComboBoxModel<>(mIconManager.getIcons()));
+
List listNames = mAliasModel.getListNames();
if(listNames.isEmpty())
@@ -218,7 +237,7 @@ public class AliasNameEditor extends Editor
if(iconName == null)
{
- iconName = SettingsManager.DEFAULT_ICON;
+ iconName = IconModel.DEFAULT_ICON;
}
Icon savedIcon = mIconManager.getModel().getIcon(iconName);
diff --git a/src/alias/MultipleAliasEditor.java b/src/alias/MultipleAliasEditor.java
index 3bcc34ce..415c615e 100644
--- a/src/alias/MultipleAliasEditor.java
+++ b/src/alias/MultipleAliasEditor.java
@@ -266,6 +266,8 @@ public class MultipleAliasEditor extends Editor>
List streamNames = mBroadcastModel.getBroadcastConfigurationNames();
mStreamCombo.setModel(new DefaultComboBoxModel(streamNames.toArray(new String[streamNames.size()])));
+ mIconCombo.setModel(new DefaultComboBoxModel<>(mIconManager.getIcons()));
+
setCheckBoxesUnselected();
setModified(false);
diff --git a/src/audio/AudioChannelPanel.java b/src/audio/AudioChannelPanel.java
index 58540f88..72f4a091 100644
--- a/src/audio/AudioChannelPanel.java
+++ b/src/audio/AudioChannelPanel.java
@@ -1,12 +1,29 @@
+/*******************************************************************************
+ * sdrtrunk
+ * Copyright (C) 2014-2017 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
+ *
+ ******************************************************************************/
package audio;
-import java.awt.Color;
-import java.awt.EventQueue;
-import java.awt.Font;
-
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-
+import alias.Alias;
+import audio.metadata.AudioMetadata;
+import audio.metadata.Metadata;
+import audio.metadata.MetadataType;
+import audio.output.AudioOutput;
+import icon.IconManager;
import net.miginfocom.swing.MigLayout;
import sample.Listener;
import settings.ColorSetting;
@@ -14,278 +31,279 @@ import settings.ColorSetting.ColorSettingName;
import settings.Setting;
import settings.SettingChangeListener;
import settings.SettingsManager;
-import alias.Alias;
-import audio.metadata.AudioMetadata;
-import audio.metadata.Metadata;
-import audio.metadata.MetadataType;
-import audio.output.AudioOutput;
-public class AudioChannelPanel extends JPanel
- implements Listener, SettingChangeListener
+import javax.swing.*;
+import java.awt.*;
+
+public class AudioChannelPanel extends JPanel
+ implements Listener, SettingChangeListener
{
- private static final long serialVersionUID = 1L;
-
- private Font mFont = new Font( Font.MONOSPACED, Font.PLAIN, 12 );
+ private static final long serialVersionUID = 1L;
+
+ private Font mFont = new Font(Font.MONOSPACED, Font.PLAIN, 12);
private Color mLabelColor;
private Color mDetailsColor;
+ private IconManager mIconManager;
private SettingsManager mSettingsManager;
- private AudioOutput mAudioOutput;
+ private AudioOutput mAudioOutput;
- private JLabel mChannelName = new JLabel( " " );
- private JLabel mToLabel = new JLabel( "TO:" );
- private JLabel mTo = new JLabel( "" );
- private JLabel mToAlias = new JLabel( "" );
-
- private JLabel mMutedLabel = new JLabel( " " );
- private JLabel mFromLabel = new JLabel( "FROM:" );
- private JLabel mFrom = new JLabel( "" );
- private JLabel mFromAlias = new JLabel( "" );
-
- private boolean mConfigured = false;
-
- public AudioChannelPanel( SettingsManager settingsManager, AudioOutput audioOutput )
- {
- mSettingsManager = settingsManager;
- mSettingsManager.addListener( this );
+ private JLabel mChannelName = new JLabel(" ");
+ private JLabel mToLabel = new JLabel("TO:");
+ private JLabel mTo = new JLabel("");
+ private JLabel mToAlias = new JLabel("");
- mAudioOutput = audioOutput;
-
- if( mAudioOutput != null )
- {
- mAudioOutput.addAudioEventListener( this );
- mAudioOutput.setAudioMetadataListener( new AudioMetadataProcessor() );
- }
+ private JLabel mMutedLabel = new JLabel(" ");
+ private JLabel mFromLabel = new JLabel("FROM:");
+ private JLabel mFrom = new JLabel("");
+ private JLabel mFromAlias = new JLabel("");
- mLabelColor = mSettingsManager.getColorSetting(
- ColorSettingName.CHANNEL_STATE_LABEL_DECODER ).getColor();
- mDetailsColor = mSettingsManager.getColorSetting(
- ColorSettingName.CHANNEL_STATE_LABEL_DETAILS ).getColor();
-
- init();
- }
-
- private void init()
- {
- setLayout( new MigLayout( "insets 0 0 0 0", "[][right][][grow,fill]", "[]0[]0[grow,fill]" ) );
- setBackground( Color.BLACK );
-
- mChannelName = new JLabel( mAudioOutput != null ? mAudioOutput.getChannelName() : " " );
- mChannelName.setFont( mFont );
- mChannelName.setForeground( mDetailsColor );
- add( mChannelName );
-
- mToLabel.setFont( mFont );
- if( mAudioOutput != null )
- {
- mToLabel.setForeground( mLabelColor );
- }
- else
- {
- mToLabel.setForeground( getBackground() );
- }
- add( mToLabel );
+ private boolean mConfigured = false;
- mTo.setFont( mFont );
- mTo.setForeground( mLabelColor );
- add( mTo );
-
- mToAlias.setFont( mFont );
- mToAlias.setForeground( mLabelColor );
- add( mToAlias,"wrap" );
-
- mMutedLabel.setFont( mFont );
- mMutedLabel.setForeground( Color.RED );
- add( mMutedLabel );
-
- mFromLabel.setFont( mFont );
- if( mAudioOutput != null )
- {
- mFromLabel.setForeground( mLabelColor );
- }
- else
- {
- mFromLabel.setForeground( getBackground() );
- }
- add( mFromLabel );
-
- mFrom.setFont( mFont );
- mFrom.setForeground( mLabelColor );
- add( mFrom );
-
- mFromAlias.setFont( mFont );
- mFromAlias.setForeground( mLabelColor );
- add( mFromAlias,"wrap" );
-
- }
-
- @Override
- public void receive( final AudioEvent audioEvent )
- {
- switch( audioEvent.getType() )
- {
- case AUDIO_STOPPED:
- EventQueue.invokeLater( new Runnable()
- {
- @Override
- public void run()
- {
- resetLabels();
- }
- } );
- break;
- case AUDIO_MUTED:
- case AUDIO_UNMUTED:
- EventQueue.invokeLater( new Runnable()
- {
- @Override
- public void run()
- {
- mMutedLabel.setText( mAudioOutput.isMuted() ? "M" : " " );
- }
- } );
- break;
- default:
- break;
- }
- }
-
- /**
- * Resets the from and to labels. Note: this does not happen on the swing
- * event thread. Only invoke from the swing thread.
- */
- private void resetLabels()
- {
- mFrom.setText( "" );
- updateAlias( mFromAlias, null );
-
- mTo.setText( "" );
- updateAlias( mToAlias, null );
-
- mConfigured = false;
- }
-
- /**
- * Updates the alias label with text and icon from the alias. Note: this
- * does not occur on the Swing event thread -- wrap any calls to this
- * method with an event thread call.
- */
- private void updateAlias( JLabel label, Alias alias )
- {
- if( alias != null )
- {
- label.setText( alias.getName() );
-
- String icon = alias.getIconName();
-
- if( icon != null )
- {
- label.setIcon( mSettingsManager.getImageIcon( icon,
- SettingsManager.DEFAULT_ICON_SIZE ) );
- }
- else
- {
- label.setIcon( null );
- }
- }
- else
- {
- label.setText( "" );
- label.setIcon( null );
- }
- }
-
-
- /**
- * Processes audio metadata to update this panel's display values
- */
- public class AudioMetadataProcessor implements Listener
- {
- @Override
- public void receive( AudioMetadata audioMetadata )
- {
- if( !mConfigured || audioMetadata.isUpdated() )
- {
- final Metadata from = audioMetadata.getMetadata( MetadataType.FROM );
-
- final Metadata to = audioMetadata.getMetadata( MetadataType.TO );
-
- EventQueue.invokeLater( new Runnable()
- {
- @Override
- public void run()
- {
- if( from != null )
- {
- mFrom.setText( from.getValue() );
- updateAlias( mFromAlias, from.getAlias() );
- }
- else
- {
- mFrom.setText( "-----" );
- }
-
- if( to != null )
- {
- mTo.setText( to.getValue() );
- updateAlias( mToAlias, to.getAlias() );
- }
- else
- {
- mTo.setText( "-----" );
- }
- }
- } );
-
- mConfigured = true;
- }
- }
- }
-
-
- @Override
- public void settingChanged( Setting setting )
+ public AudioChannelPanel(IconManager iconManager, SettingsManager settingsManager, AudioOutput audioOutput)
{
- if( setting instanceof ColorSetting )
- {
- ColorSetting colorSetting = (ColorSetting)setting;
-
- switch( colorSetting.getColorSettingName() )
- {
- case CHANNEL_STATE_LABEL_DECODER:
- if( mFrom != null )
- {
- mFrom.setForeground( mLabelColor );
- }
- if( mFromAlias != null )
- {
- mFromAlias.setForeground( mLabelColor );
- }
- if( mTo != null )
- {
- mTo.setForeground( mLabelColor );
- }
- if( mToAlias != null )
- {
- mToAlias.setForeground( mLabelColor );
- }
- break;
- case CHANNEL_STATE_LABEL_DETAILS:
- if( mFromLabel != null )
- {
- mFromLabel.setForeground( mDetailsColor );
- }
- if( mToLabel != null )
- {
- mToLabel.setForeground( mDetailsColor );
- }
- break;
- default:
- break;
- }
- }
+ mIconManager = iconManager;
+ mSettingsManager = settingsManager;
+ mSettingsManager.addListener(this);
+
+ mAudioOutput = audioOutput;
+
+ if(mAudioOutput != null)
+ {
+ mAudioOutput.addAudioEventListener(this);
+ mAudioOutput.setAudioMetadataListener(new AudioMetadataProcessor());
+ }
+
+ mLabelColor = mSettingsManager.getColorSetting(
+ ColorSettingName.CHANNEL_STATE_LABEL_DECODER).getColor();
+ mDetailsColor = mSettingsManager.getColorSetting(
+ ColorSettingName.CHANNEL_STATE_LABEL_DETAILS).getColor();
+
+ init();
}
- @Override
- public void settingDeleted( Setting setting ) {}
+ private void init()
+ {
+ setLayout(new MigLayout("insets 0 0 0 0", "[][right][][grow,fill]", "[]0[]0[grow,fill]"));
+ setBackground(Color.BLACK);
+
+ mChannelName = new JLabel(mAudioOutput != null ? mAudioOutput.getChannelName() : " ");
+ mChannelName.setFont(mFont);
+ mChannelName.setForeground(mDetailsColor);
+ add(mChannelName);
+
+ mToLabel.setFont(mFont);
+ if(mAudioOutput != null)
+ {
+ mToLabel.setForeground(mLabelColor);
+ }
+ else
+ {
+ mToLabel.setForeground(getBackground());
+ }
+ add(mToLabel);
+
+ mTo.setFont(mFont);
+ mTo.setForeground(mLabelColor);
+ add(mTo);
+
+ mToAlias.setFont(mFont);
+ mToAlias.setForeground(mLabelColor);
+ add(mToAlias, "wrap");
+
+ mMutedLabel.setFont(mFont);
+ mMutedLabel.setForeground(Color.RED);
+ add(mMutedLabel);
+
+ mFromLabel.setFont(mFont);
+ if(mAudioOutput != null)
+ {
+ mFromLabel.setForeground(mLabelColor);
+ }
+ else
+ {
+ mFromLabel.setForeground(getBackground());
+ }
+ add(mFromLabel);
+
+ mFrom.setFont(mFont);
+ mFrom.setForeground(mLabelColor);
+ add(mFrom);
+
+ mFromAlias.setFont(mFont);
+ mFromAlias.setForeground(mLabelColor);
+ add(mFromAlias, "wrap");
+
+ }
+
+ @Override
+ public void receive(final AudioEvent audioEvent)
+ {
+ switch(audioEvent.getType())
+ {
+ case AUDIO_STOPPED:
+ EventQueue.invokeLater(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ resetLabels();
+ }
+ });
+ break;
+ case AUDIO_MUTED:
+ case AUDIO_UNMUTED:
+ EventQueue.invokeLater(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ mMutedLabel.setText(mAudioOutput.isMuted() ? "M" : " ");
+ }
+ });
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * Resets the from and to labels. Note: this does not happen on the swing
+ * event thread. Only invoke from the swing thread.
+ */
+ private void resetLabels()
+ {
+ mFrom.setText("");
+ updateAlias(mFromAlias, null);
+
+ mTo.setText("");
+ updateAlias(mToAlias, null);
+
+ mConfigured = false;
+ }
+
+ /**
+ * Updates the alias label with text and icon from the alias. Note: this
+ * does not occur on the Swing event thread -- wrap any calls to this
+ * method with an event thread call.
+ */
+ private void updateAlias(JLabel label, Alias alias)
+ {
+ if(alias != null)
+ {
+ label.setText(alias.getName());
+
+ String icon = alias.getIconName();
+
+ if(icon != null)
+ {
+ label.setIcon(mIconManager.getIcon(icon, IconManager.DEFAULT_ICON_SIZE));
+ }
+ else
+ {
+ label.setIcon(null);
+ }
+ }
+ else
+ {
+ label.setText("");
+ label.setIcon(null);
+ }
+ }
+
+
+ /**
+ * Processes audio metadata to update this panel's display values
+ */
+ public class AudioMetadataProcessor implements Listener
+ {
+ @Override
+ public void receive(AudioMetadata audioMetadata)
+ {
+ if(!mConfigured || audioMetadata.isUpdated())
+ {
+ final Metadata from = audioMetadata.getMetadata(MetadataType.FROM);
+
+ final Metadata to = audioMetadata.getMetadata(MetadataType.TO);
+
+ EventQueue.invokeLater(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ if(from != null)
+ {
+ mFrom.setText(from.getValue());
+ updateAlias(mFromAlias, from.getAlias());
+ }
+ else
+ {
+ mFrom.setText("-----");
+ }
+
+ if(to != null)
+ {
+ mTo.setText(to.getValue());
+ updateAlias(mToAlias, to.getAlias());
+ }
+ else
+ {
+ mTo.setText("-----");
+ }
+ }
+ });
+
+ mConfigured = true;
+ }
+ }
+ }
+
+
+ @Override
+ public void settingChanged(Setting setting)
+ {
+ if(setting instanceof ColorSetting)
+ {
+ ColorSetting colorSetting = (ColorSetting) setting;
+
+ switch(colorSetting.getColorSettingName())
+ {
+ case CHANNEL_STATE_LABEL_DECODER:
+ if(mFrom != null)
+ {
+ mFrom.setForeground(mLabelColor);
+ }
+ if(mFromAlias != null)
+ {
+ mFromAlias.setForeground(mLabelColor);
+ }
+ if(mTo != null)
+ {
+ mTo.setForeground(mLabelColor);
+ }
+ if(mToAlias != null)
+ {
+ mToAlias.setForeground(mLabelColor);
+ }
+ break;
+ case CHANNEL_STATE_LABEL_DETAILS:
+ if(mFromLabel != null)
+ {
+ mFromLabel.setForeground(mDetailsColor);
+ }
+ if(mToLabel != null)
+ {
+ mToLabel.setForeground(mDetailsColor);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ @Override
+ public void settingDeleted(Setting setting)
+ {
+ }
}
diff --git a/src/audio/AudioChannelsPanel.java b/src/audio/AudioChannelsPanel.java
index 4043d4de..bf28bcb4 100644
--- a/src/audio/AudioChannelsPanel.java
+++ b/src/audio/AudioChannelsPanel.java
@@ -1,51 +1,67 @@
+/*******************************************************************************
+ * sdrtrunk
+ * Copyright (C) 2014-2017 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
+ *
+ ******************************************************************************/
package audio;
-import java.awt.Color;
-import java.util.List;
-
-import javax.swing.JPanel;
-import javax.swing.JSeparator;
-
+import audio.output.AudioOutput;
+import icon.IconManager;
import net.miginfocom.swing.MigLayout;
import settings.SettingsManager;
-import audio.output.AudioOutput;
+
+import javax.swing.*;
+import java.awt.*;
+import java.util.List;
public class AudioChannelsPanel extends JPanel
{
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- public AudioChannelsPanel( SettingsManager settingsManager,
- IAudioController controller )
- {
- setLayout( new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[]0[]") );
-
- setBackground( Color.BLACK );
+ public AudioChannelsPanel(IconManager iconManager, SettingsManager settingsManager, IAudioController controller)
+ {
+ setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[]0[]"));
- List outputs = controller.getAudioOutputs();
+ setBackground(Color.BLACK);
- for( int x = 0; x < outputs.size(); x++ )
- {
- add( new AudioChannelPanel( settingsManager, outputs.get( x ) ), "wrap" );
-
- if( x < outputs.size() - 1 )
- {
- addSeparator();
- }
- }
+ List outputs = controller.getAudioOutputs();
+
+ for(int x = 0; x < outputs.size(); x++)
+ {
+ add(new AudioChannelPanel(iconManager, settingsManager, outputs.get(x)), "wrap");
+
+ if(x < outputs.size() - 1)
+ {
+ addSeparator();
+ }
+ }
/* Add an empty channel panel so that the panel is sized appropriately
- * for either a single channel or two channels */
- if( outputs.size() == 1 )
- {
- addSeparator();
- add( new AudioChannelPanel( settingsManager, null ), "wrap" );
- }
- }
-
- private void addSeparator()
- {
- JSeparator separator = new JSeparator( JSeparator.HORIZONTAL );
- separator.setBackground( Color.DARK_GRAY );
- add( separator, "span,growx" );
- }
+ * for either a single channel or two channels */
+ if(outputs.size() == 1)
+ {
+ addSeparator();
+ add(new AudioChannelPanel(iconManager, settingsManager, null), "wrap");
+ }
+ }
+
+ private void addSeparator()
+ {
+ JSeparator separator = new JSeparator(JSeparator.HORIZONTAL);
+ separator.setBackground(Color.DARK_GRAY);
+ add(separator, "span,growx");
+ }
}
diff --git a/src/audio/AudioPanel.java b/src/audio/AudioPanel.java
index a9e10b4d..589c959b 100644
--- a/src/audio/AudioPanel.java
+++ b/src/audio/AudioPanel.java
@@ -1,382 +1,411 @@
+/*******************************************************************************
+ * sdrtrunk
+ * Copyright (C) 2014-2017 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
+ *
+ ******************************************************************************/
package audio;
-import java.awt.Color;
-import java.awt.EventQueue;
+import audio.output.AudioOutput;
+import icon.IconManager;
+import net.miginfocom.swing.MigLayout;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import sample.Listener;
+import settings.SettingsManager;
+import source.SourceManager;
+import source.mixer.MixerChannelConfiguration;
+
+import javax.sound.sampled.FloatControl;
+import javax.swing.*;
+import javax.swing.event.ChangeEvent;
+import javax.swing.event.ChangeListener;
+import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
-import javax.sound.sampled.FloatControl;
-import javax.swing.ImageIcon;
-import javax.swing.JButton;
-import javax.swing.JMenu;
-import javax.swing.JMenuItem;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JPopupMenu;
-import javax.swing.JSlider;
-import javax.swing.SwingUtilities;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-
-import net.miginfocom.swing.MigLayout;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import sample.Listener;
-import settings.SettingsManager;
-import source.SourceManager;
-import source.mixer.MixerChannelConfiguration;
-import audio.output.AudioOutput;
-
public class AudioPanel extends JPanel implements Listener
{
- private static final long serialVersionUID = 1L;
-
- private static final Logger mLog = LoggerFactory.getLogger( AudioPanel.class );
-
- private static ImageIcon MUTED_ICON = SettingsManager.getScaledIcon(
- new ImageIcon( "images/audio_muted.png" ), 38 );
- private static ImageIcon UNMUTED_ICON = SettingsManager.getScaledIcon(
- new ImageIcon( "images/audio_unmuted.png" ), 38 );
+ private static final long serialVersionUID = 1L;
- private SettingsManager mSettingsManager;
- private SourceManager mSourceManager;
- private IAudioController mController;
+ private static final Logger mLog = LoggerFactory.getLogger(AudioPanel.class);
- private JButton mMuteButton;
- private AudioChannelsPanel mAudioChannelsPanel;
-
- public AudioPanel( SettingsManager settingsManager,
- SourceManager sourceManager,
- IAudioController controller )
- {
- mSettingsManager = settingsManager;
- mSourceManager = sourceManager;
- mController = controller;
-
- mController.addControllerListener( this );
-
- init();
- }
-
- private void init()
- {
- setLayout( new MigLayout( "insets 0 0 0 0", "[]0[grow,fill]", "[fill]0[]") );
- setBackground( Color.BLACK );
+ private static ImageIcon MUTED_ICON = IconManager.getScaledIcon(
+ new ImageIcon("images/audio_muted.png"), 38);
+ private static ImageIcon UNMUTED_ICON = IconManager.getScaledIcon(
+ new ImageIcon("images/audio_unmuted.png"), 38);
- mMuteButton = new MuteButton();
- mMuteButton.setBackground( getBackground() );
- add( mMuteButton );
-
- mAudioChannelsPanel = new AudioChannelsPanel( mSettingsManager, mController );
-
- add( mAudioChannelsPanel );
-
- addMouseListener( new MouseSelectionListener() );
- }
-
- @Override
- public void receive( AudioEvent event )
- {
- switch( event.getType() )
- {
- case AUDIO_CONFIGURATION_CHANGE_STARTED:
- break;
- case AUDIO_CONFIGURATION_CHANGE_COMPLETE:
- EventQueue.invokeLater( new Runnable()
- {
- @Override
- public void run()
- {
- remove( mAudioChannelsPanel );
+ private IconManager mIconManager;
+ private SettingsManager mSettingsManager;
+ private SourceManager mSourceManager;
+ private IAudioController mController;
- mAudioChannelsPanel = new AudioChannelsPanel(
- mSettingsManager, mController );
-
- add( mAudioChannelsPanel );
+ private JButton mMuteButton;
+ private AudioChannelsPanel mAudioChannelsPanel;
- mAudioChannelsPanel.repaint();
+ public AudioPanel(IconManager iconManager, SettingsManager settingsManager, SourceManager sourceManager,
+ IAudioController controller)
+ {
+ mIconManager = iconManager;
+ mSettingsManager = settingsManager;
+ mSourceManager = sourceManager;
+ mController = controller;
- revalidate();
- repaint();
- }
- } );
- break;
- default:
- break;
- }
- }
+ mController.addControllerListener(this);
- /**
- * Audio output mute control menu item.
- */
- public class AudioOutputMuteItem extends JMenuItem
- {
- private static final long serialVersionUID = 1L;
-
- private AudioOutput mAudioOutput;
-
- public AudioOutputMuteItem( AudioOutput audioOutput )
- {
- super( audioOutput.isMuted() ? "Unmute" : "Mute" );
-
- mAudioOutput = audioOutput;
-
- addActionListener( new ActionListener()
- {
- @Override
- public void actionPerformed( ActionEvent e )
- {
- mAudioOutput.setMuted( !mAudioOutput.isMuted() );
- }
- } );
- }
- }
-
- /**
- * Mouse listener
- */
- public class MouseSelectionListener implements MouseListener
- {
- @Override
- public void mouseClicked( MouseEvent event )
- {
- if( SwingUtilities.isRightMouseButton( event ) )
- {
- JPopupMenu popup = new JPopupMenu();
+ init();
+ }
+
+ private void init()
+ {
+ setLayout(new MigLayout("insets 0 0 0 0", "[]0[grow,fill]", "[fill]0[]"));
+ setBackground(Color.BLACK);
+
+ mMuteButton = new MuteButton();
+ mMuteButton.setBackground(getBackground());
+ add(mMuteButton);
+
+ mAudioChannelsPanel = new AudioChannelsPanel(mIconManager, mSettingsManager, mController);
+
+ add(mAudioChannelsPanel);
+
+ addMouseListener(new MouseSelectionListener());
+ }
+
+ @Override
+ public void receive(AudioEvent event)
+ {
+ switch(event.getType())
+ {
+ case AUDIO_CONFIGURATION_CHANGE_STARTED:
+ break;
+ case AUDIO_CONFIGURATION_CHANGE_COMPLETE:
+ EventQueue.invokeLater(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ remove(mAudioChannelsPanel);
+
+ mAudioChannelsPanel = new AudioChannelsPanel(mIconManager, mSettingsManager, mController);
+
+ add(mAudioChannelsPanel);
+
+ mAudioChannelsPanel.repaint();
+
+ revalidate();
+ repaint();
+ }
+ });
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * Audio output mute control menu item.
+ */
+ public class AudioOutputMuteItem extends JMenuItem
+ {
+ private static final long serialVersionUID = 1L;
+
+ private AudioOutput mAudioOutput;
+
+ public AudioOutputMuteItem(AudioOutput audioOutput)
+ {
+ super(audioOutput.isMuted() ? "Unmute" : "Mute");
+
+ mAudioOutput = audioOutput;
+
+ addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ mAudioOutput.setMuted(!mAudioOutput.isMuted());
+ }
+ });
+ }
+ }
+
+ /**
+ * Mouse listener
+ */
+ public class MouseSelectionListener implements MouseListener
+ {
+ @Override
+ public void mouseClicked(MouseEvent event)
+ {
+ if(SwingUtilities.isRightMouseButton(event))
+ {
+ JPopupMenu popup = new JPopupMenu();
/* Audio mixer/output selection menus */
- JMenu outputMenu = new JMenu( "Audio Output" );
+ JMenu outputMenu = new JMenu("Audio Output");
- MixerChannelConfiguration[] mixerConfigurations =
- mSourceManager.getMixerManager().getOutputMixers();
+ MixerChannelConfiguration[] mixerConfigurations =
+ mSourceManager.getMixerManager().getOutputMixers();
- for( MixerChannelConfiguration mixerConfig: mixerConfigurations )
- {
- MixerSelectionItem mixerItem = new MixerSelectionItem( mixerConfig );
-
- try
- {
- MixerChannelConfiguration current = mController.getMixerChannelConfiguration();
+ for(MixerChannelConfiguration mixerConfig : mixerConfigurations)
+ {
+ MixerSelectionItem mixerItem = new MixerSelectionItem(mixerConfig);
- if( current != null && current.equals( mixerConfig ) )
- {
- mixerItem.setSelected( true );
- }
- }
- catch( AudioException e )
- {
- mLog.error( "Error while detecting current mixer "
- + "channel configuration", e );
- }
-
- outputMenu.add( mixerItem );
- }
-
- popup.add( outputMenu );
+ try
+ {
+ MixerChannelConfiguration current = mController.getMixerChannelConfiguration();
+
+ if(current != null && current.equals(mixerConfig))
+ {
+ mixerItem.setSelected(true);
+ }
+ }
+ catch(AudioException e)
+ {
+ mLog.error("Error while detecting current mixer "
+ + "channel configuration", e);
+ }
+
+ outputMenu.add(mixerItem);
+ }
+
+ popup.add(outputMenu);
/* Audio output mute and volume control */
- for( AudioOutput output: mController.getAudioOutputs() )
- {
- JMenu menu = new JMenu( "Channel: " + output.getChannelName() );
-
- menu.add( new AudioOutputMuteItem( output ) );
-
- if( output.hasGainControl() )
- {
- JMenu volume = new JMenu( "Volume" );
- volume.add( new VolumeSlider( output.getGainControl() ) );
- menu.add( volume );
- }
-
- popup.add( menu );
- }
-
- popup.show( event.getComponent(), event.getX(), event.getY() );
- }
- }
+ for(AudioOutput output : mController.getAudioOutputs())
+ {
+ JMenu menu = new JMenu("Channel: " + output.getChannelName());
- @Override
- public void mousePressed( MouseEvent e ) {}
- @Override
- public void mouseReleased( MouseEvent e ) {}
- @Override
- public void mouseEntered( MouseEvent e ) {}
- @Override
- public void mouseExited( MouseEvent e ) {}
- }
-
- /**
- * Audio volume (gain) adjustment slider control
- */
- public class VolumeSlider extends JSlider
- {
- private static final long serialVersionUID = 1L;
-
- private FloatControl mFloatControl;
-
- public VolumeSlider( FloatControl control )
- {
- super( 0, 100, 0 );
-
- setMajorTickSpacing( 25 );
- setMinorTickSpacing( 5 );
- setPaintTicks( true );
- setPaintLabels( true );
+ menu.add(new AudioOutputMuteItem(output));
- mFloatControl = control;
-
- setValue( getIntegerValue( mFloatControl.getValue() ) );
-
- addChangeListener( new ChangeListener()
- {
- @Override
- public void stateChanged( ChangeEvent event )
- {
- mFloatControl.shift( mFloatControl.getValue(),
- getFloatValue( VolumeSlider.this.getValue() ),
- 1000 );
- }
- } );
-
- addMouseListener( new MouseListener()
- {
- @Override
- public void mouseClicked( MouseEvent event )
- {
- if( event.getClickCount() == 2 )
- {
- VolumeSlider.this.setValue( 50 );
- }
- }
-
- public void mouseReleased( MouseEvent arg0 ) {}
- public void mousePressed( MouseEvent arg0 ) {}
- public void mouseExited( MouseEvent arg0 ) {}
- public void mouseEntered( MouseEvent arg0 ) {}
- } );
- }
+ if(output.hasGainControl())
+ {
+ JMenu volume = new JMenu("Volume");
+ volume.add(new VolumeSlider(output.getGainControl()));
+ menu.add(volume);
+ }
- /**
- * Converts the integer value to a floating point value to use in the
- * float control. Assumes an integer value of 50 is the 0.0 dB mid
- * point (ie no gain ) value.
- */
- private int getIntegerValue( float value )
- {
- if( value == 0.0f )
- {
- return 50;
- }
- else if( value < 0.0f )
- {
- float ratio = value / mFloatControl.getMinimum();
-
- return 50 - (int)( ratio * 50.0f );
- }
- else
- {
- float ratio = value / mFloatControl.getMaximum();
-
- return 50 + (int)( ratio * 50.0f );
- }
- }
-
- private float getFloatValue( int value )
- {
- if( value == 50 )
- {
- return 0.0f;
- }
- else if( value < 50 )
- {
- return (float)( 50 - value ) / 50.0f * mFloatControl.getMinimum();
- }
- else
- {
- return (float)( value - 50 ) / 50.0f * mFloatControl.getMaximum();
- }
- }
- }
-
- /**
- * Mixer/Channel configuration selection item
- */
- public class MixerSelectionItem extends JMenuItem
- {
- private static final long serialVersionUID = 1L;
+ popup.add(menu);
+ }
- private MixerChannelConfiguration mConfiguration;
-
- public MixerSelectionItem( MixerChannelConfiguration config )
- {
- super( config.toString() );
-
- mConfiguration = config;
-
- addActionListener( new ActionListener()
- {
- @Override
- public void actionPerformed( ActionEvent e )
- {
- try
- {
- mController.setMixerChannelConfiguration( mConfiguration );
- }
- catch ( AudioException e1 )
- {
- mLog.error( "Couldn't set mixer channel configuration "
- + "to: " + mConfiguration.toString() );
-
- JOptionPane.showMessageDialog( MixerSelectionItem.this,
- "Couldn't set [" + mConfiguration.toString() +
- "] as the audio output device" );
- }
- }
- } );
- }
- }
+ popup.show(event.getComponent(), event.getX(), event.getY());
+ }
+ }
- /**
- * Mute button to mute all audio output channels exposed by the audio
- * controller
- */
- public class MuteButton extends JButton
- {
- private static final long serialVersionUID = 1L;
-
- private boolean mMuted = false;
-
- public MuteButton()
- {
- setIcon( UNMUTED_ICON );
- setBorderPainted( false );
-
- addActionListener( new ActionListener()
- {
- @Override
- public void actionPerformed( ActionEvent e )
- {
- mMuted = !mMuted;
-
- for( AudioOutput output: mController.getAudioOutputs() )
- {
- output.setMuted( mMuted );
- }
-
- EventQueue.invokeLater( new Runnable()
- {
- @Override
- public void run()
- {
- setIcon( mMuted ? MUTED_ICON : UNMUTED_ICON );
- }
- } );
- }
- } );
- }
- }
+ @Override
+ public void mousePressed(MouseEvent e)
+ {
+ }
+
+ @Override
+ public void mouseReleased(MouseEvent e)
+ {
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent e)
+ {
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e)
+ {
+ }
+ }
+
+ /**
+ * Audio volume (gain) adjustment slider control
+ */
+ public class VolumeSlider extends JSlider
+ {
+ private static final long serialVersionUID = 1L;
+
+ private FloatControl mFloatControl;
+
+ public VolumeSlider(FloatControl control)
+ {
+ super(0, 100, 0);
+
+ setMajorTickSpacing(25);
+ setMinorTickSpacing(5);
+ setPaintTicks(true);
+ setPaintLabels(true);
+
+ mFloatControl = control;
+
+ setValue(getIntegerValue(mFloatControl.getValue()));
+
+ addChangeListener(new ChangeListener()
+ {
+ @Override
+ public void stateChanged(ChangeEvent event)
+ {
+ mFloatControl.shift(mFloatControl.getValue(),
+ getFloatValue(VolumeSlider.this.getValue()),
+ 1000);
+ }
+ });
+
+ addMouseListener(new MouseListener()
+ {
+ @Override
+ public void mouseClicked(MouseEvent event)
+ {
+ if(event.getClickCount() == 2)
+ {
+ VolumeSlider.this.setValue(50);
+ }
+ }
+
+ public void mouseReleased(MouseEvent arg0)
+ {
+ }
+
+ public void mousePressed(MouseEvent arg0)
+ {
+ }
+
+ public void mouseExited(MouseEvent arg0)
+ {
+ }
+
+ public void mouseEntered(MouseEvent arg0)
+ {
+ }
+ });
+ }
+
+ /**
+ * Converts the integer value to a floating point value to use in the
+ * float control. Assumes an integer value of 50 is the 0.0 dB mid
+ * point (ie no gain ) value.
+ */
+ private int getIntegerValue(float value)
+ {
+ if(value == 0.0f)
+ {
+ return 50;
+ }
+ else if(value < 0.0f)
+ {
+ float ratio = value / mFloatControl.getMinimum();
+
+ return 50 - (int) (ratio * 50.0f);
+ }
+ else
+ {
+ float ratio = value / mFloatControl.getMaximum();
+
+ return 50 + (int) (ratio * 50.0f);
+ }
+ }
+
+ private float getFloatValue(int value)
+ {
+ if(value == 50)
+ {
+ return 0.0f;
+ }
+ else if(value < 50)
+ {
+ return (float) (50 - value) / 50.0f * mFloatControl.getMinimum();
+ }
+ else
+ {
+ return (float) (value - 50) / 50.0f * mFloatControl.getMaximum();
+ }
+ }
+ }
+
+ /**
+ * Mixer/Channel configuration selection item
+ */
+ public class MixerSelectionItem extends JMenuItem
+ {
+ private static final long serialVersionUID = 1L;
+
+ private MixerChannelConfiguration mConfiguration;
+
+ public MixerSelectionItem(MixerChannelConfiguration config)
+ {
+ super(config.toString());
+
+ mConfiguration = config;
+
+ addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ try
+ {
+ mController.setMixerChannelConfiguration(mConfiguration);
+ }
+ catch(AudioException e1)
+ {
+ mLog.error("Couldn't set mixer channel configuration "
+ + "to: " + mConfiguration.toString());
+
+ JOptionPane.showMessageDialog(MixerSelectionItem.this,
+ "Couldn't set [" + mConfiguration.toString() +
+ "] as the audio output device");
+ }
+ }
+ });
+ }
+ }
+
+ /**
+ * Mute button to mute all audio output channels exposed by the audio
+ * controller
+ */
+ public class MuteButton extends JButton
+ {
+ private static final long serialVersionUID = 1L;
+
+ private boolean mMuted = false;
+
+ public MuteButton()
+ {
+ setIcon(UNMUTED_ICON);
+ setBorderPainted(false);
+
+ addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ mMuted = !mMuted;
+
+ for(AudioOutput output : mController.getAudioOutputs())
+ {
+ output.setMuted(mMuted);
+ }
+
+ EventQueue.invokeLater(new Runnable()
+ {
+ @Override
+ public void run()
+ {
+ setIcon(mMuted ? MUTED_ICON : UNMUTED_ICON);
+ }
+ });
+ }
+ });
+ }
+ }
}
diff --git a/src/audio/broadcast/BroadcastConfigurationEditor.java b/src/audio/broadcast/BroadcastConfigurationEditor.java
index 678ba383..4c1b5f71 100644
--- a/src/audio/broadcast/BroadcastConfigurationEditor.java
+++ b/src/audio/broadcast/BroadcastConfigurationEditor.java
@@ -19,24 +19,22 @@
package audio.broadcast;
import alias.AliasModel;
-import audio.broadcast.broadcastify.BroadcastifyConfiguration;
-import audio.broadcast.broadcastify.BroadcastifyConfigurationEditor;
import gui.editor.DocumentListenerEditor;
-import settings.SettingsManager;
+import icon.IconManager;
import javax.swing.*;
public abstract class BroadcastConfigurationEditor extends DocumentListenerEditor
{
- protected SettingsManager mSettingsManager;
+ protected IconManager mIconManager;
protected BroadcastModel mBroadcastModel;
protected AliasModel mAliasModel;
- public BroadcastConfigurationEditor(BroadcastModel broadcastModel, AliasModel aliasModel, SettingsManager settingsManager)
+ public BroadcastConfigurationEditor(BroadcastModel broadcastModel, AliasModel aliasModel, IconManager iconManager)
{
mBroadcastModel = broadcastModel;
mAliasModel = aliasModel;
- mSettingsManager = settingsManager;
+ mIconManager = iconManager;
}
/**
diff --git a/src/audio/broadcast/BroadcastFactory.java b/src/audio/broadcast/BroadcastFactory.java
index 3fc95768..745be778 100644
--- a/src/audio/broadcast/BroadcastFactory.java
+++ b/src/audio/broadcast/BroadcastFactory.java
@@ -40,6 +40,7 @@ import audio.convert.MP3SilenceGenerator;
import controller.ThreadPoolManager;
import gui.editor.Editor;
import gui.editor.EmptyEditor;
+import icon.IconManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import record.AudioRecorder;
@@ -155,26 +156,26 @@ public class BroadcastFactory
public static Editor getEditor(BroadcastConfiguration configuration,
BroadcastModel broadcastModel,
AliasModel aliasModel,
- SettingsManager settingsManager)
+ IconManager iconManager)
{
Editor editor;
switch (configuration.getBroadcastServerType())
{
case BROADCASTIFY:
- editor = new BroadcastifyConfigurationEditor(broadcastModel, aliasModel, settingsManager);
+ editor = new BroadcastifyConfigurationEditor(broadcastModel, aliasModel, iconManager);
break;
case ICECAST_TCP:
- editor = new IcecastTCPConfigurationEditor(broadcastModel, aliasModel, settingsManager);
+ editor = new IcecastTCPConfigurationEditor(broadcastModel, aliasModel, iconManager);
break;
case ICECAST_HTTP:
- editor = new IcecastHTTPConfigurationEditor(broadcastModel, aliasModel, settingsManager);
+ editor = new IcecastHTTPConfigurationEditor(broadcastModel, aliasModel, iconManager);
break;
case SHOUTCAST_V1:
- editor = new ShoutcastV1ConfigurationEditor(broadcastModel, aliasModel, settingsManager);
+ editor = new ShoutcastV1ConfigurationEditor(broadcastModel, aliasModel, iconManager);
break;
case SHOUTCAST_V2:
- editor = new ShoutcastV2ConfigurationEditor(broadcastModel, aliasModel, settingsManager);
+ editor = new ShoutcastV2ConfigurationEditor(broadcastModel, aliasModel, iconManager);
break;
default:
editor = new EmptyEditor();
diff --git a/src/audio/broadcast/BroadcastModel.java b/src/audio/broadcast/BroadcastModel.java
index 703c350c..911eaf39 100644
--- a/src/audio/broadcast/BroadcastModel.java
+++ b/src/audio/broadcast/BroadcastModel.java
@@ -22,12 +22,12 @@ import alias.id.broadcast.BroadcastChannel;
import audio.AudioPacket;
import audio.metadata.AudioMetadata;
import controller.ThreadPoolManager;
+import icon.IconManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import properties.SystemProperties;
import sample.Broadcaster;
import sample.Listener;
-import settings.SettingsManager;
import javax.swing.*;
import javax.swing.table.AbstractTableModel;
@@ -67,17 +67,17 @@ public class BroadcastModel extends AbstractTableModel implements Listener