Search in sources :

Example 16 with RenderingRulesStorage

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();
    }
}
Also used : OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) RenderingRulesStorage(net.osmand.render.RenderingRulesStorage)

Example 17 with RenderingRulesStorage

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;
}
Also used : RenderingRuleSearchRequest(net.osmand.render.RenderingRuleSearchRequest) RenderingRulesStorage(net.osmand.render.RenderingRulesStorage)

Example 18 with RenderingRulesStorage

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);
        }
    }
}
Also used : File(java.io.File) RenderingRulesStorage(net.osmand.render.RenderingRulesStorage) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

RenderingRulesStorage (net.osmand.render.RenderingRulesStorage)18 RenderingRuleProperty (net.osmand.render.RenderingRuleProperty)6 ArrayList (java.util.ArrayList)5 File (java.io.File)4 OsmandApplication (net.osmand.plus.OsmandApplication)4 RenderingRuleSearchRequest (net.osmand.render.RenderingRuleSearchRequest)4 DialogInterface (android.content.DialogInterface)3 AlertDialog (android.support.v7.app.AlertDialog)3 View (android.view.View)3 ArrayAdapter (android.widget.ArrayAdapter)3 ImageView (android.widget.ImageView)3 TIntArrayList (gnu.trove.list.array.TIntArrayList)3 Paint (android.graphics.Paint)2 SwitchCompat (android.support.v7.widget.SwitchCompat)2 ViewGroup (android.view.ViewGroup)2 AdapterView (android.widget.AdapterView)2 CompoundButton (android.widget.CompoundButton)2 OnCheckedChangeListener (android.widget.CompoundButton.OnCheckedChangeListener)2 TextView (android.widget.TextView)2 FileInputStream (java.io.FileInputStream)2