diff --git a/docs/Changelog.md b/docs/Changelog.md index 5908d996..3e0540de 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -11,8 +11,9 @@ - Overpass tile source [#663](https://github.com/mapsforge/vtm/issues/663) - vtm-gdx-poi3d module [#600](https://github.com/mapsforge/vtm/pull/600) - 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 +- `ThemeCallback.getColor` refactor [#274](https://github.com/mapsforge/vtm/issues/274) - Enable physical fling and fling on rotation / scale - `Parameters.ANIMATOR2` - Enable optimal placement of labels or symbols on polygons diff --git a/vtm/src/org/oscim/theme/ThemeCallback.java b/vtm/src/org/oscim/theme/ThemeCallback.java index 617d68eb..256fe6f5 100644 --- a/vtm/src/org/oscim/theme/ThemeCallback.java +++ b/vtm/src/org/oscim/theme/ThemeCallback.java @@ -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 * terms of the GNU Lesser General Public License as published by the Free Software @@ -14,6 +14,8 @@ */ package org.oscim.theme; +import org.oscim.theme.styles.RenderStyle; + /** * Callback methods for render theme. */ @@ -21,5 +23,5 @@ public interface ThemeCallback { /** * @return the color-int */ - int getColor(int color); + int getColor(RenderStyle origin, int color); } diff --git a/vtm/src/org/oscim/theme/XmlThemeBuilder.java b/vtm/src/org/oscim/theme/XmlThemeBuilder.java index 9ec2379c..22e79d32 100644 --- a/vtm/src/org/oscim/theme/XmlThemeBuilder.java +++ b/vtm/src/org/oscim/theme/XmlThemeBuilder.java @@ -926,7 +926,7 @@ public class XmlThemeBuilder extends DefaultHandler { else if ("map-background".equals(name)) { mapBackground = Color.parseColor(value); if (mThemeCallback != null) - mapBackground = mThemeCallback.getColor(mapBackground); + mapBackground = mThemeCallback.getColor(null, mapBackground); } else if ("base-stroke-width".equals(name)) baseStrokeWidth = Float.parseFloat(value); diff --git a/vtm/src/org/oscim/theme/styles/AreaStyle.java b/vtm/src/org/oscim/theme/styles/AreaStyle.java index 042b227c..169d3e63 100644 --- a/vtm/src/org/oscim/theme/styles/AreaStyle.java +++ b/vtm/src/org/oscim/theme/styles/AreaStyle.java @@ -1,7 +1,7 @@ /* * Copyright 2010, 2011, 2012 mapsforge.org * Copyright 2014 Hannes Janetzek - * Copyright 2016-2017 devemux86 + * Copyright 2016-2019 devemux86 * * 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; -/*TODO +/** + * TODO * - add custom shaders * - create distance field per tile? */ @@ -112,11 +113,11 @@ public class AreaStyle extends RenderStyle { this.level = b.level; this.style = b.style; 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.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.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.mesh = b.mesh; @@ -200,11 +201,11 @@ public class AreaStyle extends RenderStyle { this.level = area.level; this.style = area.style; 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.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.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.mesh = area.mesh; diff --git a/vtm/src/org/oscim/theme/styles/CircleStyle.java b/vtm/src/org/oscim/theme/styles/CircleStyle.java index 3b573b49..2e939b01 100644 --- a/vtm/src/org/oscim/theme/styles/CircleStyle.java +++ b/vtm/src/org/oscim/theme/styles/CircleStyle.java @@ -1,7 +1,7 @@ /* * Copyright 2010, 2011, 2012 mapsforge.org * Copyright 2013 Hannes Janetzek - * Copyright 2016 devemux86 + * Copyright 2016-2019 devemux86 * * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). * @@ -46,8 +46,8 @@ public final class CircleStyle extends RenderStyle { this.cat = b.cat; this.radius = b.radius; this.scaleRadius = b.scaleRadius; - this.fillColor = b.themeCallback != null ? b.themeCallback.getColor(b.fillColor) : b.fillColor; - this.strokeColor = b.themeCallback != null ? b.themeCallback.getColor(b.strokeColor) : b.strokeColor; + this.fillColor = b.themeCallback != null ? b.themeCallback.getColor(this, b.fillColor) : b.fillColor; + this.strokeColor = b.themeCallback != null ? b.themeCallback.getColor(this, b.strokeColor) : b.strokeColor; this.strokeWidth = b.strokeWidth; this.level = b.level; } @@ -76,8 +76,8 @@ public final class CircleStyle extends RenderStyle { this.radius = circle.radius; this.scaleRadius = circle.scaleRadius; - this.fillColor = themeCallback != null ? themeCallback.getColor(circle.fillColor) : circle.fillColor; - this.strokeColor = themeCallback != null ? themeCallback.getColor(circle.strokeColor) : circle.strokeColor; + this.fillColor = themeCallback != null ? themeCallback.getColor(circle, circle.fillColor) : circle.fillColor; + this.strokeColor = themeCallback != null ? themeCallback.getColor(circle, circle.strokeColor) : circle.strokeColor; this.strokeWidth = circle.strokeWidth; this.cat = circle.cat; this.level = circle.level; diff --git a/vtm/src/org/oscim/theme/styles/ExtrusionStyle.java b/vtm/src/org/oscim/theme/styles/ExtrusionStyle.java index e7457776..6a62d679 100644 --- a/vtm/src/org/oscim/theme/styles/ExtrusionStyle.java +++ b/vtm/src/org/oscim/theme/styles/ExtrusionStyle.java @@ -1,6 +1,6 @@ /* * Copyright 2013 Hannes Janetzek - * Copyright 2016-2017 devemux86 + * Copyright 2016-2019 devemux86 * Copyright 2018-2019 Gustl22 * * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). @@ -50,9 +50,9 @@ public class ExtrusionStyle extends RenderStyle { this.cat = b.cat; this.level = b.level; - this.colorSide = b.themeCallback != null ? b.themeCallback.getColor(b.colorSide) : b.colorSide; - this.colorTop = b.themeCallback != null ? b.themeCallback.getColor(b.colorTop) : b.colorTop; - this.colorLine = b.themeCallback != null ? b.themeCallback.getColor(b.colorLine) : b.colorLine; + this.colorSide = b.themeCallback != null ? b.themeCallback.getColor(this, b.colorSide) : b.colorSide; + this.colorTop = b.themeCallback != null ? b.themeCallback.getColor(this, b.colorTop) : b.colorTop; + this.colorLine = b.themeCallback != null ? b.themeCallback.getColor(this, b.colorLine) : b.colorLine; this.colors = new float[16]; fillColors(colorSide, colorTop, colorLine, colors); @@ -129,9 +129,9 @@ public class ExtrusionStyle extends RenderStyle { this.cat = extrusion.cat; this.level = extrusion.level; - this.colorSide = themeCallback != null ? themeCallback.getColor(extrusion.colorSide) : extrusion.colorSide; - this.colorTop = themeCallback != null ? themeCallback.getColor(extrusion.colorTop) : extrusion.colorTop; - this.colorLine = themeCallback != null ? themeCallback.getColor(extrusion.colorLine) : extrusion.colorLine; + this.colorSide = themeCallback != null ? themeCallback.getColor(extrusion, extrusion.colorSide) : extrusion.colorSide; + this.colorTop = themeCallback != null ? themeCallback.getColor(extrusion, extrusion.colorTop) : extrusion.colorTop; + this.colorLine = themeCallback != null ? themeCallback.getColor(extrusion, extrusion.colorLine) : extrusion.colorLine; this.hsvHue = extrusion.hsv.hue; this.hsvSaturation = extrusion.hsv.saturation; this.hsvValue = extrusion.hsv.value; diff --git a/vtm/src/org/oscim/theme/styles/LineStyle.java b/vtm/src/org/oscim/theme/styles/LineStyle.java index 41328ec2..513b8166 100644 --- a/vtm/src/org/oscim/theme/styles/LineStyle.java +++ b/vtm/src/org/oscim/theme/styles/LineStyle.java @@ -1,7 +1,7 @@ /* * Copyright 2010, 2011, 2012 mapsforge.org * Copyright 2013 Hannes Janetzek - * Copyright 2016-2018 devemux86 + * Copyright 2016-2019 devemux86 * Copyright 2017 Longri * * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). @@ -110,7 +110,7 @@ public final class LineStyle extends RenderStyle { this.level = b.level; this.style = b.style; 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.outline = b.outline; this.fixed = b.fixed; @@ -118,7 +118,7 @@ public final class LineStyle extends RenderStyle { this.fadeScale = b.fadeScale; this.blur = b.blur; 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.texture = b.texture; @@ -180,7 +180,7 @@ public final class LineStyle extends RenderStyle { this.level = line.level; this.style = line.style; 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.outline = line.outline; this.fixed = line.fixed; @@ -188,7 +188,7 @@ public final class LineStyle extends RenderStyle { this.fadeScale = line.fadeScale; this.blur = line.blur; 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.texture = line.texture; diff --git a/vtm/src/org/oscim/theme/styles/TextStyle.java b/vtm/src/org/oscim/theme/styles/TextStyle.java index 059e69a2..1b511082 100644 --- a/vtm/src/org/oscim/theme/styles/TextStyle.java +++ b/vtm/src/org/oscim/theme/styles/TextStyle.java @@ -1,6 +1,6 @@ /* * Copyright 2013 Hannes Janetzek - * Copyright 2016-2017 devemux86 + * Copyright 2016-2019 devemux86 * Copyright 2016 Andrey Novikov * * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). @@ -188,11 +188,11 @@ public final class TextStyle extends RenderStyle { this.areaSize = text.areaSize; this.bitmap = text.bitmap; 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.fontStyle = text.fontStyle; 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.fontSize = text.fontSize; @@ -220,7 +220,7 @@ public final class TextStyle extends RenderStyle { //paint.setTextAlign(Align.CENTER); 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); if (b.strokeWidth > 0) { @@ -228,7 +228,7 @@ public final class TextStyle extends RenderStyle { stroke.setStyle(Paint.Style.STROKE); //stroke.setTextAlign(Align.CENTER); 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.setTextSize(b.fontSize); } else