CanvasAdapter: add getScale method #92
This commit is contained in:
@@ -86,7 +86,7 @@ public class ReverseGeocodeActivity extends MapsforgeMapActivity {
|
|||||||
GeoPoint p = mMap.viewport().fromScreenPoint(e.getX(), e.getY());
|
GeoPoint p = mMap.viewport().fromScreenPoint(e.getX(), e.getY());
|
||||||
|
|
||||||
// Read all labeled POI and ways for the area covered by the tiles under touch
|
// Read all labeled POI and ways for the area covered by the tiles under touch
|
||||||
float touchRadius = TOUCH_RADIUS * CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI;
|
float touchRadius = TOUCH_RADIUS * CanvasAdapter.getScale();
|
||||||
long mapSize = MercatorProjection.getMapSize((byte) mMap.getMapPosition().getZoomLevel());
|
long mapSize = MercatorProjection.getMapSize((byte) mMap.getMapPosition().getZoomLevel());
|
||||||
double pixelX = MercatorProjection.longitudeToPixelX(p.getLongitude(), mapSize);
|
double pixelX = MercatorProjection.longitudeToPixelX(p.getLongitude(), mapSize);
|
||||||
double pixelY = MercatorProjection.latitudeToPixelY(p.getLatitude(), mapSize);
|
double pixelY = MercatorProjection.latitudeToPixelY(p.getLatitude(), mapSize);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||||
* Copyright 2013-2014 Ludwig M Brinckmann
|
* Copyright 2013-2014 Ludwig M Brinckmann
|
||||||
* Copyright 2014-2016 devemux86
|
* Copyright 2014-2017 devemux86
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the
|
* 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
|
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||||
@@ -78,7 +78,7 @@ public class AndroidSvgBitmap extends AndroidBitmap {
|
|||||||
|
|
||||||
private static android.graphics.Bitmap getResourceBitmapImpl(InputStream inputStream, int width, int height, int percent) throws IOException {
|
private static android.graphics.Bitmap getResourceBitmapImpl(InputStream inputStream, int width, int height, int percent) throws IOException {
|
||||||
synchronized (SVG.getVersion()) {
|
synchronized (SVG.getVersion()) {
|
||||||
return getResourceBitmap(inputStream, CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI, DEFAULT_SIZE, width, height, percent);
|
return getResourceBitmap(inputStream, CanvasAdapter.getScale(), DEFAULT_SIZE, width, height, percent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2015-2016 devemux86
|
* Copyright 2015-2017 devemux86
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the
|
* 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
|
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||||
@@ -79,7 +79,7 @@ public class AwtSvgBitmap extends AwtBitmap {
|
|||||||
|
|
||||||
private static BufferedImage getResourceBitmapImpl(InputStream inputStream, int width, int height, int percent) throws IOException {
|
private static BufferedImage getResourceBitmapImpl(InputStream inputStream, int width, int height, int percent) throws IOException {
|
||||||
synchronized (SVGCache.getSVGUniverse()) {
|
synchronized (SVGCache.getSVGUniverse()) {
|
||||||
return getResourceBitmap(inputStream, CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI, DEFAULT_SIZE, width, height, percent);
|
return getResourceBitmap(inputStream, CanvasAdapter.getScale(), DEFAULT_SIZE, width, height, percent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Longri
|
* Copyright 2016 Longri
|
||||||
* Copyright 2016 devemux86
|
* Copyright 2016-2017 devemux86
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the
|
* 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
|
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||||
@@ -90,7 +90,7 @@ public class IosSvgBitmap extends IosBitmap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static UIImage getResourceBitmapImpl(InputStream inputStream, int width, int height, int percent) {
|
private static UIImage getResourceBitmapImpl(InputStream inputStream, int width, int height, int percent) {
|
||||||
return getResourceBitmap(inputStream, CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI, DEFAULT_SIZE, width, height, percent);
|
return getResourceBitmap(inputStream, CanvasAdapter.getScale(), DEFAULT_SIZE, width, height, percent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IosSvgBitmap(InputStream inputStream, int width, int height, int percent) throws IOException {
|
public IosSvgBitmap(InputStream inputStream, int width, int height, int percent) throws IOException {
|
||||||
|
|||||||
@@ -210,6 +210,10 @@ public abstract class CanvasAdapter {
|
|||||||
return new File(parentPath, pathName);
|
return new File(parentPath, pathName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static float getScale() {
|
||||||
|
return CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI;
|
||||||
|
}
|
||||||
|
|
||||||
protected static void init(CanvasAdapter adapter) {
|
protected static void init(CanvasAdapter adapter) {
|
||||||
g = adapter;
|
g = adapter;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class LocationLayer extends Layer {
|
|||||||
public final LocationRenderer locationRenderer;
|
public final LocationRenderer locationRenderer;
|
||||||
|
|
||||||
public LocationLayer(Map map) {
|
public LocationLayer(Map map) {
|
||||||
this(map, CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI);
|
this(map, CanvasAdapter.getScale());
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocationLayer(Map map, float scale) {
|
public LocationLayer(Map map, float scale) {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class ScreenUtils {
|
|||||||
* @return Value in PX according to screen density
|
* @return Value in PX according to screen density
|
||||||
*/
|
*/
|
||||||
public static int getPixels(float dp) {
|
public static int getPixels(float dp) {
|
||||||
return (int) (CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI * dp);
|
return (int) (CanvasAdapter.getScale() * dp);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ClusterDrawable {
|
public static class ClusterDrawable {
|
||||||
@@ -66,7 +66,7 @@ public class ScreenUtils {
|
|||||||
|
|
||||||
mPaintBorder.setColor(foregroundColor);
|
mPaintBorder.setColor(foregroundColor);
|
||||||
mPaintBorder.setStyle(Paint.Style.STROKE);
|
mPaintBorder.setStyle(Paint.Style.STROKE);
|
||||||
mPaintBorder.setStrokeWidth(2.0f * CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI);
|
mPaintBorder.setStrokeWidth(2.0f * CanvasAdapter.getScale());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setText(String text) {
|
private void setText(String text) {
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class LocationRenderer extends LayerRenderer {
|
|||||||
private int mShowAccuracyZoom = SHOW_ACCURACY_ZOOM;
|
private int mShowAccuracyZoom = SHOW_ACCURACY_ZOOM;
|
||||||
|
|
||||||
public LocationRenderer(Map map, Layer layer) {
|
public LocationRenderer(Map map, Layer layer) {
|
||||||
this(map, layer, CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI);
|
this(map, layer, CanvasAdapter.getScale());
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocationRenderer(Map map, Layer layer, float scale) {
|
public LocationRenderer(Map map, Layer layer, float scale) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
|
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
|
||||||
* Copyright 2014 Ludwig M Brinckmann
|
* Copyright 2014 Ludwig M Brinckmann
|
||||||
* Copyright 2014-2016 devemux86
|
* Copyright 2014-2017 devemux86
|
||||||
* Copyright 2014 Erik Duisters
|
* Copyright 2014 Erik Duisters
|
||||||
* Copyright 2014 Christian Pesch
|
* Copyright 2014 Christian Pesch
|
||||||
*
|
*
|
||||||
@@ -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 / CanvasAdapter.DEFAULT_DPI);
|
this(map, CanvasAdapter.getScale());
|
||||||
}
|
}
|
||||||
|
|
||||||
public DefaultMapScaleBar(Map map, float scale) {
|
public DefaultMapScaleBar(Map map, float scale) {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class ThemeLoader {
|
|||||||
else
|
else
|
||||||
t = USE_ATLAS ? XmlAtlasThemeBuilder.read(theme, themeCallback) : XmlThemeBuilder.read(theme, themeCallback);
|
t = USE_ATLAS ? XmlAtlasThemeBuilder.read(theme, themeCallback) : XmlThemeBuilder.read(theme, themeCallback);
|
||||||
if (t != null)
|
if (t != null)
|
||||||
t.scaleTextSize(CanvasAdapter.textScale + (CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI - 1));
|
t.scaleTextSize(CanvasAdapter.textScale + (CanvasAdapter.getScale() - 1));
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,8 +169,8 @@ public class XmlMapsforgeThemeBuilder extends DefaultHandler {
|
|||||||
public XmlMapsforgeThemeBuilder(ThemeFile theme, ThemeCallback themeCallback) {
|
public XmlMapsforgeThemeBuilder(ThemeFile theme, ThemeCallback themeCallback) {
|
||||||
mTheme = theme;
|
mTheme = theme;
|
||||||
mThemeCallback = themeCallback;
|
mThemeCallback = themeCallback;
|
||||||
mScale = CanvasAdapter.scale + (CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI - 1);
|
mScale = CanvasAdapter.scale + (CanvasAdapter.getScale() - 1);
|
||||||
mScale2 = CanvasAdapter.scale + (CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI - 1) * 0.5f;
|
mScale2 = CanvasAdapter.scale + (CanvasAdapter.getScale() - 1) * 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -169,8 +169,8 @@ public class XmlThemeBuilder extends DefaultHandler {
|
|||||||
public XmlThemeBuilder(ThemeFile theme, ThemeCallback themeCallback) {
|
public XmlThemeBuilder(ThemeFile theme, ThemeCallback themeCallback) {
|
||||||
mTheme = theme;
|
mTheme = theme;
|
||||||
mThemeCallback = themeCallback;
|
mThemeCallback = themeCallback;
|
||||||
mScale = CanvasAdapter.scale + (CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI - 1);
|
mScale = CanvasAdapter.scale + (CanvasAdapter.getScale() - 1);
|
||||||
mScale2 = CanvasAdapter.scale + (CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI - 1) * 0.5f;
|
mScale2 = CanvasAdapter.scale + (CanvasAdapter.getScale() - 1) * 0.5f;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ public class MapDatabase implements ITileDataSource {
|
|||||||
if (queryParameters.queryZoomLevel > MapFileTileSource.MAX_ZOOM_LEVEL)
|
if (queryParameters.queryZoomLevel > MapFileTileSource.MAX_ZOOM_LEVEL)
|
||||||
buffer = Tile.SIZE / 2;
|
buffer = Tile.SIZE / 2;
|
||||||
else
|
else
|
||||||
buffer = (int) (16 * CanvasAdapter.dpi / CanvasAdapter.DEFAULT_DPI + 0.5f);
|
buffer = (int) (16 * CanvasAdapter.getScale() + 0.5f);
|
||||||
|
|
||||||
xmin = -buffer;
|
xmin = -buffer;
|
||||||
ymin = -buffer;
|
ymin = -buffer;
|
||||||
|
|||||||
Reference in New Issue
Block a user