|
@@ -22,6 +22,15 @@
|
22
|
22
|
|
23
|
23
|
package uk.co.md87.evetool.ui.data;
|
24
|
24
|
|
|
25
|
+import java.awt.Image;
|
|
26
|
+import java.io.IOException;
|
|
27
|
+import java.net.URL;
|
|
28
|
+import java.util.concurrent.ExecutionException;
|
|
29
|
+import java.util.logging.Level;
|
|
30
|
+import java.util.logging.Logger;
|
|
31
|
+import javax.imageio.ImageIO;
|
|
32
|
+import javax.swing.ImageIcon;
|
|
33
|
+import javax.swing.SwingWorker;
|
25
|
34
|
import uk.co.md87.evetool.api.wrappers.CharacterSheet;
|
26
|
35
|
import uk.co.md87.evetool.api.wrappers.data.BasicShipInfo;
|
27
|
36
|
import uk.co.md87.evetool.ui.listable.ListableImpl;
|
|
@@ -40,6 +49,8 @@ public class BasicShipInfoSurrogate extends ListableImpl {
|
40
|
49
|
public BasicShipInfoSurrogate(final BasicShipInfo info, final CharacterSheet sheet) {
|
41
|
50
|
this.info = info;
|
42
|
51
|
this.sheet = sheet;
|
|
52
|
+
|
|
53
|
+ new ImageWorker().execute();
|
43
|
54
|
}
|
44
|
55
|
|
45
|
56
|
@Retrievable(deferred=true)
|
|
@@ -52,4 +63,28 @@ public class BasicShipInfoSurrogate extends ListableImpl {
|
52
|
63
|
return sheet.hasSkills(info.getRequirements());
|
53
|
64
|
}
|
54
|
65
|
|
|
66
|
+ private class ImageWorker extends SwingWorker<Image,Void> {
|
|
67
|
+
|
|
68
|
+ @Override
|
|
69
|
+ protected Image doInBackground() throws Exception {
|
|
70
|
+ return ImageIO.read(
|
|
71
|
+ new URL("http://evetool.md87.co.uk/api/dx9/types/shiptypes_png/64_64/"
|
|
72
|
+ + info.getID() + ".png")).getScaledInstance(48, 48, Image.SCALE_SMOOTH);
|
|
73
|
+ }
|
|
74
|
+
|
|
75
|
+ @Override
|
|
76
|
+ protected void done() {
|
|
77
|
+ try {
|
|
78
|
+ updateImage(new ImageIcon(get()));
|
|
79
|
+ } catch (InterruptedException ex) {
|
|
80
|
+ Logger.getLogger(BasicShipInfoSurrogate.class.getName())
|
|
81
|
+ .log(Level.SEVERE, null, ex);
|
|
82
|
+ } catch (ExecutionException ex) {
|
|
83
|
+ Logger.getLogger(BasicShipInfoSurrogate.class.getName())
|
|
84
|
+ .log(Level.SEVERE, null, ex);
|
|
85
|
+ }
|
|
86
|
+ }
|
|
87
|
+
|
|
88
|
+ }
|
|
89
|
+
|
55
|
90
|
}
|