Small fixes
This commit is contained in:
parent
0bdf2dfa8a
commit
fbec2abd19
5 changed files with 47 additions and 33 deletions
|
@ -266,6 +266,8 @@ public class RouteColorize {
|
|||
List<RouteColorizationPoint> sublist = dataList.subList(prevId, currentId);
|
||||
simplified.addAll(getExtremums(sublist));
|
||||
}
|
||||
Node lastSurvivedPoint = result.get(result.size() - 1);
|
||||
simplified.add(dataList.get((int) lastSurvivedPoint.getId()));
|
||||
return simplified;
|
||||
}
|
||||
|
||||
|
|
|
@ -139,6 +139,11 @@ public abstract class GeometryWay<T extends GeometryWayContext, D extends Geomet
|
|||
@NonNull
|
||||
public abstract GeometryWayStyle<?> getDefaultWayStyle();
|
||||
|
||||
@NonNull
|
||||
protected Map<Integer, GeometryWayStyle<?>> getStyleMap() {
|
||||
return styleMap;
|
||||
}
|
||||
|
||||
public Location getNextVisiblePoint() {
|
||||
return null;
|
||||
}
|
||||
|
@ -380,6 +385,8 @@ public abstract class GeometryWay<T extends GeometryWayContext, D extends Geomet
|
|||
}
|
||||
}
|
||||
context.clearCustomColor();
|
||||
context.clearCustomShader();
|
||||
|
||||
}
|
||||
drawer.drawArrowsOverPath(canvas, tb, tx, ty, angles, distances, distToFinish, styles);
|
||||
} finally {
|
||||
|
|
|
@ -105,6 +105,10 @@ public abstract class GeometryWayContext {
|
|||
attrs.customColor = 0;
|
||||
}
|
||||
|
||||
public void clearCustomShader() {
|
||||
attrs.customColorPaint.setShader(null);
|
||||
}
|
||||
|
||||
public int getStrokeColor(int sourceColor) {
|
||||
return ColorUtils.blendARGB(sourceColor, Color.BLACK, 0.6f);
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ import net.osmand.plus.routing.RoutingHelper;
|
|||
import net.osmand.plus.track.GradientScaleType;
|
||||
import net.osmand.router.RouteColorize;
|
||||
import net.osmand.router.RouteColorize.RouteColorizationPoint;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -46,6 +47,11 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Route
|
|||
@Nullable Float width,
|
||||
@Nullable @ColorInt Integer pointColor,
|
||||
@Nullable GradientScaleType scaleType) {
|
||||
if (scaleType != null && !Algorithms.objectEquals(customWidth, width)) {
|
||||
for (GeometryWayStyle<?> style : getStyleMap().values()) {
|
||||
style.width = width;
|
||||
}
|
||||
}
|
||||
this.customColor = color;
|
||||
this.customWidth = width;
|
||||
this.customPointColor = pointColor;
|
||||
|
@ -54,14 +60,11 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Route
|
|||
if (width != null) {
|
||||
getContext().getAttrs().shadowPaint.setStrokeWidth(width + getContext().getDensity() * 2);
|
||||
}
|
||||
|
||||
getContext().getAttrs().customColorPaint.setStrokeCap(scaleType != null ? Paint.Cap.ROUND : Paint.Cap.BUTT);
|
||||
}
|
||||
|
||||
public void updateRoute(RotatedTileBox tb, RouteCalculationResult route, OsmandApplication app) {
|
||||
if (tb.getMapDensity() == getMapDensity() && this.route == route && prevScaleType == scaleType) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (tb.getMapDensity() != getMapDensity() || this.route != route || prevScaleType != scaleType) {
|
||||
this.route = route;
|
||||
List<Location> locations = route != null ? route.getImmutableAllLocations() : Collections.<Location>emptyList();
|
||||
|
||||
|
@ -85,19 +88,18 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Route
|
|||
RouteColorize routeColorize = new RouteColorize(tb.getZoom(), gpxFile, null, scaleType.toColorizationType(), 0);
|
||||
List<RouteColorizationPoint> points = routeColorize.getResult(false);
|
||||
|
||||
updateWay(new GradientGeometryWayProvider(routeColorize), createStyles(points), tb);
|
||||
updateWay(new GradientGeometryWayProvider(routeColorize, points), createStyles(points), tb);
|
||||
}
|
||||
}
|
||||
|
||||
private Map<Integer, GeometryWayStyle<?>> createStyles(List<RouteColorizationPoint> points) {
|
||||
Map<Integer, GeometryWayStyle<?>> styleMap = new TreeMap<>();
|
||||
|
||||
for (int i = 1; i < points.size(); i++) {
|
||||
GeometryGradientWayStyle style = getGradientWayStyle();
|
||||
style.startColor = points.get(i - 1).color;
|
||||
style.endColor = points.get(i).color;
|
||||
styleMap.put(i, style);
|
||||
}
|
||||
|
||||
return styleMap;
|
||||
}
|
||||
|
||||
|
@ -183,9 +185,9 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Route
|
|||
private final RouteColorize routeColorize;
|
||||
private final List<RouteColorizationPoint> locations;
|
||||
|
||||
public GradientGeometryWayProvider(RouteColorize routeColorize) {
|
||||
public GradientGeometryWayProvider(RouteColorize routeColorize, List<RouteColorizationPoint> locations) {
|
||||
this.routeColorize = routeColorize;
|
||||
locations = routeColorize.getResult(false);
|
||||
this.locations = locations;
|
||||
}
|
||||
|
||||
public List<RouteColorizationPoint> simplify(int zoom) {
|
||||
|
|
|
@ -44,7 +44,6 @@ public class RouteGeometryWayDrawer extends GeometryWayDrawer<RouteGeometryWayCo
|
|||
LinearGradient gradient = new LinearGradient(style.startXY.x, style.startXY.y, style.endXY.x, style.endXY.y,
|
||||
style.startColor, style.endColor, Shader.TileMode.CLAMP);
|
||||
getContext().getAttrs().customColorPaint.setShader(gradient);
|
||||
getContext().getAttrs().customColorPaint.setStrokeCap(Paint.Cap.ROUND);
|
||||
}
|
||||
super.drawPath(canvas, path, s);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue