From c28d0db4aecd60ffb4f8f17308370e6107383617 Mon Sep 17 00:00:00 2001 From: Emux Date: Wed, 25 Oct 2023 16:59:29 +0300 Subject: [PATCH] Line scale option (#1075) --- docs/Changelog.md | 1 + vtm/src/org/oscim/backend/CanvasAdapter.java | 5 +++++ vtm/src/org/oscim/theme/XmlThemeBuilder.java | 12 ++++++------ 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/Changelog.md b/docs/Changelog.md index 591e61286..f3fb9c079 100644 --- a/docs/Changelog.md +++ b/docs/Changelog.md @@ -2,6 +2,7 @@ ## New since 0.20.0 +- Canvas adapter: line scale option [#1075](https://github.com/mapsforge/vtm/pull/1075) - Minor improvements and bug fixes - [Solved issues](https://github.com/mapsforge/vtm/issues?q=is%3Aclosed+milestone%3A0.21.0) diff --git a/vtm/src/org/oscim/backend/CanvasAdapter.java b/vtm/src/org/oscim/backend/CanvasAdapter.java index 623189af2..6fe8d12d6 100644 --- a/vtm/src/org/oscim/backend/CanvasAdapter.java +++ b/vtm/src/org/oscim/backend/CanvasAdapter.java @@ -61,6 +61,11 @@ public abstract class CanvasAdapter { */ public static Platform platform = Platform.UNKNOWN; + /** + * The line scale. + */ + public static float lineScale = 1; + /** * The symbol scale. */ diff --git a/vtm/src/org/oscim/theme/XmlThemeBuilder.java b/vtm/src/org/oscim/theme/XmlThemeBuilder.java index 778e34a9f..0b97760d4 100644 --- a/vtm/src/org/oscim/theme/XmlThemeBuilder.java +++ b/vtm/src/org/oscim/theme/XmlThemeBuilder.java @@ -565,7 +565,7 @@ else if ("stroke".equals(name)) b.color(value); else if ("width".equals(name) || "stroke-width".equals(name)) { - b.strokeWidth = Float.parseFloat(value) * mScale * mStrokeScale; + b.strokeWidth = Float.parseFloat(value) * mScale * mStrokeScale * CanvasAdapter.lineScale; if (line == null) { if (!isOutline) validateNonNegative("width", b.strokeWidth); @@ -582,7 +582,7 @@ else if ("fix".equals(name)) b.fixed = Boolean.parseBoolean(value); else if ("stipple".equals(name)) - b.stipple = (int) (Integer.parseInt(value) * mScale * mStrokeScale); + b.stipple = (int) (Integer.parseInt(value) * mScale * mStrokeScale * CanvasAdapter.lineScale); else if ("stipple-stroke".equals(name)) b.stippleColor(value); @@ -605,7 +605,7 @@ else if ("style".equals(name)) else if ("dasharray".equals(name) || "stroke-dasharray".equals(name)) { b.dashArray = parseFloatArray(value); for (int j = 0; j < b.dashArray.length; ++j) { - b.dashArray[j] = b.dashArray[j] * mScale * mStrokeScale; + b.dashArray[j] = b.dashArray[j] * mScale * mStrokeScale * CanvasAdapter.lineScale; } } else if ("symbol-width".equals(name)) @@ -763,7 +763,7 @@ else if ("stroke".equals(name)) else if ("stroke-width".equals(name)) { float strokeWidth = Float.parseFloat(value); validateNonNegative("stroke-width", strokeWidth); - b.strokeWidth = strokeWidth * mScale * mStrokeScale; + b.strokeWidth = strokeWidth * mScale * mStrokeScale * CanvasAdapter.lineScale; } else if ("fade".equals(name)) b.fadeScale = Integer.parseInt(value); @@ -1147,7 +1147,7 @@ private CircleStyle createCircle(String elementName, int level) { String value = mPullParser.getAttributeValue(i); if ("r".equals(name) || "radius".equals(name)) - b.radius(Float.parseFloat(value) * mScale * mStrokeScale); + b.radius(Float.parseFloat(value) * mScale * mStrokeScale * CanvasAdapter.lineScale); else if ("cat".equals(name)) b.cat(value); @@ -1162,7 +1162,7 @@ else if ("stroke".equals(name)) b.strokeColor(Color.parseColor(value)); else if ("stroke-width".equals(name)) - b.strokeWidth(Float.parseFloat(value) * mScale * mStrokeScale); + b.strokeWidth(Float.parseFloat(value) * mScale * mStrokeScale * CanvasAdapter.lineScale); else logUnknownAttribute(elementName, name, value, i);