changing Icon references to what they actually always are, ImageIcons

this change is in prep for some serialization changes i will be doing
in the very near future. i will need access to the underlying Image
object and the Icon interface doesn't include that so i would need to
cast at some point to ImageIcon anyway.
This commit is contained in:
Gered 2015-12-01 13:40:49 -05:00
parent 3c9405e74b
commit 0559de6b88
5 changed files with 19 additions and 27 deletions

View file

@ -976,7 +976,7 @@ public class Run implements TableModel, Serializable {
Segment segment = getSegment(row);
switch (column) {
case COLUMN_ICON:
segment.setIcon((Icon) value);
segment.setIcon((ImageIcon) value);
tmSupport.fireTableCellUpdated(row, column);
break;

View file

@ -91,7 +91,7 @@ public class Segment implements Cloneable, Serializable {
* Icon associated with this segment. Can be {@code null} if no icon is to
* be displayed.
*/
private Icon icon;
private ImageIcon icon;
/**
* Registered time for this segment during the best run.
@ -155,7 +155,7 @@ public class Segment implements Cloneable, Serializable {
*
* @return the icon of the segment or {@code null}.
*/
public Icon getIcon() {
public ImageIcon getIcon() {
return icon;
}
@ -240,7 +240,7 @@ public class Segment implements Cloneable, Serializable {
*
* @param icon - the new icon for this segment.
*/
public void setIcon(Icon icon) {
public void setIcon(ImageIcon icon) {
if (icon == null) {
this.icon = null;
} else {

View file

@ -515,7 +515,7 @@ class Core extends JPanel implements ActionListener {
}
if ((identifier & ICON) == ICON) {
if (hasCurrent) {
Icon img = currentSgt.getIcon();
ImageIcon img = currentSgt.getIcon();
if (img != null) {
icon.setIcon(
Images.rescale(img, Settings.coreIconSize.get()));

View file

@ -1,29 +1,21 @@
package org.fenix.llanfair.gui;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.GridBagLayout;
import org.fenix.llanfair.Run;
import org.fenix.llanfair.Run.State;
import org.fenix.llanfair.Segment;
import org.fenix.llanfair.Time;
import org.fenix.llanfair.config.Merge;
import org.fenix.llanfair.config.Settings;
import org.fenix.utils.Images;
import org.fenix.utils.gui.GBC;
import javax.swing.*;
import javax.swing.event.TableModelEvent;
import java.awt.*;
import java.beans.PropertyChangeEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.Icon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.event.TableModelEvent;
import org.fenix.llanfair.Run;
import org.fenix.llanfair.Segment;
import org.fenix.llanfair.config.Settings;
import org.fenix.llanfair.Time;
import org.fenix.llanfair.Run.State;
import org.fenix.llanfair.config.Merge;
import org.fenix.utils.gui.GBC;
import org.fenix.utils.Images;
/**
* A scrolling pane capable of displaying a specific number of segments with
* information concerning their times. This pane contains a viewport on
@ -535,7 +527,7 @@ public class History extends JPanel {
}
if ((identifier & ICON) == ICON) {
int iconSize = Settings.historyIconSize.get();
Icon runIcon = run.getSegment(index).getIcon();
ImageIcon runIcon = run.getSegment(index).getIcon();
if (runIcon != null) {
icon.setIcon(Images.rescale(runIcon, iconSize));
} else {

View file

@ -13,7 +13,7 @@ public class Images {
public Images() {
}
public static Icon rescale(Icon icon, int size) {
public static ImageIcon rescale(ImageIcon icon, int size) {
if(icon == null) {
throw new NullPointerException("Icon is null");
} else if(size <= 0) {