diff --git a/vtm/src/org/oscim/layers/tile/vector/labeling/LabelPlacement.java b/vtm/src/org/oscim/layers/tile/vector/labeling/LabelPlacement.java index 3d33aba9..efddf395 100644 --- a/vtm/src/org/oscim/layers/tile/vector/labeling/LabelPlacement.java +++ b/vtm/src/org/oscim/layers/tile/vector/labeling/LabelPlacement.java @@ -426,9 +426,12 @@ public class LabelPlacement { for (Label ti = mLabels; ti != null; ti = (Label) ti.next) { /* add caption symbols */ if (ti.text.caption) { - if (ti.text.texture != null) { + if (ti.text.bitmap != null || ti.text.texture != null) { SymbolItem s = SymbolItem.pool.get(); - s.texRegion = ti.text.texture; + if (ti.text.bitmap != null) + s.bitmap = ti.text.bitmap; + else + s.texRegion = ti.text.texture; s.x = ti.x; s.y = ti.y; s.billboard = true; diff --git a/vtm/src/org/oscim/theme/XmlThemeBuilder.java b/vtm/src/org/oscim/theme/XmlThemeBuilder.java index 8be63bec..da35d0c3 100644 --- a/vtm/src/org/oscim/theme/XmlThemeBuilder.java +++ b/vtm/src/org/oscim/theme/XmlThemeBuilder.java @@ -763,9 +763,17 @@ public class XmlThemeBuilder extends DefaultHandler { // NB: minus.. b.dy = -Float.parseFloat(value) * CanvasAdapter.dpi / 160; - else if ("symbol".equals(name)) - b.texture = getAtlasRegion(value); - else if ("use".equals(name)) + else if ("symbol".equals(name)) { + String lowValue = value.toLowerCase(Locale.ENGLISH); + if (lowValue.endsWith(".png") || lowValue.endsWith(".svg")) { + try { + b.bitmap = CanvasAdapter.getBitmapAsset(mRelativePathPrefix, value); + } catch (Exception e) { + log.debug(e.getMessage()); + } + } else + b.texture = getAtlasRegion(value); + } else if ("use".equals(name)) ;/* ignore */ else logUnknownAttribute(elementName, name, value, i); diff --git a/vtm/src/org/oscim/theme/styles/TextStyle.java b/vtm/src/org/oscim/theme/styles/TextStyle.java index 4ff14baa..5d479903 100644 --- a/vtm/src/org/oscim/theme/styles/TextStyle.java +++ b/vtm/src/org/oscim/theme/styles/TextStyle.java @@ -1,5 +1,6 @@ /* * Copyright 2013 Hannes Janetzek + * Copyright 2016 devemux86 * * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * @@ -17,6 +18,7 @@ package org.oscim.theme.styles; import org.oscim.backend.CanvasAdapter; +import org.oscim.backend.canvas.Bitmap; import org.oscim.backend.canvas.Color; import org.oscim.backend.canvas.Paint; import org.oscim.backend.canvas.Paint.Align; @@ -34,6 +36,7 @@ public final class TextStyle extends RenderStyle { public boolean caption; public float dy; public int priority; + public Bitmap bitmap; public TextureRegion texture; public FontFamily fontFamily; public FontStyle fontStyle; @@ -46,6 +49,7 @@ public final class TextStyle extends RenderStyle { fontSize = 0; caption = false; priority = Integer.MAX_VALUE; + bitmap = null; texture = null; fillColor = Color.BLACK; strokeColor = Color.BLACK; @@ -94,6 +98,11 @@ public final class TextStyle extends RenderStyle { return self(); } + public T bitmap(Bitmap bitmap) { + this.bitmap = bitmap; + return self(); + } + public T texture(TextureRegion texture) { this.texture = texture; return self(); @@ -117,6 +126,7 @@ public final class TextStyle extends RenderStyle { fontSize = other.fontSize; caption = other.caption; priority = other.priority; + bitmap = other.bitmap; texture = other.texture; fillColor = other.fillColor; strokeColor = other.strokeColor; @@ -131,6 +141,7 @@ public final class TextStyle extends RenderStyle { this.caption = style.caption; this.dy = style.dy; this.priority = style.priority; + this.bitmap = style.bitmap; this.texture = style.texture; this.fillColor = style.paint.getColor(); this.fontFamily = FontFamily.DEFAULT; @@ -148,6 +159,7 @@ public final class TextStyle extends RenderStyle { this.caption = tb.caption; this.dy = tb.dy; this.priority = tb.priority; + this.bitmap = tb.bitmap; this.texture = tb.texture; paint = CanvasAdapter.newPaint(); @@ -185,8 +197,15 @@ public final class TextStyle extends RenderStyle { public float fontHeight; public float fontDescent; + public final Bitmap bitmap; public final TextureRegion texture; + @Override + public void dispose() { + if (bitmap != null) + bitmap.recycle(); + } + @Override public void renderNode(Callback cb) { cb.renderText(this);