mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
#82 WIP - converted all classes to get icons from IconManager and removed icon management from the SettingsManager
This commit is contained in:
@@ -45,6 +45,7 @@ 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;
|
||||
@@ -99,6 +100,14 @@ public class IconManager
|
||||
{
|
||||
IconSet loadedIcons = load();
|
||||
|
||||
boolean saveRequired = false;
|
||||
|
||||
if(loadedIcons == null)
|
||||
{
|
||||
loadedIcons = getDefaultIconSet();
|
||||
saveRequired = true;
|
||||
}
|
||||
|
||||
mIconModel = new IconModel(loadedIcons);
|
||||
mIconModel.addListDataListener(new ListDataListener()
|
||||
{
|
||||
@@ -120,6 +129,11 @@ public class IconManager
|
||||
scheduleSave();
|
||||
}
|
||||
});
|
||||
|
||||
if(saveRequired)
|
||||
{
|
||||
scheduleSave();
|
||||
}
|
||||
}
|
||||
|
||||
return mIconModel;
|
||||
@@ -170,7 +184,7 @@ public class IconManager
|
||||
* @param height new height to scale the image (width will be scaled accordingly)
|
||||
* @return
|
||||
*/
|
||||
private static ImageIcon getScaledIcon(ImageIcon original, int height)
|
||||
public static ImageIcon getScaledIcon(ImageIcon original, int height)
|
||||
{
|
||||
double scale = (double) original.getIconHeight() / (double) height;
|
||||
|
||||
@@ -365,11 +379,6 @@ public class IconManager
|
||||
mLog.info("Icons file not found at [" + getIconFilePath().toString() + "]");
|
||||
}
|
||||
|
||||
if(iconSet == null)
|
||||
{
|
||||
iconSet = getDefaultIconSet();
|
||||
}
|
||||
|
||||
return iconSet;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ package icon;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -31,11 +30,11 @@ public class IconModel extends DefaultListModel<Icon>
|
||||
public static final String DEFAULT_ICON = "No Icon";
|
||||
|
||||
private Icon mDefaultIcon;
|
||||
private Map<String,Icon> mIconMap = new HashMap();
|
||||
private Map<String, Icon> mIconMap = new HashMap<>();
|
||||
|
||||
public IconModel(IconSet iconSet)
|
||||
{
|
||||
for(Icon icon: iconSet.getIcons())
|
||||
for(Icon icon : iconSet.getIcons())
|
||||
{
|
||||
this.addElement(icon);
|
||||
}
|
||||
@@ -78,6 +77,7 @@ public class IconModel extends DefaultListModel<Icon>
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
@@ -131,7 +131,7 @@ public class IconModel extends DefaultListModel<Icon>
|
||||
{
|
||||
if(object instanceof Icon)
|
||||
{
|
||||
mIconMap.remove(((Icon)object).getName());
|
||||
mIconMap.remove(((Icon) object).getName());
|
||||
}
|
||||
|
||||
return super.removeElement(object);
|
||||
|
||||
@@ -20,7 +20,6 @@ package icon;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlElementWrapper;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -46,7 +45,6 @@ public class IconSet
|
||||
mIcons.remove(icon);
|
||||
}
|
||||
|
||||
@XmlElementWrapper(name="icons")
|
||||
@XmlElement(name = "icon")
|
||||
public List<Icon> getIcons()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user