Index: applications/viewer/jmapviewer/.classpath
===================================================================
--- applications/viewer/jmapviewer/.classpath	(revision 9618)
+++ applications/viewer/jmapviewer/.classpath	(revision 9618)
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>
Index: applications/viewer/jmapviewer/.project
===================================================================
--- applications/viewer/jmapviewer/.project	(revision 9618)
+++ applications/viewer/jmapviewer/.project	(revision 9618)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>OSM</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>
Index: applications/viewer/jmapviewer/.settings/org.eclipse.core.resources.prefs
===================================================================
--- applications/viewer/jmapviewer/.settings/org.eclipse.core.resources.prefs	(revision 9618)
+++ applications/viewer/jmapviewer/.settings/org.eclipse.core.resources.prefs	(revision 9618)
@@ -0,0 +1,3 @@
+#Wed Jul 16 10:49:16 CEST 2008
+eclipse.preferences.version=1
+encoding/<project>=UTF-8
Index: applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Demo.java
===================================================================
--- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Demo.java	(revision 9603)
+++ applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Demo.java	(revision 9618)
@@ -13,5 +13,4 @@
 import javax.swing.JPanel;
 
-
 /**
  * 
@@ -23,10 +22,13 @@
 public class Demo extends JFrame {
 
+	private static final long serialVersionUID = 1L;
+
 	public Demo() {
 		super("JMapViewer Demo");
 		setSize(400, 400);
 		final JMapViewer map = new JMapViewer();
-//		final JMapViewer map = new JMapViewer(new MemoryTileCache(),4);
-//		map.setTileLoader(new OsmFileCacheTileLoader(map,OsmTileLoader.MAP_MAPNIK));
+		// final JMapViewer map = new JMapViewer(new MemoryTileCache(),4);
+		// map.setTileLoader(new
+		// OsmFileCacheTileLoader(map,OsmTileLoader.MAP_MAPNIK));
 		new DefaultMapController(map);
 		setLayout(new BorderLayout());
@@ -35,7 +37,6 @@
 		JPanel panel = new JPanel();
 		add(panel, BorderLayout.NORTH);
-		JLabel label =
-				new JLabel(
-						"Use right mouse button to move,\n left double click or mouse wheel to zoom.");
+		JLabel label = new JLabel(
+				"Use right mouse button to move,\n left double click or mouse wheel to zoom.");
 		panel.add(label);
 		JButton button = new JButton("setDisplayToFitMapMarkers");
@@ -83,6 +84,6 @@
 		map.addMapMarker(new MapMarkerDot(49.807, 8.644));
 
-		//map.setDisplayPositionByLatLon(49.807, 8.6, 11);
-		//map.setTileGridVisible(true);
+		// map.setDisplayPositionByLatLon(49.807, 8.6, 11);
+		// map.setTileGridVisible(true);
 	}
 
@@ -91,7 +92,7 @@
 	 */
 	public static void main(String[] args) {
-//		Properties systemProperties = System.getProperties();
-//		systemProperties.setProperty("http.proxyHost","localhost");
-//		systemProperties.setProperty("http.proxyPort","8008");
+		// Properties systemProperties = System.getProperties();
+		// systemProperties.setProperty("http.proxyHost","localhost");
+		// systemProperties.setProperty("http.proxyPort","8008");
 		new Demo().setVisible(true);
 	}
Index: applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmFileCacheTileLoader.java
===================================================================
--- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmFileCacheTileLoader.java	(revision 9603)
+++ applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmFileCacheTileLoader.java	(revision 9618)
@@ -13,6 +13,4 @@
 import java.net.URL;
 import java.net.URLConnection;
-
-import javax.imageio.ImageIO;
 
 import org.openstreetmap.gui.jmapviewer.interfaces.TileCache;
@@ -90,5 +88,5 @@
 					f = getTileFile(tile);
 					fin = new FileInputStream(f);
-					tile.setImage(ImageIO.read(fin));
+					tile.loadImage(fin);
 					fin.close();
 					fileAge = f.lastModified();
@@ -129,5 +127,5 @@
 				// }
 				byte[] buffer = loadTileInBuffer(urlConn);
-				tile.setImage(ImageIO.read(new ByteArrayInputStream(buffer)));
+				tile.loadImage(new ByteArrayInputStream(buffer));
 				tile.setLoaded(true);
 				map.repaint();
@@ -136,6 +134,6 @@
 			} catch (Exception e) {
 				if (input == null /* || !input.isStopped() */)
-					System.err.println("failed loading " + zoom + "/" + tilex + "/" + tiley + " "
-							+ e.getMessage());
+					System.err.println("failed loading " + zoom + "/" + tilex
+							+ "/" + tiley + " " + e.getMessage());
 			} finally {
 				tile.loading = false;
@@ -143,7 +141,9 @@
 		}
 
