Height offset in render styles, close #368

This commit is contained in:
Emux
2017-06-24 20:05:34 +03:00
parent 3041ab5515
commit 25f0310334
7 changed files with 69 additions and 22 deletions

View File

@@ -1,7 +1,7 @@
/* /*
* Copyright 2012 osmdroid authors: Viesturs Zarins, Martin Pearman * Copyright 2012 osmdroid authors: Viesturs Zarins, Martin Pearman
* Copyright 2012 Hannes Janetzek * Copyright 2012 Hannes Janetzek
* Copyright 2016 devemux86 * Copyright 2016-2017 devemux86
* Copyright 2016 Pedinel * Copyright 2016 Pedinel
* *
* 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,6 +50,7 @@ public class PathLayer extends VectorLayer {
public PathLayer(Map map, int lineColor, float lineWidth) { public PathLayer(Map map, int lineColor, float lineWidth) {
this(map, Style.builder() this(map, Style.builder()
.fixed(true)
.strokeColor(lineColor) .strokeColor(lineColor)
.strokeWidth(lineWidth) .strokeWidth(lineWidth)
.build()); .build());

View File

@@ -1,5 +1,6 @@
/* /*
* Copyright 2016 devemux86 * Copyright 2014 Hannes Janetzek
* Copyright 2016-2017 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).
* *
@@ -256,13 +257,12 @@ public class VectorLayer extends AbstractVectorLayer<Drawable> {
else else
ll = t.buckets.getLineTexBucket(level); ll = t.buckets.getLineTexBucket(level);
if (ll.line == null) { if (ll.line == null) {
if (style.stipple == 0 && style.texture == null)
ll.line = new LineStyle(style.strokeColor, style.strokeWidth, style.cap);
else
ll.line = LineStyle.builder() ll.line = LineStyle.builder()
.reset()
.cap(style.cap) .cap(style.cap)
.color(style.strokeColor) .color(style.strokeColor)
.fixed(style.fixed) .fixed(style.fixed)
.heightOffset(style.heightOffset)
.level(0) .level(0)
.randomOffset(style.randomOffset) .randomOffset(style.randomOffset)
.stipple(style.stipple) .stipple(style.stipple)

View File

@@ -1,5 +1,6 @@
/* /*
* Copyright 2016 devemux86 * Copyright 2014 Hannes Janetzek
* Copyright 2016-2017 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).
* *
@@ -50,6 +51,7 @@ public class Style {
public final float stippleWidth; public final float stippleWidth;
public final TextureItem texture; public final TextureItem texture;
public final float heightOffset;
public final boolean randomOffset; public final boolean randomOffset;
private Style(Builder builder) { private Style(Builder builder) {
@@ -71,6 +73,7 @@ public class Style {
stippleWidth = builder.stippleWidth; stippleWidth = builder.stippleWidth;
texture = builder.texture; texture = builder.texture;
heightOffset = builder.heightOffset;
randomOffset = builder.randomOffset; randomOffset = builder.randomOffset;
} }
@@ -103,6 +106,7 @@ public class Style {
public float stippleWidth = 1; public float stippleWidth = 1;
public TextureItem texture = null; public TextureItem texture = null;
public float heightOffset = 0;
public boolean randomOffset = true; public boolean randomOffset = true;
protected Builder() { protected Builder() {
@@ -228,6 +232,11 @@ public class Style {
return this; return this;
} }
public Builder heightOffset(float heightOffset) {
this.heightOffset = heightOffset;
return this;
}
public Builder randomOffset(boolean randomOffset) { public Builder randomOffset(boolean randomOffset) {
this.randomOffset = randomOffset; this.randomOffset = randomOffset;
return this; return this;

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* Copyright 2016 devemux86 * Copyright 2016-2017 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).
* *
@@ -633,6 +633,8 @@ public class LineBucket extends RenderBucket {
LineBucket lb = (LineBucket) b; LineBucket lb = (LineBucket) b;
LineStyle line = lb.line.current(); LineStyle line = lb.line.current();
if (line.heightOffset != lb.heightOffset)
lb.heightOffset = line.heightOffset;
if (lb.heightOffset != heightOffset) { if (lb.heightOffset != heightOffset) {
heightOffset = lb.heightOffset; heightOffset = lb.heightOffset;

View File

@@ -1,5 +1,6 @@
/* /*
* Copyright 2013 Hannes Janetzek * Copyright 2013 Hannes Janetzek
* Copyright 2017 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).
* *
@@ -182,7 +183,10 @@ public class MeshBucket extends RenderBucket {
for (; l != null && l.type == MESH; l = l.next) { for (; l != null && l.type == MESH; l = l.next) {
MeshBucket ml = (MeshBucket) l; MeshBucket ml = (MeshBucket) l;
AreaStyle area = ml.area.current();
if (area.heightOffset != ml.heightOffset)
ml.heightOffset = area.heightOffset;
if (ml.heightOffset != heightOffset) { if (ml.heightOffset != heightOffset) {
heightOffset = ml.heightOffset; heightOffset = ml.heightOffset;
@@ -193,7 +197,7 @@ public class MeshBucket extends RenderBucket {
if (ml.area == null) if (ml.area == null)
GLUtils.setColor(s.uColor, Color.BLUE, 0.4f); GLUtils.setColor(s.uColor, Color.BLUE, 0.4f);
else { else {
setColor(ml.area.current(), s, v.pos); setColor(area, s, v.pos);
} }
gl.vertexAttribPointer(s.aPos, 2, GL.SHORT, gl.vertexAttribPointer(s.aPos, 2, GL.SHORT,
false, 0, ml.vertexOffset); false, 0, ml.vertexOffset);

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 devemux86 * Copyright 2016-2017 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).
* *
@@ -78,6 +78,8 @@ public class AreaStyle extends RenderStyle<AreaStyle> {
*/ */
public final boolean mesh; public final boolean mesh;
public final float heightOffset;
public final int symbolWidth; public final int symbolWidth;
public final int symbolHeight; public final int symbolHeight;
public final int symbolPercent; public final int symbolPercent;
@@ -98,6 +100,8 @@ public class AreaStyle extends RenderStyle<AreaStyle> {
this.strokeWidth = 1; this.strokeWidth = 1;
this.mesh = false; this.mesh = false;
this.heightOffset = 0;
this.symbolWidth = 0; this.symbolWidth = 0;
this.symbolHeight = 0; this.symbolHeight = 0;
this.symbolPercent = 100; this.symbolPercent = 100;
@@ -115,6 +119,8 @@ public class AreaStyle extends RenderStyle<AreaStyle> {
this.strokeWidth = b.strokeWidth; this.strokeWidth = b.strokeWidth;
this.mesh = b.mesh; this.mesh = b.mesh;
this.heightOffset = b.heightOffset;
this.symbolWidth = b.symbolWidth; this.symbolWidth = b.symbolWidth;
this.symbolHeight = b.symbolHeight; this.symbolHeight = b.symbolHeight;
this.symbolPercent = b.symbolPercent; this.symbolPercent = b.symbolPercent;
@@ -176,6 +182,8 @@ public class AreaStyle extends RenderStyle<AreaStyle> {
public TextureItem texture; public TextureItem texture;
public float heightOffset;
public int symbolWidth; public int symbolWidth;
public int symbolHeight; public int symbolHeight;
public int symbolPercent; public int symbolPercent;
@@ -198,6 +206,8 @@ public class AreaStyle extends RenderStyle<AreaStyle> {
this.strokeWidth = area.strokeWidth; this.strokeWidth = area.strokeWidth;
this.mesh = area.mesh; this.mesh = area.mesh;
this.heightOffset = area.heightOffset;
this.symbolWidth = area.symbolWidth; this.symbolWidth = area.symbolWidth;
this.symbolHeight = area.symbolHeight; this.symbolHeight = area.symbolHeight;
this.symbolPercent = area.symbolPercent; this.symbolPercent = area.symbolPercent;
@@ -235,6 +245,11 @@ public class AreaStyle extends RenderStyle<AreaStyle> {
return self(); return self();
} }
public T heightOffset(float heightOffset) {
this.heightOffset = heightOffset;
return self();
}
public T symbolWidth(int symbolWidth) { public T symbolWidth(int symbolWidth) {
this.symbolWidth = symbolWidth; this.symbolWidth = symbolWidth;
return self(); return self();
@@ -262,6 +277,8 @@ public class AreaStyle extends RenderStyle<AreaStyle> {
texture = null; texture = null;
mesh = false; mesh = false;
heightOffset = 0;
symbolWidth = 0; symbolWidth = 0;
symbolHeight = 0; symbolHeight = 0;
symbolPercent = 100; symbolPercent = 100;

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-2017 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).
* *
@@ -41,6 +41,7 @@ public final class LineStyle extends RenderStyle<LineStyle> {
public final float stippleWidth; public final float stippleWidth;
public final TextureItem texture; public final TextureItem texture;
public final float heightOffset;
public final boolean randomOffset; public final boolean randomOffset;
public final int symbolWidth; public final int symbolWidth;
@@ -82,6 +83,7 @@ public final class LineStyle extends RenderStyle<LineStyle> {
this.blur = blur; this.blur = blur;
this.fadeScale = fadeScale; this.fadeScale = fadeScale;
this.heightOffset = 0;
this.randomOffset = randomOffset; this.randomOffset = randomOffset;
this.symbolWidth = 0; this.symbolWidth = 0;
@@ -103,6 +105,8 @@ public final class LineStyle extends RenderStyle<LineStyle> {
this.stippleColor = b.themeCallback != null ? b.themeCallback.getColor(b.stippleColor) : b.stippleColor; this.stippleColor = b.themeCallback != null ? b.themeCallback.getColor(b.stippleColor) : b.stippleColor;
this.stippleWidth = b.stippleWidth; this.stippleWidth = b.stippleWidth;
this.texture = b.texture; this.texture = b.texture;
this.heightOffset = b.heightOffset;
this.randomOffset = b.randomOffset; this.randomOffset = b.randomOffset;
this.symbolWidth = b.symbolWidth; this.symbolWidth = b.symbolWidth;
@@ -133,6 +137,7 @@ public final class LineStyle extends RenderStyle<LineStyle> {
public float stippleWidth; public float stippleWidth;
public TextureItem texture; public TextureItem texture;
public float heightOffset;
public boolean randomOffset; public boolean randomOffset;
public int symbolWidth; public int symbolWidth;
@@ -159,6 +164,8 @@ public final class LineStyle extends RenderStyle<LineStyle> {
this.stippleColor = themeCallback != null ? themeCallback.getColor(line.stippleColor) : line.stippleColor; this.stippleColor = themeCallback != null ? themeCallback.getColor(line.stippleColor) : line.stippleColor;
this.stippleWidth = line.stippleWidth; this.stippleWidth = line.stippleWidth;
this.texture = line.texture; this.texture = line.texture;
this.heightOffset = line.heightOffset;
this.randomOffset = line.randomOffset; this.randomOffset = line.randomOffset;
this.symbolWidth = line.symbolWidth; this.symbolWidth = line.symbolWidth;
@@ -218,6 +225,11 @@ public final class LineStyle extends RenderStyle<LineStyle> {
return self(); return self();
} }
public T heightOffset(float heightOffset) {
this.heightOffset = heightOffset;
return self();
}
public T randomOffset(boolean randomOffset) { public T randomOffset(boolean randomOffset) {
this.randomOffset = randomOffset; this.randomOffset = randomOffset;
return self(); return self();
@@ -243,6 +255,7 @@ public final class LineStyle extends RenderStyle<LineStyle> {
style = null; style = null;
fillColor = Color.BLACK; fillColor = Color.BLACK;
cap = Cap.ROUND; cap = Cap.ROUND;
outline = false;
strokeWidth = 1; strokeWidth = 1;
fixed = false; fixed = false;
@@ -254,6 +267,7 @@ public final class LineStyle extends RenderStyle<LineStyle> {
stippleColor = Color.BLACK; stippleColor = Color.BLACK;
texture = null; texture = null;
heightOffset = 0;
randomOffset = true; randomOffset = true;
symbolWidth = 0; symbolWidth = 0;