Render themes: allow caption symbols without texture atlas, #64
This commit is contained in:
parent
1cfae3a47f
commit
1d46b2f63a
@ -426,9 +426,12 @@ public class LabelPlacement {
|
|||||||
for (Label ti = mLabels; ti != null; ti = (Label) ti.next) {
|
for (Label ti = mLabels; ti != null; ti = (Label) ti.next) {
|
||||||
/* add caption symbols */
|
/* add caption symbols */
|
||||||
if (ti.text.caption) {
|
if (ti.text.caption) {
|
||||||
if (ti.text.texture != null) {
|
if (ti.text.bitmap != null || ti.text.texture != null) {
|
||||||
SymbolItem s = SymbolItem.pool.get();
|
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.x = ti.x;
|
||||||
s.y = ti.y;
|
s.y = ti.y;
|
||||||
s.billboard = true;
|
s.billboard = true;
|
||||||
|
@ -763,9 +763,17 @@ public class XmlThemeBuilder extends DefaultHandler {
|
|||||||
// NB: minus..
|
// NB: minus..
|
||||||
b.dy = -Float.parseFloat(value) * CanvasAdapter.dpi / 160;
|
b.dy = -Float.parseFloat(value) * CanvasAdapter.dpi / 160;
|
||||||
|
|
||||||
else if ("symbol".equals(name))
|
else if ("symbol".equals(name)) {
|
||||||
b.texture = getAtlasRegion(value);
|
String lowValue = value.toLowerCase(Locale.ENGLISH);
|
||||||
else if ("use".equals(name))
|
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 */
|
;/* ignore */
|
||||||
else
|
else
|
||||||
logUnknownAttribute(elementName, name, value, i);
|
logUnknownAttribute(elementName, name, value, i);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 Hannes Janetzek
|
* Copyright 2013 Hannes Janetzek
|
||||||
|
* 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).
|
||||||
*
|
*
|
||||||
@ -17,6 +18,7 @@
|
|||||||
package org.oscim.theme.styles;
|
package org.oscim.theme.styles;
|
||||||
|
|
||||||
import org.oscim.backend.CanvasAdapter;
|
import org.oscim.backend.CanvasAdapter;
|
||||||
|
import org.oscim.backend.canvas.Bitmap;
|
||||||
import org.oscim.backend.canvas.Color;
|
import org.oscim.backend.canvas.Color;
|
||||||
import org.oscim.backend.canvas.Paint;
|
import org.oscim.backend.canvas.Paint;
|
||||||
import org.oscim.backend.canvas.Paint.Align;
|
import org.oscim.backend.canvas.Paint.Align;
|
||||||
@ -34,6 +36,7 @@ public final class TextStyle extends RenderStyle {
|
|||||||
public boolean caption;
|
public boolean caption;
|
||||||
public float dy;
|
public float dy;
|
||||||
public int priority;
|
public int priority;
|
||||||
|
public Bitmap bitmap;
|
||||||
public TextureRegion texture;
|
public TextureRegion texture;
|
||||||
public FontFamily fontFamily;
|
public FontFamily fontFamily;
|
||||||
public FontStyle fontStyle;
|
public FontStyle fontStyle;
|
||||||
@ -46,6 +49,7 @@ public final class TextStyle extends RenderStyle {
|
|||||||
fontSize = 0;
|
fontSize = 0;
|
||||||
caption = false;
|
caption = false;
|
||||||
priority = Integer.MAX_VALUE;
|
priority = Integer.MAX_VALUE;
|
||||||
|
bitmap = null;
|
||||||
texture = null;
|
texture = null;
|
||||||
fillColor = Color.BLACK;
|
fillColor = Color.BLACK;
|
||||||
strokeColor = Color.BLACK;
|
strokeColor = Color.BLACK;
|
||||||
@ -94,6 +98,11 @@ public final class TextStyle extends RenderStyle {
|
|||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public T bitmap(Bitmap bitmap) {
|
||||||
|
this.bitmap = bitmap;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
public T texture(TextureRegion texture) {
|
public T texture(TextureRegion texture) {
|
||||||
this.texture = texture;
|
this.texture = texture;
|
||||||
return self();
|
return self();
|
||||||
@ -117,6 +126,7 @@ public final class TextStyle extends RenderStyle {
|
|||||||
fontSize = other.fontSize;
|
fontSize = other.fontSize;
|
||||||
caption = other.caption;
|
caption = other.caption;
|
||||||
priority = other.priority;
|
priority = other.priority;
|
||||||
|
bitmap = other.bitmap;
|
||||||
texture = other.texture;
|
texture = other.texture;
|
||||||
fillColor = other.fillColor;
|
fillColor = other.fillColor;
|
||||||
strokeColor = other.strokeColor;
|
strokeColor = other.strokeColor;
|
||||||
@ -131,6 +141,7 @@ public final class TextStyle extends RenderStyle {
|
|||||||
this.caption = style.caption;
|
this.caption = style.caption;
|
||||||
this.dy = style.dy;
|
this.dy = style.dy;
|
||||||
this.priority = style.priority;
|
this.priority = style.priority;
|
||||||
|
this.bitmap = style.bitmap;
|
||||||
this.texture = style.texture;
|
this.texture = style.texture;
|
||||||
this.fillColor = style.paint.getColor();
|
this.fillColor = style.paint.getColor();
|
||||||
this.fontFamily = FontFamily.DEFAULT;
|
this.fontFamily = FontFamily.DEFAULT;
|
||||||
@ -148,6 +159,7 @@ public final class TextStyle extends RenderStyle {
|
|||||||
this.caption = tb.caption;
|
this.caption = tb.caption;
|
||||||
this.dy = tb.dy;
|
this.dy = tb.dy;
|
||||||
this.priority = tb.priority;
|
this.priority = tb.priority;
|
||||||
|
this.bitmap = tb.bitmap;
|
||||||
this.texture = tb.texture;
|
this.texture = tb.texture;
|
||||||
|
|
||||||
paint = CanvasAdapter.newPaint();
|
paint = CanvasAdapter.newPaint();
|
||||||
@ -185,8 +197,15 @@ public final class TextStyle extends RenderStyle {
|
|||||||
public float fontHeight;
|
public float fontHeight;
|
||||||
public float fontDescent;
|
public float fontDescent;
|
||||||
|
|
||||||
|
public final Bitmap bitmap;
|
||||||
public final TextureRegion texture;
|
public final TextureRegion texture;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
if (bitmap != null)
|
||||||
|
bitmap.recycle();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void renderNode(Callback cb) {
|
public void renderNode(Callback cb) {
|
||||||
cb.renderText(this);
|
cb.renderText(this);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user