Skip to content

Commit

Permalink
Line scale option
Browse files Browse the repository at this point in the history
  • Loading branch information
devemux86 committed Oct 25, 2023
1 parent 7e1afa6 commit 06e8192
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions docs/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 5 additions & 0 deletions vtm/src/org/oscim/backend/CanvasAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
12 changes: 6 additions & 6 deletions vtm/src/org/oscim/theme/XmlThemeBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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))
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 06e8192

Please sign in to comment.