-		protected byte[] loadTileInBuffer(URLConnection urlConn) throws IOException {
+		protected byte[] loadTileInBuffer(URLConnection urlConn)
+				throws IOException {
 			input = urlConn.getInputStream();
-			ByteArrayOutputStream bout = new ByteArrayOutputStream(input.available());
+			ByteArrayOutputStream bout = new ByteArrayOutputStream(input
+					.available());
 			byte[] buffer = new byte[2048];
 			boolean finished = false;
@@ -175,8 +175,10 @@
 		 * @throws IOException
 		 */
-		protected boolean isOsmTileNewer(Tile tile, long fileAge) throws IOException {
+		protected boolean isOsmTileNewer(Tile tile, long fileAge)
+				throws IOException {
 			URL url;
 			url = new URL(baseUrl + "/" + tile.getKey() + ".png");
-			HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
+			HttpURLConnection urlConn = (HttpURLConnection) url
+					.openConnection();
 			urlConn.setRequestMethod("HEAD");
 			urlConn.setReadTimeout(30000); // 30 seconds read
@@ -191,18 +193,19 @@
 
 		protected File getTileFile(Tile tile) throws IOException {
-			return new File(tileCacheDir + "/" + tile.getZoom() + "_" + tile.getXtile() + "_"
-					+ tile.getYtile() + FILE_EXT);
+			return new File(tileCacheDir + "/" + tile.getZoom() + "_"
+					+ tile.getXtile() + "_" + tile.getYtile() + FILE_EXT);
 		}
 
 		protected void saveTileToFile(Tile tile, byte[] rawData) {
 			try {
-				FileOutputStream f =
-						new FileOutputStream(tileCacheDir + "/" + tile.getZoom() + "_"
-								+ tile.getXtile() + "_" + tile.getYtile() + FILE_EXT);
+				FileOutputStream f = new FileOutputStream(tileCacheDir + "/"
+						+ tile.getZoom() + "_" + tile.getXtile() + "_"
+						+ tile.getYtile() + FILE_EXT);
 				f.write(rawData);
 				f.close();
 				// System.out.println("Saved tile to file: " + tile);
 			} catch (Exception e) {
-				System.err.println("Failed to save tile content: " + e.getLocalizedMessage());
+				System.err.println("Failed to save tile content: "
+						+ e.getLocalizedMessage());
 			}
 		}
@@ -230,7 +233,8 @@
 
 	public void setTileCacheDir(String tileCacheDir) {
-		this.tileCacheDir = tileCacheDir;
-	}
-
-	
+		File dir = new File(tileCacheDir);
+		dir.mkdirs();
+		this.tileCacheDir = dir.getAbsolutePath();
+	}
+
 }
Index: applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java
===================================================================
--- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java	(revision 9603)
+++ applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java	(revision 9618)
@@ -7,6 +7,4 @@
 import java.net.HttpURLConnection;
 import java.net.URL;
-
-import javax.imageio.ImageIO;
 
 import org.openstreetmap.gui.jmapviewer.interfaces.Job;
@@ -54,5 +52,5 @@
 					// Thread.sleep(500);
 					input = loadTileFromOsm(tile).getInputStream();
-					tile.setImage(ImageIO.read(input));
+					tile.loadImage(input);
 					tile.setLoaded(true);
 					map.repaint();
@@ -61,6 +59,6 @@
 				} catch (Exception e) {
 					if (input == null /* || !input.isStopped() */)
-						System.err.println("failed loading " + zoom + "/" + tilex + "/" + tiley
-								+ " " + e.getMessage());
+						System.err.println("failed loading " + zoom + "/"
+								+ tilex + "/" + tiley + " " + e.getMessage());
 				} finally {
 					tile.loading = false;
Index: applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Tile.java
===================================================================
--- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Tile.java	(revision 9603)
+++ applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/Tile.java	(revision 9618)
@@ -7,4 +7,8 @@
 import java.awt.geom.AffineTransform;
 import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.io.InputStream;
+
+import javax.imageio.ImageIO;
 
 import org.openstreetmap.gui.jmapviewer.interfaces.TileCache;
@@ -55,5 +59,6 @@
 	 */
 	public void loadPlaceholderFromCache(TileCache cache) {
-		BufferedImage tmpImage = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);
+		BufferedImage tmpImage = new BufferedImage(WIDTH, HEIGHT,
+				BufferedImage.TYPE_INT_RGB);
 		Graphics2D g = (Graphics2D) tmpImage.getGraphics();
 		// g.drawImage(image, 0, 0, null);
@@ -71,5 +76,6 @@
 				for (int x = 0; x < factor; x++) {
 					for (int y = 0; y < factor; y++) {
-						Tile tile = cache.getTile(xtile_high + x, ytile_high + y, zoom_high);
+						Tile tile = cache.getTile(xtile_high + x, ytile_high
+								+ y, zoom_high);
 						if (tile != null && tile.isLoaded()) {
 							paintedTileCount++;
@@ -134,4 +140,8 @@
 	}
 
+	public void loadImage(InputStream input) throws IOException {
+		image = ImageIO.read(input);
+	}
+
 	/**
 	 * @return key that identifies a tile
@@ -175,5 +185,6 @@
 			return false;
 		Tile tile = (Tile) obj;
-		return (xtile == tile.xtile) && (ytile == tile.ytile) && (zoom == tile.zoom);
+		return (xtile == tile.xtile) && (ytile == tile.ytile)
+				&& (zoom == tile.zoom);
 	}
 
