mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-13 17:17:29 -05:00
#90 [WIP] merged metadata management for channel state, decoder states and audio metadata into a new metadata class. The new metadata class is maintained for each decoding audio channel, or in the future, a decoding TDMA channel. Audio playback, recording and streaming all use the same metadata object for the channel. The list of channel processing gui panels have been deleted and channel processing status will now reside in a table where each table row is a metadata instance from the processing channel. The channel processing manager is responsible for adding/removing the channel's metadata instance to/from the metadata table. This allows the channel processing table to be the controller for the messages, events and channel spectrum views, keyed to the selected table row metadata.
I still have to clean up the gui components and wire in the table selection listeners.
This commit is contained in:
@@ -23,7 +23,7 @@ public enum Attribute
|
||||
CHANNEL_CONFIGURATION_LABEL_1,
|
||||
CHANNEL_CONFIGURATION_LABEL_2,
|
||||
CHANNEL_FREQUENCY,
|
||||
CHANNEL_ID,
|
||||
CHANNEL_FREQUENCY_LABEL,
|
||||
CHANNEL_STATE,
|
||||
MESSAGE,
|
||||
MESSAGE_TYPE,
|
||||
@@ -31,32 +31,7 @@ public enum Attribute
|
||||
NETWORK_ID_2,
|
||||
PRIMARY_ADDRESS_FROM,
|
||||
PRIMARY_ADDRESS_TO,
|
||||
PRIMARY_DECODER_TYPE,
|
||||
SECONDARY_ADDRESS_FROM,
|
||||
SECONDARY_ADDRESS_TO,
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//TODO: remove all attributes below here ********************
|
||||
|
||||
CHANNEL_NUMBER,
|
||||
CHANNEL_NAME,
|
||||
CHANNEL_SITE_NUMBER,
|
||||
CHANNEL_SITE_NUMBER_ALIAS,
|
||||
DESCRIPTION,
|
||||
FROM_TALKGROUP,
|
||||
FROM_TALKGROUP_ALIAS,
|
||||
FROM_TALKGROUP_TYPE,
|
||||
NAC,
|
||||
SITE,
|
||||
SITE_ALIAS,
|
||||
SITE_NAME,
|
||||
SOURCE,
|
||||
SYSTEM,
|
||||
SYSTEM_NAME,
|
||||
TO_TALKGROUP,
|
||||
TO_TALKGROUP_ALIAS,
|
||||
TO_TALKGROUP_TYPE;
|
||||
}
|
||||
@@ -19,6 +19,7 @@
|
||||
package channel.metadata;
|
||||
|
||||
import alias.Alias;
|
||||
import module.decode.DecoderType;
|
||||
|
||||
public class AttributeChangeRequest<T>
|
||||
{
|
||||
@@ -89,6 +90,9 @@ public class AttributeChangeRequest<T>
|
||||
return mAlias != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value as a String or null if the value is not a String instance.
|
||||
*/
|
||||
public String getStringValue()
|
||||
{
|
||||
if(mValue instanceof String)
|
||||
@@ -99,6 +103,9 @@ public class AttributeChangeRequest<T>
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value as a Long or null if the value is not a Long instance.
|
||||
*/
|
||||
public Long getLongValue()
|
||||
{
|
||||
if(mValue instanceof Long)
|
||||
@@ -108,4 +115,17 @@ public class AttributeChangeRequest<T>
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value as a DecoderType or null if the value is not a DecoderType instance.
|
||||
*/
|
||||
public DecoderType getDecoderTypeValue()
|
||||
{
|
||||
if(mValue instanceof DecoderType)
|
||||
{
|
||||
return (DecoderType)mValue;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ public class ChannelMetadataModel extends AbstractTableModel implements Listener
|
||||
fireTableCellUpdated(rowIndex, COLUMN_CONFIGURATION);
|
||||
break;
|
||||
case CHANNEL_FREQUENCY:
|
||||
case CHANNEL_ID:
|
||||
case CHANNEL_FREQUENCY_LABEL:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_FREQUENCY);
|
||||
break;
|
||||
case CHANNEL_STATE:
|
||||
|
||||
@@ -20,42 +20,86 @@ package channel.metadata;
|
||||
|
||||
import com.jidesoft.swing.JideSplitPane;
|
||||
import com.jidesoft.swing.JideTabbedPane;
|
||||
import controller.channel.ChannelProcessingManager;
|
||||
import icon.IconManager;
|
||||
import icon.IconTableModel;
|
||||
import module.decode.event.CallEventPanel;
|
||||
import module.decode.event.MessageActivityPanel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import settings.SettingsManager;
|
||||
import spectrum.ChannelSpectrumPanel;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class ChannelMetadataViewer extends JPanel
|
||||
{
|
||||
private ChannelMetadataModel mChannelMetadataModel;
|
||||
private IconTableModel mIconTableModel;
|
||||
private CallEventPanel mCallEventPanel;
|
||||
private MessageActivityPanel mMessageActivityPanel;
|
||||
private ChannelSpectrumPanel mChannelSpectrumPanel;
|
||||
private ChannelMetadataPanel mChannelMetadataPanel;
|
||||
|
||||
/**
|
||||
* GUI panel that combines the currently decoding channels metadata table and viewers for channel details,
|
||||
* messages, events, and spectral view.
|
||||
*/
|
||||
public ChannelMetadataViewer(ChannelMetadataModel channelMetadataModel, IconTableModel iconTableModel)
|
||||
public ChannelMetadataViewer(ChannelProcessingManager channelProcessingManager, IconManager iconManager,
|
||||
SettingsManager settingsManager)
|
||||
{
|
||||
mChannelMetadataModel = channelMetadataModel;
|
||||
mIconTableModel = iconTableModel;
|
||||
mCallEventPanel = new CallEventPanel(iconManager, channelProcessingManager);
|
||||
mMessageActivityPanel = new MessageActivityPanel(channelProcessingManager);
|
||||
mChannelSpectrumPanel = new ChannelSpectrumPanel(settingsManager, channelProcessingManager);
|
||||
mChannelMetadataPanel = new ChannelMetadataPanel(channelProcessingManager.getChannelMetadataModel(),
|
||||
iconManager.getModel());
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "", "[grow,fill]", "[grow,fill]") );
|
||||
|
||||
ChannelMetadataPanel channelMetadataPanel = new ChannelMetadataPanel(mChannelMetadataModel, mIconTableModel);
|
||||
|
||||
JideTabbedPane tabbedPane = new JideTabbedPane();
|
||||
tabbedPane.addTab("Details", new JPanel());
|
||||
tabbedPane.addTab("Events", new JPanel());
|
||||
tabbedPane.addTab("Messages", new JPanel());
|
||||
tabbedPane.addTab("Spectrum", new JPanel());
|
||||
tabbedPane.addTab("Events", mCallEventPanel);
|
||||
tabbedPane.addTab("Messages", mMessageActivityPanel);
|
||||
tabbedPane.addTab("Spectrum", mChannelSpectrumPanel);
|
||||
|
||||
JideSplitPane splitPane = new JideSplitPane(JideSplitPane.VERTICAL_SPLIT);
|
||||
splitPane.add(channelMetadataPanel);
|
||||
splitPane.add(mChannelMetadataPanel);
|
||||
splitPane.add(tabbedPane);
|
||||
|
||||
//TODO: move this change listener to the metadata table view
|
||||
// /**
|
||||
// * Change listener to enable/disable the channel spectrum display
|
||||
// * only when the tab is visible, and a channel has been selected
|
||||
// */
|
||||
// mTabbedPane.addChangeListener(new ChangeListener()
|
||||
// {
|
||||
// @Override
|
||||
// public void stateChanged(ChangeEvent event)
|
||||
// {
|
||||
// int index = mTabbedPane.getSelectedIndex();
|
||||
//
|
||||
// Component component = mTabbedPane.getComponentAt(index);
|
||||
//
|
||||
// if(component instanceof ChannelSpectrumPanel)
|
||||
// {
|
||||
// mChannelSpectrumPanel.setEnabled(true);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// mChannelSpectrumPanel.setEnabled(false);
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
//TODO: call, message and spectrum should listen to the metadata table now
|
||||
//
|
||||
//
|
||||
// /* Register each of the components to receive channel events when the
|
||||
// * channels are selected or change */
|
||||
// mChannelModel.addListener(mCallEventPanel);
|
||||
// mChannelModel.addListener(mChannelSpectrumPanel);
|
||||
// mChannelModel.addListener(mMessageActivityPanel);
|
||||
|
||||
add(splitPane);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class Metadata
|
||||
|
||||
//Lazily constructed member variables.
|
||||
private Integer mAudioPriority;
|
||||
private Boolean mRecordable;
|
||||
protected Boolean mRecordable;
|
||||
private List<BroadcastChannel> mBroadcastChannels;
|
||||
|
||||
|
||||
@@ -237,7 +237,7 @@ public class Metadata
|
||||
return mChannelConfigurationLabel1;
|
||||
case CHANNEL_CONFIGURATION_LABEL_2:
|
||||
return mChannelConfigurationLabel2;
|
||||
case CHANNEL_ID:
|
||||
case CHANNEL_FREQUENCY_LABEL:
|
||||
return mChannelFrequencyLabel;
|
||||
case CHANNEL_STATE:
|
||||
return mState.getDisplayValue();
|
||||
|
||||
@@ -47,6 +47,15 @@ public class MutableMetadata extends Metadata implements Listener<AttributeChang
|
||||
public void setSelected(boolean selected)
|
||||
{
|
||||
mSelected = selected;
|
||||
mUpdated = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the recordable flag to the argument value and overrides any recordable settings in the enclosed aliases.
|
||||
*/
|
||||
public void setRecordable(boolean recordable)
|
||||
{
|
||||
mRecordable = recordable;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,6 +64,7 @@ public class MutableMetadata extends Metadata implements Listener<AttributeChang
|
||||
public void setPrimaryDecoderType(DecoderType decoderType)
|
||||
{
|
||||
mPrimaryDecoderType = decoderType;
|
||||
mUpdated = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,9 +95,9 @@ public class MutableMetadata extends Metadata implements Listener<AttributeChang
|
||||
}
|
||||
broadcast(Attribute.CHANNEL_FREQUENCY);
|
||||
break;
|
||||
case CHANNEL_ID:
|
||||
case CHANNEL_FREQUENCY_LABEL:
|
||||
mChannelFrequencyLabel = request.getStringValue();
|
||||
broadcast(Attribute.CHANNEL_ID);
|
||||
broadcast(Attribute.CHANNEL_FREQUENCY_LABEL);
|
||||
break;
|
||||
case MESSAGE:
|
||||
mMessage = request.getStringValue();
|
||||
@@ -117,6 +127,10 @@ public class MutableMetadata extends Metadata implements Listener<AttributeChang
|
||||
mPrimaryAddressTo.setAlias(request.getAlias());
|
||||
broadcast(Attribute.PRIMARY_ADDRESS_TO);
|
||||
break;
|
||||
case PRIMARY_DECODER_TYPE:
|
||||
mPrimaryDecoderType = request.getDecoderTypeValue();
|
||||
broadcast(Attribute.PRIMARY_DECODER_TYPE);
|
||||
break;
|
||||
case SECONDARY_ADDRESS_FROM:
|
||||
mSecondaryAddressFrom.setIdentifier(request.getStringValue());
|
||||
mSecondaryAddressFrom.setAlias(request.getAlias());
|
||||
@@ -135,6 +149,8 @@ public class MutableMetadata extends Metadata implements Listener<AttributeChang
|
||||
throw new IllegalArgumentException("Unrecognized Metadata Attribute: " +
|
||||
request.getAttribute().name());
|
||||
}
|
||||
|
||||
mUpdated = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -178,6 +194,8 @@ public class MutableMetadata extends Metadata implements Listener<AttributeChang
|
||||
mSecondaryAddressTo.reset();
|
||||
broadcast(Attribute.SECONDARY_ADDRESS_TO);
|
||||
}
|
||||
|
||||
mUpdated = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -202,7 +220,7 @@ public class MutableMetadata extends Metadata implements Listener<AttributeChang
|
||||
if(hasChannelFrequencyLabel())
|
||||
{
|
||||
mChannelFrequencyLabel = null;
|
||||
broadcast(Attribute.CHANNEL_ID);
|
||||
broadcast(Attribute.CHANNEL_FREQUENCY_LABEL);
|
||||
}
|
||||
|
||||
if(hasChannelFrequency())
|
||||
@@ -211,6 +229,12 @@ public class MutableMetadata extends Metadata implements Listener<AttributeChang
|
||||
broadcast(Attribute.CHANNEL_FREQUENCY);
|
||||
}
|
||||
|
||||
if(hasPrimaryDecoderType())
|
||||
{
|
||||
mPrimaryDecoderType = null;
|
||||
broadcast(Attribute.PRIMARY_DECODER_TYPE);
|
||||
}
|
||||
|
||||
if(mNetworkID1.hasIdentifier())
|
||||
{
|
||||
mNetworkID1.reset();
|
||||
@@ -222,6 +246,8 @@ public class MutableMetadata extends Metadata implements Listener<AttributeChang
|
||||
mNetworkID2.reset();
|
||||
broadcast(Attribute.NETWORK_ID_2);
|
||||
}
|
||||
|
||||
mUpdated = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,317 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* 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 <http://www.gnu.org/licenses/>
|
||||
*
|
||||
******************************************************************************/
|
||||
package channel.state;
|
||||
|
||||
import audio.AudioPanel;
|
||||
import controller.channel.Channel;
|
||||
import controller.channel.ChannelEvent;
|
||||
import controller.channel.ChannelEvent.Event;
|
||||
import controller.channel.ChannelEventListener;
|
||||
import controller.channel.ChannelModel;
|
||||
import controller.channel.ChannelProcessingManager;
|
||||
import icon.IconManager;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import settings.ColorSetting.ColorSettingName;
|
||||
import settings.ColorSettingMenuItem;
|
||||
import settings.ColorSettingResetMenuItem;
|
||||
import settings.SettingsManager;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* Gui wrapper for the list of currently processing primary channels
|
||||
*/
|
||||
public class ChannelList extends JPanel implements ChannelEventListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Map<Channel, ChannelPanel> mDisplayedPanels = new ConcurrentHashMap<>();
|
||||
|
||||
private ChannelModel mChannelModel;
|
||||
private ChannelProcessingManager mChannelProcessingManager;
|
||||
private IconManager mIconManager;
|
||||
private SettingsManager mSettingsManager;
|
||||
private AudioPanel mAudioPanel;
|
||||
|
||||
public ChannelList(ChannelModel channelModel,
|
||||
ChannelProcessingManager channelProcessingManager,
|
||||
IconManager iconManager,
|
||||
SettingsManager settingsManager,
|
||||
AudioPanel audioPanel)
|
||||
{
|
||||
mChannelModel = channelModel;
|
||||
mChannelProcessingManager = channelProcessingManager;
|
||||
mIconManager = iconManager;
|
||||
mSettingsManager = settingsManager;
|
||||
mAudioPanel = audioPanel;
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout(new MigLayout("insets 0 0 0 0,wrap 1", "[grow,fill]", "[]0[]"));
|
||||
setBackground(Color.BLACK);
|
||||
|
||||
addMouseListener(new ListSelectionListener());
|
||||
|
||||
add(mAudioPanel);
|
||||
|
||||
JSeparator separator = new JSeparator(JSeparator.HORIZONTAL);
|
||||
add(separator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelChanged(ChannelEvent event)
|
||||
{
|
||||
switch(event.getEvent())
|
||||
{
|
||||
case NOTIFICATION_PROCESSING_START:
|
||||
addChannelPanel(event.getChannel());
|
||||
break;
|
||||
case NOTIFICATION_PROCESSING_STOP:
|
||||
removeChannelPanel(event.getChannel());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void addChannelPanel(Channel channel)
|
||||
{
|
||||
if(!mDisplayedPanels.containsKey(channel))
|
||||
{
|
||||
ChannelPanel channelPanel = new ChannelPanel(mChannelModel,
|
||||
mChannelProcessingManager, mIconManager, mSettingsManager, channel);
|
||||
|
||||
add(channelPanel);
|
||||
|
||||
mDisplayedPanels.put(channel, channelPanel);
|
||||
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
public void removeChannelPanel(Channel channel)
|
||||
{
|
||||
if(mDisplayedPanels.containsKey(channel))
|
||||
{
|
||||
ChannelPanel panel = mDisplayedPanels.remove(channel);
|
||||
|
||||
if(panel != null)
|
||||
{
|
||||
remove(panel);
|
||||
|
||||
panel.dispose();
|
||||
}
|
||||
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
public class ListSelectionListener implements MouseListener
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e)
|
||||
{
|
||||
Component component = getComponentAt(e.getPoint());
|
||||
|
||||
if(component instanceof ChannelPanel)
|
||||
{
|
||||
ChannelPanel panel = (ChannelPanel) component;
|
||||
|
||||
Channel channel = panel.getChannel();
|
||||
|
||||
if(e.getButton() == MouseEvent.BUTTON1)
|
||||
{
|
||||
if(channel.isSelected())
|
||||
{
|
||||
mChannelModel.broadcast(new ChannelEvent(channel, Event.REQUEST_DESELECT));
|
||||
}
|
||||
else
|
||||
{
|
||||
mChannelModel.broadcast(new ChannelEvent(channel, Event.REQUEST_SELECT));
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,466 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* 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 <http://www.gnu.org/licenses/>
|
||||
*
|
||||
******************************************************************************/
|
||||
package channel.state;
|
||||
|
||||
import channel.metadata.Attribute;
|
||||
import controller.channel.Channel;
|
||||
import controller.channel.ChannelEvent;
|
||||
import controller.channel.ChannelEvent.Event;
|
||||
import controller.channel.ChannelEventListener;
|
||||
import controller.channel.ChannelModel;
|
||||
import controller.channel.ChannelProcessingManager;
|
||||
import controller.channel.ChannelUtils;
|
||||
import icon.IconManager;
|
||||
import module.ProcessingChain;
|
||||
import module.decode.DecoderFactory;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import record.RecorderType;
|
||||
import record.config.RecordConfiguration;
|
||||
import sample.Listener;
|
||||
import settings.ColorSetting;
|
||||
import settings.ColorSetting.ColorSettingName;
|
||||
import settings.Setting;
|
||||
import settings.SettingChangeListener;
|
||||
import settings.SettingsManager;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ChannelPanel extends JPanel
|
||||
implements Listener<Attribute>,
|
||||
SettingChangeListener,
|
||||
ChannelEventListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final static Logger mLog = LoggerFactory.getLogger(ChannelPanel.class);
|
||||
|
||||
private Font mFontDetails = new Font(Font.MONOSPACED, Font.PLAIN, 12);
|
||||
private Font mFontDecoder = new Font(Font.MONOSPACED, Font.PLAIN, 12);
|
||||
|
||||
protected Color mColorChannelBackground;
|
||||
protected Color mColorChannelSelected;
|
||||
protected Color mColorTopCall;
|
||||
protected Color mColorMiddleCall;
|
||||
protected Color mColorTopControl;
|
||||
protected Color mColorMiddleControl;
|
||||
protected Color mColorTopData;
|
||||
protected Color mColorMiddleData;
|
||||
protected Color mColorTopFade;
|
||||
protected Color mColorMiddleFade;
|
||||
protected Color mColorTopIdle;
|
||||
protected Color mColorMiddleIdle;
|
||||
protected Color mColorTopNoTuner;
|
||||
protected Color mColorMiddleNoTuner;
|
||||
protected Color mColorLabelDetails;
|
||||
protected Color mColorLabelDecoder;
|
||||
protected Color mColorLabelAuxDecoder;
|
||||
|
||||
private JLabel mStateLabel;
|
||||
private JLabel mSourceLabel;
|
||||
private JLabel mOptionsLabel;
|
||||
|
||||
private JLabel mSystemLabel;
|
||||
private JLabel mSiteLabel;
|
||||
private JLabel mChannelLabel;
|
||||
|
||||
protected SettingsManager mSettingsManager;
|
||||
protected IconManager mIconManager;
|
||||
|
||||
private Channel mChannel;
|
||||
private ChannelState mChannelState;
|
||||
private List<DecoderPanel> mDecoderPanels = new ArrayList<>();
|
||||
private ChannelModel mChannelModel;
|
||||
private ChannelProcessingManager mChannelProcessingManager;
|
||||
|
||||
/**
|
||||
* Gui component to a channel state. Provides System, Site and channel
|
||||
* name, source and channel state visualization.
|
||||
*
|
||||
* Updates color background according to current channel state.
|
||||
*/
|
||||
public ChannelPanel(ChannelModel channelModel,
|
||||
ChannelProcessingManager channelProcessingManager,
|
||||
IconManager iconManager,
|
||||
SettingsManager settingsManager,
|
||||
Channel channel)
|
||||
{
|
||||
mChannelModel = channelModel;
|
||||
mChannelProcessingManager = channelProcessingManager;
|
||||
mIconManager = iconManager;
|
||||
mSettingsManager = settingsManager;
|
||||
mChannel = channel;
|
||||
|
||||
ProcessingChain processingChain =
|
||||
channelProcessingManager.getProcessingChain(mChannel);
|
||||
|
||||
if(processingChain != null)
|
||||
{
|
||||
mChannelState = processingChain.getChannelState();
|
||||
|
||||
init();
|
||||
|
||||
for(DecoderState decoderState : processingChain.getDecoderStates())
|
||||
{
|
||||
DecoderPanel panel = DecoderFactory.getDecoderPanel(mIconManager, mSettingsManager, decoderState);
|
||||
mDecoderPanels.add(panel);
|
||||
add(panel, "grow,span");
|
||||
}
|
||||
|
||||
mChannelState.setChangedAttributeListener(this);
|
||||
mChannelModel.addListener(this);
|
||||
mSettingsManager.addListener(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
mLog.error("Processing Chain was null!");
|
||||
}
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
getColors();
|
||||
|
||||
setLayout(new MigLayout("insets 1 1 1 1", "[grow,fill]", "[]0[]0[]"));
|
||||
|
||||
mSystemLabel = new JLabel(mChannel.getSystem());
|
||||
mSystemLabel.setFont(mFontDetails);
|
||||
mSystemLabel.setForeground(mColorLabelDetails);
|
||||
add(mSystemLabel);
|
||||
|
||||
mSiteLabel = new JLabel(mChannel.getSite());
|
||||
mSiteLabel.setFont(mFontDetails);
|
||||
mSiteLabel.setForeground(mColorLabelDetails);
|
||||
add(mSiteLabel);
|
||||
|
||||
mChannelLabel = new JLabel(mChannel.getName());
|
||||
mChannelLabel.setFont(mFontDetails);
|
||||
mChannelLabel.setForeground(mColorLabelDetails);
|
||||
add(mChannelLabel, "wrap");
|
||||
|
||||
mStateLabel = new JLabel(mChannelState.getState().getDisplayValue());
|
||||
mStateLabel.setFont(mFontDecoder);
|
||||
mStateLabel.setForeground(mColorLabelDecoder);
|
||||
add(mStateLabel);
|
||||
|
||||
mSourceLabel = new JLabel(mChannel.getSourceConfiguration().getDescription());
|
||||
mSourceLabel.setFont(mFontDetails);
|
||||
mSourceLabel.setForeground(mColorLabelDetails);
|
||||
add(mSourceLabel);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
if(!mChannel.getEventLogConfiguration().getLoggers().isEmpty())
|
||||
{
|
||||
sb.append("LOG ");
|
||||
}
|
||||
|
||||
RecordConfiguration recordConfig = mChannel.getRecordConfiguration();
|
||||
|
||||
if(recordConfig.getRecorders().contains(RecorderType.AUDIO))
|
||||
{
|
||||
sb.append("AUDIO ");
|
||||
}
|
||||
|
||||
if(recordConfig.getRecorders().contains(RecorderType.BASEBAND) ||
|
||||
recordConfig.getRecorders().contains(RecorderType.TRAFFIC_BASEBAND))
|
||||
{
|
||||
sb.append("BASEBAND");
|
||||
}
|
||||
|
||||
mOptionsLabel = new JLabel(sb.toString());
|
||||
mOptionsLabel.setFont(mFontDetails);
|
||||
mOptionsLabel.setForeground(mColorLabelAuxDecoder);
|
||||
add(mOptionsLabel, "wrap");
|
||||
}
|
||||
|
||||
public Channel getChannel()
|
||||
{
|
||||
return mChannel;
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
mChannelModel.removeListener(this);
|
||||
mChannelModel = null;
|
||||
|
||||
mChannelProcessingManager = null;
|
||||
|
||||
mSettingsManager.removeListener(this);
|
||||
mSettingsManager = null;
|
||||
|
||||
mChannelState.removeChangedAttributeListener();
|
||||
mChannelState = null;
|
||||
mChannel = null;
|
||||
|
||||
for(DecoderPanel panel : mDecoderPanels)
|
||||
{
|
||||
panel.dispose();
|
||||
remove(panel);
|
||||
}
|
||||
|
||||
mDecoderPanels.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(final Attribute attribute)
|
||||
{
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
switch(attribute)
|
||||
{
|
||||
case CHANNEL_STATE:
|
||||
if(mChannelState != null && mChannelState.getState() != null)
|
||||
{
|
||||
mStateLabel.setText(mChannelState.getState().getDisplayValue());
|
||||
}
|
||||
break;
|
||||
case SOURCE:
|
||||
mSourceLabel.setText(mChannel.getSourceConfiguration()
|
||||
.getDescription());
|
||||
break;
|
||||
case CHANNEL_NAME:
|
||||
case SITE_NAME:
|
||||
case SYSTEM_NAME:
|
||||
mChannelLabel.setText(mChannel.toString());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
repaint();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g)
|
||||
{
|
||||
super.paintComponent(g);
|
||||
|
||||
setBackground(mColorChannelBackground);
|
||||
|
||||
Graphics2D g2 = (Graphics2D) g.create();
|
||||
|
||||
Paint p = null;
|
||||
|
||||
final Channel channel = mChannel;
|
||||
|
||||
if(mChannelState != null)
|
||||
{
|
||||
switch(mChannelState.getState())
|
||||
{
|
||||
case CALL:
|
||||
p = getGradient(mColorTopCall, mColorMiddleCall);
|
||||
break;
|
||||
case CONTROL:
|
||||
p = getGradient(mColorTopControl, mColorMiddleControl);
|
||||
break;
|
||||
case DATA:
|
||||
p = getGradient(mColorTopData, mColorMiddleData);
|
||||
break;
|
||||
case FADE:
|
||||
p = getGradient(mColorTopFade, mColorMiddleFade);
|
||||
break;
|
||||
case IDLE:
|
||||
default:
|
||||
p = getGradient(mColorTopIdle, mColorMiddleIdle);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(p == null)
|
||||
{
|
||||
p = getGradient(mColorTopIdle, mColorMiddleIdle);
|
||||
}
|
||||
|
||||
g2.setPaint(p);
|
||||
g2.fillRect(0, 0, getWidth(), getHeight());
|
||||
|
||||
/* Draw bottom separator line */
|
||||
g2.setColor(Color.LIGHT_GRAY);
|
||||
g2.drawLine(0, getHeight() - 1, getWidth(), getHeight() - 1);
|
||||
|
||||
/* Draw channel selected box */
|
||||
if(getChannel() != null && getChannel().isSelected())
|
||||
{
|
||||
g2.setColor(mColorChannelSelected);
|
||||
g2.drawRect(1, 1, getWidth() - 2, getHeight() - 2);
|
||||
}
|
||||
|
||||
g2.dispose();
|
||||
}
|
||||
|
||||
|
||||
private void getColors()
|
||||
{
|
||||
mColorChannelBackground = mSettingsManager.getColorSetting(
|
||||
ColorSettingName.CHANNEL_STATE_BACKGROUND).getColor();
|
||||
mColorChannelSelected = mSettingsManager.getColorSetting(
|
||||
ColorSettingName.CHANNEL_STATE_SELECTED_CHANNEL).getColor();
|
||||
mColorTopCall = mSettingsManager.getColorSetting(
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_CALL).getColor();
|
||||
mColorMiddleCall = mSettingsManager.getColorSetting(
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_CALL).getColor();
|
||||
mColorTopControl = mSettingsManager.getColorSetting(
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_CONTROL).getColor();
|
||||
mColorMiddleControl = mSettingsManager.getColorSetting(
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_CONTROL).getColor();
|
||||
mColorTopData = mSettingsManager.getColorSetting(
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_DATA).getColor();
|
||||
mColorMiddleData = mSettingsManager.getColorSetting(
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_DATA).getColor();
|
||||
mColorTopFade = mSettingsManager.getColorSetting(
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_FADE).getColor();
|
||||
mColorMiddleFade = mSettingsManager.getColorSetting(
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_FADE).getColor();
|
||||
mColorTopIdle = mSettingsManager.getColorSetting(
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_IDLE).getColor();
|
||||
mColorMiddleIdle = mSettingsManager.getColorSetting(
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_IDLE).getColor();
|
||||
mColorTopNoTuner = mSettingsManager.getColorSetting(
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_TOP_NO_TUNER).getColor();
|
||||
mColorMiddleNoTuner = mSettingsManager.getColorSetting(
|
||||
ColorSettingName.CHANNEL_STATE_GRADIENT_MIDDLE_NO_TUNER).getColor();
|
||||
|
||||
mColorLabelDetails = mSettingsManager.getColorSetting(
|
||||
ColorSettingName.CHANNEL_STATE_LABEL_DETAILS).getColor();
|
||||
mColorLabelDecoder = mSettingsManager.getColorSetting(
|
||||
ColorSettingName.CHANNEL_STATE_LABEL_DECODER).getColor();
|
||||
mColorLabelAuxDecoder = mSettingsManager.getColorSetting(
|
||||
ColorSettingName.CHANNEL_STATE_LABEL_AUX_DECODER).getColor();
|
||||
}
|
||||
|
||||
private GradientPaint getGradient(Color top, Color middle)
|
||||
{
|
||||
return new GradientPaint(0f, -50.0f, top,
|
||||
0f, (float) getHeight() / 2.2f, middle, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingChanged(Setting setting)
|
||||
{
|
||||
if(setting instanceof ColorSetting)
|
||||
{
|
||||
ColorSetting colorSetting = (ColorSetting) setting;
|
||||
|
||||
switch(colorSetting.getColorSettingName())
|
||||
{
|
||||
case CHANNEL_STATE_BACKGROUND:
|
||||
mColorChannelBackground = colorSetting.getColor();
|
||||
repaint();
|
||||
break;
|
||||
case CHANNEL_STATE_GRADIENT_MIDDLE_CALL:
|
||||
mColorMiddleCall = colorSetting.getColor();
|
||||
repaint();
|
||||
break;
|
||||
case CHANNEL_STATE_GRADIENT_TOP_CALL:
|
||||
mColorTopCall = colorSetting.getColor();
|
||||
repaint();
|
||||
break;
|
||||
case CHANNEL_STATE_GRADIENT_MIDDLE_CONTROL:
|
||||
mColorMiddleControl = colorSetting.getColor();
|
||||
repaint();
|
||||
break;
|
||||
case CHANNEL_STATE_GRADIENT_TOP_CONTROL:
|
||||
mColorTopControl = colorSetting.getColor();
|
||||
repaint();
|
||||
break;
|
||||
case CHANNEL_STATE_GRADIENT_MIDDLE_DATA:
|
||||
mColorMiddleData = colorSetting.getColor();
|
||||
repaint();
|
||||
break;
|
||||
case CHANNEL_STATE_GRADIENT_TOP_DATA:
|
||||
mColorTopData = colorSetting.getColor();
|
||||
repaint();
|
||||
break;
|
||||
case CHANNEL_STATE_GRADIENT_MIDDLE_FADE:
|
||||
mColorMiddleFade = colorSetting.getColor();
|
||||
repaint();
|
||||
break;
|
||||
case CHANNEL_STATE_GRADIENT_TOP_FADE:
|
||||
mColorTopFade = colorSetting.getColor();
|
||||
repaint();
|
||||
break;
|
||||
case CHANNEL_STATE_GRADIENT_MIDDLE_IDLE:
|
||||
mColorMiddleIdle = colorSetting.getColor();
|
||||
repaint();
|
||||
break;
|
||||
case CHANNEL_STATE_GRADIENT_TOP_IDLE:
|
||||
mColorTopIdle = colorSetting.getColor();
|
||||
repaint();
|
||||
break;
|
||||
case CHANNEL_STATE_GRADIENT_MIDDLE_NO_TUNER:
|
||||
mColorMiddleNoTuner = colorSetting.getColor();
|
||||
repaint();
|
||||
break;
|
||||
case CHANNEL_STATE_GRADIENT_TOP_NO_TUNER:
|
||||
mColorTopNoTuner = colorSetting.getColor();
|
||||
repaint();
|
||||
break;
|
||||
case CHANNEL_STATE_LABEL_AUX_DECODER:
|
||||
mColorLabelAuxDecoder = colorSetting.getColor();
|
||||
repaint();
|
||||
break;
|
||||
case CHANNEL_STATE_LABEL_DECODER:
|
||||
mColorLabelDecoder = colorSetting.getColor();
|
||||
repaint();
|
||||
break;
|
||||
case CHANNEL_STATE_LABEL_DETAILS:
|
||||
mColorLabelDetails = colorSetting.getColor();
|
||||
repaint();
|
||||
break;
|
||||
case CHANNEL_STATE_SELECTED_CHANNEL:
|
||||
mColorChannelSelected = colorSetting.getColor();
|
||||
repaint();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingDeleted(Setting setting)
|
||||
{
|
||||
}
|
||||
|
||||
public JMenu getContextMenu()
|
||||
{
|
||||
return ChannelUtils.getContextMenu(mChannelModel, mChannelProcessingManager,
|
||||
mChannel, ChannelPanel.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelChanged(ChannelEvent event)
|
||||
{
|
||||
if(event.getEvent() == Event.NOTIFICATION_SELECTION_CHANGE &&
|
||||
event.getChannel() == mChannel)
|
||||
{
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,163 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* 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 <http://www.gnu.org/licenses/>
|
||||
*
|
||||
******************************************************************************/
|
||||
package channel.state;
|
||||
|
||||
import alias.Alias;
|
||||
import channel.metadata.Attribute;
|
||||
import icon.IconManager;
|
||||
import sample.Listener;
|
||||
import settings.ColorSetting;
|
||||
import settings.ColorSetting.ColorSettingName;
|
||||
import settings.Setting;
|
||||
import settings.SettingChangeListener;
|
||||
import settings.SettingsManager;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public abstract class DecoderPanel extends JPanel
|
||||
implements Listener<Attribute>, SettingChangeListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected Font mFontDetails = new Font(Font.MONOSPACED, Font.PLAIN, 12);
|
||||
protected Font mFontDecoder = new Font(Font.MONOSPACED, Font.PLAIN, 12);
|
||||
protected Font mFontAuxDecoder = new Font(Font.MONOSPACED, Font.PLAIN, 10);
|
||||
public static final int ICON_SIZE = 12;
|
||||
|
||||
protected Color mColorLabelDetails;
|
||||
protected Color mColorLabelDecoder;
|
||||
protected Color mColorLabelAuxDecoder;
|
||||
|
||||
protected IconManager mIconManager;
|
||||
protected SettingsManager mSettingsManager;
|
||||
protected DecoderState mDecoderState;
|
||||
|
||||
public DecoderPanel(IconManager iconManager, SettingsManager settingsManager, DecoderState decoderState)
|
||||
{
|
||||
mIconManager = iconManager;
|
||||
mSettingsManager = settingsManager;
|
||||
mSettingsManager.addListener(this);
|
||||
|
||||
mDecoderState = decoderState;
|
||||
|
||||
mDecoderState.setChangedAttributeListener(this);
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
mSettingsManager.removeListener(this);
|
||||
mSettingsManager = null;
|
||||
|
||||
mDecoderState.removeChangedAttributeListener();
|
||||
mDecoderState = null;
|
||||
}
|
||||
|
||||
public DecoderState getDecoderState()
|
||||
{
|
||||
return mDecoderState;
|
||||
}
|
||||
|
||||
protected void init()
|
||||
{
|
||||
getColors();
|
||||
|
||||
setOpaque(false); //Use the parent panel's background color
|
||||
}
|
||||
|
||||
private void getColors()
|
||||
{
|
||||
mColorLabelDetails = mSettingsManager.getColorSetting(
|
||||
ColorSettingName.CHANNEL_STATE_LABEL_DETAILS).getColor();
|
||||
mColorLabelDecoder = mSettingsManager.getColorSetting(
|
||||
ColorSettingName.CHANNEL_STATE_LABEL_DECODER).getColor();
|
||||
mColorLabelAuxDecoder = mSettingsManager.getColorSetting(
|
||||
ColorSettingName.CHANNEL_STATE_LABEL_AUX_DECODER).getColor();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void settingChanged(Setting setting)
|
||||
{
|
||||
if(setting instanceof ColorSetting)
|
||||
{
|
||||
ColorSetting colorSetting = (ColorSetting) setting;
|
||||
|
||||
switch(colorSetting.getColorSettingName())
|
||||
{
|
||||
case CHANNEL_STATE_LABEL_AUX_DECODER:
|
||||
mColorLabelAuxDecoder = colorSetting.getColor();
|
||||
repaint();
|
||||
break;
|
||||
case CHANNEL_STATE_LABEL_DECODER:
|
||||
mColorLabelDecoder = colorSetting.getColor();
|
||||
repaint();
|
||||
break;
|
||||
case CHANNEL_STATE_LABEL_DETAILS:
|
||||
mColorLabelDetails = colorSetting.getColor();
|
||||
repaint();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingDeleted(Setting setting)
|
||||
{
|
||||
}
|
||||
|
||||
protected void setAliasLabel(final JLabel label, final Alias alias)
|
||||
{
|
||||
setAliasLabel(label, alias, true);
|
||||
}
|
||||
|
||||
protected void setAliasLabel(final JLabel label, final Alias alias, boolean includeIcon)
|
||||
{
|
||||
if(alias != null)
|
||||
{
|
||||
label.setText(alias.getName());
|
||||
|
||||
if(includeIcon)
|
||||
{
|
||||
String iconName = alias.getIconName();
|
||||
|
||||
if(iconName != null)
|
||||
{
|
||||
label.setIcon(mIconManager.getIcon(iconName, IconManager.DEFAULT_ICON_SIZE));
|
||||
}
|
||||
else
|
||||
{
|
||||
label.setIcon(null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
label.setIcon(null);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
label.setText("");
|
||||
label.setIcon(null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,6 @@
|
||||
package channel.state;
|
||||
|
||||
import alias.AliasList;
|
||||
import audio.metadata.IMetadataProvider;
|
||||
import audio.metadata.Metadata;
|
||||
import channel.metadata.Attribute;
|
||||
import channel.metadata.AttributeChangeRequest;
|
||||
import channel.metadata.IAttributeChangeRequestProvider;
|
||||
import message.IMessageListener;
|
||||
@@ -193,4 +190,5 @@ public abstract class DecoderState extends Module implements ActivitySummaryProv
|
||||
{
|
||||
mAttributeChangeRequestListener = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
package channel.state;
|
||||
|
||||
import channel.metadata.Attribute;
|
||||
import sample.Listener;
|
||||
|
||||
public interface IChangedAttributeProvider
|
||||
{
|
||||
public void setChangedAttributeListener( Listener<Attribute> listener );
|
||||
public void removeChangedAttributeListener();
|
||||
}
|
||||
Reference in New Issue
Block a user