use dpi for label size
This commit is contained in:
parent
43a116708d
commit
3b67e4a3d1
@ -121,12 +121,14 @@ public final class Text extends RenderInstruction {
|
|||||||
public final Paint paint;
|
public final Paint paint;
|
||||||
public Paint stroke;
|
public Paint stroke;
|
||||||
public String textKey;
|
public String textKey;
|
||||||
public final float fontHeight;
|
|
||||||
public final float fontDescent;
|
|
||||||
public String style;
|
public String style;
|
||||||
public final boolean caption;
|
public final boolean caption;
|
||||||
public final float dy;
|
public final float dy;
|
||||||
|
|
||||||
|
public float fontHeight;
|
||||||
|
public float fontDescent;
|
||||||
|
|
||||||
public static Text createText(float fontSize, float strokeWidth, int fill, int outline,
|
public static Text createText(float fontSize, float strokeWidth, int fill, int outline,
|
||||||
boolean billboard) {
|
boolean billboard) {
|
||||||
|
|
||||||
@ -183,6 +185,11 @@ public final class Text extends RenderInstruction {
|
|||||||
@Override
|
@Override
|
||||||
public void scaleTextSize(float scaleFactor) {
|
public void scaleTextSize(float scaleFactor) {
|
||||||
paint.setTextSize(fontSize * scaleFactor);
|
paint.setTextSize(fontSize * scaleFactor);
|
||||||
stroke.setTextSize(fontSize * scaleFactor);
|
if (stroke != null)
|
||||||
|
stroke.setTextSize(fontSize * scaleFactor);
|
||||||
|
|
||||||
|
FontMetrics fm = paint.getFontMetrics();
|
||||||
|
fontHeight = (float) Math.ceil(Math.abs(fm.bottom) + Math.abs(fm.top));
|
||||||
|
fontDescent = (float) Math.ceil(Math.abs(fm.descent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,7 @@ import org.xml.sax.SAXException;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
@ -82,7 +83,7 @@ public class MapView extends RelativeLayout {
|
|||||||
private final TouchHandler mTouchEventHandler;
|
private final TouchHandler mTouchEventHandler;
|
||||||
private final Compass mCompass;
|
private final Compass mCompass;
|
||||||
|
|
||||||
private TileManager mTileManager;
|
private final TileManager mTileManager;
|
||||||
private final OverlayManager mOverlayManager;
|
private final OverlayManager mOverlayManager;
|
||||||
|
|
||||||
private final GLView mGLView;
|
private final GLView mGLView;
|
||||||
@ -102,6 +103,8 @@ public class MapView extends RelativeLayout {
|
|||||||
// FIXME: keep until old pbmap reader is removed
|
// FIXME: keep until old pbmap reader is removed
|
||||||
public static boolean enableClosePolygons = false;
|
public static boolean enableClosePolygons = false;
|
||||||
|
|
||||||
|
public final float dpi;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param context
|
* @param context
|
||||||
* the enclosing MapActivity instance.
|
* the enclosing MapActivity instance.
|
||||||
@ -133,6 +136,11 @@ public class MapView extends RelativeLayout {
|
|||||||
|
|
||||||
this.setWillNotDraw(true);
|
this.setWillNotDraw(true);
|
||||||
|
|
||||||
|
DisplayMetrics metrics = getResources().getDisplayMetrics();
|
||||||
|
dpi = Math.max(metrics.xdpi, metrics.ydpi);
|
||||||
|
|
||||||
|
Log.d(TAG, "dpi is: " + dpi);
|
||||||
|
|
||||||
// TODO set tilesize, make this dpi dependent
|
// TODO set tilesize, make this dpi dependent
|
||||||
Tile.TILE_SIZE = 400;
|
Tile.TILE_SIZE = 400;
|
||||||
|
|
||||||
@ -186,32 +194,6 @@ public class MapView extends RelativeLayout {
|
|||||||
mOverlayManager.add(new LabelingOverlay(this));
|
mOverlayManager.add(new LabelingOverlay(this));
|
||||||
|
|
||||||
// mOverlayManager.add(new GenericOverlay(this, new TestOverlay(this)));
|
// mOverlayManager.add(new GenericOverlay(this, new TestOverlay(this)));
|
||||||
|
|
||||||
// ArrayList<OverlayItem> pList = new ArrayList<OverlayItem>();
|
|
||||||
// pList.add(new OverlayItem("title", "description", new GeoPoint(53.067221, 8.78767)));
|
|
||||||
// Overlay overlay = new ItemizedIconOverlay<OverlayItem>(this, context, pList, null);
|
|
||||||
// mOverlayManager.add(overlay);
|
|
||||||
|
|
||||||
// ArrayList<OverlayItem> pList = new ArrayList<OverlayItem>();
|
|
||||||
// pList.add(new ExtendedOverlayItem("Bremen", "description",
|
|
||||||
// new GeoPoint(53.047221, 8.78767), context));
|
|
||||||
// pList.add(new ExtendedOverlayItem("New York", "description",
|
|
||||||
// new GeoPoint(40.4251, -74.021), context));
|
|
||||||
// pList.add(new ExtendedOverlayItem("Tokyo", "description",
|
|
||||||
// new GeoPoint(35.4122, 139.4130), context));
|
|
||||||
// Overlay overlay = new ItemizedOverlayWithBubble<OverlayItem>(this, context, pList, null);
|
|
||||||
// mOverlayManager.add(overlay);
|
|
||||||
|
|
||||||
// PathOverlay pathOverlay = new PathOverlay(this, Color.BLUE, context);
|
|
||||||
// pathOverlay.addGreatCircle(
|
|
||||||
// new GeoPoint(53.047221, 8.78767),
|
|
||||||
// new GeoPoint(40.4251, -74.021));
|
|
||||||
// // pathOverlay.addPoint(new GeoPoint(53.047221, 8.78767));
|
|
||||||
// // pathOverlay.addPoint(new GeoPoint(53.067221, 8.78767));
|
|
||||||
// mOverlayManager.add(pathOverlay);
|
|
||||||
|
|
||||||
// mMapViewPosition.animateTo(new GeoPoint(53.067221, 8.78767));
|
|
||||||
|
|
||||||
// if (testRegionZoom)
|
// if (testRegionZoom)
|
||||||
// mRegionLookup = new RegionLookup(this);
|
// mRegionLookup = new RegionLookup(this);
|
||||||
|
|
||||||
@ -451,7 +433,8 @@ public class MapView extends RelativeLayout {
|
|||||||
try {
|
try {
|
||||||
inputStream = theme.getRenderThemeAsStream();
|
inputStream = theme.getRenderThemeAsStream();
|
||||||
RenderTheme t = RenderThemeHandler.getRenderTheme(inputStream);
|
RenderTheme t = RenderThemeHandler.getRenderTheme(inputStream);
|
||||||
// FIXME somehow...
|
t.scaleTextSize(1 + (dpi / 240 - 1) * 0.5f);
|
||||||
|
// FIXME
|
||||||
GLRenderer.setRenderTheme(t);
|
GLRenderer.setRenderTheme(t);
|
||||||
TileGenerator.setRenderTheme(t);
|
TileGenerator.setRenderTheme(t);
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user