Skip to content

Commit

Permalink
correct code review findings
Browse files Browse the repository at this point in the history
  • Loading branch information
eddiemuc committed Dec 18, 2023
1 parent 7da1a2a commit b1c757d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,32 +83,32 @@ public void onCreate(Bundle savedInstanceState) {

private void addRandomCircles(VectorLayer vectorLayer) {
Style.Builder sb = Style.builder()
.buffer(0.5)
.fillColor(Color.RED)
.fillAlpha(0.2f);
.buffer(0.5)
.fillColor(Color.RED)
.fillAlpha(0.2f);

for (int i = 0; i < 2000; i++) {
Style style = sb.buffer(Math.random() + 0.2)
.fillColor(ColorUtil.setHue(Color.RED,
(int) (Math.random() * 50) / 50.0))
.fillAlpha(0.5f)
.build();
.fillColor(ColorUtil.setHue(Color.RED,
(int) (Math.random() * 50) / 50.0))
.fillAlpha(0.5f)
.build();

vectorLayer.add(new PointDrawable(Math.random() * 180 - 90,
Math.random() * 360 - 180,
style));
style));

}
}

private void addThickSemitransparentPolyline(VectorLayer vectorLayer) {
final Style style = Style.builder()
.strokeWidth(20f)
.strokeColor(Color.setA(Color.BLUE, 127))
.cap(Paint.Cap.BUTT)
.pointReduction(10f)
.fixed(true)
.build();
.strokeWidth(20f)
.strokeColor(Color.setA(Color.BLUE, 127))
.cap(Paint.Cap.BUTT)
.dropDistance(10f)
.fixed(true)
.build();

//create a polyline in Hamburg, Germany
final List<GeoPoint> points = Arrays.asList(
Expand Down
6 changes: 3 additions & 3 deletions vtm-jts/src/org/oscim/layers/vector/VectorLayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ protected void drawPoint(Task t, int level, Geometry points, Style style) {
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 : style.dropDistance);
ll.setDropDistance(style.dropDistance);
}

for (int i = 0; i < points.getNumGeometries(); i++) {
Expand Down Expand Up @@ -296,7 +296,7 @@ protected void drawLine(Task t, int level, Geometry line, Style style) {
.strokeWidth(style.strokeWidth)
.texture(style.texture)
.build();
ll.setDropDistance(style.pointReduction ? LineBucket.MIN_DIST : style.dropDistance);
ll.setDropDistance(style.dropDistance);
if (ll instanceof LineTexBucket)
((LineTexBucket) ll).setTexRepeat(style.textureRepeat);
}
Expand Down Expand Up @@ -330,7 +330,7 @@ protected void drawPolygon(Task t, int level, Geometry polygon, Style style) {
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 : style.dropDistance);
ll.setDropDistance(style.dropDistance);
}

if (style.generalization != Style.GENERALIZATION_NONE) {
Expand Down
15 changes: 3 additions & 12 deletions vtm-jts/src/org/oscim/layers/vector/geometries/Style.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import org.oscim.backend.canvas.Color;
import org.oscim.backend.canvas.Paint;
import org.oscim.renderer.bucket.LineBucket;
import org.oscim.renderer.bucket.TextureItem;

import static org.oscim.backend.canvas.Color.parseColor;

/**
Expand Down Expand Up @@ -52,7 +52,6 @@ public class Style {
public final int stippleColor;
public final float stippleWidth;
public final TextureItem texture;
public final boolean pointReduction;
public final float dropDistance;
public final boolean textureRepeat;

Expand All @@ -79,7 +78,6 @@ private Style(Builder builder) {
stippleColor = builder.stippleColor;
stippleWidth = builder.stippleWidth;
texture = builder.texture;
pointReduction = builder.pointReduction;
dropDistance = builder.dropDistance;
textureRepeat = builder.textureRepeat;

Expand Down Expand Up @@ -117,8 +115,7 @@ public static class Builder {
public int stippleColor = Color.GRAY;
public float stippleWidth = 1;
public TextureItem texture = null;
public boolean pointReduction = true;
public float dropDistance = 0f;
public float dropDistance = LineBucket.MIN_DIST;
public boolean textureRepeat = true;

public float heightOffset = 0;
Expand Down Expand Up @@ -257,13 +254,7 @@ public Builder texture(TextureItem texture) {
return this;
}

public Builder pointReduction(boolean pointReduction) {
this.pointReduction = pointReduction;
return this;
}

public Builder pointReduction(float dropDistance) {
this.pointReduction = false;
public Builder dropDistance(float dropDistance) {
this.dropDistance = dropDistance;
return this;
}
Expand Down

0 comments on commit b1c757d

Please sign in to comment.