From 583fa222052108a5ddf0f6e160ef03fdbb0c5288 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Fri, 19 Jul 2013 00:24:16 +0200 Subject: [PATCH] Introduce icon order in rendering style --- .../osmand/render/RenderingRuleStorageProperties.java | 3 +++ OsmAnd/src/net/osmand/plus/render/OsmandRenderer.java | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/OsmAnd-java/src/net/osmand/render/RenderingRuleStorageProperties.java b/OsmAnd-java/src/net/osmand/render/RenderingRuleStorageProperties.java index 753710ab77..5ef95b1401 100644 --- a/OsmAnd-java/src/net/osmand/render/RenderingRuleStorageProperties.java +++ b/OsmAnd-java/src/net/osmand/render/RenderingRuleStorageProperties.java @@ -44,6 +44,7 @@ public class RenderingRuleStorageProperties { public static final String COLOR__1 = "color__1"; public static final String TEXT_BOLD = "textBold"; public static final String TEXT_ORDER = "textOrder"; + public static final String ICON_ORDER = "iconOrder"; public static final String TEXT_MIN_DISTANCE = "textMinDistance"; public static final String TEXT_ON_PATH = "textOnPath"; public static final String ICON = "icon"; @@ -101,6 +102,7 @@ public class RenderingRuleStorageProperties { public RenderingRuleProperty R_COLOR__1; public RenderingRuleProperty R_TEXT_BOLD; public RenderingRuleProperty R_TEXT_ORDER; + public RenderingRuleProperty R_ICON_ORDER; public RenderingRuleProperty R_TEXT_MIN_DISTANCE; public RenderingRuleProperty R_TEXT_ON_PATH; public RenderingRuleProperty R_ICON; @@ -175,6 +177,7 @@ public class RenderingRuleStorageProperties { R_TEXT_HALO_RADIUS = registerRuleInternal(RenderingRuleProperty.createOutputIntProperty(TEXT_HALO_RADIUS)); R_TEXT_SIZE = registerRuleInternal(RenderingRuleProperty.createOutputIntProperty(TEXT_SIZE)); R_TEXT_ORDER = registerRuleInternal(RenderingRuleProperty.createOutputIntProperty(TEXT_ORDER)); + R_ICON_ORDER = registerRuleInternal(RenderingRuleProperty.createOutputIntProperty(ICON_ORDER)); R_TEXT_MIN_DISTANCE = registerRuleInternal(RenderingRuleProperty.createOutputIntProperty(TEXT_MIN_DISTANCE)); R_TEXT_SHIELD = registerRuleInternal(RenderingRuleProperty.createOutputStringProperty(TEXT_SHIELD)); diff --git a/OsmAnd/src/net/osmand/plus/render/OsmandRenderer.java b/OsmAnd/src/net/osmand/plus/render/OsmandRenderer.java index 711ad5598a..c9d7cc9485 100644 --- a/OsmAnd/src/net/osmand/plus/render/OsmandRenderer.java +++ b/OsmAnd/src/net/osmand/plus/render/OsmandRenderer.java @@ -5,6 +5,8 @@ import gnu.trove.map.hash.TIntObjectHashMap; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -70,6 +72,7 @@ public class OsmandRenderer { float x = 0; float y = 0; String resId; + int iconOrder; } @@ -286,6 +289,13 @@ public class OsmandRenderer { } private void drawIconsOverCanvas(RenderingContext rc, Canvas cv) { + // 1. Sort text using text order + Collections.sort(rc.iconsToDraw, new Comparator() { + @Override + public int compare(IconDrawInfo object1, IconDrawInfo object2) { + return object1.iconOrder - object2.iconOrder; + } + }); int skewConstant = (int) rc.getDensityValue(16); int iconsW = rc.width / skewConstant; int iconsH = rc.height / skewConstant; @@ -598,6 +608,7 @@ public class OsmandRenderer { IconDrawInfo ico = new IconDrawInfo(); ico.x = ps.x; ico.y = ps.y; + ico.iconOrder = render.getIntPropertyValue(render.ALL.R_ICON_ORDER, 100); ico.resId = resId; rc.iconsToDraw.add(ico); }