Browse Source

Ship images

master
Chris Smith 15 years ago
parent
commit
e34d030718
1 changed files with 35 additions and 0 deletions
  1. 35
    0
      src/uk/co/md87/evetool/ui/data/BasicShipInfoSurrogate.java

+ 35
- 0
src/uk/co/md87/evetool/ui/data/BasicShipInfoSurrogate.java View File

22
 
22
 
23
 package uk.co.md87.evetool.ui.data;
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
 import uk.co.md87.evetool.api.wrappers.CharacterSheet;
34
 import uk.co.md87.evetool.api.wrappers.CharacterSheet;
26
 import uk.co.md87.evetool.api.wrappers.data.BasicShipInfo;
35
 import uk.co.md87.evetool.api.wrappers.data.BasicShipInfo;
27
 import uk.co.md87.evetool.ui.listable.ListableImpl;
36
 import uk.co.md87.evetool.ui.listable.ListableImpl;
40
     public BasicShipInfoSurrogate(final BasicShipInfo info, final CharacterSheet sheet) {
49
     public BasicShipInfoSurrogate(final BasicShipInfo info, final CharacterSheet sheet) {
41
         this.info = info;
50
         this.info = info;
42
         this.sheet = sheet;
51
         this.sheet = sheet;
52
+
53
+        new ImageWorker().execute();
43
     }
54
     }
44
 
55
 
45
     @Retrievable(deferred=true)
56
     @Retrievable(deferred=true)
52
         return sheet.hasSkills(info.getRequirements());
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
 }

Loading…
Cancel
Save