Browse Source

Move resources to class.

Mikael Capelle 3 years ago
parent
commit
3e93445e38

+ 69
- 68
.classpath View File

@@ -1,68 +1,69 @@
1
-<?xml version="1.0" encoding="UTF-8"?>
2
-<classpath>
3
-	<classpathentry kind="src" output="target/classes" path="src/main">
4
-		<attributes>
5
-			<attribute name="optional" value="true"/>
6
-			<attribute name="maven.pomderived" value="true"/>
7
-		</attributes>
8
-	</classpathentry>
9
-	<classpathentry kind="src" output="target/test-classes" path="src/test">
10
-		<attributes>
11
-			<attribute name="optional" value="true"/>
12
-			<attribute name="maven.pomderived" value="true"/>
13
-		</attributes>
14
-	</classpathentry>
15
-	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
16
-		<attributes>
17
-			<attribute name="maven.pomderived" value="true"/>
18
-		</attributes>
19
-	</classpathentry>
20
-	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
21
-		<attributes>
22
-			<attribute name="maven.pomderived" value="true"/>
23
-		</attributes>
24
-	</classpathentry>
25
-	<classpathentry kind="lib" path="libs/kxml2-2.3.0.jar"/>
26
-	<classpathentry kind="lib" path="libs/mapsforge-core-0.9.1.jar">
27
-		<attributes>
28
-			<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-core-0.9.1-javadoc.jar!/"/>
29
-		</attributes>
30
-	</classpathentry>
31
-	<classpathentry kind="lib" path="libs/mapsforge-map-0.9.1.jar">
32
-		<attributes>
33
-			<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-map-0.9.1-javadoc.jar!/"/>
34
-		</attributes>
35
-	</classpathentry>
36
-	<classpathentry kind="lib" path="libs/mapsforge-map-awt-0.9.1.jar">
37
-		<attributes>
38
-			<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-map-awt-0.9.1-javadoc.jar!/"/>
39
-		</attributes>
40
-	</classpathentry>
41
-	<classpathentry kind="lib" path="libs/mapsforge-map-reader-0.9.1.jar">
42
-		<attributes>
43
-			<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-map-reader-0.9.1-javadoc.jar!/"/>
44
-		</attributes>
45
-	</classpathentry>
46
-	<classpathentry kind="lib" path="libs/mapsforge-poi-0.9.1.jar">
47
-		<attributes>
48
-			<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-poi-0.9.1-javadoc.jar!/"/>
49
-		</attributes>
50
-	</classpathentry>
51
-	<classpathentry kind="lib" path="libs/mapsforge-poi-awt-0.9.1.jar">
52
-		<attributes>
53
-			<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-poi-awt-0.9.1-javadoc.jar!/"/>
54
-		</attributes>
55
-	</classpathentry>
56
-	<classpathentry kind="lib" path="libs/mapsforge-themes-0.9.1.jar">
57
-		<attributes>
58
-			<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-themes-0.9.1-javadoc.jar!/"/>
59
-		</attributes>
60
-	</classpathentry>
61
-	<classpathentry kind="lib" path="libs/svg-salamander-1.0.jar">
62
-		<attributes>
63
-			<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/svg-salamander-1.0-javadoc.jar!/"/>
64
-		</attributes>
65
-	</classpathentry>
66
-	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
67
-	<classpathentry kind="output" path="target/classes"/>
68
-</classpath>
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<classpath>
3
+	<classpathentry kind="src" output="target/classes" path="src/main">
4
+		<attributes>
5
+			<attribute name="optional" value="true"/>
6
+			<attribute name="maven.pomderived" value="true"/>
7
+		</attributes>
8
+	</classpathentry>
9
+	<classpathentry kind="src" output="target/test-classes" path="src/test">
10
+		<attributes>
11
+			<attribute name="optional" value="true"/>
12
+			<attribute name="maven.pomderived" value="true"/>
13
+		</attributes>
14
+	</classpathentry>
15
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
16
+		<attributes>
17
+			<attribute name="maven.pomderived" value="true"/>
18
+		</attributes>
19
+	</classpathentry>
20
+	<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
21
+		<attributes>
22
+			<attribute name="maven.pomderived" value="true"/>
23
+		</attributes>
24
+	</classpathentry>
25
+	<classpathentry kind="lib" path="libs/kxml2-2.3.0.jar"/>
26
+	<classpathentry kind="lib" path="libs/mapsforge-core-0.9.1.jar">
27
+		<attributes>
28
+			<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-core-0.9.1-javadoc.jar!/"/>
29
+		</attributes>
30
+	</classpathentry>
31
+	<classpathentry kind="lib" path="libs/mapsforge-map-0.9.1.jar">
32
+		<attributes>
33
+			<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-map-0.9.1-javadoc.jar!/"/>
34
+		</attributes>
35
+	</classpathentry>
36
+	<classpathentry kind="lib" path="libs/mapsforge-map-awt-0.9.1.jar">
37
+		<attributes>
38
+			<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-map-awt-0.9.1-javadoc.jar!/"/>
39
+		</attributes>
40
+	</classpathentry>
41
+	<classpathentry kind="lib" path="libs/mapsforge-map-reader-0.9.1.jar">
42
+		<attributes>
43
+			<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-map-reader-0.9.1-javadoc.jar!/"/>
44
+		</attributes>
45
+	</classpathentry>
46
+	<classpathentry kind="lib" path="libs/mapsforge-poi-0.9.1.jar">
47
+		<attributes>
48
+			<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-poi-0.9.1-javadoc.jar!/"/>
49
+		</attributes>
50
+	</classpathentry>
51
+	<classpathentry kind="lib" path="libs/mapsforge-poi-awt-0.9.1.jar">
52
+		<attributes>
53
+			<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-poi-awt-0.9.1-javadoc.jar!/"/>
54
+		</attributes>
55
+	</classpathentry>
56
+	<classpathentry kind="lib" path="libs/mapsforge-themes-0.9.1.jar">
57
+		<attributes>
58
+			<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-themes-0.9.1-javadoc.jar!/"/>
59
+		</attributes>
60
+	</classpathentry>
61
+	<classpathentry kind="lib" path="libs/svg-salamander-1.0.jar">
62
+		<attributes>
63
+			<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/svg-salamander-1.0-javadoc.jar!/"/>
64
+		</attributes>
65
+	</classpathentry>
66
+	<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
67
+	<classpathentry kind="lib" path="res"/>
68
+	<classpathentry kind="output" path="target/classes"/>
69
+</classpath>

