mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 08:37:25 -05:00
Merge pull request #103 from DSheirer/#82_icon_manager_model
#82 icon manager model
This commit is contained in:
@@ -1,369 +1,356 @@
|
||||
package alias;
|
||||
|
||||
import audio.broadcast.BroadcastModel;
|
||||
import com.jidesoft.swing.JideSplitPane;
|
||||
import gui.editor.Editor;
|
||||
import icon.IconManager;
|
||||
import net.coderazzi.filters.gui.AutoChoices;
|
||||
import net.coderazzi.filters.gui.TableFilterHeader;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Rectangle;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
|
||||
import net.coderazzi.filters.gui.AutoChoices;
|
||||
import net.coderazzi.filters.gui.TableFilterHeader;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import settings.SettingsManager;
|
||||
|
||||
import com.jidesoft.swing.JideSplitPane;
|
||||
|
||||
public class AliasController extends JPanel
|
||||
implements ActionListener, ListSelectionListener
|
||||
public class AliasController extends JPanel
|
||||
implements ActionListener, ListSelectionListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private AliasModel mAliasModel;
|
||||
private JTable mAliasTable;
|
||||
private TableFilterHeader mTableFilterHeader;
|
||||
private AliasEditor mAliasEditor;
|
||||
private MultipleAliasEditor mMultipleAliasEditor;
|
||||
private JideSplitPane mSplitPane;
|
||||
|
||||
private static final String NEW_ALIAS = "New";
|
||||
private static final String COPY_ALIAS = "Copy";
|
||||
private static final String DELETE_ALIAS = "Delete";
|
||||
|
||||
private JButton mNewButton = new JButton( NEW_ALIAS );
|
||||
private JButton mCopyButton = new JButton( COPY_ALIAS );
|
||||
private JButton mDeleteButton = new JButton( DELETE_ALIAS );
|
||||
|
||||
private IconCellRenderer mIconCellRenderer;
|
||||
private AliasModel mAliasModel;
|
||||
private JTable mAliasTable;
|
||||
private TableFilterHeader mTableFilterHeader;
|
||||
private AliasEditor mAliasEditor;
|
||||
private MultipleAliasEditor mMultipleAliasEditor;
|
||||
private JideSplitPane mSplitPane;
|
||||
|
||||
public AliasController(AliasModel aliasModel, BroadcastModel broadcastModel, SettingsManager settingsManager )
|
||||
{
|
||||
mAliasModel = aliasModel;
|
||||
private static final String NEW_ALIAS = "New";
|
||||
private static final String COPY_ALIAS = "Copy";
|
||||
private static final String DELETE_ALIAS = "Delete";
|
||||
|
||||
mAliasEditor = new AliasEditor( mAliasModel, broadcastModel, settingsManager );
|
||||
mMultipleAliasEditor = new MultipleAliasEditor( mAliasModel, broadcastModel, settingsManager );
|
||||
private JButton mNewButton = new JButton(NEW_ALIAS);
|
||||
private JButton mCopyButton = new JButton(COPY_ALIAS);
|
||||
private JButton mDeleteButton = new JButton(DELETE_ALIAS);
|
||||
|
||||
mIconCellRenderer = new IconCellRenderer( settingsManager );
|
||||
|
||||
init();
|
||||
|
||||
mAliasModel.addListener( mAliasEditor );
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "insets 0 0 0 0",
|
||||
"[grow,fill]",
|
||||
"[grow,fill]") );
|
||||
private IconCellRenderer mIconCellRenderer;
|
||||
|
||||
//System Configuration View and Editor
|
||||
mAliasTable = new JTable( mAliasModel );
|
||||
mAliasTable.setSelectionMode( ListSelectionModel.MULTIPLE_INTERVAL_SELECTION );
|
||||
mAliasTable.getSelectionModel().addListSelectionListener( this );
|
||||
mAliasTable.setAutoCreateRowSorter( true );
|
||||
|
||||
mAliasTable.getColumnModel().getColumn( AliasModel.COLUMN_COLOR )
|
||||
.setCellRenderer( new ColorCellRenderer() );
|
||||
|
||||
mAliasTable.getColumnModel().getColumn( AliasModel.COLUMN_ICON )
|
||||
.setCellRenderer( mIconCellRenderer );
|
||||
public AliasController(AliasModel aliasModel, BroadcastModel broadcastModel, IconManager iconManager)
|
||||
{
|
||||
mAliasModel = aliasModel;
|
||||
|
||||
mTableFilterHeader = new TableFilterHeader( mAliasTable, AutoChoices.ENABLED );
|
||||
mTableFilterHeader.setFilterOnUpdates( true );
|
||||
|
||||
JScrollPane tableScroller = new JScrollPane( mAliasTable );
|
||||
mAliasEditor = new AliasEditor(mAliasModel, broadcastModel, iconManager);
|
||||
mMultipleAliasEditor = new MultipleAliasEditor(mAliasModel, broadcastModel, iconManager);
|
||||
|
||||
JPanel buttonsPanel = new JPanel();
|
||||
|
||||
buttonsPanel.setLayout(
|
||||
new MigLayout( "insets 0 0 0 0", "[grow,fill][grow,fill][grow,fill]", "[]") );
|
||||
mIconCellRenderer = new IconCellRenderer(iconManager);
|
||||
|
||||
mNewButton.addActionListener( this );
|
||||
mNewButton.setToolTipText( "Adds a new alias" );
|
||||
buttonsPanel.add( mNewButton );
|
||||
|
||||
mCopyButton.addActionListener( this );
|
||||
mCopyButton.setEnabled( false );
|
||||
mCopyButton.setToolTipText( "Creates a copy of the currently selected alias and adds it" );
|
||||
buttonsPanel.add( mCopyButton );
|
||||
init();
|
||||
|
||||
mDeleteButton.addActionListener( this );
|
||||
mDeleteButton.setEnabled( false );
|
||||
mDeleteButton.setToolTipText( "Deletes the currently selected alias" );
|
||||
buttonsPanel.add( mDeleteButton );
|
||||
|
||||
JPanel listAndButtonsPanel = new JPanel();
|
||||
mAliasModel.addListener(mAliasEditor);
|
||||
}
|
||||
|
||||
listAndButtonsPanel.setLayout(
|
||||
new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[grow,fill][]") );
|
||||
private void init()
|
||||
{
|
||||
setLayout(new MigLayout("insets 0 0 0 0",
|
||||
"[grow,fill]",
|
||||
"[grow,fill]"));
|
||||
|
||||
listAndButtonsPanel.add( tableScroller, "wrap" );
|
||||
listAndButtonsPanel.add( buttonsPanel );
|
||||
|
||||
mSplitPane = new JideSplitPane( JideSplitPane.HORIZONTAL_SPLIT );
|
||||
mSplitPane.setDividerSize( 5 );
|
||||
mSplitPane.setShowGripper( true );
|
||||
mSplitPane.add( listAndButtonsPanel );
|
||||
mSplitPane.add( mAliasEditor );
|
||||
//System Configuration View and Editor
|
||||
mAliasTable = new JTable(mAliasModel);
|
||||
mAliasTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||
mAliasTable.getSelectionModel().addListSelectionListener(this);
|
||||
mAliasTable.setAutoCreateRowSorter(true);
|
||||
|
||||
add( mSplitPane );
|
||||
}
|
||||
mAliasTable.getColumnModel().getColumn(AliasModel.COLUMN_COLOR)
|
||||
.setCellRenderer(new ColorCellRenderer());
|
||||
|
||||
/**
|
||||
* Sets the editor argument as the currently visible alias editor
|
||||
*/
|
||||
private void setEditor( Editor<?> editor )
|
||||
{
|
||||
if( mSplitPane.getComponentCount() == 3 )
|
||||
{
|
||||
Component component = mSplitPane.getComponent( 2 );
|
||||
|
||||
if( component instanceof Editor<?> && component != editor )
|
||||
{
|
||||
//Get current divider location so that we can reapply it after
|
||||
//changing out the editors, so that the interface doesn't move
|
||||
int location = mSplitPane.getDividerLocation( 0 );
|
||||
|
||||
((Editor<?>)component).setItem( null );
|
||||
|
||||
mSplitPane.remove( component );
|
||||
editor.setPreferredSize( new Dimension( 100, 100 ) );
|
||||
mSplitPane.add( editor );
|
||||
|
||||
mSplitPane.validate();
|
||||
mSplitPane.setDividerLocation( 0, location );
|
||||
mSplitPane.repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Alias getAlias( int selectedRow )
|
||||
{
|
||||
if( selectedRow >= 0 )
|
||||
{
|
||||
int index = mAliasTable.convertRowIndexToModel( selectedRow );
|
||||
|
||||
return mAliasModel.getAliasAtIndex( index );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
mAliasTable.getColumnModel().getColumn(AliasModel.COLUMN_ICON)
|
||||
.setCellRenderer(mIconCellRenderer);
|
||||
|
||||
@Override
|
||||
public void valueChanged( ListSelectionEvent event )
|
||||
{
|
||||
//Limits event firing to only when selection is complete
|
||||
if( !event.getValueIsAdjusting() )
|
||||
{
|
||||
int[] selectedRows = mAliasTable.getSelectedRows();
|
||||
mTableFilterHeader = new TableFilterHeader(mAliasTable, AutoChoices.ENABLED);
|
||||
mTableFilterHeader.setFilterOnUpdates(true);
|
||||
|
||||
if( selectedRows.length == 0 )
|
||||
{
|
||||
mAliasEditor.setItem( null );
|
||||
mCopyButton.setEnabled( false );
|
||||
mDeleteButton.setEnabled( false );
|
||||
}
|
||||
else if( selectedRows.length == 1 )
|
||||
{
|
||||
setEditor( mAliasEditor );
|
||||
|
||||
Alias selectedAlias = getAlias( selectedRows[ 0 ] );
|
||||
|
||||
mAliasEditor.setItem( selectedAlias );
|
||||
|
||||
if( selectedAlias != null )
|
||||
{
|
||||
mCopyButton.setEnabled( true );
|
||||
mDeleteButton.setEnabled( true );
|
||||
}
|
||||
else
|
||||
{
|
||||
mCopyButton.setEnabled( false );
|
||||
mDeleteButton.setEnabled( false );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setEditor( mMultipleAliasEditor );
|
||||
|
||||
mCopyButton.setEnabled( true );
|
||||
mDeleteButton.setEnabled( true );
|
||||
JScrollPane tableScroller = new JScrollPane(mAliasTable);
|
||||
|
||||
List<Alias> selectedAliases = new ArrayList<Alias>();
|
||||
|
||||
for( int selectedRow: selectedRows )
|
||||
{
|
||||
Alias alias = getAlias( selectedRow );
|
||||
JPanel buttonsPanel = new JPanel();
|
||||
|
||||
selectedAliases.add( alias );
|
||||
}
|
||||
|
||||
mMultipleAliasEditor.setItem( selectedAliases );
|
||||
}
|
||||
}
|
||||
}
|
||||
buttonsPanel.setLayout(
|
||||
new MigLayout("insets 0 0 0 0", "[grow,fill][grow,fill][grow,fill]", "[]"));
|
||||
|
||||
/**
|
||||
* Adds the alias to the alias table/model and scrolls the view it
|
||||
*/
|
||||
private void addAlias( Alias alias )
|
||||
{
|
||||
//HACK: when inserting a row to the model, the JTable gets
|
||||
//notified and attempts to tell the coderazzi table filter
|
||||
//adaptive choices filter to refresh before the table filter is
|
||||
//notified of the row additions, causing an index out of bounds
|
||||
//exception. We turn off adaptive choices temporarily, add the
|
||||
//channel, and turn on adaptive choices again.
|
||||
mTableFilterHeader.setAdaptiveChoices( false );
|
||||
|
||||
int index = mAliasModel.addAlias( alias );
|
||||
mNewButton.addActionListener(this);
|
||||
mNewButton.setToolTipText("Adds a new alias");
|
||||
buttonsPanel.add(mNewButton);
|
||||
|
||||
mTableFilterHeader.setAdaptiveChoices( true );
|
||||
mCopyButton.addActionListener(this);
|
||||
mCopyButton.setEnabled(false);
|
||||
mCopyButton.setToolTipText("Creates a copy of the currently selected alias and adds it");
|
||||
buttonsPanel.add(mCopyButton);
|
||||
|
||||
if( index >= 0 )
|
||||
{
|
||||
int translatedIndex = mAliasTable.convertRowIndexToView( index );
|
||||
mAliasTable.setRowSelectionInterval( translatedIndex, translatedIndex );
|
||||
mAliasTable.scrollRectToVisible(
|
||||
new Rectangle( mAliasTable.getCellRect( translatedIndex, 0, true ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
private List<Alias> getSelectedAliases()
|
||||
{
|
||||
List<Alias> selected = new ArrayList<>();
|
||||
|
||||
int[] rows = mAliasTable.getSelectedRows();
|
||||
mDeleteButton.addActionListener(this);
|
||||
mDeleteButton.setEnabled(false);
|
||||
mDeleteButton.setToolTipText("Deletes the currently selected alias");
|
||||
buttonsPanel.add(mDeleteButton);
|
||||
|
||||
for( int row: rows )
|
||||
{
|
||||
if( row >= 0 )
|
||||
{
|
||||
Alias alias = mAliasModel.getAliasAtIndex( mAliasTable.convertRowIndexToModel( row ) );
|
||||
|
||||
if( alias != null )
|
||||
{
|
||||
selected.add( alias );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return selected;
|
||||
}
|
||||
JPanel listAndButtonsPanel = new JPanel();
|
||||
|
||||
/**
|
||||
* Responds to New, Copy and Delete Channel button invocations
|
||||
*/
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent event )
|
||||
{
|
||||
switch( event.getActionCommand() )
|
||||
{
|
||||
case NEW_ALIAS:
|
||||
addAlias( new Alias( "New Alias" ) );
|
||||
break;
|
||||
case COPY_ALIAS:
|
||||
for( Alias alias: getSelectedAliases() )
|
||||
{
|
||||
addAlias( AliasFactory.copyOf( alias ) );
|
||||
}
|
||||
break;
|
||||
case DELETE_ALIAS:
|
||||
List<Alias> toDelete = getSelectedAliases();
|
||||
listAndButtonsPanel.setLayout(
|
||||
new MigLayout("insets 0 0 0 0", "[grow,fill]", "[grow,fill][]"));
|
||||
|
||||
if( toDelete != null && !toDelete.isEmpty() )
|
||||
{
|
||||
String title = toDelete.size() == 1 ? "Delete Alias?" : "Delete Aliases?";
|
||||
String prompt = toDelete.size() == 1 ? "Do you want to delete this alias?" :
|
||||
"Do you want to delete these " + toDelete.size() + " aliases?";
|
||||
|
||||
int choice = JOptionPane.showConfirmDialog( AliasController.this,
|
||||
prompt, title, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE );
|
||||
|
||||
if( choice == JOptionPane.YES_OPTION )
|
||||
{
|
||||
for( Alias alias: toDelete )
|
||||
{
|
||||
mAliasModel.removeAlias( alias );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
listAndButtonsPanel.add(tableScroller, "wrap");
|
||||
listAndButtonsPanel.add(buttonsPanel);
|
||||
|
||||
/**
|
||||
* Colorizes the cell based on the cell's integer value
|
||||
*/
|
||||
public class ColorCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
mSplitPane = new JideSplitPane(JideSplitPane.HORIZONTAL_SPLIT);
|
||||
mSplitPane.setDividerSize(5);
|
||||
mSplitPane.setShowGripper(true);
|
||||
mSplitPane.add(listAndButtonsPanel);
|
||||
mSplitPane.add(mAliasEditor);
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent( JTable table,
|
||||
Object value, boolean isSelected, boolean hasFocus, int row,
|
||||
int column )
|
||||
{
|
||||
JLabel label = (JLabel)super.getTableCellRendererComponent( table,
|
||||
value, isSelected, hasFocus, row, column );
|
||||
add(mSplitPane);
|
||||
}
|
||||
|
||||
label.setBackground( new Color( (int)value ) );
|
||||
|
||||
label.setText( "" );
|
||||
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays cell's icon and name
|
||||
*/
|
||||
public class IconCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private SettingsManager mSettingsManager;
|
||||
|
||||
public IconCellRenderer( SettingsManager settingsManager )
|
||||
{
|
||||
mSettingsManager = settingsManager;
|
||||
}
|
||||
/**
|
||||
* Sets the editor argument as the currently visible alias editor
|
||||
*/
|
||||
private void setEditor(Editor<?> editor)
|
||||
{
|
||||
if(mSplitPane.getComponentCount() == 3)
|
||||
{
|
||||
Component component = mSplitPane.getComponent(2);
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent( JTable table,
|
||||
Object value, boolean isSelected, boolean hasFocus, int row,
|
||||
int column )
|
||||
{
|
||||
JLabel label = (JLabel)super.getTableCellRendererComponent( table,
|
||||
value, isSelected, hasFocus, row, column );
|
||||
if(component instanceof Editor<?> && component != editor)
|
||||
{
|
||||
//Get current divider location so that we can reapply it after
|
||||
//changing out the editors, so that the interface doesn't move
|
||||
int location = mSplitPane.getDividerLocation(0);
|
||||
|
||||
ImageIcon icon = mSettingsManager.getImageIcon( label.getText(), 12 );
|
||||
((Editor<?>) component).setItem(null);
|
||||
|
||||
if( icon != null )
|
||||
{
|
||||
label.setIcon( icon );
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
}
|
||||
mSplitPane.remove(component);
|
||||
editor.setPreferredSize(new Dimension(100, 100));
|
||||
mSplitPane.add(editor);
|
||||
|
||||
mSplitPane.validate();
|
||||
mSplitPane.setDividerLocation(0, location);
|
||||
mSplitPane.repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Alias getAlias(int selectedRow)
|
||||
{
|
||||
if(selectedRow >= 0)
|
||||
{
|
||||
int index = mAliasTable.convertRowIndexToModel(selectedRow);
|
||||
|
||||
return mAliasModel.getAliasAtIndex(index);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent event)
|
||||
{
|
||||
//Limits event firing to only when selection is complete
|
||||
if(!event.getValueIsAdjusting())
|
||||
{
|
||||
int[] selectedRows = mAliasTable.getSelectedRows();
|
||||
|
||||
if(selectedRows.length == 0)
|
||||
{
|
||||
mAliasEditor.setItem(null);
|
||||
mCopyButton.setEnabled(false);
|
||||
mDeleteButton.setEnabled(false);
|
||||
}
|
||||
else if(selectedRows.length == 1)
|
||||
{
|
||||
setEditor(mAliasEditor);
|
||||
|
||||
Alias selectedAlias = getAlias(selectedRows[0]);
|
||||
|
||||
mAliasEditor.setItem(selectedAlias);
|
||||
|
||||
if(selectedAlias != null)
|
||||
{
|
||||
mCopyButton.setEnabled(true);
|
||||
mDeleteButton.setEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
mCopyButton.setEnabled(false);
|
||||
mDeleteButton.setEnabled(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setEditor(mMultipleAliasEditor);
|
||||
|
||||
mCopyButton.setEnabled(true);
|
||||
mDeleteButton.setEnabled(true);
|
||||
|
||||
List<Alias> selectedAliases = new ArrayList<Alias>();
|
||||
|
||||
for(int selectedRow : selectedRows)
|
||||
{
|
||||
Alias alias = getAlias(selectedRow);
|
||||
|
||||
selectedAliases.add(alias);
|
||||
}
|
||||
|
||||
mMultipleAliasEditor.setItem(selectedAliases);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the alias to the alias table/model and scrolls the view it
|
||||
*/
|
||||
private void addAlias(Alias alias)
|
||||
{
|
||||
//HACK: when inserting a row to the model, the JTable gets
|
||||
//notified and attempts to tell the coderazzi table filter
|
||||
//adaptive choices filter to refresh before the table filter is
|
||||
//notified of the row additions, causing an index out of bounds
|
||||
//exception. We turn off adaptive choices temporarily, add the
|
||||
//channel, and turn on adaptive choices again.
|
||||
mTableFilterHeader.setAdaptiveChoices(false);
|
||||
|
||||
int index = mAliasModel.addAlias(alias);
|
||||
|
||||
mTableFilterHeader.setAdaptiveChoices(true);
|
||||
|
||||
if(index >= 0)
|
||||
{
|
||||
int translatedIndex = mAliasTable.convertRowIndexToView(index);
|
||||
mAliasTable.setRowSelectionInterval(translatedIndex, translatedIndex);
|
||||
mAliasTable.scrollRectToVisible(
|
||||
new Rectangle(mAliasTable.getCellRect(translatedIndex, 0, true)));
|
||||
}
|
||||
}
|
||||
|
||||
private List<Alias> getSelectedAliases()
|
||||
{
|
||||
List<Alias> selected = new ArrayList<>();
|
||||
|
||||
int[] rows = mAliasTable.getSelectedRows();
|
||||
|
||||
for(int row : rows)
|
||||
{
|
||||
if(row >= 0)
|
||||
{
|
||||
Alias alias = mAliasModel.getAliasAtIndex(mAliasTable.convertRowIndexToModel(row));
|
||||
|
||||
if(alias != null)
|
||||
{
|
||||
selected.add(alias);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return selected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Responds to New, Copy and Delete Channel button invocations
|
||||
*/
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent event)
|
||||
{
|
||||
switch(event.getActionCommand())
|
||||
{
|
||||
case NEW_ALIAS:
|
||||
addAlias(new Alias("New Alias"));
|
||||
break;
|
||||
case COPY_ALIAS:
|
||||
for(Alias alias : getSelectedAliases())
|
||||
{
|
||||
addAlias(AliasFactory.copyOf(alias));
|
||||
}
|
||||
break;
|
||||
case DELETE_ALIAS:
|
||||
List<Alias> toDelete = getSelectedAliases();
|
||||
|
||||
if(toDelete != null && !toDelete.isEmpty())
|
||||
{
|
||||
String title = toDelete.size() == 1 ? "Delete Alias?" : "Delete Aliases?";
|
||||
String prompt = toDelete.size() == 1 ? "Do you want to delete this alias?" :
|
||||
"Do you want to delete these " + toDelete.size() + " aliases?";
|
||||
|
||||
int choice = JOptionPane.showConfirmDialog(AliasController.this,
|
||||
prompt, title, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
|
||||
|
||||
if(choice == JOptionPane.YES_OPTION)
|
||||
{
|
||||
for(Alias alias : toDelete)
|
||||
{
|
||||
mAliasModel.removeAlias(alias);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Colorizes the cell based on the cell's integer value
|
||||
*/
|
||||
public class ColorCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table,
|
||||
Object value, boolean isSelected, boolean hasFocus, int row,
|
||||
int column)
|
||||
{
|
||||
JLabel label = (JLabel) super.getTableCellRendererComponent(table,
|
||||
value, isSelected, hasFocus, row, column);
|
||||
|
||||
label.setBackground(new Color((int) value));
|
||||
|
||||
label.setText("");
|
||||
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays cell's icon and name
|
||||
*/
|
||||
public class IconCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private IconManager mIconManager;
|
||||
|
||||
public IconCellRenderer(IconManager iconManager)
|
||||
{
|
||||
mIconManager = iconManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table,
|
||||
Object value, boolean isSelected, boolean hasFocus, int row,
|
||||
int column)
|
||||
{
|
||||
JLabel label = (JLabel) super.getTableCellRendererComponent(table,
|
||||
value, isSelected, hasFocus, row, column);
|
||||
|
||||
ImageIcon icon = mIconManager.getIcon(label.getText(), 12);
|
||||
|
||||
if(icon != null)
|
||||
{
|
||||
label.setIcon(icon);
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import javax.swing.JButton;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JSeparator;
|
||||
|
||||
import icon.IconManager;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import sample.Listener;
|
||||
import settings.SettingsManager;
|
||||
@@ -50,10 +51,10 @@ public class AliasEditor extends Editor<Alias>
|
||||
private AliasIdentifierEditor mAliasIdentifierEditor;
|
||||
private AliasActionEditor mAliasActionEditor;
|
||||
|
||||
public AliasEditor(AliasModel aliasModel, BroadcastModel broadcastModel, SettingsManager settingsManager )
|
||||
public AliasEditor(AliasModel aliasModel, BroadcastModel broadcastModel, IconManager iconManager )
|
||||
{
|
||||
mAliasModel = aliasModel;
|
||||
mAliasNameEditor = new AliasNameEditor( mAliasModel, settingsManager );
|
||||
mAliasNameEditor = new AliasNameEditor( mAliasModel, iconManager );
|
||||
mAliasIdentifierEditor = new AliasIdentifierEditor( aliasModel, broadcastModel );
|
||||
mAliasActionEditor = new AliasActionEditor( aliasModel );
|
||||
|
||||
|
||||
@@ -1,291 +1,333 @@
|
||||
/*******************************************************************************
|
||||
* 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 alias;
|
||||
|
||||
import alias.AliasEvent.Event;
|
||||
import gui.editor.Editor;
|
||||
import icon.Icon;
|
||||
import icon.IconListCellRenderer;
|
||||
import icon.IconManager;
|
||||
import icon.IconTableModel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.event.TableModelListener;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.ComboBoxModel;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JColorChooser;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
|
||||
import map.IconManager;
|
||||
import map.MapIcon;
|
||||
import map.MapIconListCellRenderer;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import settings.SettingsManager;
|
||||
import alias.AliasEvent.Event;
|
||||
|
||||
public class AliasNameEditor extends Editor<Alias>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private static ComboBoxModel<String> EMPTY_MODEL = new DefaultComboBoxModel<>();
|
||||
private static ComboBoxModel<String> EMPTY_MODEL = new DefaultComboBoxModel<>();
|
||||
|
||||
private JComboBox<String> mListCombo = new JComboBox<>( EMPTY_MODEL );
|
||||
private JComboBox<String> mGroupCombo = new JComboBox<>( EMPTY_MODEL );
|
||||
private JComboBox<MapIcon> mMapIconCombo;
|
||||
private JComboBox<String> mListCombo = new JComboBox<>(EMPTY_MODEL);
|
||||
private JComboBox<String> mGroupCombo = new JComboBox<>(EMPTY_MODEL);
|
||||
private JComboBox<Icon> mIconCombo;
|
||||
private JTextField mName;
|
||||
private JButton mButtonColor;
|
||||
private JButton mBtnIconManager;
|
||||
|
||||
|
||||
private AliasModel mAliasModel;
|
||||
private SettingsManager mSettingsManager;
|
||||
|
||||
public AliasNameEditor( AliasModel aliasModel, SettingsManager settingsManager )
|
||||
{
|
||||
mAliasModel = aliasModel;
|
||||
mSettingsManager = settingsManager;
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[right][grow,fill]",
|
||||
"[][][][][][][grow]" ) );
|
||||
private IconManager mIconManager;
|
||||
|
||||
add( new JLabel( "Name:" ) );
|
||||
mName = new JTextField();
|
||||
mName.getDocument().addDocumentListener( new DocumentListener()
|
||||
{
|
||||
@Override
|
||||
public void removeUpdate( DocumentEvent e )
|
||||
{
|
||||
setModified( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertUpdate( DocumentEvent e )
|
||||
{
|
||||
setModified( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate( DocumentEvent e ){}
|
||||
} );
|
||||
add( mName, "wrap" );
|
||||
public AliasNameEditor(AliasModel aliasModel, IconManager iconManager)
|
||||
{
|
||||
mAliasModel = aliasModel;
|
||||
mIconManager = iconManager;
|
||||
|
||||
add( new JLabel( "List:" ) );
|
||||
mListCombo.setEditable( true );
|
||||
mListCombo.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
if( mListCombo.getSelectedItem() != null )
|
||||
{
|
||||
List<String> groups = mAliasModel
|
||||
.getGroupNames( (String)mListCombo.getSelectedItem() );
|
||||
|
||||
if( groups.isEmpty() )
|
||||
{
|
||||
mGroupCombo.setModel( EMPTY_MODEL );
|
||||
}
|
||||
else
|
||||
{
|
||||
mGroupCombo.setModel( new DefaultComboBoxModel<String>(
|
||||
groups.toArray( new String[ groups.size() ] ) ) );;
|
||||
}
|
||||
}
|
||||
|
||||
setModified( true );
|
||||
}
|
||||
} );
|
||||
add( mListCombo, "wrap" );
|
||||
|
||||
add( new JLabel( "Group:" ) );
|
||||
mGroupCombo.setEditable( true );
|
||||
mGroupCombo.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
setModified( true );
|
||||
}
|
||||
} );
|
||||
add( mGroupCombo, "wrap" );
|
||||
|
||||
add( new JLabel( "Color:" ) );
|
||||
|
||||
mButtonColor = new JButton( "Select ..." );
|
||||
mButtonColor.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
mIconManager.getModel().addTableModelListener(new TableModelListener()
|
||||
{
|
||||
@Override
|
||||
public void tableChanged(TableModelEvent e)
|
||||
{
|
||||
Color newColor = JColorChooser.showDialog(
|
||||
AliasNameEditor.this,
|
||||
"Choose color for this alias",
|
||||
( hasItem() ? getItem().getMapColor() : null ) );
|
||||
|
||||
if( newColor != null )
|
||||
{
|
||||
mButtonColor.setForeground( newColor );
|
||||
mButtonColor.setBackground( newColor );
|
||||
|
||||
setModified( true );
|
||||
}
|
||||
refreshIcons();
|
||||
}
|
||||
} );
|
||||
add( mButtonColor, "wrap" );
|
||||
|
||||
add( new JLabel( "Icon:" ) );
|
||||
|
||||
mMapIconCombo = new JComboBox<MapIcon>( mSettingsManager.getMapIcons() );
|
||||
});
|
||||
|
||||
MapIconListCellRenderer renderer = new MapIconListCellRenderer();
|
||||
renderer.setPreferredSize( new Dimension( 200, 30 ) );
|
||||
mMapIconCombo.setRenderer( renderer );
|
||||
mMapIconCombo.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
setModified( true );
|
||||
}
|
||||
} );
|
||||
init();
|
||||
}
|
||||
|
||||
add( mMapIconCombo, "wrap" );
|
||||
private void init()
|
||||
{
|
||||
setLayout(new MigLayout("fill,wrap 2", "[right][grow,fill]", "[][][][][][][grow]"));
|
||||
|
||||
//Dummy place holder
|
||||
add( new JLabel() );
|
||||
|
||||
mBtnIconManager = new JButton( "Icon Manager" );
|
||||
mBtnIconManager.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent arg0 )
|
||||
add(new JLabel("Name:"));
|
||||
mName = new JTextField();
|
||||
mName.getDocument().addDocumentListener(new DocumentListener()
|
||||
{
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e)
|
||||
{
|
||||
final IconManager iconManager =
|
||||
new IconManager( mSettingsManager, AliasNameEditor.this );
|
||||
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
iconManager.setVisible( true );
|
||||
}
|
||||
} );
|
||||
setModified(true);
|
||||
}
|
||||
} );
|
||||
|
||||
add( mBtnIconManager, "span 2,wrap" );
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e)
|
||||
{
|
||||
setModified(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem( Alias alias )
|
||||
{
|
||||
super.setItem( alias );
|
||||
|
||||
if( hasItem() )
|
||||
{
|
||||
mName.setText( alias.getName() );
|
||||
|
||||
List<String> listNames = mAliasModel.getListNames();
|
||||
|
||||
if( listNames.isEmpty() )
|
||||
{
|
||||
mListCombo.setModel( EMPTY_MODEL );
|
||||
}
|
||||
else
|
||||
{
|
||||
mListCombo.setModel( new DefaultComboBoxModel<String>(
|
||||
listNames.toArray( new String[ listNames.size() ] ) ) );;
|
||||
}
|
||||
|
||||
mListCombo.setSelectedItem( alias.getList() );
|
||||
|
||||
List<String> groupNames = mAliasModel.getGroupNames( alias.getList() );
|
||||
|
||||
if( groupNames.isEmpty() )
|
||||
{
|
||||
mGroupCombo.setModel( EMPTY_MODEL );
|
||||
}
|
||||
else
|
||||
{
|
||||
mGroupCombo.setModel( new DefaultComboBoxModel<String>(
|
||||
groupNames.toArray( new String[ groupNames.size() ] ) ) );;
|
||||
}
|
||||
|
||||
mGroupCombo.setSelectedItem( alias.getGroup() );
|
||||
|
||||
Color color = alias.getMapColor();
|
||||
|
||||
mButtonColor.setBackground( color );
|
||||
mButtonColor.setForeground( color );
|
||||
|
||||
String iconName = alias.getIconName();
|
||||
|
||||
if( iconName == null )
|
||||
{
|
||||
iconName = SettingsManager.DEFAULT_ICON;
|
||||
}
|
||||
|
||||
MapIcon savedIcon = mSettingsManager.getMapIcon( iconName );
|
||||
|
||||
if( savedIcon != null )
|
||||
{
|
||||
mMapIconCombo.setSelectedItem( savedIcon );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mListCombo.setModel( EMPTY_MODEL );
|
||||
mGroupCombo.setModel( EMPTY_MODEL );
|
||||
mName.setText( null );
|
||||
|
||||
mButtonColor.setBackground( getBackground() );
|
||||
mButtonColor.setForeground( getForeground() );
|
||||
}
|
||||
|
||||
repaint();
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e)
|
||||
{
|
||||
}
|
||||
});
|
||||
add(mName, "wrap");
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
if( hasItem() && isModified() )
|
||||
{
|
||||
Alias alias = getItem();
|
||||
|
||||
if( mListCombo.getSelectedItem() != null )
|
||||
{
|
||||
alias.setList( (String)mListCombo.getSelectedItem() );
|
||||
}
|
||||
|
||||
if( mGroupCombo.getSelectedItem() != null )
|
||||
{
|
||||
alias.setGroup( (String)mGroupCombo.getSelectedItem() );
|
||||
}
|
||||
add(new JLabel("List:"));
|
||||
mListCombo.setEditable(true);
|
||||
mListCombo.addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
if(mListCombo.getSelectedItem() != null)
|
||||
{
|
||||
List<String> groups = mAliasModel
|
||||
.getGroupNames((String) mListCombo.getSelectedItem());
|
||||
|
||||
alias.setName( mName.getText() );
|
||||
if(groups.isEmpty())
|
||||
{
|
||||
mGroupCombo.setModel(EMPTY_MODEL);
|
||||
}
|
||||
else
|
||||
{
|
||||
mGroupCombo.setModel(new DefaultComboBoxModel<String>(
|
||||
groups.toArray(new String[groups.size()])));
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
alias.setColor( mButtonColor.getBackground().getRGB() );
|
||||
setModified(true);
|
||||
}
|
||||
});
|
||||
add(mListCombo, "wrap");
|
||||
|
||||
if( mMapIconCombo.getSelectedItem() != null )
|
||||
{
|
||||
alias.setIconName( ((MapIcon)mMapIconCombo.getSelectedItem()).getName() );
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
add(new JLabel("Group:"));
|
||||
mGroupCombo.setEditable(true);
|
||||
mGroupCombo.addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
setModified(true);
|
||||
}
|
||||
});
|
||||
add(mGroupCombo, "wrap");
|
||||
|
||||
//Broadcast an alias change event to save the updates
|
||||
mAliasModel.broadcast( new AliasEvent( getItem(), Event.CHANGE ) );
|
||||
}
|
||||
}
|
||||
add(new JLabel("Color:"));
|
||||
|
||||
mButtonColor = new JButton("Select ...");
|
||||
mButtonColor.addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
Color newColor = JColorChooser.showDialog(
|
||||
AliasNameEditor.this,
|
||||
"Choose color for this alias",
|
||||
(hasItem() ? getItem().getMapColor() : null));
|
||||
|
||||
if(newColor != null)
|
||||
{
|
||||
mButtonColor.setForeground(newColor);
|
||||
mButtonColor.setBackground(newColor);
|
||||
|
||||
setModified(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
add(mButtonColor, "wrap");
|
||||
|
||||
add(new JLabel("Icon:"));
|
||||
|
||||
mIconCombo = new JComboBox<Icon>(mIconManager.getIcons());
|
||||
|
||||
IconListCellRenderer renderer = new IconListCellRenderer(mIconManager);
|
||||
renderer.setPreferredSize(new Dimension(200, 30));
|
||||
mIconCombo.setRenderer(renderer);
|
||||
mIconCombo.addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
setModified(true);
|
||||
}
|
||||
});
|
||||
|
||||
add(mIconCombo, "wrap");
|
||||
|
||||
//Dummy place holder
|
||||
add(new JLabel());
|
||||
|
||||
mBtnIconManager = new JButton("Icon Manager");
|
||||
mBtnIconManager.addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0)
|
||||
{
|
||||
mIconManager.showEditor(AliasNameEditor.this);
|
||||
}
|
||||
});
|
||||
|
||||
add(mBtnIconManager, "span 2,wrap");
|
||||
|
||||
setModified(false);
|
||||
}
|
||||
|
||||
private void refreshIcons()
|
||||
{
|
||||
if(mIconCombo != null)
|
||||
{
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
mIconCombo.setModel(new DefaultComboBoxModel<>(mIconManager.getIcons()));
|
||||
|
||||
if(hasItem())
|
||||
{
|
||||
String iconName = getItem().getIconName();
|
||||
Icon aliasIcon = mIconManager.getModel().getIcon(iconName);
|
||||
|
||||
if(aliasIcon != null)
|
||||
{
|
||||
mIconCombo.setSelectedItem(aliasIcon);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(Alias alias)
|
||||
{
|
||||
super.setItem(alias);
|
||||
|
||||
if(hasItem())
|
||||
{
|
||||
mName.setText(alias.getName());
|
||||
|
||||
mIconCombo.setModel(new DefaultComboBoxModel<>(mIconManager.getIcons()));
|
||||
|
||||
List<String> listNames = mAliasModel.getListNames();
|
||||
|
||||
if(listNames.isEmpty())
|
||||
{
|
||||
mListCombo.setModel(EMPTY_MODEL);
|
||||
}
|
||||
else
|
||||
{
|
||||
mListCombo.setModel(new DefaultComboBoxModel<String>(
|
||||
listNames.toArray(new String[listNames.size()])));
|
||||
;
|
||||
}
|
||||
|
||||
mListCombo.setSelectedItem(alias.getList());
|
||||
|
||||
List<String> groupNames = mAliasModel.getGroupNames(alias.getList());
|
||||
|
||||
if(groupNames.isEmpty())
|
||||
{
|
||||
mGroupCombo.setModel(EMPTY_MODEL);
|
||||
}
|
||||
else
|
||||
{
|
||||
mGroupCombo.setModel(new DefaultComboBoxModel<String>(
|
||||
groupNames.toArray(new String[groupNames.size()])));
|
||||
;
|
||||
}
|
||||
|
||||
mGroupCombo.setSelectedItem(alias.getGroup());
|
||||
|
||||
Color color = alias.getMapColor();
|
||||
|
||||
mButtonColor.setBackground(color);
|
||||
mButtonColor.setForeground(color);
|
||||
|
||||
String iconName = alias.getIconName();
|
||||
|
||||
if(iconName == null)
|
||||
{
|
||||
iconName = IconTableModel.DEFAULT_ICON;
|
||||
}
|
||||
|
||||
Icon savedIcon = mIconManager.getModel().getIcon(iconName);
|
||||
|
||||
if(savedIcon != null)
|
||||
{
|
||||
mIconCombo.setSelectedItem(savedIcon);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mListCombo.setModel(EMPTY_MODEL);
|
||||
mGroupCombo.setModel(EMPTY_MODEL);
|
||||
mName.setText(null);
|
||||
|
||||
mButtonColor.setBackground(getBackground());
|
||||
mButtonColor.setForeground(getForeground());
|
||||
}
|
||||
|
||||
repaint();
|
||||
|
||||
setModified(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
if(hasItem() && isModified())
|
||||
{
|
||||
Alias alias = getItem();
|
||||
|
||||
if(mListCombo.getSelectedItem() != null)
|
||||
{
|
||||
alias.setList((String) mListCombo.getSelectedItem());
|
||||
}
|
||||
|
||||
if(mGroupCombo.getSelectedItem() != null)
|
||||
{
|
||||
alias.setGroup((String) mGroupCombo.getSelectedItem());
|
||||
}
|
||||
|
||||
alias.setName(mName.getText());
|
||||
|
||||
alias.setColor(mButtonColor.getBackground().getRGB());
|
||||
|
||||
if(mIconCombo.getSelectedItem() != null)
|
||||
{
|
||||
alias.setIconName(((Icon) mIconCombo.getSelectedItem()).getName());
|
||||
}
|
||||
|
||||
setModified(false);
|
||||
|
||||
//Broadcast an alias change event to save the updates
|
||||
mAliasModel.broadcast(new AliasEvent(getItem(), Event.CHANGE));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,41 +1,28 @@
|
||||
package alias;
|
||||
|
||||
import alias.AliasEvent.Event;
|
||||
import alias.id.AliasIDType;
|
||||
import alias.id.broadcast.BroadcastChannel;
|
||||
import alias.id.priority.Priority;
|
||||
import audio.broadcast.BroadcastModel;
|
||||
import gui.editor.Editor;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JColorChooser;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
|
||||
import map.IconManager;
|
||||
import map.MapIcon;
|
||||
import map.MapIconListCellRenderer;
|
||||
import icon.Icon;
|
||||
import icon.IconListCellRenderer;
|
||||
import icon.IconManager;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import sample.Listener;
|
||||
import settings.SettingsManager;
|
||||
import alias.AliasEvent.Event;
|
||||
import alias.id.priority.Priority;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ChangeListener;
|
||||
import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.event.TableModelListener;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.List;
|
||||
|
||||
public class MultipleAliasEditor extends Editor<List<Alias>>
|
||||
implements Listener<AliasEvent>
|
||||
@@ -54,7 +41,7 @@ public class MultipleAliasEditor extends Editor<List<Alias>>
|
||||
private JCheckBox mGroupCheckBox = new JCheckBox("Group");
|
||||
private JComboBox<String> mGroupCombo = new JComboBox<>();
|
||||
private JCheckBox mIconCheckBox = new JCheckBox("Icon");
|
||||
private JComboBox<MapIcon> mMapIconCombo;
|
||||
private JComboBox<Icon> mIconCombo;
|
||||
private JCheckBox mColorCheckBox = new JCheckBox("Color");
|
||||
private JButton mButtonColor;
|
||||
private JButton mBtnIconManager;
|
||||
@@ -68,15 +55,23 @@ public class MultipleAliasEditor extends Editor<List<Alias>>
|
||||
|
||||
private AliasModel mAliasModel;
|
||||
private BroadcastModel mBroadcastModel;
|
||||
private SettingsManager mSettingsManager;
|
||||
private IconManager mIconManager;
|
||||
|
||||
public MultipleAliasEditor(AliasModel aliasModel, BroadcastModel broadcastModel, SettingsManager settingsManager)
|
||||
public MultipleAliasEditor(AliasModel aliasModel, BroadcastModel broadcastModel, IconManager iconManager)
|
||||
{
|
||||
mAliasModel = aliasModel;
|
||||
mBroadcastModel = broadcastModel;
|
||||
mSettingsManager = settingsManager;
|
||||
mIconManager = iconManager;
|
||||
|
||||
mAliasModel.addListener(this);
|
||||
mIconManager.getModel().addTableModelListener(new TableModelListener()
|
||||
{
|
||||
@Override
|
||||
public void tableChanged(TableModelEvent e)
|
||||
{
|
||||
refreshIcons();
|
||||
}
|
||||
});
|
||||
|
||||
init();
|
||||
}
|
||||
@@ -139,12 +134,12 @@ public class MultipleAliasEditor extends Editor<List<Alias>>
|
||||
|
||||
add(mIconCheckBox);
|
||||
|
||||
mMapIconCombo = new JComboBox<MapIcon>(mSettingsManager.getMapIcons());
|
||||
mIconCombo = new JComboBox<Icon>(mIconManager.getIcons());
|
||||
|
||||
MapIconListCellRenderer renderer = new MapIconListCellRenderer();
|
||||
IconListCellRenderer renderer = new IconListCellRenderer(mIconManager);
|
||||
renderer.setPreferredSize(new Dimension(200, 30));
|
||||
mMapIconCombo.setRenderer(renderer);
|
||||
add(mMapIconCombo, "wrap");
|
||||
mIconCombo.setRenderer(renderer);
|
||||
add(mIconCombo, "wrap");
|
||||
|
||||
//Dummy place holder
|
||||
add(new JLabel());
|
||||
@@ -155,17 +150,7 @@ public class MultipleAliasEditor extends Editor<List<Alias>>
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0)
|
||||
{
|
||||
final IconManager iconManager =
|
||||
new IconManager(mSettingsManager, MultipleAliasEditor.this);
|
||||
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
iconManager.setVisible(true);
|
||||
}
|
||||
});
|
||||
mIconManager.showEditor(MultipleAliasEditor.this);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -243,6 +228,21 @@ public class MultipleAliasEditor extends Editor<List<Alias>>
|
||||
setModified(false);
|
||||
}
|
||||
|
||||
private void refreshIcons()
|
||||
{
|
||||
if(mIconCombo != null)
|
||||
{
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
mIconCombo.setModel(new DefaultComboBoxModel<>(mIconManager.getIcons()));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItem(List<Alias> item)
|
||||
{
|
||||
@@ -277,6 +277,8 @@ public class MultipleAliasEditor extends Editor<List<Alias>>
|
||||
List<String> streamNames = mBroadcastModel.getBroadcastConfigurationNames();
|
||||
mStreamCombo.setModel(new DefaultComboBoxModel<String>(streamNames.toArray(new String[streamNames.size()])));
|
||||
|
||||
mIconCombo.setModel(new DefaultComboBoxModel<>(mIconManager.getIcons()));
|
||||
|
||||
setCheckBoxesUnselected();
|
||||
|
||||
setModified(false);
|
||||
@@ -363,9 +365,9 @@ public class MultipleAliasEditor extends Editor<List<Alias>>
|
||||
|
||||
if (mIconCheckBox.isSelected())
|
||||
{
|
||||
if (mMapIconCombo.getSelectedItem() != null)
|
||||
if (mIconCombo.getSelectedItem() != null)
|
||||
{
|
||||
alias.setIconName(((MapIcon) mMapIconCombo.getSelectedItem()).getName());
|
||||
alias.setIconName(((Icon)mIconCombo.getSelectedItem()).getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -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 <http://www.gnu.org/licenses/>
|
||||
*
|
||||
******************************************************************************/
|
||||
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<AudioEvent>, SettingChangeListener
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class AudioChannelPanel extends JPanel
|
||||
implements Listener<AudioEvent>, 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<AudioMetadata>
|
||||
{
|
||||
@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<AudioMetadata>
|
||||
{
|
||||
@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)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 <http://www.gnu.org/licenses/>
|
||||
*
|
||||
******************************************************************************/
|
||||
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<AudioOutput> 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<AudioOutput> 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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 <http://www.gnu.org/licenses/>
|
||||
*
|
||||
******************************************************************************/
|
||||
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<AudioEvent>
|
||||
{
|
||||
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<BroadcastConfiguration>
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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<BroadcastConfiguration> getEditor(BroadcastConfiguration configuration,
|
||||
BroadcastModel broadcastModel,
|
||||
AliasModel aliasModel,
|
||||
SettingsManager settingsManager)
|
||||
IconManager iconManager)
|
||||
{
|
||||
Editor<BroadcastConfiguration> 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<BroadcastConfiguration>();
|
||||
|
||||
@@ -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<Audio
|
||||
private Map<String,BroadcastConfiguration> mBroadcastConfigurationMap = new HashMap<>();
|
||||
private Map<String,AudioBroadcaster> mBroadcasterMap = new HashMap<>();
|
||||
private ThreadPoolManager mThreadPoolManager;
|
||||
private SettingsManager mSettingsManager;
|
||||
private IconManager mIconManager;
|
||||
private StreamManager mStreamManager;
|
||||
private Broadcaster<BroadcastEvent> mBroadcastEventBroadcaster = new Broadcaster<>();
|
||||
|
||||
/**
|
||||
* Model for managing Broadcast configurations and any associated broadcaster instances.
|
||||
*/
|
||||
public BroadcastModel(ThreadPoolManager threadPoolManager, SettingsManager settingsManager)
|
||||
public BroadcastModel(ThreadPoolManager threadPoolManager, IconManager iconManager)
|
||||
{
|
||||
mThreadPoolManager = threadPoolManager;
|
||||
mSettingsManager = settingsManager;
|
||||
mIconManager = iconManager;
|
||||
mStreamManager = new StreamManager(threadPoolManager, new CompletedRecordingListener(), BroadcastFormat.MP3,
|
||||
SystemProperties.getInstance().getApplicationFolder(TEMPORARY_STREAM_DIRECTORY));
|
||||
mStreamManager.start();
|
||||
@@ -497,11 +497,11 @@ public class BroadcastModel extends AbstractTableModel implements Listener<Audio
|
||||
switch(columnIndex)
|
||||
{
|
||||
case COLUMN_SERVER_ICON:
|
||||
String iconName = configuration.getBroadcastServerType().getIconName();
|
||||
String iconPath = configuration.getBroadcastServerType().getIconPath();
|
||||
|
||||
if(iconName != null && mSettingsManager != null)
|
||||
if(iconPath != null && mIconManager != null)
|
||||
{
|
||||
return mSettingsManager.getImageIcon(iconName, 14);
|
||||
return mIconManager.getScaledIcon(new ImageIcon(iconPath), 14);
|
||||
}
|
||||
break;
|
||||
case COLUMN_STREAM_NAME:
|
||||
|
||||
@@ -22,19 +22,16 @@ import alias.AliasModel;
|
||||
import com.jidesoft.swing.JideSplitPane;
|
||||
import gui.editor.Editor;
|
||||
import gui.editor.EmptyEditor;
|
||||
import icon.IconManager;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import settings.SettingsManager;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.event.TableColumnModelEvent;
|
||||
import javax.swing.event.TableColumnModelListener;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
@@ -51,7 +48,7 @@ public class BroadcastPanel extends JPanel implements ActionListener, ListSelect
|
||||
|
||||
private BroadcastModel mBroadcastModel;
|
||||
private AliasModel mAliasModel;
|
||||
private SettingsManager mSettingsManager;
|
||||
private IconManager mIconManager;
|
||||
|
||||
private JTable mBroadcastConfigurationTable;
|
||||
private JideSplitPane mSplitPane;
|
||||
@@ -61,11 +58,11 @@ public class BroadcastPanel extends JPanel implements ActionListener, ListSelect
|
||||
private JButton mCopyButton = new JButton(COPY_BROADCAST_CONFIGURATION);
|
||||
private JButton mDeleteButton = new JButton(DELETE_BROADCAST_CONFIGURATION);
|
||||
|
||||
public BroadcastPanel(BroadcastModel broadcastModel, AliasModel aliasModel, SettingsManager settingManager)
|
||||
public BroadcastPanel(BroadcastModel broadcastModel, AliasModel aliasModel, IconManager iconManager)
|
||||
{
|
||||
mBroadcastModel = broadcastModel;
|
||||
mAliasModel = aliasModel;
|
||||
mSettingsManager = settingManager;
|
||||
mIconManager = iconManager;
|
||||
mEditor = mEmptyEditor;
|
||||
|
||||
init();
|
||||
@@ -218,7 +215,7 @@ public class BroadcastPanel extends JPanel implements ActionListener, ListSelect
|
||||
if (selectedConfiguration != null)
|
||||
{
|
||||
mEditor = BroadcastFactory.getEditor(selectedConfiguration, mBroadcastModel, mAliasModel,
|
||||
mSettingsManager);
|
||||
mIconManager);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -239,7 +236,7 @@ public class BroadcastPanel extends JPanel implements ActionListener, ListSelect
|
||||
|
||||
public AddBroadcastConfigurationItem(BroadcastServerType type)
|
||||
{
|
||||
super(type.toString(), mSettingsManager.getImageIcon(type.getIconName(), 14));
|
||||
super(type.toString(), mIconManager.getScaledIcon(new ImageIcon(type.getIconPath()), 14));
|
||||
|
||||
mBroadcastServerType = type;
|
||||
|
||||
|
||||
@@ -28,12 +28,12 @@ public enum BroadcastServerType
|
||||
UNKNOWN("Unknown", null);
|
||||
|
||||
private String mLabel;
|
||||
private String mIconName;
|
||||
private String mIconPath;
|
||||
|
||||
BroadcastServerType(String label, String iconName)
|
||||
BroadcastServerType(String label, String iconPath)
|
||||
{
|
||||
mLabel = label;
|
||||
mIconName = iconName;
|
||||
mIconPath = iconPath;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
@@ -41,8 +41,8 @@ public enum BroadcastServerType
|
||||
return mLabel;
|
||||
}
|
||||
|
||||
public String getIconName()
|
||||
public String getIconPath()
|
||||
{
|
||||
return mIconName;
|
||||
return mIconPath;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,12 +25,11 @@ import audio.broadcast.BroadcastEvent;
|
||||
import audio.broadcast.BroadcastModel;
|
||||
import audio.broadcast.BroadcastServerType;
|
||||
import com.radioreference.api.soap2.UserFeedBroadcast;
|
||||
import gui.editor.DocumentListenerEditor;
|
||||
import icon.IconManager;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import sample.Listener;
|
||||
import settings.SettingsManager;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
@@ -41,7 +40,7 @@ import java.awt.event.ActionListener;
|
||||
|
||||
public class BroadcastifyConfigurationEditor extends BroadcastConfigurationEditor implements Listener<UserFeedBroadcast>
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger( BroadcastifyConfigurationEditor.class );
|
||||
private final static Logger mLog = LoggerFactory.getLogger(BroadcastifyConfigurationEditor.class);
|
||||
|
||||
private static final int ONE_MINUTE_MS = 60000;
|
||||
|
||||
@@ -57,24 +56,24 @@ public class BroadcastifyConfigurationEditor extends BroadcastConfigurationEdito
|
||||
private JButton mSaveButton;
|
||||
private JButton mResetButton;
|
||||
|
||||
public BroadcastifyConfigurationEditor(BroadcastModel broadcastModel, AliasModel aliasModel,
|
||||
SettingsManager settingsManager)
|
||||
public BroadcastifyConfigurationEditor(BroadcastModel broadcastModel, AliasModel aliasModel, IconManager iconManager)
|
||||
{
|
||||
super(broadcastModel, aliasModel, settingsManager);
|
||||
super(broadcastModel, aliasModel, iconManager);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[align right][grow,fill]",
|
||||
"[][][][][][][][][][][][][grow,fill]" ) );
|
||||
setPreferredSize(new Dimension(150,400));
|
||||
setLayout(new MigLayout("fill,wrap 2", "[align right][grow,fill]",
|
||||
"[][][][][][][][][][][][][grow,fill]"));
|
||||
setPreferredSize(new Dimension(150, 400));
|
||||
|
||||
|
||||
JLabel channelLabel = new JLabel("Broadcastify Stream");
|
||||
|
||||
ImageIcon broadcastifyIcon = mSettingsManager.getImageIcon(BroadcastServerType.BROADCASTIFY.getIconName(), 25);
|
||||
ImageIcon broadcastifyIcon = mIconManager.getScaledIcon(
|
||||
new ImageIcon(BroadcastServerType.BROADCASTIFY.getIconPath()), 25);
|
||||
channelLabel.setIcon(broadcastifyIcon);
|
||||
add(channelLabel, "span, align center");
|
||||
|
||||
@@ -143,7 +142,7 @@ public class BroadcastifyConfigurationEditor extends BroadcastConfigurationEdito
|
||||
add(mDelayValue);
|
||||
|
||||
add(new JLabel("Delay:"));
|
||||
mDelay = new JSlider(0,60,0);
|
||||
mDelay = new JSlider(0, 60, 0);
|
||||
mDelay.setMajorTickSpacing(10);
|
||||
mDelay.setMinorTickSpacing(5);
|
||||
mDelay.addChangeListener(new ChangeListener()
|
||||
@@ -215,7 +214,7 @@ public class BroadcastifyConfigurationEditor extends BroadcastConfigurationEdito
|
||||
|
||||
if(hasItem())
|
||||
{
|
||||
BroadcastifyConfiguration config = (BroadcastifyConfiguration)getItem();
|
||||
BroadcastifyConfiguration config = (BroadcastifyConfiguration) getItem();
|
||||
|
||||
mName.setText(config.getName());
|
||||
mServer.setText(config.getHost());
|
||||
@@ -223,7 +222,7 @@ public class BroadcastifyConfigurationEditor extends BroadcastConfigurationEdito
|
||||
mMountPoint.setText(config.getMountPoint());
|
||||
mPassword.setText(config.getPassword());
|
||||
mFeedID.setText(String.valueOf(config.getFeedID()));
|
||||
mDelay.setValue((int)(config.getDelay() / ONE_MINUTE_MS));
|
||||
mDelay.setValue((int) (config.getDelay() / ONE_MINUTE_MS));
|
||||
mEnabled.setSelected(config.isEnabled());
|
||||
}
|
||||
else
|
||||
@@ -244,7 +243,7 @@ public class BroadcastifyConfigurationEditor extends BroadcastConfigurationEdito
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
BroadcastifyConfiguration config = (BroadcastifyConfiguration)getItem();
|
||||
BroadcastifyConfiguration config = (BroadcastifyConfiguration) getItem();
|
||||
|
||||
if(validateConfiguration())
|
||||
{
|
||||
@@ -274,11 +273,11 @@ public class BroadcastifyConfigurationEditor extends BroadcastConfigurationEdito
|
||||
if(!mBroadcastModel.isUniqueName(name, getItem()))
|
||||
{
|
||||
String message = (name == null || name.isEmpty()) ?
|
||||
"Please specify a stream name." : "Stream name " + name +
|
||||
"is already in use.\nPlease choose another name.";
|
||||
"Please specify a stream name." : "Stream name " + name +
|
||||
"is already in use.\nPlease choose another name.";
|
||||
|
||||
JOptionPane.showMessageDialog(BroadcastifyConfigurationEditor.this,
|
||||
message, "Invalid Stream Name", JOptionPane.ERROR_MESSAGE);
|
||||
message, "Invalid Stream Name", JOptionPane.ERROR_MESSAGE);
|
||||
|
||||
mName.requestFocus();
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import audio.broadcast.BroadcastConfigurationEditor;
|
||||
import audio.broadcast.BroadcastEvent;
|
||||
import audio.broadcast.BroadcastModel;
|
||||
import audio.broadcast.BroadcastServerType;
|
||||
import icon.IconManager;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -57,10 +58,9 @@ public class IcecastHTTPConfigurationEditor extends BroadcastConfigurationEditor
|
||||
private JButton mSaveButton;
|
||||
private JButton mResetButton;
|
||||
|
||||
public IcecastHTTPConfigurationEditor(BroadcastModel broadcastModel, AliasModel aliasModel,
|
||||
SettingsManager settingsManager)
|
||||
public IcecastHTTPConfigurationEditor(BroadcastModel broadcastModel, AliasModel aliasModel, IconManager iconManager)
|
||||
{
|
||||
super(broadcastModel, aliasModel, settingsManager);
|
||||
super(broadcastModel, aliasModel, iconManager);
|
||||
init();
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public class IcecastHTTPConfigurationEditor extends BroadcastConfigurationEditor
|
||||
|
||||
JLabel channelLabel = new JLabel("Icecast 2 (v2.4+) Stream");
|
||||
|
||||
ImageIcon icon = mSettingsManager.getImageIcon(BroadcastServerType.ICECAST_HTTP.getIconName(), 25);
|
||||
ImageIcon icon = mIconManager.getScaledIcon(new ImageIcon(BroadcastServerType.ICECAST_HTTP.getIconPath()), 25);
|
||||
channelLabel.setIcon(icon);
|
||||
|
||||
add(channelLabel, "span, align center");
|
||||
|
||||
@@ -24,8 +24,7 @@ import audio.broadcast.BroadcastConfigurationEditor;
|
||||
import audio.broadcast.BroadcastEvent;
|
||||
import audio.broadcast.BroadcastModel;
|
||||
import audio.broadcast.BroadcastServerType;
|
||||
import audio.broadcast.broadcastify.BroadcastifyConfiguration;
|
||||
import gui.editor.DocumentListenerEditor;
|
||||
import icon.IconManager;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -58,10 +57,9 @@ public class IcecastTCPConfigurationEditor extends BroadcastConfigurationEditor
|
||||
private JButton mSaveButton;
|
||||
private JButton mResetButton;
|
||||
|
||||
public IcecastTCPConfigurationEditor(BroadcastModel broadcastModel, AliasModel aliasModel,
|
||||
SettingsManager settingsManager)
|
||||
public IcecastTCPConfigurationEditor(BroadcastModel broadcastModel, AliasModel aliasModel, IconManager iconManager)
|
||||
{
|
||||
super(broadcastModel, aliasModel, settingsManager);
|
||||
super(broadcastModel, aliasModel, iconManager);
|
||||
init();
|
||||
}
|
||||
|
||||
@@ -73,7 +71,7 @@ public class IcecastTCPConfigurationEditor extends BroadcastConfigurationEditor
|
||||
|
||||
JLabel channelLabel = new JLabel("Icecast (v2.3) Stream");
|
||||
|
||||
ImageIcon icon = mSettingsManager.getImageIcon(BroadcastServerType.ICECAST_TCP.getIconName(), 25);
|
||||
ImageIcon icon = mIconManager.getScaledIcon(new ImageIcon(BroadcastServerType.ICECAST_TCP.getIconPath()), 25);
|
||||
channelLabel.setIcon(icon);
|
||||
|
||||
add(channelLabel, "span, align center");
|
||||
|
||||
@@ -24,10 +24,10 @@ import audio.broadcast.BroadcastConfigurationEditor;
|
||||
import audio.broadcast.BroadcastEvent;
|
||||
import audio.broadcast.BroadcastModel;
|
||||
import audio.broadcast.BroadcastServerType;
|
||||
import icon.IconManager;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import settings.SettingsManager;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
@@ -38,7 +38,7 @@ import java.awt.event.ActionListener;
|
||||
|
||||
public class ShoutcastV1ConfigurationEditor extends BroadcastConfigurationEditor
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger( ShoutcastV1ConfigurationEditor.class );
|
||||
private final static Logger mLog = LoggerFactory.getLogger(ShoutcastV1ConfigurationEditor.class);
|
||||
|
||||
private static final int ONE_MINUTE_MS = 60000;
|
||||
|
||||
@@ -55,22 +55,21 @@ public class ShoutcastV1ConfigurationEditor extends BroadcastConfigurationEditor
|
||||
private JButton mSaveButton;
|
||||
private JButton mResetButton;
|
||||
|
||||
public ShoutcastV1ConfigurationEditor(BroadcastModel broadcastModel, AliasModel aliasModel,
|
||||
SettingsManager settingsManager)
|
||||
public ShoutcastV1ConfigurationEditor(BroadcastModel broadcastModel, AliasModel aliasModel, IconManager iconManager)
|
||||
{
|
||||
super(broadcastModel, aliasModel, settingsManager);
|
||||
super(broadcastModel, aliasModel, iconManager);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[align right][grow,fill]",
|
||||
"[][][][][][][][][][][][][][grow,fill]" ) );
|
||||
setPreferredSize(new Dimension(150,400));
|
||||
setLayout(new MigLayout("fill,wrap 2", "[align right][grow,fill]",
|
||||
"[][][][][][][][][][][][][][grow,fill]"));
|
||||
setPreferredSize(new Dimension(150, 400));
|
||||
|
||||
JLabel channelLabel = new JLabel("Shoutcast (v1.x) Stream");
|
||||
|
||||
ImageIcon icon = mSettingsManager.getImageIcon(BroadcastServerType.SHOUTCAST_V1.getIconName(), 25);
|
||||
ImageIcon icon = mIconManager.getScaledIcon(new ImageIcon(BroadcastServerType.SHOUTCAST_V1.getIconPath()), 25);
|
||||
channelLabel.setIcon(icon);
|
||||
|
||||
add(channelLabel, "span, align center");
|
||||
@@ -129,7 +128,7 @@ public class ShoutcastV1ConfigurationEditor extends BroadcastConfigurationEditor
|
||||
add(mDelayValue);
|
||||
|
||||
add(new JLabel("Delay:"));
|
||||
mDelay = new JSlider(0,60,0);
|
||||
mDelay = new JSlider(0, 60, 0);
|
||||
mDelay.setMajorTickSpacing(10);
|
||||
mDelay.setMinorTickSpacing(5);
|
||||
mDelay.addChangeListener(new ChangeListener()
|
||||
@@ -201,7 +200,7 @@ public class ShoutcastV1ConfigurationEditor extends BroadcastConfigurationEditor
|
||||
|
||||
if(hasItem())
|
||||
{
|
||||
ShoutcastV1Configuration config = (ShoutcastV1Configuration)getItem();
|
||||
ShoutcastV1Configuration config = (ShoutcastV1Configuration) getItem();
|
||||
|
||||
mName.setText(config.getName());
|
||||
mServer.setText(config.getHost());
|
||||
@@ -210,7 +209,7 @@ public class ShoutcastV1ConfigurationEditor extends BroadcastConfigurationEditor
|
||||
mGenre.setText(config.getGenre());
|
||||
mDescription.setText(config.getDescription());
|
||||
mPublic.setSelected(config.isPublic());
|
||||
mDelay.setValue((int)(config.getDelay() / ONE_MINUTE_MS));
|
||||
mDelay.setValue((int) (config.getDelay() / ONE_MINUTE_MS));
|
||||
mEnabled.setSelected(config.isEnabled());
|
||||
}
|
||||
else
|
||||
@@ -232,7 +231,7 @@ public class ShoutcastV1ConfigurationEditor extends BroadcastConfigurationEditor
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
ShoutcastV1Configuration config = (ShoutcastV1Configuration)getItem();
|
||||
ShoutcastV1Configuration config = (ShoutcastV1Configuration) getItem();
|
||||
|
||||
if(validateConfiguration())
|
||||
{
|
||||
@@ -263,11 +262,11 @@ public class ShoutcastV1ConfigurationEditor extends BroadcastConfigurationEditor
|
||||
if(!mBroadcastModel.isUniqueName(name, getItem()))
|
||||
{
|
||||
String message = (name == null || name.isEmpty()) ?
|
||||
"Please specify a stream name." : "Stream name " + name +
|
||||
"is already in use.\nPlease choose another name.";
|
||||
"Please specify a stream name." : "Stream name " + name +
|
||||
"is already in use.\nPlease choose another name.";
|
||||
|
||||
JOptionPane.showMessageDialog(ShoutcastV1ConfigurationEditor.this,
|
||||
message, "Invalid Stream Name", JOptionPane.ERROR_MESSAGE);
|
||||
message, "Invalid Stream Name", JOptionPane.ERROR_MESSAGE);
|
||||
|
||||
mName.requestFocus();
|
||||
|
||||
|
||||
@@ -24,10 +24,10 @@ import audio.broadcast.BroadcastConfigurationEditor;
|
||||
import audio.broadcast.BroadcastEvent;
|
||||
import audio.broadcast.BroadcastModel;
|
||||
import audio.broadcast.BroadcastServerType;
|
||||
import icon.IconManager;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import settings.SettingsManager;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
@@ -38,7 +38,7 @@ import java.awt.event.ActionListener;
|
||||
|
||||
public class ShoutcastV2ConfigurationEditor extends BroadcastConfigurationEditor
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger( ShoutcastV2ConfigurationEditor.class );
|
||||
private final static Logger mLog = LoggerFactory.getLogger(ShoutcastV2ConfigurationEditor.class);
|
||||
|
||||
private static final int ONE_MINUTE_MS = 60000;
|
||||
|
||||
@@ -56,22 +56,21 @@ public class ShoutcastV2ConfigurationEditor extends BroadcastConfigurationEditor
|
||||
private JButton mSaveButton;
|
||||
private JButton mResetButton;
|
||||
|
||||
public ShoutcastV2ConfigurationEditor(BroadcastModel broadcastModel, AliasModel aliasModel,
|
||||
SettingsManager settingsManager)
|
||||
public ShoutcastV2ConfigurationEditor(BroadcastModel broadcastModel, AliasModel aliasModel, IconManager iconManager)
|
||||
{
|
||||
super(broadcastModel, aliasModel, settingsManager);
|
||||
super(broadcastModel, aliasModel, iconManager);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "fill,wrap 2", "[align right][grow,fill]",
|
||||
"[][][][][][][][][][][][][][grow,fill]" ) );
|
||||
setPreferredSize(new Dimension(150,400));
|
||||
setLayout(new MigLayout("fill,wrap 2", "[align right][grow,fill]",
|
||||
"[][][][][][][][][][][][][][grow,fill]"));
|
||||
setPreferredSize(new Dimension(150, 400));
|
||||
|
||||
JLabel channelLabel = new JLabel("Shoutcast (v2) Stream");
|
||||
|
||||
ImageIcon icon = mSettingsManager.getImageIcon(BroadcastServerType.SHOUTCAST_V2.getIconName(), 25);
|
||||
ImageIcon icon = mIconManager.getScaledIcon(new ImageIcon(BroadcastServerType.SHOUTCAST_V2.getIconPath()), 25);
|
||||
channelLabel.setIcon(icon);
|
||||
|
||||
add(channelLabel, "span, align center");
|
||||
@@ -136,7 +135,7 @@ public class ShoutcastV2ConfigurationEditor extends BroadcastConfigurationEditor
|
||||
add(mDelayValue);
|
||||
|
||||
add(new JLabel("Delay:"));
|
||||
mDelay = new JSlider(0,60,0);
|
||||
mDelay = new JSlider(0, 60, 0);
|
||||
mDelay.setMajorTickSpacing(10);
|
||||
mDelay.setMinorTickSpacing(5);
|
||||
mDelay.addChangeListener(new ChangeListener()
|
||||
@@ -208,7 +207,7 @@ public class ShoutcastV2ConfigurationEditor extends BroadcastConfigurationEditor
|
||||
|
||||
if(hasItem())
|
||||
{
|
||||
ShoutcastV2Configuration config = (ShoutcastV2Configuration)getItem();
|
||||
ShoutcastV2Configuration config = (ShoutcastV2Configuration) getItem();
|
||||
|
||||
mName.setText(config.getName());
|
||||
mServer.setText(config.getHost());
|
||||
@@ -218,7 +217,7 @@ public class ShoutcastV2ConfigurationEditor extends BroadcastConfigurationEditor
|
||||
mPassword.setText(config.getPassword());
|
||||
mGenre.setText(config.getGenre());
|
||||
mPublic.setSelected(config.isPublic());
|
||||
mDelay.setValue((int)(config.getDelay() / ONE_MINUTE_MS));
|
||||
mDelay.setValue((int) (config.getDelay() / ONE_MINUTE_MS));
|
||||
mEnabled.setSelected(config.isEnabled());
|
||||
}
|
||||
else
|
||||
@@ -241,7 +240,7 @@ public class ShoutcastV2ConfigurationEditor extends BroadcastConfigurationEditor
|
||||
@Override
|
||||
public void save()
|
||||
{
|
||||
ShoutcastV2Configuration config = (ShoutcastV2Configuration)getItem();
|
||||
ShoutcastV2Configuration config = (ShoutcastV2Configuration) getItem();
|
||||
|
||||
if(validateConfiguration())
|
||||
{
|
||||
@@ -273,11 +272,11 @@ public class ShoutcastV2ConfigurationEditor extends BroadcastConfigurationEditor
|
||||
if(!mBroadcastModel.isUniqueName(name, getItem()))
|
||||
{
|
||||
String message = (name == null || name.isEmpty()) ?
|
||||
"Please specify a stream name." : "Stream name " + name +
|
||||
"is already in use.\nPlease choose another name.";
|
||||
"Please specify a stream name." : "Stream name " + name +
|
||||
"is already in use.\nPlease choose another name.";
|
||||
|
||||
JOptionPane.showMessageDialog(ShoutcastV2ConfigurationEditor.this,
|
||||
message, "Invalid Stream Name", JOptionPane.ERROR_MESSAGE);
|
||||
message, "Invalid Stream Name", JOptionPane.ERROR_MESSAGE);
|
||||
|
||||
mName.requestFocus();
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import javax.swing.event.ChangeListener;
|
||||
|
||||
import audio.broadcast.BroadcastModel;
|
||||
import audio.broadcast.BroadcastPanel;
|
||||
import icon.IconManager;
|
||||
import map.MapPanel;
|
||||
import map.MapService;
|
||||
import module.decode.event.CallEventPanel;
|
||||
@@ -78,6 +79,7 @@ public class ControllerPanel extends JPanel
|
||||
ChannelModel channelModel,
|
||||
ChannelMapModel channelMapModel,
|
||||
ChannelProcessingManager channelProcessingManager,
|
||||
IconManager iconManager,
|
||||
MapService mapService,
|
||||
SettingsManager settingsManager,
|
||||
SourceManager sourceManager,
|
||||
@@ -85,27 +87,26 @@ public class ControllerPanel extends JPanel
|
||||
{
|
||||
mChannelModel = channelModel;
|
||||
|
||||
mAudioPanel = new AudioPanel(settingsManager, sourceManager, audioManager);
|
||||
mAudioPanel = new AudioPanel(iconManager, settingsManager, sourceManager, audioManager);
|
||||
|
||||
mMapPanel = new MapPanel(mapService, settingsManager);
|
||||
mMapPanel = new MapPanel(mapService, iconManager, settingsManager);
|
||||
|
||||
mMessageActivityPanel = new MessageActivityPanel(channelProcessingManager);
|
||||
|
||||
mBroadcastPanel = new BroadcastPanel(broadcastModel, aliasModel, settingsManager);
|
||||
mBroadcastPanel = new BroadcastPanel(broadcastModel, aliasModel, iconManager);
|
||||
|
||||
mCallEventPanel = new CallEventPanel(settingsManager, channelProcessingManager);
|
||||
mCallEventPanel = new CallEventPanel(iconManager, channelProcessingManager);
|
||||
|
||||
mChannelSpectrumPanel = new ChannelSpectrumPanel(settingsManager,
|
||||
channelProcessingManager);
|
||||
|
||||
mChannelStateList = new ChannelList(channelModel, channelProcessingManager,
|
||||
mChannelStateList = new ChannelList(channelModel, channelProcessingManager, iconManager,
|
||||
settingsManager, mAudioPanel);
|
||||
|
||||
mChannelController = new ChannelController(channelModel, channelMapModel,
|
||||
sourceManager, aliasModel);
|
||||
|
||||
mAliasController = new AliasController(aliasModel, broadcastModel, settingsManager);
|
||||
|
||||
mAliasController = new AliasController(aliasModel, broadcastModel, iconManager);
|
||||
mTunerManagerPanel = new TunerViewPanel(tunerModel);
|
||||
|
||||
init();
|
||||
|
||||
@@ -30,7 +30,7 @@ import controller.channel.ChannelModel;
|
||||
import controller.channel.ChannelProcessingManager;
|
||||
import controller.channel.ChannelSelectionManager;
|
||||
import controller.channel.map.ChannelMapModel;
|
||||
import map.IconManager;
|
||||
import icon.IconManager;
|
||||
import map.MapService;
|
||||
import module.log.EventLogManager;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
@@ -66,6 +66,7 @@ public class SDRTrunk implements Listener<TunerEvent>
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger(SDRTrunk.class);
|
||||
|
||||
private IconManager mIconManager;
|
||||
private ControllerPanel mControllerPanel;
|
||||
private SettingsManager mSettingsManager;
|
||||
private SpectralDisplayPanel mSpectralPanel;
|
||||
@@ -105,6 +106,8 @@ public class SDRTrunk implements Listener<TunerEvent>
|
||||
|
||||
ThreadPoolManager threadPoolManager = new ThreadPoolManager();
|
||||
|
||||
mIconManager = new IconManager(threadPoolManager);
|
||||
|
||||
mSettingsManager = new SettingsManager(threadPoolManager, tunerConfigurationModel);
|
||||
|
||||
AliasModel aliasModel = new AliasModel();
|
||||
@@ -136,15 +139,15 @@ public class SDRTrunk implements Listener<TunerEvent>
|
||||
AudioManager audioManager = new AudioManager(threadPoolManager, sourceManager.getMixerManager());
|
||||
channelProcessingManager.addAudioPacketListener(audioManager);
|
||||
|
||||
BroadcastModel broadcastModel = new BroadcastModel(threadPoolManager, mSettingsManager);
|
||||
BroadcastModel broadcastModel = new BroadcastModel(threadPoolManager, mIconManager);
|
||||
|
||||
channelProcessingManager.addAudioPacketListener(broadcastModel);
|
||||
|
||||
MapService mapService = new MapService(mSettingsManager);
|
||||
MapService mapService = new MapService(mIconManager);
|
||||
channelProcessingManager.addMessageListener(mapService);
|
||||
|
||||
mControllerPanel = new ControllerPanel(audioManager, aliasModel, broadcastModel,
|
||||
channelModel, channelMapModel, channelProcessingManager,
|
||||
channelModel, channelMapModel, channelProcessingManager, mIconManager,
|
||||
mapService, mSettingsManager, sourceManager, tunerModel);
|
||||
|
||||
mSpectralPanel = new SpectralDisplayPanel(channelModel,
|
||||
@@ -268,16 +271,7 @@ public class SDRTrunk implements Listener<TunerEvent>
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent arg0)
|
||||
{
|
||||
final IconManager iconManager = new IconManager(mSettingsManager, mMainGui);
|
||||
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
iconManager.setVisible(true);
|
||||
}
|
||||
});
|
||||
mIconManager.showEditor(mMainGui);
|
||||
}
|
||||
});
|
||||
fileMenu.add(settingsMenu);
|
||||
|
||||
@@ -1,131 +1,148 @@
|
||||
/*******************************************************************************
|
||||
* 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 gui.editor;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.*;
|
||||
|
||||
/**
|
||||
* Generic editor with change detection, save and reset functions.
|
||||
*
|
||||
*
|
||||
* This editor supports hierarchical nesting of sub-component editors where changes are detected
|
||||
* at the lowest editor in the tree and percolated up to the top-level editor for managing the
|
||||
* configuration set as a whole.
|
||||
*
|
||||
* at the lowest editor in the tree and percolated up to the top-level editor for managing the
|
||||
* configuration set as a whole.
|
||||
*
|
||||
* To configure this editor as a collective, register each parent editor as a saveRequestListener
|
||||
* on each child editor. If no save request listener is registered, the editor will simply invoke
|
||||
* save when a change is detected and the user opts to save the contents.
|
||||
*
|
||||
*
|
||||
* The top-level editor can override the saveRequest() method to perform custom save operations
|
||||
* and validation.
|
||||
*/
|
||||
public abstract class Editor<T> extends JPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
protected T mItem;
|
||||
protected boolean mModified = false;
|
||||
protected Editor<?> mSaveRequestListener;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public Editor()
|
||||
{
|
||||
}
|
||||
protected T mItem;
|
||||
protected boolean mModified = false;
|
||||
protected Editor<?> mSaveRequestListener;
|
||||
|
||||
/**
|
||||
* Requests to save the contents of this editor.
|
||||
*
|
||||
* If a save request listener is registered, the listener is notified that a save is requested,
|
||||
* otherwise the save is request is processed by the instance.
|
||||
*
|
||||
* This allows for a save event to be percolated up the hierarchical set of editors so that
|
||||
* a top-level editor can invoke custom operations such as configuration validation.
|
||||
*/
|
||||
protected void saveRequest()
|
||||
{
|
||||
if( mSaveRequestListener != null )
|
||||
{
|
||||
mSaveRequestListener.saveRequest();
|
||||
}
|
||||
else
|
||||
{
|
||||
save();
|
||||
}
|
||||
}
|
||||
public Editor()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the editor to be notified when this editor contents have been saved.
|
||||
*/
|
||||
public void setSaveRequestListener( Editor<?> listener )
|
||||
{
|
||||
mSaveRequestListener = listener;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the object to be edited. If the contents from the previous object have changed, this
|
||||
* prompts the user to save these changes. A saveRequest() is issued and either this editor
|
||||
* or the parent editor will respond to the save request and invoke the save() method.
|
||||
*/
|
||||
public void setItem( T item )
|
||||
{
|
||||
if( isModified() )
|
||||
{
|
||||
int option = JOptionPane.showConfirmDialog(
|
||||
Editor.this,
|
||||
"This item has changed. Do you want to save these changes?",
|
||||
"Save Changes?",
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE );
|
||||
|
||||
if( option == JOptionPane.YES_OPTION )
|
||||
{
|
||||
saveRequest();
|
||||
}
|
||||
|
||||
setModified( false );
|
||||
}
|
||||
|
||||
mItem = item;
|
||||
}
|
||||
/**
|
||||
* Requests to save the contents of this editor.
|
||||
*
|
||||
* If a save request listener is registered, the listener is notified that a save is requested,
|
||||
* otherwise the save is request is processed by the instance.
|
||||
*
|
||||
* This allows for a save event to be percolated up the hierarchical set of editors so that
|
||||
* a top-level editor can invoke custom operations such as configuration validation.
|
||||
*/
|
||||
protected void saveRequest()
|
||||
{
|
||||
if(mSaveRequestListener != null)
|
||||
{
|
||||
mSaveRequestListener.saveRequest();
|
||||
}
|
||||
else
|
||||
{
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Current editing item
|
||||
*/
|
||||
public T getItem()
|
||||
{
|
||||
return mItem;
|
||||
}
|
||||
|
||||
public boolean hasItem()
|
||||
{
|
||||
return mItem != null;
|
||||
}
|
||||
/**
|
||||
* Registers the editor to be notified when this editor contents have been saved.
|
||||
*/
|
||||
public void setSaveRequestListener(Editor<?> listener)
|
||||
{
|
||||
mSaveRequestListener = listener;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the contents modified flag
|
||||
*/
|
||||
public void setModified( boolean modified )
|
||||
{
|
||||
mModified = modified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this editor contents have been modified
|
||||
*/
|
||||
public boolean isModified()
|
||||
{
|
||||
return mModified;
|
||||
}
|
||||
/**
|
||||
* Sets the object to be edited. If the contents from the previous object have changed, this
|
||||
* prompts the user to save these changes. A saveRequest() is issued and either this editor
|
||||
* or the parent editor will respond to the save request and invoke the save() method.
|
||||
*/
|
||||
public void setItem(T item)
|
||||
{
|
||||
if(isModified())
|
||||
{
|
||||
int option = JOptionPane.showConfirmDialog(
|
||||
Editor.this,
|
||||
"This item has changed. Do you want to save these changes?",
|
||||
"Save Changes?",
|
||||
JOptionPane.YES_NO_OPTION,
|
||||
JOptionPane.QUESTION_MESSAGE);
|
||||
|
||||
/**
|
||||
* Save the contents of the editor
|
||||
*/
|
||||
public abstract void save();
|
||||
if(option == JOptionPane.YES_OPTION)
|
||||
{
|
||||
saveRequest();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the contents of the editor without saving any changes
|
||||
*/
|
||||
public void reset()
|
||||
{
|
||||
mModified = false;
|
||||
setItem( mItem );
|
||||
}
|
||||
setModified(false);
|
||||
}
|
||||
|
||||
mItem = item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Current editing item
|
||||
*/
|
||||
public T getItem()
|
||||
{
|
||||
return mItem;
|
||||
}
|
||||
|
||||
public boolean hasItem()
|
||||
{
|
||||
return mItem != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the contents modified flag
|
||||
*/
|
||||
public void setModified(boolean modified)
|
||||
{
|
||||
mModified = modified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this editor contents have been modified
|
||||
*/
|
||||
public boolean isModified()
|
||||
{
|
||||
return mModified;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save the contents of the editor
|
||||
*/
|
||||
public abstract void save();
|
||||
|
||||
/**
|
||||
* Reset the contents of the editor without saving any changes
|
||||
*/
|
||||
public void reset()
|
||||
{
|
||||
mModified = false;
|
||||
setItem(mItem);
|
||||
}
|
||||
}
|
||||
|
||||
99
src/icon/Icon.java
Normal file
99
src/icon/Icon.java
Normal file
@@ -0,0 +1,99 @@
|
||||
/*******************************************************************************
|
||||
* 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 icon;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
@XmlRootElement(name = "icon")
|
||||
public class Icon implements Comparable<Icon>
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger(Icon.class);
|
||||
|
||||
protected String mName;
|
||||
private String mPath;
|
||||
private ImageIcon mImageIcon;
|
||||
|
||||
public Icon()
|
||||
{
|
||||
//No-arg JAXB constructor
|
||||
}
|
||||
|
||||
public Icon(String name, String path)
|
||||
{
|
||||
mName = name;
|
||||
mPath = path;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "name")
|
||||
public String getName()
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
|
||||
public void setName(String name)
|
||||
{
|
||||
mName = name;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
return mName;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "path")
|
||||
public String getPath()
|
||||
{
|
||||
return mPath;
|
||||
}
|
||||
|
||||
public void setPath(String path)
|
||||
{
|
||||
mPath = path;
|
||||
}
|
||||
|
||||
@XmlTransient
|
||||
public ImageIcon getIcon()
|
||||
{
|
||||
if(mImageIcon == null && mPath != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
mImageIcon = new ImageIcon(mPath);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
mLog.error("Error loading Icon [" + mPath + "]", e);
|
||||
}
|
||||
}
|
||||
|
||||
return mImageIcon;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Icon otherIcon)
|
||||
{
|
||||
return getName().compareTo(otherIcon.getName());
|
||||
}
|
||||
}
|
||||
156
src/icon/IconEditor.java
Normal file
156
src/icon/IconEditor.java
Normal file
@@ -0,0 +1,156 @@
|
||||
/*******************************************************************************
|
||||
* 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 icon;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class IconEditor extends JFrame implements ActionListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Logger mLog = LoggerFactory.getLogger(IconEditor.class);
|
||||
private static final String ADD = "Add";
|
||||
private static final String DEFAULT = "Set Default";
|
||||
private static final String DELETE = "Delete";
|
||||
|
||||
private JButton mAddButton;
|
||||
private JButton mDeleteButton;
|
||||
private JButton mDefaultButton;
|
||||
private JTable mIconTable;
|
||||
private IconManager mIconManager;
|
||||
|
||||
public IconEditor(IconManager model)
|
||||
{
|
||||
mIconManager = model;
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setTitle("Icon Manager");
|
||||
setSize(400, 400);
|
||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
setLayout(new MigLayout("", "[grow,fill]", "[grow,fill]"));
|
||||
|
||||
/**
|
||||
* Editor Panel
|
||||
*/
|
||||
JPanel editorPanel = new JPanel();
|
||||
editorPanel.setLayout(new MigLayout("insets 1 1 1 1", "[grow,fill][grow,fill][grow,fill]", "[grow,fill][]"));
|
||||
|
||||
mIconTable = new JTable(mIconManager.getModel());
|
||||
IconTableCellRenderer renderer = new IconTableCellRenderer(mIconManager);
|
||||
mIconTable.getColumnModel().getColumn(IconTableModel.COLUMN_IMAGE_ICON).setCellRenderer(renderer);
|
||||
mIconTable.setAutoCreateRowSorter(true);
|
||||
mIconTable.getRowSorter().toggleSortOrder(IconTableModel.COLUMN_ICON_NAME);
|
||||
mIconTable.setRowHeight(36);
|
||||
mIconTable.getSelectionModel().addListSelectionListener(new ListSelectionListener()
|
||||
{
|
||||
@Override
|
||||
public void valueChanged(ListSelectionEvent e)
|
||||
{
|
||||
checkButtons();
|
||||
}
|
||||
});
|
||||
editorPanel.add(new JScrollPane(mIconTable), "span");
|
||||
|
||||
mAddButton = new JButton(ADD);
|
||||
mAddButton.addActionListener(this);
|
||||
editorPanel.add(mAddButton);
|
||||
|
||||
mDeleteButton = new JButton(DELETE);
|
||||
mDeleteButton.addActionListener(this);
|
||||
mDeleteButton.setEnabled(false);
|
||||
editorPanel.add(mDeleteButton);
|
||||
|
||||
mDefaultButton = new JButton(DEFAULT);
|
||||
mDefaultButton.addActionListener(this);
|
||||
mDefaultButton.setEnabled(false);
|
||||
editorPanel.add(mDefaultButton, "wrap");
|
||||
|
||||
add(editorPanel);
|
||||
}
|
||||
|
||||
private void checkButtons()
|
||||
{
|
||||
Icon selected = getSelectedIcon();
|
||||
|
||||
mDefaultButton.setEnabled(selected != null && selected != mIconManager.getModel().getDefaultIcon());
|
||||
mDeleteButton.setEnabled(selected != null && selected != mIconManager.getModel().getDefaultIcon());
|
||||
}
|
||||
|
||||
private Icon getSelectedIcon()
|
||||
{
|
||||
int selectedViewRow = mIconTable.getSelectedRow();
|
||||
|
||||
if(selectedViewRow >= 0)
|
||||
{
|
||||
int selectedModelRow = mIconTable.convertRowIndexToModel(mIconTable.getSelectedRow());
|
||||
|
||||
if(selectedModelRow >= 0)
|
||||
{
|
||||
return mIconManager.getModel().get(selectedModelRow);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
Icon selected = getSelectedIcon();
|
||||
|
||||
switch(e.getActionCommand())
|
||||
{
|
||||
case ADD:
|
||||
IconSelector iconSelector = new IconSelector(this, mIconManager.getModel());
|
||||
iconSelector.setVisible(true);
|
||||
break;
|
||||
case DELETE:
|
||||
if(selected != null)
|
||||
{
|
||||
int choice = JOptionPane.showConfirmDialog(IconEditor.this,
|
||||
"Are you sure you want to delete this icon?", "Delete Icon?", JOptionPane.YES_NO_OPTION);
|
||||
|
||||
if(choice == JOptionPane.YES_OPTION)
|
||||
{
|
||||
mIconManager.getModel().remove(selected);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DEFAULT:
|
||||
if(selected != null)
|
||||
{
|
||||
mIconManager.getModel().setDefaultIcon(selected);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
checkButtons();
|
||||
}
|
||||
}
|
||||
65
src/icon/IconListCellRenderer.java
Normal file
65
src/icon/IconListCellRenderer.java
Normal file
@@ -0,0 +1,65 @@
|
||||
/*******************************************************************************
|
||||
* 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 icon;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class IconListCellRenderer extends JLabel implements ListCellRenderer<Icon>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private IconManager mIconManager;
|
||||
|
||||
public IconListCellRenderer(IconManager iconManager)
|
||||
{
|
||||
mIconManager = iconManager;
|
||||
setOpaque(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<? extends Icon> list, Icon icon, int index,
|
||||
boolean isSelected, boolean cellHasFocus)
|
||||
{
|
||||
//Get a scaled version of the icon
|
||||
setIcon(mIconManager.getIcon(icon.getName(), 24));
|
||||
|
||||
if(mIconManager.getModel().isDefaultIcon(icon))
|
||||
{
|
||||
setText(icon.getName() + " (default)");
|
||||
}
|
||||
else
|
||||
{
|
||||
setText(icon.getName());
|
||||
}
|
||||
|
||||
if(isSelected)
|
||||
{
|
||||
setBackground(list.getSelectionBackground());
|
||||
setForeground(list.getSelectionForeground());
|
||||
}
|
||||
else
|
||||
{
|
||||
setBackground(list.getBackground());
|
||||
setForeground(list.getForeground());
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
432
src/icon/IconManager.java
Normal file
432
src/icon/IconManager.java
Normal file
@@ -0,0 +1,432 @@
|
||||
/*******************************************************************************
|
||||
* 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 icon;
|
||||
|
||||
import controller.ThreadPoolManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import properties.SystemProperties;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.ListDataEvent;
|
||||
import javax.swing.event.ListDataListener;
|
||||
import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.event.TableModelListener;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class IconManager
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger(IconManager.class);
|
||||
public static final int DEFAULT_ICON_SIZE = 12;
|
||||
|
||||
private Path mIconFolderPath;
|
||||
private Path mIconFilePath;
|
||||
private Path mIconBackupFilePath;
|
||||
private Path mIconLockFilePath;
|
||||
|
||||
private ThreadPoolManager mThreadPoolManager;
|
||||
private IconEditor mIconEditor;
|
||||
private IconTableModel mIconTableModel;
|
||||
private AtomicBoolean mSavingIcons = new AtomicBoolean();
|
||||
|
||||
private Map<String, ImageIcon> mResizedIcons = new HashMap<>();
|
||||
|
||||
public IconManager(ThreadPoolManager threadPoolManager)
|
||||
{
|
||||
mThreadPoolManager = threadPoolManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the icon editor centered over the specified component.
|
||||
*
|
||||
* @param centerOnComponent to center the editor
|
||||
*/
|
||||
public void showEditor(Component centerOnComponent)
|
||||
{
|
||||
if(mIconEditor == null)
|
||||
{
|
||||
mIconEditor = new IconEditor(this);
|
||||
}
|
||||
|
||||
mIconEditor.setLocationRelativeTo(centerOnComponent);
|
||||
|
||||
if(mIconEditor.isVisible())
|
||||
{
|
||||
mIconEditor.requestFocus();
|
||||
}
|
||||
else
|
||||
{
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
mIconEditor.setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public IconTableModel getModel()
|
||||
{
|
||||
if(mIconTableModel == null)
|
||||
{
|
||||
IconSet loadedIcons = load();
|
||||
|
||||
boolean saveRequired = false;
|
||||
|
||||
if(loadedIcons == null)
|
||||
{
|
||||
loadedIcons = getDefaultIconSet();
|
||||
saveRequired = true;
|
||||
}
|
||||
|
||||
mIconTableModel = new IconTableModel(loadedIcons);
|
||||
mIconTableModel.addTableModelListener(new TableModelListener()
|
||||
{
|
||||
@Override
|
||||
public void tableChanged(TableModelEvent e)
|
||||
{
|
||||
scheduleSave();
|
||||
}
|
||||
});
|
||||
|
||||
if(saveRequired)
|
||||
{
|
||||
scheduleSave();
|
||||
}
|
||||
}
|
||||
|
||||
return mIconTableModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* All icons in a sorted array
|
||||
*/
|
||||
public Icon[] getIcons()
|
||||
{
|
||||
return getModel().getIconsAsArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns named icon scaled to the specified height. Utilizes an internal map to retain scaled icons so that they
|
||||
* are only scaled/generated once.
|
||||
*
|
||||
* @param name - name of icon
|
||||
* @param height - height of icon in pixels
|
||||
* @return - scaled named icon (if it exists) or a scaled version of the default icon
|
||||
*/
|
||||
public ImageIcon getIcon(String name, int height)
|
||||
{
|
||||
if(name == null)
|
||||
{
|
||||
name = getModel().getDefaultIcon().getName();
|
||||
}
|
||||
|
||||
String scaledIconName = name + height;
|
||||
|
||||
if(mResizedIcons.containsKey(scaledIconName))
|
||||
{
|
||||
return mResizedIcons.get(scaledIconName);
|
||||
}
|
||||
|
||||
Icon icon = getModel().getIcon(name);
|
||||
|
||||
ImageIcon scaledIcon = getScaledIcon(icon.getIcon(), height);
|
||||
mResizedIcons.put(scaledIconName, scaledIcon);
|
||||
|
||||
return scaledIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scales the icon to the new pixel height value
|
||||
*
|
||||
* @param original image icon
|
||||
* @param height new height to scale the image (width will be scaled accordingly)
|
||||
* @return
|
||||
*/
|
||||
public static ImageIcon getScaledIcon(ImageIcon original, int height)
|
||||
{
|
||||
double scale = (double) original.getIconHeight() / (double) height;
|
||||
|
||||
int scaledWidth = (int) ((double) original.getIconWidth() / scale);
|
||||
|
||||
Image scaledImage = original.getImage().getScaledInstance(scaledWidth,
|
||||
height, java.awt.Image.SCALE_SMOOTH);
|
||||
|
||||
return new ImageIcon(scaledImage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Folder where icon, backup and lock files are stored
|
||||
*/
|
||||
private Path getIconFolderPath()
|
||||
{
|
||||
if(mIconFolderPath == null)
|
||||
{
|
||||
SystemProperties props = SystemProperties.getInstance();
|
||||
|
||||
mIconFolderPath = props.getApplicationFolder("settings");
|
||||
}
|
||||
|
||||
return mIconFolderPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Path to current icon file
|
||||
*/
|
||||
private Path getIconFilePath()
|
||||
{
|
||||
if(mIconFilePath == null)
|
||||
{
|
||||
mIconFilePath = getIconFolderPath().resolve("icons.xml");
|
||||
}
|
||||
|
||||
return mIconFilePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Path to most recent playlist backup
|
||||
*/
|
||||
private Path getIconBackupFilePath()
|
||||
{
|
||||
if(mIconBackupFilePath == null)
|
||||
{
|
||||
mIconBackupFilePath = getIconFolderPath().resolve("icons.backup");
|
||||
}
|
||||
|
||||
return mIconBackupFilePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Path to playlist lock file that is created prior to saving a playlist and removed immediately thereafter.
|
||||
* Presence of a lock file indicates an incomplete or corrupt playlist file on startup.
|
||||
*/
|
||||
private Path getIconLockFilePath()
|
||||
{
|
||||
if(mIconLockFilePath == null)
|
||||
{
|
||||
mIconLockFilePath = getIconFolderPath().resolve("icons.lock");
|
||||
}
|
||||
|
||||
return mIconLockFilePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the current playlist
|
||||
*/
|
||||
private void save()
|
||||
{
|
||||
IconSet iconSet = getModel().getIconSet();
|
||||
|
||||
JAXBContext context = null;
|
||||
|
||||
//Create a backup copy of the current playlist
|
||||
if(Files.exists(getIconFilePath()))
|
||||
{
|
||||
try
|
||||
{
|
||||
Files.copy(getIconFilePath(), getIconBackupFilePath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
mLog.error("Error creating backup copy of current icons prior to saving updates [" +
|
||||
getIconFilePath().toString() + "]", e);
|
||||
}
|
||||
}
|
||||
|
||||
//Create a temporary lock file to signify that we're in the process of updating the playlist
|
||||
if(!Files.exists(getIconLockFilePath()))
|
||||
{
|
||||
try
|
||||
{
|
||||
Files.createFile(getIconLockFilePath());
|
||||
}
|
||||
catch(IOException e)
|
||||
{
|
||||
mLog.error("Error creating temporary lock file prior to saving icons [" +
|
||||
getIconLockFilePath().toString() + "]", e);
|
||||
}
|
||||
}
|
||||
|
||||
try(OutputStream out = Files.newOutputStream(getIconFilePath()))
|
||||
{
|
||||
context = JAXBContext.newInstance(IconSet.class);
|
||||
|
||||
Marshaller m = context.createMarshaller();
|
||||
|
||||
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
|
||||
|
||||
m.marshal(iconSet, out);
|
||||
|
||||
out.flush();
|
||||
|
||||
//Remove the playlist lock file to indicate that we successfully saved the file
|
||||
if(Files.exists(getIconLockFilePath()))
|
||||
{
|
||||
Files.delete(getIconLockFilePath());
|
||||
}
|
||||
}
|
||||
catch(JAXBException je)
|
||||
{
|
||||
mLog.error("JAXB exception while serializing icons to a file [" + getIconFilePath().toString() + "]", je);
|
||||
}
|
||||
catch(IOException ioe)
|
||||
{
|
||||
mLog.error("IO error while writing icons to a file [" + getIconFilePath().toString() + "]", ioe);
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
mLog.error("Error while saving icons [" + getIconFilePath().toString() + "]", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads icons from file or creates a default set of icons
|
||||
*/
|
||||
public IconSet load()
|
||||
{
|
||||
mLog.info("loading icons file [" + getIconFilePath().toString() + "]");
|
||||
|
||||
IconSet iconSet = null;
|
||||
|
||||
//Check for a lock file that indicates the previous save attempt was incomplete or had an error
|
||||
if(Files.exists(getIconLockFilePath()))
|
||||
{
|
||||
try
|
||||
{
|
||||
//Remove the previous icons file
|
||||
Files.delete(getIconFilePath());
|
||||
|
||||
//Copy the backup file to restore the previous icons file
|
||||
if(Files.exists(getIconBackupFilePath()))
|
||||
{
|
||||
Files.copy(getIconBackupFilePath(), getIconFilePath());
|
||||
}
|
||||
|
||||
//Remove the lock file
|
||||
Files.delete(getIconLockFilePath());
|
||||
}
|
||||
catch(IOException ioe)
|
||||
{
|
||||
mLog.error("Previous icons save attempt was incomplete and there was an error restoring the " +
|
||||
"icons backup file", ioe);
|
||||
}
|
||||
}
|
||||
|
||||
if(Files.exists(getIconFilePath()))
|
||||
{
|
||||
JAXBContext context = null;
|
||||
|
||||
try(InputStream in = Files.newInputStream(getIconFilePath()))
|
||||
{
|
||||
context = JAXBContext.newInstance(IconSet.class);
|
||||
|
||||
Unmarshaller m = context.createUnmarshaller();
|
||||
|
||||
iconSet = (IconSet) m.unmarshal(in);
|
||||
}
|
||||
catch(JAXBException je)
|
||||
{
|
||||
mLog.error("JAXB exception while loading/unmarshalling icons", je);
|
||||
}
|
||||
catch(IOException ioe)
|
||||
{
|
||||
mLog.error("IO error while reading icons file", ioe);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mLog.info("Icons file not found at [" + getIconFilePath().toString() + "]");
|
||||
}
|
||||
|
||||
return iconSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a default icon set
|
||||
*/
|
||||
private IconSet getDefaultIconSet()
|
||||
{
|
||||
IconSet iconSet = new IconSet();
|
||||
|
||||
Icon defaultIcon = new Icon(IconTableModel.DEFAULT_ICON, "images/no_icon.png");
|
||||
iconSet.add(defaultIcon);
|
||||
iconSet.setDefaultIcon(defaultIcon.getName());
|
||||
|
||||
iconSet.add(new Icon("Ambulance", "images/ambulance.png"));
|
||||
iconSet.add(new Icon("Block Truck", "images/concrete_block_truck.png"));
|
||||
iconSet.add(new Icon("CWID", "images/cwid.png"));
|
||||
iconSet.add(new Icon("Dispatcher", "images/dispatcher.png"));
|
||||
iconSet.add(new Icon("Dump Truck", "images/dump_truck_red.png"));
|
||||
iconSet.add(new Icon("Fire Truck", "images/fire_truck.png"));
|
||||
iconSet.add(new Icon("Garbage Truck", "images/garbage_truck.png"));
|
||||
iconSet.add(new Icon("Loader", "images/loader.png"));
|
||||
iconSet.add(new Icon("Police", "images/police.png"));
|
||||
iconSet.add(new Icon("Propane Truck", "images/propane_truck.png"));
|
||||
iconSet.add(new Icon("Rescue Truck", "images/rescue_truck.png"));
|
||||
iconSet.add(new Icon("School Bus", "images/school_bus.png"));
|
||||
iconSet.add(new Icon("Taxi", "images/taxi.png"));
|
||||
iconSet.add(new Icon("Train", "images/train.png"));
|
||||
iconSet.add(new Icon("Transport Bus", "images/opt_bus.png"));
|
||||
iconSet.add(new Icon("Van", "images/van.png"));
|
||||
|
||||
return iconSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedules an icon file save task. Subsequent calls to this method will be ignored until the save event occurs,
|
||||
* thus limiting repetitive saving to a minimum.
|
||||
*/
|
||||
private void scheduleSave()
|
||||
{
|
||||
if(mSavingIcons.compareAndSet(false, true))
|
||||
{
|
||||
mThreadPoolManager.scheduleOnce(new IconSaveTask(), 2, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the playlist save pending flag to false and proceeds to save the playlist.
|
||||
*/
|
||||
public class IconSaveTask implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
save();
|
||||
|
||||
mSavingIcons.set(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
173
src/icon/IconSelector.java
Normal file
173
src/icon/IconSelector.java
Normal file
@@ -0,0 +1,173 @@
|
||||
/*******************************************************************************
|
||||
* 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 icon;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
|
||||
public class IconSelector extends JDialog implements DocumentListener
|
||||
{
|
||||
private IconTableModel mIconTableModel;
|
||||
private JTextField mNameText;
|
||||
private JTextField mFileLabel;
|
||||
private JButton mFileChooserButton;
|
||||
private JButton mOKButton;
|
||||
private JButton mCancelButton;
|
||||
|
||||
/**
|
||||
* Window for selecting an Icon to add to the Icon Model
|
||||
*
|
||||
* @param owner for this modal dialog
|
||||
* @param iconTableModel to receive the added/selected icon
|
||||
*/
|
||||
public IconSelector(Frame owner, IconTableModel iconTableModel)
|
||||
{
|
||||
super(owner, "Add Icon", true);
|
||||
|
||||
mIconTableModel = iconTableModel;
|
||||
|
||||
init();
|
||||
|
||||
setLocationRelativeTo(owner);
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
setSize(250, 170);
|
||||
|
||||
JPanel contentPanel = new JPanel();
|
||||
contentPanel.setPreferredSize(new Dimension(250, 170));
|
||||
contentPanel.setLayout(new MigLayout("insets 1 1 1 1", "[align right][align left,grow,fill]", "[][][][grow,fill][]"));
|
||||
|
||||
contentPanel.add(new JLabel("Name"));
|
||||
|
||||
mNameText = new JTextField();
|
||||
mNameText.getDocument().addDocumentListener(this);
|
||||
contentPanel.add(mNameText, "wrap");
|
||||
|
||||
contentPanel.add(new JLabel("File"));
|
||||
|
||||
mFileLabel = new JTextField();
|
||||
mFileLabel.setEnabled(false);
|
||||
contentPanel.add(mFileLabel, "wrap");
|
||||
|
||||
mFileChooserButton = new JButton("Select File ...");
|
||||
mFileChooserButton.addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
JFileChooser fileChooser = new JFileChooser();
|
||||
|
||||
// fileChooser.setSelectedFile(null);
|
||||
|
||||
//Add a custom file filter and disable the default
|
||||
fileChooser.addChoosableFileFilter(new ImageFilter());
|
||||
fileChooser.setAcceptAllFileFilterUsed(false);
|
||||
|
||||
int returnVal = fileChooser.showDialog(IconSelector.this, "Select");
|
||||
|
||||
if(returnVal == JFileChooser.APPROVE_OPTION)
|
||||
{
|
||||
File file = fileChooser.getSelectedFile();
|
||||
|
||||
if(file != null)
|
||||
{
|
||||
mFileLabel.setText(file.getAbsolutePath());
|
||||
checkButtons();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
contentPanel.add(mFileChooserButton, "span,align center");
|
||||
|
||||
contentPanel.add(new JLabel(), "wrap");
|
||||
|
||||
JPanel buttonPanel = new JPanel();
|
||||
buttonPanel.setLayout(new MigLayout("", "[grow,fill][grow,fill]", "[]"));
|
||||
|
||||
mOKButton = new JButton("OK");
|
||||
mOKButton.setEnabled(false);
|
||||
mOKButton.addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
String name = mNameText.getText();
|
||||
String path = mFileLabel.getText();
|
||||
|
||||
Icon icon = new Icon(name, path);
|
||||
mIconTableModel.add(icon);
|
||||
|
||||
IconSelector.this.dispose();
|
||||
}
|
||||
});
|
||||
|
||||
mCancelButton = new JButton("Cancel");
|
||||
mCancelButton.addActionListener(new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
IconSelector.this.dispose();
|
||||
}
|
||||
});
|
||||
|
||||
buttonPanel.add(mOKButton);
|
||||
buttonPanel.add(mCancelButton);
|
||||
|
||||
contentPanel.add(buttonPanel, "span,grow");
|
||||
|
||||
add(contentPanel);
|
||||
}
|
||||
|
||||
private void checkButtons()
|
||||
{
|
||||
String name = mNameText.getText();
|
||||
String path = mFileLabel.getText();
|
||||
|
||||
mOKButton.setEnabled(name != null && path != null && !path.isEmpty() && !mIconTableModel.hasIcon(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e)
|
||||
{
|
||||
checkButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e)
|
||||
{
|
||||
checkButtons();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e)
|
||||
{
|
||||
checkButtons();
|
||||
}
|
||||
}
|
||||
|
||||
74
src/icon/IconSet.java
Normal file
74
src/icon/IconSet.java
Normal file
@@ -0,0 +1,74 @@
|
||||
/*******************************************************************************
|
||||
* 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 icon;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@XmlRootElement(name="iconset")
|
||||
public class IconSet
|
||||
{
|
||||
private String mDefaultIcon;
|
||||
private List<Icon> mIcons = new ArrayList<>();
|
||||
|
||||
public IconSet()
|
||||
{
|
||||
//No-arg JAXB constructor
|
||||
}
|
||||
|
||||
public void add(Icon icon)
|
||||
{
|
||||
mIcons.add(icon);
|
||||
}
|
||||
|
||||
public void remove(Icon icon)
|
||||
{
|
||||
mIcons.remove(icon);
|
||||
}
|
||||
|
||||
@XmlElement(name = "icon")
|
||||
public List<Icon> getIcons()
|
||||
{
|
||||
if(mIcons == null)
|
||||
{
|
||||
mIcons = new ArrayList<>();
|
||||
}
|
||||
|
||||
return mIcons;
|
||||
}
|
||||
|
||||
public void setIcons(List<Icon> icons)
|
||||
{
|
||||
mIcons = icons;
|
||||
}
|
||||
|
||||
@XmlAttribute(name = "default")
|
||||
public String getDefaultIcon()
|
||||
{
|
||||
return mDefaultIcon;
|
||||
}
|
||||
|
||||
public void setDefaultIcon(String name)
|
||||
{
|
||||
mDefaultIcon = name;
|
||||
}
|
||||
}
|
||||
71
src/icon/IconTableCellRenderer.java
Normal file
71
src/icon/IconTableCellRenderer.java
Normal file
@@ -0,0 +1,71 @@
|
||||
/*******************************************************************************
|
||||
* 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 icon;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.TableCellRenderer;
|
||||
import java.awt.*;
|
||||
|
||||
public class IconTableCellRenderer extends JLabel implements TableCellRenderer
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger(IconTableCellRenderer.class);
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private IconManager mIconManager;
|
||||
|
||||
public IconTableCellRenderer(IconManager iconManager)
|
||||
{
|
||||
mIconManager = iconManager;
|
||||
setOpaque(true);
|
||||
setHorizontalAlignment(JLabel.CENTER);
|
||||
setPreferredSize(new Dimension(40,34));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
|
||||
int row, int column)
|
||||
{
|
||||
if(value instanceof ImageIcon)
|
||||
{
|
||||
//Get a scaled version of the icon
|
||||
setIcon(mIconManager.getScaledIcon((ImageIcon)value, 24));
|
||||
}
|
||||
else
|
||||
{
|
||||
setIcon(null);
|
||||
}
|
||||
|
||||
if(isSelected)
|
||||
{
|
||||
setBackground(table.getSelectionBackground());
|
||||
setForeground(table.getSelectionForeground());
|
||||
}
|
||||
else
|
||||
{
|
||||
setBackground(table.getBackground());
|
||||
setForeground(table.getForeground());
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
270
src/icon/IconTableModel.java
Normal file
270
src/icon/IconTableModel.java
Normal file
@@ -0,0 +1,270 @@
|
||||
/*******************************************************************************
|
||||
* 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 icon;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.AbstractTableModel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class IconTableModel extends AbstractTableModel
|
||||
{
|
||||
public static final String DEFAULT_ICON = "No Icon";
|
||||
public static final int COLUMN_IMAGE_ICON = 0;
|
||||
public static final int COLUMN_ICON_NAME = 1;
|
||||
|
||||
private Icon mDefaultIcon;
|
||||
|
||||
private Map<String, Icon> mIconMap = new HashMap<>();
|
||||
private List<Icon> mIcons = new ArrayList<>();
|
||||
|
||||
public IconTableModel()
|
||||
{
|
||||
setDefaultIcon(DEFAULT_ICON);
|
||||
}
|
||||
|
||||
public IconTableModel(IconSet iconSet)
|
||||
{
|
||||
mIconMap.clear();
|
||||
mIcons.clear();
|
||||
|
||||
fireTableDataChanged();
|
||||
|
||||
for(Icon icon: iconSet.getIcons())
|
||||
{
|
||||
add(icon);
|
||||
}
|
||||
|
||||
setDefaultIcon(iconSet.getDefaultIcon());
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the icon to the model
|
||||
*/
|
||||
public void add(Icon icon)
|
||||
{
|
||||
if(icon != null)
|
||||
{
|
||||
mIcons.add(icon);
|
||||
mIconMap.put(icon.getName(), icon);
|
||||
|
||||
int index = mIcons.indexOf(icon);
|
||||
fireTableRowsInserted(index, index);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the icon from the model
|
||||
*/
|
||||
public void remove(Icon icon)
|
||||
{
|
||||
if(icon != null && mIcons.contains(icon))
|
||||
{
|
||||
int index = mIcons.indexOf(icon);
|
||||
|
||||
mIcons.remove(icon);
|
||||
mIconMap.remove(icon.getName());
|
||||
|
||||
fireTableRowsDeleted(index, index);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Icon get(int row)
|
||||
{
|
||||
if(row < mIcons.size())
|
||||
{
|
||||
return mIcons.get(row);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRowCount()
|
||||
{
|
||||
return mIcons.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getValueAt(int rowIndex, int columnIndex)
|
||||
{
|
||||
if(rowIndex < mIcons.size() && columnIndex < getColumnCount())
|
||||
{
|
||||
Icon icon = get(rowIndex);
|
||||
|
||||
switch(columnIndex)
|
||||
{
|
||||
case COLUMN_IMAGE_ICON:
|
||||
return icon.getIcon();
|
||||
case COLUMN_ICON_NAME:
|
||||
if(rowIndex == mIcons.indexOf(getDefaultIcon()))
|
||||
{
|
||||
return icon.getName() + " (default)";
|
||||
}
|
||||
else
|
||||
{
|
||||
return icon.getName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getColumnName(int column)
|
||||
{
|
||||
if(column == COLUMN_ICON_NAME)
|
||||
{
|
||||
return "Name";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> getColumnClass(int columnIndex)
|
||||
{
|
||||
if(columnIndex == COLUMN_IMAGE_ICON)
|
||||
{
|
||||
return ImageIcon.class;
|
||||
}
|
||||
|
||||
return String.class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Icons in an array - suitable for use in a JComboBox
|
||||
*/
|
||||
public Icon[] getIconsAsArray()
|
||||
{
|
||||
List<Icon> icons = new ArrayList<>(mIconMap.values());
|
||||
|
||||
Collections.sort(icons);
|
||||
|
||||
return icons.toArray(new Icon[icons.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current default icon
|
||||
*/
|
||||
public Icon getDefaultIcon()
|
||||
{
|
||||
return mDefaultIcon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if the icon argument is the current default icon
|
||||
*/
|
||||
public boolean isDefaultIcon(Icon icon)
|
||||
{
|
||||
return icon == getDefaultIcon();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates if this model contains an icon with the specified name
|
||||
*
|
||||
* @param name to check
|
||||
* @return true if name is not null and not empty and the internal map contains an icon matching name
|
||||
*/
|
||||
public boolean hasIcon(String name)
|
||||
{
|
||||
return name != null && !name.isEmpty() && mIconMap.containsKey(name);
|
||||
}
|
||||
|
||||
public void setDefaultIcon(Icon icon)
|
||||
{
|
||||
if(icon != null)
|
||||
{
|
||||
int currentIndex = mIcons.indexOf(getDefaultIcon());
|
||||
|
||||
mDefaultIcon = icon;
|
||||
|
||||
int newIndex = mIcons.indexOf(icon);
|
||||
|
||||
fireTableCellUpdated(currentIndex, COLUMN_ICON_NAME);
|
||||
fireTableCellUpdated(newIndex, COLUMN_ICON_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the default icon to the icon with the specified name, or to a default icon of the named icon does not exist
|
||||
*/
|
||||
public void setDefaultIcon(String name)
|
||||
{
|
||||
if(name == null)
|
||||
{
|
||||
name = DEFAULT_ICON;
|
||||
}
|
||||
|
||||
Icon defaultIcon = mIconMap.get(name);
|
||||
|
||||
if(defaultIcon != null)
|
||||
{
|
||||
setDefaultIcon(defaultIcon);
|
||||
}
|
||||
else
|
||||
{
|
||||
defaultIcon = new Icon(DEFAULT_ICON, "images/no_icon.png");
|
||||
add(defaultIcon);
|
||||
setDefaultIcon(defaultIcon);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the named icon or the default icon if the named icon does not exist
|
||||
*/
|
||||
public Icon getIcon(String name)
|
||||
{
|
||||
if(name == null || name.isEmpty())
|
||||
{
|
||||
return mDefaultIcon;
|
||||
}
|
||||
|
||||
Icon icon = mIconMap.get(name);
|
||||
|
||||
if(icon == null)
|
||||
{
|
||||
icon = mDefaultIcon;
|
||||
}
|
||||
|
||||
return icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new icon set from a snapshot of the icons contained in this model
|
||||
*/
|
||||
public IconSet getIconSet()
|
||||
{
|
||||
IconSet iconSet = new IconSet();
|
||||
iconSet.setIcons(new ArrayList<Icon>(mIconMap.values()));
|
||||
iconSet.setDefaultIcon(getDefaultIcon().getName());
|
||||
return iconSet;
|
||||
}
|
||||
}
|
||||
74
src/icon/ImageFilter.java
Normal file
74
src/icon/ImageFilter.java
Normal file
@@ -0,0 +1,74 @@
|
||||
/*******************************************************************************
|
||||
* 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 icon;
|
||||
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
import java.io.File;
|
||||
|
||||
public class ImageFilter extends FileFilter
|
||||
{
|
||||
//Accept all directories and all gif, jpg, tiff, or png files.
|
||||
public boolean accept(File f)
|
||||
{
|
||||
if(f.isDirectory())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
String extension = getExtension(f);
|
||||
|
||||
if(extension != null)
|
||||
{
|
||||
if(extension.equals("tiff") ||
|
||||
extension.equals("tif") ||
|
||||
extension.equals("gif") ||
|
||||
extension.equals("jpeg") ||
|
||||
extension.equals("jpg") ||
|
||||
extension.equals("png"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//The description of this filter
|
||||
public String getDescription()
|
||||
{
|
||||
return "Images (*.gif,*.jpg,*.png.";
|
||||
}
|
||||
|
||||
public String getExtension(File f)
|
||||
{
|
||||
String ext = null;
|
||||
String s = f.getName();
|
||||
int i = s.lastIndexOf('.');
|
||||
|
||||
if(i > 0 && i < s.length() - 1)
|
||||
{
|
||||
ext = s.substring(i + 1).toLowerCase();
|
||||
}
|
||||
return ext;
|
||||
}
|
||||
}
|
||||
@@ -1,495 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package map;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSplitPane;
|
||||
import javax.swing.JTextArea;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import settings.Setting;
|
||||
import settings.SettingChangeListener;
|
||||
import settings.SettingsManager;
|
||||
|
||||
public class IconManager extends JFrame
|
||||
implements ActionListener, SettingChangeListener
|
||||
|
||||
{
|
||||
public enum Mode { NORMAL, NEW, EDIT }
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final static Logger mLog =
|
||||
LoggerFactory.getLogger( IconManager.class );
|
||||
|
||||
private static final String sMSG_NEW = "Type a name for the new icon, "
|
||||
+ "select the file, and click Save,\nor Cancel to reset";
|
||||
private static final String sMSG_EDIT = "Change the name for the selected \n"
|
||||
+ "icon and/or the file, and click Save\nto update, or Cancel to reset";
|
||||
private static final String sMSG_NORMAL = "Select an icon to edit, or \n"
|
||||
+ "click New to add an icon";
|
||||
|
||||
private JTextField mIconName;
|
||||
private JTextField mIconPath;
|
||||
private JButton mButtonLeft = new JButton( "New" );
|
||||
private JButton mButtonRight = new JButton( "Edit" );
|
||||
private JButton mButtonFile = new JButton( "File" );
|
||||
private JTextArea mInstructionLabel = new JTextArea();
|
||||
private JList<MapIcon> mIconList;
|
||||
private JFileChooser mFileChooser;
|
||||
private Mode mMode = Mode.NORMAL;
|
||||
|
||||
private SettingsManager mSettingsManager;
|
||||
|
||||
public IconManager( SettingsManager settingsManager, Component displayOver )
|
||||
{
|
||||
mSettingsManager = settingsManager;
|
||||
|
||||
init( displayOver );
|
||||
}
|
||||
|
||||
private void init( Component displayOver )
|
||||
{
|
||||
setTitle( "Icon Manager" );
|
||||
setLocationRelativeTo( displayOver );
|
||||
setSize( 400, 400 );
|
||||
setDefaultCloseOperation( JFrame.DISPOSE_ON_CLOSE );
|
||||
setLayout( new MigLayout( "", "[grow,fill]", "[grow,fill]" ) );
|
||||
|
||||
/**
|
||||
* Editor Panel
|
||||
*/
|
||||
JPanel editorPanel = new JPanel();
|
||||
editorPanel.setLayout( new MigLayout( "", "", "[][][][grow,fill]" ) );
|
||||
|
||||
mButtonFile.addActionListener( this );
|
||||
editorPanel.add( mButtonFile, "align right" );
|
||||
|
||||
mIconPath = new JTextField();
|
||||
editorPanel.add( mIconPath, "grow,wrap" );
|
||||
|
||||
editorPanel.add( new JLabel( "Name:" ), "align right" );
|
||||
|
||||
mIconName = new JTextField();
|
||||
editorPanel.add( mIconName, "grow,wrap" );
|
||||
|
||||
mButtonLeft.addActionListener( this );
|
||||
editorPanel.add( mButtonLeft );
|
||||
|
||||
mButtonRight.addActionListener( this );
|
||||
mButtonRight.setEnabled( false );
|
||||
editorPanel.add( mButtonRight, "wrap" );
|
||||
|
||||
mInstructionLabel.setText( sMSG_NORMAL );
|
||||
mInstructionLabel.setRows( 3 );
|
||||
mInstructionLabel.setBackground( getBackground() );
|
||||
editorPanel.add( mInstructionLabel, "span,grow,wrap" );
|
||||
|
||||
/**
|
||||
* MapIcon list
|
||||
*/
|
||||
MapIcon[] icons = mSettingsManager.getMapIcons();
|
||||
Arrays.sort( icons );
|
||||
|
||||
mIconList = new JList<MapIcon>( icons );
|
||||
|
||||
MapIconListCellRenderer renderer = new MapIconListCellRenderer();
|
||||
renderer.setPreferredSize( new Dimension( 200, 30 ) );
|
||||
mIconList.setCellRenderer( renderer );
|
||||
|
||||
mIconList.addListSelectionListener( new ListSelectionListener()
|
||||
{
|
||||
@Override
|
||||
public void valueChanged( ListSelectionEvent event )
|
||||
{
|
||||
/**
|
||||
* Refresh the display by setting the mode to normal. If we
|
||||
* were in editing or new mode, and the user clicks in the list
|
||||
* throw away the changes and set the mode to normal
|
||||
*/
|
||||
setMode( Mode.NORMAL );
|
||||
}
|
||||
} );
|
||||
|
||||
mIconList.addMouseListener( new MouseListener()
|
||||
{
|
||||
@Override
|
||||
public void mouseClicked( MouseEvent event )
|
||||
{
|
||||
if( event.getButton() == MouseEvent.BUTTON3 )
|
||||
{
|
||||
//Select the item
|
||||
mIconList.setSelectedIndex(
|
||||
mIconList.locationToIndex( event.getPoint() ) );
|
||||
|
||||
//Determine if it can be deleted
|
||||
final MapIcon icon = mIconList.getSelectedValue();
|
||||
|
||||
if( icon != null )
|
||||
{
|
||||
JPopupMenu context = new JPopupMenu();
|
||||
|
||||
JMenuItem setDefault = new JMenuItem( "Set As Default" );
|
||||
|
||||
setDefault.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent e )
|
||||
{
|
||||
mSettingsManager.setDefaultIcon( icon );
|
||||
|
||||
refreshList();
|
||||
}
|
||||
} );
|
||||
|
||||
context.add( setDefault );
|
||||
|
||||
if( icon.isEditable() )
|
||||
{
|
||||
JMenuItem deleteItem = new JMenuItem( "Delete Icon" );
|
||||
deleteItem.addActionListener( new ActionListener()
|
||||
{
|
||||
@Override
|
||||
public void actionPerformed( ActionEvent arg0 )
|
||||
{
|
||||
mSettingsManager.deleteMapIcon( icon );
|
||||
}
|
||||
} );
|
||||
|
||||
context.add( deleteItem );
|
||||
}
|
||||
|
||||
context.show( mIconList, event.getX(), event.getY() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Unused
|
||||
public void mouseEntered( MouseEvent arg0 ) {}
|
||||
public void mouseExited( MouseEvent arg0 ) {}
|
||||
public void mousePressed( MouseEvent arg0 ) {}
|
||||
public void mouseReleased( MouseEvent arg0 ) {}
|
||||
} );
|
||||
|
||||
JScrollPane scroller = new JScrollPane( mIconList );
|
||||
|
||||
/**
|
||||
* Splitpane to hold editor and icon list
|
||||
*/
|
||||
JSplitPane splitPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT,
|
||||
scroller,
|
||||
editorPanel );
|
||||
splitPane.setResizeWeight( 0.7D );
|
||||
|
||||
add( splitPane );
|
||||
}
|
||||
|
||||
private void setMode( Mode mode )
|
||||
{
|
||||
MapIcon selected = mIconList.getSelectedValue();
|
||||
|
||||
switch( mode )
|
||||
{
|
||||
case NORMAL:
|
||||
setTitle( "Icon Manager" );
|
||||
mButtonLeft.setText( "New" );
|
||||
mButtonRight.setText( "Edit" );
|
||||
|
||||
if( selected != null )
|
||||
{
|
||||
if( selected.isEditable() )
|
||||
{
|
||||
mButtonRight.setEnabled( true );
|
||||
mIconName.setText( selected.getName() );
|
||||
mIconPath.setText( selected.getPath() );
|
||||
}
|
||||
else
|
||||
{
|
||||
mButtonRight.setEnabled( false );
|
||||
mIconName.setText( selected.getName() + " [NO EDIT]" );
|
||||
mIconPath.setText( null );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mButtonRight.setEnabled( false );
|
||||
mIconName.setText( null );
|
||||
mIconPath.setText( null );
|
||||
}
|
||||
mInstructionLabel.setText( sMSG_NORMAL );
|
||||
break;
|
||||
case EDIT:
|
||||
if( selected != null )
|
||||
{
|
||||
setTitle( "Icon Manager - editing [" + selected.getName() + "]" );
|
||||
}
|
||||
else
|
||||
{
|
||||
setTitle( "Icon Manager - edit [*]" );
|
||||
}
|
||||
mButtonLeft.setText( "Save" );
|
||||
mButtonRight.setText( "Cancel" );
|
||||
mButtonRight.setEnabled( true );
|
||||
mInstructionLabel.setText( sMSG_EDIT );
|
||||
break;
|
||||
case NEW:
|
||||
setTitle( "Icon Manager - add new icon" );
|
||||
mButtonLeft.setText( "Save" );
|
||||
mButtonRight.setText( "Cancel" );
|
||||
mButtonRight.setEnabled( true );
|
||||
mIconName.setText( null );
|
||||
mIconPath.setText( null );
|
||||
mInstructionLabel.setText( sMSG_NEW );
|
||||
break;
|
||||
}
|
||||
|
||||
mMode = mode;
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
if( e.getSource() == mButtonFile )
|
||||
{
|
||||
if ( mFileChooser == null )
|
||||
{
|
||||
mFileChooser = new JFileChooser();
|
||||
|
||||
//Add a custom file filter and disable the default
|
||||
mFileChooser.addChoosableFileFilter( new ImageFilter() );
|
||||
mFileChooser.setAcceptAllFileFilterUsed( false );
|
||||
}
|
||||
|
||||
int returnVal = mFileChooser.showDialog( this, "Select" );
|
||||
|
||||
if ( returnVal == JFileChooser.APPROVE_OPTION )
|
||||
{
|
||||
File file = mFileChooser.getSelectedFile();
|
||||
|
||||
if( file != null )
|
||||
{
|
||||
mIconPath.setText( file.getAbsolutePath() );
|
||||
}
|
||||
}
|
||||
|
||||
//Reset the file chooser for the next time it's shown.
|
||||
mFileChooser.setSelectedFile( null );
|
||||
}
|
||||
else if( e.getSource() == mButtonLeft )
|
||||
{
|
||||
switch( mMode )
|
||||
{
|
||||
case EDIT: //Save
|
||||
save();
|
||||
break;
|
||||
case NEW: //Save
|
||||
save();
|
||||
break;
|
||||
case NORMAL:
|
||||
setMode( Mode.NEW );
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if( e.getSource() == mButtonRight )
|
||||
{
|
||||
switch( mMode )
|
||||
{
|
||||
case EDIT: //Cancel
|
||||
case NEW: //Cancel
|
||||
setMode( Mode.NORMAL );
|
||||
break;
|
||||
case NORMAL: //Edit
|
||||
setMode( Mode.EDIT );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshList()
|
||||
{
|
||||
MapIcon[] icons = mSettingsManager.getMapIcons();
|
||||
|
||||
Arrays.sort( icons );
|
||||
|
||||
mIconList.setListData( icons );
|
||||
|
||||
repaint();
|
||||
}
|
||||
|
||||
private void save()
|
||||
{
|
||||
String name = mIconName.getText();
|
||||
String path = mIconPath.getText();
|
||||
|
||||
switch( mMode )
|
||||
{
|
||||
case NEW:
|
||||
if( name != null && !name.isEmpty() )
|
||||
{
|
||||
if( path != null && !path.isEmpty() )
|
||||
{
|
||||
mSettingsManager.addMapIcon( new MapIcon( name, path, true ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
JOptionPane.showMessageDialog( this,
|
||||
"Please select an image file",
|
||||
"Filename and path missing",
|
||||
JOptionPane.ERROR_MESSAGE );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
JOptionPane.showMessageDialog( this,
|
||||
"Please type a name for the new icon",
|
||||
"Name missing",
|
||||
JOptionPane.ERROR_MESSAGE );
|
||||
}
|
||||
break;
|
||||
|
||||
case EDIT:
|
||||
MapIcon selected = mIconList.getSelectedValue();
|
||||
|
||||
if( name != null && !name.isEmpty() )
|
||||
{
|
||||
if( path != null && !path.isEmpty() )
|
||||
{
|
||||
selected.setName( name );
|
||||
selected.setPath( path );
|
||||
mSettingsManager.updatMapIcon( selected, name, path );
|
||||
}
|
||||
else
|
||||
{
|
||||
JOptionPane.showMessageDialog( this,
|
||||
"Please select an image file",
|
||||
"Filename and path missing",
|
||||
JOptionPane.ERROR_MESSAGE );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
JOptionPane.showMessageDialog( this,
|
||||
"Please type a name for the new icon",
|
||||
"Name missing",
|
||||
JOptionPane.ERROR_MESSAGE );
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class ImageFilter extends FileFilter
|
||||
{
|
||||
//Accept all directories and all gif, jpg, tiff, or png files.
|
||||
public boolean accept(File f)
|
||||
{
|
||||
if ( f.isDirectory() )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
String extension = getExtension( f );
|
||||
|
||||
if (extension != null)
|
||||
{
|
||||
if (extension.equals( "tiff" ) ||
|
||||
extension.equals( "tif" ) ||
|
||||
extension.equals( "gif" ) ||
|
||||
extension.equals( "jpeg" ) ||
|
||||
extension.equals( "jpg" ) ||
|
||||
extension.equals( "png" ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//The description of this filter
|
||||
public String getDescription()
|
||||
{
|
||||
return "Images (*.gif,*.jpg,*.png.";
|
||||
}
|
||||
|
||||
public String getExtension( File f )
|
||||
{
|
||||
String ext = null;
|
||||
String s = f.getName();
|
||||
int i = s.lastIndexOf('.');
|
||||
|
||||
if (i > 0 && i < s.length() - 1) {
|
||||
ext = s.substring(i+1).toLowerCase();
|
||||
}
|
||||
return ext;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingChanged( Setting setting )
|
||||
{
|
||||
if( setting instanceof MapIcon )
|
||||
{
|
||||
refreshList();
|
||||
setMode( Mode.NORMAL );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingDeleted( Setting setting )
|
||||
{
|
||||
if( setting instanceof MapIcon )
|
||||
{
|
||||
refreshList();
|
||||
setMode( Mode.NORMAL );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
******************************************************************************/
|
||||
package map;
|
||||
|
||||
import java.awt.Component;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JList;
|
||||
import javax.swing.ListCellRenderer;
|
||||
|
||||
public class MapIconListCellRenderer extends JLabel
|
||||
implements ListCellRenderer<MapIcon>
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public MapIconListCellRenderer()
|
||||
{
|
||||
setOpaque( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getListCellRendererComponent(
|
||||
JList<? extends MapIcon> list, MapIcon value, int index,
|
||||
boolean isSelected, boolean cellHasFocus )
|
||||
{
|
||||
setIcon( value.getImageIcon() );
|
||||
setText( value.toString() );
|
||||
|
||||
if ( isSelected )
|
||||
{
|
||||
setBackground( list.getSelectionBackground() );
|
||||
setForeground( list.getSelectionForeground() );
|
||||
}
|
||||
else
|
||||
{
|
||||
setBackground( list.getBackground() );
|
||||
setForeground( list.getForeground() );
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,25 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* 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 map;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import icon.IconManager;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.jdesktop.swingx.JXMapViewer;
|
||||
import org.jdesktop.swingx.OSMTileFactoryInfo;
|
||||
import org.jdesktop.swingx.input.PanKeyListener;
|
||||
@@ -30,10 +27,12 @@ import org.jdesktop.swingx.input.ZoomMouseWheelListenerCursor;
|
||||
import org.jdesktop.swingx.mapviewer.DefaultTileFactory;
|
||||
import org.jdesktop.swingx.mapviewer.GeoPosition;
|
||||
import org.jdesktop.swingx.mapviewer.TileFactoryInfo;
|
||||
|
||||
import settings.MapViewSetting;
|
||||
import settings.SettingsManager;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class MapPanel extends JPanel implements PlottableUpdateListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -42,107 +41,103 @@ public class MapPanel extends JPanel implements PlottableUpdateListener
|
||||
private MapService mMapService;
|
||||
private JXMapViewer mMapViewer = new JXMapViewer();
|
||||
private PlottableEntityPainter mMapPainter;
|
||||
|
||||
public MapPanel( MapService mapService, SettingsManager settingsManager )
|
||||
|
||||
public MapPanel(MapService mapService, IconManager iconManager, SettingsManager settingsManager)
|
||||
{
|
||||
mSettingsManager = settingsManager;
|
||||
mMapService = mapService;
|
||||
mMapPainter = new PlottableEntityPainter( mSettingsManager );
|
||||
|
||||
init();
|
||||
mSettingsManager = settingsManager;
|
||||
mMapService = mapService;
|
||||
mMapPainter = new PlottableEntityPainter(iconManager);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
private void init()
|
||||
{
|
||||
setLayout( new MigLayout( "insets 0 0 0 0",
|
||||
"[grow,fill]", "[grow,fill]") );
|
||||
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[grow,fill]"));
|
||||
|
||||
/**
|
||||
* Set the entity painter as the overlay painter and register this panel
|
||||
* to receive new messages (plots)
|
||||
*/
|
||||
mMapViewer.setOverlayPainter( mMapPainter );
|
||||
mMapService.addListener( this );
|
||||
|
||||
/**
|
||||
* Map image source
|
||||
*/
|
||||
TileFactoryInfo info = new OSMTileFactoryInfo();
|
||||
DefaultTileFactory tileFactory = new DefaultTileFactory( info );
|
||||
mMapViewer.setTileFactory( tileFactory );
|
||||
/**
|
||||
* Set the entity painter as the overlay painter and register this panel
|
||||
* to receive new messages (plots)
|
||||
*/
|
||||
mMapViewer.setOverlayPainter(mMapPainter);
|
||||
mMapService.addListener(this);
|
||||
|
||||
/**
|
||||
* Defines how many threads will be used to fetch the background map
|
||||
* tiles (graphics)
|
||||
*/
|
||||
tileFactory.setThreadPoolSize( 8 );
|
||||
/**
|
||||
* Map image source
|
||||
*/
|
||||
TileFactoryInfo info = new OSMTileFactoryInfo();
|
||||
DefaultTileFactory tileFactory = new DefaultTileFactory(info);
|
||||
mMapViewer.setTileFactory(tileFactory);
|
||||
|
||||
/**
|
||||
* Set initial location and zoom for the map upon display
|
||||
*/
|
||||
GeoPosition syracuse = new GeoPosition( 43.048, -76.147 );
|
||||
int zoom = 7;
|
||||
|
||||
MapViewSetting view = mSettingsManager
|
||||
.getMapViewSetting( "Default", syracuse, zoom );
|
||||
|
||||
mMapViewer.setAddressLocation( view.getGeoPosition() );
|
||||
mMapViewer.setZoom( view.getZoom() );
|
||||
/**
|
||||
* Defines how many threads will be used to fetch the background map
|
||||
* tiles (graphics)
|
||||
*/
|
||||
tileFactory.setThreadPoolSize(8);
|
||||
|
||||
/**
|
||||
* Set initial location and zoom for the map upon display
|
||||
*/
|
||||
GeoPosition syracuse = new GeoPosition(43.048, -76.147);
|
||||
int zoom = 7;
|
||||
|
||||
MapViewSetting view = mSettingsManager.getMapViewSetting("Default", syracuse, zoom);
|
||||
|
||||
mMapViewer.setAddressLocation(view.getGeoPosition());
|
||||
mMapViewer.setZoom(view.getZoom());
|
||||
|
||||
/**
|
||||
* Add a mouse adapter for panning and scrolling
|
||||
*/
|
||||
MapMouseListener listener = new MapMouseListener(mMapViewer, mSettingsManager);
|
||||
mMapViewer.addMouseListener(listener);
|
||||
mMapViewer.addMouseMotionListener(listener);
|
||||
|
||||
/**
|
||||
* Add a mouse adapter for panning and scrolling
|
||||
*/
|
||||
MapMouseListener listener =
|
||||
new MapMouseListener( mMapViewer, mSettingsManager );
|
||||
mMapViewer.addMouseListener( listener );
|
||||
mMapViewer.addMouseMotionListener( listener );
|
||||
|
||||
/* Map zoom listener */
|
||||
mMapViewer.addMouseWheelListener(
|
||||
new ZoomMouseWheelListenerCursor( mMapViewer ) );
|
||||
mMapViewer.addMouseWheelListener(new ZoomMouseWheelListenerCursor(mMapViewer));
|
||||
|
||||
/* Keyboard panning listener */
|
||||
mMapViewer.addKeyListener( new PanKeyListener( mMapViewer ) );
|
||||
mMapViewer.addKeyListener(new PanKeyListener(mMapViewer));
|
||||
|
||||
/**
|
||||
* Add a selection listener
|
||||
*/
|
||||
SelectionAdapter sa = new SelectionAdapter( mMapViewer );
|
||||
mMapViewer.addMouseListener( sa );
|
||||
mMapViewer.addMouseMotionListener( sa );
|
||||
/**
|
||||
* Add a selection listener
|
||||
*/
|
||||
SelectionAdapter sa = new SelectionAdapter(mMapViewer);
|
||||
mMapViewer.addMouseListener(sa);
|
||||
mMapViewer.addMouseMotionListener(sa);
|
||||
|
||||
/**
|
||||
* Map component
|
||||
*/
|
||||
add( mMapViewer, "span" );
|
||||
/**
|
||||
* Map component
|
||||
*/
|
||||
add(mMapViewer, "span");
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void entitiesUpdated()
|
||||
{
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
mMapViewer.repaint();
|
||||
mMapViewer.repaint();
|
||||
}
|
||||
} );
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPlottableEntity( PlottableEntity entity )
|
||||
@Override
|
||||
public void addPlottableEntity(PlottableEntity entity)
|
||||
{
|
||||
mMapPainter.addEntity( entity );
|
||||
|
||||
entitiesUpdated();
|
||||
mMapPainter.addEntity(entity);
|
||||
|
||||
entitiesUpdated();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePlottableEntity( PlottableEntity entity )
|
||||
@Override
|
||||
public void removePlottableEntity(PlottableEntity entity)
|
||||
{
|
||||
mMapPainter.removeEntity( entity );
|
||||
|
||||
entitiesUpdated();
|
||||
mMapPainter.removeEntity(entity);
|
||||
|
||||
entitiesUpdated();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,23 +1,31 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* 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 map;
|
||||
|
||||
import java.awt.Color;
|
||||
import alias.Alias;
|
||||
import controller.NamingThreadFactory;
|
||||
import icon.IconManager;
|
||||
import message.Message;
|
||||
import sample.Listener;
|
||||
import settings.SettingsManager;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -25,159 +33,144 @@ import java.util.Set;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import message.Message;
|
||||
import sample.Listener;
|
||||
import settings.SettingsManager;
|
||||
import alias.Alias;
|
||||
import controller.NamingThreadFactory;
|
||||
|
||||
public class MapService implements Listener<Message>
|
||||
{
|
||||
private int mMaxHistory = 2;
|
||||
private int mCullThresholdMinutes = 60;
|
||||
|
||||
private static final Color sDEFAULT_COLOR = Color.BLACK;
|
||||
|
||||
private final ScheduledExecutorService scheduler =
|
||||
Executors.newScheduledThreadPool(1,
|
||||
new NamingThreadFactory( "map tile fetcher" ) );
|
||||
|
||||
private ArrayList<PlottableUpdateListener> mListeners =
|
||||
new ArrayList<PlottableUpdateListener>();
|
||||
private int mMaxHistory = 2;
|
||||
private int mCullThresholdMinutes = 60;
|
||||
|
||||
private HashMap<String,PlottableEntity> mEntities =
|
||||
new HashMap<String,PlottableEntity>();
|
||||
private static final Color sDEFAULT_COLOR = Color.BLACK;
|
||||
|
||||
private SettingsManager mSettingsManager;
|
||||
|
||||
public MapService( SettingsManager resourceManager )
|
||||
{
|
||||
mSettingsManager = resourceManager;
|
||||
|
||||
// scheduler.scheduleAtFixedRate( new CullThread(), 5, 5, TimeUnit.MINUTES );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the max plottables (locations) history setting that is applied
|
||||
* to all plottable entities
|
||||
*/
|
||||
public int getMaxHistory()
|
||||
{
|
||||
return mMaxHistory;
|
||||
}
|
||||
private final ScheduledExecutorService scheduler =
|
||||
Executors.newScheduledThreadPool(1,
|
||||
new NamingThreadFactory("map tile fetcher"));
|
||||
|
||||
/**
|
||||
* Sets the max history trail for entities. Value is applied to all newly
|
||||
* created PlottableEntity and all existing entities.
|
||||
*/
|
||||
public void setMaxHistory( int maxHistory )
|
||||
{
|
||||
mMaxHistory = maxHistory;
|
||||
private ArrayList<PlottableUpdateListener> mListeners =
|
||||
new ArrayList<PlottableUpdateListener>();
|
||||
|
||||
/**
|
||||
* Update any existing entities with the new max history value
|
||||
*/
|
||||
for( PlottableEntity entity: mEntities.values() )
|
||||
{
|
||||
entity.setMaxHistory( mMaxHistory );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( Message message )
|
||||
private HashMap<String, PlottableEntity> mEntities =
|
||||
new HashMap<String, PlottableEntity>();
|
||||
|
||||
private IconManager mIconManager;
|
||||
|
||||
public MapService(IconManager resourceManager)
|
||||
{
|
||||
Plottable plottable = message.getPlottable();
|
||||
|
||||
if( plottable != null )
|
||||
{
|
||||
PlottableEntity entity = mEntities.get( plottable.getID() );
|
||||
|
||||
if( entity == null )
|
||||
{
|
||||
Alias alias = plottable.getAlias();
|
||||
mIconManager = resourceManager;
|
||||
|
||||
Color color = null;
|
||||
MapIcon icon = null;
|
||||
|
||||
if( alias != null )
|
||||
{
|
||||
color = alias.getMapColor();
|
||||
|
||||
String iconName = alias.getIconName();
|
||||
|
||||
if( iconName == null )
|
||||
{
|
||||
iconName = SettingsManager.DEFAULT_ICON;
|
||||
}
|
||||
|
||||
icon = mSettingsManager.getMapIcon( iconName );
|
||||
}
|
||||
|
||||
if( color == null )
|
||||
{
|
||||
color = sDEFAULT_COLOR;
|
||||
}
|
||||
|
||||
entity = new PlottableEntity( plottable, color );
|
||||
|
||||
entity.setMaxHistory( mMaxHistory );
|
||||
|
||||
mEntities.put( plottable.getID(), entity );
|
||||
|
||||
for( PlottableUpdateListener listener: mListeners )
|
||||
{
|
||||
listener.addPlottableEntity( entity );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.addPlottable( plottable );
|
||||
|
||||
for( PlottableUpdateListener listener: mListeners )
|
||||
{
|
||||
listener.entitiesUpdated();;
|
||||
}
|
||||
}
|
||||
}
|
||||
// scheduler.scheduleAtFixedRate( new CullThread(), 5, 5, TimeUnit.MINUTES );
|
||||
}
|
||||
|
||||
public void addListener( PlottableUpdateListener listener )
|
||||
{
|
||||
mListeners.add( listener );
|
||||
}
|
||||
|
||||
public void removeListener( PlottableUpdateListener listener )
|
||||
{
|
||||
mListeners.remove( listener );
|
||||
}
|
||||
|
||||
public class CullThread implements Runnable
|
||||
{
|
||||
@Override
|
||||
|
||||
/**
|
||||
* Returns the max plottables (locations) history setting that is applied
|
||||
* to all plottable entities
|
||||
*/
|
||||
public int getMaxHistory()
|
||||
{
|
||||
return mMaxHistory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the max history trail for entities. Value is applied to all newly
|
||||
* created PlottableEntity and all existing entities.
|
||||
*/
|
||||
public void setMaxHistory(int maxHistory)
|
||||
{
|
||||
mMaxHistory = maxHistory;
|
||||
|
||||
/**
|
||||
* Update any existing entities with the new max history value
|
||||
*/
|
||||
for(PlottableEntity entity : mEntities.values())
|
||||
{
|
||||
entity.setMaxHistory(mMaxHistory);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(Message message)
|
||||
{
|
||||
Plottable plottable = message.getPlottable();
|
||||
|
||||
if(plottable != null)
|
||||
{
|
||||
PlottableEntity entity = mEntities.get(plottable.getID());
|
||||
|
||||
if(entity == null)
|
||||
{
|
||||
Alias alias = plottable.getAlias();
|
||||
|
||||
Color color = null;
|
||||
|
||||
if(alias != null)
|
||||
{
|
||||
color = alias.getMapColor();
|
||||
}
|
||||
|
||||
if(color == null)
|
||||
{
|
||||
color = sDEFAULT_COLOR;
|
||||
}
|
||||
|
||||
entity = new PlottableEntity(plottable, color);
|
||||
|
||||
entity.setMaxHistory(mMaxHistory);
|
||||
|
||||
mEntities.put(plottable.getID(), entity);
|
||||
|
||||
for(PlottableUpdateListener listener : mListeners)
|
||||
{
|
||||
listener.addPlottableEntity(entity);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
entity.addPlottable(plottable);
|
||||
|
||||
for(PlottableUpdateListener listener : mListeners)
|
||||
{
|
||||
listener.entitiesUpdated();
|
||||
;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addListener(PlottableUpdateListener listener)
|
||||
{
|
||||
mListeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeListener(PlottableUpdateListener listener)
|
||||
{
|
||||
mListeners.remove(listener);
|
||||
}
|
||||
|
||||
public class CullThread implements Runnable
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
long cutoffTime = System.currentTimeMillis() -
|
||||
( mCullThresholdMinutes * 1000 );
|
||||
long cutoffTime = System.currentTimeMillis() -
|
||||
(mCullThresholdMinutes * 1000);
|
||||
|
||||
Set<String> ids = Collections.unmodifiableSet( mEntities.keySet() );
|
||||
Set<String> ids = Collections.unmodifiableSet(mEntities.keySet());
|
||||
|
||||
for( String id: ids )
|
||||
{
|
||||
PlottableEntity entity = mEntities.get( id );
|
||||
|
||||
if( entity.getCurrentPlottable().getTimestamp() < cutoffTime )
|
||||
{
|
||||
mEntities.remove( id );
|
||||
for(String id : ids)
|
||||
{
|
||||
PlottableEntity entity = mEntities.get(id);
|
||||
|
||||
/**
|
||||
* Let all listeners know we've removed (culled) an entity
|
||||
*/
|
||||
for( PlottableUpdateListener listener: mListeners )
|
||||
{
|
||||
listener.removePlottableEntity( entity );
|
||||
}
|
||||
}
|
||||
}
|
||||
if(entity.getCurrentPlottable().getTimestamp() < cutoffTime)
|
||||
{
|
||||
mEntities.remove(id);
|
||||
|
||||
/**
|
||||
* Let all listeners know we've removed (culled) an entity
|
||||
*/
|
||||
for(PlottableUpdateListener listener : mListeners)
|
||||
{
|
||||
listener.removePlottableEntity(entity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,71 +1,79 @@
|
||||
/*
|
||||
* WaypointMapOverlay.java
|
||||
*
|
||||
* Created on April 1, 2006, 4:59 PM
|
||||
*
|
||||
* To change this template, choose Tools | Template Manager
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* 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 map;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Rectangle;
|
||||
import icon.IconManager;
|
||||
import org.jdesktop.swingx.JXMapViewer;
|
||||
import org.jdesktop.swingx.painter.AbstractPainter;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.jdesktop.swingx.JXMapViewer;
|
||||
import org.jdesktop.swingx.painter.AbstractPainter;
|
||||
|
||||
import settings.SettingsManager;
|
||||
|
||||
public class PlottableEntityPainter extends AbstractPainter<JXMapViewer>
|
||||
{
|
||||
private PlottableEntityRenderer mRenderer;
|
||||
private Set<PlottableEntity> mEntities = new HashSet<PlottableEntity>();
|
||||
private PlottableEntityRenderer mRenderer;
|
||||
private Set<PlottableEntity> mEntities = new HashSet<PlottableEntity>();
|
||||
|
||||
public PlottableEntityPainter( SettingsManager settingsManager )
|
||||
{
|
||||
mRenderer = new PlottableEntityRenderer( settingsManager );
|
||||
setAntialiasing( true );
|
||||
setCacheable( false );
|
||||
}
|
||||
public PlottableEntityPainter(IconManager iconManager)
|
||||
{
|
||||
mRenderer = new PlottableEntityRenderer(iconManager);
|
||||
setAntialiasing(true);
|
||||
setCacheable(false);
|
||||
}
|
||||
|
||||
public void addEntity( PlottableEntity entity )
|
||||
{
|
||||
mEntities.add( entity );
|
||||
}
|
||||
|
||||
public void removeEntity( PlottableEntity entity )
|
||||
{
|
||||
mEntities.remove( entity );
|
||||
}
|
||||
|
||||
public void clearEntities()
|
||||
{
|
||||
mEntities.clear();
|
||||
}
|
||||
|
||||
private Set<PlottableEntity> getEntities()
|
||||
{
|
||||
return Collections.unmodifiableSet( mEntities );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doPaint(Graphics2D g, JXMapViewer map, int width, int height)
|
||||
{
|
||||
Rectangle viewportBounds = map.getViewportBounds();
|
||||
public void addEntity(PlottableEntity entity)
|
||||
{
|
||||
mEntities.add(entity);
|
||||
}
|
||||
|
||||
g.translate( -viewportBounds.getX(), -viewportBounds.getY() );
|
||||
public void removeEntity(PlottableEntity entity)
|
||||
{
|
||||
mEntities.remove(entity);
|
||||
}
|
||||
|
||||
Set<PlottableEntity> entities = getEntities();
|
||||
|
||||
for (PlottableEntity entity: entities )
|
||||
{
|
||||
mRenderer.paintPlottableEntity( g, map, entity, true );
|
||||
}
|
||||
public void clearEntities()
|
||||
{
|
||||
mEntities.clear();
|
||||
}
|
||||
|
||||
g.translate( viewportBounds.getX(), viewportBounds.getY() );
|
||||
}
|
||||
private Set<PlottableEntity> getEntities()
|
||||
{
|
||||
return Collections.unmodifiableSet(mEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doPaint(Graphics2D g, JXMapViewer map, int width, int height)
|
||||
{
|
||||
Rectangle viewportBounds = map.getViewportBounds();
|
||||
|
||||
g.translate(-viewportBounds.getX(), -viewportBounds.getY());
|
||||
|
||||
Set<PlottableEntity> entities = getEntities();
|
||||
|
||||
for(PlottableEntity entity : entities)
|
||||
{
|
||||
mRenderer.paintPlottableEntity(g, map, entity, true);
|
||||
}
|
||||
|
||||
g.translate(viewportBounds.getX(), viewportBounds.getY());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,169 +1,162 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* 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 map;
|
||||
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import icon.IconManager;
|
||||
import org.jdesktop.swingx.JXMapViewer;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import org.jdesktop.swingx.JXMapViewer;
|
||||
|
||||
import settings.SettingsManager;
|
||||
|
||||
public class PlottableEntityRenderer
|
||||
{
|
||||
private SettingsManager mSettingsManager;
|
||||
private IconManager mIconManager;
|
||||
|
||||
public PlottableEntityRenderer( SettingsManager settingsManager )
|
||||
{
|
||||
mSettingsManager = settingsManager;
|
||||
}
|
||||
public PlottableEntityRenderer(IconManager iconManager)
|
||||
{
|
||||
mIconManager = iconManager;
|
||||
}
|
||||
|
||||
public void paintPlottableEntity( Graphics2D g,
|
||||
JXMapViewer viewer,
|
||||
PlottableEntity entity,
|
||||
boolean antiAliasing )
|
||||
{
|
||||
Graphics2D graphics = (Graphics2D)g.create();
|
||||
public void paintPlottableEntity(Graphics2D g, JXMapViewer viewer, PlottableEntity entity, boolean antiAliasing)
|
||||
{
|
||||
Graphics2D graphics = (Graphics2D) g.create();
|
||||
|
||||
if( antiAliasing )
|
||||
{
|
||||
graphics.setRenderingHint( RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON );
|
||||
}
|
||||
if(antiAliasing)
|
||||
{
|
||||
graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
||||
RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
}
|
||||
|
||||
/**
|
||||
* Use the entity's preferred color for lines and labels
|
||||
*/
|
||||
graphics.setColor( entity.getColor() );
|
||||
/**
|
||||
* Use the entity's preferred color for lines and labels
|
||||
*/
|
||||
graphics.setColor(entity.getColor());
|
||||
|
||||
/**
|
||||
* Convert the lat/long geoposition to an x/y point on the viewer
|
||||
*/
|
||||
Point2D point = viewer.getTileFactory().geoToPixel(
|
||||
entity.getCurrentGeoPosition(), viewer.getZoom() );
|
||||
/**
|
||||
* Convert the lat/long geoposition to an x/y point on the viewer
|
||||
*/
|
||||
Point2D point = viewer.getTileFactory().geoToPixel(
|
||||
entity.getCurrentGeoPosition(), viewer.getZoom());
|
||||
|
||||
/**
|
||||
* Paint the route first, so the icon and label overlay it
|
||||
*/
|
||||
paintRoute( graphics, viewer, entity );
|
||||
/**
|
||||
* Paint the route first, so the icon and label overlay it
|
||||
*/
|
||||
paintRoute(graphics, viewer, entity);
|
||||
|
||||
/**
|
||||
* Paint the icon at the current location
|
||||
*/
|
||||
ImageIcon icon = getIcon( entity ).getImageIcon();
|
||||
|
||||
paintIcon( graphics, point, icon );
|
||||
/**
|
||||
* Paint the icon at the current location
|
||||
*/
|
||||
ImageIcon icon = getIcon(entity);
|
||||
|
||||
/**
|
||||
* Paint the label offset to the right of the icon
|
||||
*/
|
||||
paintLabel( graphics, point, entity, (int)( icon.getIconWidth() / 2 ), 0 );
|
||||
paintIcon(graphics, point, icon);
|
||||
|
||||
/**
|
||||
* Cleanup
|
||||
*/
|
||||
graphics.dispose();
|
||||
}
|
||||
|
||||
private MapIcon getIcon( PlottableEntity entity )
|
||||
{
|
||||
return mSettingsManager.getMapIcon( entity.getMapIconName() );
|
||||
}
|
||||
|
||||
private void paintIcon( Graphics2D graphics,
|
||||
Point2D point,
|
||||
ImageIcon icon )
|
||||
{
|
||||
graphics.drawImage( icon.getImage(),
|
||||
(int)point.getX() - ( icon.getIconWidth() / 2 ),
|
||||
(int)point.getY() - ( icon.getIconHeight() / 2 ),
|
||||
null );
|
||||
|
||||
}
|
||||
|
||||
private void paintLabel( Graphics2D graphics,
|
||||
Point2D point,
|
||||
PlottableEntity entity,
|
||||
int xOffset,
|
||||
int yOffset )
|
||||
{
|
||||
graphics.drawString( entity.getLabel(),
|
||||
(int)point.getX() + xOffset,
|
||||
(int)point.getY() + yOffset );
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints a two-tone route from the entity's list of plottables (locations).
|
||||
* using black as a wider background route, and the entity's preferred color
|
||||
* as a narrower foreground route.
|
||||
*/
|
||||
private void paintRoute( Graphics2D graphics,
|
||||
JXMapViewer viewer,
|
||||
PlottableEntity entity )
|
||||
{
|
||||
Set<Plottable> plottables = entity.getPlottables();
|
||||
|
||||
if( plottables.size() > 1 )
|
||||
{
|
||||
// Draw the route with a black background line
|
||||
graphics.setColor( Color.BLACK );
|
||||
graphics.setStroke( new BasicStroke( 3 ) );
|
||||
/**
|
||||
* Paint the label offset to the right of the icon
|
||||
*/
|
||||
paintLabel(graphics, point, entity, (int) (icon.getIconWidth() / 2), 0);
|
||||
|
||||
drawRoute( plottables, graphics, viewer );
|
||||
/**
|
||||
* Cleanup
|
||||
*/
|
||||
graphics.dispose();
|
||||
}
|
||||
|
||||
// Draw the route again, in the entity's preferred color
|
||||
graphics.setColor( entity.getColor() );
|
||||
graphics.setStroke( new BasicStroke( 1 ) );
|
||||
private ImageIcon getIcon(PlottableEntity entity)
|
||||
{
|
||||
return mIconManager.getIcon(entity.getMapIconName(), IconManager.DEFAULT_ICON_SIZE);
|
||||
}
|
||||
|
||||
drawRoute( plottables, graphics, viewer );
|
||||
}
|
||||
}
|
||||
private void paintIcon(Graphics2D graphics,
|
||||
Point2D point,
|
||||
ImageIcon icon)
|
||||
{
|
||||
graphics.drawImage(icon.getImage(),
|
||||
(int) point.getX() - (icon.getIconWidth() / 2),
|
||||
(int) point.getY() - (icon.getIconHeight() / 2),
|
||||
null);
|
||||
|
||||
/**
|
||||
* Draws a route from a list of plottables
|
||||
*/
|
||||
private void drawRoute( Set<Plottable> plottables,
|
||||
Graphics2D g,
|
||||
JXMapViewer viewer )
|
||||
{
|
||||
Point2D lastPoint = null;
|
||||
}
|
||||
|
||||
for (Plottable plottable: plottables )
|
||||
{
|
||||
// convert geo-coordinate to world bitmap pixel
|
||||
Point2D currentPoint = viewer.getTileFactory()
|
||||
.geoToPixel( plottable.getGeoPosition(), viewer.getZoom() );
|
||||
private void paintLabel(Graphics2D graphics,
|
||||
Point2D point,
|
||||
PlottableEntity entity,
|
||||
int xOffset,
|
||||
int yOffset)
|
||||
{
|
||||
graphics.drawString(entity.getLabel(),
|
||||
(int) point.getX() + xOffset,
|
||||
(int) point.getY() + yOffset);
|
||||
}
|
||||
|
||||
if( lastPoint != null )
|
||||
{
|
||||
g.drawLine( (int)lastPoint.getX(), (int)lastPoint.getY(),
|
||||
(int)currentPoint.getX(), (int)currentPoint.getY() );
|
||||
}
|
||||
|
||||
lastPoint = currentPoint;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Paints a two-tone route from the entity's list of plottables (locations).
|
||||
* using black as a wider background route, and the entity's preferred color
|
||||
* as a narrower foreground route.
|
||||
*/
|
||||
private void paintRoute(Graphics2D graphics,
|
||||
JXMapViewer viewer,
|
||||
PlottableEntity entity)
|
||||
{
|
||||
Set<Plottable> plottables = entity.getPlottables();
|
||||
|
||||
if(plottables.size() > 1)
|
||||
{
|
||||
// Draw the route with a black background line
|
||||
graphics.setColor(Color.BLACK);
|
||||
graphics.setStroke(new BasicStroke(3));
|
||||
|
||||
drawRoute(plottables, graphics, viewer);
|
||||
|
||||
// Draw the route again, in the entity's preferred color
|
||||
graphics.setColor(entity.getColor());
|
||||
graphics.setStroke(new BasicStroke(1));
|
||||
|
||||
drawRoute(plottables, graphics, viewer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws a route from a list of plottables
|
||||
*/
|
||||
private void drawRoute(Set<Plottable> plottables,
|
||||
Graphics2D g,
|
||||
JXMapViewer viewer)
|
||||
{
|
||||
Point2D lastPoint = null;
|
||||
|
||||
for(Plottable plottable : plottables)
|
||||
{
|
||||
// convert geo-coordinate to world bitmap pixel
|
||||
Point2D currentPoint = viewer.getTileFactory()
|
||||
.geoToPixel(plottable.getGeoPosition(), viewer.getZoom());
|
||||
|
||||
if(lastPoint != null)
|
||||
{
|
||||
g.drawLine((int) lastPoint.getX(), (int) lastPoint.getY(),
|
||||
(int) currentPoint.getX(), (int) currentPoint.getY());
|
||||
}
|
||||
|
||||
lastPoint = currentPoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,26 +1,38 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014-2016 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/>
|
||||
* 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 module.decode;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import alias.AliasList;
|
||||
import alias.AliasModel;
|
||||
import audio.AudioModule;
|
||||
import controller.channel.Channel;
|
||||
import controller.channel.Channel.ChannelType;
|
||||
import controller.channel.ChannelModel;
|
||||
import controller.channel.ChannelProcessingManager;
|
||||
import controller.channel.map.ChannelMap;
|
||||
import controller.channel.map.ChannelMapModel;
|
||||
import filter.AllPassFilter;
|
||||
import filter.FilterSet;
|
||||
import filter.IFilter;
|
||||
import gui.editor.EmptyValidatingEditor;
|
||||
import gui.editor.ValidatingEditor;
|
||||
import icon.IconManager;
|
||||
import message.Message;
|
||||
import message.MessageDirection;
|
||||
import module.Module;
|
||||
@@ -95,479 +107,460 @@ import record.RecorderType;
|
||||
import record.config.RecordConfiguration;
|
||||
import settings.SettingsManager;
|
||||
import util.TimeStamp;
|
||||
import alias.AliasList;
|
||||
import alias.AliasModel;
|
||||
import audio.AudioModule;
|
||||
import controller.channel.Channel;
|
||||
import controller.channel.Channel.ChannelType;
|
||||
import controller.channel.ChannelModel;
|
||||
import controller.channel.ChannelProcessingManager;
|
||||
import controller.channel.map.ChannelMap;
|
||||
import controller.channel.map.ChannelMapModel;
|
||||
import filter.AllPassFilter;
|
||||
import filter.FilterSet;
|
||||
import filter.IFilter;
|
||||
import gui.editor.EmptyValidatingEditor;
|
||||
import gui.editor.ValidatingEditor;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class DecoderFactory
|
||||
{
|
||||
public static final boolean NO_REMOVE_DC = false;
|
||||
public static final boolean REMOVE_DC = true;
|
||||
|
||||
public static final int NO_FREQUENCY_CORRECTION = 0;
|
||||
|
||||
/**
|
||||
* Returns a list of one primary decoder and any auxiliary decoders, as
|
||||
* specified in the configurations.
|
||||
*
|
||||
* @return list of configured decoders
|
||||
*/
|
||||
public static List<Module> getModules( ChannelModel channelModel,
|
||||
ChannelMapModel channelMapModel,
|
||||
ChannelProcessingManager channelProcessingManager,
|
||||
AliasModel aliasModel,
|
||||
Channel channel )
|
||||
{
|
||||
|
||||
/* Get the optional alias list for the decode modules to use */
|
||||
AliasList aliasList = aliasModel.getAliasList( channel.getAliasListName() );
|
||||
|
||||
List<Module> modules = getPrimaryModules( channelModel, channelMapModel,
|
||||
channelProcessingManager, aliasList, channel );
|
||||
|
||||
modules.addAll( getAuxiliaryDecoders( channel.getAuxDecodeConfiguration(), aliasList ) );
|
||||
|
||||
return modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a primary decoder as specified in the decode configuration
|
||||
*/
|
||||
public static List<Module> getPrimaryModules( ChannelModel channelModel,
|
||||
ChannelMapModel channelMapModel,
|
||||
ChannelProcessingManager channelProcessingManager,
|
||||
AliasList aliasList,
|
||||
Channel channel )
|
||||
{
|
||||
List<Module> modules = new ArrayList<Module>();
|
||||
public static final boolean NO_REMOVE_DC = false;
|
||||
public static final boolean REMOVE_DC = true;
|
||||
|
||||
ChannelType channelType = channel.getChannelType();
|
||||
public static final int NO_FREQUENCY_CORRECTION = 0;
|
||||
|
||||
/**
|
||||
* Returns a list of one primary decoder and any auxiliary decoders, as
|
||||
* specified in the configurations.
|
||||
*
|
||||
* @return list of configured decoders
|
||||
*/
|
||||
public static List<Module> getModules(ChannelModel channelModel,
|
||||
ChannelMapModel channelMapModel,
|
||||
ChannelProcessingManager channelProcessingManager,
|
||||
AliasModel aliasModel,
|
||||
Channel channel)
|
||||
{
|
||||
|
||||
/* Get the optional alias list for the decode modules to use */
|
||||
AliasList aliasList = aliasModel.getAliasList(channel.getAliasListName());
|
||||
|
||||
List<Module> modules = getPrimaryModules(channelModel, channelMapModel,
|
||||
channelProcessingManager, aliasList, channel);
|
||||
|
||||
modules.addAll(getAuxiliaryDecoders(channel.getAuxDecodeConfiguration(), aliasList));
|
||||
|
||||
return modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a primary decoder as specified in the decode configuration
|
||||
*/
|
||||
public static List<Module> getPrimaryModules(ChannelModel channelModel,
|
||||
ChannelMapModel channelMapModel,
|
||||
ChannelProcessingManager channelProcessingManager,
|
||||
AliasList aliasList,
|
||||
Channel channel)
|
||||
{
|
||||
List<Module> modules = new ArrayList<Module>();
|
||||
|
||||
ChannelType channelType = channel.getChannelType();
|
||||
|
||||
/* Baseband low-pass filter pass and stop frequencies */
|
||||
DecodeConfiguration decodeConfig = channel.getDecodeConfiguration();
|
||||
|
||||
int iqPass = decodeConfig.getDecoderType().getChannelBandwidth() / 2;
|
||||
int iqStop = iqPass + 1250;
|
||||
DecodeConfiguration decodeConfig = channel.getDecodeConfiguration();
|
||||
|
||||
RecordConfiguration recordConfig = channel.getRecordConfiguration();
|
||||
|
||||
boolean recordAudio = recordConfig == null ? false :
|
||||
recordConfig.getRecorders().contains( RecorderType.AUDIO );
|
||||
|
||||
switch( decodeConfig.getDecoderType() )
|
||||
{
|
||||
case AM:
|
||||
modules.add( new AMDecoder( decodeConfig ) );
|
||||
modules.add( new AlwaysUnsquelchedDecoderState( DecoderType.AM, channel.getName() ) );
|
||||
modules.add( new AMDemodulatorModule() );
|
||||
modules.add( new DemodulatedAudioFilterModule( 4000, 6000 ));
|
||||
modules.add( new AudioModule( recordAudio ) );
|
||||
break;
|
||||
case NBFM:
|
||||
modules.add( new NBFMDecoder( decodeConfig ) );
|
||||
modules.add( new AlwaysUnsquelchedDecoderState( DecoderType.NBFM, channel.getName() ) );
|
||||
modules.add( new FMDemodulatorModule( iqPass, iqStop ) );
|
||||
modules.add( new DemodulatedAudioFilterModule( 4000, 6000 ));
|
||||
modules.add( new AudioModule( recordAudio ) );
|
||||
break;
|
||||
case LTR_STANDARD:
|
||||
MessageDirection direction = ((DecodeConfigLTRStandard)decodeConfig).getMessageDirection();
|
||||
modules.add( new LTRStandardDecoder( aliasList, direction ) );
|
||||
modules.add( new LTRStandardDecoderState( aliasList ) );
|
||||
modules.add( new FMDemodulatorModule( iqPass, iqStop ) );
|
||||
modules.add( new DemodulatedAudioFilterModule( 4000, 6000 ));
|
||||
modules.add( new AudioModule( recordAudio ) );
|
||||
break;
|
||||
case LTR_NET:
|
||||
modules.add( new LTRNetDecoder( (DecodeConfigLTRNet)decodeConfig, aliasList ) );
|
||||
modules.add( new LTRNetDecoderState( aliasList ) );
|
||||
modules.add( new FMDemodulatorModule( iqPass, iqStop ) );
|
||||
modules.add( new DemodulatedAudioFilterModule( 4000, 6000 ));
|
||||
modules.add( new AudioModule( recordAudio ) );
|
||||
break;
|
||||
case MPT1327:
|
||||
DecodeConfigMPT1327 mptConfig = (DecodeConfigMPT1327)decodeConfig;
|
||||
|
||||
ChannelMap channelMap = channelMapModel
|
||||
.getChannelMap( mptConfig.getChannelMapName() );
|
||||
|
||||
Sync sync = mptConfig.getSync();
|
||||
|
||||
modules.add( new MPT1327Decoder( aliasList, sync ) );
|
||||
|
||||
|
||||
modules.add( new MPT1327DecoderState( aliasList, channelMap,
|
||||
channelType, mptConfig.getCallTimeout() * 1000 ) );
|
||||
int iqPass = decodeConfig.getDecoderType().getChannelBandwidth() / 2;
|
||||
int iqStop = iqPass + 1250;
|
||||
|
||||
if( channelType == ChannelType.STANDARD )
|
||||
{
|
||||
long timeout = mptConfig.getCallTimeout() * 1000; //convert to milliseconds
|
||||
RecordConfiguration recordConfig = channel.getRecordConfiguration();
|
||||
|
||||
modules.add( new TrafficChannelManager( channelModel, channelProcessingManager,
|
||||
decodeConfig, recordConfig, channel.getSystem(),
|
||||
channel.getSite(), ( aliasList != null ? aliasList.getName() : null ), timeout,
|
||||
mptConfig.getTrafficChannelPoolSize() ) );
|
||||
}
|
||||
|
||||
modules.add( new FMDemodulatorModule( iqPass, iqStop ) );
|
||||
modules.add( new DemodulatedAudioFilterModule( 4000, 6000 ));
|
||||
modules.add( new AudioModule( recordAudio ) );
|
||||
break;
|
||||
case PASSPORT:
|
||||
modules.add( new PassportDecoder( decodeConfig, aliasList ) );
|
||||
modules.add( new PassportDecoderState( aliasList ) );
|
||||
modules.add( new FMDemodulatorModule( iqPass, iqStop ) );
|
||||
modules.add( new DemodulatedAudioFilterModule( 4000, 6000 ));
|
||||
modules.add( new AudioModule( recordAudio ) );
|
||||
break;
|
||||
case P25_PHASE1:
|
||||
DecodeConfigP25Phase1 p25Config = (DecodeConfigP25Phase1)decodeConfig;
|
||||
boolean recordAudio = recordConfig == null ? false :
|
||||
recordConfig.getRecorders().contains(RecorderType.AUDIO);
|
||||
|
||||
Modulation modulation = p25Config.getModulation();
|
||||
|
||||
|
||||
switch( modulation )
|
||||
{
|
||||
case C4FM:
|
||||
modules.add( new FMDemodulatorModule( 6750, 7500 ) );
|
||||
modules.add( new P25_C4FMDecoder( aliasList, decodeConfig.getAFCMaximumCorrection() ) );
|
||||
modules.add( new P25DecoderState( aliasList, channelType,
|
||||
Modulation.C4FM, p25Config.getIgnoreDataCalls() ) );
|
||||
break;
|
||||
case CQPSK:
|
||||
modules.add( new P25_LSMDecoder( aliasList ) );
|
||||
modules.add( new P25DecoderState( aliasList, channelType,
|
||||
Modulation.CQPSK, p25Config.getIgnoreDataCalls() ) );
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException( "Unrecognized P25 "
|
||||
+ "Phase 1 Modulation [" + modulation + "]" );
|
||||
}
|
||||
switch(decodeConfig.getDecoderType())
|
||||
{
|
||||
case AM:
|
||||
modules.add(new AMDecoder(decodeConfig));
|
||||
modules.add(new AlwaysUnsquelchedDecoderState(DecoderType.AM, channel.getName()));
|
||||
modules.add(new AMDemodulatorModule());
|
||||
modules.add(new DemodulatedAudioFilterModule(4000, 6000));
|
||||
modules.add(new AudioModule(recordAudio));
|
||||
break;
|
||||
case NBFM:
|
||||
modules.add(new NBFMDecoder(decodeConfig));
|
||||
modules.add(new AlwaysUnsquelchedDecoderState(DecoderType.NBFM, channel.getName()));
|
||||
modules.add(new FMDemodulatorModule(iqPass, iqStop));
|
||||
modules.add(new DemodulatedAudioFilterModule(4000, 6000));
|
||||
modules.add(new AudioModule(recordAudio));
|
||||
break;
|
||||
case LTR_STANDARD:
|
||||
MessageDirection direction = ((DecodeConfigLTRStandard) decodeConfig).getMessageDirection();
|
||||
modules.add(new LTRStandardDecoder(aliasList, direction));
|
||||
modules.add(new LTRStandardDecoderState(aliasList));
|
||||
modules.add(new FMDemodulatorModule(iqPass, iqStop));
|
||||
modules.add(new DemodulatedAudioFilterModule(4000, 6000));
|
||||
modules.add(new AudioModule(recordAudio));
|
||||
break;
|
||||
case LTR_NET:
|
||||
modules.add(new LTRNetDecoder((DecodeConfigLTRNet) decodeConfig, aliasList));
|
||||
modules.add(new LTRNetDecoderState(aliasList));
|
||||
modules.add(new FMDemodulatorModule(iqPass, iqStop));
|
||||
modules.add(new DemodulatedAudioFilterModule(4000, 6000));
|
||||
modules.add(new AudioModule(recordAudio));
|
||||
break;
|
||||
case MPT1327:
|
||||
DecodeConfigMPT1327 mptConfig = (DecodeConfigMPT1327) decodeConfig;
|
||||
|
||||
if( channelType == ChannelType.STANDARD )
|
||||
{
|
||||
//Set call timeout to 3 seconds for P25 traffic channels
|
||||
long timeout = 3000;
|
||||
ChannelMap channelMap = channelMapModel
|
||||
.getChannelMap(mptConfig.getChannelMapName());
|
||||
|
||||
modules.add( new TrafficChannelManager( channelModel,
|
||||
channelProcessingManager, decodeConfig,
|
||||
recordConfig, channel.getSystem(), channel.getSite(),
|
||||
( aliasList != null ? aliasList.getName() : null ), timeout,
|
||||
p25Config.getTrafficChannelPoolSize() ) );
|
||||
}
|
||||
|
||||
modules.add( new P25AudioModule( recordAudio ) );
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"Unknown decoder type [" +
|
||||
decodeConfig.getDecoderType().toString() + "]" );
|
||||
}
|
||||
|
||||
return modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a list of auxiliary decoders, as specified in the configuration
|
||||
*
|
||||
* @param config - auxiliary configuration
|
||||
* @param aliasList - optional alias list
|
||||
* @return - list of auxiliary decoders
|
||||
*/
|
||||
public static List<Module> getAuxiliaryDecoders( AuxDecodeConfiguration config,
|
||||
AliasList aliasList )
|
||||
{
|
||||
List<Module> modules = new ArrayList<>();
|
||||
Sync sync = mptConfig.getSync();
|
||||
|
||||
if( config != null )
|
||||
{
|
||||
for( DecoderType auxDecoder: config.getAuxDecoders() )
|
||||
{
|
||||
switch( auxDecoder )
|
||||
{
|
||||
case FLEETSYNC2:
|
||||
modules.add( new Fleetsync2Decoder( aliasList ) );
|
||||
modules.add( new Fleetsync2DecoderState( aliasList ) );
|
||||
break;
|
||||
case MDC1200:
|
||||
modules.add( new MDCDecoder( aliasList ) );
|
||||
modules.add( new MDCDecoderState( aliasList ) );
|
||||
break;
|
||||
case LJ_1200:
|
||||
modules.add( new LJ1200Decoder( aliasList ) );
|
||||
modules.add( new LJ1200DecoderState( aliasList ) );
|
||||
break;
|
||||
case TAIT_1200:
|
||||
modules.add( new Tait1200Decoder( aliasList ) );
|
||||
modules.add( new Tait1200DecoderState( aliasList ) );
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException( "Unrecognized auxiliary "
|
||||
+ "decoder type [" + auxDecoder + "]" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return modules;
|
||||
}
|
||||
modules.add(new MPT1327Decoder(aliasList, sync));
|
||||
|
||||
public static DecoderPanel getDecoderPanel( SettingsManager settingsManager,
|
||||
DecoderState decoderState )
|
||||
{
|
||||
switch( decoderState.getDecoderType() )
|
||||
{
|
||||
case AM:
|
||||
return new AMDecoderPanel( settingsManager, decoderState );
|
||||
case FLEETSYNC2:
|
||||
return new Fleetsync2DecoderPanel( settingsManager,
|
||||
(Fleetsync2DecoderState)decoderState );
|
||||
case LJ_1200:
|
||||
return new LJ1200DecoderPanel( settingsManager,
|
||||
(LJ1200DecoderState)decoderState );
|
||||
case LTR_NET:
|
||||
return new LTRNetDecoderPanel( settingsManager,
|
||||
(LTRNetDecoderState)decoderState );
|
||||
case LTR_STANDARD:
|
||||
return new LTRStandardDecoderPanel( settingsManager,
|
||||
(LTRStandardDecoderState)decoderState );
|
||||
case MDC1200:
|
||||
return new MDCDecoderPanel( settingsManager,
|
||||
(MDCDecoderState)decoderState );
|
||||
case MPT1327:
|
||||
return new MPT1327DecoderPanel( settingsManager,
|
||||
(MPT1327DecoderState)decoderState );
|
||||
case NBFM:
|
||||
return new NBFMDecoderPanel( settingsManager, decoderState );
|
||||
case P25_PHASE1:
|
||||
return new P25DecoderPanel( settingsManager,
|
||||
(P25DecoderState)decoderState );
|
||||
case PASSPORT:
|
||||
return new PassportDecoderPanel( settingsManager,
|
||||
(PassportDecoderState)decoderState );
|
||||
case TAIT_1200:
|
||||
return new Tait1200DecoderPanel( settingsManager,
|
||||
(Tait1200DecoderState)decoderState );
|
||||
default:
|
||||
throw new IllegalArgumentException( "Unrecognized decoder: " +
|
||||
decoderState.getDecoderType().getDisplayString() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assembles a filter set containing filters for the primary channel
|
||||
* decoder and each of the auxiliary decoders
|
||||
*/
|
||||
public static FilterSet<Message> getMessageFilters( List<Module> modules )
|
||||
{
|
||||
FilterSet<Message> filterSet = new FilterSet<>();
|
||||
|
||||
for( Module module: modules )
|
||||
{
|
||||
if( module instanceof Decoder )
|
||||
{
|
||||
filterSet.addFilters( getMessageFilter(
|
||||
((Decoder)module).getDecoderType() ) );
|
||||
}
|
||||
}
|
||||
modules.add(new MPT1327DecoderState(aliasList, channelMap,
|
||||
channelType, mptConfig.getCallTimeout() * 1000));
|
||||
|
||||
if(channelType == ChannelType.STANDARD)
|
||||
{
|
||||
long timeout = mptConfig.getCallTimeout() * 1000; //convert to milliseconds
|
||||
|
||||
modules.add(new TrafficChannelManager(channelModel, channelProcessingManager,
|
||||
decodeConfig, recordConfig, channel.getSystem(),
|
||||
channel.getSite(), (aliasList != null ? aliasList.getName() : null), timeout,
|
||||
mptConfig.getTrafficChannelPoolSize()));
|
||||
}
|
||||
|
||||
modules.add(new FMDemodulatorModule(iqPass, iqStop));
|
||||
modules.add(new DemodulatedAudioFilterModule(4000, 6000));
|
||||
modules.add(new AudioModule(recordAudio));
|
||||
break;
|
||||
case PASSPORT:
|
||||
modules.add(new PassportDecoder(decodeConfig, aliasList));
|
||||
modules.add(new PassportDecoderState(aliasList));
|
||||
modules.add(new FMDemodulatorModule(iqPass, iqStop));
|
||||
modules.add(new DemodulatedAudioFilterModule(4000, 6000));
|
||||
modules.add(new AudioModule(recordAudio));
|
||||
break;
|
||||
case P25_PHASE1:
|
||||
DecodeConfigP25Phase1 p25Config = (DecodeConfigP25Phase1) decodeConfig;
|
||||
|
||||
Modulation modulation = p25Config.getModulation();
|
||||
|
||||
|
||||
switch(modulation)
|
||||
{
|
||||
case C4FM:
|
||||
modules.add(new FMDemodulatorModule(6750, 7500));
|
||||
modules.add(new P25_C4FMDecoder(aliasList, decodeConfig.getAFCMaximumCorrection()));
|
||||
modules.add(new P25DecoderState(aliasList, channelType,
|
||||
Modulation.C4FM, p25Config.getIgnoreDataCalls()));
|
||||
break;
|
||||
case CQPSK:
|
||||
modules.add(new P25_LSMDecoder(aliasList));
|
||||
modules.add(new P25DecoderState(aliasList, channelType,
|
||||
Modulation.CQPSK, p25Config.getIgnoreDataCalls()));
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unrecognized P25 "
|
||||
+ "Phase 1 Modulation [" + modulation + "]");
|
||||
}
|
||||
|
||||
if(channelType == ChannelType.STANDARD)
|
||||
{
|
||||
//Set call timeout to 3 seconds for P25 traffic channels
|
||||
long timeout = 3000;
|
||||
|
||||
modules.add(new TrafficChannelManager(channelModel,
|
||||
channelProcessingManager, decodeConfig,
|
||||
recordConfig, channel.getSystem(), channel.getSite(),
|
||||
(aliasList != null ? aliasList.getName() : null), timeout,
|
||||
p25Config.getTrafficChannelPoolSize()));
|
||||
}
|
||||
|
||||
modules.add(new P25AudioModule(recordAudio));
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException(
|
||||
"Unknown decoder type [" +
|
||||
decodeConfig.getDecoderType().toString() + "]");
|
||||
}
|
||||
|
||||
return modules;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a list of auxiliary decoders, as specified in the configuration
|
||||
*
|
||||
* @param config - auxiliary configuration
|
||||
* @param aliasList - optional alias list
|
||||
* @return - list of auxiliary decoders
|
||||
*/
|
||||
public static List<Module> getAuxiliaryDecoders(AuxDecodeConfiguration config,
|
||||
AliasList aliasList)
|
||||
{
|
||||
List<Module> modules = new ArrayList<>();
|
||||
|
||||
if(config != null)
|
||||
{
|
||||
for(DecoderType auxDecoder : config.getAuxDecoders())
|
||||
{
|
||||
switch(auxDecoder)
|
||||
{
|
||||
case FLEETSYNC2:
|
||||
modules.add(new Fleetsync2Decoder(aliasList));
|
||||
modules.add(new Fleetsync2DecoderState(aliasList));
|
||||
break;
|
||||
case MDC1200:
|
||||
modules.add(new MDCDecoder(aliasList));
|
||||
modules.add(new MDCDecoderState(aliasList));
|
||||
break;
|
||||
case LJ_1200:
|
||||
modules.add(new LJ1200Decoder(aliasList));
|
||||
modules.add(new LJ1200DecoderState(aliasList));
|
||||
break;
|
||||
case TAIT_1200:
|
||||
modules.add(new Tait1200Decoder(aliasList));
|
||||
modules.add(new Tait1200DecoderState(aliasList));
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unrecognized auxiliary "
|
||||
+ "decoder type [" + auxDecoder + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return modules;
|
||||
}
|
||||
|
||||
public static DecoderPanel getDecoderPanel(IconManager iconManager, SettingsManager settingsManager,
|
||||
DecoderState decoderState)
|
||||
{
|
||||
switch(decoderState.getDecoderType())
|
||||
{
|
||||
case AM:
|
||||
return new AMDecoderPanel(iconManager, settingsManager, decoderState);
|
||||
case FLEETSYNC2:
|
||||
return new Fleetsync2DecoderPanel(iconManager, settingsManager, (Fleetsync2DecoderState) decoderState);
|
||||
case LJ_1200:
|
||||
return new LJ1200DecoderPanel(iconManager, settingsManager, (LJ1200DecoderState) decoderState);
|
||||
case LTR_NET:
|
||||
return new LTRNetDecoderPanel(iconManager, settingsManager, (LTRNetDecoderState) decoderState);
|
||||
case LTR_STANDARD:
|
||||
return new LTRStandardDecoderPanel(iconManager, settingsManager, (LTRStandardDecoderState) decoderState);
|
||||
case MDC1200:
|
||||
return new MDCDecoderPanel(iconManager, settingsManager, (MDCDecoderState) decoderState);
|
||||
case MPT1327:
|
||||
return new MPT1327DecoderPanel(iconManager, settingsManager, (MPT1327DecoderState) decoderState);
|
||||
case NBFM:
|
||||
return new NBFMDecoderPanel(iconManager, settingsManager, decoderState);
|
||||
case P25_PHASE1:
|
||||
return new P25DecoderPanel(iconManager, settingsManager, (P25DecoderState) decoderState);
|
||||
case PASSPORT:
|
||||
return new PassportDecoderPanel(iconManager, settingsManager, (PassportDecoderState) decoderState);
|
||||
case TAIT_1200:
|
||||
return new Tait1200DecoderPanel(iconManager, settingsManager, (Tait1200DecoderState) decoderState);
|
||||
default:
|
||||
throw new IllegalArgumentException("Unrecognized decoder: " +
|
||||
decoderState.getDecoderType().getDisplayString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assembles a filter set containing filters for the primary channel
|
||||
* decoder and each of the auxiliary decoders
|
||||
*/
|
||||
public static FilterSet<Message> getMessageFilters(List<Module> modules)
|
||||
{
|
||||
FilterSet<Message> filterSet = new FilterSet<>();
|
||||
|
||||
for(Module module : modules)
|
||||
{
|
||||
if(module instanceof Decoder)
|
||||
{
|
||||
filterSet.addFilters(getMessageFilter(
|
||||
((Decoder) module).getDecoderType()));
|
||||
}
|
||||
}
|
||||
|
||||
/* If we don't have any filters, add an ALL-PASS filter */
|
||||
if( filterSet.getFilters().isEmpty() )
|
||||
{
|
||||
filterSet.addFilter( new AllPassFilter<Message>() );
|
||||
}
|
||||
if(filterSet.getFilters().isEmpty())
|
||||
{
|
||||
filterSet.addFilter(new AllPassFilter<Message>());
|
||||
}
|
||||
|
||||
return filterSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a set of IMessageFilter objects (FilterSets or Filters) that
|
||||
* can process all of the messages produced by the specified decoder type.
|
||||
*/
|
||||
public static List<IFilter<Message>> getMessageFilter( DecoderType decoder )
|
||||
{
|
||||
ArrayList<IFilter<Message>> filters = new ArrayList<IFilter<Message>>();
|
||||
return filterSet;
|
||||
}
|
||||
|
||||
switch( decoder )
|
||||
{
|
||||
case FLEETSYNC2:
|
||||
filters.add( new FleetsyncMessageFilter() );
|
||||
break;
|
||||
case LJ_1200:
|
||||
filters.add( new LJ1200MessageFilter() );
|
||||
break;
|
||||
case LTR_NET:
|
||||
filters.add( new LTRNetMessageFilter() );
|
||||
break;
|
||||
case LTR_STANDARD:
|
||||
filters.add( new LTRStandardMessageFilter() );
|
||||
break;
|
||||
case MDC1200:
|
||||
filters.add( new MDCMessageFilter() );
|
||||
break;
|
||||
case MPT1327:
|
||||
filters.add( new MPT1327MessageFilter() );
|
||||
break;
|
||||
case P25_PHASE1:
|
||||
case P25_PHASE2:
|
||||
filters.add( new P25MessageFilterSet() );
|
||||
break;
|
||||
case PASSPORT:
|
||||
filters.add( new PassportMessageFilter() );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return filters;
|
||||
}
|
||||
/**
|
||||
* Returns a set of IMessageFilter objects (FilterSets or Filters) that
|
||||
* can process all of the messages produced by the specified decoder type.
|
||||
*/
|
||||
public static List<IFilter<Message>> getMessageFilter(DecoderType decoder)
|
||||
{
|
||||
ArrayList<IFilter<Message>> filters = new ArrayList<IFilter<Message>>();
|
||||
|
||||
public static DecodeConfiguration getDefaultDecodeConfiguration()
|
||||
{
|
||||
return getDecodeConfiguration( DecoderType.NBFM );
|
||||
}
|
||||
|
||||
public static DecodeConfiguration getDecodeConfiguration( DecoderType decoder )
|
||||
{
|
||||
DecodeConfiguration retVal;
|
||||
switch(decoder)
|
||||
{
|
||||
case FLEETSYNC2:
|
||||
filters.add(new FleetsyncMessageFilter());
|
||||
break;
|
||||
case LJ_1200:
|
||||
filters.add(new LJ1200MessageFilter());
|
||||
break;
|
||||
case LTR_NET:
|
||||
filters.add(new LTRNetMessageFilter());
|
||||
break;
|
||||
case LTR_STANDARD:
|
||||
filters.add(new LTRStandardMessageFilter());
|
||||
break;
|
||||
case MDC1200:
|
||||
filters.add(new MDCMessageFilter());
|
||||
break;
|
||||
case MPT1327:
|
||||
filters.add(new MPT1327MessageFilter());
|
||||
break;
|
||||
case P25_PHASE1:
|
||||
case P25_PHASE2:
|
||||
filters.add(new P25MessageFilterSet());
|
||||
break;
|
||||
case PASSPORT:
|
||||
filters.add(new PassportMessageFilter());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch( decoder )
|
||||
{
|
||||
case AM:
|
||||
return new DecodeConfigAM();
|
||||
case LTR_NET:
|
||||
return new DecodeConfigLTRNet();
|
||||
case LTR_STANDARD:
|
||||
return new DecodeConfigLTRStandard();
|
||||
case MPT1327:
|
||||
return new DecodeConfigMPT1327();
|
||||
case NBFM:
|
||||
return new DecodeConfigNBFM();
|
||||
case PASSPORT:
|
||||
return new DecodeConfigPassport();
|
||||
case P25_PHASE1:
|
||||
return new DecodeConfigP25Phase1();
|
||||
default:
|
||||
throw new IllegalArgumentException( "DecodeConfigFactory - unknown decoder type ["
|
||||
+ decoder.toString() + "]" );
|
||||
}
|
||||
}
|
||||
|
||||
public static ValidatingEditor<Channel> getEditor( DecoderType type, ChannelMapModel model )
|
||||
{
|
||||
switch( type )
|
||||
{
|
||||
case AM:
|
||||
return new AMDecoderEditor();
|
||||
case LTR_NET:
|
||||
return new LTRNetDecoderEditor();
|
||||
case LTR_STANDARD:
|
||||
return new LTRStandardDecoderEditor();
|
||||
case MPT1327:
|
||||
return new MPT1327DecoderEditor( model );
|
||||
case NBFM:
|
||||
return new NBFMDecoderEditor();
|
||||
case P25_PHASE1:
|
||||
return new P25DecoderEditor();
|
||||
case PASSPORT:
|
||||
return new PassportDecoderEditor();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return new EmptyValidatingEditor<Channel>( "a decoder" );
|
||||
}
|
||||
return filters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of the configuration
|
||||
*/
|
||||
public static DecodeConfiguration copy( DecodeConfiguration config )
|
||||
{
|
||||
if( config != null )
|
||||
{
|
||||
switch( config.getDecoderType() )
|
||||
{
|
||||
case AM:
|
||||
DecodeConfigAM originalAM = (DecodeConfigAM)config;
|
||||
DecodeConfigAM copyAM = new DecodeConfigAM();
|
||||
copyAM.setAFC( originalAM.getAFC() );
|
||||
copyAM.setAFCMaximumCorrection( originalAM.getAFCMaximumCorrection() );
|
||||
return copyAM;
|
||||
case LTR_NET:
|
||||
DecodeConfigLTRNet originalLTRNet = (DecodeConfigLTRNet)config;
|
||||
DecodeConfigLTRNet copyLTRNet = new DecodeConfigLTRNet();
|
||||
copyLTRNet.setAFC( originalLTRNet.getAFC() );
|
||||
copyLTRNet.setAFCMaximumCorrection( originalLTRNet.getAFCMaximumCorrection() );
|
||||
copyLTRNet.setMessageDirection( originalLTRNet.getMessageDirection() );
|
||||
return copyLTRNet;
|
||||
case LTR_STANDARD:
|
||||
DecodeConfigLTRStandard originalLTRStandard = (DecodeConfigLTRStandard)config;
|
||||
DecodeConfigLTRStandard copyLTRStandard = new DecodeConfigLTRStandard();
|
||||
copyLTRStandard.setAFC( originalLTRStandard.getAFC() );
|
||||
copyLTRStandard.setAFCMaximumCorrection( originalLTRStandard.getAFCMaximumCorrection() );
|
||||
copyLTRStandard.setMessageDirection( originalLTRStandard.getMessageDirection() );
|
||||
return copyLTRStandard;
|
||||
case MPT1327:
|
||||
DecodeConfigMPT1327 originalMPT = (DecodeConfigMPT1327)config;
|
||||
DecodeConfigMPT1327 copyMPT = new DecodeConfigMPT1327();
|
||||
copyMPT.setAFC( originalMPT.getAFC() );
|
||||
copyMPT.setAFCMaximumCorrection( originalMPT.getAFCMaximumCorrection() );
|
||||
copyMPT.setCallTimeout( originalMPT.getCallTimeout() );
|
||||
copyMPT.setChannelMapName( originalMPT.getChannelMapName() );
|
||||
copyMPT.setSync( originalMPT.getSync() );
|
||||
copyMPT.setTrafficChannelPoolSize( originalMPT.getTrafficChannelPoolSize() );
|
||||
return copyMPT;
|
||||
case NBFM:
|
||||
DecodeConfigNBFM originalNBFM = (DecodeConfigNBFM)config;
|
||||
DecodeConfigNBFM copyNBFM = new DecodeConfigNBFM();
|
||||
copyNBFM.setAFC( originalNBFM.getAFC() );
|
||||
copyNBFM.setAFCMaximumCorrection( originalNBFM.getAFCMaximumCorrection() );
|
||||
return copyNBFM;
|
||||
case P25_PHASE1:
|
||||
DecodeConfigP25Phase1 originalP25 = (DecodeConfigP25Phase1)config;
|
||||
DecodeConfigP25Phase1 copyP25 = new DecodeConfigP25Phase1();
|
||||
copyP25.setAFC( originalP25.getAFC() );
|
||||
copyP25.setAFCMaximumCorrection( originalP25.getAFCMaximumCorrection() );
|
||||
copyP25.setIgnoreDataCalls( originalP25.getIgnoreDataCalls() );
|
||||
copyP25.setModulation( originalP25.getModulation() );
|
||||
copyP25.setTrafficChannelPoolSize( originalP25.getTrafficChannelPoolSize() );
|
||||
return copyP25;
|
||||
case PASSPORT:
|
||||
DecodeConfigPassport originalPass = (DecodeConfigPassport)config;
|
||||
DecodeConfigPassport copyPass = new DecodeConfigPassport();
|
||||
copyPass.setAFC( originalPass.getAFC() );
|
||||
copyPass.setAFCMaximumCorrection( originalPass.getAFCMaximumCorrection() );
|
||||
return copyPass;
|
||||
default:
|
||||
throw new IllegalArgumentException( "Unrecognized decoder "
|
||||
+ "configuration type:" + config.getDecoderType() );
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public static DecodeConfiguration getDefaultDecodeConfiguration()
|
||||
{
|
||||
return getDecodeConfiguration(DecoderType.NBFM);
|
||||
}
|
||||
|
||||
public static String getRecordingFilename( String token )
|
||||
{
|
||||
//Get the base recording filename
|
||||
public static DecodeConfiguration getDecodeConfiguration(DecoderType decoder)
|
||||
{
|
||||
DecodeConfiguration retVal;
|
||||
|
||||
switch(decoder)
|
||||
{
|
||||
case AM:
|
||||
return new DecodeConfigAM();
|
||||
case LTR_NET:
|
||||
return new DecodeConfigLTRNet();
|
||||
case LTR_STANDARD:
|
||||
return new DecodeConfigLTRStandard();
|
||||
case MPT1327:
|
||||
return new DecodeConfigMPT1327();
|
||||
case NBFM:
|
||||
return new DecodeConfigNBFM();
|
||||
case PASSPORT:
|
||||
return new DecodeConfigPassport();
|
||||
case P25_PHASE1:
|
||||
return new DecodeConfigP25Phase1();
|
||||
default:
|
||||
throw new IllegalArgumentException("DecodeConfigFactory - unknown decoder type ["
|
||||
+ decoder.toString() + "]");
|
||||
}
|
||||
}
|
||||
|
||||
public static ValidatingEditor<Channel> getEditor(DecoderType type, ChannelMapModel model)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case AM:
|
||||
return new AMDecoderEditor();
|
||||
case LTR_NET:
|
||||
return new LTRNetDecoderEditor();
|
||||
case LTR_STANDARD:
|
||||
return new LTRStandardDecoderEditor();
|
||||
case MPT1327:
|
||||
return new MPT1327DecoderEditor(model);
|
||||
case NBFM:
|
||||
return new NBFMDecoderEditor();
|
||||
case P25_PHASE1:
|
||||
return new P25DecoderEditor();
|
||||
case PASSPORT:
|
||||
return new PassportDecoderEditor();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return new EmptyValidatingEditor<Channel>("a decoder");
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of the configuration
|
||||
*/
|
||||
public static DecodeConfiguration copy(DecodeConfiguration config)
|
||||
{
|
||||
if(config != null)
|
||||
{
|
||||
switch(config.getDecoderType())
|
||||
{
|
||||
case AM:
|
||||
DecodeConfigAM originalAM = (DecodeConfigAM) config;
|
||||
DecodeConfigAM copyAM = new DecodeConfigAM();
|
||||
copyAM.setAFC(originalAM.getAFC());
|
||||
copyAM.setAFCMaximumCorrection(originalAM.getAFCMaximumCorrection());
|
||||
return copyAM;
|
||||
case LTR_NET:
|
||||
DecodeConfigLTRNet originalLTRNet = (DecodeConfigLTRNet) config;
|
||||
DecodeConfigLTRNet copyLTRNet = new DecodeConfigLTRNet();
|
||||
copyLTRNet.setAFC(originalLTRNet.getAFC());
|
||||
copyLTRNet.setAFCMaximumCorrection(originalLTRNet.getAFCMaximumCorrection());
|
||||
copyLTRNet.setMessageDirection(originalLTRNet.getMessageDirection());
|
||||
return copyLTRNet;
|
||||
case LTR_STANDARD:
|
||||
DecodeConfigLTRStandard originalLTRStandard = (DecodeConfigLTRStandard) config;
|
||||
DecodeConfigLTRStandard copyLTRStandard = new DecodeConfigLTRStandard();
|
||||
copyLTRStandard.setAFC(originalLTRStandard.getAFC());
|
||||
copyLTRStandard.setAFCMaximumCorrection(originalLTRStandard.getAFCMaximumCorrection());
|
||||
copyLTRStandard.setMessageDirection(originalLTRStandard.getMessageDirection());
|
||||
return copyLTRStandard;
|
||||
case MPT1327:
|
||||
DecodeConfigMPT1327 originalMPT = (DecodeConfigMPT1327) config;
|
||||
DecodeConfigMPT1327 copyMPT = new DecodeConfigMPT1327();
|
||||
copyMPT.setAFC(originalMPT.getAFC());
|
||||
copyMPT.setAFCMaximumCorrection(originalMPT.getAFCMaximumCorrection());
|
||||
copyMPT.setCallTimeout(originalMPT.getCallTimeout());
|
||||
copyMPT.setChannelMapName(originalMPT.getChannelMapName());
|
||||
copyMPT.setSync(originalMPT.getSync());
|
||||
copyMPT.setTrafficChannelPoolSize(originalMPT.getTrafficChannelPoolSize());
|
||||
return copyMPT;
|
||||
case NBFM:
|
||||
DecodeConfigNBFM originalNBFM = (DecodeConfigNBFM) config;
|
||||
DecodeConfigNBFM copyNBFM = new DecodeConfigNBFM();
|
||||
copyNBFM.setAFC(originalNBFM.getAFC());
|
||||
copyNBFM.setAFCMaximumCorrection(originalNBFM.getAFCMaximumCorrection());
|
||||
return copyNBFM;
|
||||
case P25_PHASE1:
|
||||
DecodeConfigP25Phase1 originalP25 = (DecodeConfigP25Phase1) config;
|
||||
DecodeConfigP25Phase1 copyP25 = new DecodeConfigP25Phase1();
|
||||
copyP25.setAFC(originalP25.getAFC());
|
||||
copyP25.setAFCMaximumCorrection(originalP25.getAFCMaximumCorrection());
|
||||
copyP25.setIgnoreDataCalls(originalP25.getIgnoreDataCalls());
|
||||
copyP25.setModulation(originalP25.getModulation());
|
||||
copyP25.setTrafficChannelPoolSize(originalP25.getTrafficChannelPoolSize());
|
||||
return copyP25;
|
||||
case PASSPORT:
|
||||
DecodeConfigPassport originalPass = (DecodeConfigPassport) config;
|
||||
DecodeConfigPassport copyPass = new DecodeConfigPassport();
|
||||
copyPass.setAFC(originalPass.getAFC());
|
||||
copyPass.setAFCMaximumCorrection(originalPass.getAFCMaximumCorrection());
|
||||
return copyPass;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unrecognized decoder "
|
||||
+ "configuration type:" + config.getDecoderType());
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getRecordingFilename(String token)
|
||||
{
|
||||
//Get the base recording filename
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append( SystemProperties.getInstance()
|
||||
.getApplicationFolder( "recordings" ) );
|
||||
sb.append( File.separator );
|
||||
sb.append( TimeStamp.getTimeStamp( "_" ) );
|
||||
sb.append( "_" );
|
||||
sb.append( token );
|
||||
sb.append(SystemProperties.getInstance()
|
||||
.getApplicationFolder("recordings"));
|
||||
sb.append(File.separator);
|
||||
sb.append(TimeStamp.getTimeStamp("_"));
|
||||
sb.append("_");
|
||||
sb.append(token);
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,82 +1,84 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* 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 module.decode.am;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import icon.IconManager;
|
||||
import module.decode.state.ChangedAttribute;
|
||||
import module.decode.state.DecoderPanel;
|
||||
import module.decode.state.DecoderState;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import settings.ColorSetting;
|
||||
import settings.Setting;
|
||||
import settings.SettingsManager;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class AMDecoderPanel extends DecoderPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private JLabel mProtocol = new JLabel( "AM" );
|
||||
|
||||
public AMDecoderPanel( SettingsManager settingsManager, DecoderState decoderState )
|
||||
{
|
||||
super( settingsManager, decoderState );
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
setLayout( new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[]0[]0[]") );
|
||||
|
||||
mProtocol.setFont( mFontDecoder );
|
||||
mProtocol.setForeground( mColorLabelDecoder );
|
||||
private JLabel mProtocol = new JLabel("AM");
|
||||
|
||||
add( mProtocol, "wrap" );
|
||||
}
|
||||
public AMDecoderPanel(IconManager iconManager, SettingsManager settingsManager, DecoderState decoderState)
|
||||
{
|
||||
super(iconManager, settingsManager, decoderState);
|
||||
|
||||
@Override
|
||||
public void receive( final ChangedAttribute changedAttribute )
|
||||
init();
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[]0[]0[]"));
|
||||
|
||||
mProtocol.setFont(mFontDecoder);
|
||||
mProtocol.setForeground(mColorLabelDecoder);
|
||||
|
||||
add(mProtocol, "wrap");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(final ChangedAttribute changedAttribute)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingChanged( Setting setting )
|
||||
@Override
|
||||
public void settingChanged(Setting setting)
|
||||
{
|
||||
super.settingChanged( setting );
|
||||
|
||||
if( setting instanceof ColorSetting )
|
||||
{
|
||||
ColorSetting colorSetting = (ColorSetting)setting;
|
||||
|
||||
switch( colorSetting.getColorSettingName() )
|
||||
{
|
||||
case CHANNEL_STATE_LABEL_DECODER:
|
||||
if( mProtocol != null )
|
||||
{
|
||||
mProtocol.setForeground( mColorLabelDecoder );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
super.settingChanged(setting);
|
||||
|
||||
if(setting instanceof ColorSetting)
|
||||
{
|
||||
ColorSetting colorSetting = (ColorSetting) setting;
|
||||
|
||||
switch(colorSetting.getColorSettingName())
|
||||
{
|
||||
case CHANNEL_STATE_LABEL_DECODER:
|
||||
if(mProtocol != null)
|
||||
{
|
||||
mProtocol.setForeground(mColorLabelDecoder);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,28 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* 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 module.decode.event;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
|
||||
import settings.SettingsManager;
|
||||
import alias.Alias;
|
||||
import icon.IconManager;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.table.DefaultTableCellRenderer;
|
||||
|
||||
/**
|
||||
* Custom renderer for JTable cells that contain Alias objects. Renders the
|
||||
@@ -30,45 +31,45 @@ import alias.Alias;
|
||||
*/
|
||||
public class CallEventAliasCellRenderer extends DefaultTableCellRenderer
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private SettingsManager mSettingsManager;
|
||||
|
||||
public CallEventAliasCellRenderer( SettingsManager settingsManager )
|
||||
{
|
||||
super();
|
||||
mSettingsManager = settingsManager;
|
||||
}
|
||||
|
||||
public void setValue( Object obj )
|
||||
{
|
||||
if( obj != null && obj instanceof Alias )
|
||||
{
|
||||
Alias alias = (Alias)obj;
|
||||
|
||||
setText( alias.getName() );
|
||||
|
||||
ImageIcon icon = getIcon( alias, SettingsManager.DEFAULT_ICON_SIZE );
|
||||
|
||||
if( icon != null )
|
||||
{
|
||||
setIcon( icon );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setText( " " );
|
||||
setIcon( null );
|
||||
}
|
||||
}
|
||||
|
||||
private ImageIcon getIcon( Alias alias, int height )
|
||||
{
|
||||
if( mSettingsManager != null && alias != null )
|
||||
{
|
||||
return mSettingsManager.getImageIcon( alias.getIconName(), height );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
private IconManager mIconManager;
|
||||
|
||||
public CallEventAliasCellRenderer(IconManager iconManager)
|
||||
{
|
||||
super();
|
||||
mIconManager = iconManager;
|
||||
}
|
||||
|
||||
public void setValue(Object obj)
|
||||
{
|
||||
if(obj != null && obj instanceof Alias)
|
||||
{
|
||||
Alias alias = (Alias) obj;
|
||||
|
||||
setText(alias.getName());
|
||||
|
||||
ImageIcon icon = getIcon(alias, IconManager.DEFAULT_ICON_SIZE);
|
||||
|
||||
if(icon != null)
|
||||
{
|
||||
setIcon(icon);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setText(" ");
|
||||
setIcon(null);
|
||||
}
|
||||
}
|
||||
|
||||
private ImageIcon getIcon(Alias alias, int height)
|
||||
{
|
||||
if(mIconManager != null && alias != null)
|
||||
{
|
||||
return mIconManager.getIcon(alias.getIconName(), height);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,36 +1,34 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* 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 module.decode.event;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JTable;
|
||||
|
||||
import module.ProcessingChain;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import settings.SettingsManager;
|
||||
import controller.channel.Channel;
|
||||
import controller.channel.ChannelEvent;
|
||||
import controller.channel.ChannelEvent.Event;
|
||||
import controller.channel.ChannelEventListener;
|
||||
import controller.channel.ChannelProcessingManager;
|
||||
import icon.IconManager;
|
||||
import module.ProcessingChain;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class CallEventPanel extends JPanel implements ChannelEventListener
|
||||
{
|
||||
@@ -41,100 +39,91 @@ public class CallEventPanel extends JPanel implements ChannelEventListener
|
||||
private CallEventAliasCellRenderer mRenderer;
|
||||
private ChannelProcessingManager mChannelProcessingManager;
|
||||
|
||||
public CallEventPanel( SettingsManager settingsManager,
|
||||
ChannelProcessingManager channelProcessingManager )
|
||||
{
|
||||
mChannelProcessingManager = channelProcessingManager;
|
||||
|
||||
setLayout( new MigLayout("insets 0 0 0 0 ", "[grow,fill]", "[grow,fill]") );
|
||||
|
||||
JTable table = new JTable( new CallEventModel() );
|
||||
table.setAutoCreateRowSorter( true );
|
||||
table.setAutoResizeMode( JTable.AUTO_RESIZE_LAST_COLUMN );
|
||||
|
||||
mRenderer = new CallEventAliasCellRenderer( settingsManager );
|
||||
|
||||
table.getColumnModel().getColumn( CallEventModel.FROM_ALIAS )
|
||||
.setCellRenderer( mRenderer );
|
||||
|
||||
table.getColumnModel().getColumn( CallEventModel.TO_ALIAS )
|
||||
.setCellRenderer( mRenderer );
|
||||
|
||||
mEmptyScroller = new JScrollPane( table );
|
||||
|
||||
add( mEmptyScroller );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelChanged( final ChannelEvent event )
|
||||
public CallEventPanel(IconManager iconManager, ChannelProcessingManager channelProcessingManager)
|
||||
{
|
||||
if( event.getEvent() == Event.NOTIFICATION_SELECTION_CHANGE &&
|
||||
event.getChannel().isSelected() )
|
||||
{
|
||||
if( mDisplayedChannel == null ||
|
||||
( mDisplayedChannel != null &&
|
||||
mDisplayedChannel != event.getChannel() ) )
|
||||
{
|
||||
ProcessingChain chain = mChannelProcessingManager
|
||||
.getProcessingChain( event.getChannel() );
|
||||
|
||||
if( chain != null )
|
||||
{
|
||||
final CallEventModel model = chain.getCallEventModel();
|
||||
|
||||
if( model != null )
|
||||
{
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
removeAll();
|
||||
|
||||
JTable table = new JTable( model );
|
||||
mChannelProcessingManager = channelProcessingManager;
|
||||
|
||||
table.setAutoCreateRowSorter( true );
|
||||
table.setAutoResizeMode( JTable.AUTO_RESIZE_LAST_COLUMN );
|
||||
|
||||
table.getColumnModel().getColumn( CallEventModel.FROM_ALIAS )
|
||||
.setCellRenderer( mRenderer );
|
||||
setLayout(new MigLayout("insets 0 0 0 0 ", "[grow,fill]", "[grow,fill]"));
|
||||
|
||||
table.getColumnModel().getColumn( CallEventModel.TO_ALIAS )
|
||||
.setCellRenderer( mRenderer );
|
||||
|
||||
add( new JScrollPane( table ) );
|
||||
|
||||
mDisplayedChannel = event.getChannel();
|
||||
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( event.getEvent() == Event.NOTIFICATION_PROCESSING_STOP ||
|
||||
event.getEvent() == Event.REQUEST_DISABLE )
|
||||
{
|
||||
if( mDisplayedChannel != null &&
|
||||
mDisplayedChannel == event.getChannel() )
|
||||
{
|
||||
mDisplayedChannel = null;
|
||||
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
removeAll();
|
||||
add( mEmptyScroller );
|
||||
JTable table = new JTable(new CallEventModel());
|
||||
table.setAutoCreateRowSorter(true);
|
||||
table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
|
||||
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
mRenderer = new CallEventAliasCellRenderer(iconManager);
|
||||
|
||||
table.getColumnModel().getColumn(CallEventModel.FROM_ALIAS).setCellRenderer(mRenderer);
|
||||
|
||||
table.getColumnModel().getColumn(CallEventModel.TO_ALIAS).setCellRenderer(mRenderer);
|
||||
|
||||
mEmptyScroller = new JScrollPane(table);
|
||||
|
||||
add(mEmptyScroller);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void channelChanged(final ChannelEvent event)
|
||||
{
|
||||
if(event.getEvent() == Event.NOTIFICATION_SELECTION_CHANGE && event.getChannel().isSelected())
|
||||
{
|
||||
if(mDisplayedChannel == null || (mDisplayedChannel != null && mDisplayedChannel != event.getChannel()))
|
||||
{
|
||||
ProcessingChain chain = mChannelProcessingManager.getProcessingChain(event.getChannel());
|
||||
|
||||
if(chain != null)
|
||||
{
|
||||
final CallEventModel model = chain.getCallEventModel();
|
||||
|
||||
if(model != null)
|
||||
{
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
removeAll();
|
||||
|
||||
JTable table = new JTable(model);
|
||||
|
||||
table.setAutoCreateRowSorter(true);
|
||||
table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
|
||||
|
||||
table.getColumnModel().getColumn(CallEventModel.FROM_ALIAS)
|
||||
.setCellRenderer(mRenderer);
|
||||
|
||||
table.getColumnModel().getColumn(CallEventModel.TO_ALIAS)
|
||||
.setCellRenderer(mRenderer);
|
||||
|
||||
add(new JScrollPane(table));
|
||||
|
||||
mDisplayedChannel = event.getChannel();
|
||||
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(event.getEvent() == Event.NOTIFICATION_PROCESSING_STOP || event.getEvent() == Event.REQUEST_DISABLE)
|
||||
{
|
||||
if(mDisplayedChannel != null && mDisplayedChannel == event.getChannel())
|
||||
{
|
||||
mDisplayedChannel = null;
|
||||
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
removeAll();
|
||||
add(mEmptyScroller);
|
||||
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,202 +1,201 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014,2015 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/>
|
||||
* 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 module.decode.fleetsync2;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import icon.IconManager;
|
||||
import module.decode.state.ChangedAttribute;
|
||||
import module.decode.state.DecoderPanel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import settings.ColorSetting;
|
||||
import settings.ColorSetting.ColorSettingName;
|
||||
import settings.Setting;
|
||||
import settings.SettingsManager;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class Fleetsync2DecoderPanel extends DecoderPanel
|
||||
{
|
||||
private final static Logger mLog = LoggerFactory.getLogger( Fleetsync2DecoderPanel.class );
|
||||
private final static Logger mLog = LoggerFactory.getLogger(Fleetsync2DecoderPanel.class);
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final String PROTOCOL = "FSync II";
|
||||
|
||||
private JLabel mToLabel = new JLabel( " " );
|
||||
private JLabel mTo = new JLabel( " " );
|
||||
private JLabel mToAlias = new JLabel( " " );
|
||||
private JLabel mToLabel = new JLabel(" ");
|
||||
private JLabel mTo = new JLabel(" ");
|
||||
private JLabel mToAlias = new JLabel(" ");
|
||||
|
||||
private JLabel mFromLabel = new JLabel( " " );
|
||||
private JLabel mFrom = new JLabel( " " );
|
||||
private JLabel mFromAlias = new JLabel( " " );
|
||||
|
||||
private JLabel mProtocol = new JLabel( PROTOCOL );
|
||||
private JLabel mMessage = new JLabel( " " );
|
||||
private JLabel mMessageType = new JLabel( " " );
|
||||
|
||||
public Fleetsync2DecoderPanel( SettingsManager settingsManager,
|
||||
Fleetsync2DecoderState decoderState )
|
||||
{
|
||||
super( settingsManager, decoderState );
|
||||
|
||||
init();
|
||||
}
|
||||
private JLabel mFromLabel = new JLabel(" ");
|
||||
private JLabel mFrom = new JLabel(" ");
|
||||
private JLabel mFromAlias = new JLabel(" ");
|
||||
|
||||
@Override
|
||||
public Fleetsync2DecoderState getDecoderState()
|
||||
{
|
||||
return (Fleetsync2DecoderState)super.getDecoderState();
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
protected void init()
|
||||
{
|
||||
/* Calling super init will get and broadcast color settings to properly
|
||||
* setup the jlabel colors */
|
||||
super.init();
|
||||
|
||||
setLayout( new MigLayout( "insets 1 0 0 0", "[grow,fill]", "[]0[]0[]") );
|
||||
private JLabel mProtocol = new JLabel(PROTOCOL);
|
||||
private JLabel mMessage = new JLabel(" ");
|
||||
private JLabel mMessageType = new JLabel(" ");
|
||||
|
||||
mToLabel.setFont( mFontAuxDecoder );
|
||||
mToLabel.setForeground( mColorLabelAuxDecoder );
|
||||
add( mToLabel );
|
||||
|
||||
mTo.setFont( mFontAuxDecoder );
|
||||
mTo.setForeground( mColorLabelAuxDecoder );
|
||||
add( mTo );
|
||||
|
||||
mToAlias.setFont( mFontAuxDecoder );
|
||||
mToAlias.setForeground( mColorLabelAuxDecoder );
|
||||
add( mToAlias, "wrap" );
|
||||
|
||||
mFromLabel.setFont( mFontAuxDecoder );
|
||||
mFromLabel.setForeground( mColorLabelAuxDecoder );
|
||||
add( mFromLabel );
|
||||
|
||||
mFrom.setFont( mFontAuxDecoder );
|
||||
mFrom.setForeground( mColorLabelAuxDecoder );
|
||||
add( mFrom );
|
||||
|
||||
mFromAlias.setFont( mFontAuxDecoder );
|
||||
mFromAlias.setForeground( mColorLabelAuxDecoder );
|
||||
add( mFromAlias, "wrap" );
|
||||
|
||||
mProtocol.setFont( mFontAuxDecoder );
|
||||
mProtocol.setForeground( mColorLabelAuxDecoder );
|
||||
add( mProtocol );
|
||||
|
||||
mMessageType.setFont( mFontAuxDecoder );
|
||||
mMessageType.setForeground( mColorLabelAuxDecoder );
|
||||
add( mMessageType );
|
||||
|
||||
mMessage.setFont( mFontAuxDecoder );
|
||||
mMessage.setForeground( mColorLabelAuxDecoder );
|
||||
add( mMessage, "wrap" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( final ChangedAttribute changedAttribute )
|
||||
public Fleetsync2DecoderPanel(IconManager iconManager, SettingsManager settingsManager,
|
||||
Fleetsync2DecoderState decoderState)
|
||||
{
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
super(iconManager, settingsManager, decoderState);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fleetsync2DecoderState getDecoderState()
|
||||
{
|
||||
return (Fleetsync2DecoderState) super.getDecoderState();
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
protected void init()
|
||||
{
|
||||
/* Calling super init will get and broadcast color settings to properly
|
||||
* setup the jlabel colors */
|
||||
super.init();
|
||||
|
||||
setLayout(new MigLayout("insets 1 0 0 0", "[grow,fill]", "[]0[]0[]"));
|
||||
|
||||
mToLabel.setFont(mFontAuxDecoder);
|
||||
mToLabel.setForeground(mColorLabelAuxDecoder);
|
||||
add(mToLabel);
|
||||
|
||||
mTo.setFont(mFontAuxDecoder);
|
||||
mTo.setForeground(mColorLabelAuxDecoder);
|
||||
add(mTo);
|
||||
|
||||
mToAlias.setFont(mFontAuxDecoder);
|
||||
mToAlias.setForeground(mColorLabelAuxDecoder);
|
||||
add(mToAlias, "wrap");
|
||||
|
||||
mFromLabel.setFont(mFontAuxDecoder);
|
||||
mFromLabel.setForeground(mColorLabelAuxDecoder);
|
||||
add(mFromLabel);
|
||||
|
||||
mFrom.setFont(mFontAuxDecoder);
|
||||
mFrom.setForeground(mColorLabelAuxDecoder);
|
||||
add(mFrom);
|
||||
|
||||
mFromAlias.setFont(mFontAuxDecoder);
|
||||
mFromAlias.setForeground(mColorLabelAuxDecoder);
|
||||
add(mFromAlias, "wrap");
|
||||
|
||||
mProtocol.setFont(mFontAuxDecoder);
|
||||
mProtocol.setForeground(mColorLabelAuxDecoder);
|
||||
add(mProtocol);
|
||||
|
||||
mMessageType.setFont(mFontAuxDecoder);
|
||||
mMessageType.setForeground(mColorLabelAuxDecoder);
|
||||
add(mMessageType);
|
||||
|
||||
mMessage.setFont(mFontAuxDecoder);
|
||||
mMessage.setForeground(mColorLabelAuxDecoder);
|
||||
add(mMessage, "wrap");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(final ChangedAttribute changedAttribute)
|
||||
{
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
switch( changedAttribute )
|
||||
{
|
||||
case FROM_TALKGROUP:
|
||||
String from = getDecoderState().getFromID();
|
||||
|
||||
if( from != null )
|
||||
{
|
||||
mFromLabel.setText( "FROM:" );
|
||||
mFrom.setText( from );
|
||||
}
|
||||
else
|
||||
{
|
||||
mFromLabel.setText( " " );
|
||||
mFrom.setText( " " );
|
||||
}
|
||||
break;
|
||||
case FROM_TALKGROUP_ALIAS:
|
||||
setAliasLabel( mFromAlias, getDecoderState().getFromIDAlias() );
|
||||
break;
|
||||
case MESSAGE:
|
||||
mMessage.setText( getDecoderState().getMessage() );
|
||||
break;
|
||||
case MESSAGE_TYPE:
|
||||
mMessageType.setText( getDecoderState().getMessageType() );
|
||||
break;
|
||||
case TO_TALKGROUP:
|
||||
String to = getDecoderState().getToID();
|
||||
|
||||
if( to != null )
|
||||
{
|
||||
mToLabel.setText( "TO:" );
|
||||
mTo.setText( to );
|
||||
}
|
||||
else
|
||||
{
|
||||
mToLabel.setText( " " );
|
||||
mTo.setText( " " );
|
||||
}
|
||||
break;
|
||||
case TO_TALKGROUP_ALIAS:
|
||||
setAliasLabel( mToAlias, getDecoderState().getToIDAlias() );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
repaint();
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingChanged( Setting setting )
|
||||
{
|
||||
super.settingChanged( setting );
|
||||
|
||||
if( setting instanceof ColorSetting )
|
||||
{
|
||||
ColorSetting color = (ColorSetting)setting;
|
||||
switch(changedAttribute)
|
||||
{
|
||||
case FROM_TALKGROUP:
|
||||
String from = getDecoderState().getFromID();
|
||||
|
||||
if( color.getColorSettingName() ==
|
||||
ColorSettingName.CHANNEL_STATE_LABEL_AUX_DECODER )
|
||||
{
|
||||
mFromLabel.setForeground( color.getColor() );
|
||||
mFrom.setForeground( color.getColor() );
|
||||
mFromAlias.setForeground( color.getColor() );
|
||||
mToLabel.setForeground( color.getColor() );
|
||||
mTo.setForeground( color.getColor() );
|
||||
mToAlias.setForeground( color.getColor() );
|
||||
mProtocol.setForeground( color.getColor() );
|
||||
mMessageType.setForeground( color.getColor() );
|
||||
mMessage.setForeground( color.getColor() );
|
||||
}
|
||||
}
|
||||
if(from != null)
|
||||
{
|
||||
mFromLabel.setText("FROM:");
|
||||
mFrom.setText(from);
|
||||
}
|
||||
else
|
||||
{
|
||||
mFromLabel.setText(" ");
|
||||
mFrom.setText(" ");
|
||||
}
|
||||
break;
|
||||
case FROM_TALKGROUP_ALIAS:
|
||||
setAliasLabel(mFromAlias, getDecoderState().getFromIDAlias());
|
||||
break;
|
||||
case MESSAGE:
|
||||
mMessage.setText(getDecoderState().getMessage());
|
||||
break;
|
||||
case MESSAGE_TYPE:
|
||||
mMessageType.setText(getDecoderState().getMessageType());
|
||||
break;
|
||||
case TO_TALKGROUP:
|
||||
String to = getDecoderState().getToID();
|
||||
|
||||
if(to != null)
|
||||
{
|
||||
mToLabel.setText("TO:");
|
||||
mTo.setText(to);
|
||||
}
|
||||
else
|
||||
{
|
||||
mToLabel.setText(" ");
|
||||
mTo.setText(" ");
|
||||
}
|
||||
break;
|
||||
case TO_TALKGROUP_ALIAS:
|
||||
setAliasLabel(mToAlias, getDecoderState().getToIDAlias());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
repaint();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingChanged(Setting setting)
|
||||
{
|
||||
super.settingChanged(setting);
|
||||
|
||||
if(setting instanceof ColorSetting)
|
||||
{
|
||||
ColorSetting color = (ColorSetting) setting;
|
||||
|
||||
if(color.getColorSettingName() ==
|
||||
ColorSettingName.CHANNEL_STATE_LABEL_AUX_DECODER)
|
||||
{
|
||||
mFromLabel.setForeground(color.getColor());
|
||||
mFrom.setForeground(color.getColor());
|
||||
mFromAlias.setForeground(color.getColor());
|
||||
mToLabel.setForeground(color.getColor());
|
||||
mTo.setForeground(color.getColor());
|
||||
mToAlias.setForeground(color.getColor());
|
||||
mProtocol.setForeground(color.getColor());
|
||||
mMessageType.setForeground(color.getColor());
|
||||
mMessage.setForeground(color.getColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014,2015 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/>
|
||||
* 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 module.decode.lj1200;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import alias.Alias;
|
||||
import icon.IconManager;
|
||||
import module.decode.state.ChangedAttribute;
|
||||
import module.decode.state.DecoderPanel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
@@ -28,98 +28,100 @@ import settings.ColorSetting.ColorSettingName;
|
||||
import settings.Setting;
|
||||
import settings.SettingsManager;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class LJ1200DecoderPanel extends DecoderPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final String PROTOCOL = "LJ-1200";
|
||||
|
||||
private JLabel mProtocol = new JLabel( PROTOCOL );
|
||||
private JLabel mProtocol = new JLabel(PROTOCOL);
|
||||
private JLabel mTo = new JLabel();
|
||||
private JLabel mToAlias = new JLabel();
|
||||
|
||||
public LJ1200DecoderPanel( SettingsManager settingsManager, LJ1200DecoderState decoderState )
|
||||
{
|
||||
super( settingsManager, decoderState );
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
protected void init()
|
||||
{
|
||||
/* Calling super init will get and broadcast color settings to properly
|
||||
* setup the jlabel colors */
|
||||
super.init();
|
||||
|
||||
setLayout( new MigLayout( "insets 1 0 0 0", "[grow,fill]", "" ) );
|
||||
|
||||
mProtocol.setFont( mFontDecoder );
|
||||
mProtocol.setForeground( mColorLabelDecoder );
|
||||
|
||||
mTo.setFont( mFontDecoder );
|
||||
mTo.setForeground( mColorLabelDecoder );
|
||||
|
||||
mToAlias.setFont( mFontDecoder );
|
||||
mToAlias.setForeground( mColorLabelDecoder );
|
||||
|
||||
add( mProtocol );
|
||||
add( mTo );
|
||||
add( mToAlias, "wrap" );
|
||||
}
|
||||
|
||||
public LJ1200DecoderState getDecoderState()
|
||||
{
|
||||
return (LJ1200DecoderState)super.getDecoderState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( final ChangedAttribute changedAttribute )
|
||||
public LJ1200DecoderPanel(IconManager iconManager, SettingsManager settingsManager, LJ1200DecoderState decoderState)
|
||||
{
|
||||
switch( changedAttribute )
|
||||
{
|
||||
case TO_TALKGROUP:
|
||||
mTo.setText( getDecoderState().getAddress() );
|
||||
repaint();
|
||||
break;
|
||||
case TO_TALKGROUP_ALIAS:
|
||||
Alias alias = getDecoderState().getAddressAlias();
|
||||
|
||||
if( alias != null )
|
||||
{
|
||||
mToAlias.setText( alias.getName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
mToAlias.setText( "" );
|
||||
}
|
||||
|
||||
repaint();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
super(iconManager, settingsManager, decoderState);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingChanged( Setting setting )
|
||||
{
|
||||
super.settingChanged( setting );
|
||||
|
||||
if( setting instanceof ColorSetting )
|
||||
{
|
||||
ColorSetting color = (ColorSetting)setting;
|
||||
|
||||
if( color.getColorSettingName() ==
|
||||
ColorSettingName.CHANNEL_STATE_LABEL_AUX_DECODER )
|
||||
{
|
||||
mProtocol.setForeground( color.getColor() );
|
||||
mTo.setForeground( color.getColor() );
|
||||
mToAlias.setForeground( color.getColor() );
|
||||
}
|
||||
}
|
||||
public void dispose()
|
||||
{
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
protected void init()
|
||||
{
|
||||
/* Calling super init will get and broadcast color settings to properly
|
||||
* setup the jlabel colors */
|
||||
super.init();
|
||||
|
||||
setLayout(new MigLayout("insets 1 0 0 0", "[grow,fill]", ""));
|
||||
|
||||
mProtocol.setFont(mFontDecoder);
|
||||
mProtocol.setForeground(mColorLabelDecoder);
|
||||
|
||||
mTo.setFont(mFontDecoder);
|
||||
mTo.setForeground(mColorLabelDecoder);
|
||||
|
||||
mToAlias.setFont(mFontDecoder);
|
||||
mToAlias.setForeground(mColorLabelDecoder);
|
||||
|
||||
add(mProtocol);
|
||||
add(mTo);
|
||||
add(mToAlias, "wrap");
|
||||
}
|
||||
|
||||
public LJ1200DecoderState getDecoderState()
|
||||
{
|
||||
return (LJ1200DecoderState) super.getDecoderState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(final ChangedAttribute changedAttribute)
|
||||
{
|
||||
switch(changedAttribute)
|
||||
{
|
||||
case TO_TALKGROUP:
|
||||
mTo.setText(getDecoderState().getAddress());
|
||||
repaint();
|
||||
break;
|
||||
case TO_TALKGROUP_ALIAS:
|
||||
Alias alias = getDecoderState().getAddressAlias();
|
||||
|
||||
if(alias != null)
|
||||
{
|
||||
mToAlias.setText(alias.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
mToAlias.setText("");
|
||||
}
|
||||
|
||||
repaint();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingChanged(Setting setting)
|
||||
{
|
||||
super.settingChanged(setting);
|
||||
|
||||
if(setting instanceof ColorSetting)
|
||||
{
|
||||
ColorSetting color = (ColorSetting) setting;
|
||||
|
||||
if(color.getColorSettingName() ==
|
||||
ColorSettingName.CHANNEL_STATE_LABEL_AUX_DECODER)
|
||||
{
|
||||
mProtocol.setForeground(color.getColor());
|
||||
mTo.setForeground(color.getColor());
|
||||
mToAlias.setForeground(color.getColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,157 +1,157 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* 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 module.decode.ltrnet;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import alias.Alias;
|
||||
import icon.IconManager;
|
||||
import module.decode.state.ChangedAttribute;
|
||||
import module.decode.state.DecoderPanel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import settings.ColorSetting;
|
||||
import settings.Setting;
|
||||
import settings.SettingsManager;
|
||||
import alias.Alias;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class LTRNetDecoderPanel extends DecoderPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private JLabel mProtocol = new JLabel( "LTR-Net" );
|
||||
|
||||
private JLabel mProtocol = new JLabel("LTR-Net");
|
||||
private JLabel mTalkgroup = new JLabel();
|
||||
private JLabel mTalkgroupAlias = new JLabel();
|
||||
|
||||
private JLabel mLCN = new JLabel( "LCN:" );
|
||||
private JLabel mLCN = new JLabel("LCN:");
|
||||
private JLabel mDescription = new JLabel();
|
||||
|
||||
public LTRNetDecoderPanel( SettingsManager settingsManager,
|
||||
LTRNetDecoderState decoderState )
|
||||
{
|
||||
super( settingsManager, decoderState );
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
setLayout( new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[]0[]0[]") );
|
||||
|
||||
mProtocol.setFont( mFontDecoder );
|
||||
mProtocol.setForeground( mColorLabelDecoder );
|
||||
|
||||
mTalkgroup.setFont( mFontDecoder );
|
||||
mTalkgroup.setForeground( mColorLabelDecoder );
|
||||
|
||||
mTalkgroupAlias.setFont( mFontDecoder );
|
||||
mTalkgroupAlias.setForeground( mColorLabelDecoder );
|
||||
|
||||
mLCN.setFont( mFontDecoder );
|
||||
mLCN.setForeground( mColorLabelDecoder );
|
||||
|
||||
mDescription.setFont( mFontDecoder );
|
||||
mDescription.setForeground( mColorLabelDecoder );
|
||||
|
||||
add( mProtocol );
|
||||
add( mTalkgroup );
|
||||
add( mTalkgroupAlias, "wrap" );
|
||||
|
||||
add( mLCN );
|
||||
add( mDescription, "span" );
|
||||
}
|
||||
|
||||
public LTRNetDecoderState getDecoderState()
|
||||
{
|
||||
return (LTRNetDecoderState)super.getDecoderState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( final ChangedAttribute changedAttribute )
|
||||
public LTRNetDecoderPanel(IconManager iconManager, SettingsManager settingsManager, LTRNetDecoderState decoderState)
|
||||
{
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
super(iconManager, settingsManager, decoderState);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[]0[]0[]"));
|
||||
|
||||
mProtocol.setFont(mFontDecoder);
|
||||
mProtocol.setForeground(mColorLabelDecoder);
|
||||
|
||||
mTalkgroup.setFont(mFontDecoder);
|
||||
mTalkgroup.setForeground(mColorLabelDecoder);
|
||||
|
||||
mTalkgroupAlias.setFont(mFontDecoder);
|
||||
mTalkgroupAlias.setForeground(mColorLabelDecoder);
|
||||
|
||||
mLCN.setFont(mFontDecoder);
|
||||
mLCN.setForeground(mColorLabelDecoder);
|
||||
|
||||
mDescription.setFont(mFontDecoder);
|
||||
mDescription.setForeground(mColorLabelDecoder);
|
||||
|
||||
add(mProtocol);
|
||||
add(mTalkgroup);
|
||||
add(mTalkgroupAlias, "wrap");
|
||||
|
||||
add(mLCN);
|
||||
add(mDescription, "span");
|
||||
}
|
||||
|
||||
public LTRNetDecoderState getDecoderState()
|
||||
{
|
||||
return (LTRNetDecoderState) super.getDecoderState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(final ChangedAttribute changedAttribute)
|
||||
{
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
LTRNetDecoderState state = getDecoderState();
|
||||
LTRNetDecoderState state = getDecoderState();
|
||||
|
||||
switch( changedAttribute )
|
||||
{
|
||||
case TO_TALKGROUP:
|
||||
mTalkgroup.setText( state.getToTalkgroup() );
|
||||
break;
|
||||
case TO_TALKGROUP_ALIAS:
|
||||
Alias tgAlias = state.getToTalkgroupAlias();
|
||||
setAliasLabel( mTalkgroupAlias, tgAlias );
|
||||
break;
|
||||
case DESCRIPTION:
|
||||
mDescription.setText( state.getDescription() );
|
||||
break;
|
||||
case CHANNEL_NUMBER:
|
||||
mLCN.setText( "LCN: " + state.getChannelNumber() );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
repaint();
|
||||
switch(changedAttribute)
|
||||
{
|
||||
case TO_TALKGROUP:
|
||||
mTalkgroup.setText(state.getToTalkgroup());
|
||||
break;
|
||||
case TO_TALKGROUP_ALIAS:
|
||||
Alias tgAlias = state.getToTalkgroupAlias();
|
||||
setAliasLabel(mTalkgroupAlias, tgAlias);
|
||||
break;
|
||||
case DESCRIPTION:
|
||||
mDescription.setText(state.getDescription());
|
||||
break;
|
||||
case CHANNEL_NUMBER:
|
||||
mLCN.setText("LCN: " + state.getChannelNumber());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
repaint();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingChanged( Setting setting )
|
||||
@Override
|
||||
public void settingChanged(Setting setting)
|
||||
{
|
||||
super.settingChanged( setting );
|
||||
|
||||
if( setting instanceof ColorSetting )
|
||||
{
|
||||
ColorSetting colorSetting = (ColorSetting)setting;
|
||||
|
||||
switch( colorSetting.getColorSettingName() )
|
||||
{
|
||||
case CHANNEL_STATE_LABEL_DECODER:
|
||||
if( mProtocol != null )
|
||||
{
|
||||
mProtocol.setForeground( mColorLabelDecoder );
|
||||
}
|
||||
if( mTalkgroup != null )
|
||||
{
|
||||
mTalkgroup.setForeground( mColorLabelDecoder );
|
||||
}
|
||||
if( mTalkgroupAlias != null )
|
||||
{
|
||||
mTalkgroupAlias.setForeground( mColorLabelDecoder );
|
||||
}
|
||||
if( mLCN != null )
|
||||
{
|
||||
mLCN.setForeground( mColorLabelDecoder );
|
||||
}
|
||||
if( mDescription != null )
|
||||
{
|
||||
mDescription.setForeground( mColorLabelDecoder );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
super.settingChanged(setting);
|
||||
|
||||
if(setting instanceof ColorSetting)
|
||||
{
|
||||
ColorSetting colorSetting = (ColorSetting) setting;
|
||||
|
||||
switch(colorSetting.getColorSettingName())
|
||||
{
|
||||
case CHANNEL_STATE_LABEL_DECODER:
|
||||
if(mProtocol != null)
|
||||
{
|
||||
mProtocol.setForeground(mColorLabelDecoder);
|
||||
}
|
||||
if(mTalkgroup != null)
|
||||
{
|
||||
mTalkgroup.setForeground(mColorLabelDecoder);
|
||||
}
|
||||
if(mTalkgroupAlias != null)
|
||||
{
|
||||
mTalkgroupAlias.setForeground(mColorLabelDecoder);
|
||||
}
|
||||
if(mLCN != null)
|
||||
{
|
||||
mLCN.setForeground(mColorLabelDecoder);
|
||||
}
|
||||
if(mDescription != null)
|
||||
{
|
||||
mDescription.setForeground(mColorLabelDecoder);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,163 +1,164 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* 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 module.decode.ltrstandard;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import alias.Alias;
|
||||
import icon.IconManager;
|
||||
import module.decode.state.ChangedAttribute;
|
||||
import module.decode.state.DecoderPanel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import settings.ColorSetting;
|
||||
import settings.Setting;
|
||||
import settings.SettingsManager;
|
||||
import alias.Alias;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class LTRStandardDecoderPanel extends DecoderPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private JLabel mProtocol = new JLabel( "LTR Standard" );
|
||||
private JLabel mProtocol = new JLabel("LTR Standard");
|
||||
private JLabel mTalkgroup = new JLabel();
|
||||
private JLabel mTalkgroupAlias = new JLabel();
|
||||
|
||||
private JLabel mLCN = new JLabel( "LCN:" );
|
||||
|
||||
public LTRStandardDecoderPanel( SettingsManager settingsManager,
|
||||
LTRStandardDecoderState decoderState )
|
||||
{
|
||||
super( settingsManager, decoderState );
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
setLayout( new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[]0[]0[]") );
|
||||
private JLabel mLCN = new JLabel("LCN:");
|
||||
|
||||
mProtocol.setFont( mFontDecoder );
|
||||
mProtocol.setForeground( mColorLabelDecoder );
|
||||
public LTRStandardDecoderPanel(IconManager iconManager, SettingsManager settingsManager,
|
||||
LTRStandardDecoderState decoderState)
|
||||
{
|
||||
super(iconManager, settingsManager, decoderState);
|
||||
|
||||
mTalkgroup.setFont( mFontDecoder );
|
||||
mTalkgroup.setForeground( mColorLabelDecoder );
|
||||
init();
|
||||
}
|
||||
|
||||
mTalkgroupAlias.setFont( mFontDecoder );
|
||||
mTalkgroupAlias.setForeground( mColorLabelDecoder );
|
||||
public void dispose()
|
||||
{
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
mLCN.setFont( mFontDecoder );
|
||||
mLCN.setForeground( mColorLabelDecoder );
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
add( mProtocol );
|
||||
add( mTalkgroup );
|
||||
add( mTalkgroupAlias, "wrap" );
|
||||
|
||||
add( mLCN, "wrap" );
|
||||
}
|
||||
|
||||
public LTRStandardDecoderState getDecoderState()
|
||||
{
|
||||
return (LTRStandardDecoderState)super.getDecoderState();
|
||||
}
|
||||
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[]0[]0[]"));
|
||||
|
||||
mProtocol.setFont(mFontDecoder);
|
||||
mProtocol.setForeground(mColorLabelDecoder);
|
||||
|
||||
mTalkgroup.setFont(mFontDecoder);
|
||||
mTalkgroup.setForeground(mColorLabelDecoder);
|
||||
|
||||
mTalkgroupAlias.setFont(mFontDecoder);
|
||||
mTalkgroupAlias.setForeground(mColorLabelDecoder);
|
||||
|
||||
mLCN.setFont(mFontDecoder);
|
||||
mLCN.setForeground(mColorLabelDecoder);
|
||||
|
||||
add(mProtocol);
|
||||
add(mTalkgroup);
|
||||
add(mTalkgroupAlias, "wrap");
|
||||
|
||||
add(mLCN, "wrap");
|
||||
}
|
||||
|
||||
public LTRStandardDecoderState getDecoderState()
|
||||
{
|
||||
return (LTRStandardDecoderState) super.getDecoderState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( final ChangedAttribute attribute )
|
||||
public void receive(final ChangedAttribute attribute)
|
||||
{
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
LTRStandardDecoderState state = getDecoderState();
|
||||
|
||||
switch( attribute )
|
||||
{
|
||||
case CHANNEL_NUMBER:
|
||||
if( state.getChannelNumber() != 0 )
|
||||
{
|
||||
mLCN.setText( "LCN: " + state.getChannelNumber() );
|
||||
}
|
||||
break;
|
||||
case TO_TALKGROUP:
|
||||
mTalkgroup.setText( state.getTalkgroup() );
|
||||
/* fall-through */
|
||||
case TO_TALKGROUP_ALIAS:
|
||||
Alias alias = state.getTalkgroupAlias();
|
||||
|
||||
if( alias != null )
|
||||
{
|
||||
mTalkgroupAlias.setText( alias.getName() );
|
||||
mTalkgroupAlias.setIcon( mSettingsManager
|
||||
.getImageIcon( alias.getIconName(), SettingsManager.DEFAULT_ICON_SIZE ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
mTalkgroupAlias.setText( null );
|
||||
mTalkgroupAlias.setIcon( null );
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
repaint();
|
||||
LTRStandardDecoderState state = getDecoderState();
|
||||
|
||||
switch(attribute)
|
||||
{
|
||||
case CHANNEL_NUMBER:
|
||||
if(state.getChannelNumber() != 0)
|
||||
{
|
||||
mLCN.setText("LCN: " + state.getChannelNumber());
|
||||
}
|
||||
break;
|
||||
case TO_TALKGROUP:
|
||||
mTalkgroup.setText(state.getTalkgroup());
|
||||
/* fall-through */
|
||||
case TO_TALKGROUP_ALIAS:
|
||||
Alias alias = state.getTalkgroupAlias();
|
||||
|
||||
if(alias != null)
|
||||
{
|
||||
mTalkgroupAlias.setText(alias.getName());
|
||||
mTalkgroupAlias.setIcon(mIconManager.getIcon(alias.getIconName(),
|
||||
IconManager.DEFAULT_ICON_SIZE));
|
||||
}
|
||||
else
|
||||
{
|
||||
mTalkgroupAlias.setText(null);
|
||||
mTalkgroupAlias.setIcon(null);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
repaint();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingChanged( Setting setting )
|
||||
@Override
|
||||
public void settingChanged(Setting setting)
|
||||
{
|
||||
super.settingChanged( setting );
|
||||
|
||||
if( setting instanceof ColorSetting )
|
||||
{
|
||||
ColorSetting colorSetting = (ColorSetting)setting;
|
||||
|
||||
switch( colorSetting.getColorSettingName() )
|
||||
{
|
||||
case CHANNEL_STATE_LABEL_DECODER:
|
||||
if( mProtocol != null )
|
||||
{
|
||||
mProtocol.setForeground( mColorLabelDecoder );
|
||||
}
|
||||
if( mTalkgroup != null )
|
||||
{
|
||||
mTalkgroup.setForeground( mColorLabelDecoder );
|
||||
}
|
||||
if( mTalkgroupAlias != null )
|
||||
{
|
||||
mTalkgroupAlias.setForeground( mColorLabelDecoder );
|
||||
}
|
||||
if( mLCN != null )
|
||||
{
|
||||
mLCN.setForeground( mColorLabelDecoder );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
super.settingChanged(setting);
|
||||
|
||||
if(setting instanceof ColorSetting)
|
||||
{
|
||||
ColorSetting colorSetting = (ColorSetting) setting;
|
||||
|
||||
switch(colorSetting.getColorSettingName())
|
||||
{
|
||||
case CHANNEL_STATE_LABEL_DECODER:
|
||||
if(mProtocol != null)
|
||||
{
|
||||
mProtocol.setForeground(mColorLabelDecoder);
|
||||
}
|
||||
if(mTalkgroup != null)
|
||||
{
|
||||
mTalkgroup.setForeground(mColorLabelDecoder);
|
||||
}
|
||||
if(mTalkgroupAlias != null)
|
||||
{
|
||||
mTalkgroupAlias.setForeground(mColorLabelDecoder);
|
||||
}
|
||||
if(mLCN != null)
|
||||
{
|
||||
mLCN.setForeground(mColorLabelDecoder);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,27 +1,25 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* 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 module.decode.mdc1200;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import alias.Alias;
|
||||
import icon.IconManager;
|
||||
import module.decode.state.ChangedAttribute;
|
||||
import module.decode.state.DecoderPanel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
@@ -30,154 +28,156 @@ import settings.ColorSetting.ColorSettingName;
|
||||
import settings.Setting;
|
||||
import settings.SettingsManager;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class MDCDecoderPanel extends DecoderPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final String sPROTOCOL = "MDC-1200";
|
||||
|
||||
private JLabel mFromLabel = new JLabel( " " );
|
||||
private JLabel mFromLabel = new JLabel(" ");
|
||||
private JLabel mFrom = new JLabel();
|
||||
private JLabel mFromAlias = new JLabel();
|
||||
|
||||
private JLabel mToLabel = new JLabel( " " );
|
||||
|
||||
private JLabel mToLabel = new JLabel(" ");
|
||||
private JLabel mTo = new JLabel();
|
||||
private JLabel mToAlias = new JLabel();
|
||||
|
||||
private JLabel mProtocol = new JLabel( sPROTOCOL );
|
||||
private JLabel mProtocol = new JLabel(sPROTOCOL);
|
||||
private JLabel mMessage = new JLabel();
|
||||
private JLabel mMessageType = new JLabel();
|
||||
|
||||
public MDCDecoderPanel( SettingsManager settingsManager,
|
||||
MDCDecoderState decoderState )
|
||||
{
|
||||
super( settingsManager, decoderState );
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public MDCDecoderState getDecoderState()
|
||||
{
|
||||
return (MDCDecoderState)super.getDecoderState();
|
||||
}
|
||||
|
||||
protected void init()
|
||||
{
|
||||
/* Calling super init will get and broadcast color settings to properly
|
||||
* setup the jlabel colors */
|
||||
super.init();
|
||||
|
||||
setLayout( new MigLayout( "insets 1 0 0 0", "[grow,fill]", "[]0[]0[]") );
|
||||
private JLabel mMessageType = new JLabel();
|
||||
|
||||
add( mFromLabel );
|
||||
add( mFrom );
|
||||
add( mFromAlias, "wrap" );
|
||||
|
||||
add( mToLabel );
|
||||
add( mTo );
|
||||
add( mToAlias, "wrap" );
|
||||
|
||||
add( mProtocol );
|
||||
add( mMessageType );
|
||||
add( mMessage, "wrap" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( final ChangedAttribute changedAttribute )
|
||||
public MDCDecoderPanel(IconManager iconManager, SettingsManager settingsManager, MDCDecoderState decoderState)
|
||||
{
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
super(iconManager, settingsManager, decoderState);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public MDCDecoderState getDecoderState()
|
||||
{
|
||||
return (MDCDecoderState) super.getDecoderState();
|
||||
}
|
||||
|
||||
protected void init()
|
||||
{
|
||||
/* Calling super init will get and broadcast color settings to properly
|
||||
* setup the jlabel colors */
|
||||
super.init();
|
||||
|
||||
setLayout(new MigLayout("insets 1 0 0 0", "[grow,fill]", "[]0[]0[]"));
|
||||
|
||||
add(mFromLabel);
|
||||
add(mFrom);
|
||||
add(mFromAlias, "wrap");
|
||||
|
||||
add(mToLabel);
|
||||
add(mTo);
|
||||
add(mToAlias, "wrap");
|
||||
|
||||
add(mProtocol);
|
||||
add(mMessageType);
|
||||
add(mMessage, "wrap");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(final ChangedAttribute changedAttribute)
|
||||
{
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
switch( changedAttribute )
|
||||
{
|
||||
case FROM_TALKGROUP:
|
||||
String from = getDecoderState().getFrom();
|
||||
|
||||
if( from != null )
|
||||
{
|
||||
mFromLabel.setText( "FM:" );
|
||||
}
|
||||
else
|
||||
{
|
||||
mFromLabel.setText( " " );
|
||||
}
|
||||
mFrom.setText( from );
|
||||
break;
|
||||
case FROM_TALKGROUP_ALIAS:
|
||||
Alias fromAlias = getDecoderState().getFromAlias();
|
||||
|
||||
if( fromAlias != null )
|
||||
{
|
||||
mFromAlias.setText( fromAlias.getName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
mFromAlias.setText( null );
|
||||
}
|
||||
break;
|
||||
case TO_TALKGROUP:
|
||||
String to = getDecoderState().getTo();
|
||||
|
||||
if( to != null )
|
||||
{
|
||||
mToLabel.setText( "TO:" );
|
||||
}
|
||||
else
|
||||
{
|
||||
mToLabel.setText( " " );
|
||||
}
|
||||
mTo.setText( to );
|
||||
break;
|
||||
case TO_TALKGROUP_ALIAS:
|
||||
Alias toAlias = getDecoderState().getToAlias();
|
||||
|
||||
if( toAlias != null )
|
||||
{
|
||||
mToAlias.setText( toAlias.getName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
mToAlias.setText( null );
|
||||
}
|
||||
break;
|
||||
case MESSAGE:
|
||||
mMessage.setText( getDecoderState().getMessage() );
|
||||
break;
|
||||
case MESSAGE_TYPE:
|
||||
mMessageType.setText( getDecoderState().getMessageType() );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
repaint();
|
||||
switch(changedAttribute)
|
||||
{
|
||||
case FROM_TALKGROUP:
|
||||
String from = getDecoderState().getFrom();
|
||||
|
||||
if(from != null)
|
||||
{
|
||||
mFromLabel.setText("FM:");
|
||||
}
|
||||
else
|
||||
{
|
||||
mFromLabel.setText(" ");
|
||||
}
|
||||
mFrom.setText(from);
|
||||
break;
|
||||
case FROM_TALKGROUP_ALIAS:
|
||||
Alias fromAlias = getDecoderState().getFromAlias();
|
||||
|
||||
if(fromAlias != null)
|
||||
{
|
||||
mFromAlias.setText(fromAlias.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
mFromAlias.setText(null);
|
||||
}
|
||||
break;
|
||||
case TO_TALKGROUP:
|
||||
String to = getDecoderState().getTo();
|
||||
|
||||
if(to != null)
|
||||
{
|
||||
mToLabel.setText("TO:");
|
||||
}
|
||||
else
|
||||
{
|
||||
mToLabel.setText(" ");
|
||||
}
|
||||
mTo.setText(to);
|
||||
break;
|
||||
case TO_TALKGROUP_ALIAS:
|
||||
Alias toAlias = getDecoderState().getToAlias();
|
||||
|
||||
if(toAlias != null)
|
||||
{
|
||||
mToAlias.setText(toAlias.getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
mToAlias.setText(null);
|
||||
}
|
||||
break;
|
||||
case MESSAGE:
|
||||
mMessage.setText(getDecoderState().getMessage());
|
||||
break;
|
||||
case MESSAGE_TYPE:
|
||||
mMessageType.setText(getDecoderState().getMessageType());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
repaint();
|
||||
}
|
||||
} );
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingChanged( Setting setting )
|
||||
@Override
|
||||
public void settingChanged(Setting setting)
|
||||
{
|
||||
super.settingChanged( setting );
|
||||
|
||||
if( setting instanceof ColorSetting )
|
||||
{
|
||||
ColorSetting color = (ColorSetting)setting;
|
||||
super.settingChanged(setting);
|
||||
|
||||
if( color.getColorSettingName() ==
|
||||
ColorSettingName.CHANNEL_STATE_LABEL_AUX_DECODER )
|
||||
{
|
||||
mFromLabel.setForeground( color.getColor() );
|
||||
mFrom.setForeground( color.getColor() );
|
||||
mFromAlias.setForeground( color.getColor() );
|
||||
mToLabel.setForeground( color.getColor() );
|
||||
mTo.setForeground( color.getColor() );
|
||||
mToAlias.setForeground( color.getColor() );
|
||||
mProtocol.setForeground( color.getColor() );
|
||||
mMessageType.setForeground( color.getColor() );
|
||||
mMessage.setForeground( color.getColor() );
|
||||
}
|
||||
}
|
||||
if(setting instanceof ColorSetting)
|
||||
{
|
||||
ColorSetting color = (ColorSetting) setting;
|
||||
|
||||
if(color.getColorSettingName() ==
|
||||
ColorSettingName.CHANNEL_STATE_LABEL_AUX_DECODER)
|
||||
{
|
||||
mFromLabel.setForeground(color.getColor());
|
||||
mFrom.setForeground(color.getColor());
|
||||
mFromAlias.setForeground(color.getColor());
|
||||
mToLabel.setForeground(color.getColor());
|
||||
mTo.setForeground(color.getColor());
|
||||
mToAlias.setForeground(color.getColor());
|
||||
mProtocol.setForeground(color.getColor());
|
||||
mMessageType.setForeground(color.getColor());
|
||||
mMessage.setForeground(color.getColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,200 +1,200 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* 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 module.decode.mpt1327;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import controller.channel.Channel.ChannelType;
|
||||
import icon.IconManager;
|
||||
import module.decode.state.ChangedAttribute;
|
||||
import module.decode.state.DecoderPanel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import settings.ColorSetting;
|
||||
import settings.Setting;
|
||||
import settings.SettingsManager;
|
||||
import controller.channel.Channel.ChannelType;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class MPT1327DecoderPanel extends DecoderPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private JLabel mProtocol = new JLabel( "" );
|
||||
private JLabel mSiteOrToTalkgroup = new JLabel( "" );
|
||||
private JLabel mSiteOrToTalkgroupAlias = new JLabel( "" );
|
||||
|
||||
private JLabel mFromTalkgroupLabel = new JLabel( "" );
|
||||
private JLabel mFromTalkgroup = new JLabel( "" );
|
||||
private JLabel mFromTalkgroupAliasLabel = new JLabel( "" );
|
||||
|
||||
public MPT1327DecoderPanel( SettingsManager settingsManager,
|
||||
MPT1327DecoderState decoderState )
|
||||
{
|
||||
super( settingsManager, decoderState );
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
private JLabel mProtocol = new JLabel("");
|
||||
private JLabel mSiteOrToTalkgroup = new JLabel("");
|
||||
private JLabel mSiteOrToTalkgroupAlias = new JLabel("");
|
||||
|
||||
private JLabel mFromTalkgroupLabel = new JLabel("");
|
||||
private JLabel mFromTalkgroup = new JLabel("");
|
||||
private JLabel mFromTalkgroupAliasLabel = new JLabel("");
|
||||
|
||||
public MPT1327DecoderPanel(IconManager iconManager, SettingsManager settingsManager, MPT1327DecoderState decoderState)
|
||||
{
|
||||
super(iconManager, settingsManager, decoderState);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public MPT1327DecoderState getDecoderState()
|
||||
{
|
||||
return (MPT1327DecoderState)super.getDecoderState();
|
||||
return (MPT1327DecoderState) super.getDecoderState();
|
||||
}
|
||||
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
super.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
setLayout( new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[]0[]0[]") );
|
||||
|
||||
mProtocol.setText( "MPT1327" );
|
||||
mProtocol.setFont( mFontDecoder );
|
||||
mProtocol.setForeground( mColorLabelDecoder );
|
||||
|
||||
MPT1327DecoderState mptState = getDecoderState();
|
||||
|
||||
mSiteOrToTalkgroup.setFont( mFontDecoder );
|
||||
mSiteOrToTalkgroup.setForeground( mColorLabelDecoder );
|
||||
|
||||
mSiteOrToTalkgroupAlias.setFont( mFontDecoder );
|
||||
mSiteOrToTalkgroupAlias.setForeground( mColorLabelDecoder );
|
||||
|
||||
mFromTalkgroupLabel.setFont( mFontDetails );
|
||||
mFromTalkgroupLabel.setForeground( mColorLabelDetails );
|
||||
|
||||
mFromTalkgroup.setFont( mFontDecoder );
|
||||
mFromTalkgroup.setForeground( mColorLabelDecoder );
|
||||
|
||||
mFromTalkgroupAliasLabel.setFont( mFontDecoder );
|
||||
mFromTalkgroupAliasLabel.setForeground( mColorLabelDecoder );
|
||||
|
||||
|
||||
switch( mptState.getChannelType() )
|
||||
{
|
||||
case STANDARD:
|
||||
mSiteOrToTalkgroup.setText( mptState.getSite() );
|
||||
setAliasLabel( mSiteOrToTalkgroupAlias, mptState.getSiteAlias() );
|
||||
break;
|
||||
case TRAFFIC:
|
||||
mSiteOrToTalkgroup.setText( mptState.getToTalkgroup() );
|
||||
setAliasLabel( mSiteOrToTalkgroupAlias, mptState.getToTalkgroupAlias() );
|
||||
|
||||
mFromTalkgroupLabel.setText( "From:" );
|
||||
mFromTalkgroup.setText( getDecoderState().getFromTalkgroup() );
|
||||
setAliasLabel( mFromTalkgroupAliasLabel, mptState.getFromTalkgroupAlias() );
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException( "Unrecognized channel "
|
||||
+ "type in MPT1327 Decoder [" + getDecoderState()
|
||||
.getChannelType().name() + "]" );
|
||||
}
|
||||
|
||||
add( mProtocol );
|
||||
add( mSiteOrToTalkgroup );
|
||||
add( mSiteOrToTalkgroupAlias, "wrap" );
|
||||
|
||||
if( mptState.getChannelType() == ChannelType.TRAFFIC )
|
||||
{
|
||||
add( mFromTalkgroupLabel );
|
||||
add( mFromTalkgroup );
|
||||
add( mFromTalkgroupAliasLabel, "wrap" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( final ChangedAttribute changedAttribute )
|
||||
public void init()
|
||||
{
|
||||
final MPT1327DecoderState state = getDecoderState();
|
||||
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
super.init();
|
||||
|
||||
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[]0[]0[]"));
|
||||
|
||||
mProtocol.setText("MPT1327");
|
||||
mProtocol.setFont(mFontDecoder);
|
||||
mProtocol.setForeground(mColorLabelDecoder);
|
||||
|
||||
MPT1327DecoderState mptState = getDecoderState();
|
||||
|
||||
mSiteOrToTalkgroup.setFont(mFontDecoder);
|
||||
mSiteOrToTalkgroup.setForeground(mColorLabelDecoder);
|
||||
|
||||
mSiteOrToTalkgroupAlias.setFont(mFontDecoder);
|
||||
mSiteOrToTalkgroupAlias.setForeground(mColorLabelDecoder);
|
||||
|
||||
mFromTalkgroupLabel.setFont(mFontDetails);
|
||||
mFromTalkgroupLabel.setForeground(mColorLabelDetails);
|
||||
|
||||
mFromTalkgroup.setFont(mFontDecoder);
|
||||
mFromTalkgroup.setForeground(mColorLabelDecoder);
|
||||
|
||||
mFromTalkgroupAliasLabel.setFont(mFontDecoder);
|
||||
mFromTalkgroupAliasLabel.setForeground(mColorLabelDecoder);
|
||||
|
||||
|
||||
switch(mptState.getChannelType())
|
||||
{
|
||||
case STANDARD:
|
||||
mSiteOrToTalkgroup.setText(mptState.getSite());
|
||||
setAliasLabel(mSiteOrToTalkgroupAlias, mptState.getSiteAlias());
|
||||
break;
|
||||
case TRAFFIC:
|
||||
mSiteOrToTalkgroup.setText(mptState.getToTalkgroup());
|
||||
setAliasLabel(mSiteOrToTalkgroupAlias, mptState.getToTalkgroupAlias());
|
||||
|
||||
mFromTalkgroupLabel.setText("From:");
|
||||
mFromTalkgroup.setText(getDecoderState().getFromTalkgroup());
|
||||
setAliasLabel(mFromTalkgroupAliasLabel, mptState.getFromTalkgroupAlias());
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException("Unrecognized channel "
|
||||
+ "type in MPT1327 Decoder [" + getDecoderState()
|
||||
.getChannelType().name() + "]");
|
||||
}
|
||||
|
||||
add(mProtocol);
|
||||
add(mSiteOrToTalkgroup);
|
||||
add(mSiteOrToTalkgroupAlias, "wrap");
|
||||
|
||||
if(mptState.getChannelType() == ChannelType.TRAFFIC)
|
||||
{
|
||||
add(mFromTalkgroupLabel);
|
||||
add(mFromTalkgroup);
|
||||
add(mFromTalkgroupAliasLabel, "wrap");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(final ChangedAttribute changedAttribute)
|
||||
{
|
||||
final MPT1327DecoderState state = getDecoderState();
|
||||
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
switch( changedAttribute )
|
||||
{
|
||||
case CHANNEL_SITE_NUMBER:
|
||||
mSiteOrToTalkgroup.setText( String.valueOf( state.getSite() ) );
|
||||
setAliasLabel( mSiteOrToTalkgroupAlias, state.getSiteAlias(), false );
|
||||
repaint();
|
||||
break;
|
||||
case TO_TALKGROUP:
|
||||
mSiteOrToTalkgroup.setText( state.getToTalkgroup() );
|
||||
setAliasLabel( mSiteOrToTalkgroupAlias, state.getToTalkgroupAlias() );
|
||||
repaint();
|
||||
break;
|
||||
case FROM_TALKGROUP:
|
||||
mFromTalkgroup.setText( state.getFromTalkgroup() );
|
||||
setAliasLabel( mFromTalkgroupAliasLabel, state.getFromTalkgroupAlias() );
|
||||
repaint();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch(changedAttribute)
|
||||
{
|
||||
case CHANNEL_SITE_NUMBER:
|
||||
mSiteOrToTalkgroup.setText(String.valueOf(state.getSite()));
|
||||
setAliasLabel(mSiteOrToTalkgroupAlias, state.getSiteAlias(), false);
|
||||
repaint();
|
||||
break;
|
||||
case TO_TALKGROUP:
|
||||
mSiteOrToTalkgroup.setText(state.getToTalkgroup());
|
||||
setAliasLabel(mSiteOrToTalkgroupAlias, state.getToTalkgroupAlias());
|
||||
repaint();
|
||||
break;
|
||||
case FROM_TALKGROUP:
|
||||
mFromTalkgroup.setText(state.getFromTalkgroup());
|
||||
setAliasLabel(mFromTalkgroupAliasLabel, state.getFromTalkgroupAlias());
|
||||
repaint();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} );
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingChanged( Setting setting )
|
||||
|
||||
@Override
|
||||
public void settingChanged(Setting setting)
|
||||
{
|
||||
super.settingChanged( setting );
|
||||
|
||||
if( setting instanceof ColorSetting )
|
||||
{
|
||||
ColorSetting colorSetting = (ColorSetting)setting;
|
||||
|
||||
switch( colorSetting.getColorSettingName() )
|
||||
{
|
||||
case CHANNEL_STATE_LABEL_DECODER:
|
||||
if( mProtocol != null )
|
||||
{
|
||||
mProtocol.setForeground( mColorLabelDecoder );
|
||||
}
|
||||
if( mSiteOrToTalkgroup != null )
|
||||
{
|
||||
mSiteOrToTalkgroup.setForeground( mColorLabelDecoder );
|
||||
}
|
||||
if( mSiteOrToTalkgroupAlias != null )
|
||||
{
|
||||
mSiteOrToTalkgroupAlias.setForeground( mColorLabelDecoder );
|
||||
}
|
||||
if( mFromTalkgroup != null )
|
||||
{
|
||||
mFromTalkgroup.setForeground( mColorLabelDecoder );
|
||||
}
|
||||
if( mFromTalkgroupAliasLabel != null )
|
||||
{
|
||||
mFromTalkgroupAliasLabel.setForeground( mColorLabelDecoder );
|
||||
}
|
||||
break;
|
||||
case CHANNEL_STATE_LABEL_DETAILS:
|
||||
if( mFromTalkgroupLabel != null )
|
||||
{
|
||||
mFromTalkgroupLabel.setForeground( mColorLabelDetails );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
super.settingChanged(setting);
|
||||
|
||||
if(setting instanceof ColorSetting)
|
||||
{
|
||||
ColorSetting colorSetting = (ColorSetting) setting;
|
||||
|
||||
switch(colorSetting.getColorSettingName())
|
||||
{
|
||||
case CHANNEL_STATE_LABEL_DECODER:
|
||||
if(mProtocol != null)
|
||||
{
|
||||
mProtocol.setForeground(mColorLabelDecoder);
|
||||
}
|
||||
if(mSiteOrToTalkgroup != null)
|
||||
{
|
||||
mSiteOrToTalkgroup.setForeground(mColorLabelDecoder);
|
||||
}
|
||||
if(mSiteOrToTalkgroupAlias != null)
|
||||
{
|
||||
mSiteOrToTalkgroupAlias.setForeground(mColorLabelDecoder);
|
||||
}
|
||||
if(mFromTalkgroup != null)
|
||||
{
|
||||
mFromTalkgroup.setForeground(mColorLabelDecoder);
|
||||
}
|
||||
if(mFromTalkgroupAliasLabel != null)
|
||||
{
|
||||
mFromTalkgroupAliasLabel.setForeground(mColorLabelDecoder);
|
||||
}
|
||||
break;
|
||||
case CHANNEL_STATE_LABEL_DETAILS:
|
||||
if(mFromTalkgroupLabel != null)
|
||||
{
|
||||
mFromTalkgroupLabel.setForeground(mColorLabelDetails);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +1,33 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* 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 module.decode.mpt1327;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import alias.Alias;
|
||||
import icon.IconManager;
|
||||
import module.decode.state.ChangedAttribute;
|
||||
import module.decode.state.DecoderPanel;
|
||||
import settings.ColorSetting;
|
||||
import settings.Setting;
|
||||
import settings.SettingsManager;
|
||||
import alias.Alias;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class MPT1327TrafficPanel extends DecoderPanel
|
||||
{
|
||||
@@ -39,141 +40,140 @@ public class MPT1327TrafficPanel extends DecoderPanel
|
||||
private JLabel mToLabel;
|
||||
private JLabel mToTalkgroupLabel;
|
||||
private JLabel mToTalkgroupAliasLabel;
|
||||
|
||||
public MPT1327TrafficPanel( SettingsManager settingsManager, MPT1327DecoderState decoderState )
|
||||
{
|
||||
super( settingsManager, decoderState );
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
|
||||
public MPT1327TrafficPanel(IconManager iconManager, SettingsManager settingsManager,
|
||||
MPT1327DecoderState decoderState)
|
||||
{
|
||||
super(iconManager, settingsManager, decoderState);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public MPT1327DecoderState getDecoderState()
|
||||
{
|
||||
return (MPT1327DecoderState)super.getDecoderState();
|
||||
return (MPT1327DecoderState) super.getDecoderState();
|
||||
}
|
||||
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
super.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
mProtocolLabel = new JLabel( "MPT1327" );
|
||||
mProtocolLabel.setFont( mFontDecoder );
|
||||
mProtocolLabel.setForeground( mColorLabelDecoder );
|
||||
|
||||
mFromTalkgroupLabel = new JLabel();
|
||||
mFromTalkgroupLabel.setFont( mFontDecoder );
|
||||
mFromTalkgroupLabel.setForeground( mColorLabelDecoder );
|
||||
|
||||
mFromTalkgroupAliasLabel = new JLabel();
|
||||
mFromTalkgroupAliasLabel.setFont( mFontDecoder );
|
||||
mFromTalkgroupAliasLabel.setForeground( mColorLabelDecoder );
|
||||
|
||||
mToLabel = new JLabel( "TO:" );
|
||||
mToLabel.setFont( mFontDetails );
|
||||
mToLabel.setForeground( mColorLabelDetails );
|
||||
|
||||
mToTalkgroupLabel = new JLabel( getDecoderState().getFromTalkgroup() );
|
||||
mToTalkgroupLabel.setFont( mFontDecoder );
|
||||
mToTalkgroupLabel.setForeground( mColorLabelDecoder );
|
||||
|
||||
mToTalkgroupAliasLabel = new JLabel();
|
||||
mToTalkgroupAliasLabel.setFont( mFontDecoder );
|
||||
mToTalkgroupAliasLabel.setForeground( mColorLabelDecoder );
|
||||
|
||||
add( mProtocolLabel );
|
||||
add( mFromTalkgroupLabel );
|
||||
add( mFromTalkgroupAliasLabel, "wrap" );
|
||||
|
||||
add( mToLabel );
|
||||
add( mToTalkgroupLabel );
|
||||
add( mToTalkgroupAliasLabel, "wrap" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( final ChangedAttribute changedAttribute )
|
||||
public void init()
|
||||
{
|
||||
final MPT1327DecoderState state = getDecoderState();
|
||||
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
mProtocolLabel = new JLabel("MPT1327");
|
||||
mProtocolLabel.setFont(mFontDecoder);
|
||||
mProtocolLabel.setForeground(mColorLabelDecoder);
|
||||
|
||||
mFromTalkgroupLabel = new JLabel();
|
||||
mFromTalkgroupLabel.setFont(mFontDecoder);
|
||||
mFromTalkgroupLabel.setForeground(mColorLabelDecoder);
|
||||
|
||||
mFromTalkgroupAliasLabel = new JLabel();
|
||||
mFromTalkgroupAliasLabel.setFont(mFontDecoder);
|
||||
mFromTalkgroupAliasLabel.setForeground(mColorLabelDecoder);
|
||||
|
||||
mToLabel = new JLabel("TO:");
|
||||
mToLabel.setFont(mFontDetails);
|
||||
mToLabel.setForeground(mColorLabelDetails);
|
||||
|
||||
mToTalkgroupLabel = new JLabel(getDecoderState().getFromTalkgroup());
|
||||
mToTalkgroupLabel.setFont(mFontDecoder);
|
||||
mToTalkgroupLabel.setForeground(mColorLabelDecoder);
|
||||
|
||||
mToTalkgroupAliasLabel = new JLabel();
|
||||
mToTalkgroupAliasLabel.setFont(mFontDecoder);
|
||||
mToTalkgroupAliasLabel.setForeground(mColorLabelDecoder);
|
||||
|
||||
add(mProtocolLabel);
|
||||
add(mFromTalkgroupLabel);
|
||||
add(mFromTalkgroupAliasLabel, "wrap");
|
||||
|
||||
add(mToLabel);
|
||||
add(mToTalkgroupLabel);
|
||||
add(mToTalkgroupAliasLabel, "wrap");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(final ChangedAttribute changedAttribute)
|
||||
{
|
||||
final MPT1327DecoderState state = getDecoderState();
|
||||
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
switch( changedAttribute )
|
||||
{
|
||||
case FROM_TALKGROUP:
|
||||
String talkgroup = state.getFromTalkgroup();
|
||||
|
||||
mFromTalkgroupLabel.setText( talkgroup );
|
||||
|
||||
Alias alias = state.getFromTalkgroupAlias();
|
||||
|
||||
if( alias != null )
|
||||
{
|
||||
mFromTalkgroupAliasLabel.setText( alias.getName() );
|
||||
|
||||
String icon = alias.getIconName();
|
||||
|
||||
mFromTalkgroupAliasLabel.setIcon( mSettingsManager
|
||||
.getImageIcon( icon, SettingsManager.DEFAULT_ICON_SIZE ) );
|
||||
}
|
||||
break;
|
||||
case TO_TALKGROUP:
|
||||
String toTalkgroup = state.getToTalkgroup();
|
||||
|
||||
mToTalkgroupLabel.setText( toTalkgroup );
|
||||
|
||||
Alias toAlias = state.getToTalkgroupAlias();
|
||||
|
||||
if( toAlias != null )
|
||||
{
|
||||
mToTalkgroupAliasLabel.setText( toAlias.getName() );
|
||||
|
||||
String icon = toAlias.getIconName();
|
||||
|
||||
if( icon != null )
|
||||
{
|
||||
mToTalkgroupAliasLabel.setIcon( mSettingsManager
|
||||
.getImageIcon( icon, 12 ) );
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch(changedAttribute)
|
||||
{
|
||||
case FROM_TALKGROUP:
|
||||
String talkgroup = state.getFromTalkgroup();
|
||||
|
||||
repaint();
|
||||
mFromTalkgroupLabel.setText(talkgroup);
|
||||
|
||||
Alias alias = state.getFromTalkgroupAlias();
|
||||
|
||||
if(alias != null)
|
||||
{
|
||||
mFromTalkgroupAliasLabel.setText(alias.getName());
|
||||
|
||||
String icon = alias.getIconName();
|
||||
|
||||
mFromTalkgroupAliasLabel.setIcon(mIconManager.getIcon(icon, IconManager.DEFAULT_ICON_SIZE));
|
||||
}
|
||||
break;
|
||||
case TO_TALKGROUP:
|
||||
String toTalkgroup = state.getToTalkgroup();
|
||||
|
||||
mToTalkgroupLabel.setText(toTalkgroup);
|
||||
|
||||
Alias toAlias = state.getToTalkgroupAlias();
|
||||
|
||||
if(toAlias != null)
|
||||
{
|
||||
mToTalkgroupAliasLabel.setText(toAlias.getName());
|
||||
|
||||
String icon = toAlias.getIconName();
|
||||
|
||||
if(icon != null)
|
||||
{
|
||||
mToTalkgroupAliasLabel.setIcon(mIconManager.getIcon(icon, IconManager.DEFAULT_ICON_SIZE));
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
repaint();
|
||||
}
|
||||
} );
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingChanged( Setting setting )
|
||||
|
||||
@Override
|
||||
public void settingChanged(Setting setting)
|
||||
{
|
||||
super.settingChanged( setting );
|
||||
|
||||
if( setting instanceof ColorSetting )
|
||||
{
|
||||
ColorSetting colorSetting = (ColorSetting)setting;
|
||||
|
||||
switch( colorSetting.getColorSettingName() )
|
||||
{
|
||||
case CHANNEL_STATE_LABEL_DECODER:
|
||||
mProtocolLabel.setForeground( mColorLabelDecoder );
|
||||
mFromTalkgroupLabel.setForeground( mColorLabelDecoder );
|
||||
mFromTalkgroupAliasLabel.setForeground( mColorLabelDecoder );
|
||||
mToTalkgroupLabel.setForeground( mColorLabelDecoder );
|
||||
mToTalkgroupAliasLabel.setForeground( mColorLabelDecoder );
|
||||
break;
|
||||
case CHANNEL_STATE_LABEL_DETAILS:
|
||||
mToLabel.setForeground( mColorLabelDetails );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
super.settingChanged(setting);
|
||||
|
||||
if(setting instanceof ColorSetting)
|
||||
{
|
||||
ColorSetting colorSetting = (ColorSetting) setting;
|
||||
|
||||
switch(colorSetting.getColorSettingName())
|
||||
{
|
||||
case CHANNEL_STATE_LABEL_DECODER:
|
||||
mProtocolLabel.setForeground(mColorLabelDecoder);
|
||||
mFromTalkgroupLabel.setForeground(mColorLabelDecoder);
|
||||
mFromTalkgroupAliasLabel.setForeground(mColorLabelDecoder);
|
||||
mToTalkgroupLabel.setForeground(mColorLabelDecoder);
|
||||
mToTalkgroupAliasLabel.setForeground(mColorLabelDecoder);
|
||||
break;
|
||||
case CHANNEL_STATE_LABEL_DETAILS:
|
||||
mToLabel.setForeground(mColorLabelDetails);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014,2015 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/>
|
||||
* 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 module.decode.nbfm;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import icon.IconManager;
|
||||
import module.decode.state.ChangedAttribute;
|
||||
import module.decode.state.DecoderPanel;
|
||||
import module.decode.state.DecoderState;
|
||||
@@ -28,52 +28,53 @@ import settings.ColorSetting.ColorSettingName;
|
||||
import settings.Setting;
|
||||
import settings.SettingsManager;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
public class NBFMDecoderPanel extends DecoderPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private JLabel mProtocol = new JLabel( "NBFM" );
|
||||
|
||||
public NBFMDecoderPanel( SettingsManager settingsManager,
|
||||
DecoderState decoderState )
|
||||
{
|
||||
super( settingsManager, decoderState );
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
protected void init()
|
||||
{
|
||||
super.init();
|
||||
private JLabel mProtocol = new JLabel("NBFM");
|
||||
|
||||
setLayout( new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[]0[]0[]") );
|
||||
|
||||
mProtocol.setFont( mFontDecoder );
|
||||
mProtocol.setForeground( mColorLabelDecoder );
|
||||
|
||||
add( mProtocol, "wrap" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( ChangedAttribute t )
|
||||
{
|
||||
/* Not implemented */
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingChanged( Setting setting )
|
||||
public NBFMDecoderPanel(IconManager iconManager, SettingsManager settingsManager, DecoderState decoderState)
|
||||
{
|
||||
super.settingChanged( setting );
|
||||
|
||||
if( setting instanceof ColorSetting )
|
||||
{
|
||||
ColorSetting color = (ColorSetting)setting;
|
||||
super(iconManager, settingsManager, decoderState);
|
||||
|
||||
if( color.getColorSettingName() ==
|
||||
ColorSettingName.CHANNEL_STATE_LABEL_DECODER )
|
||||
{
|
||||
mProtocol.setForeground( color.getColor() );
|
||||
}
|
||||
}
|
||||
init();
|
||||
}
|
||||
|
||||
protected void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[]0[]0[]"));
|
||||
|
||||
mProtocol.setFont(mFontDecoder);
|
||||
mProtocol.setForeground(mColorLabelDecoder);
|
||||
|
||||
add(mProtocol, "wrap");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(ChangedAttribute t)
|
||||
{
|
||||
/* Not implemented */
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingChanged(Setting setting)
|
||||
{
|
||||
super.settingChanged(setting);
|
||||
|
||||
if(setting instanceof ColorSetting)
|
||||
{
|
||||
ColorSetting color = (ColorSetting) setting;
|
||||
|
||||
if(color.getColorSettingName() ==
|
||||
ColorSettingName.CHANNEL_STATE_LABEL_DECODER)
|
||||
{
|
||||
mProtocol.setForeground(color.getColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,228 +1,226 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* 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 module.decode.p25;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import alias.Alias;
|
||||
import icon.IconManager;
|
||||
import module.decode.state.ChangedAttribute;
|
||||
import module.decode.state.DecoderPanel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import settings.ColorSetting;
|
||||
import settings.Setting;
|
||||
import settings.SettingsManager;
|
||||
import alias.Alias;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class P25DecoderPanel extends DecoderPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private JLabel mProtocol;
|
||||
private JLabel mTo = new JLabel( " " );
|
||||
private JLabel mToAlias = new JLabel( " " );
|
||||
|
||||
private JLabel mNAC = new JLabel( "NAC:" );
|
||||
private JLabel mFrom = new JLabel( " " );
|
||||
private JLabel mFromAlias = new JLabel( " " );
|
||||
|
||||
private JLabel mSystem = new JLabel( "SYS:" );
|
||||
private JLabel mSite = new JLabel( "Site:" );
|
||||
private JLabel mSiteAlias = new JLabel( "" );
|
||||
|
||||
|
||||
public P25DecoderPanel( SettingsManager settingsManager,
|
||||
P25DecoderState decoderState )
|
||||
{
|
||||
super( settingsManager, decoderState );
|
||||
private JLabel mTo = new JLabel(" ");
|
||||
private JLabel mToAlias = new JLabel(" ");
|
||||
|
||||
mProtocol = new JLabel( "P25-1 " + decoderState.getModulation().getShortLabel() );
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
setLayout( new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[]0[]0[]") );
|
||||
private JLabel mNAC = new JLabel("NAC:");
|
||||
private JLabel mFrom = new JLabel(" ");
|
||||
private JLabel mFromAlias = new JLabel(" ");
|
||||
|
||||
mProtocol.setFont( mFontDecoder );
|
||||
mProtocol.setForeground( mColorLabelDecoder );
|
||||
private JLabel mSystem = new JLabel("SYS:");
|
||||
private JLabel mSite = new JLabel("Site:");
|
||||
private JLabel mSiteAlias = new JLabel("");
|
||||
|
||||
mTo.setFont( mFontDecoder );
|
||||
mTo.setForeground( mColorLabelDecoder );
|
||||
|
||||
mToAlias.setFont( mFontDecoder );
|
||||
mToAlias.setForeground( mColorLabelDecoder );
|
||||
|
||||
mNAC.setFont( mFontDetails );
|
||||
mNAC.setForeground( mColorLabelDecoder );
|
||||
|
||||
mFrom.setFont( mFontDecoder );
|
||||
mFrom.setForeground( mColorLabelDecoder );
|
||||
|
||||
mFromAlias.setFont( mFontDecoder );
|
||||
mFromAlias.setForeground( mColorLabelDecoder );
|
||||
|
||||
mSystem.setFont( mFontDetails );
|
||||
mSystem.setForeground( mColorLabelDecoder );
|
||||
|
||||
mSiteAlias.setFont( mFontDecoder );
|
||||
mSiteAlias.setForeground( mColorLabelDecoder );
|
||||
|
||||
mSite.setFont( mFontDetails );
|
||||
mSite.setForeground( mColorLabelDecoder );
|
||||
|
||||
add( mProtocol );
|
||||
add( mTo );
|
||||
add( mToAlias, "wrap" );
|
||||
|
||||
add( mNAC );
|
||||
add( mFrom );
|
||||
add( mFromAlias, "wrap" );
|
||||
|
||||
add( mSystem );
|
||||
add( mSite );
|
||||
add( mSiteAlias, "wrap" );
|
||||
}
|
||||
|
||||
public P25DecoderState getDecoderState()
|
||||
{
|
||||
return (P25DecoderState)super.getDecoderState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( final ChangedAttribute changedAttribute )
|
||||
public P25DecoderPanel(IconManager iconManager, SettingsManager settingsManager, P25DecoderState decoderState)
|
||||
{
|
||||
final P25DecoderState state = getDecoderState();
|
||||
super(iconManager, settingsManager, decoderState);
|
||||
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
mProtocol = new JLabel("P25-1 " + decoderState.getModulation().getShortLabel());
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[]0[]0[]"));
|
||||
|
||||
mProtocol.setFont(mFontDecoder);
|
||||
mProtocol.setForeground(mColorLabelDecoder);
|
||||
|
||||
mTo.setFont(mFontDecoder);
|
||||
mTo.setForeground(mColorLabelDecoder);
|
||||
|
||||
mToAlias.setFont(mFontDecoder);
|
||||
mToAlias.setForeground(mColorLabelDecoder);
|
||||
|
||||
mNAC.setFont(mFontDetails);
|
||||
mNAC.setForeground(mColorLabelDecoder);
|
||||
|
||||
mFrom.setFont(mFontDecoder);
|
||||
mFrom.setForeground(mColorLabelDecoder);
|
||||
|
||||
mFromAlias.setFont(mFontDecoder);
|
||||
mFromAlias.setForeground(mColorLabelDecoder);
|
||||
|
||||
mSystem.setFont(mFontDetails);
|
||||
mSystem.setForeground(mColorLabelDecoder);
|
||||
|
||||
mSiteAlias.setFont(mFontDecoder);
|
||||
mSiteAlias.setForeground(mColorLabelDecoder);
|
||||
|
||||
mSite.setFont(mFontDetails);
|
||||
mSite.setForeground(mColorLabelDecoder);
|
||||
|
||||
add(mProtocol);
|
||||
add(mTo);
|
||||
add(mToAlias, "wrap");
|
||||
|
||||
add(mNAC);
|
||||
add(mFrom);
|
||||
add(mFromAlias, "wrap");
|
||||
|
||||
add(mSystem);
|
||||
add(mSite);
|
||||
add(mSiteAlias, "wrap");
|
||||
}
|
||||
|
||||
public P25DecoderState getDecoderState()
|
||||
{
|
||||
return (P25DecoderState) super.getDecoderState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(final ChangedAttribute changedAttribute)
|
||||
{
|
||||
final P25DecoderState state = getDecoderState();
|
||||
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
|
||||
switch( changedAttribute )
|
||||
{
|
||||
case NAC:
|
||||
mNAC.setText( "NAC:" + state.getNAC() );
|
||||
break;
|
||||
case SYSTEM:
|
||||
mSystem.setText( "SYS:" + state.getSystem() );
|
||||
break;
|
||||
case SITE:
|
||||
mSite.setText( "SITE:" + state.getSite() );
|
||||
break;
|
||||
case SITE_ALIAS:
|
||||
mSiteAlias.setText( state.getSiteAlias() );
|
||||
break;
|
||||
case FROM_TALKGROUP:
|
||||
if( state.getFromTalkgroup() == null )
|
||||
{
|
||||
mFrom.setText( " " );
|
||||
}
|
||||
else
|
||||
{
|
||||
mFrom.setText( state.getFromTalkgroup() );
|
||||
}
|
||||
break;
|
||||
case FROM_TALKGROUP_ALIAS:
|
||||
Alias from = state.getFromAlias();
|
||||
|
||||
if( from != null )
|
||||
{
|
||||
mFromAlias.setText( from.getName() );
|
||||
|
||||
final String icon = from.getIconName();
|
||||
|
||||
if( icon != null && mSettingsManager != null )
|
||||
{
|
||||
mFromAlias.setIcon( mSettingsManager.getImageIcon(
|
||||
icon, SettingsManager.DEFAULT_ICON_SIZE ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mFromAlias.setText( " " );
|
||||
mFromAlias.setIcon( null );
|
||||
}
|
||||
break;
|
||||
case TO_TALKGROUP:
|
||||
if( state.getToTalkgroup() == null )
|
||||
{
|
||||
mTo.setText( " " );
|
||||
}
|
||||
else
|
||||
{
|
||||
mTo.setText( state.getToTalkgroup() );
|
||||
}
|
||||
break;
|
||||
case TO_TALKGROUP_ALIAS:
|
||||
final Alias to = state.getToAlias();
|
||||
|
||||
if( to != null )
|
||||
{
|
||||
mToAlias.setText( to.getName() );
|
||||
|
||||
final String icon = to.getIconName();
|
||||
|
||||
if( icon != null && mSettingsManager != null )
|
||||
{
|
||||
mToAlias.setIcon( mSettingsManager.getImageIcon(
|
||||
icon, SettingsManager.DEFAULT_ICON_SIZE ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mToAlias.setText( " " );
|
||||
mToAlias.setIcon( null );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch(changedAttribute)
|
||||
{
|
||||
case NAC:
|
||||
mNAC.setText("NAC:" + state.getNAC());
|
||||
break;
|
||||
case SYSTEM:
|
||||
mSystem.setText("SYS:" + state.getSystem());
|
||||
break;
|
||||
case SITE:
|
||||
mSite.setText("SITE:" + state.getSite());
|
||||
break;
|
||||
case SITE_ALIAS:
|
||||
mSiteAlias.setText(state.getSiteAlias());
|
||||
break;
|
||||
case FROM_TALKGROUP:
|
||||
if(state.getFromTalkgroup() == null)
|
||||
{
|
||||
mFrom.setText(" ");
|
||||
}
|
||||
else
|
||||
{
|
||||
mFrom.setText(state.getFromTalkgroup());
|
||||
}
|
||||
break;
|
||||
case FROM_TALKGROUP_ALIAS:
|
||||
Alias from = state.getFromAlias();
|
||||
|
||||
repaint();
|
||||
}
|
||||
});
|
||||
if(from != null)
|
||||
{
|
||||
mFromAlias.setText(from.getName());
|
||||
|
||||
final String icon = from.getIconName();
|
||||
|
||||
if(icon != null && mIconManager != null)
|
||||
{
|
||||
mFromAlias.setIcon(mIconManager.getIcon(icon, IconManager.DEFAULT_ICON_SIZE));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mFromAlias.setText(" ");
|
||||
mFromAlias.setIcon(null);
|
||||
}
|
||||
break;
|
||||
case TO_TALKGROUP:
|
||||
if(state.getToTalkgroup() == null)
|
||||
{
|
||||
mTo.setText(" ");
|
||||
}
|
||||
else
|
||||
{
|
||||
mTo.setText(state.getToTalkgroup());
|
||||
}
|
||||
break;
|
||||
case TO_TALKGROUP_ALIAS:
|
||||
final Alias to = state.getToAlias();
|
||||
|
||||
if(to != null)
|
||||
{
|
||||
mToAlias.setText(to.getName());
|
||||
|
||||
final String icon = to.getIconName();
|
||||
|
||||
if(icon != null && mIconManager != null)
|
||||
{
|
||||
mToAlias.setIcon(mIconManager.getIcon(icon, IconManager.DEFAULT_ICON_SIZE));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
mToAlias.setText(" ");
|
||||
mToAlias.setIcon(null);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
repaint();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingChanged( Setting setting )
|
||||
@Override
|
||||
public void settingChanged(Setting setting)
|
||||
{
|
||||
super.settingChanged( setting );
|
||||
|
||||
if( setting instanceof ColorSetting )
|
||||
{
|
||||
ColorSetting colorSetting = (ColorSetting)setting;
|
||||
|
||||
switch( colorSetting.getColorSettingName() )
|
||||
{
|
||||
case CHANNEL_STATE_LABEL_DECODER:
|
||||
if( mProtocol != null )
|
||||
{
|
||||
mProtocol.setForeground( mColorLabelDecoder );
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
super.settingChanged(setting);
|
||||
|
||||
if(setting instanceof ColorSetting)
|
||||
{
|
||||
ColorSetting colorSetting = (ColorSetting) setting;
|
||||
|
||||
switch(colorSetting.getColorSettingName())
|
||||
{
|
||||
case CHANNEL_STATE_LABEL_DECODER:
|
||||
if(mProtocol != null)
|
||||
{
|
||||
mProtocol.setForeground(mColorLabelDecoder);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,226 +1,225 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* 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 module.decode.passport;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import alias.Alias;
|
||||
import icon.IconManager;
|
||||
import module.decode.state.ChangedAttribute;
|
||||
import module.decode.state.DecoderPanel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import settings.ColorSetting;
|
||||
import settings.Setting;
|
||||
import settings.SettingsManager;
|
||||
import alias.Alias;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class PassportDecoderPanel extends DecoderPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private JLabel mProtocol = new JLabel( "Passport" );
|
||||
private JLabel mProtocol = new JLabel("Passport");
|
||||
private JLabel mToTalkgroup = new JLabel();
|
||||
private JLabel mToTalkgroupAlias = new JLabel();
|
||||
|
||||
private JLabel mSiteAndChannel = new JLabel( "Site:" );
|
||||
|
||||
private JLabel mSiteAndChannel = new JLabel("Site:");
|
||||
private JLabel mFromTalkgroup = new JLabel();
|
||||
private JLabel mFromTalkgroupAlias = new JLabel();
|
||||
|
||||
public PassportDecoderPanel( SettingsManager settingsManager,
|
||||
PassportDecoderState decoderState )
|
||||
{
|
||||
super( settingsManager, decoderState );
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
setLayout( new MigLayout( "insets 0 0 0 0", "[grow,fill]", "[]0[]0[]") );
|
||||
|
||||
mProtocol.setFont( mFontDecoder );
|
||||
mProtocol.setForeground( mColorLabelDecoder );
|
||||
|
||||
mToTalkgroup.setFont( mFontDecoder );
|
||||
mToTalkgroup.setForeground( mColorLabelDecoder );
|
||||
|
||||
mToTalkgroupAlias.setFont( mFontDecoder );
|
||||
mToTalkgroupAlias.setForeground( mColorLabelDecoder );
|
||||
|
||||
mSiteAndChannel.setFont( mFontDecoder );
|
||||
mSiteAndChannel.setForeground( mColorLabelDecoder );
|
||||
|
||||
mFromTalkgroup.setFont( mFontDecoder );
|
||||
mFromTalkgroup.setForeground( mColorLabelDecoder );
|
||||
|
||||
mFromTalkgroupAlias.setFont( mFontDecoder );
|
||||
mFromTalkgroupAlias.setForeground( mColorLabelDecoder );
|
||||
|
||||
add( mProtocol );
|
||||
add( mToTalkgroup );
|
||||
add( mToTalkgroupAlias, "wrap" );
|
||||
|
||||
add( mSiteAndChannel );
|
||||
add( mFromTalkgroup );
|
||||
add( mFromTalkgroupAlias, "wrap" );
|
||||
}
|
||||
|
||||
public PassportDecoderState getDecoderState()
|
||||
{
|
||||
return (PassportDecoderState)super.getDecoderState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( final ChangedAttribute changedAttribute )
|
||||
public PassportDecoderPanel(IconManager iconManager, SettingsManager settingsManager, PassportDecoderState decoderState)
|
||||
{
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
super(iconManager, settingsManager, decoderState);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
public void init()
|
||||
{
|
||||
super.init();
|
||||
|
||||
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[]0[]0[]"));
|
||||
|
||||
mProtocol.setFont(mFontDecoder);
|
||||
mProtocol.setForeground(mColorLabelDecoder);
|
||||
|
||||
mToTalkgroup.setFont(mFontDecoder);
|
||||
mToTalkgroup.setForeground(mColorLabelDecoder);
|
||||
|
||||
mToTalkgroupAlias.setFont(mFontDecoder);
|
||||
mToTalkgroupAlias.setForeground(mColorLabelDecoder);
|
||||
|
||||
mSiteAndChannel.setFont(mFontDecoder);
|
||||
mSiteAndChannel.setForeground(mColorLabelDecoder);
|
||||
|
||||
mFromTalkgroup.setFont(mFontDecoder);
|
||||
mFromTalkgroup.setForeground(mColorLabelDecoder);
|
||||
|
||||
mFromTalkgroupAlias.setFont(mFontDecoder);
|
||||
mFromTalkgroupAlias.setForeground(mColorLabelDecoder);
|
||||
|
||||
add(mProtocol);
|
||||
add(mToTalkgroup);
|
||||
add(mToTalkgroupAlias, "wrap");
|
||||
|
||||
add(mSiteAndChannel);
|
||||
add(mFromTalkgroup);
|
||||
add(mFromTalkgroupAlias, "wrap");
|
||||
}
|
||||
|
||||
public PassportDecoderState getDecoderState()
|
||||
{
|
||||
return (PassportDecoderState) super.getDecoderState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(final ChangedAttribute changedAttribute)
|
||||
{
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
PassportDecoderState state = getDecoderState();
|
||||
|
||||
switch( changedAttribute )
|
||||
{
|
||||
case TO_TALKGROUP:
|
||||
String tg = state.getTalkgroup();
|
||||
|
||||
if( tg != null )
|
||||
{
|
||||
mToTalkgroup.setText( "TG:" + tg );
|
||||
}
|
||||
else
|
||||
{
|
||||
mToTalkgroup.setText( null );
|
||||
}
|
||||
break;
|
||||
case TO_TALKGROUP_ALIAS:
|
||||
Alias toAlias = state.getTalkgroupAlias();
|
||||
|
||||
if( toAlias != null )
|
||||
{
|
||||
mToTalkgroupAlias.setText( toAlias.getName() );
|
||||
|
||||
mToTalkgroupAlias.setIcon( mSettingsManager
|
||||
.getImageIcon( toAlias.getIconName(), SettingsManager.DEFAULT_ICON_SIZE ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
mToTalkgroupAlias.setText( null );
|
||||
mToTalkgroupAlias.setIcon( null );
|
||||
}
|
||||
break;
|
||||
case FROM_TALKGROUP:
|
||||
String mid = state.getMobileID();
|
||||
|
||||
if( mid != null )
|
||||
{
|
||||
mFromTalkgroup.setText( "MIN:" + mid );
|
||||
}
|
||||
else
|
||||
{
|
||||
mFromTalkgroup.setText( null );
|
||||
}
|
||||
break;
|
||||
case FROM_TALKGROUP_ALIAS:
|
||||
Alias fromAlias = state.getMobileIDAlias();
|
||||
|
||||
if( fromAlias != null )
|
||||
{
|
||||
mFromTalkgroupAlias.setText( fromAlias.getName() );
|
||||
|
||||
mFromTalkgroupAlias.setIcon( mSettingsManager
|
||||
.getImageIcon( fromAlias.getIconName(), SettingsManager.DEFAULT_ICON_SIZE ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
mFromTalkgroupAlias.setText( null );
|
||||
mFromTalkgroupAlias.setIcon( null );
|
||||
}
|
||||
break;
|
||||
case CHANNEL_NUMBER:
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append( "Site: " );
|
||||
sb.append( state.getSiteNumber() );
|
||||
sb.append( "/" );
|
||||
sb.append( state.getChannelNumber() );
|
||||
|
||||
mSiteAndChannel.setText( sb.toString() );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
repaint();
|
||||
PassportDecoderState state = getDecoderState();
|
||||
|
||||
switch(changedAttribute)
|
||||
{
|
||||
case TO_TALKGROUP:
|
||||
String tg = state.getTalkgroup();
|
||||
|
||||
if(tg != null)
|
||||
{
|
||||
mToTalkgroup.setText("TG:" + tg);
|
||||
}
|
||||
else
|
||||
{
|
||||
mToTalkgroup.setText(null);
|
||||
}
|
||||
break;
|
||||
case TO_TALKGROUP_ALIAS:
|
||||
Alias toAlias = state.getTalkgroupAlias();
|
||||
|
||||
if(toAlias != null)
|
||||
{
|
||||
mToTalkgroupAlias.setText(toAlias.getName());
|
||||
|
||||
mToTalkgroupAlias.setIcon(mIconManager.getIcon(toAlias.getIconName(), IconManager.DEFAULT_ICON_SIZE));
|
||||
}
|
||||
else
|
||||
{
|
||||
mToTalkgroupAlias.setText(null);
|
||||
mToTalkgroupAlias.setIcon(null);
|
||||
}
|
||||
break;
|
||||
case FROM_TALKGROUP:
|
||||
String mid = state.getMobileID();
|
||||
|
||||
if(mid != null)
|
||||
{
|
||||
mFromTalkgroup.setText("MIN:" + mid);
|
||||
}
|
||||
else
|
||||
{
|
||||
mFromTalkgroup.setText(null);
|
||||
}
|
||||
break;
|
||||
case FROM_TALKGROUP_ALIAS:
|
||||
Alias fromAlias = state.getMobileIDAlias();
|
||||
|
||||
if(fromAlias != null)
|
||||
{
|
||||
mFromTalkgroupAlias.setText(fromAlias.getName());
|
||||
|
||||
mFromTalkgroupAlias.setIcon(mIconManager
|
||||
.getIcon(fromAlias.getIconName(), IconManager.DEFAULT_ICON_SIZE));
|
||||
}
|
||||
else
|
||||
{
|
||||
mFromTalkgroupAlias.setText(null);
|
||||
mFromTalkgroupAlias.setIcon(null);
|
||||
}
|
||||
break;
|
||||
case CHANNEL_NUMBER:
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Site: ");
|
||||
sb.append(state.getSiteNumber());
|
||||
sb.append("/");
|
||||
sb.append(state.getChannelNumber());
|
||||
|
||||
mSiteAndChannel.setText(sb.toString());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
repaint();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingChanged( Setting setting )
|
||||
|
||||
@Override
|
||||
public void settingChanged(Setting setting)
|
||||
{
|
||||
super.settingChanged( setting );
|
||||
|
||||
if( setting instanceof ColorSetting )
|
||||
{
|
||||
ColorSetting colorSetting = (ColorSetting)setting;
|
||||
|
||||
switch( colorSetting.getColorSettingName() )
|
||||
{
|
||||
case CHANNEL_STATE_LABEL_DECODER:
|
||||
if( mColorLabelDecoder != null )
|
||||
{
|
||||
if( mProtocol != null )
|
||||
{
|
||||
mProtocol.setForeground( mColorLabelDecoder );
|
||||
}
|
||||
if( mToTalkgroup != null )
|
||||
{
|
||||
mToTalkgroup.setForeground( mColorLabelDecoder );
|
||||
}
|
||||
if( mToTalkgroupAlias != null )
|
||||
{
|
||||
mToTalkgroupAlias.setForeground( mColorLabelDecoder );
|
||||
}
|
||||
if( mSiteAndChannel != null )
|
||||
{
|
||||
mSiteAndChannel.setForeground( mColorLabelDecoder );
|
||||
}
|
||||
if( mFromTalkgroup != null )
|
||||
{
|
||||
mFromTalkgroup.setForeground( mColorLabelDecoder );
|
||||
}
|
||||
if( mFromTalkgroupAlias != null )
|
||||
{
|
||||
mFromTalkgroupAlias.setForeground( mColorLabelDecoder );
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
super.settingChanged(setting);
|
||||
|
||||
if(setting instanceof ColorSetting)
|
||||
{
|
||||
ColorSetting colorSetting = (ColorSetting) setting;
|
||||
|
||||
switch(colorSetting.getColorSettingName())
|
||||
{
|
||||
case CHANNEL_STATE_LABEL_DECODER:
|
||||
if(mColorLabelDecoder != null)
|
||||
{
|
||||
if(mProtocol != null)
|
||||
{
|
||||
mProtocol.setForeground(mColorLabelDecoder);
|
||||
}
|
||||
if(mToTalkgroup != null)
|
||||
{
|
||||
mToTalkgroup.setForeground(mColorLabelDecoder);
|
||||
}
|
||||
if(mToTalkgroupAlias != null)
|
||||
{
|
||||
mToTalkgroupAlias.setForeground(mColorLabelDecoder);
|
||||
}
|
||||
if(mSiteAndChannel != null)
|
||||
{
|
||||
mSiteAndChannel.setForeground(mColorLabelDecoder);
|
||||
}
|
||||
if(mFromTalkgroup != null)
|
||||
{
|
||||
mFromTalkgroup.setForeground(mColorLabelDecoder);
|
||||
}
|
||||
if(mFromTalkgroupAlias != null)
|
||||
{
|
||||
mFromTalkgroupAlias.setForeground(mColorLabelDecoder);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,39 +1,23 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014 Dennis Sheirer
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||
* 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 module.decode.state;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseListener;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.JSeparator;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
import settings.ColorSetting.ColorSettingName;
|
||||
import settings.ColorSettingMenuItem;
|
||||
import settings.ColorSettingResetMenuItem;
|
||||
import settings.SettingsManager;
|
||||
import audio.AudioPanel;
|
||||
import controller.channel.Channel;
|
||||
import controller.channel.ChannelEvent;
|
||||
@@ -41,266 +25,293 @@ 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
|
||||
* 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 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,
|
||||
SettingsManager settingsManager,
|
||||
AudioPanel audioPanel )
|
||||
{
|
||||
mChannelModel = channelModel;
|
||||
mChannelProcessingManager = channelProcessingManager;
|
||||
mSettingsManager = settingsManager;
|
||||
mAudioPanel = audioPanel;
|
||||
|
||||
init();
|
||||
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 );
|
||||
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 )
|
||||
|
||||
@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, 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 )
|
||||
switch(event.getEvent())
|
||||
{
|
||||
Component component = getComponentAt( e.getPoint() );
|
||||
case NOTIFICATION_PROCESSING_START:
|
||||
addChannelPanel(event.getChannel());
|
||||
break;
|
||||
case NOTIFICATION_PROCESSING_STOP:
|
||||
removeChannelPanel(event.getChannel());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( component instanceof ChannelPanel )
|
||||
{
|
||||
ChannelPanel panel = (ChannelPanel)component;
|
||||
private void addChannelPanel(Channel channel)
|
||||
{
|
||||
if(!mDisplayedPanels.containsKey(channel))
|
||||
{
|
||||
ChannelPanel channelPanel = new ChannelPanel(mChannelModel,
|
||||
mChannelProcessingManager, mIconManager, mSettingsManager, channel);
|
||||
|
||||
Channel channel = panel.getChannel();
|
||||
add(channelPanel);
|
||||
|
||||
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 );
|
||||
mDisplayedPanels.put(channel, channelPanel);
|
||||
|
||||
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() );
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
|
||||
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 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 ) {}
|
||||
}
|
||||
public void mousePressed(MouseEvent e)
|
||||
{
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent e)
|
||||
{
|
||||
}
|
||||
|
||||
public void mouseEntered(MouseEvent e)
|
||||
{
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,26 +1,36 @@
|
||||
/*******************************************************************************
|
||||
* 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 module.decode.state;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Font;
|
||||
import java.awt.GradientPaint;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Paint;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
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;
|
||||
@@ -29,25 +39,23 @@ import settings.ColorSetting.ColorSettingName;
|
||||
import settings.Setting;
|
||||
import settings.SettingChangeListener;
|
||||
import settings.SettingsManager;
|
||||
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;
|
||||
|
||||
public class ChannelPanel extends JPanel
|
||||
implements Listener<ChangedAttribute>,
|
||||
SettingChangeListener,
|
||||
ChannelEventListener
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ChannelPanel extends JPanel
|
||||
implements Listener<ChangedAttribute>,
|
||||
SettingChangeListener,
|
||||
ChannelEventListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private final static Logger mLog = LoggerFactory.getLogger( ChannelPanel.class );
|
||||
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 );
|
||||
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;
|
||||
@@ -70,383 +78,388 @@ public class ChannelPanel extends JPanel
|
||||
private JLabel mStateLabel;
|
||||
private JLabel mSourceLabel;
|
||||
private JLabel mOptionsLabel;
|
||||
|
||||
|
||||
private JLabel mSystemLabel;
|
||||
private JLabel mSiteLabel;
|
||||
private JLabel mChannelLabel;
|
||||
|
||||
protected SettingsManager mSettingsManager;
|
||||
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,
|
||||
SettingsManager settingsManager,
|
||||
Channel channel )
|
||||
{
|
||||
mChannelModel = channelModel;
|
||||
mChannelProcessingManager = channelProcessingManager;
|
||||
mSettingsManager = settingsManager;
|
||||
mChannel = channel;
|
||||
|
||||
ProcessingChain processingChain =
|
||||
channelProcessingManager.getProcessingChain( mChannel );
|
||||
private Channel mChannel;
|
||||
private ChannelState mChannelState;
|
||||
private List<DecoderPanel> mDecoderPanels = new ArrayList<>();
|
||||
private ChannelModel mChannelModel;
|
||||
private ChannelProcessingManager mChannelProcessingManager;
|
||||
|
||||
if( processingChain != null )
|
||||
{
|
||||
mChannelState = processingChain.getChannelState();
|
||||
/**
|
||||
* 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;
|
||||
|
||||
init();
|
||||
ProcessingChain processingChain =
|
||||
channelProcessingManager.getProcessingChain(mChannel);
|
||||
|
||||
for( DecoderState decoderState: processingChain.getDecoderStates() )
|
||||
{
|
||||
DecoderPanel panel = DecoderFactory.getDecoderPanel( mSettingsManager, decoderState );
|
||||
mDecoderPanels.add( panel );
|
||||
add( panel, "grow,span" );
|
||||
}
|
||||
if(processingChain != null)
|
||||
{
|
||||
mChannelState = processingChain.getChannelState();
|
||||
|
||||
mChannelState.setChangedAttributeListener( this );
|
||||
mChannelModel.addListener( this );
|
||||
mSettingsManager.addListener( this );
|
||||
}
|
||||
else
|
||||
{
|
||||
mLog.error( "Processing Chain was null!" );
|
||||
}
|
||||
}
|
||||
|
||||
private void init()
|
||||
{
|
||||
getColors();
|
||||
init();
|
||||
|
||||
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 );
|
||||
for(DecoderState decoderState : processingChain.getDecoderStates())
|
||||
{
|
||||
DecoderPanel panel = DecoderFactory.getDecoderPanel(mIconManager, mSettingsManager, decoderState);
|
||||
mDecoderPanels.add(panel);
|
||||
add(panel, "grow,span");
|
||||
}
|
||||
|
||||
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();
|
||||
mChannelState.setChangedAttributeListener(this);
|
||||
mChannelModel.addListener(this);
|
||||
mSettingsManager.addListener(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
mLog.error("Processing Chain was null!");
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
private void init()
|
||||
{
|
||||
getColors();
|
||||
|
||||
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 ChangedAttribute changedAttribute )
|
||||
{
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
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 ChangedAttribute changedAttribute)
|
||||
{
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
switch( changedAttribute )
|
||||
{
|
||||
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;
|
||||
}
|
||||
switch(changedAttribute)
|
||||
{
|
||||
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();
|
||||
repaint();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintComponent(Graphics g)
|
||||
{
|
||||
super.paintComponent( g );
|
||||
|
||||
setBackground( mColorChannelBackground );
|
||||
|
||||
Graphics2D g2 = (Graphics2D)g.create();
|
||||
super.paintComponent(g);
|
||||
|
||||
setBackground(mColorChannelBackground);
|
||||
|
||||
Graphics2D g2 = (Graphics2D) g.create();
|
||||
|
||||
Paint p = null;
|
||||
|
||||
final Channel channel = mChannel;
|
||||
|
||||
if( mChannelState != null )
|
||||
|
||||
if(mChannelState != null)
|
||||
{
|
||||
switch( mChannelState.getState() )
|
||||
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;
|
||||
}
|
||||
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 )
|
||||
|
||||
if(p == null)
|
||||
{
|
||||
p = getGradient( mColorTopIdle, mColorMiddleIdle );
|
||||
p = getGradient(mColorTopIdle, mColorMiddleIdle);
|
||||
}
|
||||
|
||||
g2.setPaint( p );
|
||||
g2.fillRect( 0, 0, getWidth(), getHeight() );
|
||||
|
||||
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 );
|
||||
g2.setColor(Color.LIGHT_GRAY);
|
||||
g2.drawLine(0, getHeight() - 1, getWidth(), getHeight() - 1);
|
||||
|
||||
/* Draw channel selected box */
|
||||
if( getChannel() != null && getChannel().isSelected() )
|
||||
if(getChannel() != null && getChannel().isSelected())
|
||||
{
|
||||
g2.setColor( mColorChannelSelected );
|
||||
g2.drawRect( 1, 1, getWidth() - 2, getHeight() - 2 );
|
||||
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();
|
||||
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();
|
||||
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 )
|
||||
|
||||
private GradientPaint getGradient(Color top, Color middle)
|
||||
{
|
||||
return new GradientPaint( 0f, -50.0f, top,
|
||||
0f, (float)getHeight() / 2.2f, middle, true );
|
||||
return new GradientPaint(0f, -50.0f, top,
|
||||
0f, (float) getHeight() / 2.2f, middle, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingChanged( Setting setting )
|
||||
@Override
|
||||
public void settingChanged(Setting setting)
|
||||
{
|
||||
if( setting instanceof ColorSetting )
|
||||
{
|
||||
ColorSetting colorSetting = (ColorSetting)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;
|
||||
}
|
||||
}
|
||||
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 ) {}
|
||||
@Override
|
||||
public void settingDeleted(Setting setting)
|
||||
{
|
||||
}
|
||||
|
||||
public JMenu getContextMenu()
|
||||
{
|
||||
return ChannelUtils.getContextMenu( mChannelModel, mChannelProcessingManager,
|
||||
mChannel, ChannelPanel.this );
|
||||
}
|
||||
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();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void channelChanged(ChannelEvent event)
|
||||
{
|
||||
if(event.getEvent() == Event.NOTIFICATION_SELECTION_CHANGE &&
|
||||
event.getChannel() == mChannel)
|
||||
{
|
||||
repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,160 +1,162 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2015 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/>
|
||||
* 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 module.decode.state;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import alias.Alias;
|
||||
import icon.IconManager;
|
||||
import sample.Listener;
|
||||
import settings.ColorSetting;
|
||||
import settings.ColorSetting.ColorSettingName;
|
||||
import settings.Setting;
|
||||
import settings.SettingChangeListener;
|
||||
import settings.SettingsManager;
|
||||
import alias.Alias;
|
||||
|
||||
public abstract class DecoderPanel extends JPanel
|
||||
implements Listener<ChangedAttribute>, SettingChangeListener
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public abstract class DecoderPanel extends JPanel
|
||||
implements Listener<ChangedAttribute>, SettingChangeListener
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
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 );
|
||||
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 SettingsManager mSettingsManager;
|
||||
|
||||
protected IconManager mIconManager;
|
||||
protected SettingsManager mSettingsManager;
|
||||
protected DecoderState mDecoderState;
|
||||
|
||||
public DecoderPanel( SettingsManager settingsManager, DecoderState decoderState )
|
||||
{
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
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 )
|
||||
|
||||
|
||||
@Override
|
||||
public void settingChanged(Setting setting)
|
||||
{
|
||||
if( setting instanceof ColorSetting )
|
||||
{
|
||||
ColorSetting colorSetting = (ColorSetting)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;
|
||||
}
|
||||
}
|
||||
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() );
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
if( includeIcon )
|
||||
{
|
||||
String iconName = alias.getIconName();
|
||||
|
||||
if( iconName != null )
|
||||
{
|
||||
label.setIcon( mSettingsManager
|
||||
.getImageIcon( iconName, SettingsManager.DEFAULT_ICON_SIZE ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
label.setIcon( null );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
label.setIcon( null );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
label.setText( "" );
|
||||
label.setIcon( null );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,27 +1,25 @@
|
||||
/*******************************************************************************
|
||||
* SDR Trunk
|
||||
* Copyright (C) 2014,2015 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/>
|
||||
* 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 module.decode.tait;
|
||||
|
||||
import java.awt.EventQueue;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
|
||||
import alias.Alias;
|
||||
import icon.IconManager;
|
||||
import module.decode.state.ChangedAttribute;
|
||||
import module.decode.state.DecoderPanel;
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
@@ -30,151 +28,153 @@ import settings.ColorSetting.ColorSettingName;
|
||||
import settings.Setting;
|
||||
import settings.SettingsManager;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class Tait1200DecoderPanel extends DecoderPanel
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final String PROTOCOL = "TAIT-1200";
|
||||
|
||||
private JLabel mFromLabel = new JLabel( " " );
|
||||
private JLabel mFromLabel = new JLabel(" ");
|
||||
private JLabel mFrom = new JLabel();
|
||||
private JLabel mFromAlias = new JLabel();
|
||||
|
||||
|
||||
private JLabel mToLabel = new JLabel();
|
||||
private JLabel mTo = new JLabel( " " );
|
||||
private JLabel mTo = new JLabel(" ");
|
||||
private JLabel mToAlias = new JLabel();
|
||||
|
||||
private JLabel mProtocol = new JLabel( PROTOCOL );
|
||||
private JLabel mProtocol = new JLabel(PROTOCOL);
|
||||
private JLabel mMessage = new JLabel();
|
||||
private JLabel mMessageType = new JLabel();
|
||||
|
||||
public Tait1200DecoderPanel( SettingsManager settingsManager,
|
||||
Tait1200DecoderState decoderState )
|
||||
{
|
||||
super( settingsManager, decoderState );
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
public Tait1200DecoderState getDecoderState()
|
||||
{
|
||||
return (Tait1200DecoderState)super.getDecoderState();
|
||||
}
|
||||
|
||||
protected void init()
|
||||
{
|
||||
/* Calling super init will get and broadcast color settings to properly
|
||||
* setup the jlabel colors */
|
||||
super.init();
|
||||
|
||||
setLayout( new MigLayout( "insets 1 0 0 0", "[grow,fill]", "[]0[]0[]") );
|
||||
private JLabel mMessageType = new JLabel();
|
||||
|
||||
add( mFromLabel );
|
||||
add( mFrom );
|
||||
add( mFromAlias, "wrap" );
|
||||
|
||||
add( mToLabel );
|
||||
add( mTo );
|
||||
add( mToAlias, "wrap" );
|
||||
|
||||
add( mProtocol );
|
||||
add( mMessageType );
|
||||
add( mMessage, "wrap" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive( final ChangedAttribute changedAttribute )
|
||||
public Tait1200DecoderPanel(IconManager iconManager, SettingsManager settingsManager, Tait1200DecoderState decoderState)
|
||||
{
|
||||
EventQueue.invokeLater( new Runnable()
|
||||
{
|
||||
@Override
|
||||
super(iconManager, settingsManager, decoderState);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
public Tait1200DecoderState getDecoderState()
|
||||
{
|
||||
return (Tait1200DecoderState) super.getDecoderState();
|
||||
}
|
||||
|
||||
protected void init()
|
||||
{
|
||||
/* Calling super init will get and broadcast color settings to properly
|
||||
* setup the jlabel colors */
|
||||
super.init();
|
||||
|
||||
setLayout(new MigLayout("insets 1 0 0 0", "[grow,fill]", "[]0[]0[]"));
|
||||
|
||||
add(mFromLabel);
|
||||
add(mFrom);
|
||||
add(mFromAlias, "wrap");
|
||||
|
||||
add(mToLabel);
|
||||
add(mTo);
|
||||
add(mToAlias, "wrap");
|
||||
|
||||
add(mProtocol);
|
||||
add(mMessageType);
|
||||
add(mMessage, "wrap");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receive(final ChangedAttribute changedAttribute)
|
||||
{
|
||||
EventQueue.invokeLater(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
switch( changedAttribute )
|
||||
{
|
||||
case FROM_TALKGROUP:
|
||||
String from = getDecoderState().getFromID();
|
||||
|
||||
if( from != null )
|
||||
{
|
||||
mFromLabel.setText( "FM:" );
|
||||
}
|
||||
else
|
||||
{
|
||||
mFromLabel.setText( " " );
|
||||
}
|
||||
mFrom.setText( from );
|
||||
break;
|
||||
case FROM_TALKGROUP_ALIAS:
|
||||
Alias fromAlias = getDecoderState().getFromIDAlias();
|
||||
|
||||
if( fromAlias != null )
|
||||
{
|
||||
mFromAlias.setText( fromAlias.getName() );
|
||||
}
|
||||
break;
|
||||
case TO_TALKGROUP:
|
||||
String to = getDecoderState().getToID();
|
||||
|
||||
if( to != null )
|
||||
{
|
||||
mToLabel.setText( "TO:" );
|
||||
}
|
||||
else
|
||||
{
|
||||
mToLabel.setText( " " );
|
||||
}
|
||||
mTo.setText( to );
|
||||
break;
|
||||
case TO_TALKGROUP_ALIAS:
|
||||
Alias toAlias = getDecoderState().getToIDAlias();
|
||||
|
||||
if( toAlias != null )
|
||||
{
|
||||
mToAlias.setText( toAlias.getName() );
|
||||
}
|
||||
break;
|
||||
case MESSAGE:
|
||||
mMessage.setText( getDecoderState().getMessage() );
|
||||
break;
|
||||
case MESSAGE_TYPE:
|
||||
mMessageType.setText( getDecoderState().getMessageType() );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
repaint();
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingChanged( Setting setting )
|
||||
{
|
||||
super.settingChanged( setting );
|
||||
|
||||
if( setting instanceof ColorSetting )
|
||||
{
|
||||
ColorSetting color = (ColorSetting)setting;
|
||||
switch(changedAttribute)
|
||||
{
|
||||
case FROM_TALKGROUP:
|
||||
String from = getDecoderState().getFromID();
|
||||
|
||||
if( color.getColorSettingName() ==
|
||||
ColorSettingName.CHANNEL_STATE_LABEL_AUX_DECODER )
|
||||
{
|
||||
mFromLabel.setForeground( color.getColor() );
|
||||
mFrom.setForeground( color.getColor() );
|
||||
mFromAlias.setForeground( color.getColor() );
|
||||
mToLabel.setForeground( color.getColor() );
|
||||
mTo.setForeground( color.getColor() );
|
||||
mToAlias.setForeground( color.getColor() );
|
||||
mProtocol.setForeground( color.getColor() );
|
||||
mMessageType.setForeground( color.getColor() );
|
||||
mMessage.setForeground( color.getColor() );
|
||||
}
|
||||
}
|
||||
if(from != null)
|
||||
{
|
||||
mFromLabel.setText("FM:");
|
||||
}
|
||||
else
|
||||
{
|
||||
mFromLabel.setText(" ");
|
||||
}
|
||||
mFrom.setText(from);
|
||||
break;
|
||||
case FROM_TALKGROUP_ALIAS:
|
||||
Alias fromAlias = getDecoderState().getFromIDAlias();
|
||||
|
||||
if(fromAlias != null)
|
||||
{
|
||||
mFromAlias.setText(fromAlias.getName());
|
||||
}
|
||||
break;
|
||||
case TO_TALKGROUP:
|
||||
String to = getDecoderState().getToID();
|
||||
|
||||
if(to != null)
|
||||
{
|
||||
mToLabel.setText("TO:");
|
||||
}
|
||||
else
|
||||
{
|
||||
mToLabel.setText(" ");
|
||||
}
|
||||
mTo.setText(to);
|
||||
break;
|
||||
case TO_TALKGROUP_ALIAS:
|
||||
Alias toAlias = getDecoderState().getToIDAlias();
|
||||
|
||||
if(toAlias != null)
|
||||
{
|
||||
mToAlias.setText(toAlias.getName());
|
||||
}
|
||||
break;
|
||||
case MESSAGE:
|
||||
mMessage.setText(getDecoderState().getMessage());
|
||||
break;
|
||||
case MESSAGE_TYPE:
|
||||
mMessageType.setText(getDecoderState().getMessageType());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
repaint();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void settingChanged(Setting setting)
|
||||
{
|
||||
super.settingChanged(setting);
|
||||
|
||||
if(setting instanceof ColorSetting)
|
||||
{
|
||||
ColorSetting color = (ColorSetting) setting;
|
||||
|
||||
if(color.getColorSettingName() ==
|
||||
ColorSettingName.CHANNEL_STATE_LABEL_AUX_DECODER)
|
||||
{
|
||||
mFromLabel.setForeground(color.getColor());
|
||||
mFrom.setForeground(color.getColor());
|
||||
mFromAlias.setForeground(color.getColor());
|
||||
mToLabel.setForeground(color.getColor());
|
||||
mTo.setForeground(color.getColor());
|
||||
mToAlias.setForeground(color.getColor());
|
||||
mProtocol.setForeground(color.getColor());
|
||||
mMessageType.setForeground(color.getColor());
|
||||
mMessage.setForeground(color.getColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,9 +432,9 @@ public class PlaylistManager implements ChannelEventListener
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
mPlaylistSavePending.set(false);
|
||||
|
||||
save();
|
||||
|
||||
mPlaylistSavePending.set(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user