use contrast color for direction arrows
This commit is contained in:
parent
d9bea4ecd4
commit
294040aaf9
3 changed files with 43 additions and 10 deletions
|
@ -30,6 +30,7 @@ import net.osmand.data.QuadRect;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.data.TransportStop;
|
import net.osmand.data.TransportStop;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.plus.UiUtilities;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.mapcontextmenu.other.TrackChartPoints;
|
import net.osmand.plus.mapcontextmenu.other.TrackChartPoints;
|
||||||
import net.osmand.plus.measurementtool.MeasurementToolFragment;
|
import net.osmand.plus.measurementtool.MeasurementToolFragment;
|
||||||
|
@ -105,6 +106,10 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
|
||||||
private LayerDrawable projectionIcon;
|
private LayerDrawable projectionIcon;
|
||||||
private LayerDrawable previewIcon;
|
private LayerDrawable previewIcon;
|
||||||
|
|
||||||
|
private int routeLineColor;
|
||||||
|
private float routeLineWidth;
|
||||||
|
private Integer directionArrowsColor;
|
||||||
|
|
||||||
public RouteLayer(RoutingHelper helper) {
|
public RouteLayer(RoutingHelper helper) {
|
||||||
this.helper = helper;
|
this.helper = helper;
|
||||||
this.transportHelper = helper.getTransportRoutingHelper();
|
this.transportHelper = helper.getTransportRoutingHelper();
|
||||||
|
@ -326,7 +331,8 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
|
||||||
DrawSettings settings,
|
DrawSettings settings,
|
||||||
RouteLineDrawInfo drawInfo) {
|
RouteLineDrawInfo drawInfo) {
|
||||||
updateAttrs(settings, tileBox);
|
updateAttrs(settings, tileBox);
|
||||||
paintRouteLinePreview.setColor(getRouteLineColor(nightMode));
|
updateRouteColors(nightMode);
|
||||||
|
paintRouteLinePreview.setColor(getRouteLineColor());
|
||||||
paintRouteLinePreview.setStrokeWidth(getRouteLineWidth(tileBox));
|
paintRouteLinePreview.setStrokeWidth(getRouteLineWidth(tileBox));
|
||||||
|
|
||||||
int centerX = drawInfo.getCenterX();
|
int centerX = drawInfo.getCenterX();
|
||||||
|
@ -418,6 +424,22 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
|
||||||
|
|
||||||
@ColorInt
|
@ColorInt
|
||||||
public int getRouteLineColor(boolean night) {
|
public int getRouteLineColor(boolean night) {
|
||||||
|
updateRouteColors(night);
|
||||||
|
return routeLineColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ColorInt
|
||||||
|
public int getRouteLineColor() {
|
||||||
|
return routeLineColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@ColorInt
|
||||||
|
public Integer getDirectionArrowsColor() {
|
||||||
|
return directionArrowsColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateRouteColors(boolean night) {
|
||||||
Integer color;
|
Integer color;
|
||||||
if (routeLineDrawInfo != null) {
|
if (routeLineDrawInfo != null) {
|
||||||
color = routeLineDrawInfo.getColor(night);
|
color = routeLineDrawInfo.getColor(night);
|
||||||
|
@ -429,10 +451,13 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
|
||||||
color = storedValue != 0 ? storedValue : null;
|
color = storedValue != 0 ? storedValue : null;
|
||||||
}
|
}
|
||||||
if (color == null) {
|
if (color == null) {
|
||||||
|
directionArrowsColor = null;
|
||||||
updateAttrs(new DrawSettings(night), view.getCurrentRotatedTileBox());
|
updateAttrs(new DrawSettings(night), view.getCurrentRotatedTileBox());
|
||||||
color = attrs.paint.getColor();
|
color = attrs.paint.getColor();
|
||||||
|
} else if (routeLineColor != color) {
|
||||||
|
directionArrowsColor = UiUtilities.getContrastColor(view.getContext(), color, false);
|
||||||
}
|
}
|
||||||
return color;
|
routeLineColor = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getRouteLineWidth(@NonNull RotatedTileBox tileBox) {
|
private float getRouteLineWidth(@NonNull RotatedTileBox tileBox) {
|
||||||
|
@ -442,7 +467,7 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
|
||||||
} else {
|
} else {
|
||||||
widthKey = view.getSettings().ROUTE_LINE_WIDTH.getModeValue(helper.getAppMode());
|
widthKey = view.getSettings().ROUTE_LINE_WIDTH.getModeValue(helper.getAppMode());
|
||||||
}
|
}
|
||||||
return widthKey != null ? getWidthByKey(tileBox, widthKey) : attrs.paint.getStrokeWidth();
|
return routeLineWidth = widthKey != null ? getWidthByKey(tileBox, widthKey) : attrs.paint.getStrokeWidth();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -500,7 +525,8 @@ public class RouteLayer extends OsmandMapLayer implements ContextMenuLayer.ICont
|
||||||
boolean straight = route.getRouteService() == RouteService.STRAIGHT;
|
boolean straight = route.getRouteService() == RouteService.STRAIGHT;
|
||||||
publicTransportRouteGeometry.clearRoute();
|
publicTransportRouteGeometry.clearRoute();
|
||||||
routeGeometry.updateRoute(tb, route);
|
routeGeometry.updateRoute(tb, route);
|
||||||
routeGeometry.setRouteStyleParams(getRouteLineColor(nightMode), getRouteLineWidth(tb));
|
updateRouteColors(nightMode);
|
||||||
|
routeGeometry.setRouteStyleParams(getRouteLineColor(), getRouteLineWidth(tb), getDirectionArrowsColor());
|
||||||
if (directTo) {
|
if (directTo) {
|
||||||
routeGeometry.drawSegments(tb, canvas, topLatitude, leftLongitude, bottomLatitude, rightLongitude,
|
routeGeometry.drawSegments(tb, canvas, topLatitude, leftLongitude, bottomLatitude, rightLongitude,
|
||||||
null, 0);
|
null, 0);
|
||||||
|
|
|
@ -8,6 +8,7 @@ public abstract class GeometryWayStyle<T extends GeometryWayContext> {
|
||||||
private T context;
|
private T context;
|
||||||
protected Integer color;
|
protected Integer color;
|
||||||
protected Float width;
|
protected Float width;
|
||||||
|
protected Integer pointColor;
|
||||||
|
|
||||||
public GeometryWayStyle(T context) {
|
public GeometryWayStyle(T context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
@ -18,10 +19,11 @@ public abstract class GeometryWayStyle<T extends GeometryWayContext> {
|
||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GeometryWayStyle(T context, Integer color, Float width) {
|
public GeometryWayStyle(T context, Integer color, Float width, Integer pointColor) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
this.width = width;
|
this.width = width;
|
||||||
|
this.pointColor = pointColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T getContext() {
|
public T getContext() {
|
||||||
|
@ -45,7 +47,7 @@ public abstract class GeometryWayStyle<T extends GeometryWayContext> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getPointColor() {
|
public Integer getPointColor() {
|
||||||
return null;
|
return pointColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNightMode() {
|
public boolean isNightMode() {
|
||||||
|
|
|
@ -22,15 +22,19 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Geome
|
||||||
|
|
||||||
private Integer customColor;
|
private Integer customColor;
|
||||||
private Float customWidth;
|
private Float customWidth;
|
||||||
|
private Integer customPointColor;
|
||||||
|
|
||||||
public RouteGeometryWay(RouteGeometryWayContext context) {
|
public RouteGeometryWay(RouteGeometryWayContext context) {
|
||||||
super(context, new GeometryWayDrawer<>(context));
|
super(context, new GeometryWayDrawer<>(context));
|
||||||
this.helper = context.getApp().getRoutingHelper();
|
this.helper = context.getApp().getRoutingHelper();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRouteStyleParams(@Nullable @ColorInt Integer color, @Nullable Float width) {
|
public void setRouteStyleParams(@Nullable @ColorInt Integer color,
|
||||||
|
@Nullable Float width,
|
||||||
|
@Nullable @ColorInt Integer pointColor) {
|
||||||
this.customColor = color;
|
this.customColor = color;
|
||||||
this.customWidth = width;
|
this.customWidth = width;
|
||||||
|
this.customPointColor = pointColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -39,7 +43,7 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Geome
|
||||||
Paint paint = getContext().getAttrs().paint;
|
Paint paint = getContext().getAttrs().paint;
|
||||||
int color = customColor != null ? customColor : paint.getColor();
|
int color = customColor != null ? customColor : paint.getColor();
|
||||||
float width = customWidth != null ? customWidth : paint.getStrokeWidth();
|
float width = customWidth != null ? customWidth : paint.getStrokeWidth();
|
||||||
return new GeometrySolidWayStyle(getContext(), color, width);
|
return new GeometrySolidWayStyle(getContext(), color, width, customPointColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateRoute(RotatedTileBox tb, RouteCalculationResult route) {
|
public void updateRoute(RotatedTileBox tb, RouteCalculationResult route) {
|
||||||
|
@ -64,8 +68,9 @@ public class RouteGeometryWay extends GeometryWay<RouteGeometryWayContext, Geome
|
||||||
|
|
||||||
private static class GeometrySolidWayStyle extends GeometryWayStyle<RouteGeometryWayContext> {
|
private static class GeometrySolidWayStyle extends GeometryWayStyle<RouteGeometryWayContext> {
|
||||||
|
|
||||||
GeometrySolidWayStyle(RouteGeometryWayContext context, Integer color, Float width) {
|
GeometrySolidWayStyle(RouteGeometryWayContext context, Integer color, Float width,
|
||||||
super(context, color, width);
|
Integer pointColor) {
|
||||||
|
super(context, color, width, pointColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in a new issue