+ 15
- 8
src/main/org/insa/graphics/PathsPanel.java View File

@@ -15,6 +15,7 @@ import java.io.File;
15 15
 import java.io.FileOutputStream;
16 16
 import java.io.IOException;
17 17
 
18
+import javax.imageio.ImageIO;
18 19
 import javax.swing.BorderFactory;
19 20
 import javax.swing.Box;
20 21
 import javax.swing.BoxLayout;
@@ -105,8 +106,10 @@ public class PathsPanel extends JPanel implements DrawingChangeListener, GraphCh
105 106
          * 
106 107
          * @param path Path for this bundle, must not be null.
107 108
          * 
109
+         * @throws IOException If a resource was not found.
110
+         * 
108 111
          */
109
-        public PathPanel(Path path) {
112
+        public PathPanel(Path path) throws IOException {
110 113
             super();
111 114
             setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
112 115
             setBorder(BorderFactory.createCompoundBorder(
@@ -241,8 +244,8 @@ public class PathsPanel extends JPanel implements DrawingChangeListener, GraphCh
241 244
                 }
242 245
             });
243 246
 
244
-            Image newimg = new ImageIcon("res/cross_mark.png").getImage().getScaledInstance(14, 14,
245
-                    java.awt.Image.SCALE_SMOOTH);
247
+            Image newimg = ImageIO.read(getClass().getResourceAsStream("/cross_mark.png"))
248
+                    .getScaledInstance(14, 14, java.awt.Image.SCALE_SMOOTH);
246 249
             JButton deleteButton = new JButton(new ImageIcon(newimg));
247 250
             deleteButton.setFocusPainted(false);
248 251
             deleteButton.setFocusable(false);
@@ -283,7 +286,6 @@ public class PathsPanel extends JPanel implements DrawingChangeListener, GraphCh
283 286
 
284 287
         /*
285 288
          * (non-Javadoc)
286
-         * 
287 289
          * @see java.lang.Object#toString()
288 290
          */
289 291
         public String toString() {
@@ -307,10 +309,15 @@ public class PathsPanel extends JPanel implements DrawingChangeListener, GraphCh
307 309
     }
308 310
 
309 311
     public void addPath(Path path) {
310
-        this.add(new PathPanel(path));
311
-        this.setVisible(true);
312
-        this.revalidate();
313
-        this.repaint();
312
+        try {
313
+            this.add(new PathPanel(path));
314
+            this.setVisible(true);
315
+            this.revalidate();
316
+            this.repaint();
317
+        }
318
+        catch (Exception e) {
319
+            e.printStackTrace();
320
+        }
314 321
     }
315 322
 
316 323
     protected void removePath(PathPanel panel) {

+ 4
- 5
src/main/org/insa/graphics/drawing/components/MapZoomControls.java View File

@@ -13,7 +13,6 @@ import java.awt.event.ActionListener;
13 13
 import java.awt.event.MouseAdapter;
14 14
 import java.awt.event.MouseEvent;
15 15
 import java.awt.image.ImageObserver;
16
-import java.io.File;
17 16
 import java.io.IOException;
18 17
 import java.util.ArrayList;
19 18
 import java.util.List;
@@ -65,10 +64,10 @@ public class MapZoomControls {
65 64
     public MapZoomControls(Component component, final int defaultZoom, final int minZoom,
66 65
             final int maxZoom) throws IOException {
67 66
 
68
-        zoomIn = ImageIO.read(new File("res/zoomIn.png")).getScaledInstance(DEFAULT_HEIGHT,
69
-                DEFAULT_HEIGHT, Image.SCALE_SMOOTH);
70
-        zoomOut = ImageIO.read(new File("res/zoomOut.png")).getScaledInstance(DEFAULT_HEIGHT,
71
-                DEFAULT_HEIGHT, Image.SCALE_SMOOTH);
67
+        zoomIn = ImageIO.read(getClass().getResourceAsStream("/zoomIn.png"))
68
+                .getScaledInstance(DEFAULT_HEIGHT, DEFAULT_HEIGHT, Image.SCALE_SMOOTH);
69
+        zoomOut = ImageIO.read(getClass().getResourceAsStream("/zoomOut.png"))
70
+                .getScaledInstance(DEFAULT_HEIGHT, DEFAULT_HEIGHT, Image.SCALE_SMOOTH);
72 71
 
73 72
         this.currentLevel = defaultZoom;
74 73
         this.minLevel = minZoom;

+ 2
- 4
src/main/org/insa/graphics/drawing/overlays/MarkerUtils.java View File

@@ -4,12 +4,9 @@ import java.awt.Color;
4 4
 import java.awt.Image;
5 5
 import java.awt.image.BufferedImage;
6 6
 import java.io.DataInputStream;
7
-import java.io.FileInputStream;
8 7
 
9 8
 public class MarkerUtils {
10 9
 
11
-    private static final String MARKER_MASK_FILE = "res/marker_mask.bin";
12
-
13 10
     /**
14 11
      * Create an Image representing a marker of the given color.
15 12
      * 
@@ -44,7 +41,8 @@ public class MarkerUtils {
44 41
     private static int[][] readMarkerMask() {
45 42
         if (MASK_CACHE == null) {
46 43
             try {
47
-                DataInputStream dis = new DataInputStream(new FileInputStream(MARKER_MASK_FILE));
44
+                DataInputStream dis = new DataInputStream(
45
+                        MarkerUtils.class.getResourceAsStream("/marker_mask.bin"));
48 46
 
49 47
                 int nrows = dis.readInt();
50 48
                 int ncols = dis.readInt();

Loading…
Cancel
Save