From 2a2b30f9fcafcb84ecad7291ba825b5132fc0829 Mon Sep 17 00:00:00 2001 From: Emux Date: Sun, 25 Sep 2016 19:02:08 +0300 Subject: [PATCH] Samples: update with scaled tile size #183 --- .../org/oscim/android/test/MapActivity.java | 2 ++ .../src/org/oscim/gdx/MainActivity.java | 2 +- .../org/oscim/android/start/TestActivity.java | 4 ++++ vtm-app/src/org/oscim/app/TileMap.java | 2 ++ vtm-desktop/src/org/oscim/gdx/GdxMapApp.java | 9 ++++----- .../src/org/oscim/stuff/MapzenTest.java | 2 +- .../src/org/oscim/test/HairLineTest.java | 18 +++++++++++++++++- .../src/org/oscim/test/LineTexTest.java | 2 +- vtm-playground/src/org/oscim/test/MapTest.java | 2 +- .../src/org/oscim/test/MapsforgeTest.java | 2 +- .../src/org/oscim/test/MarkerLayerTest.java | 2 +- .../src/org/oscim/test/PathLayerTest.java | 2 +- .../src/org/oscim/test/RuleVisitorTest.java | 18 +++++++++++++++++- .../src/org/oscim/test/S3DBLayerTest.java | 2 +- .../src/org/oscim/test/ThemeBuilderTest.java | 18 +++++++++++++++++- .../src/org/oscim/test/TileRenderTest.java | 18 +++++++++++++++++- .../src/org/oscim/test/VectorLayerTest.java | 2 +- .../org/oscim/test/gdx/poi3d/Gdx3DTest.java | 18 +++++++++++++++++- .../src/org/oscim/test/renderer/AtlasTest.java | 18 +++++++++++++++++- .../org/oscim/test/renderer/BezierTest.java | 18 +++++++++++++++++- .../oscim/test/renderer/HexagonRenderTest.java | 18 +++++++++++++++++- 21 files changed, 157 insertions(+), 22 deletions(-) diff --git a/vtm-android-example/src/org/oscim/android/test/MapActivity.java b/vtm-android-example/src/org/oscim/android/test/MapActivity.java index 55a88a03..6e12cd7b 100644 --- a/vtm-android-example/src/org/oscim/android/test/MapActivity.java +++ b/vtm-android-example/src/org/oscim/android/test/MapActivity.java @@ -21,6 +21,7 @@ import android.os.Bundle; import org.oscim.android.MapPreferences; import org.oscim.android.MapView; +import org.oscim.core.Tile; import org.oscim.map.Map; public class MapActivity extends Activity { @@ -40,6 +41,7 @@ public class MapActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + Tile.SIZE = Tile.calculateTileSize(getResources().getDisplayMetrics().scaledDensity); setContentView(mContentView); setTitle(getClass().getSimpleName()); diff --git a/vtm-android-gdx/src/org/oscim/gdx/MainActivity.java b/vtm-android-gdx/src/org/oscim/gdx/MainActivity.java index e25f5ea5..9ebba02c 100644 --- a/vtm-android-gdx/src/org/oscim/gdx/MainActivity.java +++ b/vtm-android-gdx/src/org/oscim/gdx/MainActivity.java @@ -40,10 +40,10 @@ public class MainActivity extends AndroidApplication { AndroidGraphics.init(); GdxAssets.init(""); GLAdapter.init(new AndroidGL()); - Tile.SIZE = 400; DisplayMetrics metrics = getResources().getDisplayMetrics(); CanvasAdapter.dpi = (int) Math.max(metrics.xdpi, metrics.ydpi); + Tile.SIZE = Tile.calculateTileSize(metrics.scaledDensity); AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration(); cfg.stencil = 8; diff --git a/vtm-android-start/src/org/oscim/android/start/TestActivity.java b/vtm-android-start/src/org/oscim/android/start/TestActivity.java index 37ad0e25..abbb648b 100644 --- a/vtm-android-start/src/org/oscim/android/start/TestActivity.java +++ b/vtm-android-start/src/org/oscim/android/start/TestActivity.java @@ -21,6 +21,8 @@ import android.os.Bundle; import org.oscim.android.MapPreferences; import org.oscim.android.MapView; +import org.oscim.core.Tile; +import org.oscim.layers.TileGridLayer; import org.oscim.layers.tile.buildings.BuildingLayer; import org.oscim.layers.tile.vector.VectorTileLayer; import org.oscim.layers.tile.vector.labeling.LabelLayer; @@ -34,6 +36,7 @@ public class TestActivity extends Activity { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + Tile.SIZE = Tile.calculateTileSize(getResources().getDisplayMetrics().scaledDensity); setContentView(R.layout.activity_map); mMapView = (MapView) findViewById(R.id.mapView); @@ -43,6 +46,7 @@ public class TestActivity extends Activity { VectorTileLayer baseLayer = map.setBaseMap(new OSciMap4TileSource()); map.layers().add(new BuildingLayer(map, baseLayer)); map.layers().add(new LabelLayer(map, baseLayer)); + map.layers().add(new TileGridLayer(map)); map.setTheme(VtmThemes.DEFAULT); } diff --git a/vtm-app/src/org/oscim/app/TileMap.java b/vtm-app/src/org/oscim/app/TileMap.java index 8b19862a..bcfe9e82 100755 --- a/vtm-app/src/org/oscim/app/TileMap.java +++ b/vtm-app/src/org/oscim/app/TileMap.java @@ -40,6 +40,7 @@ import org.oscim.app.location.LocationDialog; import org.oscim.app.location.LocationHandler; import org.oscim.app.preferences.EditPreferences; import org.oscim.core.GeoPoint; +import org.oscim.core.Tile; import org.oscim.overlay.DistanceTouchOverlay; import org.osmdroid.location.POI; import org.osmdroid.overlays.MapEventsReceiver; @@ -73,6 +74,7 @@ public class TileMap extends MapActivity implements MapEventsReceiver { protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + Tile.SIZE = Tile.calculateTileSize(getResources().getDisplayMetrics().scaledDensity); setContentView(R.layout.activity_tilemap); App.view = (MapView) findViewById(R.id.mapView); registerMapView(App.view); diff --git a/vtm-desktop/src/org/oscim/gdx/GdxMapApp.java b/vtm-desktop/src/org/oscim/gdx/GdxMapApp.java index 94afa8ab..f4b1db2a 100644 --- a/vtm-desktop/src/org/oscim/gdx/GdxMapApp.java +++ b/vtm-desktop/src/org/oscim/gdx/GdxMapApp.java @@ -45,21 +45,20 @@ public class GdxMapApp extends GdxMap { } public static void main(String[] args) { - Tile.SIZE = 360; init(); new LwjglApplication(new GdxMapApp(), getConfig()); } + public static void run(GdxMap map) { + run(map, null, Tile.SIZE); + } + public static void run(GdxMap map, LwjglApplicationConfiguration config, int tileSize) { Tile.SIZE = FastMath.clamp(tileSize, 128, 512); new LwjglApplication(map, (config == null ? getConfig() : config)); } - public static void run(LwjglApplicationConfiguration config, int tileSize, GdxMap map) { - run(map, config, tileSize); - } - static protected LwjglApplicationConfiguration getConfig() { LwjglApplicationConfiguration cfg = new LwjglApplicationConfiguration(); cfg.title = "vtm-gdx"; diff --git a/vtm-playground/src/org/oscim/stuff/MapzenTest.java b/vtm-playground/src/org/oscim/stuff/MapzenTest.java index 90a99fff..18c49df5 100644 --- a/vtm-playground/src/org/oscim/stuff/MapzenTest.java +++ b/vtm-playground/src/org/oscim/stuff/MapzenTest.java @@ -70,6 +70,6 @@ public class MapzenTest extends GdxMap { public static void main(String[] args) { GdxMapApp.init(); - GdxMapApp.run(new MapzenTest(), null, 400); + GdxMapApp.run(new MapzenTest()); } } diff --git a/vtm-playground/src/org/oscim/test/HairLineTest.java b/vtm-playground/src/org/oscim/test/HairLineTest.java index e135ed7a..4956085a 100644 --- a/vtm-playground/src/org/oscim/test/HairLineTest.java +++ b/vtm-playground/src/org/oscim/test/HairLineTest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2016 devemux86 + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * 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 + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ package org.oscim.test; import org.oscim.backend.canvas.Color; @@ -109,7 +125,7 @@ public class HairLineTest extends GdxMap { public static void main(String[] args) { GdxMapApp.init(); - GdxMapApp.run(new HairLineTest(), null, 400); + GdxMapApp.run(new HairLineTest()); } } diff --git a/vtm-playground/src/org/oscim/test/LineTexTest.java b/vtm-playground/src/org/oscim/test/LineTexTest.java index 79de2123..2eb514e2 100644 --- a/vtm-playground/src/org/oscim/test/LineTexTest.java +++ b/vtm-playground/src/org/oscim/test/LineTexTest.java @@ -120,6 +120,6 @@ public class LineTexTest extends GdxMapApp { public static void main(String[] args) { GdxMapApp.init(); - GdxMapApp.run(new LineTexTest(), null, 400); + GdxMapApp.run(new LineTexTest()); } } diff --git a/vtm-playground/src/org/oscim/test/MapTest.java b/vtm-playground/src/org/oscim/test/MapTest.java index 0a1d2a2c..6f9ea943 100644 --- a/vtm-playground/src/org/oscim/test/MapTest.java +++ b/vtm-playground/src/org/oscim/test/MapTest.java @@ -63,6 +63,6 @@ public class MapTest extends GdxMapApp { public static void main(String[] args) { GdxMapApp.init(); - GdxMapApp.run(new MapTest(), null, 400); + GdxMapApp.run(new MapTest()); } } diff --git a/vtm-playground/src/org/oscim/test/MapsforgeTest.java b/vtm-playground/src/org/oscim/test/MapsforgeTest.java index a8086d2c..d8b2a50e 100644 --- a/vtm-playground/src/org/oscim/test/MapsforgeTest.java +++ b/vtm-playground/src/org/oscim/test/MapsforgeTest.java @@ -71,6 +71,6 @@ public class MapsforgeTest extends GdxMap { mapFile = getMapFile(args); GdxMapApp.init(); - GdxMapApp.run(new MapsforgeTest(), null, 400); + GdxMapApp.run(new MapsforgeTest()); } } diff --git a/vtm-playground/src/org/oscim/test/MarkerLayerTest.java b/vtm-playground/src/org/oscim/test/MarkerLayerTest.java index 0860dc5d..af5419af 100644 --- a/vtm-playground/src/org/oscim/test/MarkerLayerTest.java +++ b/vtm-playground/src/org/oscim/test/MarkerLayerTest.java @@ -87,6 +87,6 @@ public class MarkerLayerTest extends GdxMapApp implements ItemizedLayer.OnItemGe public static void main(String[] args) { GdxMapApp.init(); - GdxMapApp.run(new MarkerLayerTest(), null, 400); + GdxMapApp.run(new MarkerLayerTest()); } } diff --git a/vtm-playground/src/org/oscim/test/PathLayerTest.java b/vtm-playground/src/org/oscim/test/PathLayerTest.java index ea9dbe1d..684e6059 100644 --- a/vtm-playground/src/org/oscim/test/PathLayerTest.java +++ b/vtm-playground/src/org/oscim/test/PathLayerTest.java @@ -102,6 +102,6 @@ public class PathLayerTest extends GdxMapApp { public static void main(String[] args) { GdxMapApp.init(); - GdxMapApp.run(new PathLayerTest(), null, 400); + GdxMapApp.run(new PathLayerTest()); } } diff --git a/vtm-playground/src/org/oscim/test/RuleVisitorTest.java b/vtm-playground/src/org/oscim/test/RuleVisitorTest.java index 32946d60..e9a6c06a 100644 --- a/vtm-playground/src/org/oscim/test/RuleVisitorTest.java +++ b/vtm-playground/src/org/oscim/test/RuleVisitorTest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2016 devemux86 + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * 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 + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ package org.oscim.test; import com.badlogic.gdx.Input; @@ -73,7 +89,7 @@ public class RuleVisitorTest extends GdxMap { public static void main(String[] args) { GdxMapApp.init(); - GdxMapApp.run(new RuleVisitorTest(), null, 400); + GdxMapApp.run(new RuleVisitorTest()); } static class SaturateLineStyles extends RuleVisitor { diff --git a/vtm-playground/src/org/oscim/test/S3DBLayerTest.java b/vtm-playground/src/org/oscim/test/S3DBLayerTest.java index bcb10d65..e0ff630c 100644 --- a/vtm-playground/src/org/oscim/test/S3DBLayerTest.java +++ b/vtm-playground/src/org/oscim/test/S3DBLayerTest.java @@ -43,6 +43,6 @@ public class S3DBLayerTest extends GdxMapApp { public static void main(String[] args) { init(); - run(new S3DBLayerTest(), null, 400); + run(new S3DBLayerTest()); } } diff --git a/vtm-playground/src/org/oscim/test/ThemeBuilderTest.java b/vtm-playground/src/org/oscim/test/ThemeBuilderTest.java index 212bd6e3..964ba397 100644 --- a/vtm-playground/src/org/oscim/test/ThemeBuilderTest.java +++ b/vtm-playground/src/org/oscim/test/ThemeBuilderTest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2016 devemux86 + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * 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 + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ package org.oscim.test; import org.oscim.backend.canvas.Color; @@ -56,6 +72,6 @@ public class ThemeBuilderTest extends GdxMap { public static void main(String[] args) { GdxMapApp.init(); - GdxMapApp.run(new ThemeBuilderTest(), null, 400); + GdxMapApp.run(new ThemeBuilderTest()); } } diff --git a/vtm-playground/src/org/oscim/test/TileRenderTest.java b/vtm-playground/src/org/oscim/test/TileRenderTest.java index 4999cc11..f17aed5c 100644 --- a/vtm-playground/src/org/oscim/test/TileRenderTest.java +++ b/vtm-playground/src/org/oscim/test/TileRenderTest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2016 devemux86 + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * 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 + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ package org.oscim.test; import org.oscim.backend.canvas.Color; @@ -197,6 +213,6 @@ public class TileRenderTest extends GdxMapApp { public static void main(String[] args) { GdxMapApp.init(); - GdxMapApp.run(new TileRenderTest(), null, 512); + GdxMapApp.run(new TileRenderTest()); } } diff --git a/vtm-playground/src/org/oscim/test/VectorLayerTest.java b/vtm-playground/src/org/oscim/test/VectorLayerTest.java index e5c1a775..eae1eb4e 100644 --- a/vtm-playground/src/org/oscim/test/VectorLayerTest.java +++ b/vtm-playground/src/org/oscim/test/VectorLayerTest.java @@ -91,6 +91,6 @@ public class VectorLayerTest extends GdxMapApp { public static void main(String[] args) { GdxMapApp.init(); - GdxMapApp.run(new VectorLayerTest(), null, 400); + GdxMapApp.run(new VectorLayerTest()); } } diff --git a/vtm-playground/src/org/oscim/test/gdx/poi3d/Gdx3DTest.java b/vtm-playground/src/org/oscim/test/gdx/poi3d/Gdx3DTest.java index 28a83320..616a4ceb 100644 --- a/vtm-playground/src/org/oscim/test/gdx/poi3d/Gdx3DTest.java +++ b/vtm-playground/src/org/oscim/test/gdx/poi3d/Gdx3DTest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2016 devemux86 + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * 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 + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ package org.oscim.test.gdx.poi3d; import org.oscim.gdx.GdxMap; @@ -43,6 +59,6 @@ public class Gdx3DTest extends GdxMap { public static void main(String[] args) { GdxMapApp.init(); - GdxMapApp.run(new Gdx3DTest(), null, 320); + GdxMapApp.run(new Gdx3DTest()); } } diff --git a/vtm-playground/src/org/oscim/test/renderer/AtlasTest.java b/vtm-playground/src/org/oscim/test/renderer/AtlasTest.java index b37261a6..0e1ae53f 100644 --- a/vtm-playground/src/org/oscim/test/renderer/AtlasTest.java +++ b/vtm-playground/src/org/oscim/test/renderer/AtlasTest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2016 devemux86 + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * 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 + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ package org.oscim.test.renderer; import org.oscim.backend.canvas.Color; @@ -30,7 +46,7 @@ public class AtlasTest extends GdxMap { public static void main(String[] args) { GdxMapApp.init(); - GdxMapApp.run(new AtlasTest(), null, 400); + GdxMapApp.run(new AtlasTest()); } static class AtlasRenderLayer extends BucketRenderer { diff --git a/vtm-playground/src/org/oscim/test/renderer/BezierTest.java b/vtm-playground/src/org/oscim/test/renderer/BezierTest.java index 663888b9..309d77f1 100644 --- a/vtm-playground/src/org/oscim/test/renderer/BezierTest.java +++ b/vtm-playground/src/org/oscim/test/renderer/BezierTest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2016 devemux86 + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * 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 + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ package org.oscim.test.renderer; import org.oscim.backend.canvas.Color; @@ -23,7 +39,7 @@ public class BezierTest extends GdxMap { public static void main(String[] args) { GdxMapApp.init(); - GdxMapApp.run(new BezierTest(), null, 400); + GdxMapApp.run(new BezierTest()); } static class BezierPathLayer extends BucketRenderer { diff --git a/vtm-playground/src/org/oscim/test/renderer/HexagonRenderTest.java b/vtm-playground/src/org/oscim/test/renderer/HexagonRenderTest.java index 82b30d7f..c483e35f 100644 --- a/vtm-playground/src/org/oscim/test/renderer/HexagonRenderTest.java +++ b/vtm-playground/src/org/oscim/test/renderer/HexagonRenderTest.java @@ -1,3 +1,19 @@ +/* + * Copyright 2016 devemux86 + * + * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). + * + * 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 + * Foundation, either version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT ANY + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License along with + * this program. If not, see . + */ package org.oscim.test.renderer; import org.oscim.backend.GL; @@ -28,7 +44,7 @@ public class HexagonRenderTest extends GdxMap { public static void main(String[] args) { GdxMapApp.init(); - GdxMapApp.run(new HexagonRenderTest(), null, 400); + GdxMapApp.run(new HexagonRenderTest()); } /* This is an example how to integrate custom OpenGL drawing routines as map