Drawable style point reduction / texture repeat options (#862)

This commit is contained in:
Emux
2021-07-25 13:59:01 +03:00
committed by GitHub
parent bd24ba12d5
commit b8983007d2
5 changed files with 56 additions and 24 deletions

View File

@@ -1,6 +1,6 @@
/*
* Copyright 2014 Hannes Janetzek
* Copyright 2016-2019 devemux86
* Copyright 2016-2021 devemux86
* Copyright 2020 marq24
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
@@ -32,6 +32,7 @@ import org.oscim.layers.vector.geometries.PointDrawable;
import org.oscim.layers.vector.geometries.Style;
import org.oscim.map.Map;
import org.oscim.renderer.bucket.LineBucket;
import org.oscim.renderer.bucket.LineTexBucket;
import org.oscim.renderer.bucket.MeshBucket;
import org.oscim.theme.styles.AreaStyle;
import org.oscim.theme.styles.LineStyle;
@@ -235,6 +236,7 @@ public class VectorLayer extends AbstractVectorLayer<Drawable> implements Gestur
LineBucket ll = t.buckets.getLineBucket(level + 1);
if (ll.line == null) {
ll.line = new LineStyle(2, style.strokeColor, style.strokeWidth);
ll.setDropDistance(style.pointReduction ? LineBucket.MIN_DIST : 0);
}
for (int i = 0; i < points.getNumGeometries(); i++) {
@@ -273,6 +275,9 @@ public class VectorLayer extends AbstractVectorLayer<Drawable> implements Gestur
.strokeWidth(style.strokeWidth)
.texture(style.texture)
.build();
ll.setDropDistance(style.pointReduction ? LineBucket.MIN_DIST : 0);
if (ll instanceof LineTexBucket)
((LineTexBucket) ll).setTexRepeat(style.textureRepeat);
}
if (!style.fixed && style.strokeIncrease > 1)
@@ -304,6 +309,7 @@ public class VectorLayer extends AbstractVectorLayer<Drawable> implements Gestur
LineBucket ll = t.buckets.getLineBucket(level + 1);
if (ll.line == null) {
ll.line = new LineStyle(2, style.strokeColor, style.strokeWidth);
ll.setDropDistance(style.pointReduction ? LineBucket.MIN_DIST : 0);
}
if (style.generalization != Style.GENERALIZATION_NONE) {

View File

@@ -1,6 +1,6 @@
/*
* Copyright 2014 Hannes Janetzek
* Copyright 2016-2019 devemux86
* Copyright 2016-2021 devemux86
*
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
*
@@ -52,6 +52,8 @@ public class Style {
public final int stippleColor;
public final float stippleWidth;
public final TextureItem texture;
public final boolean pointReduction;
public final boolean textureRepeat;
public final float heightOffset;
public final boolean randomOffset;
@@ -76,6 +78,8 @@ public class Style {
stippleColor = builder.stippleColor;
stippleWidth = builder.stippleWidth;
texture = builder.texture;
pointReduction = builder.pointReduction;
textureRepeat = builder.textureRepeat;
heightOffset = builder.heightOffset;
randomOffset = builder.randomOffset;
@@ -111,6 +115,8 @@ public class Style {
public int stippleColor = Color.GRAY;
public float stippleWidth = 1;
public TextureItem texture = null;
public boolean pointReduction = true;
public boolean textureRepeat = true;
public float heightOffset = 0;
public boolean randomOffset = true;
@@ -248,6 +254,16 @@ public class Style {
return this;
}
public Builder pointReduction(boolean pointReduction) {
this.pointReduction = pointReduction;
return this;
}
public Builder textureRepeat(boolean textureRepeat) {
this.textureRepeat = textureRepeat;
return this;
}
public Builder heightOffset(float heightOffset) {
this.heightOffset = heightOffset;
return this;