add option for text priorities

This commit is contained in:
Hannes Janetzek 2013-02-11 10:08:05 +01:00
parent fab415057e
commit f2f93d180b
2 changed files with 10 additions and 8 deletions

View File

@ -50,8 +50,8 @@ public final class Text extends RenderInstruction {
int stroke = Color.BLACK;
float strokeWidth = 0;
String style = null;
// boolean caption = false;
float dy = 0;
int priority = Integer.MAX_VALUE;
for (int i = 0; i < attributes.getLength(); ++i) {
String name = attributes.getLocalName(i);
@ -74,6 +74,8 @@ public final class Text extends RenderInstruction {
strokeWidth = Float.parseFloat(value);
} else if ("caption".equals(name)) {
caption = Boolean.parseBoolean(value);
} else if ("priority".equals(name)) {
priority = Integer.parseInt(value);
} else if ("dy".equals(name)) {
dy = Float.parseFloat(value);
} else {
@ -94,7 +96,7 @@ public final class Text extends RenderInstruction {
if (typeface == null)
typeface = Typeface.create(fontFamily.toTypeface(), fontStyle.toInt());
return new Text(style, textKey, typeface, fontSize, fill, stroke, strokeWidth, dy, caption);
return new Text(style, textKey, typeface, fontSize, fill, stroke, strokeWidth, dy, caption, priority);
}
private static Typeface typefaceNormal = Typeface.create(FontFamily.DEFAULT.toTypeface(),
@ -125,24 +127,24 @@ public final class Text extends RenderInstruction {
public String style;
public final boolean caption;
public final float dy;
public final int priority;
public float fontHeight;
public float fontDescent;
public static Text createText(float fontSize, float strokeWidth, int fill, int outline,
boolean billboard) {
return new Text("", "", typefaceNormal, fontSize, fill, outline, strokeWidth, 0, billboard);
return new Text("", "", typefaceNormal, fontSize, fill, outline, strokeWidth, 0, billboard, Integer.MAX_VALUE);
}
private Text(String style, String textKey, Typeface typeface, float fontSize,
int fill, int outline, float strokeWidth, float dy, boolean caption) {
// super();
int fill, int outline, float strokeWidth, float dy, boolean caption, int priority) {
this.style = style;
this.textKey = textKey;
this.caption = caption;
this.dy = dy;
this.priority = priority;
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setTextAlign(Align.CENTER);

View File

@ -4,8 +4,8 @@
xsi:schemaLocation="http://mapsforge.org/renderTheme ../renderTheme.xsd"
version="1" map-background="#fdfdfc">
<style-text name="road" k="name" font-size="16" fill="#101010" stroke="#ffffff" stroke-width="2.0" />
<style-text name="major-road" k="name" font-style="bold" font-size="16" fill="#101010" stroke="#ffffff" stroke-width="2.0" />
<style-text name="road" k="name" font-size="16" fill="#101010" stroke="#ffffff" stroke-width="2.0" priority="2"/>
<style-text name="major-road" k="name" font-style="bold" font-size="16" fill="#101010" stroke="#ffffff" stroke-width="2.0" priority="1"/>
<style-area name="residential" fill="#f0eee8" fade="10"/>