extract theme assets to vtm-themes project

This commit is contained in:
Hannes Janetzek 2014-02-23 12:35:44 +01:00
parent ff83629054
commit f193921432
39 changed files with 91 additions and 83 deletions

View File

@ -7,3 +7,4 @@ include ':vtm-gdx-desktop'
include ':vtm-gdx-html' include ':vtm-gdx-html'
include ':vtm-gdx-android' include ':vtm-gdx-android'
include ':vtm-android-app' include ':vtm-android-app'
include ':vtm-themes'

@ -1 +1 @@
Subproject commit da1e3b8aa8c523e5e374d8e7329def769edb3c0a Subproject commit 2fc23ee26b0eb99e13fba3c65177c761f3b6cdf1

View File

@ -10,18 +10,19 @@ buildscript {
apply plugin: 'android' apply plugin: 'android'
dependencies { dependencies {
//compile fileTree(dir: 'libs', include: '*.jar')
compile project(':vtm-android') compile project(':vtm-android')
compile fileTree(dir: 'libs', include: '*.jar') compile project(':vtm-themes')
} }
task copyAssets(type: Copy) { // task copyAssets(type: Copy) {
from "$rootDir/vtm/assets" // from "$rootDir/vtm/assets"
into "assets" // into "assets"
include '**/*' // include '**/*'
} // }
tasks.withType(JavaCompile) { compileTask -> // tasks.withType(JavaCompile) { compileTask ->
compileTask.dependsOn copyAssets } // compileTask.dependsOn copyAssets }
android { android {
compileSdkVersion 19 compileSdkVersion 19
@ -60,12 +61,12 @@ eclipse.classpath {
// Manipulation of the classpath XML before merging local // Manipulation of the classpath XML before merging local
// and generated copies // and generated copies
beforeMerged { classpath -> // beforeMerged { classpath ->
// Remove all source entries to avoid overlap // // Remove all source entries to avoid overlap
classpath.entries.removeAll() { c -> // classpath.entries.removeAll() { c ->
c.kind == 'src' // c.kind == 'src'
} // }
} // }
// Direct manipulation of the generated classpath XML // Direct manipulation of the generated classpath XML
withXml { withXml {
@ -82,14 +83,13 @@ eclipse.classpath {
} }
eclipse.project { eclipse.project {
natures = ['com.android.ide.eclipse.adt.AndroidNature', natures = ['com.android.ide.eclipse.adt.AndroidNature',
'org.eclipse.jdt.core.javanature'] 'org.eclipse.jdt.core.javanature']
buildCommand 'com.android.ide.eclipse.adt.ResourceManagerBuilder' buildCommand 'com.android.ide.eclipse.adt.ResourceManagerBuilder'
buildCommand 'com.android.ide.eclipse.adt.PreCompilerBuilder' buildCommand 'com.android.ide.eclipse.adt.PreCompilerBuilder'
buildCommand 'com.android.ide.eclipse.adt.ApkBuilder' buildCommand 'com.android.ide.eclipse.adt.ApkBuilder'
linkedResource name: 'assets', type: '2', linkedResource name: 'assets', type: '2',
locationUri: 'PARENT-1-PROJECT_LOC/vtm/assets' locationUri: 'PARENT-1-PROJECT_LOC/vtm-themes/resources/assets'
} }

View File

@ -23,7 +23,7 @@ import org.oscim.core.MapPosition;
import org.oscim.core.Tile; import org.oscim.core.Tile;
import org.oscim.layers.tile.vector.VectorTileLayer; import org.oscim.layers.tile.vector.VectorTileLayer;
import org.oscim.layers.tile.vector.labeling.LabelLayer; import org.oscim.layers.tile.vector.labeling.LabelLayer;
import org.oscim.theme.InternalRenderTheme; import org.oscim.theme.VtmThemes;
import org.oscim.tiling.source.mapfile.MapFileTileSource; import org.oscim.tiling.source.mapfile.MapFileTileSource;
import org.oscim.tiling.source.mapfile.MapInfo; import org.oscim.tiling.source.mapfile.MapInfo;
@ -68,17 +68,17 @@ public class MapsforgeMapActivity extends MapActivity {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.theme_default: case R.id.theme_default:
mMap.setTheme(InternalRenderTheme.DEFAULT); mMap.setTheme(VtmThemes.DEFAULT);
item.setChecked(true); item.setChecked(true);
return true; return true;
case R.id.theme_tubes: case R.id.theme_tubes:
mMap.setTheme(InternalRenderTheme.TRONRENDER); mMap.setTheme(VtmThemes.TRONRENDER);
item.setChecked(true); item.setChecked(true);
return true; return true;
case R.id.theme_osmarender: case R.id.theme_osmarender:
mMap.setTheme(InternalRenderTheme.OSMARENDER); mMap.setTheme(VtmThemes.OSMARENDER);
item.setChecked(true); item.setChecked(true);
return true; return true;
} }
@ -100,17 +100,17 @@ public class MapsforgeMapActivity extends MapActivity {
if (mTileSource.setMapFile(file)) { if (mTileSource.setMapFile(file)) {
VectorTileLayer l = mMap.setBaseMap(mTileSource); VectorTileLayer l = mMap.setBaseMap(mTileSource);
mMap.setTheme(InternalRenderTheme.DEFAULT); mMap.setTheme(VtmThemes.DEFAULT);
mMap.layers().add(new LabelLayer(mMap, l)); mMap.layers().add(new LabelLayer(mMap, l));
MapInfo info = mTileSource.getMapInfo(); MapInfo info = mTileSource.getMapInfo();
if (info.boundingBox != null) { if (info.boundingBox != null) {
MapPosition pos = new MapPosition(); MapPosition pos = new MapPosition();
pos.setByBoundingBox(info.boundingBox, pos.setByBoundingBox(info.boundingBox,
Tile.SIZE * 4, Tile.SIZE * 4,
Tile.SIZE * 4); Tile.SIZE * 4);
mMap.setMapPosition(pos); mMap.setMapPosition(pos);
Samples.log.debug("set position {}",pos); Samples.log.debug("set position {}", pos);
} else if (info.mapCenter != null) { } else if (info.mapCenter != null) {
double scale = 1 << 8; double scale = 1 << 8;

View File

@ -18,7 +18,7 @@
import org.oscim.layers.tile.vector.BuildingLayer; import org.oscim.layers.tile.vector.BuildingLayer;
import org.oscim.layers.tile.vector.labeling.LabelLayer; import org.oscim.layers.tile.vector.labeling.LabelLayer;
import org.oscim.map.Layers; import org.oscim.map.Layers;
import org.oscim.theme.InternalRenderTheme; import org.oscim.theme.VtmThemes;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
@ -36,9 +36,10 @@ public class SimpleMapActivity extends BaseMapActivity {
//layers.add(new TileGridLayer(mMap)); //layers.add(new TileGridLayer(mMap));
mMap.setTheme(InternalRenderTheme.DEFAULT); mMap.setTheme(VtmThemes.DEFAULT);
//mMap.setTheme(InternalRenderTheme.TRONRENDER); //mMap.setTheme(VtmThemes.TRONRENDER);
//mMap.setTheme(InternalRenderTheme.OSMARENDER); //mMap.setTheme(VtmThemes.TRON2);
//mMap.setTheme(VtmThemes.OSMARENDER);
mMap.setMapPosition(53.08, 8.83, Math.pow(2, 10)); mMap.setMapPosition(53.08, 8.83, Math.pow(2, 10));
} }
@ -54,17 +55,17 @@ public class SimpleMapActivity extends BaseMapActivity {
switch (item.getItemId()) { switch (item.getItemId()) {
case R.id.theme_default: case R.id.theme_default:
mMap.setTheme(InternalRenderTheme.DEFAULT); mMap.setTheme(VtmThemes.DEFAULT);
item.setChecked(true); item.setChecked(true);
return true; return true;
case R.id.theme_tubes: case R.id.theme_tubes:
mMap.setTheme(InternalRenderTheme.TRONRENDER); mMap.setTheme(VtmThemes.TRONRENDER);
item.setChecked(true); item.setChecked(true);
return true; return true;
case R.id.theme_osmarender: case R.id.theme_osmarender:
mMap.setTheme(InternalRenderTheme.OSMARENDER); mMap.setTheme(VtmThemes.OSMARENDER);
item.setChecked(true); item.setChecked(true);
return true; return true;
} }
@ -77,18 +78,18 @@ public class SimpleMapActivity extends BaseMapActivity {
mMapView.postDelayed(new Runnable() { mMapView.postDelayed(new Runnable() {
@Override @Override
public void run() { public void run() {
InternalRenderTheme t; VtmThemes t;
if (i == 0) if (i == 0)
t = InternalRenderTheme.DEFAULT; t = VtmThemes.DEFAULT;
else if (i == 1) else if (i == 1)
t = InternalRenderTheme.TRONRENDER; t = VtmThemes.TRONRENDER;
else else
t = InternalRenderTheme.OSMARENDER; t = VtmThemes.OSMARENDER;
mMapView.getMap().setTheme(t); mMapView.getMap().setTheme(t);
loooop((i + 1) % 3); loooop((i + 1) % 3);
} }
}, 300 + (int)(Math.random() * 200)); }, 300 + (int) (Math.random() * 200));
} }
} }

@ -1 +1 @@
Subproject commit cc278b239cea8bfc16f1915fb23f5e3ad93b2c7a Subproject commit 416f8e79e2128394575d3b302d5178cb56fd1d25

View File

@ -9,20 +9,25 @@ buildscript {
apply plugin: 'android' apply plugin: 'android'
ext.gdxVersion = "1.0-SNAPSHOT"
dependencies { dependencies {
compile project(':vtm-gdx') compile project(':vtm-gdx')
compile project(':vtm-themes')
compile files('../vtm-ext-libs/gdx/gdx-backend-android.jar') compile files('../vtm-ext-libs/gdx/gdx-backend-android.jar')
compile fileTree(dir: 'libs', include: '*.jar') //natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
//natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
//compile fileTree(dir: 'libs', include: '*.jar')
} }
task copyAssets(type: Copy) { // task copyAssets(type: Copy) {
from "$rootDir/vtm/assets" // from "$rootDir/vtm/assets"
into "assets" // into "assets"
include '**/*' // include '**/*'
} // }
tasks.withType(JavaCompile) { compileTask -> // tasks.withType(JavaCompile) { compileTask ->
compileTask.dependsOn copyAssets } // compileTask.dependsOn copyAssets }
android { android {
compileSdkVersion 19 compileSdkVersion 19
@ -83,14 +88,14 @@ eclipse.classpath {
} }
eclipse.project { eclipse.project {
natures = ['com.android.ide.eclipse.adt.AndroidNature', natures = ['com.android.ide.eclipse.adt.AndroidNature',
'org.eclipse.jdt.core.javanature'] 'org.eclipse.jdt.core.javanature']
buildCommand 'com.android.ide.eclipse.adt.ResourceManagerBuilder' buildCommand 'com.android.ide.eclipse.adt.ResourceManagerBuilder'
buildCommand 'com.android.ide.eclipse.adt.PreCompilerBuilder' buildCommand 'com.android.ide.eclipse.adt.PreCompilerBuilder'
buildCommand 'com.android.ide.eclipse.adt.ApkBuilder' buildCommand 'com.android.ide.eclipse.adt.ApkBuilder'
linkedResource name: 'assets', type: '2', linkedResource name: 'assets', type: '2',
locationUri: 'PARENT-1-PROJECT_LOC/vtm/assets' locationUri: 'PARENT-1-PROJECT_LOC/vtm/assets'
// use extracted jni .so in eclipse // use extracted jni .so in eclipse

View File

@ -5,14 +5,14 @@ apply plugin: 'application'
mainClassName = 'org.oscim.gdx.GdxMapApp' mainClassName = 'org.oscim.gdx.GdxMapApp'
task copyAssets(type: Copy) { // task copyAssets(type: Copy) {
from "$rootDir/vtm/assets" // from "$rootDir/vtm/assets"
into "assets" // into "assets"
include '**/*' // include '**/*'
} // }
tasks.withType(JavaCompile) { compileTask -> // tasks.withType(JavaCompile) { compileTask ->
compileTask.dependsOn copyAssets } // compileTask.dependsOn copyAssets }
sourceSets { sourceSets {
main.java.srcDirs = ['src'] main.java.srcDirs = ['src']
@ -25,15 +25,15 @@ run { ignoreExitValue = true }
dependencies { dependencies {
compile project(':vtm-gdx') compile project(':vtm-gdx')
compile project(':vtm-themes')
compile files('../vtm-ext-libs/gdx/gdx-backend-lwjgl.jar') compile files('../vtm-ext-libs/gdx/gdx-backend-lwjgl.jar')
compile files('../vtm-ext-libs/gdx/gdx-backend-lwjgl-natives.jar') compile files('../vtm-ext-libs/gdx/gdx-backend-lwjgl-natives.jar')
compile files('../vtm-ext-libs/gdx/gdx-natives.jar') compile files('../vtm-ext-libs/gdx/gdx-natives.jar')
compile files('../vtm-ext-libs/gdx/vtm-jni-natives.jar') compile files('../vtm-ext-libs/gdx/vtm-jni-natives.jar')
//compile 'org.slf4j:slf4j-api:1.7.5'
compile 'org.slf4j:slf4j-simple:1.7.5' compile 'org.slf4j:slf4j-simple:1.7.5'
} }
eclipse.project { eclipse.project {
linkedResource name: 'assets', type: '2', linkedResource name: 'assets', type: '2',
locationUri: 'PARENT-1-PROJECT_LOC/vtm/assets' locationUri: 'PARENT-1-PROJECT_LOC/vtm-themes/resources/assets'
} }

View File

@ -8,6 +8,7 @@ sourceSets {
dependencies { dependencies {
compile project(':vtm') compile project(':vtm')
compile project(':vtm-themes')
compile files('../vtm-ext-libs/gdx/gdx.jar') compile files('../vtm-ext-libs/gdx/gdx.jar')
//compile "com.badlogicgames.gdx:gdx:$gdxVersion" //compile "com.badlogicgames.gdx:gdx:$gdxVersion"
} }

View File

@ -27,7 +27,7 @@ import org.oscim.map.Layers;
import org.oscim.map.Map; import org.oscim.map.Map;
import org.oscim.map.ViewController; import org.oscim.map.ViewController;
import org.oscim.renderer.MapRenderer; import org.oscim.renderer.MapRenderer;
import org.oscim.theme.InternalRenderTheme; import org.oscim.theme.VtmThemes;
import org.oscim.tiling.TileSource; import org.oscim.tiling.TileSource;
import com.badlogic.gdx.Application; import com.badlogic.gdx.Application;
@ -133,7 +133,7 @@ public abstract class GdxMap implements ApplicationListener {
if (tileSource != null) { if (tileSource != null) {
mMapLayer = mMap.setBaseMap(tileSource); mMapLayer = mMap.setBaseMap(tileSource);
mMap.setTheme(InternalRenderTheme.DEFAULT); mMap.setTheme(VtmThemes.DEFAULT);
if (buildings) if (buildings)
layers.add(new BuildingLayer(mMap, mMapLayer)); layers.add(new BuildingLayer(mMap, mMapLayer));
@ -292,17 +292,17 @@ public abstract class GdxMap implements ApplicationListener {
break; break;
case Input.Keys.D: case Input.Keys.D:
mMap.setTheme(InternalRenderTheme.DEFAULT); mMap.setTheme(VtmThemes.DEFAULT);
mMap.updateMap(false); mMap.updateMap(false);
break; break;
case Input.Keys.T: case Input.Keys.T:
mMap.setTheme(InternalRenderTheme.TRONRENDER); mMap.setTheme(VtmThemes.TRONRENDER);
mMap.updateMap(false); mMap.updateMap(false);
break; break;
case Input.Keys.R: case Input.Keys.R:
mMap.setTheme(InternalRenderTheme.OSMARENDER); mMap.setTheme(VtmThemes.OSMARENDER);
mMap.updateMap(false); mMap.updateMap(false);
break; break;

12
vtm-themes/build.gradle Normal file
View File

@ -0,0 +1,12 @@
apply plugin: 'java'
apply plugin: 'maven'
dependencies {
compile project(':vtm')
}
sourceSets {
main.java.srcDirs = ['src']
main.resources.srcDirs = ['resources']
}

View File

Before

Width:  |  Height:  |  Size: 288 B

After

Width:  |  Height:  |  Size: 288 B

View File

Before

Width:  |  Height:  |  Size: 288 B

After

Width:  |  Height:  |  Size: 288 B

View File

Before

Width:  |  Height:  |  Size: 343 B

After

Width:  |  Height:  |  Size: 343 B

View File

Before

Width:  |  Height:  |  Size: 728 B

After

Width:  |  Height:  |  Size: 728 B

View File

Before

Width:  |  Height:  |  Size: 471 B

After

Width:  |  Height:  |  Size: 471 B

View File

Before

Width:  |  Height:  |  Size: 834 B

After

Width:  |  Height:  |  Size: 834 B

View File

Before

Width:  |  Height:  |  Size: 893 B

After

Width:  |  Height:  |  Size: 893 B

View File

Before

Width:  |  Height:  |  Size: 849 B

After

Width:  |  Height:  |  Size: 849 B

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 23 KiB

View File

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

View File

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 118 KiB

View File

Before

Width:  |  Height:  |  Size: 73 KiB

After

Width:  |  Height:  |  Size: 73 KiB

View File

@ -24,7 +24,7 @@ import org.oscim.backend.AssetAdapter;
/** /**
* Enumeration of all internal rendering themes. * Enumeration of all internal rendering themes.
*/ */
public enum InternalRenderTheme implements Theme { public enum VtmThemes implements ThemeFile {
DEFAULT("styles/default.xml"), DEFAULT("styles/default.xml"),
TRONRENDER("styles/tronrender.xml"), TRONRENDER("styles/tronrender.xml"),
@ -34,7 +34,7 @@ public enum InternalRenderTheme implements Theme {
private final String mPath; private final String mPath;
private InternalRenderTheme(String path) { private VtmThemes(String path) {
mPath = path; mPath = path;
} }

View File

@ -1,8 +1,6 @@
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'maven' apply plugin: 'maven'
dependencies { dependencies {
compile 'org.slf4j:slf4j-api:1.7.6' compile 'org.slf4j:slf4j-api:1.7.6'
compile 'com.google.code.findbugs:annotations:2.0.1' compile 'com.google.code.findbugs:annotations:2.0.1'

View File

@ -29,7 +29,7 @@ import org.oscim.layers.tile.vector.OsmTileLayer;
import org.oscim.layers.tile.vector.VectorTileLayer; import org.oscim.layers.tile.vector.VectorTileLayer;
import org.oscim.renderer.MapRenderer; import org.oscim.renderer.MapRenderer;
import org.oscim.theme.IRenderTheme; import org.oscim.theme.IRenderTheme;
import org.oscim.theme.InternalRenderTheme; import org.oscim.theme.ThemeFile;
import org.oscim.theme.ThemeLoader; import org.oscim.theme.ThemeLoader;
import org.oscim.tiling.TileSource; import org.oscim.tiling.TileSource;
import org.oscim.utils.async.AsyncExecutor; import org.oscim.utils.async.AsyncExecutor;
@ -146,7 +146,7 @@ public abstract class Map {
* Utility function to set theme of base vector-layer and * Utility function to set theme of base vector-layer and
* use map background color from theme. * use map background color from theme.
*/ */
public void setTheme(InternalRenderTheme theme) { public void setTheme(ThemeFile theme) {
if (mBaseLayer == null) { if (mBaseLayer == null) {
log.error("No base layer set"); log.error("No base layer set");
throw new IllegalStateException(); throw new IllegalStateException();

View File

@ -30,7 +30,7 @@ import org.oscim.backend.AssetAdapter;
* An ExternalRenderTheme allows for customizing the rendering style of the map * An ExternalRenderTheme allows for customizing the rendering style of the map
* via an XML file. * via an XML file.
*/ */
public class ExternalRenderTheme implements Theme { public class ExternalRenderTheme implements ThemeFile {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private final long mFileModificationDate; private final long mFileModificationDate;

View File

@ -21,7 +21,7 @@ import java.io.FileNotFoundException;
import java.io.InputStream; import java.io.InputStream;
import java.io.Serializable; import java.io.Serializable;
public interface Theme extends Serializable { public interface ThemeFile extends Serializable {
/** /**
* @return an InputStream to read the render theme data from. * @return an InputStream to read the render theme data from.
* @throws FileNotFoundException * @throws FileNotFoundException

View File

@ -29,16 +29,6 @@ import org.slf4j.LoggerFactory;
public class ThemeLoader { public class ThemeLoader {
static final Logger log = LoggerFactory.getLogger(ThemeLoader.class); static final Logger log = LoggerFactory.getLogger(ThemeLoader.class);
/**
* Load internal theme, see {@link InternalRenderTheme}.
*
* @param internalRenderTheme ...
* @return ...
*/
public static IRenderTheme load(InternalRenderTheme internalRenderTheme) {
return load((Theme) internalRenderTheme);
}
/** /**
* Load theme from XML file. * Load theme from XML file.
* *
@ -50,7 +40,7 @@ public class ThemeLoader {
return load(new ExternalRenderTheme(renderThemePath)); return load(new ExternalRenderTheme(renderThemePath));
} }
public static IRenderTheme load(Theme theme) { public static IRenderTheme load(ThemeFile theme) {
InputStream inputStream = null; InputStream inputStream = null;
try { try {