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); Segment segment = getSegment(row);
switch (column) { switch (column) {
case COLUMN_ICON: case COLUMN_ICON:
segment.setIcon((Icon) value); segment.setIcon((ImageIcon) value);
tmSupport.fireTableCellUpdated(row, column); tmSupport.fireTableCellUpdated(row, column);
break; 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 * Icon associated with this segment. Can be {@code null} if no icon is to
* be displayed. * be displayed.
*/ */
private Icon icon; private ImageIcon icon;
/** /**
* Registered time for this segment during the best run. * 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}. * @return the icon of the segment or {@code null}.
*/ */
public Icon getIcon() { public ImageIcon getIcon() {
return icon; return icon;
} }
@ -240,7 +240,7 @@ public class Segment implements Cloneable, Serializable {
* *
* @param icon - the new icon for this segment. * @param icon - the new icon for this segment.
*/ */
public void setIcon(Icon icon) { public void setIcon(ImageIcon icon) {
if (icon == null) { if (icon == null) {
this.icon = null; this.icon = null;
} else { } else {

View file

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

View file

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

View file

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