From e52112636e88a5cd92396acb8a19ba3352ef0f3a Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 18 Jul 2013 23:56:50 +0200 Subject: [PATCH] Introduce tag=disable for rendering style, so we can disable features by specifying disable=true --- .../src/net/osmand/render/RenderingRuleSearchRequest.java | 8 ++++++++ .../net/osmand/render/RenderingRuleStorageProperties.java | 3 +++ 2 files changed, 11 insertions(+) diff --git a/OsmAnd-java/src/net/osmand/render/RenderingRuleSearchRequest.java b/OsmAnd-java/src/net/osmand/render/RenderingRuleSearchRequest.java index 4124cb2372..c7a7bc1055 100644 --- a/OsmAnd-java/src/net/osmand/render/RenderingRuleSearchRequest.java +++ b/OsmAnd-java/src/net/osmand/render/RenderingRuleSearchRequest.java @@ -138,11 +138,15 @@ public class RenderingRuleSearchRequest { private boolean searchInternal(int state, int tagKey, int valueKey, boolean loadOutput) { values[storage.PROPS.R_TAG.getId()] = tagKey; values[storage.PROPS.R_VALUE.getId()] = valueKey; + values[storage.PROPS.R_DISABLE.getId()] = 0; RenderingRule accept = storage.getRule(state, tagKey, valueKey); if (accept == null) { return false; } boolean match = visitRule(accept, loadOutput); + if(match && values[storage.PROPS.R_DISABLE.getId()] != 0) { + return false; + } return match; } @@ -160,6 +164,10 @@ public class RenderingRuleSearchRequest { if (!match) { return false; } + } else if(rp == storage.PROPS.R_DISABLE){ + // quick disable return even without load output + RenderingRuleProperty p = storage.PROPS.R_DISABLE; + values[rp.getId()] = rule.getIntProp(i); } } if (!loadOutput) { diff --git a/OsmAnd-java/src/net/osmand/render/RenderingRuleStorageProperties.java b/OsmAnd-java/src/net/osmand/render/RenderingRuleStorageProperties.java index 2a2578e3a6..753710ab77 100644 --- a/OsmAnd-java/src/net/osmand/render/RenderingRuleStorageProperties.java +++ b/OsmAnd-java/src/net/osmand/render/RenderingRuleStorageProperties.java @@ -14,6 +14,7 @@ public class RenderingRuleStorageProperties { public static final String ATTR_COLOR_VALUE = "attrColorValue"; public static final String ATTR_STRING_VALUE = "attrStringValue"; public static final String TEST = "test"; + public static final String DISABLE = "disable"; public static final String TEXT_LENGTH = "textLength"; public static final String NAME_TAG = "nameTag"; @@ -67,6 +68,7 @@ public class RenderingRuleStorageProperties { public RenderingRuleProperty R_TEST; + public RenderingRuleProperty R_DISABLE; public RenderingRuleProperty R_ATTR_INT_VALUE; public RenderingRuleProperty R_ATTR_BOOL_VALUE; public RenderingRuleProperty R_ATTR_COLOR_VALUE; @@ -156,6 +158,7 @@ public class RenderingRuleStorageProperties { R_TEXT_LENGTH = registerRuleInternal(RenderingRuleProperty.createInputIntProperty(TEXT_LENGTH)); R_NAME_TAG = registerRuleInternal(RenderingRuleProperty.createInputStringProperty(NAME_TAG)); + R_DISABLE = registerRuleInternal(RenderingRuleProperty.createOutputBooleanProperty(DISABLE)); R_ATTR_INT_VALUE = registerRuleInternal(RenderingRuleProperty.createOutputIntProperty(ATTR_INT_VALUE)); R_ATTR_BOOL_VALUE = registerRuleInternal(RenderingRuleProperty.createOutputBooleanProperty(ATTR_BOOL_VALUE)); R_ATTR_COLOR_VALUE = registerRuleInternal(RenderingRuleProperty.createOutputColorProperty(ATTR_COLOR_VALUE));