Render theme callback improvements, #274

This commit is contained in:
Emux 2019-03-22 13:18:05 +02:00
parent 71a4ba1c19
commit 2f27803fc5
No known key found for this signature in database
GPG Key ID: 64ED9980896038C3
8 changed files with 38 additions and 34 deletions

View File

@ -11,8 +11,9 @@
- Overpass tile source [#663](https://github.com/mapsforge/vtm/issues/663) - Overpass tile source [#663](https://github.com/mapsforge/vtm/issues/663)
- vtm-gdx-poi3d module [#600](https://github.com/mapsforge/vtm/pull/600) - vtm-gdx-poi3d module [#600](https://github.com/mapsforge/vtm/pull/600)
- vtm-models module [#580](https://github.com/mapsforge/vtm/issues/580) - vtm-models module [#580](https://github.com/mapsforge/vtm/issues/580)
- ViewController refactor [#625](https://github.com/mapsforge/vtm/pull/625) - `ViewController` refactor [#625](https://github.com/mapsforge/vtm/pull/625)
- `getMapViewCenter`, `setMapViewCenter` with pivotX, pivotY - `getMapViewCenter`, `setMapViewCenter` with pivotX, pivotY
- `ThemeCallback.getColor` refactor [#274](https://github.com/mapsforge/vtm/issues/274)
- Enable physical fling and fling on rotation / scale - Enable physical fling and fling on rotation / scale
- `Parameters.ANIMATOR2` - `Parameters.ANIMATOR2`
- Enable optimal placement of labels or symbols on polygons - Enable optimal placement of labels or symbols on polygons

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2016 devemux86 * Copyright 2016-2019 devemux86
* *
* This program is free software: you can redistribute it and/or modify it under the * This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software * terms of the GNU Lesser General Public License as published by the Free Software
@ -14,6 +14,8 @@
*/ */
package org.oscim.theme; package org.oscim.theme;
import org.oscim.theme.styles.RenderStyle;
/** /**
* Callback methods for render theme. * Callback methods for render theme.
*/ */
@ -21,5 +23,5 @@ public interface ThemeCallback {
/** /**
* @return the color-int * @return the color-int
*/ */
int getColor(int color); int getColor(RenderStyle origin, int color);
} }

View File

@ -926,7 +926,7 @@ public class XmlThemeBuilder extends DefaultHandler {
else if ("map-background".equals(name)) { else if ("map-background".equals(name)) {
mapBackground = Color.parseColor(value); mapBackground = Color.parseColor(value);
if (mThemeCallback != null) if (mThemeCallback != null)
mapBackground = mThemeCallback.getColor(mapBackground); mapBackground = mThemeCallback.getColor(null, mapBackground);
} else if ("base-stroke-width".equals(name)) } else if ("base-stroke-width".equals(name))
baseStrokeWidth = Float.parseFloat(value); baseStrokeWidth = Float.parseFloat(value);

View File

@ -1,7 +1,7 @@
/* /*
* Copyright 2010, 2011, 2012 mapsforge.org * Copyright 2010, 2011, 2012 mapsforge.org
* Copyright 2014 Hannes Janetzek * Copyright 2014 Hannes Janetzek
* Copyright 2016-2017 devemux86 * Copyright 2016-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).
* *
@ -24,7 +24,8 @@ import org.oscim.utils.FastMath;
import static org.oscim.backend.canvas.Color.parseColor; import static org.oscim.backend.canvas.Color.parseColor;
/*TODO /**
* TODO
* - add custom shaders * - add custom shaders
* - create distance field per tile? * - create distance field per tile?
*/ */
@ -112,11 +113,11 @@ public class AreaStyle extends RenderStyle<AreaStyle> {
this.level = b.level; this.level = b.level;
this.style = b.style; this.style = b.style;
this.fadeScale = b.fadeScale; this.fadeScale = b.fadeScale;
this.blendColor = b.themeCallback != null ? b.themeCallback.getColor(b.blendColor) : b.blendColor; this.blendColor = b.themeCallback != null ? b.themeCallback.getColor(this, b.blendColor) : b.blendColor;
this.blendScale = b.blendScale; this.blendScale = b.blendScale;
this.color = b.themeCallback != null ? b.themeCallback.getColor(b.fillColor) : b.fillColor; this.color = b.themeCallback != null ? b.themeCallback.getColor(this, b.fillColor) : b.fillColor;
this.texture = b.texture; this.texture = b.texture;
this.strokeColor = b.themeCallback != null ? b.themeCallback.getColor(b.strokeColor) : b.strokeColor; this.strokeColor = b.themeCallback != null ? b.themeCallback.getColor(this, b.strokeColor) : b.strokeColor;
this.strokeWidth = b.strokeWidth; this.strokeWidth = b.strokeWidth;
this.mesh = b.mesh; this.mesh = b.mesh;
@ -200,11 +201,11 @@ public class AreaStyle extends RenderStyle<AreaStyle> {
this.level = area.level; this.level = area.level;
this.style = area.style; this.style = area.style;
this.fadeScale = area.fadeScale; this.fadeScale = area.fadeScale;
this.blendColor = themeCallback != null ? themeCallback.getColor(area.blendColor) : area.blendColor; this.blendColor = themeCallback != null ? themeCallback.getColor(area, area.blendColor) : area.blendColor;
this.blendScale = area.blendScale; this.blendScale = area.blendScale;
this.fillColor = themeCallback != null ? themeCallback.getColor(area.color) : area.color; this.fillColor = themeCallback != null ? themeCallback.getColor(area, area.color) : area.color;
this.texture = area.texture; this.texture = area.texture;
this.strokeColor = themeCallback != null ? themeCallback.getColor(area.strokeColor) : area.strokeColor; this.strokeColor = themeCallback != null ? themeCallback.getColor(area, area.strokeColor) : area.strokeColor;
this.strokeWidth = area.strokeWidth; this.strokeWidth = area.strokeWidth;
this.mesh = area.mesh; this.mesh = area.mesh;

View File

@ -1,7 +1,7 @@
/* /*
* Copyright 2010, 2011, 2012 mapsforge.org * Copyright 2010, 2011, 2012 mapsforge.org
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* Copyright 2016 devemux86 * Copyright 2016-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).
* *
@ -46,8 +46,8 @@ public final class CircleStyle extends RenderStyle<CircleStyle> {
this.cat = b.cat; this.cat = b.cat;
this.radius = b.radius; this.radius = b.radius;
this.scaleRadius = b.scaleRadius; this.scaleRadius = b.scaleRadius;
this.fillColor = b.themeCallback != null ? b.themeCallback.getColor(b.fillColor) : b.fillColor; this.fillColor = b.themeCallback != null ? b.themeCallback.getColor(this, b.fillColor) : b.fillColor;
this.strokeColor = b.themeCallback != null ? b.themeCallback.getColor(b.strokeColor) : b.strokeColor; this.strokeColor = b.themeCallback != null ? b.themeCallback.getColor(this, b.strokeColor) : b.strokeColor;
this.strokeWidth = b.strokeWidth; this.strokeWidth = b.strokeWidth;
this.level = b.level; this.level = b.level;
} }
@ -76,8 +76,8 @@ public final class CircleStyle extends RenderStyle<CircleStyle> {
this.radius = circle.radius; this.radius = circle.radius;
this.scaleRadius = circle.scaleRadius; this.scaleRadius = circle.scaleRadius;
this.fillColor = themeCallback != null ? themeCallback.getColor(circle.fillColor) : circle.fillColor; this.fillColor = themeCallback != null ? themeCallback.getColor(circle, circle.fillColor) : circle.fillColor;
this.strokeColor = themeCallback != null ? themeCallback.getColor(circle.strokeColor) : circle.strokeColor; this.strokeColor = themeCallback != null ? themeCallback.getColor(circle, circle.strokeColor) : circle.strokeColor;
this.strokeWidth = circle.strokeWidth; this.strokeWidth = circle.strokeWidth;
this.cat = circle.cat; this.cat = circle.cat;
this.level = circle.level; this.level = circle.level;

View File

@ -1,6 +1,6 @@
/* /*
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* Copyright 2016-2017 devemux86 * Copyright 2016-2019 devemux86
* Copyright 2018-2019 Gustl22 * Copyright 2018-2019 Gustl22
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
@ -50,9 +50,9 @@ public class ExtrusionStyle extends RenderStyle<ExtrusionStyle> {
this.cat = b.cat; this.cat = b.cat;
this.level = b.level; this.level = b.level;
this.colorSide = b.themeCallback != null ? b.themeCallback.getColor(b.colorSide) : b.colorSide; this.colorSide = b.themeCallback != null ? b.themeCallback.getColor(this, b.colorSide) : b.colorSide;
this.colorTop = b.themeCallback != null ? b.themeCallback.getColor(b.colorTop) : b.colorTop; this.colorTop = b.themeCallback != null ? b.themeCallback.getColor(this, b.colorTop) : b.colorTop;
this.colorLine = b.themeCallback != null ? b.themeCallback.getColor(b.colorLine) : b.colorLine; this.colorLine = b.themeCallback != null ? b.themeCallback.getColor(this, b.colorLine) : b.colorLine;
this.colors = new float[16]; this.colors = new float[16];
fillColors(colorSide, colorTop, colorLine, colors); fillColors(colorSide, colorTop, colorLine, colors);
@ -129,9 +129,9 @@ public class ExtrusionStyle extends RenderStyle<ExtrusionStyle> {
this.cat = extrusion.cat; this.cat = extrusion.cat;
this.level = extrusion.level; this.level = extrusion.level;
this.colorSide = themeCallback != null ? themeCallback.getColor(extrusion.colorSide) : extrusion.colorSide; this.colorSide = themeCallback != null ? themeCallback.getColor(extrusion, extrusion.colorSide) : extrusion.colorSide;
this.colorTop = themeCallback != null ? themeCallback.getColor(extrusion.colorTop) : extrusion.colorTop; this.colorTop = themeCallback != null ? themeCallback.getColor(extrusion, extrusion.colorTop) : extrusion.colorTop;
this.colorLine = themeCallback != null ? themeCallback.getColor(extrusion.colorLine) : extrusion.colorLine; this.colorLine = themeCallback != null ? themeCallback.getColor(extrusion, extrusion.colorLine) : extrusion.colorLine;
this.hsvHue = extrusion.hsv.hue; this.hsvHue = extrusion.hsv.hue;
this.hsvSaturation = extrusion.hsv.saturation; this.hsvSaturation = extrusion.hsv.saturation;
this.hsvValue = extrusion.hsv.value; this.hsvValue = extrusion.hsv.value;

View File

@ -1,7 +1,7 @@
/* /*
* Copyright 2010, 2011, 2012 mapsforge.org * Copyright 2010, 2011, 2012 mapsforge.org
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* Copyright 2016-2018 devemux86 * Copyright 2016-2019 devemux86
* Copyright 2017 Longri * Copyright 2017 Longri
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
@ -110,7 +110,7 @@ public final class LineStyle extends RenderStyle<LineStyle> {
this.level = b.level; this.level = b.level;
this.style = b.style; this.style = b.style;
this.width = b.strokeWidth; this.width = b.strokeWidth;
this.color = b.themeCallback != null ? b.themeCallback.getColor(b.fillColor) : b.fillColor; this.color = b.themeCallback != null ? b.themeCallback.getColor(this, b.fillColor) : b.fillColor;
this.cap = b.cap; this.cap = b.cap;
this.outline = b.outline; this.outline = b.outline;
this.fixed = b.fixed; this.fixed = b.fixed;
@ -118,7 +118,7 @@ public final class LineStyle extends RenderStyle<LineStyle> {
this.fadeScale = b.fadeScale; this.fadeScale = b.fadeScale;
this.blur = b.blur; this.blur = b.blur;
this.stipple = b.stipple; this.stipple = b.stipple;
this.stippleColor = b.themeCallback != null ? b.themeCallback.getColor(b.stippleColor) : b.stippleColor; this.stippleColor = b.themeCallback != null ? b.themeCallback.getColor(this, b.stippleColor) : b.stippleColor;
this.stippleWidth = b.stippleWidth; this.stippleWidth = b.stippleWidth;
this.texture = b.texture; this.texture = b.texture;
@ -180,7 +180,7 @@ public final class LineStyle extends RenderStyle<LineStyle> {
this.level = line.level; this.level = line.level;
this.style = line.style; this.style = line.style;
this.strokeWidth = line.width; this.strokeWidth = line.width;
this.fillColor = themeCallback != null ? themeCallback.getColor(line.color) : line.color; this.fillColor = themeCallback != null ? themeCallback.getColor(line, line.color) : line.color;
this.cap = line.cap; this.cap = line.cap;
this.outline = line.outline; this.outline = line.outline;
this.fixed = line.fixed; this.fixed = line.fixed;
@ -188,7 +188,7 @@ public final class LineStyle extends RenderStyle<LineStyle> {
this.fadeScale = line.fadeScale; this.fadeScale = line.fadeScale;
this.blur = line.blur; this.blur = line.blur;
this.stipple = line.stipple; this.stipple = line.stipple;
this.stippleColor = themeCallback != null ? themeCallback.getColor(line.stippleColor) : line.stippleColor; this.stippleColor = themeCallback != null ? themeCallback.getColor(line, line.stippleColor) : line.stippleColor;
this.stippleWidth = line.stippleWidth; this.stippleWidth = line.stippleWidth;
this.texture = line.texture; this.texture = line.texture;

View File

@ -1,6 +1,6 @@
/* /*
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* Copyright 2016-2017 devemux86 * Copyright 2016-2019 devemux86
* Copyright 2016 Andrey Novikov * Copyright 2016 Andrey Novikov
* *
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
@ -188,11 +188,11 @@ public final class TextStyle extends RenderStyle<TextStyle> {
this.areaSize = text.areaSize; this.areaSize = text.areaSize;
this.bitmap = text.bitmap; this.bitmap = text.bitmap;
this.texture = text.texture; this.texture = text.texture;
this.fillColor = themeCallback != null ? themeCallback.getColor(text.paint.getColor()) : text.paint.getColor(); this.fillColor = themeCallback != null ? themeCallback.getColor(text, text.paint.getColor()) : text.paint.getColor();
this.fontFamily = text.fontFamily; this.fontFamily = text.fontFamily;
this.fontStyle = text.fontStyle; this.fontStyle = text.fontStyle;
if (text.stroke != null) { if (text.stroke != null) {
this.strokeColor = themeCallback != null ? themeCallback.getColor(text.stroke.getColor()) : text.stroke.getColor(); this.strokeColor = themeCallback != null ? themeCallback.getColor(text, text.stroke.getColor()) : text.stroke.getColor();
this.strokeWidth = text.stroke.getStrokeWidth(); this.strokeWidth = text.stroke.getStrokeWidth();
} }
this.fontSize = text.fontSize; this.fontSize = text.fontSize;
@ -220,7 +220,7 @@ public final class TextStyle extends RenderStyle<TextStyle> {
//paint.setTextAlign(Align.CENTER); //paint.setTextAlign(Align.CENTER);
paint.setTypeface(b.fontFamily, b.fontStyle); paint.setTypeface(b.fontFamily, b.fontStyle);
paint.setColor(b.themeCallback != null ? b.themeCallback.getColor(b.fillColor) : b.fillColor); paint.setColor(b.themeCallback != null ? b.themeCallback.getColor(this, b.fillColor) : b.fillColor);
paint.setTextSize(b.fontSize); paint.setTextSize(b.fontSize);
if (b.strokeWidth > 0) { if (b.strokeWidth > 0) {
@ -228,7 +228,7 @@ public final class TextStyle extends RenderStyle<TextStyle> {
stroke.setStyle(Paint.Style.STROKE); stroke.setStyle(Paint.Style.STROKE);
//stroke.setTextAlign(Align.CENTER); //stroke.setTextAlign(Align.CENTER);
stroke.setTypeface(b.fontFamily, b.fontStyle); stroke.setTypeface(b.fontFamily, b.fontStyle);
stroke.setColor(b.themeCallback != null ? b.themeCallback.getColor(b.strokeColor) : b.strokeColor); stroke.setColor(b.themeCallback != null ? b.themeCallback.getColor(this, b.strokeColor) : b.strokeColor);
stroke.setStrokeWidth(b.strokeWidth); stroke.setStrokeWidth(b.strokeWidth);
stroke.setTextSize(b.fontSize); stroke.setTextSize(b.fontSize);
} else } else