mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-19 20:17:25 -05:00
Merge pull request #103 from DSheirer/#82_icon_manager_model
#82 icon manager model
This commit is contained in:
@@ -1,36 +1,23 @@
|
|||||||
package alias;
|
package alias;
|
||||||
|
|
||||||
import audio.broadcast.BroadcastModel;
|
import audio.broadcast.BroadcastModel;
|
||||||
|
import com.jidesoft.swing.JideSplitPane;
|
||||||
import gui.editor.Editor;
|
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 javax.swing.*;
|
||||||
import java.awt.Component;
|
import javax.swing.event.ListSelectionEvent;
|
||||||
import java.awt.Dimension;
|
import javax.swing.event.ListSelectionListener;
|
||||||
import java.awt.Rectangle;
|
import javax.swing.table.DefaultTableCellRenderer;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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
|
public class AliasController extends JPanel
|
||||||
implements ActionListener, ListSelectionListener
|
implements ActionListener, ListSelectionListener
|
||||||
{
|
{
|
||||||
@@ -53,14 +40,14 @@ public class AliasController extends JPanel
|
|||||||
|
|
||||||
private IconCellRenderer mIconCellRenderer;
|
private IconCellRenderer mIconCellRenderer;
|
||||||
|
|
||||||
public AliasController(AliasModel aliasModel, BroadcastModel broadcastModel, SettingsManager settingsManager )
|
public AliasController(AliasModel aliasModel, BroadcastModel broadcastModel, IconManager iconManager)
|
||||||
{
|
{
|
||||||
mAliasModel = aliasModel;
|
mAliasModel = aliasModel;
|
||||||
|
|
||||||
mAliasEditor = new AliasEditor( mAliasModel, broadcastModel, settingsManager );
|
mAliasEditor = new AliasEditor(mAliasModel, broadcastModel, iconManager);
|
||||||
mMultipleAliasEditor = new MultipleAliasEditor( mAliasModel, broadcastModel, settingsManager );
|
mMultipleAliasEditor = new MultipleAliasEditor(mAliasModel, broadcastModel, iconManager);
|
||||||
|
|
||||||
mIconCellRenderer = new IconCellRenderer( settingsManager );
|
mIconCellRenderer = new IconCellRenderer(iconManager);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|
||||||
@@ -341,11 +328,11 @@ public class AliasController extends JPanel
|
|||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private SettingsManager mSettingsManager;
|
private IconManager mIconManager;
|
||||||
|
|
||||||
public IconCellRenderer( SettingsManager settingsManager )
|
public IconCellRenderer(IconManager iconManager)
|
||||||
{
|
{
|
||||||
mSettingsManager = settingsManager;
|
mIconManager = iconManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -356,7 +343,7 @@ public class AliasController extends JPanel
|
|||||||
JLabel label = (JLabel) super.getTableCellRendererComponent(table,
|
JLabel label = (JLabel) super.getTableCellRendererComponent(table,
|
||||||
value, isSelected, hasFocus, row, column);
|
value, isSelected, hasFocus, row, column);
|
||||||
|
|
||||||
ImageIcon icon = mSettingsManager.getImageIcon( label.getText(), 12 );
|
ImageIcon icon = mIconManager.getIcon(label.getText(), 12);
|
||||||
|
|
||||||
if(icon != null)
|
if(icon != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import javax.swing.JButton;
|
|||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JSeparator;
|
import javax.swing.JSeparator;
|
||||||
|
|
||||||
|
import icon.IconManager;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
@@ -50,10 +51,10 @@ public class AliasEditor extends Editor<Alias>
|
|||||||
private AliasIdentifierEditor mAliasIdentifierEditor;
|
private AliasIdentifierEditor mAliasIdentifierEditor;
|
||||||
private AliasActionEditor mAliasActionEditor;
|
private AliasActionEditor mAliasActionEditor;
|
||||||
|
|
||||||
public AliasEditor(AliasModel aliasModel, BroadcastModel broadcastModel, SettingsManager settingsManager )
|
public AliasEditor(AliasModel aliasModel, BroadcastModel broadcastModel, IconManager iconManager )
|
||||||
{
|
{
|
||||||
mAliasModel = aliasModel;
|
mAliasModel = aliasModel;
|
||||||
mAliasNameEditor = new AliasNameEditor( mAliasModel, settingsManager );
|
mAliasNameEditor = new AliasNameEditor( mAliasModel, iconManager );
|
||||||
mAliasIdentifierEditor = new AliasIdentifierEditor( aliasModel, broadcastModel );
|
mAliasIdentifierEditor = new AliasIdentifierEditor( aliasModel, broadcastModel );
|
||||||
mAliasActionEditor = new AliasActionEditor( aliasModel );
|
mAliasActionEditor = new AliasActionEditor( aliasModel );
|
||||||
|
|
||||||
|
|||||||
@@ -1,31 +1,41 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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;
|
package alias;
|
||||||
|
|
||||||
|
import alias.AliasEvent.Event;
|
||||||
import gui.editor.Editor;
|
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 javax.swing.*;
|
||||||
import java.awt.Dimension;
|
import javax.swing.event.DocumentEvent;
|
||||||
import java.awt.EventQueue;
|
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.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.util.List;
|
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>
|
public class AliasNameEditor extends Editor<Alias>
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -34,25 +44,34 @@ public class AliasNameEditor extends Editor<Alias>
|
|||||||
|
|
||||||
private JComboBox<String> mListCombo = new JComboBox<>(EMPTY_MODEL);
|
private JComboBox<String> mListCombo = new JComboBox<>(EMPTY_MODEL);
|
||||||
private JComboBox<String> mGroupCombo = new JComboBox<>(EMPTY_MODEL);
|
private JComboBox<String> mGroupCombo = new JComboBox<>(EMPTY_MODEL);
|
||||||
private JComboBox<MapIcon> mMapIconCombo;
|
private JComboBox<Icon> mIconCombo;
|
||||||
private JTextField mName;
|
private JTextField mName;
|
||||||
private JButton mButtonColor;
|
private JButton mButtonColor;
|
||||||
private JButton mBtnIconManager;
|
private JButton mBtnIconManager;
|
||||||
|
|
||||||
private AliasModel mAliasModel;
|
private AliasModel mAliasModel;
|
||||||
private SettingsManager mSettingsManager;
|
private IconManager mIconManager;
|
||||||
|
|
||||||
public AliasNameEditor( AliasModel aliasModel, SettingsManager settingsManager )
|
public AliasNameEditor(AliasModel aliasModel, IconManager iconManager)
|
||||||
{
|
{
|
||||||
mAliasModel = aliasModel;
|
mAliasModel = aliasModel;
|
||||||
mSettingsManager = settingsManager;
|
mIconManager = iconManager;
|
||||||
|
|
||||||
|
mIconManager.getModel().addTableModelListener(new TableModelListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void tableChanged(TableModelEvent e)
|
||||||
|
{
|
||||||
|
refreshIcons();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
setLayout( new MigLayout( "fill,wrap 2", "[right][grow,fill]",
|
setLayout(new MigLayout("fill,wrap 2", "[right][grow,fill]", "[][][][][][][grow]"));
|
||||||
"[][][][][][][grow]" ) );
|
|
||||||
|
|
||||||
add(new JLabel("Name:"));
|
add(new JLabel("Name:"));
|
||||||
mName = new JTextField();
|
mName = new JTextField();
|
||||||
@@ -71,7 +90,9 @@ public class AliasNameEditor extends Editor<Alias>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void changedUpdate( DocumentEvent e ){}
|
public void changedUpdate(DocumentEvent e)
|
||||||
|
{
|
||||||
|
}
|
||||||
});
|
});
|
||||||
add(mName, "wrap");
|
add(mName, "wrap");
|
||||||
|
|
||||||
@@ -94,7 +115,8 @@ public class AliasNameEditor extends Editor<Alias>
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
mGroupCombo.setModel(new DefaultComboBoxModel<String>(
|
mGroupCombo.setModel(new DefaultComboBoxModel<String>(
|
||||||
groups.toArray( new String[ groups.size() ] ) ) );;
|
groups.toArray(new String[groups.size()])));
|
||||||
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,12 +163,12 @@ public class AliasNameEditor extends Editor<Alias>
|
|||||||
|
|
||||||
add(new JLabel("Icon:"));
|
add(new JLabel("Icon:"));
|
||||||
|
|
||||||
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));
|
renderer.setPreferredSize(new Dimension(200, 30));
|
||||||
mMapIconCombo.setRenderer( renderer );
|
mIconCombo.setRenderer(renderer);
|
||||||
mMapIconCombo.addActionListener( new ActionListener()
|
mIconCombo.addActionListener(new ActionListener()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e)
|
public void actionPerformed(ActionEvent e)
|
||||||
@@ -155,7 +177,7 @@ public class AliasNameEditor extends Editor<Alias>
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
add( mMapIconCombo, "wrap" );
|
add(mIconCombo, "wrap");
|
||||||
|
|
||||||
//Dummy place holder
|
//Dummy place holder
|
||||||
add(new JLabel());
|
add(new JLabel());
|
||||||
@@ -166,17 +188,7 @@ public class AliasNameEditor extends Editor<Alias>
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent arg0)
|
public void actionPerformed(ActionEvent arg0)
|
||||||
{
|
{
|
||||||
final IconManager iconManager =
|
mIconManager.showEditor(AliasNameEditor.this);
|
||||||
new IconManager( mSettingsManager, AliasNameEditor.this );
|
|
||||||
|
|
||||||
EventQueue.invokeLater( new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
iconManager.setVisible( true );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -185,6 +197,32 @@ public class AliasNameEditor extends Editor<Alias>
|
|||||||
setModified(false);
|
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
|
@Override
|
||||||
public void setItem(Alias alias)
|
public void setItem(Alias alias)
|
||||||
{
|
{
|
||||||
@@ -194,6 +232,8 @@ public class AliasNameEditor extends Editor<Alias>
|
|||||||
{
|
{
|
||||||
mName.setText(alias.getName());
|
mName.setText(alias.getName());
|
||||||
|
|
||||||
|
mIconCombo.setModel(new DefaultComboBoxModel<>(mIconManager.getIcons()));
|
||||||
|
|
||||||
List<String> listNames = mAliasModel.getListNames();
|
List<String> listNames = mAliasModel.getListNames();
|
||||||
|
|
||||||
if(listNames.isEmpty())
|
if(listNames.isEmpty())
|
||||||
@@ -203,7 +243,8 @@ public class AliasNameEditor extends Editor<Alias>
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
mListCombo.setModel(new DefaultComboBoxModel<String>(
|
mListCombo.setModel(new DefaultComboBoxModel<String>(
|
||||||
listNames.toArray( new String[ listNames.size() ] ) ) );;
|
listNames.toArray(new String[listNames.size()])));
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
mListCombo.setSelectedItem(alias.getList());
|
mListCombo.setSelectedItem(alias.getList());
|
||||||
@@ -217,7 +258,8 @@ public class AliasNameEditor extends Editor<Alias>
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
mGroupCombo.setModel(new DefaultComboBoxModel<String>(
|
mGroupCombo.setModel(new DefaultComboBoxModel<String>(
|
||||||
groupNames.toArray( new String[ groupNames.size() ] ) ) );;
|
groupNames.toArray(new String[groupNames.size()])));
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
mGroupCombo.setSelectedItem(alias.getGroup());
|
mGroupCombo.setSelectedItem(alias.getGroup());
|
||||||
@@ -231,14 +273,14 @@ public class AliasNameEditor extends Editor<Alias>
|
|||||||
|
|
||||||
if(iconName == null)
|
if(iconName == null)
|
||||||
{
|
{
|
||||||
iconName = SettingsManager.DEFAULT_ICON;
|
iconName = IconTableModel.DEFAULT_ICON;
|
||||||
}
|
}
|
||||||
|
|
||||||
MapIcon savedIcon = mSettingsManager.getMapIcon( iconName );
|
Icon savedIcon = mIconManager.getModel().getIcon(iconName);
|
||||||
|
|
||||||
if(savedIcon != null)
|
if(savedIcon != null)
|
||||||
{
|
{
|
||||||
mMapIconCombo.setSelectedItem( savedIcon );
|
mIconCombo.setSelectedItem(savedIcon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -277,9 +319,9 @@ public class AliasNameEditor extends Editor<Alias>
|
|||||||
|
|
||||||
alias.setColor(mButtonColor.getBackground().getRGB());
|
alias.setColor(mButtonColor.getBackground().getRGB());
|
||||||
|
|
||||||
if( mMapIconCombo.getSelectedItem() != null )
|
if(mIconCombo.getSelectedItem() != null)
|
||||||
{
|
{
|
||||||
alias.setIconName( ((MapIcon)mMapIconCombo.getSelectedItem()).getName() );
|
alias.setIconName(((Icon) mIconCombo.getSelectedItem()).getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
setModified(false);
|
setModified(false);
|
||||||
|
|||||||
@@ -1,41 +1,28 @@
|
|||||||
package alias;
|
package alias;
|
||||||
|
|
||||||
|
import alias.AliasEvent.Event;
|
||||||
import alias.id.AliasIDType;
|
import alias.id.AliasIDType;
|
||||||
import alias.id.broadcast.BroadcastChannel;
|
import alias.id.broadcast.BroadcastChannel;
|
||||||
|
import alias.id.priority.Priority;
|
||||||
import audio.broadcast.BroadcastModel;
|
import audio.broadcast.BroadcastModel;
|
||||||
import gui.editor.Editor;
|
import gui.editor.Editor;
|
||||||
|
import icon.Icon;
|
||||||
import java.awt.Color;
|
import icon.IconListCellRenderer;
|
||||||
import java.awt.Dimension;
|
import icon.IconManager;
|
||||||
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 net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import settings.SettingsManager;
|
|
||||||
import alias.AliasEvent.Event;
|
import javax.swing.*;
|
||||||
import alias.id.priority.Priority;
|
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>>
|
public class MultipleAliasEditor extends Editor<List<Alias>>
|
||||||
implements Listener<AliasEvent>
|
implements Listener<AliasEvent>
|
||||||
@@ -54,7 +41,7 @@ public class MultipleAliasEditor extends Editor<List<Alias>>
|
|||||||
private JCheckBox mGroupCheckBox = new JCheckBox("Group");
|
private JCheckBox mGroupCheckBox = new JCheckBox("Group");
|
||||||
private JComboBox<String> mGroupCombo = new JComboBox<>();
|
private JComboBox<String> mGroupCombo = new JComboBox<>();
|
||||||
private JCheckBox mIconCheckBox = new JCheckBox("Icon");
|
private JCheckBox mIconCheckBox = new JCheckBox("Icon");
|
||||||
private JComboBox<MapIcon> mMapIconCombo;
|
private JComboBox<Icon> mIconCombo;
|
||||||
private JCheckBox mColorCheckBox = new JCheckBox("Color");
|
private JCheckBox mColorCheckBox = new JCheckBox("Color");
|
||||||
private JButton mButtonColor;
|
private JButton mButtonColor;
|
||||||
private JButton mBtnIconManager;
|
private JButton mBtnIconManager;
|
||||||
@@ -68,15 +55,23 @@ public class MultipleAliasEditor extends Editor<List<Alias>>
|
|||||||
|
|
||||||
private AliasModel mAliasModel;
|
private AliasModel mAliasModel;
|
||||||
private BroadcastModel mBroadcastModel;
|
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;
|
mAliasModel = aliasModel;
|
||||||
mBroadcastModel = broadcastModel;
|
mBroadcastModel = broadcastModel;
|
||||||
mSettingsManager = settingsManager;
|
mIconManager = iconManager;
|
||||||
|
|
||||||
mAliasModel.addListener(this);
|
mAliasModel.addListener(this);
|
||||||
|
mIconManager.getModel().addTableModelListener(new TableModelListener()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void tableChanged(TableModelEvent e)
|
||||||
|
{
|
||||||
|
refreshIcons();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@@ -139,12 +134,12 @@ public class MultipleAliasEditor extends Editor<List<Alias>>
|
|||||||
|
|
||||||
add(mIconCheckBox);
|
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));
|
renderer.setPreferredSize(new Dimension(200, 30));
|
||||||
mMapIconCombo.setRenderer(renderer);
|
mIconCombo.setRenderer(renderer);
|
||||||
add(mMapIconCombo, "wrap");
|
add(mIconCombo, "wrap");
|
||||||
|
|
||||||
//Dummy place holder
|
//Dummy place holder
|
||||||
add(new JLabel());
|
add(new JLabel());
|
||||||
@@ -155,17 +150,7 @@ public class MultipleAliasEditor extends Editor<List<Alias>>
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent arg0)
|
public void actionPerformed(ActionEvent arg0)
|
||||||
{
|
{
|
||||||
final IconManager iconManager =
|
mIconManager.showEditor(MultipleAliasEditor.this);
|
||||||
new IconManager(mSettingsManager, MultipleAliasEditor.this);
|
|
||||||
|
|
||||||
EventQueue.invokeLater(new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
iconManager.setVisible(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -243,6 +228,21 @@ public class MultipleAliasEditor extends Editor<List<Alias>>
|
|||||||
setModified(false);
|
setModified(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void refreshIcons()
|
||||||
|
{
|
||||||
|
if(mIconCombo != null)
|
||||||
|
{
|
||||||
|
EventQueue.invokeLater(new Runnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
mIconCombo.setModel(new DefaultComboBoxModel<>(mIconManager.getIcons()));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setItem(List<Alias> item)
|
public void setItem(List<Alias> item)
|
||||||
{
|
{
|
||||||
@@ -277,6 +277,8 @@ public class MultipleAliasEditor extends Editor<List<Alias>>
|
|||||||
List<String> streamNames = mBroadcastModel.getBroadcastConfigurationNames();
|
List<String> streamNames = mBroadcastModel.getBroadcastConfigurationNames();
|
||||||
mStreamCombo.setModel(new DefaultComboBoxModel<String>(streamNames.toArray(new String[streamNames.size()])));
|
mStreamCombo.setModel(new DefaultComboBoxModel<String>(streamNames.toArray(new String[streamNames.size()])));
|
||||||
|
|
||||||
|
mIconCombo.setModel(new DefaultComboBoxModel<>(mIconManager.getIcons()));
|
||||||
|
|
||||||
setCheckBoxesUnselected();
|
setCheckBoxesUnselected();
|
||||||
|
|
||||||
setModified(false);
|
setModified(false);
|
||||||
@@ -363,9 +365,9 @@ public class MultipleAliasEditor extends Editor<List<Alias>>
|
|||||||
|
|
||||||
if (mIconCheckBox.isSelected())
|
if (mIconCheckBox.isSelected())
|
||||||
{
|
{
|
||||||
if (mMapIconCombo.getSelectedItem() != null)
|
if (mIconCombo.getSelectedItem() != null)
|
||||||
{
|
{
|
||||||
alias.setIconName(((MapIcon) mMapIconCombo.getSelectedItem()).getName());
|
alias.setIconName(((Icon)mIconCombo.getSelectedItem()).getName());
|
||||||
}
|
}
|
||||||
else
|
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;
|
package audio;
|
||||||
|
|
||||||
import java.awt.Color;
|
import alias.Alias;
|
||||||
import java.awt.EventQueue;
|
import audio.metadata.AudioMetadata;
|
||||||
import java.awt.Font;
|
import audio.metadata.Metadata;
|
||||||
|
import audio.metadata.MetadataType;
|
||||||
import javax.swing.JLabel;
|
import audio.output.AudioOutput;
|
||||||
import javax.swing.JPanel;
|
import icon.IconManager;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import settings.ColorSetting;
|
import settings.ColorSetting;
|
||||||
@@ -14,11 +31,9 @@ import settings.ColorSetting.ColorSettingName;
|
|||||||
import settings.Setting;
|
import settings.Setting;
|
||||||
import settings.SettingChangeListener;
|
import settings.SettingChangeListener;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
import alias.Alias;
|
|
||||||
import audio.metadata.AudioMetadata;
|
import javax.swing.*;
|
||||||
import audio.metadata.Metadata;
|
import java.awt.*;
|
||||||
import audio.metadata.MetadataType;
|
|
||||||
import audio.output.AudioOutput;
|
|
||||||
|
|
||||||
public class AudioChannelPanel extends JPanel
|
public class AudioChannelPanel extends JPanel
|
||||||
implements Listener<AudioEvent>, SettingChangeListener
|
implements Listener<AudioEvent>, SettingChangeListener
|
||||||
@@ -29,6 +44,7 @@ public class AudioChannelPanel extends JPanel
|
|||||||
private Color mLabelColor;
|
private Color mLabelColor;
|
||||||
private Color mDetailsColor;
|
private Color mDetailsColor;
|
||||||
|
|
||||||
|
private IconManager mIconManager;
|
||||||
private SettingsManager mSettingsManager;
|
private SettingsManager mSettingsManager;
|
||||||
private AudioOutput mAudioOutput;
|
private AudioOutput mAudioOutput;
|
||||||
|
|
||||||
@@ -44,8 +60,9 @@ public class AudioChannelPanel extends JPanel
|
|||||||
|
|
||||||
private boolean mConfigured = false;
|
private boolean mConfigured = false;
|
||||||
|
|
||||||
public AudioChannelPanel( SettingsManager settingsManager, AudioOutput audioOutput )
|
public AudioChannelPanel(IconManager iconManager, SettingsManager settingsManager, AudioOutput audioOutput)
|
||||||
{
|
{
|
||||||
|
mIconManager = iconManager;
|
||||||
mSettingsManager = settingsManager;
|
mSettingsManager = settingsManager;
|
||||||
mSettingsManager.addListener(this);
|
mSettingsManager.addListener(this);
|
||||||
|
|
||||||
@@ -180,8 +197,7 @@ public class AudioChannelPanel extends JPanel
|
|||||||
|
|
||||||
if(icon != null)
|
if(icon != null)
|
||||||
{
|
{
|
||||||
label.setIcon( mSettingsManager.getImageIcon( icon,
|
label.setIcon(mIconManager.getIcon(icon, IconManager.DEFAULT_ICON_SIZE));
|
||||||
SettingsManager.DEFAULT_ICON_SIZE ) );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -287,5 +303,7 @@ public class AudioChannelPanel extends JPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void settingDeleted( Setting setting ) {}
|
public void settingDeleted(Setting setting)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,37 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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;
|
package audio;
|
||||||
|
|
||||||
import java.awt.Color;
|
import audio.output.AudioOutput;
|
||||||
import java.util.List;
|
import icon.IconManager;
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
import javax.swing.JSeparator;
|
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
import audio.output.AudioOutput;
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class AudioChannelsPanel extends JPanel
|
public class AudioChannelsPanel extends JPanel
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public AudioChannelsPanel( SettingsManager settingsManager,
|
public AudioChannelsPanel(IconManager iconManager, SettingsManager settingsManager, IAudioController controller)
|
||||||
IAudioController controller )
|
|
||||||
{
|
{
|
||||||
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[]0[]"));
|
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[]0[]"));
|
||||||
|
|
||||||
@@ -25,7 +41,7 @@ public class AudioChannelsPanel extends JPanel
|
|||||||
|
|
||||||
for(int x = 0; x < outputs.size(); x++)
|
for(int x = 0; x < outputs.size(); x++)
|
||||||
{
|
{
|
||||||
add( new AudioChannelPanel( settingsManager, outputs.get( x ) ), "wrap" );
|
add(new AudioChannelPanel(iconManager, settingsManager, outputs.get(x)), "wrap");
|
||||||
|
|
||||||
if(x < outputs.size() - 1)
|
if(x < outputs.size() - 1)
|
||||||
{
|
{
|
||||||
@@ -38,7 +54,7 @@ public class AudioChannelsPanel extends JPanel
|
|||||||
if(outputs.size() == 1)
|
if(outputs.size() == 1)
|
||||||
{
|
{
|
||||||
addSeparator();
|
addSeparator();
|
||||||
add( new AudioChannelPanel( settingsManager, null ), "wrap" );
|
add(new AudioChannelPanel(iconManager, settingsManager, null), "wrap");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,35 +1,42 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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;
|
package audio;
|
||||||
|
|
||||||
import java.awt.Color;
|
import audio.output.AudioOutput;
|
||||||
import java.awt.EventQueue;
|
import icon.IconManager;
|
||||||
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 net.miginfocom.swing.MigLayout;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
import source.SourceManager;
|
import source.SourceManager;
|
||||||
import source.mixer.MixerChannelConfiguration;
|
import source.mixer.MixerChannelConfiguration;
|
||||||
import audio.output.AudioOutput;
|
|
||||||
|
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;
|
||||||
|
|
||||||
public class AudioPanel extends JPanel implements Listener<AudioEvent>
|
public class AudioPanel extends JPanel implements Listener<AudioEvent>
|
||||||
{
|
{
|
||||||
@@ -37,11 +44,12 @@ public class AudioPanel extends JPanel implements Listener<AudioEvent>
|
|||||||
|
|
||||||
private static final Logger mLog = LoggerFactory.getLogger(AudioPanel.class);
|
private static final Logger mLog = LoggerFactory.getLogger(AudioPanel.class);
|
||||||
|
|
||||||
private static ImageIcon MUTED_ICON = SettingsManager.getScaledIcon(
|
private static ImageIcon MUTED_ICON = IconManager.getScaledIcon(
|
||||||
new ImageIcon("images/audio_muted.png"), 38);
|
new ImageIcon("images/audio_muted.png"), 38);
|
||||||
private static ImageIcon UNMUTED_ICON = SettingsManager.getScaledIcon(
|
private static ImageIcon UNMUTED_ICON = IconManager.getScaledIcon(
|
||||||
new ImageIcon("images/audio_unmuted.png"), 38);
|
new ImageIcon("images/audio_unmuted.png"), 38);
|
||||||
|
|
||||||
|
private IconManager mIconManager;
|
||||||
private SettingsManager mSettingsManager;
|
private SettingsManager mSettingsManager;
|
||||||
private SourceManager mSourceManager;
|
private SourceManager mSourceManager;
|
||||||
private IAudioController mController;
|
private IAudioController mController;
|
||||||
@@ -49,10 +57,10 @@ public class AudioPanel extends JPanel implements Listener<AudioEvent>
|
|||||||
private JButton mMuteButton;
|
private JButton mMuteButton;
|
||||||
private AudioChannelsPanel mAudioChannelsPanel;
|
private AudioChannelsPanel mAudioChannelsPanel;
|
||||||
|
|
||||||
public AudioPanel( SettingsManager settingsManager,
|
public AudioPanel(IconManager iconManager, SettingsManager settingsManager, SourceManager sourceManager,
|
||||||
SourceManager sourceManager,
|
|
||||||
IAudioController controller)
|
IAudioController controller)
|
||||||
{
|
{
|
||||||
|
mIconManager = iconManager;
|
||||||
mSettingsManager = settingsManager;
|
mSettingsManager = settingsManager;
|
||||||
mSourceManager = sourceManager;
|
mSourceManager = sourceManager;
|
||||||
mController = controller;
|
mController = controller;
|
||||||
@@ -71,7 +79,7 @@ public class AudioPanel extends JPanel implements Listener<AudioEvent>
|
|||||||
mMuteButton.setBackground(getBackground());
|
mMuteButton.setBackground(getBackground());
|
||||||
add(mMuteButton);
|
add(mMuteButton);
|
||||||
|
|
||||||
mAudioChannelsPanel = new AudioChannelsPanel( mSettingsManager, mController );
|
mAudioChannelsPanel = new AudioChannelsPanel(mIconManager, mSettingsManager, mController);
|
||||||
|
|
||||||
add(mAudioChannelsPanel);
|
add(mAudioChannelsPanel);
|
||||||
|
|
||||||
@@ -93,8 +101,7 @@ public class AudioPanel extends JPanel implements Listener<AudioEvent>
|
|||||||
{
|
{
|
||||||
remove(mAudioChannelsPanel);
|
remove(mAudioChannelsPanel);
|
||||||
|
|
||||||
mAudioChannelsPanel = new AudioChannelsPanel(
|
mAudioChannelsPanel = new AudioChannelsPanel(mIconManager, mSettingsManager, mController);
|
||||||
mSettingsManager, mController );
|
|
||||||
|
|
||||||
add(mAudioChannelsPanel);
|
add(mAudioChannelsPanel);
|
||||||
|
|
||||||
@@ -200,13 +207,24 @@ public class AudioPanel extends JPanel implements Listener<AudioEvent>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mousePressed( MouseEvent e ) {}
|
public void mousePressed(MouseEvent e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased( MouseEvent e ) {}
|
public void mouseReleased(MouseEvent e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseEntered( MouseEvent e ) {}
|
public void mouseEntered(MouseEvent e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseExited( MouseEvent e ) {}
|
public void mouseExited(MouseEvent e)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -253,10 +271,21 @@ public class AudioPanel extends JPanel implements Listener<AudioEvent>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mouseReleased( MouseEvent arg0 ) {}
|
public void mouseReleased(MouseEvent arg0)
|
||||||
public void mousePressed( MouseEvent arg0 ) {}
|
{
|
||||||
public void mouseExited( MouseEvent arg0 ) {}
|
}
|
||||||
public void mouseEntered( MouseEvent arg0 ) {}
|
|
||||||
|
public void mousePressed(MouseEvent arg0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mouseExited(MouseEvent arg0)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void mouseEntered(MouseEvent arg0)
|
||||||
|
{
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,24 +19,22 @@
|
|||||||
package audio.broadcast;
|
package audio.broadcast;
|
||||||
|
|
||||||
import alias.AliasModel;
|
import alias.AliasModel;
|
||||||
import audio.broadcast.broadcastify.BroadcastifyConfiguration;
|
|
||||||
import audio.broadcast.broadcastify.BroadcastifyConfigurationEditor;
|
|
||||||
import gui.editor.DocumentListenerEditor;
|
import gui.editor.DocumentListenerEditor;
|
||||||
import settings.SettingsManager;
|
import icon.IconManager;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
|
||||||
public abstract class BroadcastConfigurationEditor extends DocumentListenerEditor<BroadcastConfiguration>
|
public abstract class BroadcastConfigurationEditor extends DocumentListenerEditor<BroadcastConfiguration>
|
||||||
{
|
{
|
||||||
protected SettingsManager mSettingsManager;
|
protected IconManager mIconManager;
|
||||||
protected BroadcastModel mBroadcastModel;
|
protected BroadcastModel mBroadcastModel;
|
||||||
protected AliasModel mAliasModel;
|
protected AliasModel mAliasModel;
|
||||||
|
|
||||||
public BroadcastConfigurationEditor(BroadcastModel broadcastModel, AliasModel aliasModel, SettingsManager settingsManager)
|
public BroadcastConfigurationEditor(BroadcastModel broadcastModel, AliasModel aliasModel, IconManager iconManager)
|
||||||
{
|
{
|
||||||
mBroadcastModel = broadcastModel;
|
mBroadcastModel = broadcastModel;
|
||||||
mAliasModel = aliasModel;
|
mAliasModel = aliasModel;
|
||||||
mSettingsManager = settingsManager;
|
mIconManager = iconManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import audio.convert.MP3SilenceGenerator;
|
|||||||
import controller.ThreadPoolManager;
|
import controller.ThreadPoolManager;
|
||||||
import gui.editor.Editor;
|
import gui.editor.Editor;
|
||||||
import gui.editor.EmptyEditor;
|
import gui.editor.EmptyEditor;
|
||||||
|
import icon.IconManager;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import record.AudioRecorder;
|
import record.AudioRecorder;
|
||||||
@@ -155,26 +156,26 @@ public class BroadcastFactory
|
|||||||
public static Editor<BroadcastConfiguration> getEditor(BroadcastConfiguration configuration,
|
public static Editor<BroadcastConfiguration> getEditor(BroadcastConfiguration configuration,
|
||||||
BroadcastModel broadcastModel,
|
BroadcastModel broadcastModel,
|
||||||
AliasModel aliasModel,
|
AliasModel aliasModel,
|
||||||
SettingsManager settingsManager)
|
IconManager iconManager)
|
||||||
{
|
{
|
||||||
Editor<BroadcastConfiguration> editor;
|
Editor<BroadcastConfiguration> editor;
|
||||||
|
|
||||||
switch (configuration.getBroadcastServerType())
|
switch (configuration.getBroadcastServerType())
|
||||||
{
|
{
|
||||||
case BROADCASTIFY:
|
case BROADCASTIFY:
|
||||||
editor = new BroadcastifyConfigurationEditor(broadcastModel, aliasModel, settingsManager);
|
editor = new BroadcastifyConfigurationEditor(broadcastModel, aliasModel, iconManager);
|
||||||
break;
|
break;
|
||||||
case ICECAST_TCP:
|
case ICECAST_TCP:
|
||||||
editor = new IcecastTCPConfigurationEditor(broadcastModel, aliasModel, settingsManager);
|
editor = new IcecastTCPConfigurationEditor(broadcastModel, aliasModel, iconManager);
|
||||||
break;
|
break;
|
||||||
case ICECAST_HTTP:
|
case ICECAST_HTTP:
|
||||||
editor = new IcecastHTTPConfigurationEditor(broadcastModel, aliasModel, settingsManager);
|
editor = new IcecastHTTPConfigurationEditor(broadcastModel, aliasModel, iconManager);
|
||||||
break;
|
break;
|
||||||
case SHOUTCAST_V1:
|
case SHOUTCAST_V1:
|
||||||
editor = new ShoutcastV1ConfigurationEditor(broadcastModel, aliasModel, settingsManager);
|
editor = new ShoutcastV1ConfigurationEditor(broadcastModel, aliasModel, iconManager);
|
||||||
break;
|
break;
|
||||||
case SHOUTCAST_V2:
|
case SHOUTCAST_V2:
|
||||||
editor = new ShoutcastV2ConfigurationEditor(broadcastModel, aliasModel, settingsManager);
|
editor = new ShoutcastV2ConfigurationEditor(broadcastModel, aliasModel, iconManager);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
editor = new EmptyEditor<BroadcastConfiguration>();
|
editor = new EmptyEditor<BroadcastConfiguration>();
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ import alias.id.broadcast.BroadcastChannel;
|
|||||||
import audio.AudioPacket;
|
import audio.AudioPacket;
|
||||||
import audio.metadata.AudioMetadata;
|
import audio.metadata.AudioMetadata;
|
||||||
import controller.ThreadPoolManager;
|
import controller.ThreadPoolManager;
|
||||||
|
import icon.IconManager;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import properties.SystemProperties;
|
import properties.SystemProperties;
|
||||||
import sample.Broadcaster;
|
import sample.Broadcaster;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import settings.SettingsManager;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.table.AbstractTableModel;
|
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,BroadcastConfiguration> mBroadcastConfigurationMap = new HashMap<>();
|
||||||
private Map<String,AudioBroadcaster> mBroadcasterMap = new HashMap<>();
|
private Map<String,AudioBroadcaster> mBroadcasterMap = new HashMap<>();
|
||||||
private ThreadPoolManager mThreadPoolManager;
|
private ThreadPoolManager mThreadPoolManager;
|
||||||
private SettingsManager mSettingsManager;
|
private IconManager mIconManager;
|
||||||
private StreamManager mStreamManager;
|
private StreamManager mStreamManager;
|
||||||
private Broadcaster<BroadcastEvent> mBroadcastEventBroadcaster = new Broadcaster<>();
|
private Broadcaster<BroadcastEvent> mBroadcastEventBroadcaster = new Broadcaster<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Model for managing Broadcast configurations and any associated broadcaster instances.
|
* Model for managing Broadcast configurations and any associated broadcaster instances.
|
||||||
*/
|
*/
|
||||||
public BroadcastModel(ThreadPoolManager threadPoolManager, SettingsManager settingsManager)
|
public BroadcastModel(ThreadPoolManager threadPoolManager, IconManager iconManager)
|
||||||
{
|
{
|
||||||
mThreadPoolManager = threadPoolManager;
|
mThreadPoolManager = threadPoolManager;
|
||||||
mSettingsManager = settingsManager;
|
mIconManager = iconManager;
|
||||||
mStreamManager = new StreamManager(threadPoolManager, new CompletedRecordingListener(), BroadcastFormat.MP3,
|
mStreamManager = new StreamManager(threadPoolManager, new CompletedRecordingListener(), BroadcastFormat.MP3,
|
||||||
SystemProperties.getInstance().getApplicationFolder(TEMPORARY_STREAM_DIRECTORY));
|
SystemProperties.getInstance().getApplicationFolder(TEMPORARY_STREAM_DIRECTORY));
|
||||||
mStreamManager.start();
|
mStreamManager.start();
|
||||||
@@ -497,11 +497,11 @@ public class BroadcastModel extends AbstractTableModel implements Listener<Audio
|
|||||||
switch(columnIndex)
|
switch(columnIndex)
|
||||||
{
|
{
|
||||||
case COLUMN_SERVER_ICON:
|
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;
|
break;
|
||||||
case COLUMN_STREAM_NAME:
|
case COLUMN_STREAM_NAME:
|
||||||
|
|||||||
@@ -22,19 +22,16 @@ import alias.AliasModel;
|
|||||||
import com.jidesoft.swing.JideSplitPane;
|
import com.jidesoft.swing.JideSplitPane;
|
||||||
import gui.editor.Editor;
|
import gui.editor.Editor;
|
||||||
import gui.editor.EmptyEditor;
|
import gui.editor.EmptyEditor;
|
||||||
|
import icon.IconManager;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.event.ChangeEvent;
|
|
||||||
import javax.swing.event.ListSelectionEvent;
|
import javax.swing.event.ListSelectionEvent;
|
||||||
import javax.swing.event.ListSelectionListener;
|
import javax.swing.event.ListSelectionListener;
|
||||||
import javax.swing.event.TableColumnModelEvent;
|
|
||||||
import javax.swing.event.TableColumnModelListener;
|
|
||||||
import javax.swing.table.DefaultTableCellRenderer;
|
import javax.swing.table.DefaultTableCellRenderer;
|
||||||
import javax.swing.table.TableCellRenderer;
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
@@ -51,7 +48,7 @@ public class BroadcastPanel extends JPanel implements ActionListener, ListSelect
|
|||||||
|
|
||||||
private BroadcastModel mBroadcastModel;
|
private BroadcastModel mBroadcastModel;
|
||||||
private AliasModel mAliasModel;
|
private AliasModel mAliasModel;
|
||||||
private SettingsManager mSettingsManager;
|
private IconManager mIconManager;
|
||||||
|
|
||||||
private JTable mBroadcastConfigurationTable;
|
private JTable mBroadcastConfigurationTable;
|
||||||
private JideSplitPane mSplitPane;
|
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 mCopyButton = new JButton(COPY_BROADCAST_CONFIGURATION);
|
||||||
private JButton mDeleteButton = new JButton(DELETE_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;
|
mBroadcastModel = broadcastModel;
|
||||||
mAliasModel = aliasModel;
|
mAliasModel = aliasModel;
|
||||||
mSettingsManager = settingManager;
|
mIconManager = iconManager;
|
||||||
mEditor = mEmptyEditor;
|
mEditor = mEmptyEditor;
|
||||||
|
|
||||||
init();
|
init();
|
||||||
@@ -218,7 +215,7 @@ public class BroadcastPanel extends JPanel implements ActionListener, ListSelect
|
|||||||
if (selectedConfiguration != null)
|
if (selectedConfiguration != null)
|
||||||
{
|
{
|
||||||
mEditor = BroadcastFactory.getEditor(selectedConfiguration, mBroadcastModel, mAliasModel,
|
mEditor = BroadcastFactory.getEditor(selectedConfiguration, mBroadcastModel, mAliasModel,
|
||||||
mSettingsManager);
|
mIconManager);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -239,7 +236,7 @@ public class BroadcastPanel extends JPanel implements ActionListener, ListSelect
|
|||||||
|
|
||||||
public AddBroadcastConfigurationItem(BroadcastServerType type)
|
public AddBroadcastConfigurationItem(BroadcastServerType type)
|
||||||
{
|
{
|
||||||
super(type.toString(), mSettingsManager.getImageIcon(type.getIconName(), 14));
|
super(type.toString(), mIconManager.getScaledIcon(new ImageIcon(type.getIconPath()), 14));
|
||||||
|
|
||||||
mBroadcastServerType = type;
|
mBroadcastServerType = type;
|
||||||
|
|
||||||
|
|||||||
@@ -28,12 +28,12 @@ public enum BroadcastServerType
|
|||||||
UNKNOWN("Unknown", null);
|
UNKNOWN("Unknown", null);
|
||||||
|
|
||||||
private String mLabel;
|
private String mLabel;
|
||||||
private String mIconName;
|
private String mIconPath;
|
||||||
|
|
||||||
BroadcastServerType(String label, String iconName)
|
BroadcastServerType(String label, String iconPath)
|
||||||
{
|
{
|
||||||
mLabel = label;
|
mLabel = label;
|
||||||
mIconName = iconName;
|
mIconPath = iconPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString()
|
public String toString()
|
||||||
@@ -41,8 +41,8 @@ public enum BroadcastServerType
|
|||||||
return mLabel;
|
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.BroadcastModel;
|
||||||
import audio.broadcast.BroadcastServerType;
|
import audio.broadcast.BroadcastServerType;
|
||||||
import com.radioreference.api.soap2.UserFeedBroadcast;
|
import com.radioreference.api.soap2.UserFeedBroadcast;
|
||||||
import gui.editor.DocumentListenerEditor;
|
import icon.IconManager;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import settings.SettingsManager;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.event.ChangeEvent;
|
import javax.swing.event.ChangeEvent;
|
||||||
@@ -57,10 +56,9 @@ public class BroadcastifyConfigurationEditor extends BroadcastConfigurationEdito
|
|||||||
private JButton mSaveButton;
|
private JButton mSaveButton;
|
||||||
private JButton mResetButton;
|
private JButton mResetButton;
|
||||||
|
|
||||||
public BroadcastifyConfigurationEditor(BroadcastModel broadcastModel, AliasModel aliasModel,
|
public BroadcastifyConfigurationEditor(BroadcastModel broadcastModel, AliasModel aliasModel, IconManager iconManager)
|
||||||
SettingsManager settingsManager)
|
|
||||||
{
|
{
|
||||||
super(broadcastModel, aliasModel, settingsManager);
|
super(broadcastModel, aliasModel, iconManager);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@@ -74,7 +72,8 @@ public class BroadcastifyConfigurationEditor extends BroadcastConfigurationEdito
|
|||||||
|
|
||||||
JLabel channelLabel = new JLabel("Broadcastify Stream");
|
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);
|
channelLabel.setIcon(broadcastifyIcon);
|
||||||
add(channelLabel, "span, align center");
|
add(channelLabel, "span, align center");
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import audio.broadcast.BroadcastConfigurationEditor;
|
|||||||
import audio.broadcast.BroadcastEvent;
|
import audio.broadcast.BroadcastEvent;
|
||||||
import audio.broadcast.BroadcastModel;
|
import audio.broadcast.BroadcastModel;
|
||||||
import audio.broadcast.BroadcastServerType;
|
import audio.broadcast.BroadcastServerType;
|
||||||
|
import icon.IconManager;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -57,10 +58,9 @@ public class IcecastHTTPConfigurationEditor extends BroadcastConfigurationEditor
|
|||||||
private JButton mSaveButton;
|
private JButton mSaveButton;
|
||||||
private JButton mResetButton;
|
private JButton mResetButton;
|
||||||
|
|
||||||
public IcecastHTTPConfigurationEditor(BroadcastModel broadcastModel, AliasModel aliasModel,
|
public IcecastHTTPConfigurationEditor(BroadcastModel broadcastModel, AliasModel aliasModel, IconManager iconManager)
|
||||||
SettingsManager settingsManager)
|
|
||||||
{
|
{
|
||||||
super(broadcastModel, aliasModel, settingsManager);
|
super(broadcastModel, aliasModel, iconManager);
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ public class IcecastHTTPConfigurationEditor extends BroadcastConfigurationEditor
|
|||||||
|
|
||||||
JLabel channelLabel = new JLabel("Icecast 2 (v2.4+) Stream");
|
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);
|
channelLabel.setIcon(icon);
|
||||||
|
|
||||||
add(channelLabel, "span, align center");
|
add(channelLabel, "span, align center");
|
||||||
|
|||||||
@@ -24,8 +24,7 @@ import audio.broadcast.BroadcastConfigurationEditor;
|
|||||||
import audio.broadcast.BroadcastEvent;
|
import audio.broadcast.BroadcastEvent;
|
||||||
import audio.broadcast.BroadcastModel;
|
import audio.broadcast.BroadcastModel;
|
||||||
import audio.broadcast.BroadcastServerType;
|
import audio.broadcast.BroadcastServerType;
|
||||||
import audio.broadcast.broadcastify.BroadcastifyConfiguration;
|
import icon.IconManager;
|
||||||
import gui.editor.DocumentListenerEditor;
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -58,10 +57,9 @@ public class IcecastTCPConfigurationEditor extends BroadcastConfigurationEditor
|
|||||||
private JButton mSaveButton;
|
private JButton mSaveButton;
|
||||||
private JButton mResetButton;
|
private JButton mResetButton;
|
||||||
|
|
||||||
public IcecastTCPConfigurationEditor(BroadcastModel broadcastModel, AliasModel aliasModel,
|
public IcecastTCPConfigurationEditor(BroadcastModel broadcastModel, AliasModel aliasModel, IconManager iconManager)
|
||||||
SettingsManager settingsManager)
|
|
||||||
{
|
{
|
||||||
super(broadcastModel, aliasModel, settingsManager);
|
super(broadcastModel, aliasModel, iconManager);
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +71,7 @@ public class IcecastTCPConfigurationEditor extends BroadcastConfigurationEditor
|
|||||||
|
|
||||||
JLabel channelLabel = new JLabel("Icecast (v2.3) Stream");
|
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);
|
channelLabel.setIcon(icon);
|
||||||
|
|
||||||
add(channelLabel, "span, align center");
|
add(channelLabel, "span, align center");
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ import audio.broadcast.BroadcastConfigurationEditor;
|
|||||||
import audio.broadcast.BroadcastEvent;
|
import audio.broadcast.BroadcastEvent;
|
||||||
import audio.broadcast.BroadcastModel;
|
import audio.broadcast.BroadcastModel;
|
||||||
import audio.broadcast.BroadcastServerType;
|
import audio.broadcast.BroadcastServerType;
|
||||||
|
import icon.IconManager;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import settings.SettingsManager;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.event.ChangeEvent;
|
import javax.swing.event.ChangeEvent;
|
||||||
@@ -55,10 +55,9 @@ public class ShoutcastV1ConfigurationEditor extends BroadcastConfigurationEditor
|
|||||||
private JButton mSaveButton;
|
private JButton mSaveButton;
|
||||||
private JButton mResetButton;
|
private JButton mResetButton;
|
||||||
|
|
||||||
public ShoutcastV1ConfigurationEditor(BroadcastModel broadcastModel, AliasModel aliasModel,
|
public ShoutcastV1ConfigurationEditor(BroadcastModel broadcastModel, AliasModel aliasModel, IconManager iconManager)
|
||||||
SettingsManager settingsManager)
|
|
||||||
{
|
{
|
||||||
super(broadcastModel, aliasModel, settingsManager);
|
super(broadcastModel, aliasModel, iconManager);
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +69,7 @@ public class ShoutcastV1ConfigurationEditor extends BroadcastConfigurationEditor
|
|||||||
|
|
||||||
JLabel channelLabel = new JLabel("Shoutcast (v1.x) Stream");
|
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);
|
channelLabel.setIcon(icon);
|
||||||
|
|
||||||
add(channelLabel, "span, align center");
|
add(channelLabel, "span, align center");
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ import audio.broadcast.BroadcastConfigurationEditor;
|
|||||||
import audio.broadcast.BroadcastEvent;
|
import audio.broadcast.BroadcastEvent;
|
||||||
import audio.broadcast.BroadcastModel;
|
import audio.broadcast.BroadcastModel;
|
||||||
import audio.broadcast.BroadcastServerType;
|
import audio.broadcast.BroadcastServerType;
|
||||||
|
import icon.IconManager;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import settings.SettingsManager;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.event.ChangeEvent;
|
import javax.swing.event.ChangeEvent;
|
||||||
@@ -56,10 +56,9 @@ public class ShoutcastV2ConfigurationEditor extends BroadcastConfigurationEditor
|
|||||||
private JButton mSaveButton;
|
private JButton mSaveButton;
|
||||||
private JButton mResetButton;
|
private JButton mResetButton;
|
||||||
|
|
||||||
public ShoutcastV2ConfigurationEditor(BroadcastModel broadcastModel, AliasModel aliasModel,
|
public ShoutcastV2ConfigurationEditor(BroadcastModel broadcastModel, AliasModel aliasModel, IconManager iconManager)
|
||||||
SettingsManager settingsManager)
|
|
||||||
{
|
{
|
||||||
super(broadcastModel, aliasModel, settingsManager);
|
super(broadcastModel, aliasModel, iconManager);
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +70,7 @@ public class ShoutcastV2ConfigurationEditor extends BroadcastConfigurationEditor
|
|||||||
|
|
||||||
JLabel channelLabel = new JLabel("Shoutcast (v2) Stream");
|
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);
|
channelLabel.setIcon(icon);
|
||||||
|
|
||||||
add(channelLabel, "span, align center");
|
add(channelLabel, "span, align center");
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import javax.swing.event.ChangeListener;
|
|||||||
|
|
||||||
import audio.broadcast.BroadcastModel;
|
import audio.broadcast.BroadcastModel;
|
||||||
import audio.broadcast.BroadcastPanel;
|
import audio.broadcast.BroadcastPanel;
|
||||||
|
import icon.IconManager;
|
||||||
import map.MapPanel;
|
import map.MapPanel;
|
||||||
import map.MapService;
|
import map.MapService;
|
||||||
import module.decode.event.CallEventPanel;
|
import module.decode.event.CallEventPanel;
|
||||||
@@ -78,6 +79,7 @@ public class ControllerPanel extends JPanel
|
|||||||
ChannelModel channelModel,
|
ChannelModel channelModel,
|
||||||
ChannelMapModel channelMapModel,
|
ChannelMapModel channelMapModel,
|
||||||
ChannelProcessingManager channelProcessingManager,
|
ChannelProcessingManager channelProcessingManager,
|
||||||
|
IconManager iconManager,
|
||||||
MapService mapService,
|
MapService mapService,
|
||||||
SettingsManager settingsManager,
|
SettingsManager settingsManager,
|
||||||
SourceManager sourceManager,
|
SourceManager sourceManager,
|
||||||
@@ -85,27 +87,26 @@ public class ControllerPanel extends JPanel
|
|||||||
{
|
{
|
||||||
mChannelModel = channelModel;
|
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);
|
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,
|
mChannelSpectrumPanel = new ChannelSpectrumPanel(settingsManager,
|
||||||
channelProcessingManager);
|
channelProcessingManager);
|
||||||
|
|
||||||
mChannelStateList = new ChannelList(channelModel, channelProcessingManager,
|
mChannelStateList = new ChannelList(channelModel, channelProcessingManager, iconManager,
|
||||||
settingsManager, mAudioPanel);
|
settingsManager, mAudioPanel);
|
||||||
|
|
||||||
mChannelController = new ChannelController(channelModel, channelMapModel,
|
mChannelController = new ChannelController(channelModel, channelMapModel,
|
||||||
sourceManager, aliasModel);
|
sourceManager, aliasModel);
|
||||||
|
|
||||||
mAliasController = new AliasController(aliasModel, broadcastModel, settingsManager);
|
mAliasController = new AliasController(aliasModel, broadcastModel, iconManager);
|
||||||
|
|
||||||
mTunerManagerPanel = new TunerViewPanel(tunerModel);
|
mTunerManagerPanel = new TunerViewPanel(tunerModel);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import controller.channel.ChannelModel;
|
|||||||
import controller.channel.ChannelProcessingManager;
|
import controller.channel.ChannelProcessingManager;
|
||||||
import controller.channel.ChannelSelectionManager;
|
import controller.channel.ChannelSelectionManager;
|
||||||
import controller.channel.map.ChannelMapModel;
|
import controller.channel.map.ChannelMapModel;
|
||||||
import map.IconManager;
|
import icon.IconManager;
|
||||||
import map.MapService;
|
import map.MapService;
|
||||||
import module.log.EventLogManager;
|
import module.log.EventLogManager;
|
||||||
import net.miginfocom.swing.MigLayout;
|
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 final static Logger mLog = LoggerFactory.getLogger(SDRTrunk.class);
|
||||||
|
|
||||||
|
private IconManager mIconManager;
|
||||||
private ControllerPanel mControllerPanel;
|
private ControllerPanel mControllerPanel;
|
||||||
private SettingsManager mSettingsManager;
|
private SettingsManager mSettingsManager;
|
||||||
private SpectralDisplayPanel mSpectralPanel;
|
private SpectralDisplayPanel mSpectralPanel;
|
||||||
@@ -105,6 +106,8 @@ public class SDRTrunk implements Listener<TunerEvent>
|
|||||||
|
|
||||||
ThreadPoolManager threadPoolManager = new ThreadPoolManager();
|
ThreadPoolManager threadPoolManager = new ThreadPoolManager();
|
||||||
|
|
||||||
|
mIconManager = new IconManager(threadPoolManager);
|
||||||
|
|
||||||
mSettingsManager = new SettingsManager(threadPoolManager, tunerConfigurationModel);
|
mSettingsManager = new SettingsManager(threadPoolManager, tunerConfigurationModel);
|
||||||
|
|
||||||
AliasModel aliasModel = new AliasModel();
|
AliasModel aliasModel = new AliasModel();
|
||||||
@@ -136,15 +139,15 @@ public class SDRTrunk implements Listener<TunerEvent>
|
|||||||
AudioManager audioManager = new AudioManager(threadPoolManager, sourceManager.getMixerManager());
|
AudioManager audioManager = new AudioManager(threadPoolManager, sourceManager.getMixerManager());
|
||||||
channelProcessingManager.addAudioPacketListener(audioManager);
|
channelProcessingManager.addAudioPacketListener(audioManager);
|
||||||
|
|
||||||
BroadcastModel broadcastModel = new BroadcastModel(threadPoolManager, mSettingsManager);
|
BroadcastModel broadcastModel = new BroadcastModel(threadPoolManager, mIconManager);
|
||||||
|
|
||||||
channelProcessingManager.addAudioPacketListener(broadcastModel);
|
channelProcessingManager.addAudioPacketListener(broadcastModel);
|
||||||
|
|
||||||
MapService mapService = new MapService(mSettingsManager);
|
MapService mapService = new MapService(mIconManager);
|
||||||
channelProcessingManager.addMessageListener(mapService);
|
channelProcessingManager.addMessageListener(mapService);
|
||||||
|
|
||||||
mControllerPanel = new ControllerPanel(audioManager, aliasModel, broadcastModel,
|
mControllerPanel = new ControllerPanel(audioManager, aliasModel, broadcastModel,
|
||||||
channelModel, channelMapModel, channelProcessingManager,
|
channelModel, channelMapModel, channelProcessingManager, mIconManager,
|
||||||
mapService, mSettingsManager, sourceManager, tunerModel);
|
mapService, mSettingsManager, sourceManager, tunerModel);
|
||||||
|
|
||||||
mSpectralPanel = new SpectralDisplayPanel(channelModel,
|
mSpectralPanel = new SpectralDisplayPanel(channelModel,
|
||||||
@@ -268,16 +271,7 @@ public class SDRTrunk implements Listener<TunerEvent>
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent arg0)
|
public void actionPerformed(ActionEvent arg0)
|
||||||
{
|
{
|
||||||
final IconManager iconManager = new IconManager(mSettingsManager, mMainGui);
|
mIconManager.showEditor(mMainGui);
|
||||||
|
|
||||||
EventQueue.invokeLater(new Runnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
iconManager.setVisible(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
fileMenu.add(settingsMenu);
|
fileMenu.add(settingsMenu);
|
||||||
|
|||||||
@@ -1,7 +1,24 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* 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;
|
package gui.editor;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.*;
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic editor with change detection, save and reset functions.
|
* Generic editor with change detection, save and reset functions.
|
||||||
|
|||||||
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,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,15 +14,12 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package map;
|
package map;
|
||||||
|
|
||||||
import java.awt.EventQueue;
|
import icon.IconManager;
|
||||||
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
|
||||||
import org.jdesktop.swingx.JXMapViewer;
|
import org.jdesktop.swingx.JXMapViewer;
|
||||||
import org.jdesktop.swingx.OSMTileFactoryInfo;
|
import org.jdesktop.swingx.OSMTileFactoryInfo;
|
||||||
import org.jdesktop.swingx.input.PanKeyListener;
|
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.DefaultTileFactory;
|
||||||
import org.jdesktop.swingx.mapviewer.GeoPosition;
|
import org.jdesktop.swingx.mapviewer.GeoPosition;
|
||||||
import org.jdesktop.swingx.mapviewer.TileFactoryInfo;
|
import org.jdesktop.swingx.mapviewer.TileFactoryInfo;
|
||||||
|
|
||||||
import settings.MapViewSetting;
|
import settings.MapViewSetting;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class MapPanel extends JPanel implements PlottableUpdateListener
|
public class MapPanel extends JPanel implements PlottableUpdateListener
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -43,19 +42,18 @@ public class MapPanel extends JPanel implements PlottableUpdateListener
|
|||||||
private JXMapViewer mMapViewer = new JXMapViewer();
|
private JXMapViewer mMapViewer = new JXMapViewer();
|
||||||
private PlottableEntityPainter mMapPainter;
|
private PlottableEntityPainter mMapPainter;
|
||||||
|
|
||||||
public MapPanel( MapService mapService, SettingsManager settingsManager )
|
public MapPanel(MapService mapService, IconManager iconManager, SettingsManager settingsManager)
|
||||||
{
|
{
|
||||||
mSettingsManager = settingsManager;
|
mSettingsManager = settingsManager;
|
||||||
mMapService = mapService;
|
mMapService = mapService;
|
||||||
mMapPainter = new PlottableEntityPainter( mSettingsManager );
|
mMapPainter = new PlottableEntityPainter(iconManager);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init()
|
private void init()
|
||||||
{
|
{
|
||||||
setLayout( new MigLayout( "insets 0 0 0 0",
|
setLayout(new MigLayout("insets 0 0 0 0", "[grow,fill]", "[grow,fill]"));
|
||||||
"[grow,fill]", "[grow,fill]") );
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the entity painter as the overlay painter and register this panel
|
* Set the entity painter as the overlay painter and register this panel
|
||||||
@@ -83,8 +81,7 @@ public class MapPanel extends JPanel implements PlottableUpdateListener
|
|||||||
GeoPosition syracuse = new GeoPosition(43.048, -76.147);
|
GeoPosition syracuse = new GeoPosition(43.048, -76.147);
|
||||||
int zoom = 7;
|
int zoom = 7;
|
||||||
|
|
||||||
MapViewSetting view = mSettingsManager
|
MapViewSetting view = mSettingsManager.getMapViewSetting("Default", syracuse, zoom);
|
||||||
.getMapViewSetting( "Default", syracuse, zoom );
|
|
||||||
|
|
||||||
mMapViewer.setAddressLocation(view.getGeoPosition());
|
mMapViewer.setAddressLocation(view.getGeoPosition());
|
||||||
mMapViewer.setZoom(view.getZoom());
|
mMapViewer.setZoom(view.getZoom());
|
||||||
@@ -92,14 +89,12 @@ public class MapPanel extends JPanel implements PlottableUpdateListener
|
|||||||
/**
|
/**
|
||||||
* Add a mouse adapter for panning and scrolling
|
* Add a mouse adapter for panning and scrolling
|
||||||
*/
|
*/
|
||||||
MapMouseListener listener =
|
MapMouseListener listener = new MapMouseListener(mMapViewer, mSettingsManager);
|
||||||
new MapMouseListener( mMapViewer, mSettingsManager );
|
|
||||||
mMapViewer.addMouseListener(listener);
|
mMapViewer.addMouseListener(listener);
|
||||||
mMapViewer.addMouseMotionListener(listener);
|
mMapViewer.addMouseMotionListener(listener);
|
||||||
|
|
||||||
/* Map zoom listener */
|
/* Map zoom listener */
|
||||||
mMapViewer.addMouseWheelListener(
|
mMapViewer.addMouseWheelListener(new ZoomMouseWheelListenerCursor(mMapViewer));
|
||||||
new ZoomMouseWheelListenerCursor( mMapViewer ) );
|
|
||||||
|
|
||||||
/* Keyboard panning listener */
|
/* Keyboard panning listener */
|
||||||
mMapViewer.addKeyListener(new PanKeyListener(mMapViewer));
|
mMapViewer.addKeyListener(new PanKeyListener(mMapViewer));
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,10 +14,18 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package map;
|
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.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -25,12 +33,6 @@ import java.util.Set;
|
|||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
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>
|
public class MapService implements Listener<Message>
|
||||||
{
|
{
|
||||||
private int mMaxHistory = 2;
|
private int mMaxHistory = 2;
|
||||||
@@ -48,11 +50,11 @@ public class MapService implements Listener<Message>
|
|||||||
private HashMap<String, PlottableEntity> mEntities =
|
private HashMap<String, PlottableEntity> mEntities =
|
||||||
new HashMap<String, PlottableEntity>();
|
new HashMap<String, PlottableEntity>();
|
||||||
|
|
||||||
private SettingsManager mSettingsManager;
|
private IconManager mIconManager;
|
||||||
|
|
||||||
public MapService( SettingsManager resourceManager )
|
public MapService(IconManager resourceManager)
|
||||||
{
|
{
|
||||||
mSettingsManager = resourceManager;
|
mIconManager = resourceManager;
|
||||||
|
|
||||||
// scheduler.scheduleAtFixedRate( new CullThread(), 5, 5, TimeUnit.MINUTES );
|
// scheduler.scheduleAtFixedRate( new CullThread(), 5, 5, TimeUnit.MINUTES );
|
||||||
}
|
}
|
||||||
@@ -97,20 +99,10 @@ public class MapService implements Listener<Message>
|
|||||||
Alias alias = plottable.getAlias();
|
Alias alias = plottable.getAlias();
|
||||||
|
|
||||||
Color color = null;
|
Color color = null;
|
||||||
MapIcon icon = null;
|
|
||||||
|
|
||||||
if(alias != null)
|
if(alias != null)
|
||||||
{
|
{
|
||||||
color = alias.getMapColor();
|
color = alias.getMapColor();
|
||||||
|
|
||||||
String iconName = alias.getIconName();
|
|
||||||
|
|
||||||
if( iconName == null )
|
|
||||||
{
|
|
||||||
iconName = SettingsManager.DEFAULT_ICON;
|
|
||||||
}
|
|
||||||
|
|
||||||
icon = mSettingsManager.getMapIcon( iconName );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(color == null)
|
if(color == null)
|
||||||
@@ -135,7 +127,8 @@ public class MapService implements Listener<Message>
|
|||||||
|
|
||||||
for(PlottableUpdateListener listener : mListeners)
|
for(PlottableUpdateListener listener : mListeners)
|
||||||
{
|
{
|
||||||
listener.entitiesUpdated();;
|
listener.entitiesUpdated();
|
||||||
|
;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +1,41 @@
|
|||||||
/*
|
|
||||||
* 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;
|
package map;
|
||||||
|
|
||||||
import java.awt.Graphics2D;
|
import icon.IconManager;
|
||||||
import java.awt.Rectangle;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import org.jdesktop.swingx.JXMapViewer;
|
import org.jdesktop.swingx.JXMapViewer;
|
||||||
import org.jdesktop.swingx.painter.AbstractPainter;
|
import org.jdesktop.swingx.painter.AbstractPainter;
|
||||||
|
|
||||||
import settings.SettingsManager;
|
import java.awt.*;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
public class PlottableEntityPainter extends AbstractPainter<JXMapViewer>
|
public class PlottableEntityPainter extends AbstractPainter<JXMapViewer>
|
||||||
{
|
{
|
||||||
private PlottableEntityRenderer mRenderer;
|
private PlottableEntityRenderer mRenderer;
|
||||||
private Set<PlottableEntity> mEntities = new HashSet<PlottableEntity>();
|
private Set<PlottableEntity> mEntities = new HashSet<PlottableEntity>();
|
||||||
|
|
||||||
public PlottableEntityPainter( SettingsManager settingsManager )
|
public PlottableEntityPainter(IconManager iconManager)
|
||||||
{
|
{
|
||||||
mRenderer = new PlottableEntityRenderer( settingsManager );
|
mRenderer = new PlottableEntityRenderer(iconManager);
|
||||||
setAntialiasing(true);
|
setAntialiasing(true);
|
||||||
setCacheable(false);
|
setCacheable(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,35 +14,28 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package map;
|
package map;
|
||||||
|
|
||||||
import java.awt.BasicStroke;
|
import icon.IconManager;
|
||||||
import java.awt.Color;
|
import org.jdesktop.swingx.JXMapViewer;
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.awt.RenderingHints;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
|
|
||||||
import org.jdesktop.swingx.JXMapViewer;
|
|
||||||
|
|
||||||
import settings.SettingsManager;
|
|
||||||
|
|
||||||
public class PlottableEntityRenderer
|
public class PlottableEntityRenderer
|
||||||
{
|
{
|
||||||
private SettingsManager mSettingsManager;
|
private IconManager mIconManager;
|
||||||
|
|
||||||
public PlottableEntityRenderer( SettingsManager settingsManager )
|
public PlottableEntityRenderer(IconManager iconManager)
|
||||||
{
|
{
|
||||||
mSettingsManager = settingsManager;
|
mIconManager = iconManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void paintPlottableEntity( Graphics2D g,
|
public void paintPlottableEntity(Graphics2D g, JXMapViewer viewer, PlottableEntity entity, boolean antiAliasing)
|
||||||
JXMapViewer viewer,
|
|
||||||
PlottableEntity entity,
|
|
||||||
boolean antiAliasing )
|
|
||||||
{
|
{
|
||||||
Graphics2D graphics = (Graphics2D) g.create();
|
Graphics2D graphics = (Graphics2D) g.create();
|
||||||
|
|
||||||
@@ -71,7 +64,7 @@ public class PlottableEntityRenderer
|
|||||||
/**
|
/**
|
||||||
* Paint the icon at the current location
|
* Paint the icon at the current location
|
||||||
*/
|
*/
|
||||||
ImageIcon icon = getIcon( entity ).getImageIcon();
|
ImageIcon icon = getIcon(entity);
|
||||||
|
|
||||||
paintIcon(graphics, point, icon);
|
paintIcon(graphics, point, icon);
|
||||||
|
|
||||||
@@ -86,9 +79,9 @@ public class PlottableEntityRenderer
|
|||||||
graphics.dispose();
|
graphics.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private MapIcon getIcon( PlottableEntity entity )
|
private ImageIcon getIcon(PlottableEntity entity)
|
||||||
{
|
{
|
||||||
return mSettingsManager.getMapIcon( entity.getMapIconName() );
|
return mIconManager.getIcon(entity.getMapIconName(), IconManager.DEFAULT_ICON_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void paintIcon(Graphics2D graphics,
|
private void paintIcon(Graphics2D graphics,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014-2016 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,13 +14,25 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode;
|
package module.decode;
|
||||||
|
|
||||||
import java.io.File;
|
import alias.AliasList;
|
||||||
import java.util.ArrayList;
|
import alias.AliasModel;
|
||||||
import java.util.List;
|
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.Message;
|
||||||
import message.MessageDirection;
|
import message.MessageDirection;
|
||||||
import module.Module;
|
import module.Module;
|
||||||
@@ -95,20 +107,10 @@ import record.RecorderType;
|
|||||||
import record.config.RecordConfiguration;
|
import record.config.RecordConfiguration;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
import util.TimeStamp;
|
import util.TimeStamp;
|
||||||
import alias.AliasList;
|
|
||||||
import alias.AliasModel;
|
import java.io.File;
|
||||||
import audio.AudioModule;
|
import java.util.ArrayList;
|
||||||
import controller.channel.Channel;
|
import java.util.List;
|
||||||
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;
|
|
||||||
|
|
||||||
public class DecoderFactory
|
public class DecoderFactory
|
||||||
{
|
{
|
||||||
@@ -322,42 +324,33 @@ public class DecoderFactory
|
|||||||
return modules;
|
return modules;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DecoderPanel getDecoderPanel( SettingsManager settingsManager,
|
public static DecoderPanel getDecoderPanel(IconManager iconManager, SettingsManager settingsManager,
|
||||||
DecoderState decoderState)
|
DecoderState decoderState)
|
||||||
{
|
{
|
||||||
switch(decoderState.getDecoderType())
|
switch(decoderState.getDecoderType())
|
||||||
{
|
{
|
||||||
case AM:
|
case AM:
|
||||||
return new AMDecoderPanel( settingsManager, decoderState );
|
return new AMDecoderPanel(iconManager, settingsManager, decoderState);
|
||||||
case FLEETSYNC2:
|
case FLEETSYNC2:
|
||||||
return new Fleetsync2DecoderPanel( settingsManager,
|
return new Fleetsync2DecoderPanel(iconManager, settingsManager, (Fleetsync2DecoderState) decoderState);
|
||||||
(Fleetsync2DecoderState)decoderState );
|
|
||||||
case LJ_1200:
|
case LJ_1200:
|
||||||
return new LJ1200DecoderPanel( settingsManager,
|
return new LJ1200DecoderPanel(iconManager, settingsManager, (LJ1200DecoderState) decoderState);
|
||||||
(LJ1200DecoderState)decoderState );
|
|
||||||
case LTR_NET:
|
case LTR_NET:
|
||||||
return new LTRNetDecoderPanel( settingsManager,
|
return new LTRNetDecoderPanel(iconManager, settingsManager, (LTRNetDecoderState) decoderState);
|
||||||
(LTRNetDecoderState)decoderState );
|
|
||||||
case LTR_STANDARD:
|
case LTR_STANDARD:
|
||||||
return new LTRStandardDecoderPanel( settingsManager,
|
return new LTRStandardDecoderPanel(iconManager, settingsManager, (LTRStandardDecoderState) decoderState);
|
||||||
(LTRStandardDecoderState)decoderState );
|
|
||||||
case MDC1200:
|
case MDC1200:
|
||||||
return new MDCDecoderPanel( settingsManager,
|
return new MDCDecoderPanel(iconManager, settingsManager, (MDCDecoderState) decoderState);
|
||||||
(MDCDecoderState)decoderState );
|
|
||||||
case MPT1327:
|
case MPT1327:
|
||||||
return new MPT1327DecoderPanel( settingsManager,
|
return new MPT1327DecoderPanel(iconManager, settingsManager, (MPT1327DecoderState) decoderState);
|
||||||
(MPT1327DecoderState)decoderState );
|
|
||||||
case NBFM:
|
case NBFM:
|
||||||
return new NBFMDecoderPanel( settingsManager, decoderState );
|
return new NBFMDecoderPanel(iconManager, settingsManager, decoderState);
|
||||||
case P25_PHASE1:
|
case P25_PHASE1:
|
||||||
return new P25DecoderPanel( settingsManager,
|
return new P25DecoderPanel(iconManager, settingsManager, (P25DecoderState) decoderState);
|
||||||
(P25DecoderState)decoderState );
|
|
||||||
case PASSPORT:
|
case PASSPORT:
|
||||||
return new PassportDecoderPanel( settingsManager,
|
return new PassportDecoderPanel(iconManager, settingsManager, (PassportDecoderState) decoderState);
|
||||||
(PassportDecoderState)decoderState );
|
|
||||||
case TAIT_1200:
|
case TAIT_1200:
|
||||||
return new Tait1200DecoderPanel( settingsManager,
|
return new Tait1200DecoderPanel(iconManager, settingsManager, (Tait1200DecoderState) decoderState);
|
||||||
(Tait1200DecoderState)decoderState );
|
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Unrecognized decoder: " +
|
throw new IllegalArgumentException("Unrecognized decoder: " +
|
||||||
decoderState.getDecoderType().getDisplayString());
|
decoderState.getDecoderType().getDisplayString());
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,28 +14,30 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.am;
|
package module.decode.am;
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
import icon.IconManager;
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import module.decode.state.ChangedAttribute;
|
import module.decode.state.ChangedAttribute;
|
||||||
import module.decode.state.DecoderPanel;
|
import module.decode.state.DecoderPanel;
|
||||||
import module.decode.state.DecoderState;
|
import module.decode.state.DecoderState;
|
||||||
|
import net.miginfocom.swing.MigLayout;
|
||||||
import settings.ColorSetting;
|
import settings.ColorSetting;
|
||||||
import settings.Setting;
|
import settings.Setting;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
public class AMDecoderPanel extends DecoderPanel
|
public class AMDecoderPanel extends DecoderPanel
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private JLabel mProtocol = new JLabel("AM");
|
private JLabel mProtocol = new JLabel("AM");
|
||||||
|
|
||||||
public AMDecoderPanel( SettingsManager settingsManager, DecoderState decoderState )
|
public AMDecoderPanel(IconManager iconManager, SettingsManager settingsManager, DecoderState decoderState)
|
||||||
{
|
{
|
||||||
super( settingsManager, decoderState );
|
super(iconManager, settingsManager, decoderState);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,14 +14,15 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.event;
|
package module.decode.event;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
import javax.swing.table.DefaultTableCellRenderer;
|
|
||||||
|
|
||||||
import settings.SettingsManager;
|
|
||||||
import alias.Alias;
|
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
|
* Custom renderer for JTable cells that contain Alias objects. Renders the
|
||||||
@@ -32,12 +33,12 @@ public class CallEventAliasCellRenderer extends DefaultTableCellRenderer
|
|||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private SettingsManager mSettingsManager;
|
private IconManager mIconManager;
|
||||||
|
|
||||||
public CallEventAliasCellRenderer( SettingsManager settingsManager )
|
public CallEventAliasCellRenderer(IconManager iconManager)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
mSettingsManager = settingsManager;
|
mIconManager = iconManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValue(Object obj)
|
public void setValue(Object obj)
|
||||||
@@ -48,7 +49,7 @@ public class CallEventAliasCellRenderer extends DefaultTableCellRenderer
|
|||||||
|
|
||||||
setText(alias.getName());
|
setText(alias.getName());
|
||||||
|
|
||||||
ImageIcon icon = getIcon( alias, SettingsManager.DEFAULT_ICON_SIZE );
|
ImageIcon icon = getIcon(alias, IconManager.DEFAULT_ICON_SIZE);
|
||||||
|
|
||||||
if(icon != null)
|
if(icon != null)
|
||||||
{
|
{
|
||||||
@@ -64,9 +65,9 @@ public class CallEventAliasCellRenderer extends DefaultTableCellRenderer
|
|||||||
|
|
||||||
private ImageIcon getIcon(Alias alias, int height)
|
private ImageIcon getIcon(Alias alias, int height)
|
||||||
{
|
{
|
||||||
if( mSettingsManager != null && alias != null )
|
if(mIconManager != null && alias != null)
|
||||||
{
|
{
|
||||||
return mSettingsManager.getImageIcon( alias.getIconName(), height );
|
return mIconManager.getIcon(alias.getIconName(), height);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,23 +14,21 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.event;
|
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.Channel;
|
||||||
import controller.channel.ChannelEvent;
|
import controller.channel.ChannelEvent;
|
||||||
import controller.channel.ChannelEvent.Event;
|
import controller.channel.ChannelEvent.Event;
|
||||||
import controller.channel.ChannelEventListener;
|
import controller.channel.ChannelEventListener;
|
||||||
import controller.channel.ChannelProcessingManager;
|
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
|
public class CallEventPanel extends JPanel implements ChannelEventListener
|
||||||
{
|
{
|
||||||
@@ -41,8 +39,7 @@ public class CallEventPanel extends JPanel implements ChannelEventListener
|
|||||||
private CallEventAliasCellRenderer mRenderer;
|
private CallEventAliasCellRenderer mRenderer;
|
||||||
private ChannelProcessingManager mChannelProcessingManager;
|
private ChannelProcessingManager mChannelProcessingManager;
|
||||||
|
|
||||||
public CallEventPanel( SettingsManager settingsManager,
|
public CallEventPanel(IconManager iconManager, ChannelProcessingManager channelProcessingManager)
|
||||||
ChannelProcessingManager channelProcessingManager )
|
|
||||||
{
|
{
|
||||||
mChannelProcessingManager = channelProcessingManager;
|
mChannelProcessingManager = channelProcessingManager;
|
||||||
|
|
||||||
@@ -52,13 +49,11 @@ public class CallEventPanel extends JPanel implements ChannelEventListener
|
|||||||
table.setAutoCreateRowSorter(true);
|
table.setAutoCreateRowSorter(true);
|
||||||
table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
|
table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
|
||||||
|
|
||||||
mRenderer = new CallEventAliasCellRenderer( settingsManager );
|
mRenderer = new CallEventAliasCellRenderer(iconManager);
|
||||||
|
|
||||||
table.getColumnModel().getColumn( CallEventModel.FROM_ALIAS )
|
table.getColumnModel().getColumn(CallEventModel.FROM_ALIAS).setCellRenderer(mRenderer);
|
||||||
.setCellRenderer( mRenderer );
|
|
||||||
|
|
||||||
table.getColumnModel().getColumn( CallEventModel.TO_ALIAS )
|
table.getColumnModel().getColumn(CallEventModel.TO_ALIAS).setCellRenderer(mRenderer);
|
||||||
.setCellRenderer( mRenderer );
|
|
||||||
|
|
||||||
mEmptyScroller = new JScrollPane(table);
|
mEmptyScroller = new JScrollPane(table);
|
||||||
|
|
||||||
@@ -68,15 +63,11 @@ public class CallEventPanel extends JPanel implements ChannelEventListener
|
|||||||
@Override
|
@Override
|
||||||
public void channelChanged(final ChannelEvent event)
|
public void channelChanged(final ChannelEvent event)
|
||||||
{
|
{
|
||||||
if( event.getEvent() == Event.NOTIFICATION_SELECTION_CHANGE &&
|
if(event.getEvent() == Event.NOTIFICATION_SELECTION_CHANGE && event.getChannel().isSelected())
|
||||||
event.getChannel().isSelected() )
|
|
||||||
{
|
{
|
||||||
if( mDisplayedChannel == null ||
|
if(mDisplayedChannel == null || (mDisplayedChannel != null && mDisplayedChannel != event.getChannel()))
|
||||||
( mDisplayedChannel != null &&
|
|
||||||
mDisplayedChannel != event.getChannel() ) )
|
|
||||||
{
|
{
|
||||||
ProcessingChain chain = mChannelProcessingManager
|
ProcessingChain chain = mChannelProcessingManager.getProcessingChain(event.getChannel());
|
||||||
.getProcessingChain( event.getChannel() );
|
|
||||||
|
|
||||||
if(chain != null)
|
if(chain != null)
|
||||||
{
|
{
|
||||||
@@ -114,11 +105,9 @@ public class CallEventPanel extends JPanel implements ChannelEventListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( event.getEvent() == Event.NOTIFICATION_PROCESSING_STOP ||
|
else if(event.getEvent() == Event.NOTIFICATION_PROCESSING_STOP || event.getEvent() == Event.REQUEST_DISABLE)
|
||||||
event.getEvent() == Event.REQUEST_DISABLE )
|
|
||||||
{
|
{
|
||||||
if( mDisplayedChannel != null &&
|
if(mDisplayedChannel != null && mDisplayedChannel == event.getChannel())
|
||||||
mDisplayedChannel == event.getChannel() )
|
|
||||||
{
|
{
|
||||||
mDisplayedChannel = null;
|
mDisplayedChannel = null;
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014,2015 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,25 +14,24 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.fleetsync2;
|
package module.decode.fleetsync2;
|
||||||
|
|
||||||
import java.awt.EventQueue;
|
import icon.IconManager;
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
|
|
||||||
import module.decode.state.ChangedAttribute;
|
import module.decode.state.ChangedAttribute;
|
||||||
import module.decode.state.DecoderPanel;
|
import module.decode.state.DecoderPanel;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import settings.ColorSetting;
|
import settings.ColorSetting;
|
||||||
import settings.ColorSetting.ColorSettingName;
|
import settings.ColorSetting.ColorSettingName;
|
||||||
import settings.Setting;
|
import settings.Setting;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class Fleetsync2DecoderPanel extends DecoderPanel
|
public class Fleetsync2DecoderPanel extends DecoderPanel
|
||||||
{
|
{
|
||||||
private final static Logger mLog = LoggerFactory.getLogger(Fleetsync2DecoderPanel.class);
|
private final static Logger mLog = LoggerFactory.getLogger(Fleetsync2DecoderPanel.class);
|
||||||
@@ -52,10 +51,10 @@ public class Fleetsync2DecoderPanel extends DecoderPanel
|
|||||||
private JLabel mMessage = new JLabel(" ");
|
private JLabel mMessage = new JLabel(" ");
|
||||||
private JLabel mMessageType = new JLabel(" ");
|
private JLabel mMessageType = new JLabel(" ");
|
||||||
|
|
||||||
public Fleetsync2DecoderPanel( SettingsManager settingsManager,
|
public Fleetsync2DecoderPanel(IconManager iconManager, SettingsManager settingsManager,
|
||||||
Fleetsync2DecoderState decoderState)
|
Fleetsync2DecoderState decoderState)
|
||||||
{
|
{
|
||||||
super( settingsManager, decoderState );
|
super(iconManager, settingsManager, decoderState);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014,2015 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,12 +14,12 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.lj1200;
|
package module.decode.lj1200;
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
|
|
||||||
import alias.Alias;
|
import alias.Alias;
|
||||||
|
import icon.IconManager;
|
||||||
import module.decode.state.ChangedAttribute;
|
import module.decode.state.ChangedAttribute;
|
||||||
import module.decode.state.DecoderPanel;
|
import module.decode.state.DecoderPanel;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
@@ -28,6 +28,8 @@ import settings.ColorSetting.ColorSettingName;
|
|||||||
import settings.Setting;
|
import settings.Setting;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
public class LJ1200DecoderPanel extends DecoderPanel
|
public class LJ1200DecoderPanel extends DecoderPanel
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -37,9 +39,9 @@ public class LJ1200DecoderPanel extends DecoderPanel
|
|||||||
private JLabel mTo = new JLabel();
|
private JLabel mTo = new JLabel();
|
||||||
private JLabel mToAlias = new JLabel();
|
private JLabel mToAlias = new JLabel();
|
||||||
|
|
||||||
public LJ1200DecoderPanel( SettingsManager settingsManager, LJ1200DecoderState decoderState )
|
public LJ1200DecoderPanel(IconManager iconManager, SettingsManager settingsManager, LJ1200DecoderState decoderState)
|
||||||
{
|
{
|
||||||
super( settingsManager, decoderState );
|
super(iconManager, settingsManager, decoderState);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,20 +14,21 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.ltrnet;
|
package module.decode.ltrnet;
|
||||||
|
|
||||||
import java.awt.EventQueue;
|
import alias.Alias;
|
||||||
|
import icon.IconManager;
|
||||||
import javax.swing.JLabel;
|
|
||||||
|
|
||||||
import module.decode.state.ChangedAttribute;
|
import module.decode.state.ChangedAttribute;
|
||||||
import module.decode.state.DecoderPanel;
|
import module.decode.state.DecoderPanel;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import settings.ColorSetting;
|
import settings.ColorSetting;
|
||||||
import settings.Setting;
|
import settings.Setting;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
import alias.Alias;
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class LTRNetDecoderPanel extends DecoderPanel
|
public class LTRNetDecoderPanel extends DecoderPanel
|
||||||
{
|
{
|
||||||
@@ -40,10 +41,9 @@ public class LTRNetDecoderPanel extends DecoderPanel
|
|||||||
private JLabel mLCN = new JLabel("LCN:");
|
private JLabel mLCN = new JLabel("LCN:");
|
||||||
private JLabel mDescription = new JLabel();
|
private JLabel mDescription = new JLabel();
|
||||||
|
|
||||||
public LTRNetDecoderPanel( SettingsManager settingsManager,
|
public LTRNetDecoderPanel(IconManager iconManager, SettingsManager settingsManager, LTRNetDecoderState decoderState)
|
||||||
LTRNetDecoderState decoderState )
|
|
||||||
{
|
{
|
||||||
super( settingsManager, decoderState );
|
super(iconManager, settingsManager, decoderState);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,20 +14,21 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.ltrstandard;
|
package module.decode.ltrstandard;
|
||||||
|
|
||||||
import java.awt.EventQueue;
|
import alias.Alias;
|
||||||
|
import icon.IconManager;
|
||||||
import javax.swing.JLabel;
|
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import module.decode.state.ChangedAttribute;
|
import module.decode.state.ChangedAttribute;
|
||||||
import module.decode.state.DecoderPanel;
|
import module.decode.state.DecoderPanel;
|
||||||
|
import net.miginfocom.swing.MigLayout;
|
||||||
import settings.ColorSetting;
|
import settings.ColorSetting;
|
||||||
import settings.Setting;
|
import settings.Setting;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
import alias.Alias;
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class LTRStandardDecoderPanel extends DecoderPanel
|
public class LTRStandardDecoderPanel extends DecoderPanel
|
||||||
{
|
{
|
||||||
@@ -39,10 +40,10 @@ public class LTRStandardDecoderPanel extends DecoderPanel
|
|||||||
|
|
||||||
private JLabel mLCN = new JLabel("LCN:");
|
private JLabel mLCN = new JLabel("LCN:");
|
||||||
|
|
||||||
public LTRStandardDecoderPanel( SettingsManager settingsManager,
|
public LTRStandardDecoderPanel(IconManager iconManager, SettingsManager settingsManager,
|
||||||
LTRStandardDecoderState decoderState)
|
LTRStandardDecoderState decoderState)
|
||||||
{
|
{
|
||||||
super( settingsManager, decoderState );
|
super(iconManager, settingsManager, decoderState);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@@ -109,8 +110,8 @@ public class LTRStandardDecoderPanel extends DecoderPanel
|
|||||||
if(alias != null)
|
if(alias != null)
|
||||||
{
|
{
|
||||||
mTalkgroupAlias.setText(alias.getName());
|
mTalkgroupAlias.setText(alias.getName());
|
||||||
mTalkgroupAlias.setIcon( mSettingsManager
|
mTalkgroupAlias.setIcon(mIconManager.getIcon(alias.getIconName(),
|
||||||
.getImageIcon( alias.getIconName(), SettingsManager.DEFAULT_ICON_SIZE ) );
|
IconManager.DEFAULT_ICON_SIZE));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,14 +14,12 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.mdc1200;
|
package module.decode.mdc1200;
|
||||||
|
|
||||||
import java.awt.EventQueue;
|
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
|
|
||||||
import alias.Alias;
|
import alias.Alias;
|
||||||
|
import icon.IconManager;
|
||||||
import module.decode.state.ChangedAttribute;
|
import module.decode.state.ChangedAttribute;
|
||||||
import module.decode.state.DecoderPanel;
|
import module.decode.state.DecoderPanel;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
@@ -30,6 +28,9 @@ import settings.ColorSetting.ColorSettingName;
|
|||||||
import settings.Setting;
|
import settings.Setting;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class MDCDecoderPanel extends DecoderPanel
|
public class MDCDecoderPanel extends DecoderPanel
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -47,10 +48,9 @@ public class MDCDecoderPanel extends DecoderPanel
|
|||||||
private JLabel mMessage = new JLabel();
|
private JLabel mMessage = new JLabel();
|
||||||
private JLabel mMessageType = new JLabel();
|
private JLabel mMessageType = new JLabel();
|
||||||
|
|
||||||
public MDCDecoderPanel( SettingsManager settingsManager,
|
public MDCDecoderPanel(IconManager iconManager, SettingsManager settingsManager, MDCDecoderState decoderState)
|
||||||
MDCDecoderState decoderState )
|
|
||||||
{
|
{
|
||||||
super( settingsManager, decoderState );
|
super(iconManager, settingsManager, decoderState);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,20 +14,21 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.mpt1327;
|
package module.decode.mpt1327;
|
||||||
|
|
||||||
import java.awt.EventQueue;
|
import controller.channel.Channel.ChannelType;
|
||||||
|
import icon.IconManager;
|
||||||
import javax.swing.JLabel;
|
|
||||||
|
|
||||||
import module.decode.state.ChangedAttribute;
|
import module.decode.state.ChangedAttribute;
|
||||||
import module.decode.state.DecoderPanel;
|
import module.decode.state.DecoderPanel;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import settings.ColorSetting;
|
import settings.ColorSetting;
|
||||||
import settings.Setting;
|
import settings.Setting;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
import controller.channel.Channel.ChannelType;
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class MPT1327DecoderPanel extends DecoderPanel
|
public class MPT1327DecoderPanel extends DecoderPanel
|
||||||
{
|
{
|
||||||
@@ -41,10 +42,9 @@ public class MPT1327DecoderPanel extends DecoderPanel
|
|||||||
private JLabel mFromTalkgroup = new JLabel("");
|
private JLabel mFromTalkgroup = new JLabel("");
|
||||||
private JLabel mFromTalkgroupAliasLabel = new JLabel("");
|
private JLabel mFromTalkgroupAliasLabel = new JLabel("");
|
||||||
|
|
||||||
public MPT1327DecoderPanel( SettingsManager settingsManager,
|
public MPT1327DecoderPanel(IconManager iconManager, SettingsManager settingsManager, MPT1327DecoderState decoderState)
|
||||||
MPT1327DecoderState decoderState )
|
|
||||||
{
|
{
|
||||||
super( settingsManager, decoderState );
|
super(iconManager, settingsManager, decoderState);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,19 +14,20 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.mpt1327;
|
package module.decode.mpt1327;
|
||||||
|
|
||||||
import java.awt.EventQueue;
|
import alias.Alias;
|
||||||
|
import icon.IconManager;
|
||||||
import javax.swing.JLabel;
|
|
||||||
|
|
||||||
import module.decode.state.ChangedAttribute;
|
import module.decode.state.ChangedAttribute;
|
||||||
import module.decode.state.DecoderPanel;
|
import module.decode.state.DecoderPanel;
|
||||||
import settings.ColorSetting;
|
import settings.ColorSetting;
|
||||||
import settings.Setting;
|
import settings.Setting;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
import alias.Alias;
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class MPT1327TrafficPanel extends DecoderPanel
|
public class MPT1327TrafficPanel extends DecoderPanel
|
||||||
{
|
{
|
||||||
@@ -40,9 +41,10 @@ public class MPT1327TrafficPanel extends DecoderPanel
|
|||||||
private JLabel mToTalkgroupLabel;
|
private JLabel mToTalkgroupLabel;
|
||||||
private JLabel mToTalkgroupAliasLabel;
|
private JLabel mToTalkgroupAliasLabel;
|
||||||
|
|
||||||
public MPT1327TrafficPanel( SettingsManager settingsManager, MPT1327DecoderState decoderState )
|
public MPT1327TrafficPanel(IconManager iconManager, SettingsManager settingsManager,
|
||||||
|
MPT1327DecoderState decoderState)
|
||||||
{
|
{
|
||||||
super( settingsManager, decoderState );
|
super(iconManager, settingsManager, decoderState);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@@ -117,8 +119,7 @@ public class MPT1327TrafficPanel extends DecoderPanel
|
|||||||
|
|
||||||
String icon = alias.getIconName();
|
String icon = alias.getIconName();
|
||||||
|
|
||||||
mFromTalkgroupAliasLabel.setIcon( mSettingsManager
|
mFromTalkgroupAliasLabel.setIcon(mIconManager.getIcon(icon, IconManager.DEFAULT_ICON_SIZE));
|
||||||
.getImageIcon( icon, SettingsManager.DEFAULT_ICON_SIZE ) );
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TO_TALKGROUP:
|
case TO_TALKGROUP:
|
||||||
@@ -136,8 +137,7 @@ public class MPT1327TrafficPanel extends DecoderPanel
|
|||||||
|
|
||||||
if(icon != null)
|
if(icon != null)
|
||||||
{
|
{
|
||||||
mToTalkgroupAliasLabel.setIcon( mSettingsManager
|
mToTalkgroupAliasLabel.setIcon(mIconManager.getIcon(icon, IconManager.DEFAULT_ICON_SIZE));
|
||||||
.getImageIcon( icon, 12 ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014,2015 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,11 +14,11 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.nbfm;
|
package module.decode.nbfm;
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
import icon.IconManager;
|
||||||
|
|
||||||
import module.decode.state.ChangedAttribute;
|
import module.decode.state.ChangedAttribute;
|
||||||
import module.decode.state.DecoderPanel;
|
import module.decode.state.DecoderPanel;
|
||||||
import module.decode.state.DecoderState;
|
import module.decode.state.DecoderState;
|
||||||
@@ -28,16 +28,17 @@ import settings.ColorSetting.ColorSettingName;
|
|||||||
import settings.Setting;
|
import settings.Setting;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
|
||||||
public class NBFMDecoderPanel extends DecoderPanel
|
public class NBFMDecoderPanel extends DecoderPanel
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private JLabel mProtocol = new JLabel("NBFM");
|
private JLabel mProtocol = new JLabel("NBFM");
|
||||||
|
|
||||||
public NBFMDecoderPanel( SettingsManager settingsManager,
|
public NBFMDecoderPanel(IconManager iconManager, SettingsManager settingsManager, DecoderState decoderState)
|
||||||
DecoderState decoderState )
|
|
||||||
{
|
{
|
||||||
super( settingsManager, decoderState );
|
super(iconManager, settingsManager, decoderState);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,20 +14,21 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.p25;
|
package module.decode.p25;
|
||||||
|
|
||||||
import java.awt.EventQueue;
|
import alias.Alias;
|
||||||
|
import icon.IconManager;
|
||||||
import javax.swing.JLabel;
|
|
||||||
|
|
||||||
import module.decode.state.ChangedAttribute;
|
import module.decode.state.ChangedAttribute;
|
||||||
import module.decode.state.DecoderPanel;
|
import module.decode.state.DecoderPanel;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import settings.ColorSetting;
|
import settings.ColorSetting;
|
||||||
import settings.Setting;
|
import settings.Setting;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
import alias.Alias;
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class P25DecoderPanel extends DecoderPanel
|
public class P25DecoderPanel extends DecoderPanel
|
||||||
{
|
{
|
||||||
@@ -46,10 +47,9 @@ public class P25DecoderPanel extends DecoderPanel
|
|||||||
private JLabel mSiteAlias = new JLabel("");
|
private JLabel mSiteAlias = new JLabel("");
|
||||||
|
|
||||||
|
|
||||||
public P25DecoderPanel( SettingsManager settingsManager,
|
public P25DecoderPanel(IconManager iconManager, SettingsManager settingsManager, P25DecoderState decoderState)
|
||||||
P25DecoderState decoderState )
|
|
||||||
{
|
{
|
||||||
super( settingsManager, decoderState );
|
super(iconManager, settingsManager, decoderState);
|
||||||
|
|
||||||
mProtocol = new JLabel("P25-1 " + decoderState.getModulation().getShortLabel());
|
mProtocol = new JLabel("P25-1 " + decoderState.getModulation().getShortLabel());
|
||||||
|
|
||||||
@@ -151,10 +151,9 @@ public class P25DecoderPanel extends DecoderPanel
|
|||||||
|
|
||||||
final String icon = from.getIconName();
|
final String icon = from.getIconName();
|
||||||
|
|
||||||
if( icon != null && mSettingsManager != null )
|
if(icon != null && mIconManager != null)
|
||||||
{
|
{
|
||||||
mFromAlias.setIcon( mSettingsManager.getImageIcon(
|
mFromAlias.setIcon(mIconManager.getIcon(icon, IconManager.DEFAULT_ICON_SIZE));
|
||||||
icon, SettingsManager.DEFAULT_ICON_SIZE ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -182,10 +181,9 @@ public class P25DecoderPanel extends DecoderPanel
|
|||||||
|
|
||||||
final String icon = to.getIconName();
|
final String icon = to.getIconName();
|
||||||
|
|
||||||
if( icon != null && mSettingsManager != null )
|
if(icon != null && mIconManager != null)
|
||||||
{
|
{
|
||||||
mToAlias.setIcon( mSettingsManager.getImageIcon(
|
mToAlias.setIcon(mIconManager.getIcon(icon, IconManager.DEFAULT_ICON_SIZE));
|
||||||
icon, SettingsManager.DEFAULT_ICON_SIZE ) );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,20 +14,21 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.passport;
|
package module.decode.passport;
|
||||||
|
|
||||||
import java.awt.EventQueue;
|
import alias.Alias;
|
||||||
|
import icon.IconManager;
|
||||||
import javax.swing.JLabel;
|
|
||||||
|
|
||||||
import net.miginfocom.swing.MigLayout;
|
|
||||||
import module.decode.state.ChangedAttribute;
|
import module.decode.state.ChangedAttribute;
|
||||||
import module.decode.state.DecoderPanel;
|
import module.decode.state.DecoderPanel;
|
||||||
|
import net.miginfocom.swing.MigLayout;
|
||||||
import settings.ColorSetting;
|
import settings.ColorSetting;
|
||||||
import settings.Setting;
|
import settings.Setting;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
import alias.Alias;
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class PassportDecoderPanel extends DecoderPanel
|
public class PassportDecoderPanel extends DecoderPanel
|
||||||
{
|
{
|
||||||
@@ -41,10 +42,9 @@ public class PassportDecoderPanel extends DecoderPanel
|
|||||||
private JLabel mFromTalkgroup = new JLabel();
|
private JLabel mFromTalkgroup = new JLabel();
|
||||||
private JLabel mFromTalkgroupAlias = new JLabel();
|
private JLabel mFromTalkgroupAlias = new JLabel();
|
||||||
|
|
||||||
public PassportDecoderPanel( SettingsManager settingsManager,
|
public PassportDecoderPanel(IconManager iconManager, SettingsManager settingsManager, PassportDecoderState decoderState)
|
||||||
PassportDecoderState decoderState )
|
|
||||||
{
|
{
|
||||||
super( settingsManager, decoderState );
|
super(iconManager, settingsManager, decoderState);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
@@ -123,8 +123,7 @@ public class PassportDecoderPanel extends DecoderPanel
|
|||||||
{
|
{
|
||||||
mToTalkgroupAlias.setText(toAlias.getName());
|
mToTalkgroupAlias.setText(toAlias.getName());
|
||||||
|
|
||||||
mToTalkgroupAlias.setIcon( mSettingsManager
|
mToTalkgroupAlias.setIcon(mIconManager.getIcon(toAlias.getIconName(), IconManager.DEFAULT_ICON_SIZE));
|
||||||
.getImageIcon( toAlias.getIconName(), SettingsManager.DEFAULT_ICON_SIZE ) );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -151,8 +150,8 @@ public class PassportDecoderPanel extends DecoderPanel
|
|||||||
{
|
{
|
||||||
mFromTalkgroupAlias.setText(fromAlias.getName());
|
mFromTalkgroupAlias.setText(fromAlias.getName());
|
||||||
|
|
||||||
mFromTalkgroupAlias.setIcon( mSettingsManager
|
mFromTalkgroupAlias.setIcon(mIconManager
|
||||||
.getImageIcon( fromAlias.getIconName(), SettingsManager.DEFAULT_ICON_SIZE ) );
|
.getIcon(fromAlias.getIconName(), IconManager.DEFAULT_ICON_SIZE));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,26 +14,10 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.state;
|
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 audio.AudioPanel;
|
||||||
import controller.channel.Channel;
|
import controller.channel.Channel;
|
||||||
import controller.channel.ChannelEvent;
|
import controller.channel.ChannelEvent;
|
||||||
@@ -41,6 +25,19 @@ import controller.channel.ChannelEvent.Event;
|
|||||||
import controller.channel.ChannelEventListener;
|
import controller.channel.ChannelEventListener;
|
||||||
import controller.channel.ChannelModel;
|
import controller.channel.ChannelModel;
|
||||||
import controller.channel.ChannelProcessingManager;
|
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
|
||||||
@@ -53,16 +50,19 @@ public class ChannelList extends JPanel implements ChannelEventListener
|
|||||||
|
|
||||||
private ChannelModel mChannelModel;
|
private ChannelModel mChannelModel;
|
||||||
private ChannelProcessingManager mChannelProcessingManager;
|
private ChannelProcessingManager mChannelProcessingManager;
|
||||||
|
private IconManager mIconManager;
|
||||||
private SettingsManager mSettingsManager;
|
private SettingsManager mSettingsManager;
|
||||||
private AudioPanel mAudioPanel;
|
private AudioPanel mAudioPanel;
|
||||||
|
|
||||||
public ChannelList(ChannelModel channelModel,
|
public ChannelList(ChannelModel channelModel,
|
||||||
ChannelProcessingManager channelProcessingManager,
|
ChannelProcessingManager channelProcessingManager,
|
||||||
|
IconManager iconManager,
|
||||||
SettingsManager settingsManager,
|
SettingsManager settingsManager,
|
||||||
AudioPanel audioPanel)
|
AudioPanel audioPanel)
|
||||||
{
|
{
|
||||||
mChannelModel = channelModel;
|
mChannelModel = channelModel;
|
||||||
mChannelProcessingManager = channelProcessingManager;
|
mChannelProcessingManager = channelProcessingManager;
|
||||||
|
mIconManager = iconManager;
|
||||||
mSettingsManager = settingsManager;
|
mSettingsManager = settingsManager;
|
||||||
mAudioPanel = audioPanel;
|
mAudioPanel = audioPanel;
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ public class ChannelList extends JPanel implements ChannelEventListener
|
|||||||
if(!mDisplayedPanels.containsKey(channel))
|
if(!mDisplayedPanels.containsKey(channel))
|
||||||
{
|
{
|
||||||
ChannelPanel channelPanel = new ChannelPanel(mChannelModel,
|
ChannelPanel channelPanel = new ChannelPanel(mChannelModel,
|
||||||
mChannelProcessingManager, mSettingsManager, channel );
|
mChannelProcessingManager, mIconManager, mSettingsManager, channel);
|
||||||
|
|
||||||
add(channelPanel);
|
add(channelPanel);
|
||||||
|
|
||||||
@@ -298,9 +298,20 @@ public class ChannelList extends JPanel implements ChannelEventListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mousePressed( MouseEvent e ) {}
|
public void mousePressed(MouseEvent e)
|
||||||
public void mouseReleased( MouseEvent e ) {}
|
{
|
||||||
public void mouseEntered( MouseEvent e ) {}
|
}
|
||||||
public void mouseExited( 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;
|
package module.decode.state;
|
||||||
|
|
||||||
import java.awt.Color;
|
import controller.channel.Channel;
|
||||||
import java.awt.EventQueue;
|
import controller.channel.ChannelEvent;
|
||||||
import java.awt.Font;
|
import controller.channel.ChannelEvent.Event;
|
||||||
import java.awt.GradientPaint;
|
import controller.channel.ChannelEventListener;
|
||||||
import java.awt.Graphics;
|
import controller.channel.ChannelModel;
|
||||||
import java.awt.Graphics2D;
|
import controller.channel.ChannelProcessingManager;
|
||||||
import java.awt.Paint;
|
import controller.channel.ChannelUtils;
|
||||||
import java.util.ArrayList;
|
import icon.IconManager;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JMenu;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
import module.ProcessingChain;
|
import module.ProcessingChain;
|
||||||
import module.decode.DecoderFactory;
|
import module.decode.DecoderFactory;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import record.RecorderType;
|
import record.RecorderType;
|
||||||
import record.config.RecordConfiguration;
|
import record.config.RecordConfiguration;
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
@@ -29,13 +39,11 @@ import settings.ColorSetting.ColorSettingName;
|
|||||||
import settings.Setting;
|
import settings.Setting;
|
||||||
import settings.SettingChangeListener;
|
import settings.SettingChangeListener;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
import controller.channel.Channel;
|
|
||||||
import controller.channel.ChannelEvent;
|
import javax.swing.*;
|
||||||
import controller.channel.ChannelEvent.Event;
|
import java.awt.*;
|
||||||
import controller.channel.ChannelEventListener;
|
import java.util.ArrayList;
|
||||||
import controller.channel.ChannelModel;
|
import java.util.List;
|
||||||
import controller.channel.ChannelProcessingManager;
|
|
||||||
import controller.channel.ChannelUtils;
|
|
||||||
|
|
||||||
public class ChannelPanel extends JPanel
|
public class ChannelPanel extends JPanel
|
||||||
implements Listener<ChangedAttribute>,
|
implements Listener<ChangedAttribute>,
|
||||||
@@ -76,6 +84,7 @@ public class ChannelPanel extends JPanel
|
|||||||
private JLabel mChannelLabel;
|
private JLabel mChannelLabel;
|
||||||
|
|
||||||
protected SettingsManager mSettingsManager;
|
protected SettingsManager mSettingsManager;
|
||||||
|
protected IconManager mIconManager;
|
||||||
|
|
||||||
private Channel mChannel;
|
private Channel mChannel;
|
||||||
private ChannelState mChannelState;
|
private ChannelState mChannelState;
|
||||||
@@ -91,11 +100,13 @@ public class ChannelPanel extends JPanel
|
|||||||
*/
|
*/
|
||||||
public ChannelPanel(ChannelModel channelModel,
|
public ChannelPanel(ChannelModel channelModel,
|
||||||
ChannelProcessingManager channelProcessingManager,
|
ChannelProcessingManager channelProcessingManager,
|
||||||
|
IconManager iconManager,
|
||||||
SettingsManager settingsManager,
|
SettingsManager settingsManager,
|
||||||
Channel channel)
|
Channel channel)
|
||||||
{
|
{
|
||||||
mChannelModel = channelModel;
|
mChannelModel = channelModel;
|
||||||
mChannelProcessingManager = channelProcessingManager;
|
mChannelProcessingManager = channelProcessingManager;
|
||||||
|
mIconManager = iconManager;
|
||||||
mSettingsManager = settingsManager;
|
mSettingsManager = settingsManager;
|
||||||
mChannel = channel;
|
mChannel = channel;
|
||||||
|
|
||||||
@@ -110,7 +121,7 @@ public class ChannelPanel extends JPanel
|
|||||||
|
|
||||||
for(DecoderState decoderState : processingChain.getDecoderStates())
|
for(DecoderState decoderState : processingChain.getDecoderStates())
|
||||||
{
|
{
|
||||||
DecoderPanel panel = DecoderFactory.getDecoderPanel( mSettingsManager, decoderState );
|
DecoderPanel panel = DecoderFactory.getDecoderPanel(mIconManager, mSettingsManager, decoderState);
|
||||||
mDecoderPanels.add(panel);
|
mDecoderPanels.add(panel);
|
||||||
add(panel, "grow,span");
|
add(panel, "grow,span");
|
||||||
}
|
}
|
||||||
@@ -432,7 +443,9 @@ public class ChannelPanel extends JPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void settingDeleted( Setting setting ) {}
|
public void settingDeleted(Setting setting)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public JMenu getContextMenu()
|
public JMenu getContextMenu()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2015 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,22 +14,21 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.state;
|
package module.decode.state;
|
||||||
|
|
||||||
import java.awt.Color;
|
import alias.Alias;
|
||||||
import java.awt.Font;
|
import icon.IconManager;
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JPanel;
|
|
||||||
|
|
||||||
import sample.Listener;
|
import sample.Listener;
|
||||||
import settings.ColorSetting;
|
import settings.ColorSetting;
|
||||||
import settings.ColorSetting.ColorSettingName;
|
import settings.ColorSetting.ColorSettingName;
|
||||||
import settings.Setting;
|
import settings.Setting;
|
||||||
import settings.SettingChangeListener;
|
import settings.SettingChangeListener;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
import alias.Alias;
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public abstract class DecoderPanel extends JPanel
|
public abstract class DecoderPanel extends JPanel
|
||||||
implements Listener<ChangedAttribute>, SettingChangeListener
|
implements Listener<ChangedAttribute>, SettingChangeListener
|
||||||
@@ -45,11 +44,13 @@ public abstract class DecoderPanel extends JPanel
|
|||||||
protected Color mColorLabelDecoder;
|
protected Color mColorLabelDecoder;
|
||||||
protected Color mColorLabelAuxDecoder;
|
protected Color mColorLabelAuxDecoder;
|
||||||
|
|
||||||
|
protected IconManager mIconManager;
|
||||||
protected SettingsManager mSettingsManager;
|
protected SettingsManager mSettingsManager;
|
||||||
protected DecoderState mDecoderState;
|
protected DecoderState mDecoderState;
|
||||||
|
|
||||||
public DecoderPanel( SettingsManager settingsManager, DecoderState decoderState )
|
public DecoderPanel(IconManager iconManager, SettingsManager settingsManager, DecoderState decoderState)
|
||||||
{
|
{
|
||||||
|
mIconManager = iconManager;
|
||||||
mSettingsManager = settingsManager;
|
mSettingsManager = settingsManager;
|
||||||
mSettingsManager.addListener(this);
|
mSettingsManager.addListener(this);
|
||||||
|
|
||||||
@@ -118,7 +119,9 @@ public abstract class DecoderPanel extends JPanel
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void settingDeleted( Setting setting ) {}
|
public void settingDeleted(Setting setting)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
protected void setAliasLabel(final JLabel label, final Alias alias)
|
protected void setAliasLabel(final JLabel label, final Alias alias)
|
||||||
{
|
{
|
||||||
@@ -137,8 +140,7 @@ public abstract class DecoderPanel extends JPanel
|
|||||||
|
|
||||||
if(iconName != null)
|
if(iconName != null)
|
||||||
{
|
{
|
||||||
label.setIcon( mSettingsManager
|
label.setIcon(mIconManager.getIcon(iconName, IconManager.DEFAULT_ICON_SIZE));
|
||||||
.getImageIcon( iconName, SettingsManager.DEFAULT_ICON_SIZE ) );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* SDR Trunk
|
* sdrtrunk
|
||||||
* Copyright (C) 2014,2015 Dennis Sheirer
|
* Copyright (C) 2014-2017 Dennis Sheirer
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -14,14 +14,12 @@
|
|||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
|
*
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package module.decode.tait;
|
package module.decode.tait;
|
||||||
|
|
||||||
import java.awt.EventQueue;
|
|
||||||
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
|
|
||||||
import alias.Alias;
|
import alias.Alias;
|
||||||
|
import icon.IconManager;
|
||||||
import module.decode.state.ChangedAttribute;
|
import module.decode.state.ChangedAttribute;
|
||||||
import module.decode.state.DecoderPanel;
|
import module.decode.state.DecoderPanel;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
@@ -30,6 +28,9 @@ import settings.ColorSetting.ColorSettingName;
|
|||||||
import settings.Setting;
|
import settings.Setting;
|
||||||
import settings.SettingsManager;
|
import settings.SettingsManager;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class Tait1200DecoderPanel extends DecoderPanel
|
public class Tait1200DecoderPanel extends DecoderPanel
|
||||||
{
|
{
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
@@ -47,10 +48,9 @@ public class Tait1200DecoderPanel extends DecoderPanel
|
|||||||
private JLabel mMessage = new JLabel();
|
private JLabel mMessage = new JLabel();
|
||||||
private JLabel mMessageType = new JLabel();
|
private JLabel mMessageType = new JLabel();
|
||||||
|
|
||||||
public Tait1200DecoderPanel( SettingsManager settingsManager,
|
public Tait1200DecoderPanel(IconManager iconManager, SettingsManager settingsManager, Tait1200DecoderState decoderState)
|
||||||
Tait1200DecoderState decoderState )
|
|
||||||
{
|
{
|
||||||
super( settingsManager, decoderState );
|
super(iconManager, settingsManager, decoderState);
|
||||||
|
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -432,9 +432,9 @@ public class PlaylistManager implements ChannelEventListener
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
mPlaylistSavePending.set(false);
|
|
||||||
|
|
||||||
save();
|
save();
|
||||||
|
|
||||||
|
mPlaylistSavePending.set(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,22 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package settings;
|
package settings;
|
||||||
|
|
||||||
import java.awt.Color;
|
import controller.ThreadPoolManager;
|
||||||
import java.awt.Image;
|
import org.jdesktop.swingx.mapviewer.GeoPosition;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import properties.SystemProperties;
|
||||||
|
import sample.Listener;
|
||||||
|
import settings.ColorSetting.ColorSettingName;
|
||||||
|
import source.recording.RecordingConfiguration;
|
||||||
|
import source.tuner.configuration.TunerConfigurationEvent;
|
||||||
|
import source.tuner.configuration.TunerConfigurationModel;
|
||||||
|
|
||||||
|
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.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
@@ -28,62 +42,26 @@ import java.io.OutputStream;
|
|||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
|
||||||
import javax.swing.ImageIcon;
|
|
||||||
import javax.xml.bind.JAXBContext;
|
|
||||||
import javax.xml.bind.JAXBException;
|
|
||||||
import javax.xml.bind.Marshaller;
|
|
||||||
import javax.xml.bind.Unmarshaller;
|
|
||||||
|
|
||||||
import map.DefaultIcon;
|
|
||||||
import map.MapIcon;
|
|
||||||
|
|
||||||
import org.jdesktop.swingx.mapviewer.GeoPosition;
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import properties.SystemProperties;
|
|
||||||
import sample.Listener;
|
|
||||||
import settings.ColorSetting.ColorSettingName;
|
|
||||||
import source.recording.RecordingConfiguration;
|
|
||||||
import source.tuner.configuration.TunerConfigurationEvent;
|
|
||||||
import source.tuner.configuration.TunerConfigurationModel;
|
|
||||||
import controller.ThreadPoolManager;
|
|
||||||
|
|
||||||
public class SettingsManager implements Listener<TunerConfigurationEvent>
|
public class SettingsManager implements Listener<TunerConfigurationEvent>
|
||||||
{
|
{
|
||||||
private final static Logger mLog =
|
private final static Logger mLog = LoggerFactory.getLogger(SettingsManager.class);
|
||||||
LoggerFactory.getLogger( SettingsManager.class );
|
|
||||||
|
|
||||||
private Settings mSettings = new Settings();
|
private Settings mSettings = new Settings();
|
||||||
|
private List<SettingChangeListener> mListeners = new ArrayList<>();
|
||||||
private ArrayList<SettingChangeListener> mListeners =
|
|
||||||
new ArrayList<SettingChangeListener>();
|
|
||||||
|
|
||||||
public static final String DEFAULT_ICON = "No Icon";
|
|
||||||
public String mCurrentDefaultIconName = DEFAULT_ICON;
|
|
||||||
public static final int DEFAULT_ICON_SIZE = 12;
|
|
||||||
|
|
||||||
private HashMap<String,MapIcon> mIcons = new HashMap<String,MapIcon>();
|
|
||||||
|
|
||||||
private HashMap<String,ImageIcon> mResizedIcons =
|
|
||||||
new HashMap<String,ImageIcon>();
|
|
||||||
|
|
||||||
private TunerConfigurationModel mTunerConfigurationModel;
|
private TunerConfigurationModel mTunerConfigurationModel;
|
||||||
private ThreadPoolManager mThreadPoolManager;
|
private ThreadPoolManager mThreadPoolManager;
|
||||||
|
|
||||||
private boolean mLoadingSettings = false;
|
private boolean mLoadingSettings = false;
|
||||||
private AtomicBoolean mSettingsSavePending = new AtomicBoolean();
|
private AtomicBoolean mSettingsSavePending = new AtomicBoolean();
|
||||||
|
|
||||||
public SettingsManager(ThreadPoolManager threadPoolManager,
|
public SettingsManager(ThreadPoolManager threadPoolManager,
|
||||||
TunerConfigurationModel tunerConfigurationModel)
|
TunerConfigurationModel tunerConfigurationModel)
|
||||||
{
|
{
|
||||||
//TODO: move settings and icons into a SettingsModel and an IconModel
|
//TODO: move settings into a SettingsModel
|
||||||
//and update this class to only provide loading, saving, and model
|
//and update this class to only provide loading, saving, and model
|
||||||
//change detection producing a save.
|
//change detection producing a save.
|
||||||
|
|
||||||
@@ -113,8 +91,6 @@ public class SettingsManager implements Listener<TunerConfigurationEvent>
|
|||||||
props.get("settings.currentFilename", defaultSettingsFile);
|
props.get("settings.currentFilename", defaultSettingsFile);
|
||||||
|
|
||||||
load(settingsFolder.resolve(settingsFile));
|
load(settingsFolder.resolve(settingsFile));
|
||||||
|
|
||||||
refreshIcons();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -126,39 +102,6 @@ public class SettingsManager implements Listener<TunerConfigurationEvent>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reloads the icon hash map, and sets up the default iconology. If the
|
|
||||||
* saved default icon name is not part of the current set of icons, we
|
|
||||||
* set the default icon to the standard system default name, which should
|
|
||||||
* be guaranteed to be available.
|
|
||||||
*/
|
|
||||||
public void refreshIcons()
|
|
||||||
{
|
|
||||||
mIcons.clear();
|
|
||||||
|
|
||||||
mCurrentDefaultIconName = DEFAULT_ICON;
|
|
||||||
|
|
||||||
DefaultIcon defaultIcon = getDefaultIcon();
|
|
||||||
|
|
||||||
ArrayList<MapIcon> icons = mSettings.getMapIcons();
|
|
||||||
icons.addAll( getStandardIcons() );
|
|
||||||
|
|
||||||
for( MapIcon icon: icons )
|
|
||||||
{
|
|
||||||
mIcons.put( icon.getName(), icon );
|
|
||||||
|
|
||||||
if( icon.getName().contentEquals( defaultIcon.getName() ) )
|
|
||||||
{
|
|
||||||
mCurrentDefaultIconName = defaultIcon.getName();
|
|
||||||
icon.setDefaultIcon( true );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
icon.setDefaultIcon( false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Settings getSettings()
|
public Settings getSettings()
|
||||||
{
|
{
|
||||||
return mSettings;
|
return mSettings;
|
||||||
@@ -253,309 +196,9 @@ public class SettingsManager implements Listener<TunerConfigurationEvent>
|
|||||||
scheduleSettingsSave();
|
scheduleSettingsSave();
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapIcon[] getMapIcons()
|
|
||||||
{
|
|
||||||
MapIcon[] returnIcons = new MapIcon[mIcons.values().size() ];
|
|
||||||
|
|
||||||
return mIcons.values().toArray( returnIcons );
|
|
||||||
}
|
|
||||||
|
|
||||||
private ArrayList<MapIcon> getStandardIcons()
|
|
||||||
{
|
|
||||||
ArrayList<MapIcon> icons = new ArrayList<MapIcon>();
|
|
||||||
|
|
||||||
MapIcon defaultIcon = new MapIcon( DEFAULT_ICON, "images/no_icon.png", false );
|
|
||||||
icons.add( defaultIcon );
|
|
||||||
|
|
||||||
MapIcon ambulance =
|
|
||||||
new MapIcon( "Ambulance", "images/ambulance.png", false );
|
|
||||||
icons.add( ambulance );
|
|
||||||
|
|
||||||
MapIcon blockTruck =
|
|
||||||
new MapIcon( "Block Truck", "images/concrete_block_truck.png", false );
|
|
||||||
icons.add( blockTruck );
|
|
||||||
|
|
||||||
MapIcon cwid = new MapIcon( "CWID", "images/cwid.png", false );
|
|
||||||
icons.add( cwid );
|
|
||||||
|
|
||||||
MapIcon dispatcher =
|
|
||||||
new MapIcon( "Dispatcher", "images/dispatcher.png", false );
|
|
||||||
icons.add( dispatcher );
|
|
||||||
|
|
||||||
MapIcon dumpTruck =
|
|
||||||
new MapIcon( "Dump Truck", "images/dump_truck_red.png", false );
|
|
||||||
icons.add( dumpTruck );
|
|
||||||
|
|
||||||
MapIcon fireTruck =
|
|
||||||
new MapIcon( "Fire Truck", "images/fire_truck.png", false );
|
|
||||||
icons.add( fireTruck );
|
|
||||||
|
|
||||||
MapIcon garbageTruck =
|
|
||||||
new MapIcon( "Garbage Truck", "images/garbage_truck.png", false );
|
|
||||||
icons.add( garbageTruck );
|
|
||||||
|
|
||||||
MapIcon loader = new MapIcon( "Loader", "images/loader.png", false );
|
|
||||||
icons.add( loader );
|
|
||||||
|
|
||||||
MapIcon police =
|
|
||||||
new MapIcon( "Police", "images/police.png", false );
|
|
||||||
icons.add( police );
|
|
||||||
|
|
||||||
MapIcon propaneTruck =
|
|
||||||
new MapIcon( "Propane Truck", "images/propane_truck.png", false );
|
|
||||||
icons.add( propaneTruck );
|
|
||||||
|
|
||||||
MapIcon rescueTruck =
|
|
||||||
new MapIcon( "Rescue Truck", "images/rescue_truck.png", false );
|
|
||||||
icons.add( rescueTruck );
|
|
||||||
|
|
||||||
MapIcon schoolBus =
|
|
||||||
new MapIcon( "School Bus", "images/school_bus.png", false );
|
|
||||||
icons.add( schoolBus );
|
|
||||||
|
|
||||||
MapIcon taxi =
|
|
||||||
new MapIcon( "Taxi", "images/taxi.png", false );
|
|
||||||
icons.add( taxi );
|
|
||||||
|
|
||||||
MapIcon train =
|
|
||||||
new MapIcon( "Train", "images/train.png", false );
|
|
||||||
icons.add( train );
|
|
||||||
|
|
||||||
MapIcon transportBus =
|
|
||||||
new MapIcon( "Transport Bus", "images/opt_bus.png", false );
|
|
||||||
icons.add( transportBus );
|
|
||||||
|
|
||||||
MapIcon van =
|
|
||||||
new MapIcon( "Van", "images/van.png", false );
|
|
||||||
icons.add( van );
|
|
||||||
|
|
||||||
return icons;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Deletes the map icon
|
|
||||||
*/
|
|
||||||
public void deleteMapIcon( MapIcon icon )
|
|
||||||
{
|
|
||||||
MapIcon existing = mIcons.get( icon.getName() );
|
|
||||||
|
|
||||||
if( existing != null )
|
|
||||||
{
|
|
||||||
mIcons.remove( icon.getName() );
|
|
||||||
|
|
||||||
mSettings.removeSetting( existing );
|
|
||||||
|
|
||||||
broadcastSettingDeleted( existing );
|
|
||||||
|
|
||||||
scheduleSettingsSave();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the icon, overwriting any existing icon with the same name
|
|
||||||
* @param icon
|
|
||||||
*/
|
|
||||||
public void addMapIcon( MapIcon icon )
|
|
||||||
{
|
|
||||||
MapIcon existing = mIcons.get( icon.getName() );
|
|
||||||
|
|
||||||
if( existing == null )
|
|
||||||
{
|
|
||||||
MapIcon newIcon = new MapIcon( icon.getName(), icon.getPath() );
|
|
||||||
mIcons.put( newIcon.getName(), newIcon );
|
|
||||||
addSetting( newIcon );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
existing.setName( icon.getName() );
|
|
||||||
existing.setPath( icon.getPath() );
|
|
||||||
broadcastSettingChange( existing );
|
|
||||||
scheduleSettingsSave();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updatMapIcon( MapIcon icon, String newName, String newPath )
|
|
||||||
{
|
|
||||||
MapIcon existing = mSettings.getMapIcon( icon.getName() );
|
|
||||||
|
|
||||||
if( existing == null )
|
|
||||||
{
|
|
||||||
addMapIcon( new MapIcon( newName, newPath ) );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
existing.setName( newName );
|
|
||||||
existing.setPath( newPath );
|
|
||||||
broadcastSettingChange( existing );
|
|
||||||
scheduleSettingsSave();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns named map icon scaled to height, if necessary.
|
|
||||||
* @param name - name of icon
|
|
||||||
* @param heigh - height of icon in pixels
|
|
||||||
*
|
|
||||||
* @return - ImageIcon or null
|
|
||||||
*/
|
|
||||||
public ImageIcon getImageIcon( String name, int height )
|
|
||||||
{
|
|
||||||
if( name != null )
|
|
||||||
{
|
|
||||||
String mergedName = name + height;
|
|
||||||
|
|
||||||
if( mResizedIcons.containsKey( mergedName ) )
|
|
||||||
{
|
|
||||||
return mResizedIcons.get( mergedName );
|
|
||||||
}
|
|
||||||
|
|
||||||
MapIcon mapIcon = mIcons.get( name );
|
|
||||||
|
|
||||||
if( mapIcon == null )
|
|
||||||
{
|
|
||||||
mapIcon = new MapIcon( name, name );
|
|
||||||
mIcons.put( name, mapIcon );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( mapIcon != null )
|
|
||||||
{
|
|
||||||
if( mapIcon.getImageIcon().getIconHeight() > height )
|
|
||||||
{
|
|
||||||
ImageIcon scaled = getScaledIcon( mapIcon.getImageIcon(), height );
|
|
||||||
|
|
||||||
mResizedIcons.put( mergedName, scaled );
|
|
||||||
|
|
||||||
return scaled;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return mapIcon.getImageIcon();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Use the default Icon */
|
|
||||||
@SuppressWarnings( "unused" )
|
|
||||||
String mergedDefault = mCurrentDefaultIconName + height;
|
|
||||||
|
|
||||||
if( mResizedIcons.containsKey( mergedDefault ) )
|
|
||||||
{
|
|
||||||
return mResizedIcons.get( mergedDefault );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MapIcon defaultIcon = mIcons.get( mCurrentDefaultIconName );
|
|
||||||
|
|
||||||
if( defaultIcon != null )
|
|
||||||
{
|
|
||||||
if( defaultIcon.getImageIcon().getIconHeight() > height )
|
|
||||||
{
|
|
||||||
ImageIcon scaledDefault = getScaledIcon( defaultIcon.getImageIcon(), height );
|
|
||||||
mResizedIcons.put( mergedDefault, scaledDefault );
|
|
||||||
return scaledDefault;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
mResizedIcons.put( mergedDefault, defaultIcon.getImageIcon() );
|
|
||||||
return defaultIcon.getImageIcon();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Something happened ... the above should always return an icon */
|
|
||||||
mLog.error( "SettingsManager - couldn't return an icon named [" +
|
|
||||||
name + "] of heigh [" + height + "]" );
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
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 );
|
|
||||||
}
|
|
||||||
|
|
||||||
public MapIcon getMapIcon( String name )
|
|
||||||
{
|
|
||||||
if( mIcons.containsKey( name ) )
|
|
||||||
{
|
|
||||||
return mIcons.get( name );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return the default */
|
|
||||||
if( mIcons.containsKey( mCurrentDefaultIconName ) )
|
|
||||||
{
|
|
||||||
return mIcons.get( mCurrentDefaultIconName );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return the real default */
|
|
||||||
return mIcons.get( DEFAULT_ICON );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the named map icon, or creates it with the default path
|
|
||||||
* @param name - name of the icon
|
|
||||||
* @param defaultPath - path to icon image file
|
|
||||||
* @return - map icon
|
|
||||||
*/
|
|
||||||
public MapIcon getMapIcon( String name, String defaultPath )
|
|
||||||
{
|
|
||||||
MapIcon icon = mSettings.getMapIcon( name );
|
|
||||||
|
|
||||||
if( icon == null )
|
|
||||||
{
|
|
||||||
icon = new MapIcon( name, defaultPath );
|
|
||||||
|
|
||||||
addSetting( icon );
|
|
||||||
}
|
|
||||||
|
|
||||||
return icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public DefaultIcon getDefaultIcon()
|
|
||||||
{
|
|
||||||
DefaultIcon icon = mSettings.getDefaultIcon();
|
|
||||||
|
|
||||||
if( icon == null )
|
|
||||||
{
|
|
||||||
icon = new DefaultIcon( DEFAULT_ICON );
|
|
||||||
|
|
||||||
addSetting( icon );
|
|
||||||
}
|
|
||||||
|
|
||||||
return icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefaultIcon( MapIcon icon )
|
|
||||||
{
|
|
||||||
if( mIcons.containsValue( icon ) )
|
|
||||||
{
|
|
||||||
MapIcon currentDefault = mIcons.get( mCurrentDefaultIconName );
|
|
||||||
|
|
||||||
currentDefault.setDefaultIcon( false );
|
|
||||||
|
|
||||||
icon.setDefaultIcon( true );
|
|
||||||
|
|
||||||
mCurrentDefaultIconName = icon.getName();
|
|
||||||
|
|
||||||
DefaultIcon defaultIconSetting = getDefaultIcon();
|
|
||||||
|
|
||||||
defaultIconSetting.setName( icon.getName() );
|
|
||||||
|
|
||||||
scheduleSettingsSave();
|
|
||||||
|
|
||||||
broadcastSettingChange( defaultIconSetting );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the setting and stores the set of settings
|
* Adds the setting and stores the set of settings
|
||||||
|
*
|
||||||
* @param setting
|
* @param setting
|
||||||
*/
|
*/
|
||||||
private void addSetting(Setting setting)
|
private void addSetting(Setting setting)
|
||||||
|
|||||||
Reference in New Issue
Block a user