Move resources to class.

This commit is contained in:
Mikael Capelle 2018-03-12 17:32:44 +01:00
parent 17da90c32c
commit 3e93445e38
4 changed files with 90 additions and 85 deletions

View File

@ -1,68 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/kxml2-2.3.0.jar"/>
<classpathentry kind="lib" path="libs/mapsforge-core-0.9.1.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-core-0.9.1-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/mapsforge-map-0.9.1.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-map-0.9.1-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/mapsforge-map-awt-0.9.1.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-map-awt-0.9.1-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/mapsforge-map-reader-0.9.1.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-map-reader-0.9.1-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/mapsforge-poi-0.9.1.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-poi-0.9.1-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/mapsforge-poi-awt-0.9.1.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-poi-awt-0.9.1-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/mapsforge-themes-0.9.1.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-themes-0.9.1-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/svg-salamander-1.0.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/svg-salamander-1.0-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/kxml2-2.3.0.jar"/>
<classpathentry kind="lib" path="libs/mapsforge-core-0.9.1.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-core-0.9.1-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/mapsforge-map-0.9.1.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-map-0.9.1-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/mapsforge-map-awt-0.9.1.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-map-awt-0.9.1-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/mapsforge-map-reader-0.9.1.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-map-reader-0.9.1-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/mapsforge-poi-0.9.1.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-poi-0.9.1-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/mapsforge-poi-awt-0.9.1.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-poi-awt-0.9.1-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/mapsforge-themes-0.9.1.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/mapsforge-themes-0.9.1-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="libs/svg-salamander-1.0.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/be-graphes-reloaded/libs/svg-salamander-1.0-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
<classpathentry kind="lib" path="res"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -15,6 +15,7 @@ import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.BoxLayout;
@ -105,8 +106,10 @@ public class PathsPanel extends JPanel implements DrawingChangeListener, GraphCh
*
* @param path Path for this bundle, must not be null.
*
* @throws IOException If a resource was not found.
*
*/
public PathPanel(Path path) {
public PathPanel(Path path) throws IOException {
super();
setLayout(new BoxLayout(this, BoxLayout.LINE_AXIS));
setBorder(BorderFactory.createCompoundBorder(
@ -241,8 +244,8 @@ public class PathsPanel extends JPanel implements DrawingChangeListener, GraphCh
}
});
Image newimg = new ImageIcon("res/cross_mark.png").getImage().getScaledInstance(14, 14,
java.awt.Image.SCALE_SMOOTH);
Image newimg = ImageIO.read(getClass().getResourceAsStream("/cross_mark.png"))
.getScaledInstance(14, 14, java.awt.Image.SCALE_SMOOTH);
JButton deleteButton = new JButton(new ImageIcon(newimg));
deleteButton.setFocusPainted(false);
deleteButton.setFocusable(false);
@ -283,7 +286,6 @@ public class PathsPanel extends JPanel implements DrawingChangeListener, GraphCh
/*
* (non-Javadoc)
*
* @see java.lang.Object#toString()
*/
public String toString() {
@ -307,10 +309,15 @@ public class PathsPanel extends JPanel implements DrawingChangeListener, GraphCh
}
public void addPath(Path path) {
this.add(new PathPanel(path));
this.setVisible(true);
this.revalidate();
this.repaint();
try {
this.add(new PathPanel(path));
this.setVisible(true);
this.revalidate();
this.repaint();
}
catch (Exception e) {
e.printStackTrace();
}
}
protected void removePath(PathPanel panel) {

View File

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

View File

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