Add color definition to render xml
This commit is contained in:
parent
add321b341
commit
318e294771
3 changed files with 61 additions and 10 deletions
|
@ -33,6 +33,16 @@
|
||||||
<filter minzoom="9" maxzoom="13" attrIntValue="1" shadowColor="#464646"/>
|
<filter minzoom="9" maxzoom="13" attrIntValue="1" shadowColor="#464646"/>
|
||||||
<filter attrIntValue="0"/>
|
<filter attrIntValue="0"/>
|
||||||
</renderingAttribute>
|
</renderingAttribute>
|
||||||
|
|
||||||
|
<renderingAttribute name="routeColor">
|
||||||
|
<filter nightMode="false" attrColorValue="#960000FF" />
|
||||||
|
<filter attrColorValue="#CCFF6600"/>
|
||||||
|
</renderingAttribute>
|
||||||
|
|
||||||
|
<renderingAttribute name="gpxColor">
|
||||||
|
<filter nightMode="false" attrColorValue="#B400FFFF" />
|
||||||
|
<filter attrColorValue="#B400FFFF"/>
|
||||||
|
</renderingAttribute>
|
||||||
|
|
||||||
<renderingAttribute name="defaultColor">
|
<renderingAttribute name="defaultColor">
|
||||||
<filter noPolygons="true" attrColorValue="#00ffffff"/>
|
<filter noPolygons="true" attrColorValue="#00ffffff"/>
|
||||||
|
|
|
@ -6,6 +6,8 @@ import net.osmand.GPXUtilities.GPXFile;
|
||||||
import net.osmand.GPXUtilities.WptPt;
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
import net.osmand.plus.OsmandSettings;
|
import net.osmand.plus.OsmandSettings;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
|
import net.osmand.render.RenderingRuleSearchRequest;
|
||||||
|
import net.osmand.render.RenderingRulesStorage;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Paint.Cap;
|
import android.graphics.Paint.Cap;
|
||||||
|
@ -25,6 +27,10 @@ public class GPXLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private OsmandSettings settings;
|
private OsmandSettings settings;
|
||||||
|
|
||||||
|
private RenderingRulesStorage cachedRrs;
|
||||||
|
private boolean cachedNightMode;
|
||||||
|
private int cachedColor;
|
||||||
|
|
||||||
|
|
||||||
private void initUI() {
|
private void initUI() {
|
||||||
paint = new Paint();
|
paint = new Paint();
|
||||||
|
@ -45,6 +51,24 @@ public class GPXLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private int getColor(DrawSettings nightMode){
|
||||||
|
RenderingRulesStorage rrs = view.getApplication().getRendererRegistry().getCurrentSelectedRenderer();
|
||||||
|
boolean n = nightMode != null && nightMode.isNightMode();
|
||||||
|
if (rrs != cachedRrs || cachedNightMode != n) {
|
||||||
|
cachedRrs = rrs;
|
||||||
|
cachedNightMode = n;
|
||||||
|
cachedColor = view.getResources().getColor(R.color.gpx_track);
|
||||||
|
if (cachedRrs != null) {
|
||||||
|
RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs);
|
||||||
|
req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, cachedNightMode);
|
||||||
|
if (req.searchRenderingAttribute("gpxColor")) {
|
||||||
|
cachedColor = req.getIntPropertyValue(rrs.PROPS.R_ATTR_COLOR_VALUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cachedColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDraw(Canvas canvas, RectF latLonBounds, RectF tilesRect, DrawSettings nightMode) {
|
public void onDraw(Canvas canvas, RectF latLonBounds, RectF tilesRect, DrawSettings nightMode) {
|
||||||
|
@ -53,11 +77,8 @@ public class GPXLayer extends OsmandMapLayer {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<List<WptPt>> points = gpxFile.processedPointsToDisplay;
|
List<List<WptPt>> points = gpxFile.processedPointsToDisplay;
|
||||||
if (false && view.getSettings().FLUORESCENT_OVERLAYS.get()) {
|
|
||||||
paint.setColor(view.getResources().getColor(R.color.gpx_track_fluorescent));
|
paint.setColor(getColor(nightMode));
|
||||||
} else {
|
|
||||||
paint.setColor(view.getResources().getColor(R.color.gpx_track));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (List<WptPt> l : points) {
|
for (List<WptPt> l : points) {
|
||||||
path.rewind();
|
path.rewind();
|
||||||
|
|
|
@ -5,6 +5,8 @@ import java.util.List;
|
||||||
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
|
import net.osmand.render.RenderingRuleSearchRequest;
|
||||||
|
import net.osmand.render.RenderingRulesStorage;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.Paint.Cap;
|
import android.graphics.Paint.Cap;
|
||||||
|
@ -28,6 +30,11 @@ public class RouteLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
private Path path;
|
private Path path;
|
||||||
|
|
||||||
|
// cache
|
||||||
|
private RenderingRulesStorage cachedRrs;
|
||||||
|
private boolean cachedNightMode;
|
||||||
|
private int cachedColor;
|
||||||
|
|
||||||
public RouteLayer(RoutingHelper helper){
|
public RouteLayer(RoutingHelper helper){
|
||||||
this.helper = helper;
|
this.helper = helper;
|
||||||
}
|
}
|
||||||
|
@ -53,16 +60,29 @@ public class RouteLayer extends OsmandMapLayer {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private int getColor(DrawSettings nightMode){
|
||||||
|
RenderingRulesStorage rrs = view.getApplication().getRendererRegistry().getCurrentSelectedRenderer();
|
||||||
|
boolean n = nightMode != null && nightMode.isNightMode();
|
||||||
|
if (rrs != cachedRrs || cachedNightMode != n) {
|
||||||
|
cachedRrs = rrs;
|
||||||
|
cachedNightMode = n;
|
||||||
|
cachedColor = view.getResources().getColor(cachedNightMode?R.color.nav_track_fluorescent : R.color.nav_track);
|
||||||
|
if (cachedRrs != null) {
|
||||||
|
RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs);
|
||||||
|
req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, cachedNightMode);
|
||||||
|
if (req.searchRenderingAttribute("routeColor")) {
|
||||||
|
cachedColor = req.getIntPropertyValue(rrs.PROPS.R_ATTR_COLOR_VALUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cachedColor;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDraw(Canvas canvas, RectF latLonBounds, RectF tilesRect, DrawSettings nightMode) {
|
public void onDraw(Canvas canvas, RectF latLonBounds, RectF tilesRect, DrawSettings nightMode) {
|
||||||
path.reset();
|
path.reset();
|
||||||
if (helper.getFinalLocation() != null && helper.getRoute().isCalculated()) {
|
if (helper.getFinalLocation() != null && helper.getRoute().isCalculated()) {
|
||||||
if (nightMode != null && nightMode.isNightMode()) {
|
paint.setColor(getColor(nightMode));
|
||||||
paint.setColor(view.getResources().getColor(R.color.nav_track_fluorescent));
|
|
||||||
} else {
|
|
||||||
paint.setColor(view.getResources().getColor(R.color.nav_track));
|
|
||||||
}
|
|
||||||
int w = view.getWidth();
|
int w = view.getWidth();
|
||||||
int h = view.getHeight();
|
int h = view.getHeight();
|
||||||
Location lastProjection = helper.getLastProjection();
|
Location lastProjection = helper.getLastProjection();
|
||||||
|
|
Loading…
Reference in a new issue