Render themes: text background color (highway shields)
This commit is contained in:
parent
e6137163b9
commit
dcb7b0d10c
@ -150,6 +150,7 @@
|
|||||||
<xs:attribute name="font-family" default="default" type="tns:fontFamily" use="optional" />
|
<xs:attribute name="font-family" default="default" type="tns:fontFamily" use="optional" />
|
||||||
<xs:attribute name="style" default="normal" type="tns:fontStyle" use="optional" />
|
<xs:attribute name="style" default="normal" type="tns:fontStyle" use="optional" />
|
||||||
<xs:attribute name="size" default="0" type="tns:nonNegativeFloat" use="optional" />
|
<xs:attribute name="size" default="0" type="tns:nonNegativeFloat" use="optional" />
|
||||||
|
<xs:attribute name="bg-fill" default="#00000000" type="tns:color" use="optional" />
|
||||||
<xs:attribute name="fill" default="#000000" type="tns:color" use="optional" />
|
<xs:attribute name="fill" default="#000000" type="tns:color" use="optional" />
|
||||||
<xs:attribute name="stroke" default="#000000" type="tns:color" use="optional" />
|
<xs:attribute name="stroke" default="#000000" type="tns:color" use="optional" />
|
||||||
<xs:attribute name="stroke-width" default="0" type="tns:nonNegativeFloat" use="optional" />
|
<xs:attribute name="stroke-width" default="0" type="tns:nonNegativeFloat" use="optional" />
|
||||||
@ -219,6 +220,7 @@
|
|||||||
<xs:attribute name="font-family" default="default" type="tns:fontFamily" use="optional" />
|
<xs:attribute name="font-family" default="default" type="tns:fontFamily" use="optional" />
|
||||||
<xs:attribute name="style" default="normal" type="tns:fontStyle" use="optional" />
|
<xs:attribute name="style" default="normal" type="tns:fontStyle" use="optional" />
|
||||||
<xs:attribute name="size" default="0" type="tns:nonNegativeFloat" use="optional" />
|
<xs:attribute name="size" default="0" type="tns:nonNegativeFloat" use="optional" />
|
||||||
|
<xs:attribute name="bg-fill" default="#00000000" type="tns:color" use="optional" />
|
||||||
<xs:attribute name="fill" default="#000000" type="tns:color" use="optional" />
|
<xs:attribute name="fill" default="#000000" type="tns:color" use="optional" />
|
||||||
<xs:attribute name="stroke" default="#000000" type="tns:color" use="optional" />
|
<xs:attribute name="stroke" default="#000000" type="tns:color" use="optional" />
|
||||||
<xs:attribute name="stroke-width" default="0" type="tns:nonNegativeFloat" use="optional" />
|
<xs:attribute name="stroke-width" default="0" type="tns:nonNegativeFloat" use="optional" />
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 Hannes Janetzek
|
* Copyright 2013 Hannes Janetzek
|
||||||
* Copyright 2016-2017 devemux86
|
* Copyright 2016-2019 devemux86
|
||||||
* Copyright 2017 nebular
|
* Copyright 2017 nebular
|
||||||
* Copyright 2017 Longri
|
* Copyright 2017 Longri
|
||||||
*
|
*
|
||||||
@ -21,8 +21,8 @@ package org.oscim.android.canvas;
|
|||||||
|
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.PorterDuff;
|
import android.graphics.PorterDuff;
|
||||||
|
import android.graphics.PorterDuffXfermode;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
|
|
||||||
import org.oscim.backend.canvas.Bitmap;
|
import org.oscim.backend.canvas.Bitmap;
|
||||||
import org.oscim.backend.canvas.Canvas;
|
import org.oscim.backend.canvas.Canvas;
|
||||||
import org.oscim.backend.canvas.Paint;
|
import org.oscim.backend.canvas.Paint;
|
||||||
@ -93,6 +93,7 @@ public class AndroidCanvas implements Canvas {
|
|||||||
RectF rect = new RectF(x, y, x + width, y + height);
|
RectF rect = new RectF(x, y, x + width, y + height);
|
||||||
android.graphics.Paint paint = new android.graphics.Paint();
|
android.graphics.Paint paint = new android.graphics.Paint();
|
||||||
paint.setColor(color);
|
paint.setColor(color);
|
||||||
|
paint.setXfermode(new PorterDuffXfermode(color == Color.TRANSPARENT ? PorterDuff.Mode.CLEAR : PorterDuff.Mode.SRC_OVER));
|
||||||
canvas.drawRect(rect, paint);
|
canvas.drawRect(rect, paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,7 +45,8 @@
|
|||||||
<!--references-->
|
<!--references-->
|
||||||
<style-text style="bold" fill="#606060" id="ref" k="ref" priority="2" size="12" stroke="#ffffff"
|
<style-text style="bold" fill="#606060" id="ref" k="ref" priority="2" size="12" stroke="#ffffff"
|
||||||
stroke-width="2.0" />
|
stroke-width="2.0" />
|
||||||
<style-text caption="true" id="ref-caption" use="ref" />
|
<style-text caption="true" style="bold" fill="#ffffff" id="ref-caption" k="ref" priority="2"
|
||||||
|
size="12" bg-fill="#45a976" />
|
||||||
<!--ferry-->
|
<!--ferry-->
|
||||||
<style-text style="bold" fill="#606060" id="ferry" k="name" size="12" stroke="#ffffff"
|
<style-text style="bold" fill="#606060" id="ferry" k="name" size="12" stroke="#ffffff"
|
||||||
stroke-width="2.0" />
|
stroke-width="2.0" />
|
||||||
|
@ -25,7 +25,8 @@
|
|||||||
|
|
||||||
<style-text style="bold" fill="#606060" id="ref" k="ref" priority="2" size="12" stroke="#ffffff"
|
<style-text style="bold" fill="#606060" id="ref" k="ref" priority="2" size="12" stroke="#ffffff"
|
||||||
stroke-width="2.0" />
|
stroke-width="2.0" />
|
||||||
<style-text caption="true" id="ref-caption" use="ref" />
|
<style-text caption="true" style="bold" fill="#ffffff" id="ref-caption" k="ref" priority="2"
|
||||||
|
size="12" bg-fill="#45a976" />
|
||||||
|
|
||||||
<style-text style="bold" fill="#606060" id="ferry" k="name" size="12" stroke="#ffffff"
|
<style-text style="bold" fill="#606060" id="ferry" k="name" size="12" stroke="#ffffff"
|
||||||
stroke-width="2.0" />
|
stroke-width="2.0" />
|
||||||
|
@ -35,7 +35,8 @@
|
|||||||
<!--references-->
|
<!--references-->
|
||||||
<style-text style="bold" fill="#606060" id="ref" k="ref" priority="2" size="12" stroke="#ffffff"
|
<style-text style="bold" fill="#606060" id="ref" k="ref" priority="2" size="12" stroke="#ffffff"
|
||||||
stroke-width="2.0" />
|
stroke-width="2.0" />
|
||||||
<style-text caption="true" id="ref-caption" use="ref" />
|
<style-text caption="true" style="bold" fill="#ffffff" id="ref-caption" k="ref" priority="2"
|
||||||
|
size="12" bg-fill="#45a976" />
|
||||||
|
|
||||||
|
|
||||||
<!--###### AREA styles ######-->
|
<!--###### AREA styles ######-->
|
||||||
|
@ -40,7 +40,8 @@
|
|||||||
<!--references-->
|
<!--references-->
|
||||||
<style-text style="bold" fill="#606060" id="ref" k="ref" priority="2" size="12" stroke="#ffffff"
|
<style-text style="bold" fill="#606060" id="ref" k="ref" priority="2" size="12" stroke="#ffffff"
|
||||||
stroke-width="2.0" />
|
stroke-width="2.0" />
|
||||||
<style-text caption="true" id="ref-caption" use="ref" />
|
<style-text caption="true" style="bold" fill="#ffffff" id="ref-caption" k="ref" priority="2"
|
||||||
|
size="12" bg-fill="#45a976" />
|
||||||
<!--ferry-->
|
<!--ferry-->
|
||||||
<style-text style="bold" fill="#606060" id="ferry" k="name" size="12" stroke="#ffffff"
|
<style-text style="bold" fill="#606060" id="ferry" k="name" size="12" stroke="#ffffff"
|
||||||
stroke-width="2.0" />
|
stroke-width="2.0" />
|
||||||
|
@ -34,7 +34,8 @@
|
|||||||
<!--references-->
|
<!--references-->
|
||||||
<style-text style="bold" fill="#606060" id="ref" k="ref" priority="2" size="12" stroke="#ffffff"
|
<style-text style="bold" fill="#606060" id="ref" k="ref" priority="2" size="12" stroke="#ffffff"
|
||||||
stroke-width="2.0" />
|
stroke-width="2.0" />
|
||||||
<style-text caption="true" id="ref-caption" use="ref" />
|
<style-text caption="true" style="bold" fill="#ffffff" id="ref-caption" k="ref" priority="2"
|
||||||
|
size="12" bg-fill="#5b5b5b" />
|
||||||
|
|
||||||
|
|
||||||
<!--###### AREA styles ######-->
|
<!--###### AREA styles ######-->
|
||||||
|
@ -34,7 +34,8 @@
|
|||||||
<!--references-->
|
<!--references-->
|
||||||
<style-text style="bold" fill="#606060" id="ref" k="ref" priority="2" size="12" stroke="#ffffff"
|
<style-text style="bold" fill="#606060" id="ref" k="ref" priority="2" size="12" stroke="#ffffff"
|
||||||
stroke-width="2.0" />
|
stroke-width="2.0" />
|
||||||
<style-text caption="true" id="ref-caption" use="ref" />
|
<style-text caption="true" style="bold" fill="#ffffff" id="ref-caption" k="ref" priority="2"
|
||||||
|
size="12" bg-fill="#007f00" />
|
||||||
|
|
||||||
|
|
||||||
<!--###### AREA styles ######-->
|
<!--###### AREA styles ######-->
|
||||||
|
@ -35,7 +35,8 @@
|
|||||||
<!--references-->
|
<!--references-->
|
||||||
<style-text style="bold" fill="#606060" id="ref" k="ref" priority="2" size="12" stroke="#ffffff"
|
<style-text style="bold" fill="#606060" id="ref" k="ref" priority="2" size="12" stroke="#ffffff"
|
||||||
stroke-width="2.0" />
|
stroke-width="2.0" />
|
||||||
<style-text caption="true" id="ref-caption" use="ref" />
|
<style-text caption="true" style="bold" fill="#ffffff" id="ref-caption" k="ref" priority="2"
|
||||||
|
size="12" bg-fill="#45a976" />
|
||||||
|
|
||||||
|
|
||||||
<!--###### AREA styles ######-->
|
<!--###### AREA styles ######-->
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012 Hannes Janetzek
|
* Copyright 2012 Hannes Janetzek
|
||||||
|
* Copyright 2019 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).
|
||||||
*
|
*
|
||||||
@ -89,7 +90,7 @@ public class TextBucket extends TextureBucket {
|
|||||||
int advanceY = 0;
|
int advanceY = 0;
|
||||||
float x = 0;
|
float x = 0;
|
||||||
float y = 0;
|
float y = 0;
|
||||||
float yy;
|
float xx, yy;
|
||||||
|
|
||||||
TextureItem t = pool.get();
|
TextureItem t = pool.get();
|
||||||
textures = t;
|
textures = t;
|
||||||
@ -127,14 +128,18 @@ public class TextBucket extends TextureBucket {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xx = x + mFontPadX;
|
||||||
yy = y + height - it.text.fontDescent;
|
yy = y + height - it.text.fontDescent;
|
||||||
|
|
||||||
mCanvas.drawText(it.label, x, yy, it.text.paint, it.text.stroke);
|
|
||||||
|
|
||||||
// FIXME !!!
|
// FIXME !!!
|
||||||
if (width > TEXTURE_WIDTH)
|
if (width > TEXTURE_WIDTH)
|
||||||
width = TEXTURE_WIDTH;
|
width = TEXTURE_WIDTH;
|
||||||
|
|
||||||
|
if (it.text.bgFill != null)
|
||||||
|
mCanvas.fillRectangle(x + mFontPadX, y + 1, width - 2 * mFontPadX, height, it.text.bgFill.getColor());
|
||||||
|
|
||||||
|
mCanvas.drawText(it.label, xx, yy, it.text.paint, it.text.stroke);
|
||||||
|
|
||||||
while (it != null) {
|
while (it != null) {
|
||||||
addItem(it, width, height, x, y);
|
addItem(it, width, height, x, y);
|
||||||
|
|
||||||
|
@ -1012,6 +1012,9 @@ public class XmlThemeBuilder extends DefaultHandler {
|
|||||||
else if ("size".equals(name) || "font-size".equals(name))
|
else if ("size".equals(name) || "font-size".equals(name))
|
||||||
b.fontSize = Float.parseFloat(value);
|
b.fontSize = Float.parseFloat(value);
|
||||||
|
|
||||||
|
else if ("bg-fill".equals(name))
|
||||||
|
b.bgFillColor = Color.parseColor(value);
|
||||||
|
|
||||||
else if ("fill".equals(name))
|
else if ("fill".equals(name))
|
||||||
b.fillColor = Color.parseColor(value);
|
b.fillColor = Color.parseColor(value);
|
||||||
|
|
||||||
|
@ -26,6 +26,8 @@ import org.oscim.backend.canvas.Paint.FontFamily;
|
|||||||
import org.oscim.backend.canvas.Paint.FontStyle;
|
import org.oscim.backend.canvas.Paint.FontStyle;
|
||||||
import org.oscim.renderer.atlas.TextureRegion;
|
import org.oscim.renderer.atlas.TextureRegion;
|
||||||
|
|
||||||
|
import static org.oscim.backend.canvas.Color.parseColor;
|
||||||
|
|
||||||
public final class TextStyle extends RenderStyle<TextStyle> {
|
public final class TextStyle extends RenderStyle<TextStyle> {
|
||||||
|
|
||||||
public static class TextBuilder<T extends TextBuilder<T>> extends StyleBuilder<T> {
|
public static class TextBuilder<T extends TextBuilder<T>> extends StyleBuilder<T> {
|
||||||
@ -46,6 +48,8 @@ public final class TextStyle extends RenderStyle<TextStyle> {
|
|||||||
public int symbolHeight;
|
public int symbolHeight;
|
||||||
public int symbolPercent;
|
public int symbolPercent;
|
||||||
|
|
||||||
|
public int bgFillColor;
|
||||||
|
|
||||||
public T reset() {
|
public T reset() {
|
||||||
cat = null;
|
cat = null;
|
||||||
fontFamily = FontFamily.DEFAULT;
|
fontFamily = FontFamily.DEFAULT;
|
||||||
@ -67,6 +71,8 @@ public final class TextStyle extends RenderStyle<TextStyle> {
|
|||||||
symbolHeight = 0;
|
symbolHeight = 0;
|
||||||
symbolPercent = 100;
|
symbolPercent = 100;
|
||||||
|
|
||||||
|
bgFillColor = Color.TRANSPARENT;
|
||||||
|
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,6 +157,16 @@ public final class TextStyle extends RenderStyle<TextStyle> {
|
|||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public T bgFillColor(int color) {
|
||||||
|
this.bgFillColor = color;
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
|
public T bgFillColor(String color) {
|
||||||
|
this.bgFillColor = parseColor(color);
|
||||||
|
return self();
|
||||||
|
}
|
||||||
|
|
||||||
public T from(TextBuilder<?> other) {
|
public T from(TextBuilder<?> other) {
|
||||||
cat = other.cat;
|
cat = other.cat;
|
||||||
fontFamily = other.fontFamily;
|
fontFamily = other.fontFamily;
|
||||||
@ -172,6 +188,8 @@ public final class TextStyle extends RenderStyle<TextStyle> {
|
|||||||
symbolHeight = other.symbolHeight;
|
symbolHeight = other.symbolHeight;
|
||||||
symbolPercent = other.symbolPercent;
|
symbolPercent = other.symbolPercent;
|
||||||
|
|
||||||
|
bgFillColor = other.bgFillColor;
|
||||||
|
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,6 +219,9 @@ public final class TextStyle extends RenderStyle<TextStyle> {
|
|||||||
this.symbolHeight = text.symbolHeight;
|
this.symbolHeight = text.symbolHeight;
|
||||||
this.symbolPercent = text.symbolPercent;
|
this.symbolPercent = text.symbolPercent;
|
||||||
|
|
||||||
|
if (text.bgFill != null)
|
||||||
|
this.bgFillColor = themeCallback != null ? themeCallback.getColor(text, text.bgFill.getColor()) : text.bgFill.getColor();
|
||||||
|
|
||||||
return self();
|
return self();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -241,6 +262,12 @@ public final class TextStyle extends RenderStyle<TextStyle> {
|
|||||||
this.symbolWidth = b.symbolWidth;
|
this.symbolWidth = b.symbolWidth;
|
||||||
this.symbolHeight = b.symbolHeight;
|
this.symbolHeight = b.symbolHeight;
|
||||||
this.symbolPercent = b.symbolPercent;
|
this.symbolPercent = b.symbolPercent;
|
||||||
|
|
||||||
|
if (b.bgFillColor != Color.TRANSPARENT) {
|
||||||
|
bgFill = CanvasAdapter.newPaint();
|
||||||
|
bgFill.setColor(b.themeCallback != null ? b.themeCallback.getColor(this, b.bgFillColor) : b.bgFillColor);
|
||||||
|
} else
|
||||||
|
bgFill = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final String style;
|
public final String style;
|
||||||
@ -267,6 +294,8 @@ public final class TextStyle extends RenderStyle<TextStyle> {
|
|||||||
public final int symbolHeight;
|
public final int symbolHeight;
|
||||||
public final int symbolPercent;
|
public final int symbolPercent;
|
||||||
|
|
||||||
|
public final Paint bgFill;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
if (bitmap != null)
|
if (bitmap != null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user