Use baseline 160dpi in scaling, closes #236

This commit is contained in:
Emux 2016-11-13 12:23:32 +02:00
parent d82faad435
commit 58b5f2741b
24 changed files with 56 additions and 55 deletions

View File

@ -6,6 +6,7 @@
- Polygon label position enhancements [#80](https://github.com/mapsforge/vtm/issues/80) - Polygon label position enhancements [#80](https://github.com/mapsforge/vtm/issues/80)
- PathLayer (vtm) fix disappearing segments [#108](https://github.com/mapsforge/vtm/issues/108) - PathLayer (vtm) fix disappearing segments [#108](https://github.com/mapsforge/vtm/issues/108)
- House numbers (nodes) fix visibility [#168](https://github.com/mapsforge/vtm/issues/168) - House numbers (nodes) fix visibility [#168](https://github.com/mapsforge/vtm/issues/168)
- Use baseline 160dpi in scaling [#236](https://github.com/mapsforge/vtm/issues/236)
- MapFileTileSource zoom level API enhancements [#219](https://github.com/mapsforge/vtm/issues/219) - MapFileTileSource zoom level API enhancements [#219](https://github.com/mapsforge/vtm/issues/219)
- Tile grid layer scaling [#238](https://github.com/mapsforge/vtm/issues/238) - Tile grid layer scaling [#238](https://github.com/mapsforge/vtm/issues/238)
- Internal render themes various improvements [#41](https://github.com/mapsforge/vtm/issues/41) - Internal render themes various improvements [#41](https://github.com/mapsforge/vtm/issues/41)

View File

@ -22,7 +22,6 @@ import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import org.oscim.android.cache.TileCache; import org.oscim.android.cache.TileCache;
import org.oscim.backend.CanvasAdapter;
import org.oscim.core.MapPosition; import org.oscim.core.MapPosition;
import org.oscim.layers.TileGridLayer; import org.oscim.layers.TileGridLayer;
import org.oscim.layers.tile.vector.VectorTileLayer; import org.oscim.layers.tile.vector.VectorTileLayer;
@ -109,7 +108,7 @@ public class BaseMapActivity extends MapActivity {
} else { } else {
item.setChecked(true); item.setChecked(true);
if (mGridLayer == null) if (mGridLayer == null)
mGridLayer = new TileGridLayer(mMap, CanvasAdapter.dpi / 160); mGridLayer = new TileGridLayer(mMap, getResources().getDisplayMetrics().density);
mMap.layers().add(mGridLayer); mMap.layers().add(mGridLayer);
} }

View File

@ -20,7 +20,6 @@ package org.oscim.android.test;
import android.os.Bundle; import android.os.Bundle;
import org.oscim.backend.CanvasAdapter;
import org.oscim.layers.tile.buildings.BuildingLayer; import org.oscim.layers.tile.buildings.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;
@ -53,7 +52,7 @@ public class LayerGroupActivity extends BaseMapActivity {
layers.addGroup(GROUP_LABELS); layers.addGroup(GROUP_LABELS);
layers.add(new LabelLayer(mMap, mBaseLayer), GROUP_LABELS); layers.add(new LabelLayer(mMap, mBaseLayer), GROUP_LABELS);
mapScaleBar = new DefaultMapScaleBar(mMap, CanvasAdapter.dpi / 160); mapScaleBar = new DefaultMapScaleBar(mMap);
mapScaleBar.setScaleBarMode(DefaultMapScaleBar.ScaleBarMode.BOTH); mapScaleBar.setScaleBarMode(DefaultMapScaleBar.ScaleBarMode.BOTH);
mapScaleBar.setDistanceUnitAdapter(MetricUnitAdapter.INSTANCE); mapScaleBar.setDistanceUnitAdapter(MetricUnitAdapter.INSTANCE);
mapScaleBar.setSecondaryDistanceUnitAdapter(ImperialUnitAdapter.INSTANCE); mapScaleBar.setSecondaryDistanceUnitAdapter(ImperialUnitAdapter.INSTANCE);
@ -62,7 +61,7 @@ public class LayerGroupActivity extends BaseMapActivity {
MapScaleBarLayer mapScaleBarLayer = new MapScaleBarLayer(mMap, mapScaleBar); MapScaleBarLayer mapScaleBarLayer = new MapScaleBarLayer(mMap, mapScaleBar);
BitmapRenderer renderer = mapScaleBarLayer.getRenderer(); BitmapRenderer renderer = mapScaleBarLayer.getRenderer();
renderer.setPosition(GLViewport.Position.BOTTOM_LEFT); renderer.setPosition(GLViewport.Position.BOTTOM_LEFT);
renderer.setOffset(5 * CanvasAdapter.dpi / 160, 0); renderer.setOffset(5 * getResources().getDisplayMetrics().density, 0);
layers.addGroup(GROUP_OVERLAYS); layers.addGroup(GROUP_OVERLAYS);
layers.add(mapScaleBarLayer, GROUP_OVERLAYS); layers.add(mapScaleBarLayer, GROUP_OVERLAYS);

View File

@ -25,7 +25,6 @@ import android.view.MenuItem;
import org.oscim.android.filepicker.FilePicker; import org.oscim.android.filepicker.FilePicker;
import org.oscim.android.filepicker.FilterByFileExtension; import org.oscim.android.filepicker.FilterByFileExtension;
import org.oscim.android.filepicker.ValidMapFile; import org.oscim.android.filepicker.ValidMapFile;
import org.oscim.backend.CanvasAdapter;
import org.oscim.core.MapPosition; import org.oscim.core.MapPosition;
import org.oscim.core.Tile; import org.oscim.core.Tile;
import org.oscim.layers.TileGridLayer; import org.oscim.layers.TileGridLayer;
@ -93,7 +92,7 @@ public class MapsforgeMapActivity extends MapActivity {
} else { } else {
item.setChecked(true); item.setChecked(true);
if (mGridLayer == null) if (mGridLayer == null)
mGridLayer = new TileGridLayer(mMap, CanvasAdapter.dpi / 160); mGridLayer = new TileGridLayer(mMap, getResources().getDisplayMetrics().density);
mMap.layers().add(mGridLayer); mMap.layers().add(mGridLayer);
} }

View File

@ -21,7 +21,6 @@ import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.widget.Toast; import android.widget.Toast;
import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.canvas.Bitmap; import org.oscim.backend.canvas.Bitmap;
import org.oscim.core.GeoPoint; import org.oscim.core.GeoPoint;
import org.oscim.layers.TileGridLayer; import org.oscim.layers.TileGridLayer;
@ -82,7 +81,7 @@ public class MarkerOverlayActivity extends BitmapTileMapActivity
markerLayer.addItems(pts); markerLayer.addItems(pts);
mMap.layers().add(new TileGridLayer(mMap, CanvasAdapter.dpi / 160)); mMap.layers().add(new TileGridLayer(mMap, getResources().getDisplayMetrics().density));
} }
@Override @Override

View File

@ -19,7 +19,6 @@ package org.oscim.android.test;
import android.os.Bundle; import android.os.Bundle;
import org.oscim.backend.CanvasAdapter;
import org.oscim.layers.TileGridLayer; import org.oscim.layers.TileGridLayer;
import org.oscim.layers.tile.buildings.BuildingLayer; import org.oscim.layers.tile.buildings.BuildingLayer;
import org.oscim.layers.tile.vector.VectorTileLayer; import org.oscim.layers.tile.vector.VectorTileLayer;
@ -66,7 +65,7 @@ public class OsmJsonMapActivity extends MapActivity {
mMap.layers().add(l); mMap.layers().add(l);
mMap.layers().add(new LabelLayer(mMap, l)); mMap.layers().add(new LabelLayer(mMap, l));
mMap.layers().add(new TileGridLayer(mMap, CanvasAdapter.dpi / 160)); mMap.layers().add(new TileGridLayer(mMap, getResources().getDisplayMetrics().density));
mMap.setMapPosition(53.08, 8.83, Math.pow(2, 16)); mMap.setMapPosition(53.08, 8.83, Math.pow(2, 16));
} }

View File

@ -19,7 +19,6 @@ package org.oscim.android.test;
import android.os.Bundle; import android.os.Bundle;
import org.oscim.backend.CanvasAdapter;
import org.oscim.core.MapPosition; import org.oscim.core.MapPosition;
import org.oscim.core.MercatorProjection; import org.oscim.core.MercatorProjection;
import org.oscim.layers.GroupLayer; import org.oscim.layers.GroupLayer;
@ -48,7 +47,7 @@ public class SimpleMapActivity extends BaseMapActivity {
groupLayer.layers.add(new LabelLayer(mMap, mBaseLayer)); groupLayer.layers.add(new LabelLayer(mMap, mBaseLayer));
mMap.layers().add(groupLayer); mMap.layers().add(groupLayer);
mapScaleBar = new DefaultMapScaleBar(mMap, CanvasAdapter.dpi / 160); mapScaleBar = new DefaultMapScaleBar(mMap);
mapScaleBar.setScaleBarMode(DefaultMapScaleBar.ScaleBarMode.BOTH); mapScaleBar.setScaleBarMode(DefaultMapScaleBar.ScaleBarMode.BOTH);
mapScaleBar.setDistanceUnitAdapter(MetricUnitAdapter.INSTANCE); mapScaleBar.setDistanceUnitAdapter(MetricUnitAdapter.INSTANCE);
mapScaleBar.setSecondaryDistanceUnitAdapter(ImperialUnitAdapter.INSTANCE); mapScaleBar.setSecondaryDistanceUnitAdapter(ImperialUnitAdapter.INSTANCE);
@ -57,7 +56,7 @@ public class SimpleMapActivity extends BaseMapActivity {
MapScaleBarLayer mapScaleBarLayer = new MapScaleBarLayer(mMap, mapScaleBar); MapScaleBarLayer mapScaleBarLayer = new MapScaleBarLayer(mMap, mapScaleBar);
BitmapRenderer renderer = mapScaleBarLayer.getRenderer(); BitmapRenderer renderer = mapScaleBarLayer.getRenderer();
renderer.setPosition(GLViewport.Position.BOTTOM_LEFT); renderer.setPosition(GLViewport.Position.BOTTOM_LEFT);
renderer.setOffset(5 * CanvasAdapter.dpi / 160, 0); renderer.setOffset(5 * getResources().getDisplayMetrics().density, 0);
mMap.layers().add(mapScaleBarLayer); mMap.layers().add(mapScaleBarLayer);
mMap.setTheme(VtmThemes.DEFAULT); mMap.setTheme(VtmThemes.DEFAULT);

View File

@ -58,7 +58,7 @@ public class MainActivity extends AndroidApplication {
@Override @Override
public void createLayers() { public void createLayers() {
TileSource ts = new OSciMap4TileSource(); TileSource ts = new OSciMap4TileSource();
initDefaultLayers(ts, true, true, true, CanvasAdapter.dpi / 160); initDefaultLayers(ts, true, true, true, getResources().getDisplayMetrics().density);
} }
} }
} }

View File

@ -76,7 +76,7 @@ public class AndroidSvgBitmap extends AndroidBitmap {
private static android.graphics.Bitmap getResourceBitmapImpl(InputStream inputStream) throws IOException { private static android.graphics.Bitmap getResourceBitmapImpl(InputStream inputStream) throws IOException {
synchronized (SVG.getVersion()) { synchronized (SVG.getVersion()) {
return getResourceBitmap(inputStream, CanvasAdapter.dpi / 160, DEFAULT_SIZE, 0, 0, 100); return getResourceBitmap(inputStream, CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI, DEFAULT_SIZE, 0, 0, 100);
} }
} }

View File

@ -21,7 +21,6 @@ import android.content.SharedPreferences;
import android.preference.PreferenceManager; import android.preference.PreferenceManager;
import org.oscim.android.cache.TileCache; import org.oscim.android.cache.TileCache;
import org.oscim.backend.CanvasAdapter;
import org.oscim.layers.GenericLayer; import org.oscim.layers.GenericLayer;
import org.oscim.layers.Layer; import org.oscim.layers.Layer;
import org.oscim.layers.TileGridLayer; import org.oscim.layers.TileGridLayer;
@ -149,13 +148,13 @@ public class MapLayers {
} }
void enableGridOverlay(boolean enable) { void enableGridOverlay(Context context, boolean enable) {
if (mGridEnabled == enable) if (mGridEnabled == enable)
return; return;
if (enable) { if (enable) {
if (mGridOverlay == null) if (mGridOverlay == null)
mGridOverlay = new TileGridLayer(App.map, CanvasAdapter.dpi / 160); mGridOverlay = new TileGridLayer(App.map, context.getResources().getDisplayMetrics().density);
App.map.layers().add(mGridOverlay); App.map.layers().add(mGridOverlay);
} else { } else {

View File

@ -205,7 +205,7 @@ public class TileMap extends MapActivity implements MapEventsReceiver {
break; break;
case R.id.menu_layer_grid: case R.id.menu_layer_grid:
mMapLayers.enableGridOverlay(!mMapLayers.isGridEnabled()); mMapLayers.enableGridOverlay(this, !mMapLayers.isGridEnabled());
mMap.updateMap(true); mMap.updateMap(true);
break; break;

View File

@ -28,7 +28,7 @@ import java.net.URI;
public class AwtSvgBitmap extends AwtBitmap { public class AwtSvgBitmap extends AwtBitmap {
/** /**
* Default size is 20x20px (400px) at 240dpi. * Default size is 20x20px (400px) at 160dpi.
*/ */
public static float DEFAULT_SIZE = 400f; public static float DEFAULT_SIZE = 400f;
@ -79,7 +79,7 @@ public class AwtSvgBitmap extends AwtBitmap {
private static BufferedImage getResourceBitmapImpl(InputStream inputStream) throws IOException { private static BufferedImage getResourceBitmapImpl(InputStream inputStream) throws IOException {
synchronized (SVGCache.getSVGUniverse()) { synchronized (SVGCache.getSVGUniverse()) {
return getResourceBitmap(inputStream, CanvasAdapter.dpi / 240, DEFAULT_SIZE, 0, 0, 100); return getResourceBitmap(inputStream, CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI, DEFAULT_SIZE, 0, 0, 100);
} }
} }

View File

@ -34,7 +34,7 @@ public class IosSvgBitmap extends IosBitmap {
private static final Logger log = LoggerFactory.getLogger(IosSvgBitmap.class); private static final Logger log = LoggerFactory.getLogger(IosSvgBitmap.class);
/** /**
* Default size is 20x20px (400px) at 240dpi. * Default size is 20x20px (400px) at 160dpi.
*/ */
public static float DEFAULT_SIZE = 400f; public static float DEFAULT_SIZE = 400f;
@ -90,7 +90,7 @@ public class IosSvgBitmap extends IosBitmap {
} }
private static UIImage getResourceBitmapImpl(InputStream inputStream) { private static UIImage getResourceBitmapImpl(InputStream inputStream) {
return getResourceBitmap(inputStream, CanvasAdapter.dpi / 240, DEFAULT_SIZE, 0, 0, 100); return getResourceBitmap(inputStream, CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI, DEFAULT_SIZE, 0, 0, 100);
} }
public IosSvgBitmap(InputStream inputStream) throws IOException { public IosSvgBitmap(InputStream inputStream) throws IOException {

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<rendertheme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" base-text-scale="1.25" <rendertheme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" map-background="#fffcfa"
map-background="#fffcfa" version="1" xmlns="http://opensciencemap.org/rendertheme" version="1" xmlns="http://opensciencemap.org/rendertheme"
xsi:schemaLocation="http://opensciencemap.org/rendertheme https://raw.githubusercontent.com/mapsforge/vtm/master/resources/rendertheme.xsd"> xsi:schemaLocation="http://opensciencemap.org/rendertheme https://raw.githubusercontent.com/mapsforge/vtm/master/resources/rendertheme.xsd">
<stylemenu defaultlang="en" defaultvalue="1" id="menu"> <stylemenu defaultlang="en" defaultvalue="1" id="menu">

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<rendertheme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" base-text-scale="1.25" <rendertheme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" map-background="#fffcfa"
map-background="#fffcfa" version="1" xmlns="http://opensciencemap.org/rendertheme" version="1" xmlns="http://opensciencemap.org/rendertheme"
xsi:schemaLocation="http://opensciencemap.org/rendertheme https://raw.githubusercontent.com/mapsforge/vtm/master/resources/rendertheme.xsd"> xsi:schemaLocation="http://opensciencemap.org/rendertheme https://raw.githubusercontent.com/mapsforge/vtm/master/resources/rendertheme.xsd">
<!-- base style for fixed width lines --> <!-- base style for fixed width lines -->
@ -1035,13 +1035,13 @@
<m k="railway"> <m k="railway">
<m v="station" zoom-min="14"> <m v="station" zoom-min="14">
<symbol src="assets:symbols/transport/train_station.svg" /> <symbol src="assets:symbols/transport/train_station.svg" />
<caption style="bold" dy="-15" fill="#ec2d2d" k="name" size="14" stroke="#ffffff" <caption style="bold" dy="-20" fill="#ec2d2d" k="name" size="14" stroke="#ffffff"
stroke-width="2.0" /> stroke-width="2.0" />
</m> </m>
<m v="halt|tram_stop"> <m v="halt|tram_stop">
<symbol src="assets:symbols/transport/train_station2.svg" /> <symbol src="assets:symbols/transport/train_station2.svg" />
<caption style="bold" dy="-15" fill="#ec2d2d" k="name" size="14" stroke="#ffffff" <caption style="bold" dy="-20" fill="#ec2d2d" k="name" size="14" stroke="#ffffff"
stroke-width="2.0" /> stroke-width="2.0" />
</m> </m>
<m v="level_crossing"> <m v="level_crossing">

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<rendertheme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" base-text-scale="1.25" <rendertheme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" map-background="#fffcfa"
map-background="#fffcfa" version="1" xmlns="http://opensciencemap.org/rendertheme" version="1" xmlns="http://opensciencemap.org/rendertheme"
xsi:schemaLocation="http://opensciencemap.org/rendertheme https://raw.githubusercontent.com/mapsforge/vtm/master/resources/rendertheme.xsd"> xsi:schemaLocation="http://opensciencemap.org/rendertheme https://raw.githubusercontent.com/mapsforge/vtm/master/resources/rendertheme.xsd">
<!-- base style for fixed width lines --> <!-- base style for fixed width lines -->
@ -1035,13 +1035,13 @@
<m k="railway"> <m k="railway">
<m v="station" zoom-min="14"> <m v="station" zoom-min="14">
<symbol src="assets:symbols/transport/train_station.svg" /> <symbol src="assets:symbols/transport/train_station.svg" />
<caption style="bold" dy="-15" fill="#ec2d2d" k="name" size="14" stroke="#ffffff" <caption style="bold" dy="-20" fill="#ec2d2d" k="name" size="14" stroke="#ffffff"
stroke-width="2.0" /> stroke-width="2.0" />
</m> </m>
<m v="halt|tram_stop"> <m v="halt|tram_stop">
<symbol src="assets:symbols/transport/train_station2.svg" /> <symbol src="assets:symbols/transport/train_station2.svg" />
<caption style="bold" dy="-15" fill="#ec2d2d" k="name" size="14" stroke="#ffffff" <caption style="bold" dy="-20" fill="#ec2d2d" k="name" size="14" stroke="#ffffff"
stroke-width="2.0" /> stroke-width="2.0" />
</m> </m>
<m v="level_crossing"> <m v="level_crossing">

View File

@ -1204,12 +1204,12 @@
</m> </m>
<m k="railway" v="station" zoom-min="14"> <m k="railway" v="station" zoom-min="14">
<symbol src="assets:symbols/transport/train_station.svg" /> <symbol src="assets:symbols/transport/train_station.svg" />
<caption style="bold" dy="-15" fill="#ec2d2d" k="name" size="14" stroke="#ffffff" <caption style="bold" dy="-20" fill="#ec2d2d" k="name" size="14" stroke="#ffffff"
stroke-width="2.0" /> stroke-width="2.0" />
</m> </m>
<m k="railway" v="halt|tram_stop" zoom-min="15"> <m k="railway" v="halt|tram_stop" zoom-min="15">
<symbol src="assets:symbols/transport/train_station2.svg" /> <symbol src="assets:symbols/transport/train_station2.svg" />
<caption style="bold" dy="-15" fill="#ec2d2d" k="name" size="14" stroke="#ffffff" <caption style="bold" dy="-20" fill="#ec2d2d" k="name" size="14" stroke="#ffffff"
stroke-width="2.0" /> stroke-width="2.0" />
</m> </m>
</m> </m>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<rendertheme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" base-text-scale="1.25" <rendertheme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" map-background="#fffcfa"
map-background="#fffcfa" version="1" xmlns="http://opensciencemap.org/rendertheme" version="1" xmlns="http://opensciencemap.org/rendertheme"
xsi:schemaLocation="http://opensciencemap.org/rendertheme https://raw.githubusercontent.com/mapsforge/vtm/master/resources/rendertheme.xsd"> xsi:schemaLocation="http://opensciencemap.org/rendertheme https://raw.githubusercontent.com/mapsforge/vtm/master/resources/rendertheme.xsd">
<style-line id="trunk" stroke="#7fc97f" width="1.5" /> <style-line id="trunk" stroke="#7fc97f" width="1.5" />
@ -1291,12 +1291,12 @@
</m> </m>
<m k="railway" v="station" zoom-min="14"> <m k="railway" v="station" zoom-min="14">
<symbol src="assets:symbols/transport/train_station.svg" /> <symbol src="assets:symbols/transport/train_station.svg" />
<caption style="bold" dy="-15" fill="#ec2d2d" k="name" size="14" stroke="#ffffff" <caption style="bold" dy="-20" fill="#ec2d2d" k="name" size="14" stroke="#ffffff"
stroke-width="2.0" /> stroke-width="2.0" />
</m> </m>
<m k="railway" v="halt|tram_stop" zoom-min="15"> <m k="railway" v="halt|tram_stop" zoom-min="15">
<symbol src="assets:symbols/transport/train_station2.svg" /> <symbol src="assets:symbols/transport/train_station2.svg" />
<caption style="bold" dy="-15" fill="#ec2d2d" k="name" size="14" stroke="#ffffff" <caption style="bold" dy="-20" fill="#ec2d2d" k="name" size="14" stroke="#ffffff"
stroke-width="2.0" /> stroke-width="2.0" />
</m> </m>
</m> </m>

View File

@ -1197,12 +1197,12 @@
</m> </m>
<m k="railway" v="station" zoom-min="14"> <m k="railway" v="station" zoom-min="14">
<symbol src="assets:symbols/transport/train_station.svg" /> <symbol src="assets:symbols/transport/train_station.svg" />
<caption style="bold" dy="-15" fill="#ec2d2d" k="name" size="14" stroke="#ffffff" <caption style="bold" dy="-20" fill="#ec2d2d" k="name" size="14" stroke="#ffffff"
stroke-width="2.0" /> stroke-width="2.0" />
</m> </m>
<m k="railway" v="halt|tram_stop" zoom-min="15"> <m k="railway" v="halt|tram_stop" zoom-min="15">
<symbol src="assets:symbols/transport/train_station2.svg" /> <symbol src="assets:symbols/transport/train_station2.svg" />
<caption style="bold" dy="-15" fill="#ec2d2d" k="name" size="14" stroke="#ffffff" <caption style="bold" dy="-20" fill="#ec2d2d" k="name" size="14" stroke="#ffffff"
stroke-width="2.0" /> stroke-width="2.0" />
</m> </m>
</m> </m>

View File

@ -43,10 +43,15 @@ public abstract class CanvasAdapter {
*/ */
static CanvasAdapter g; static CanvasAdapter g;
/**
* Default dpi.
*/
public static final float DEFAULT_DPI = 160;
/** /**
* The dpi. * The dpi.
*/ */
public static float dpi = 240; public static float dpi = DEFAULT_DPI;
/** /**
* The scale. * The scale.

View File

@ -1,6 +1,7 @@
/* /*
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* Copyright 2016 Stephan Leuschner * Copyright 2016 Stephan Leuschner
* Copyright 2016 devemux86
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
* *
@ -180,7 +181,7 @@ public class Animator {
float duration = 500; float duration = 500;
float flingFactor = 240 / CanvasAdapter.dpi; float flingFactor = CanvasAdapter.DEFAULT_DPI / CanvasAdapter.dpi;
mVelocity.x = velocityX * flingFactor; mVelocity.x = velocityX * flingFactor;
mVelocity.y = velocityY * flingFactor; mVelocity.y = velocityY * flingFactor;
mVelocity.x = clamp(mVelocity.x, xmin, xmax); mVelocity.x = clamp(mVelocity.x, xmin, xmax);

View File

@ -49,7 +49,7 @@ public class DefaultMapScaleBar extends MapScaleBar {
private final Paint paintScaleTextStroke; private final Paint paintScaleTextStroke;
public DefaultMapScaleBar(Map map) { public DefaultMapScaleBar(Map map) {
this(map, CanvasAdapter.dpi / 240); this(map, CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI);
} }
public DefaultMapScaleBar(Map map, float scale) { public DefaultMapScaleBar(Map map, float scale) {

View File

@ -33,7 +33,7 @@ public class ThemeLoader {
public static IRenderTheme load(ThemeFile theme) throws ThemeException { public static IRenderTheme load(ThemeFile theme) throws ThemeException {
IRenderTheme t = XmlThemeBuilder.read(theme); IRenderTheme t = XmlThemeBuilder.read(theme);
if (t != null) if (t != null)
t.scaleTextSize(CanvasAdapter.textScale + (CanvasAdapter.dpi / 240 - 1) * 0.5f); t.scaleTextSize(CanvasAdapter.textScale + (CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI - 1));
return t; return t;
} }
} }

View File

@ -134,7 +134,7 @@ public class XmlThemeBuilder extends DefaultHandler {
private final ThemeFile mTheme; private final ThemeFile mTheme;
private RenderTheme mRenderTheme; private RenderTheme mRenderTheme;
private final float mScale; private final float mScale, mScale2;
private Set<String> mCategories; private Set<String> mCategories;
private XmlRenderThemeStyleLayer mCurrentLayer; private XmlRenderThemeStyleLayer mCurrentLayer;
@ -142,7 +142,8 @@ public class XmlThemeBuilder extends DefaultHandler {
public XmlThemeBuilder(ThemeFile theme) { public XmlThemeBuilder(ThemeFile theme) {
mTheme = theme; mTheme = theme;
mScale = CanvasAdapter.scale + (CanvasAdapter.dpi / 240 - 1) * 0.5f; mScale = CanvasAdapter.scale + (CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI - 1);
mScale2 = CanvasAdapter.scale + (CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI - 1) * 0.5f;
} }
@Override @Override
@ -479,7 +480,7 @@ public class XmlThemeBuilder extends DefaultHandler {
b.color(value); b.color(value);
else if ("width".equals(name) || "stroke-width".equals(name)) { else if ("width".equals(name) || "stroke-width".equals(name)) {
b.strokeWidth = parseFloat(value) * mScale; b.strokeWidth = parseFloat(value) * mScale2;
if (line == null) { if (line == null) {
if (!isOutline) if (!isOutline)
validateNonNegative("width", b.strokeWidth); validateNonNegative("width", b.strokeWidth);
@ -496,7 +497,7 @@ public class XmlThemeBuilder extends DefaultHandler {
b.fixed = parseBoolean(value); b.fixed = parseBoolean(value);
else if ("stipple".equals(name)) else if ("stipple".equals(name))
b.stipple = Math.round(parseInt(value) * mScale); b.stipple = Math.round(parseInt(value) * mScale2);
else if ("stipple-stroke".equals(name)) else if ("stipple-stroke".equals(name))
b.stippleColor(value); b.stippleColor(value);
@ -583,7 +584,7 @@ public class XmlThemeBuilder extends DefaultHandler {
else if ("stroke-width".equals(name)) { else if ("stroke-width".equals(name)) {
float strokeWidth = Float.parseFloat(value); float strokeWidth = Float.parseFloat(value);
validateNonNegative("stroke-width", strokeWidth); validateNonNegative("stroke-width", strokeWidth);
b.strokeWidth = strokeWidth * mScale; b.strokeWidth = strokeWidth * mScale2;
} else if ("fade".equals(name)) } else if ("fade".equals(name))
b.fadeScale = Integer.parseInt(value); b.fadeScale = Integer.parseInt(value);
@ -856,7 +857,7 @@ public class XmlThemeBuilder extends DefaultHandler {
b.strokeColor = Color.parseColor(value); b.strokeColor = Color.parseColor(value);
else if ("stroke-width".equals(name)) else if ("stroke-width".equals(name))
b.strokeWidth = Float.parseFloat(value) * mScale; b.strokeWidth = Float.parseFloat(value) * mScale2;
else if ("caption".equals(name)) else if ("caption".equals(name))
b.caption = Boolean.parseBoolean(value); b.caption = Boolean.parseBoolean(value);
@ -869,7 +870,7 @@ public class XmlThemeBuilder extends DefaultHandler {
else if ("dy".equals(name)) else if ("dy".equals(name))
// NB: minus.. // NB: minus..
b.dy = -Float.parseFloat(value) * CanvasAdapter.dpi / 160; b.dy = -Float.parseFloat(value) * mScale;
else if ("symbol".equals(name)) { else if ("symbol".equals(name)) {
String lowValue = value.toLowerCase(Locale.ENGLISH); String lowValue = value.toLowerCase(Locale.ENGLISH);
@ -911,7 +912,7 @@ public class XmlThemeBuilder extends DefaultHandler {
String value = attributes.getValue(i); String value = attributes.getValue(i);
if ("r".equals(name) || "radius".equals(name)) if ("r".equals(name) || "radius".equals(name))
radius = Float.parseFloat(value) * mScale; radius = Float.parseFloat(value) * mScale2;
else if ("cat".equals(name)) else if ("cat".equals(name))
cat = value; cat = value;
@ -926,7 +927,7 @@ public class XmlThemeBuilder extends DefaultHandler {
stroke = Color.parseColor(value); stroke = Color.parseColor(value);
else if ("stroke-width".equals(name)) else if ("stroke-width".equals(name))
strokeWidth = Float.parseFloat(value) * mScale; strokeWidth = Float.parseFloat(value) * mScale2;
else else
logUnknownAttribute(elementName, name, value, i); logUnknownAttribute(elementName, name, value, i);