mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-12 16:47:31 -05:00
Updates PlaylistManager to use faster jackson XML serialization.
Removes native xml.bind serialization for improved compatibility with Java 9. Global optimize imports on the entire project.
This commit is contained in:
@@ -17,8 +17,10 @@
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.map;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
import io.github.dsheirer.settings.Setting;
|
||||
|
||||
@JsonSubTypes.Type(value = DefaultIcon.class, name = "defaultIcon")
|
||||
public class DefaultIcon extends Setting
|
||||
{
|
||||
public DefaultIcon( String name )
|
||||
|
||||
@@ -1,187 +1,190 @@
|
||||
/*******************************************************************************
|
||||
* 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 io.github.dsheirer.map;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
|
||||
import io.github.dsheirer.settings.Setting;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.xml.bind.annotation.XmlAttribute;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
import java.awt.*;
|
||||
|
||||
@JsonSubTypes.Type(value = MapIcon.class, name = "mapIcon")
|
||||
public class MapIcon extends Setting implements Comparable<MapIcon>
|
||||
{
|
||||
private static final int sMAX_IMAGE_DIMENSION = 48;
|
||||
private String mPath;
|
||||
private ImageIcon mImageIcon;
|
||||
private static final int sMAX_IMAGE_DIMENSION = 48;
|
||||
private String mPath;
|
||||
private ImageIcon mImageIcon;
|
||||
|
||||
/**
|
||||
* Only map icons created at runtime can be marked as non-editable, and
|
||||
* therefore this property is transient.
|
||||
*/
|
||||
@XmlTransient
|
||||
private boolean mEditable;
|
||||
|
||||
@XmlTransient
|
||||
private boolean mDefaultIcon;
|
||||
|
||||
/**
|
||||
* Wrapper class for a map icon.
|
||||
* @param name - name of the icon - also used as key to lookup the icon
|
||||
* @param path - file path to the icon
|
||||
* @param editable - defines if the map icon or details can be edited
|
||||
*
|
||||
* Note: the default icons are constructed with editable = false, so that
|
||||
* they cannot be deleted from the Icon Manager editor window
|
||||
*/
|
||||
public MapIcon( String name, String path, boolean editable )
|
||||
{
|
||||
super( name );
|
||||
mPath = path;
|
||||
mEditable = editable;
|
||||
}
|
||||
|
||||
public MapIcon( String name, String path )
|
||||
{
|
||||
this( name, path, true );
|
||||
}
|
||||
/**
|
||||
* Only map icons created at runtime can be marked as non-editable, and
|
||||
* therefore this property is transient.
|
||||
*/
|
||||
@JsonIgnore
|
||||
private boolean mEditable;
|
||||
|
||||
/**
|
||||
* Don't use this constructor. This is used by JAXB to unmarshall saved
|
||||
* map icons.
|
||||
*/
|
||||
public MapIcon()
|
||||
{
|
||||
mEditable = true;
|
||||
}
|
||||
@JsonIgnore
|
||||
private boolean mDefaultIcon;
|
||||
|
||||
|
||||
@XmlAttribute( name="editable" )
|
||||
public boolean isEditable()
|
||||
{
|
||||
return mEditable;
|
||||
}
|
||||
|
||||
@XmlAttribute( name="default" )
|
||||
public boolean isDefaultIcon()
|
||||
{
|
||||
return mDefaultIcon;
|
||||
}
|
||||
|
||||
public void setDefaultIcon( boolean isDefault )
|
||||
{
|
||||
mDefaultIcon = isDefault;
|
||||
}
|
||||
|
||||
public ImageIcon getImageIcon()
|
||||
{
|
||||
if( mImageIcon == null )
|
||||
{
|
||||
mImageIcon = new ImageIcon( mPath );
|
||||
|
||||
/**
|
||||
* If the image is too big, scale it down to max pixel size squared
|
||||
*/
|
||||
if( mImageIcon.getIconWidth() > sMAX_IMAGE_DIMENSION ||
|
||||
mImageIcon.getIconHeight() > sMAX_IMAGE_DIMENSION )
|
||||
{
|
||||
/**
|
||||
* getScaled instance will correct any negative value to the
|
||||
* correct value, maintaining original aspect ratio. So, we
|
||||
* only scale the larger value, and allow the image class to
|
||||
* determine the correct value for the other measurement
|
||||
*/
|
||||
int height = -1;
|
||||
int width = -1;
|
||||
|
||||
/**
|
||||
* Use the larger width or height value to determine the
|
||||
* scaling factor
|
||||
*/
|
||||
if( mImageIcon.getIconHeight() > mImageIcon.getIconWidth() )
|
||||
{
|
||||
height = sMAX_IMAGE_DIMENSION;
|
||||
}
|
||||
else
|
||||
{
|
||||
width = sMAX_IMAGE_DIMENSION;
|
||||
}
|
||||
|
||||
mImageIcon = new ImageIcon( mImageIcon.getImage()
|
||||
.getScaledInstance( width, height, Image.SCALE_SMOOTH ) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return mImageIcon;
|
||||
}
|
||||
|
||||
@XmlAttribute( name="path" )
|
||||
public String getPath()
|
||||
{
|
||||
return mPath;
|
||||
}
|
||||
|
||||
public void setPath( String path )
|
||||
{
|
||||
mPath = path;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
if( mDefaultIcon )
|
||||
{
|
||||
return getName() + " (default)";
|
||||
}
|
||||
else
|
||||
{
|
||||
return getName();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
if( obj instanceof MapIcon )
|
||||
{
|
||||
MapIcon other = (MapIcon)obj;
|
||||
|
||||
return other.getName().contentEquals( getName() ) &&
|
||||
other.getPath().contentEquals( getPath() );
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return getName().hashCode() + getPath().hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort order is determined by the icon name
|
||||
*/
|
||||
@Override
|
||||
public int compareTo( MapIcon other )
|
||||
/**
|
||||
* Wrapper class for a map icon.
|
||||
*
|
||||
* @param name - name of the icon - also used as key to lookup the icon
|
||||
* @param path - file path to the icon
|
||||
* @param editable - defines if the map icon or details can be edited
|
||||
*
|
||||
* Note: the default icons are constructed with editable = false, so that
|
||||
* they cannot be deleted from the Icon Manager editor window
|
||||
*/
|
||||
public MapIcon(String name, String path, boolean editable)
|
||||
{
|
||||
return getName().compareTo( other.getName() );
|
||||
super(name);
|
||||
mPath = path;
|
||||
mEditable = editable;
|
||||
}
|
||||
|
||||
public MapIcon(String name, String path)
|
||||
{
|
||||
this(name, path, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Don't use this constructor. This is used by JAXB to unmarshall saved
|
||||
* map icons.
|
||||
*/
|
||||
public MapIcon()
|
||||
{
|
||||
mEditable = true;
|
||||
}
|
||||
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "editable")
|
||||
public boolean isEditable()
|
||||
{
|
||||
return mEditable;
|
||||
}
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "default")
|
||||
public boolean isDefaultIcon()
|
||||
{
|
||||
return mDefaultIcon;
|
||||
}
|
||||
|
||||
public void setDefaultIcon(boolean isDefault)
|
||||
{
|
||||
mDefaultIcon = isDefault;
|
||||
}
|
||||
|
||||
public ImageIcon getImageIcon()
|
||||
{
|
||||
if(mImageIcon == null)
|
||||
{
|
||||
mImageIcon = new ImageIcon(mPath);
|
||||
|
||||
/**
|
||||
* If the image is too big, scale it down to max pixel size squared
|
||||
*/
|
||||
if(mImageIcon.getIconWidth() > sMAX_IMAGE_DIMENSION ||
|
||||
mImageIcon.getIconHeight() > sMAX_IMAGE_DIMENSION)
|
||||
{
|
||||
/**
|
||||
* getScaled instance will correct any negative value to the
|
||||
* correct value, maintaining original aspect ratio. So, we
|
||||
* only scale the larger value, and allow the image class to
|
||||
* determine the correct value for the other measurement
|
||||
*/
|
||||
int height = -1;
|
||||
int width = -1;
|
||||
|
||||
/**
|
||||
* Use the larger width or height value to determine the
|
||||
* scaling factor
|
||||
*/
|
||||
if(mImageIcon.getIconHeight() > mImageIcon.getIconWidth())
|
||||
{
|
||||
height = sMAX_IMAGE_DIMENSION;
|
||||
}
|
||||
else
|
||||
{
|
||||
width = sMAX_IMAGE_DIMENSION;
|
||||
}
|
||||
|
||||
mImageIcon = new ImageIcon(mImageIcon.getImage()
|
||||
.getScaledInstance(width, height, Image.SCALE_SMOOTH));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return mImageIcon;
|
||||
}
|
||||
|
||||
@JacksonXmlProperty(isAttribute = true, localName = "path")
|
||||
public String getPath()
|
||||
{
|
||||
return mPath;
|
||||
}
|
||||
|
||||
public void setPath(String path)
|
||||
{
|
||||
mPath = path;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
if(mDefaultIcon)
|
||||
{
|
||||
return getName() + " (default)";
|
||||
}
|
||||
else
|
||||
{
|
||||
return getName();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if(obj instanceof MapIcon)
|
||||
{
|
||||
MapIcon other = (MapIcon)obj;
|
||||
|
||||
return other.getName().contentEquals(getName()) &&
|
||||
other.getPath().contentEquals(getPath());
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return getName().hashCode() + getPath().hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort order is determined by the icon name
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(MapIcon other)
|
||||
{
|
||||
return getName().compareTo(other.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.map;
|
||||
|
||||
import io.github.dsheirer.alias.Alias;
|
||||
import io.github.dsheirer.icon.IconManager;
|
||||
import io.github.dsheirer.message.Message;
|
||||
import io.github.dsheirer.sample.Listener;
|
||||
import io.github.dsheirer.alias.Alias;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
******************************************************************************/
|
||||
package io.github.dsheirer.map;
|
||||
|
||||
import org.jdesktop.swingx.mapviewer.GeoPosition;
|
||||
import io.github.dsheirer.alias.Alias;
|
||||
import org.jdesktop.swingx.mapviewer.GeoPosition;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Collections;
|
||||
|
||||
Reference in New Issue
Block a user