parent
c36d62e0d1
commit
fd092aa4dd
@ -562,7 +562,7 @@ public class XmlThemeBuilder extends DefaultHandler {
|
|||||||
b.fixed = parseBoolean(value);
|
b.fixed = parseBoolean(value);
|
||||||
|
|
||||||
else if ("stipple".equals(name))
|
else if ("stipple".equals(name))
|
||||||
b.stipple = Math.round(parseInt(value) * mScale * mStrokeScale);
|
b.stipple = (int) (parseInt(value) * mScale * mStrokeScale);
|
||||||
|
|
||||||
else if ("stipple-stroke".equals(name))
|
else if ("stipple-stroke".equals(name))
|
||||||
b.stippleColor(value);
|
b.stippleColor(value);
|
||||||
@ -615,12 +615,16 @@ public class XmlThemeBuilder extends DefaultHandler {
|
|||||||
if (b.dashArray.length == 1) {
|
if (b.dashArray.length == 1) {
|
||||||
b.randomOffset = false;
|
b.randomOffset = false;
|
||||||
b.stipple = b.dashArray[0] < 1 ? 1 : (int) b.dashArray[0];
|
b.stipple = b.dashArray[0] < 1 ? 1 : (int) b.dashArray[0];
|
||||||
if (mTheme.isMapsforgeTheme())
|
|
||||||
b.stipple *= Parameters.MAPSFORGE_DASH_FACTOR;
|
|
||||||
b.stippleWidth = 1;
|
b.stippleWidth = 1;
|
||||||
b.stippleColor = Color.TRANSPARENT;
|
b.stippleColor = Color.TRANSPARENT;
|
||||||
b.dashArray = null;
|
b.dashArray = null;
|
||||||
} else {
|
} else {
|
||||||
|
// Min dash is 1
|
||||||
|
float factor = 1;
|
||||||
|
for (float f : b.dashArray) {
|
||||||
|
if (0 < f && f < 1)
|
||||||
|
factor = Math.max(factor, 1 / f);
|
||||||
|
}
|
||||||
// Odd number of entries is duplicated
|
// Odd number of entries is duplicated
|
||||||
if (b.dashArray.length % 2 != 0) {
|
if (b.dashArray.length % 2 != 0) {
|
||||||
float[] newDashArray = new float[b.dashArray.length * 2];
|
float[] newDashArray = new float[b.dashArray.length * 2];
|
||||||
@ -631,10 +635,7 @@ public class XmlThemeBuilder extends DefaultHandler {
|
|||||||
int width = 0;
|
int width = 0;
|
||||||
int height = b.strokeWidth < 1 ? 1 : (int) b.strokeWidth;
|
int height = b.strokeWidth < 1 ? 1 : (int) b.strokeWidth;
|
||||||
for (float f : b.dashArray) {
|
for (float f : b.dashArray) {
|
||||||
if (f < 1)
|
f *= factor;
|
||||||
f = 1;
|
|
||||||
if (mTheme.isMapsforgeTheme())
|
|
||||||
f *= Parameters.MAPSFORGE_DASH_FACTOR;
|
|
||||||
width += f;
|
width += f;
|
||||||
}
|
}
|
||||||
Bitmap bitmap = CanvasAdapter.newBitmap(width, height, 0);
|
Bitmap bitmap = CanvasAdapter.newBitmap(width, height, 0);
|
||||||
@ -643,10 +644,7 @@ public class XmlThemeBuilder extends DefaultHandler {
|
|||||||
int x = 0;
|
int x = 0;
|
||||||
boolean transparent = false;
|
boolean transparent = false;
|
||||||
for (float f : b.dashArray) {
|
for (float f : b.dashArray) {
|
||||||
if (f < 1)
|
f *= factor;
|
||||||
f = 1;
|
|
||||||
if (mTheme.isMapsforgeTheme())
|
|
||||||
f *= Parameters.MAPSFORGE_DASH_FACTOR;
|
|
||||||
canvas.fillRectangle(x, 0, f, height, transparent ? Color.TRANSPARENT : Color.WHITE);
|
canvas.fillRectangle(x, 0, f, height, transparent ? Color.TRANSPARENT : Color.WHITE);
|
||||||
x += f;
|
x += f;
|
||||||
transparent = !transparent;
|
transparent = !transparent;
|
||||||
|
@ -398,20 +398,8 @@ public final class LineTexBucket extends LineBucket {
|
|||||||
GLUtils.setColor(shader.uColor, line.stippleColor, 1);
|
GLUtils.setColor(shader.uColor, line.stippleColor, 1);
|
||||||
GLUtils.setColor(shader.uBgColor, line.color, 1);
|
GLUtils.setColor(shader.uBgColor, line.color, 1);
|
||||||
|
|
||||||
float pScale;
|
/* keep line stipple fixed */
|
||||||
if (s >= 1) {
|
gl.uniform1f(shader.uPatternScale, (lb.scale * line.stipple) / (s + 1) * COORD_SCALE);
|
||||||
pScale = line.stipple * s;
|
|
||||||
float cnt = pScale / line.stipple;
|
|
||||||
pScale = line.stipple / (cnt + 1);
|
|
||||||
} else {
|
|
||||||
pScale = line.stipple / s;
|
|
||||||
float cnt = pScale / line.stipple;
|
|
||||||
pScale = line.stipple * cnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
//log.debug("pScale {} {}", pScale, s);
|
|
||||||
|
|
||||||
gl.uniform1f(shader.uPatternScale, COORD_SCALE * pScale);
|
|
||||||
|
|
||||||
gl.uniform1f(shader.uPatternWidth, line.stippleWidth);
|
gl.uniform1f(shader.uPatternWidth, line.stippleWidth);
|
||||||
|
|
||||||
|
@ -582,7 +582,7 @@ public class XmlThemeBuilder {
|
|||||||
b.fixed = Boolean.parseBoolean(value);
|
b.fixed = Boolean.parseBoolean(value);
|
||||||
|
|
||||||
else if ("stipple".equals(name))
|
else if ("stipple".equals(name))
|
||||||
b.stipple = Math.round(Integer.parseInt(value) * mScale * mStrokeScale);
|
b.stipple = (int) (Integer.parseInt(value) * mScale * mStrokeScale);
|
||||||
|
|
||||||
else if ("stipple-stroke".equals(name))
|
else if ("stipple-stroke".equals(name))
|
||||||
b.stippleColor(value);
|
b.stippleColor(value);
|
||||||
@ -635,12 +635,16 @@ public class XmlThemeBuilder {
|
|||||||
if (b.dashArray.length == 1) {
|
if (b.dashArray.length == 1) {
|
||||||
b.randomOffset = false;
|
b.randomOffset = false;
|
||||||
b.stipple = b.dashArray[0] < 1 ? 1 : (int) b.dashArray[0];
|
b.stipple = b.dashArray[0] < 1 ? 1 : (int) b.dashArray[0];
|
||||||
if (mTheme.isMapsforgeTheme())
|
|
||||||
b.stipple *= Parameters.MAPSFORGE_DASH_FACTOR;
|
|
||||||
b.stippleWidth = 1;
|
b.stippleWidth = 1;
|
||||||
b.stippleColor = Color.TRANSPARENT;
|
b.stippleColor = Color.TRANSPARENT;
|
||||||
b.dashArray = null;
|
b.dashArray = null;
|
||||||
} else {
|
} else {
|
||||||
|
// Min dash is 1
|
||||||
|
float factor = 1;
|
||||||
|
for (float f : b.dashArray) {
|
||||||
|
if (0 < f && f < 1)
|
||||||
|
factor = Math.max(factor, 1 / f);
|
||||||
|
}
|
||||||
// Odd number of entries is duplicated
|
// Odd number of entries is duplicated
|
||||||
if (b.dashArray.length % 2 != 0) {
|
if (b.dashArray.length % 2 != 0) {
|
||||||
float[] newDashArray = new float[b.dashArray.length * 2];
|
float[] newDashArray = new float[b.dashArray.length * 2];
|
||||||
@ -651,10 +655,7 @@ public class XmlThemeBuilder {
|
|||||||
int width = 0;
|
int width = 0;
|
||||||
int height = b.strokeWidth < 1 ? 1 : (int) b.strokeWidth;
|
int height = b.strokeWidth < 1 ? 1 : (int) b.strokeWidth;
|
||||||
for (float f : b.dashArray) {
|
for (float f : b.dashArray) {
|
||||||
if (f < 1)
|
f *= factor;
|
||||||
f = 1;
|
|
||||||
if (mTheme.isMapsforgeTheme())
|
|
||||||
f *= Parameters.MAPSFORGE_DASH_FACTOR;
|
|
||||||
width += f;
|
width += f;
|
||||||
}
|
}
|
||||||
Bitmap bitmap = CanvasAdapter.newBitmap(width, height, 0);
|
Bitmap bitmap = CanvasAdapter.newBitmap(width, height, 0);
|
||||||
@ -663,10 +664,7 @@ public class XmlThemeBuilder {
|
|||||||
int x = 0;
|
int x = 0;
|
||||||
boolean transparent = false;
|
boolean transparent = false;
|
||||||
for (float f : b.dashArray) {
|
for (float f : b.dashArray) {
|
||||||
if (f < 1)
|
f *= factor;
|
||||||
f = 1;
|
|
||||||
if (mTheme.isMapsforgeTheme())
|
|
||||||
f *= Parameters.MAPSFORGE_DASH_FACTOR;
|
|
||||||
canvas.fillRectangle(x, 0, f, height, transparent ? Color.TRANSPARENT : Color.WHITE);
|
canvas.fillRectangle(x, 0, f, height, transparent ? Color.TRANSPARENT : Color.WHITE);
|
||||||
x += f;
|
x += f;
|
||||||
transparent = !transparent;
|
transparent = !transparent;
|
||||||
|
@ -48,11 +48,6 @@ public final class Parameters {
|
|||||||
*/
|
*/
|
||||||
public static boolean MAP_EVENT_LAYER2 = false;
|
public static boolean MAP_EVENT_LAYER2 = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* Dash factor for Mapsforge themes.
|
|
||||||
*/
|
|
||||||
public static float MAPSFORGE_DASH_FACTOR = 1;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If true the markers are sorted in y-axis.
|
* If true the markers are sorted in y-axis.
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user