use of net.osmand.render.RenderingRulesStorage in project Osmand by osmandapp.
the class MapStyleAction method execute.
@Override
public void execute(MapActivity activity) {
List<String> mapStyles = getFilteredStyles();
String curStyle = activity.getMyApplication().getSettings().RENDERER.get();
int index = mapStyles.indexOf(curStyle);
String nextStyle = mapStyles.get(0);
if (index >= 0 && index + 1 < mapStyles.size()) {
nextStyle = mapStyles.get(index + 1);
}
RenderingRulesStorage loaded = activity.getMyApplication().getRendererRegistry().getRenderer(nextStyle);
if (loaded != null) {
OsmandMapTileView view = activity.getMapView();
view.getSettings().RENDERER.set(nextStyle);
activity.getMyApplication().getRendererRegistry().setCurrentSelectedRender(loaded);
ConfigureMapMenu.refreshMapComplete(activity);
Toast.makeText(activity, activity.getString(R.string.quick_action_map_style_switch, nextStyle), Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(activity, R.string.renderer_load_exception, Toast.LENGTH_SHORT).show();
}
}
use of net.osmand.render.RenderingRulesStorage in project Osmand by osmandapp.
the class TransportStopRoute method getColor.
public int getColor(OsmandApplication ctx, boolean nightMode) {
if (cachedColor == 0 || cachedNight != nightMode) {
cachedColor = ctx.getResources().getColor(R.color.transport_route_line);
cachedNight = nightMode;
if (type != null) {
RenderingRulesStorage rrs = ctx.getRendererRegistry().getCurrentSelectedRenderer();
RenderingRuleSearchRequest req = new RenderingRuleSearchRequest(rrs);
req.setBooleanFilter(rrs.PROPS.R_NIGHT_MODE, nightMode);
String color = route.getColor();
String typeStr = color == null || color.isEmpty() ? type.getRendeAttr() : color;
if (req.searchRenderingAttribute(typeStr)) {
cachedColor = req.getIntPropertyValue(rrs.PROPS.R_ATTR_COLOR_VALUE);
}
}
}
return cachedColor;
}
use of net.osmand.render.RenderingRulesStorage in project Osmand by osmandapp.
the class RendererRegistry method initRenderers.
public void initRenderers(IProgress progress) {
File file = app.getAppPath(IndexConstants.RENDERERS_DIR);
file.mkdirs();
Map<String, File> externalRenderers = new LinkedHashMap<String, File>();
if (file.exists() && file.canRead()) {
File[] lf = file.listFiles();
if (lf != null) {
for (File f : lf) {
if (f != null && f.getName().endsWith(IndexConstants.RENDERER_INDEX_EXT)) {
if (!internalRenderers.containsValue(f.getName())) {
String name = f.getName().substring(0, f.getName().length() - IndexConstants.RENDERER_INDEX_EXT.length());
externalRenderers.put(name.replace('_', ' ').replace('-', ' '), f);
}
}
}
}
}
this.externalRenderers = externalRenderers;
String r = app.getSettings().RENDERER.get();
if (r != null) {
RenderingRulesStorage obj = getRenderer(r);
if (obj != null) {
setCurrentSelectedRender(obj);
}
}
}
Aggregations