From 00473cea80b689e0ec027e43f85375c4c34a2f0c Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Sun, 23 Sep 2012 14:32:33 +0200 Subject: [PATCH] Fix colors for highway roads and fix cocolors in rendering --- .../osmand/render/RenderingRulesStorage.java | 13 +- .../src/net/osmand/render/default.render.xml | 118 +++++++----------- .../render/high-contrast-roads.render.xml | 40 +++--- OsmAnd/res/values-ru/strings.xml | 12 +- OsmAnd/res/values/colors.xml | 5 +- .../extrasettings/OsmandExtraSettings.java | 21 ++-- .../src/net/osmand/plus/views/GPXLayer.java | 2 +- .../net/osmand/plus/views/MiniMapControl.java | 3 +- .../src/net/osmand/plus/views/RouteLayer.java | 2 +- Osmand-kernel/osmand/src/renderRules.cpp | 25 ++-- Osmand-kernel/osmand/src/renderRules.h | 1 + 11 files changed, 118 insertions(+), 124 deletions(-) diff --git a/DataExtractionOSM/src/net/osmand/render/RenderingRulesStorage.java b/DataExtractionOSM/src/net/osmand/render/RenderingRulesStorage.java index e4260709e8..edc0d907fd 100644 --- a/DataExtractionOSM/src/net/osmand/render/RenderingRulesStorage.java +++ b/DataExtractionOSM/src/net/osmand/render/RenderingRulesStorage.java @@ -51,6 +51,7 @@ public class RenderingRulesStorage { protected TIntObjectHashMap[] tagValueGlobalRules = new TIntObjectHashMap[LENGTH_RULES]; protected Map renderingAttributes = new LinkedHashMap(); + protected Map renderingConstants= new LinkedHashMap(); private String renderingName; @@ -311,6 +312,8 @@ public class RenderingRulesStorage { prop.setPossibleValues(attributes.getValue("possibleValues").split(",")); } PROPS.registerRule(prop); + } else if("renderingConstant".equals(name)){ //$NON-NLS-1$ + renderingConstants.put(attributes.getValue("name"), attributes.getValue("value")); } else if("renderingStyle".equals(name)){ //$NON-NLS-1$ String depends = attributes.getValue("depends"); if(depends != null && depends.length()> 0){ @@ -340,7 +343,15 @@ public class RenderingRulesStorage { private Map parseAttributes(Attributes attributes, Map m) { for (int i = 0; i < attributes.getLength(); i++) { String name = parser.isNamespaceAware() ? attributes.getLocalName(i) : attributes.getQName(i); - m.put(name, attributes.getValue(i)); + String vl = attributes.getValue(i); + if(vl != null && vl.startsWith("$")) { + String cv = vl.substring(1); + if(!renderingConstants.containsKey(cv)){ + throw new IllegalStateException("Rendering constant '" + cv + "' was not specified."); + } + vl = renderingConstants.get(cv); + } + m.put(name, vl); } return m; } diff --git a/DataExtractionOSM/src/net/osmand/render/default.render.xml b/DataExtractionOSM/src/net/osmand/render/default.render.xml index 2e8b5ece4e..34614f0377 100644 --- a/DataExtractionOSM/src/net/osmand/render/default.render.xml +++ b/DataExtractionOSM/src/net/osmand/render/default.render.xml @@ -12,8 +12,12 @@ - + + --> - + + + + + + // + + + + + + + + + + + + + + + - - - - - - - - - - - - - - + + + + @@ -1045,14 +1057,8 @@ - - - - - - - - + + @@ -1063,14 +1069,8 @@ - - - - - - - - + + @@ -1081,38 +1081,14 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + @@ -1136,14 +1112,8 @@ - - - - - - - - + + diff --git a/DataExtractionOSM/src/net/osmand/render/high-contrast-roads.render.xml b/DataExtractionOSM/src/net/osmand/render/high-contrast-roads.render.xml index 9544de4cf9..1df44331b9 100644 --- a/DataExtractionOSM/src/net/osmand/render/high-contrast-roads.render.xml +++ b/DataExtractionOSM/src/net/osmand/render/high-contrast-roads.render.xml @@ -75,23 +75,23 @@ - - - - - - - - - - + + + + + + + + + + @@ -103,22 +103,22 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/OsmAnd/res/values-ru/strings.xml b/OsmAnd/res/values-ru/strings.xml index f192f65f19..14622fcaeb 100644 --- a/OsmAnd/res/values-ru/strings.xml +++ b/OsmAnd/res/values-ru/strings.xml @@ -3,12 +3,12 @@ \nЧтобы получить дополнительную информацию о карте, выделите её в списке. Удерживайте карту, если вы хотите удалить или деактивировать. \nДанные на устройстве (%1$s свободно): "Изменения в 0.8.3: -\n\t* Промежуточные пункты\n\t* Улучшенная прокладка маршрута -\n\t* Опция Избегать автомагистралей -\n\t* Отображение трека -\n\t* Улучшенный интерфейс (иконки) -\n\t* Исправление ошибок " - + * Промежуточные пункты + * Улучшенная прокладка маршрута + * Опция Избегать автомагистралей + * Отображение трека + * Улучшенный интерфейс (иконки) + * Исправление ошибок " "\tДля некоторых векторных карт можно менять оформление между дневным и ночным. \n\tНочное оформление безопаснее для использования в темноте. \n\tДля изменения дневного/ночного оформления нажмите на значок настройки на экране карты и выберите \'Дневной/ночной режим\'. diff --git a/OsmAnd/res/values/colors.xml b/OsmAnd/res/values/colors.xml index 37c26a358b..37d0a1786c 100644 --- a/OsmAnd/res/values/colors.xml +++ b/OsmAnd/res/values/colors.xml @@ -16,14 +16,15 @@ - #B4A00AD7 + #B4B319FF #B400FFFF #320000FF #280000FF #707CDC - #960000FF + + #CCFF6600 #CCFF6600 #FADE23 #FF2300 diff --git a/OsmAnd/src/net/osmand/plus/extrasettings/OsmandExtraSettings.java b/OsmAnd/src/net/osmand/plus/extrasettings/OsmandExtraSettings.java index 14a6795db8..ccb7a04e32 100644 --- a/OsmAnd/src/net/osmand/plus/extrasettings/OsmandExtraSettings.java +++ b/OsmAnd/src/net/osmand/plus/extrasettings/OsmandExtraSettings.java @@ -109,17 +109,18 @@ public class OsmandExtraSettings extends OsmandPlugin { } }); - final MapInfoControlRegInfo fluorescent = mapInfoControls.registerAppearanceWidget(R.drawable.widget_fluorescent_routes, R.string.map_widget_fluorescent, - "fluorescent", view.getSettings().FLUORESCENT_OVERLAYS); - fluorescent.setStateChangeListener(new Runnable() { - @Override - public void run() { - view.getSettings().FLUORESCENT_OVERLAYS.set(!view.getSettings().FLUORESCENT_OVERLAYS.get()); - view.refreshMap(); - } - }); - // FIXME delete strings from this code +// final MapInfoControlRegInfo fluorescent = mapInfoControls.registerAppearanceWidget(R.drawable.widget_fluorescent_routes, R.string.map_widget_fluorescent, +// "fluorescent", view.getSettings().FLUORESCENT_OVERLAYS); +// fluorescent.setStateChangeListener(new Runnable() { +// @Override +// public void run() { +// view.getSettings().FLUORESCENT_OVERLAYS.set(!view.getSettings().FLUORESCENT_OVERLAYS.get()); +// view.refreshMap(); +// } +// }); + + // final CommonPreference posPref = view.getSettings().POSITION_ON_MAP; // final MapInfoControlRegInfo posMap = mapInfoControls.registerAppearanceWidget(R.drawable.widget_position_marker, R.string.position_on_map, // "position_on_map", textSizePref); diff --git a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java index 3044304839..8af9972462 100644 --- a/OsmAnd/src/net/osmand/plus/views/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/GPXLayer.java @@ -53,7 +53,7 @@ public class GPXLayer extends OsmandMapLayer { return; } List> points = gpxFile.processedPointsToDisplay; - if (view.getSettings().FLUORESCENT_OVERLAYS.get()) { + if (false && view.getSettings().FLUORESCENT_OVERLAYS.get()) { paint.setColor(view.getResources().getColor(R.color.gpx_track_fluorescent)); } else { paint.setColor(view.getResources().getColor(R.color.gpx_track)); diff --git a/OsmAnd/src/net/osmand/plus/views/MiniMapControl.java b/OsmAnd/src/net/osmand/plus/views/MiniMapControl.java index a893926a46..8a526f3075 100644 --- a/OsmAnd/src/net/osmand/plus/views/MiniMapControl.java +++ b/OsmAnd/src/net/osmand/plus/views/MiniMapControl.java @@ -60,7 +60,8 @@ public class MiniMapControl extends MapInfoControl { super.onDraw(canvas); //to change color immediately when needed - if (view.getSettings().FLUORESCENT_OVERLAYS.get()) { + // could be deleted in future + if (view.getSettings().FLUORESCENT_OVERLAYS.get() && false) { paintMiniRoute.setColor(getResources().getColor(R.color.nav_track_fluorescent)); } else { paintMiniRoute.setColor(getResources().getColor(R.color.nav_track)); diff --git a/OsmAnd/src/net/osmand/plus/views/RouteLayer.java b/OsmAnd/src/net/osmand/plus/views/RouteLayer.java index 9d0da52a39..e77f9b54f3 100644 --- a/OsmAnd/src/net/osmand/plus/views/RouteLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/RouteLayer.java @@ -58,7 +58,7 @@ public class RouteLayer extends OsmandMapLayer { public void onDraw(Canvas canvas, RectF latLonBounds, RectF tilesRect, DrawSettings nightMode) { path.reset(); if (helper.getFinalLocation() != null && helper.getRoute().isCalculated()) { - if (view.getSettings().FLUORESCENT_OVERLAYS.get()) { + if (false && view.getSettings().FLUORESCENT_OVERLAYS.get()) { paint.setColor(view.getResources().getColor(R.color.nav_track_fluorescent)); } else { paint.setColor(view.getResources().getColor(R.color.nav_track)); diff --git a/Osmand-kernel/osmand/src/renderRules.cpp b/Osmand-kernel/osmand/src/renderRules.cpp index 8b93c712c8..44a6f593ff 100644 --- a/Osmand-kernel/osmand/src/renderRules.cpp +++ b/Osmand-kernel/osmand/src/renderRules.cpp @@ -198,8 +198,13 @@ class RenderingRulesHandler { return dependsStorage; } - static map& parseAttributes(const char **atts, map& m) { + static map& parseAttributes(const char **atts, map& m, + RenderingRulesStorage* st) { while (*atts != NULL) { + string vl = string(atts[1]); + if(vl.size() > 1 && vl[0] == '$') { + vl = st->renderingConstants[vl.substr(1, vl.size() - 1)]; + } m[string(atts[0])] = string(atts[1]); atts += 2; } @@ -215,7 +220,7 @@ class RenderingRulesHandler { if (t->st.size() > 0 && t->st.top().isGroup()) { attrsMap.insert(t->st.top().groupAttributes.begin(), t->st.top().groupAttributes.end()); } - parseAttributes(atts, attrsMap); + parseAttributes(atts, attrsMap, t->storage); RenderingRule* renderingRule = new RenderingRule(attrsMap,t->storage); if (t->st.size() > 0 && t->st.top().isGroup()) { t->st.top().children.push_back(renderingRule); @@ -230,7 +235,7 @@ class RenderingRulesHandler { t->st.push(gr); } else if ("groupFilter" == name) { //$NON-NLS-1$ map attrsMap; - parseAttributes(atts, attrsMap); + parseAttributes(atts, attrsMap, t->storage); RenderingRule* renderingRule = new RenderingRule(attrsMap,t->storage); if (t->st.size() > 0 && t->st.top().isGroup()) { GroupRules parent = ((GroupRules) t->st.top()); @@ -246,7 +251,7 @@ class RenderingRulesHandler { if (t->st.size() > 0 && t->st.top().isGroup()) { groupRules.groupAttributes.insert(t->st.top().groupAttributes.begin(), t->st.top().groupAttributes.end()); } - parseAttributes(atts, groupRules.groupAttributes); + parseAttributes(atts, groupRules.groupAttributes, t->storage); t->st.push(groupRules); } else if ("order" == name) { //$NON-NLS-1$ t->state = RenderingRulesStorage::ORDER_RULES; @@ -258,9 +263,13 @@ class RenderingRulesHandler { t->state = RenderingRulesStorage::LINE_RULES; } else if ("polygon" == name) { //$NON-NLS-1$ t->state = RenderingRulesStorage::POLYGON_RULES; + } else if ("renderingConstant" == name) { //$NON-NLS-1$ + map attrsMap; + parseAttributes(atts, attrsMap, t->storage); + t->storage->renderingConstants[attrsMap["name"]] = attrsMap["value"]; } else if ("renderingAttribute" == name) { //$NON-NLS-1$ map attrsMap; - parseAttributes(atts, attrsMap); + parseAttributes(atts, attrsMap, t->storage); string attr = attrsMap["name"]; map empty; RenderingRule* root = new RenderingRule(empty,t->storage); @@ -268,7 +277,7 @@ class RenderingRulesHandler { t->st.push(GroupRules(root)); } else if ("renderingProperty" == name) { map attrsMap; - parseAttributes(atts, attrsMap); + parseAttributes(atts, attrsMap, t->storage); string attr = attrsMap["attr"]; RenderingRuleProperty* prop; string type = attrsMap["type"]; @@ -294,7 +303,7 @@ class RenderingRulesHandler { t->storage->PROPS.registerRule(prop); } else if ("renderingStyle" == name) { map attrsMap; - parseAttributes(atts, attrsMap); + parseAttributes(atts, attrsMap, t->storage); string depends = attrsMap["depends"]; if (depends.size() > 0 && t->resolver != NULL) { t->dependsStorage = t->resolver->resolve(depends, t->resolver); @@ -695,4 +704,4 @@ void RenderingRuleSearchRequest::printDebugResult() { printf("\nNot found\n"); } -} \ No newline at end of file +} diff --git a/Osmand-kernel/osmand/src/renderRules.h b/Osmand-kernel/osmand/src/renderRules.h index 0193087331..fb353939a9 100644 --- a/Osmand-kernel/osmand/src/renderRules.h +++ b/Osmand-kernel/osmand/src/renderRules.h @@ -380,6 +380,7 @@ public: const static int SIZE_STATES = 7; UNORDERED(map)* tagValueGlobalRules; map renderingAttributes; + map renderingConstants; std::vector childRules; public: RenderingRulesStorageProperties PROPS;