mirror of
https://github.com/DSheirer/sdrtrunk.git
synced 2026-11-09 15:17:24 -05:00
Compare commits
3 Commits
v0.3.3-bet
...
v0.3.3-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
336669f1d5 | ||
|
|
46cf7f4193 | ||
|
|
e9aeb09011 |
@@ -15,7 +15,7 @@ repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
version = '0.3.3-beta.2'
|
||||
version = '0.3.3-beta.3'
|
||||
sourceCompatibility = 1.8
|
||||
|
||||
sourceSets {
|
||||
|
||||
@@ -81,16 +81,23 @@ public class Icon implements Comparable<Icon>
|
||||
{
|
||||
try
|
||||
{
|
||||
URL imageURL = Icon.class.getResource(mPath);
|
||||
|
||||
if(imageURL == null && !mPath.startsWith("/"))
|
||||
if(mPath.startsWith("/"))
|
||||
{
|
||||
imageURL = (Icon.class.getResource("/" + mPath));
|
||||
mImageIcon = new ImageIcon(mPath);
|
||||
}
|
||||
|
||||
if(imageURL != null)
|
||||
else
|
||||
{
|
||||
mImageIcon = new ImageIcon(imageURL);
|
||||
URL imageURL = Icon.class.getResource(mPath);
|
||||
|
||||
if(imageURL == null && !mPath.startsWith("/"))
|
||||
{
|
||||
imageURL = (Icon.class.getResource("/" + mPath));
|
||||
}
|
||||
|
||||
if(imageURL != null)
|
||||
{
|
||||
mImageIcon = new ImageIcon(imageURL);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
|
||||
@@ -129,7 +129,7 @@ public class IconManager
|
||||
/**
|
||||
* All icons in a sorted array
|
||||
*/
|
||||
public io.github.dsheirer.icon.Icon[] getIcons()
|
||||
public Icon[] getIcons()
|
||||
{
|
||||
return getModel().getIconsAsArray();
|
||||
}
|
||||
@@ -159,7 +159,11 @@ public class IconManager
|
||||
Icon icon = getModel().getIcon(name);
|
||||
|
||||
ImageIcon scaledIcon = getScaledIcon(icon.getIcon(), height);
|
||||
mResizedIcons.put(scaledIconName, scaledIcon);
|
||||
|
||||
if(scaledIcon != null)
|
||||
{
|
||||
mResizedIcons.put(scaledIconName, scaledIcon);
|
||||
}
|
||||
|
||||
return scaledIcon;
|
||||
}
|
||||
@@ -173,14 +177,19 @@ public class IconManager
|
||||
*/
|
||||
public static ImageIcon getScaledIcon(ImageIcon original, int height)
|
||||
{
|
||||
double scale = (double) original.getIconHeight() / (double) height;
|
||||
if(original != null)
|
||||
{
|
||||
double scale = (double) original.getIconHeight() / (double) height;
|
||||
|
||||
int scaledWidth = (int) ((double) original.getIconWidth() / scale);
|
||||
int scaledWidth = (int) ((double) original.getIconWidth() / scale);
|
||||
|
||||
Image scaledImage = original.getImage().getScaledInstance(scaledWidth,
|
||||
height, java.awt.Image.SCALE_SMOOTH);
|
||||
Image scaledImage = original.getImage().getScaledInstance(scaledWidth,
|
||||
height, java.awt.Image.SCALE_SMOOTH);
|
||||
|
||||
return new ImageIcon(scaledImage);
|
||||
return new ImageIcon(scaledImage);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -191,9 +200,14 @@ public class IconManager
|
||||
*/
|
||||
public static ImageIcon getScaledIcon(String path, int height)
|
||||
{
|
||||
Icon icon = new Icon("", path);
|
||||
if(path != null)
|
||||
{
|
||||
Icon icon = new Icon("", path);
|
||||
|
||||
return getScaledIcon(icon.getIcon(), height);
|
||||
return getScaledIcon(icon.getIcon(), height);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,10 +20,16 @@ package io.github.dsheirer.icon;
|
||||
|
||||
import net.miginfocom.swing.MigLayout;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JTextField;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import java.awt.*;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.Frame;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
@@ -119,7 +125,7 @@ public class IconSelector extends JDialog implements DocumentListener
|
||||
String name = mNameText.getText();
|
||||
String path = mFileLabel.getText();
|
||||
|
||||
io.github.dsheirer.icon.Icon icon = new io.github.dsheirer.icon.Icon(name, path);
|
||||
Icon icon = new Icon(name, path);
|
||||
mIconTableModel.add(icon);
|
||||
|
||||
IconSelector.this.dispose();
|
||||
|
||||
Reference in New Issue
Block a user