diff --git a/docs/Changelog.md b/docs/Changelog.md index 9259183e..73f3ae51 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -2,6 +2,7 @@ ## New since 0.8.0 +- vtm-theme-comparator module [#387](https://github.com/mapsforge/vtm/issues/387) - Many other minor improvements and bug fixes - [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.9.0) diff --git a/vtm-theme-comparator/build.gradle b/vtm-theme-comparator/build.gradle index 10f42092..027ce49c 100644 --- a/vtm-theme-comparator/build.gradle +++ b/vtm-theme-comparator/build.gradle @@ -2,28 +2,16 @@ apply plugin: 'java' dependencies { compile project(':vtm-desktop') - compile project(':vtm-extras') - compile project(':vtm-http') - compile project(':vtm-json') - compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.3' - - - compile group: 'com.jtattoo', name: 'JTattoo', version: '1.6.11' - compile group: 'com.fifesoft', name: 'rsyntaxtextarea', version: '2.6.1' - + compile 'ch.qos.logback:logback-classic:1.2.3' + compile 'com.fifesoft:rsyntaxtextarea:2.6.1' + compile 'com.jtattoo:JTattoo:1.6.11' compile 'org.mapsforge:mapsforge-core:0.8.0' - compile 'org.mapsforge:mapsforge-themes:0.8.0' compile 'org.mapsforge:mapsforge-map:0.8.0' - compile 'org.mapsforge:mapsforge-map-reader:0.8.0' compile("org.mapsforge:mapsforge-map-awt:0.8.0") - compile 'com.kitfox.svg:svg-salamander:1.0' + compile 'org.mapsforge:mapsforge-map-reader:0.8.0' + compile 'org.mapsforge:mapsforge-themes:0.8.0' compile 'net.sf.kxml:kxml2:2.3.0' - - //include libs - compile fileTree(dir: 'libs', include: ['*.jar']) - - } sourceSets { diff --git a/vtm-theme-comparator/src/org/oscim/theme/comparator/Main.java b/vtm-theme-comparator/src/org/oscim/theme/comparator/Main.java index 89270033..7f0843bb 100644 --- a/vtm-theme-comparator/src/org/oscim/theme/comparator/Main.java +++ b/vtm-theme-comparator/src/org/oscim/theme/comparator/Main.java @@ -1,5 +1,6 @@ /* * Copyright 2017 Longri + * Copyright 2017 devemux86 * * This program is free software: you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free Software @@ -85,7 +86,7 @@ public class Main { new SharedLibraryLoader().load("vtm-jni"); AwtGraphics.init(); - GdxAssets.init(""); + GdxAssets.init("assets/"); GLAdapter.init(new LwjglGL20()); GLAdapter.GDX_DESKTOP_QUIRKS = true; window = new MainWindow(); diff --git a/vtm-theme-comparator/src/org/oscim/theme/comparator/MainWindow.java b/vtm-theme-comparator/src/org/oscim/theme/comparator/MainWindow.java index 0408437b..e4eab5fd 100644 --- a/vtm-theme-comparator/src/org/oscim/theme/comparator/MainWindow.java +++ b/vtm-theme-comparator/src/org/oscim/theme/comparator/MainWindow.java @@ -1,5 +1,6 @@ /* * Copyright 2017 Longri + * Copyright 2017 devemux86 * * This program is free software: you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free Software @@ -22,9 +23,12 @@ import org.oscim.theme.comparator.vtm.VtmPanel; import java.awt.BorderLayout; import java.awt.Dimension; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import javax.swing.JFrame; import javax.swing.JSplitPane; +import javax.swing.WindowConstants; class MainWindow extends JFrame { @@ -78,6 +82,16 @@ class MainWindow extends JFrame { splitPane.setResizeWeight(0.5); this.add(splitPane); + + addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + mapsforgeMapPanel.destroy(); + setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + dispose(); + System.exit(0); + } + }); } } diff --git a/vtm-theme-comparator/src/org/oscim/theme/comparator/mapsforge/MapsforgeMapPanel.java b/vtm-theme-comparator/src/org/oscim/theme/comparator/mapsforge/MapsforgeMapPanel.java index a651cc83..18bd113e 100644 --- a/vtm-theme-comparator/src/org/oscim/theme/comparator/mapsforge/MapsforgeMapPanel.java +++ b/vtm-theme-comparator/src/org/oscim/theme/comparator/mapsforge/MapsforgeMapPanel.java @@ -1,5 +1,6 @@ /* * Copyright 2017 Longri + * Copyright 2017 devemux86 * * This program is free software: you can redistribute it and/or modify it under the * terms of the GNU Lesser General Public License as published by the Free Software @@ -43,6 +44,7 @@ import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; import java.io.File; import java.io.FileNotFoundException; +import java.util.UUID; import java.util.prefs.Preferences; import javax.swing.BorderFactory; @@ -92,7 +94,7 @@ public class MapsforgeMapPanel extends JPanel { private Layer createTileRendererLayer(TileCache tileCache, MapViewPosition mapViewPosition, File mapFile, File themeFile) { - TileRendererLayer tileRendererLayer = new TileRendererLayer(tileCache, new MapFile(mapFile), mapViewPosition, false, true, true, GRAPHIC_FACTORY); + TileRendererLayer tileRendererLayer = new TileRendererLayer(tileCache, new MapFile(mapFile), mapViewPosition, false, true, false, GRAPHIC_FACTORY); if (themeFile != null) { @@ -120,11 +122,16 @@ public class MapsforgeMapPanel extends JPanel { private TileCache createTileCache() { TileCache firstLevelTileCache = new InMemoryTileCache(64); - File cacheDirectory = new File(System.getProperty("java.io.tmpdir"), "mapsforge"); + File cacheDirectory = new File(System.getProperty("java.io.tmpdir"), UUID.randomUUID().toString()); TileCache secondLevelTileCache = new FileSystemTileCache(1024, cacheDirectory, GRAPHIC_FACTORY); return new TwoLevelTileCache(firstLevelTileCache, secondLevelTileCache); } + public void destroy() { + mapView.destroyAll(); + AwtGraphicFactory.clearResourceMemoryCache(); + } + public void loadMap(File mapFile, File themeFile) { log.debug("reload MAP:{} THEME:{}", mapFile, themeFile); this.mapFile = mapFile;