mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-13 09:07:27 -05:00
#90 [WIP] GUI is functioning again and the new channels table is showing calls and the audio panel is now horizontal. Lots of gui tweaks still to do.
This commit is contained in:
@@ -100,7 +100,11 @@ public class AliasedIdentifier
|
||||
AliasedIdentifier copy = new AliasedIdentifier();
|
||||
|
||||
copy.setAlias(mAlias);
|
||||
copy.setIdentifier(new String(mIdentifier));
|
||||
|
||||
if(mIdentifier != null)
|
||||
{
|
||||
copy.setIdentifier(new String(mIdentifier));
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import controller.channel.Channel;
|
||||
import sample.Listener;
|
||||
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -30,41 +31,55 @@ import java.util.Map;
|
||||
public class ChannelMetadataModel extends AbstractTableModel implements Listener<MutableMetadataChangeEvent>
|
||||
{
|
||||
public static final int COLUMN_STATE = 0;
|
||||
public static final int COLUMN_PRIMARY = 1;
|
||||
public static final int COLUMN_SECONDARY = 2;
|
||||
public static final int COLUMN_MESSAGE = 3;
|
||||
public static final int COLUMN_NETWORK = 4;
|
||||
public static final int COLUMN_FREQUENCY = 5;
|
||||
public static final int COLUMN_FREQUENCY = 1;
|
||||
public static final int COLUMN_PRIMARY = 2;
|
||||
public static final int COLUMN_SECONDARY = 3;
|
||||
public static final int COLUMN_MESSAGE = 4;
|
||||
public static final int COLUMN_NETWORK = 5;
|
||||
public static final int COLUMN_CONFIGURATION = 6;
|
||||
|
||||
private static final String[] COLUMNS =
|
||||
{"State", "Primary", "Secondary", "Message", "Network", "Frequency", "Configuration"};
|
||||
{"State", "Frequency", "Primary", "Secondary", "Message", "Network", "Configuration"};
|
||||
|
||||
private List<MutableMetadata> mChannelMetadata = new ArrayList();
|
||||
private Map<MutableMetadata,Channel> mMetadataChannelMap = new HashMap();
|
||||
|
||||
public void add(MutableMetadata metadata, Channel channel)
|
||||
{
|
||||
mChannelMetadata.add(metadata);
|
||||
mMetadataChannelMap.put(metadata, channel);
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
mChannelMetadata.add(metadata);
|
||||
mMetadataChannelMap.put(metadata, channel);
|
||||
|
||||
int index = mChannelMetadata.indexOf(metadata);
|
||||
int index = mChannelMetadata.indexOf(metadata);
|
||||
|
||||
fireTableRowsInserted(index, index);
|
||||
fireTableRowsInserted(index, index);
|
||||
|
||||
metadata.addListener(this);
|
||||
metadata.addListener(ChannelMetadataModel.this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void remove(MutableMetadata metadata)
|
||||
{
|
||||
metadata.removeListener(this);
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
metadata.removeListener(ChannelMetadataModel.this);
|
||||
|
||||
int index = mChannelMetadata.indexOf(metadata);
|
||||
int index = mChannelMetadata.indexOf(metadata);
|
||||
|
||||
mChannelMetadata.remove(metadata);
|
||||
mMetadataChannelMap.remove(metadata);
|
||||
mChannelMetadata.remove(metadata);
|
||||
mMetadataChannelMap.remove(metadata);
|
||||
|
||||
fireTableRowsDeleted(index, index);
|
||||
fireTableRowsDeleted(index, index);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -94,46 +109,58 @@ public class ChannelMetadataModel extends AbstractTableModel implements Listener
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex)
|
||||
{
|
||||
return mChannelMetadata.get(rowIndex);
|
||||
if(rowIndex <= mChannelMetadata.size())
|
||||
{
|
||||
return mChannelMetadata.get(rowIndex);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(MutableMetadataChangeEvent mutableMetadataChangeEvent)
|
||||
{
|
||||
int rowIndex = mChannelMetadata.indexOf(mutableMetadataChangeEvent.getMetadata());
|
||||
|
||||
if(rowIndex >= 0)
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
switch(mutableMetadataChangeEvent.getAttribute())
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
case CHANNEL_CONFIGURATION_LABEL_1:
|
||||
case CHANNEL_CONFIGURATION_LABEL_2:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_CONFIGURATION);
|
||||
break;
|
||||
case CHANNEL_FREQUENCY:
|
||||
case CHANNEL_FREQUENCY_LABEL:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_FREQUENCY);
|
||||
break;
|
||||
case CHANNEL_STATE:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_STATE);
|
||||
break;
|
||||
case MESSAGE:
|
||||
case MESSAGE_TYPE:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_MESSAGE);
|
||||
break;
|
||||
case NETWORK_ID_1:
|
||||
case NETWORK_ID_2:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_NETWORK);
|
||||
break;
|
||||
case PRIMARY_ADDRESS_FROM:
|
||||
case PRIMARY_ADDRESS_TO:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_PRIMARY);
|
||||
break;
|
||||
case SECONDARY_ADDRESS_FROM:
|
||||
case SECONDARY_ADDRESS_TO:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_SECONDARY);
|
||||
break;
|
||||
int rowIndex = mChannelMetadata.indexOf(mutableMetadataChangeEvent.getMetadata());
|
||||
|
||||
if(rowIndex >= 0)
|
||||
{
|
||||
switch(mutableMetadataChangeEvent.getAttribute())
|
||||
{
|
||||
case CHANNEL_CONFIGURATION_LABEL_1:
|
||||
case CHANNEL_CONFIGURATION_LABEL_2:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_CONFIGURATION);
|
||||
break;
|
||||
case CHANNEL_FREQUENCY:
|
||||
case CHANNEL_FREQUENCY_LABEL:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_FREQUENCY);
|
||||
break;
|
||||
case CHANNEL_STATE:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_STATE);
|
||||
break;
|
||||
case MESSAGE:
|
||||
case MESSAGE_TYPE:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_MESSAGE);
|
||||
break;
|
||||
case NETWORK_ID_1:
|
||||
case NETWORK_ID_2:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_NETWORK);
|
||||
break;
|
||||
case PRIMARY_ADDRESS_FROM:
|
||||
case PRIMARY_ADDRESS_TO:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_PRIMARY);
|
||||
break;
|
||||
case SECONDARY_ADDRESS_FROM:
|
||||
case SECONDARY_ADDRESS_TO:
|
||||
fireTableCellUpdated(rowIndex, COLUMN_SECONDARY);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package channel.metadata;
|
||||
|
||||
import alias.Alias;
|
||||
import icon.IconManager;
|
||||
import icon.IconTableModel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
@@ -31,13 +32,13 @@ import java.text.DecimalFormat;
|
||||
public class ChannelMetadataPanel extends JPanel
|
||||
{
|
||||
private ChannelMetadataModel mChannelMetadataModel;
|
||||
private IconTableModel mIconTableModel;
|
||||
private IconManager mIconManager;
|
||||
private JTable mTable;
|
||||
|
||||
public ChannelMetadataPanel(ChannelMetadataModel channelMetadataModel, IconTableModel iconTableModel)
|
||||
public ChannelMetadataPanel(ChannelMetadataModel channelMetadataModel, IconManager iconManager)
|
||||
{
|
||||
mChannelMetadataModel = channelMetadataModel;
|
||||
mIconTableModel = iconTableModel;
|
||||
mIconManager = iconManager;
|
||||
|
||||
init();
|
||||
}
|
||||
@@ -47,12 +48,16 @@ public class ChannelMetadataPanel extends JPanel
|
||||
*/
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "", "[grow,fill]", "[grow,fill]") );
|
||||
setLayout( new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[grow,fill]") );
|
||||
|
||||
mTable = new JTable(mChannelMetadataModel);
|
||||
mTable.setRowHeight(35);
|
||||
|
||||
mTable.getColumnModel().getColumn(ChannelMetadataModel.COLUMN_STATE).setCellRenderer(new StateCellRenderer());
|
||||
|
||||
mTable.getColumnModel().getColumn(ChannelMetadataModel.COLUMN_FREQUENCY)
|
||||
.setCellRenderer(new FrequencyCellRenderer());
|
||||
|
||||
mTable.getColumnModel().getColumn(ChannelMetadataModel.COLUMN_PRIMARY)
|
||||
.setCellRenderer(new AliasedValueCellRenderer(Attribute.PRIMARY_ADDRESS_TO, Attribute.PRIMARY_ADDRESS_FROM));
|
||||
|
||||
@@ -65,9 +70,6 @@ public class ChannelMetadataPanel extends JPanel
|
||||
mTable.getColumnModel().getColumn(ChannelMetadataModel.COLUMN_NETWORK)
|
||||
.setCellRenderer(new AliasedValueCellRenderer(Attribute.NETWORK_ID_1, Attribute.NETWORK_ID_2));
|
||||
|
||||
mTable.getColumnModel().getColumn(ChannelMetadataModel.COLUMN_FREQUENCY)
|
||||
.setCellRenderer(new FrequencyCellRenderer());
|
||||
|
||||
mTable.getColumnModel().getColumn(ChannelMetadataModel.COLUMN_CONFIGURATION)
|
||||
.setCellRenderer(new AliasedValueCellRenderer(Attribute.CHANNEL_CONFIGURATION_LABEL_1,
|
||||
Attribute.CHANNEL_CONFIGURATION_LABEL_2));
|
||||
@@ -76,6 +78,7 @@ public class ChannelMetadataPanel extends JPanel
|
||||
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||||
|
||||
add(scrollPane);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,21 +100,29 @@ public class ChannelMetadataPanel extends JPanel
|
||||
public class AliasedValueCellRenderer extends JPanel implements TableCellRenderer
|
||||
{
|
||||
private JLabel mLabel1;
|
||||
private JLabel mAlias1;
|
||||
private JLabel mLabel2;
|
||||
private JLabel mAlias2;
|
||||
|
||||
private Attribute mAttribute1;
|
||||
private Attribute mAttribute2;
|
||||
|
||||
public AliasedValueCellRenderer(Attribute attribute1, Attribute attribute2)
|
||||
{
|
||||
attribute1 = attribute1;
|
||||
attribute2 = attribute2;
|
||||
mAttribute1 = attribute1;
|
||||
mAttribute2 = attribute2;
|
||||
|
||||
setLayout( new MigLayout( "", "[grow,fill]", "[grow,fill][grow,fill]") );
|
||||
setLayout( new MigLayout( "insets 0 0 0 0", "[12][grow,fill]", "[grow,fill]0[grow,fill]") );
|
||||
|
||||
mLabel1 = new JLabel();
|
||||
mAlias1 = new JLabel();
|
||||
add(mAlias1);
|
||||
mLabel1 = new JLabel("---");
|
||||
mLabel1.setFont(mTable.getFont());
|
||||
add(mLabel1,"wrap");
|
||||
mLabel2 = new JLabel();
|
||||
mAlias2 = new JLabel();
|
||||
add(mAlias2);
|
||||
mLabel2 = new JLabel("---");
|
||||
mLabel2.setFont(mTable.getFont());
|
||||
add(mLabel2,"wrap");
|
||||
}
|
||||
|
||||
@@ -130,12 +141,12 @@ public class ChannelMetadataPanel extends JPanel
|
||||
|
||||
if(alias1 != null)
|
||||
{
|
||||
mLabel1.setIcon(mIconTableModel.getIcon(alias1.getIconName()).getIcon());
|
||||
mAlias1.setIcon(mIconManager.getIcon(alias1.getIconName(), IconManager.DEFAULT_ICON_SIZE));
|
||||
mLabel1.setForeground(alias1.getDisplayColor());
|
||||
}
|
||||
else
|
||||
{
|
||||
mLabel1.setIcon(null);
|
||||
mAlias1.setIcon(null);
|
||||
mLabel1.setForeground(mTable.getForeground());
|
||||
}
|
||||
}
|
||||
@@ -149,12 +160,12 @@ public class ChannelMetadataPanel extends JPanel
|
||||
|
||||
if(alias2 != null)
|
||||
{
|
||||
mLabel2.setIcon(mIconTableModel.getIcon(alias2.getIconName()).getIcon());
|
||||
mAlias2.setIcon(mIconManager.getIcon(alias2.getIconName(), IconManager.DEFAULT_ICON_SIZE));
|
||||
mLabel2.setForeground(alias2.getDisplayColor());
|
||||
}
|
||||
else
|
||||
{
|
||||
mLabel2.setIcon(null);
|
||||
mAlias2.setIcon(null);
|
||||
mLabel2.setForeground(mTable.getForeground());
|
||||
}
|
||||
}
|
||||
@@ -165,21 +176,23 @@ public class ChannelMetadataPanel extends JPanel
|
||||
}
|
||||
}
|
||||
|
||||
public static class FrequencyCellRenderer extends JPanel implements TableCellRenderer
|
||||
public class FrequencyCellRenderer extends JPanel implements TableCellRenderer
|
||||
{
|
||||
private static final DecimalFormat FREQUENCY_FORMATTER = new DecimalFormat( "#.0000" );
|
||||
private final DecimalFormat FREQUENCY_FORMATTER = new DecimalFormat( "#.000000" );
|
||||
|
||||
private JLabel mLabel1;
|
||||
private JLabel mLabel2;
|
||||
|
||||
public FrequencyCellRenderer()
|
||||
{
|
||||
setLayout( new MigLayout( "", "[grow,fill]", "[grow,fill][grow,fill]") );
|
||||
setLayout( new MigLayout( "insets 0 0 0 0", "[grow,fill,align center]", "[grow,fill]0[grow,fill]") );
|
||||
|
||||
mLabel1 = new JLabel();
|
||||
mLabel1.setFont(mTable.getFont());
|
||||
add(mLabel1,"wrap");
|
||||
mLabel2 = new JLabel();
|
||||
add(mLabel2,"wrap");
|
||||
mLabel2.setFont(mTable.getFont());
|
||||
add(mLabel2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -205,17 +218,16 @@ public class ChannelMetadataPanel extends JPanel
|
||||
}
|
||||
}
|
||||
|
||||
public static class StateCellRenderer extends JPanel implements TableCellRenderer
|
||||
public class StateCellRenderer extends JPanel implements TableCellRenderer
|
||||
{
|
||||
private static final DecimalFormat FREQUENCY_FORMATTER = new DecimalFormat( "#.0000" );
|
||||
|
||||
private JLabel mLabel1;
|
||||
|
||||
public StateCellRenderer()
|
||||
{
|
||||
setLayout( new MigLayout( "", "[grow,fill,align center]", "[grow,fill,align center]") );
|
||||
setLayout( new MigLayout( "insets 0 0 0 0", "[grow,fill,align center]", "[grow,fill,align center]") );
|
||||
|
||||
mLabel1 = new JLabel();
|
||||
mLabel1.setFont(mTable.getFont());
|
||||
add(mLabel1);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,12 +49,14 @@ public class ChannelMetadataViewer extends JPanel
|
||||
mMessageActivityPanel = new MessageActivityPanel(channelProcessingManager);
|
||||
mChannelSpectrumPanel = new ChannelSpectrumPanel(settingsManager, channelProcessingManager);
|
||||
mChannelMetadataPanel = new ChannelMetadataPanel(channelProcessingManager.getChannelMetadataModel(),
|
||||
iconManager.getModel());
|
||||
iconManager);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "", "[grow,fill]", "[grow,fill]") );
|
||||
setLayout( new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[grow,fill]") );
|
||||
|
||||
JideTabbedPane tabbedPane = new JideTabbedPane();
|
||||
tabbedPane.addTab("Details", new JPanel());
|
||||
@@ -65,6 +67,7 @@ public class ChannelMetadataViewer extends JPanel
|
||||
JideSplitPane splitPane = new JideSplitPane(JideSplitPane.VERTICAL_SPLIT);
|
||||
splitPane.add(mChannelMetadataPanel);
|
||||
splitPane.add(tabbedPane);
|
||||
add(splitPane);
|
||||
|
||||
//TODO: move this change listener to the metadata table view
|
||||
// /**
|
||||
@@ -100,6 +103,5 @@ public class ChannelMetadataViewer extends JPanel
|
||||
// mChannelModel.addListener(mChannelSpectrumPanel);
|
||||
// mChannelModel.addListener(mMessageActivityPanel);
|
||||
|
||||
add(splitPane);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,7 +256,7 @@ public class Metadata
|
||||
case SECONDARY_ADDRESS_FROM:
|
||||
return mSecondaryAddressFrom.getIdentifier();
|
||||
case SECONDARY_ADDRESS_TO:
|
||||
return mPrimaryAddressTo.getIdentifier();
|
||||
return mSecondaryAddressTo.getIdentifier();
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -89,10 +89,6 @@ public class MutableMetadata extends Metadata implements Listener<AttributeChang
|
||||
{
|
||||
mChannelFrequency = request.getLongValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
mChannelFrequency = 0;
|
||||
}
|
||||
broadcast(Attribute.CHANNEL_FREQUENCY);
|
||||
break;
|
||||
case CHANNEL_FREQUENCY_LABEL:
|
||||
|
||||
Reference in New Issue
Block a user