From 8d67b70a8ecdb9c3e0fe20967f37db531811f68b Mon Sep 17 00:00:00 2001 From: vshcherb Date: Mon, 7 Oct 2013 23:41:02 +0200 Subject: [PATCH] Fix native rendering --- .../src/net/osmand/RenderingContext.java | 2 +- .../src/net/osmand/render/RenderingRule.java | 1 + .../osmand/render/RenderingRuleProperty.java | 20 ++++++++++++++----- .../render/RenderingRuleSearchRequest.java | 5 +++-- .../plus/render/MapRenderRepositories.java | 3 ++- .../osmand/plus/render/OsmandRenderer.java | 3 ++- .../net/osmand/plus/render/TextRenderer.java | 6 +++--- 7 files changed, 27 insertions(+), 13 deletions(-) diff --git a/OsmAnd-java/src/net/osmand/RenderingContext.java b/OsmAnd-java/src/net/osmand/RenderingContext.java index a860c4e970..c7fac135da 100644 --- a/OsmAnd-java/src/net/osmand/RenderingContext.java +++ b/OsmAnd-java/src/net/osmand/RenderingContext.java @@ -61,7 +61,7 @@ public class RenderingContext { } public float getComplexValue(RenderingRuleSearchRequest req, RenderingRuleProperty prop, float defVal) { - return req.getFloatPropertyValue(prop, defVal) * density; + return req.getFloatPropertyValue(prop, defVal) * density + req.getIntPropertyValue(prop, 0); } protected byte[] getIconRawData(String data) { diff --git a/OsmAnd-java/src/net/osmand/render/RenderingRule.java b/OsmAnd-java/src/net/osmand/render/RenderingRule.java index efa9639ddc..fced37bbd9 100644 --- a/OsmAnd-java/src/net/osmand/render/RenderingRule.java +++ b/OsmAnd-java/src/net/osmand/render/RenderingRule.java @@ -41,6 +41,7 @@ public class RenderingRule { floatProperties = new float[attributes.size()]; } floatProperties[i] = property.parseFloatValue(e.getValue()); + intProperties[i] = property.parseIntValue(e.getValue()); } else { intProperties[i] = property.parseIntValue(e.getValue()); } diff --git a/OsmAnd-java/src/net/osmand/render/RenderingRuleProperty.java b/OsmAnd-java/src/net/osmand/render/RenderingRuleProperty.java index 236e4f6772..a9d1fbe1ae 100644 --- a/OsmAnd-java/src/net/osmand/render/RenderingRuleProperty.java +++ b/OsmAnd-java/src/net/osmand/render/RenderingRuleProperty.java @@ -160,6 +160,18 @@ public class RenderingRuleProperty { log.error("Rendering parse " + e.getMessage()); } return -1; + } else if(type == FLOAT_TYPE){ + // parse as complex value + try { + int colon = value.indexOf(':'); + if(colon != -1) { + return Integer.parseInt(value.substring(colon + 1)); + } + return 0; + } catch (NumberFormatException e) { + log.error("Rendering parse " + value); + } + return -1; } else { return -1; } @@ -170,12 +182,10 @@ public class RenderingRuleProperty { try { int colon = value.indexOf(':'); if(colon != -1) { - float c = 0; if(colon > 0) { - c += Float.parseFloat(value.substring(0, colon)); - } - c += Float.parseFloat(value.substring(colon + 1)); - return c; + return Float.parseFloat(value.substring(0, colon)); + } + return 0; } return Float.parseFloat(value); } catch (NumberFormatException e) { diff --git a/OsmAnd-java/src/net/osmand/render/RenderingRuleSearchRequest.java b/OsmAnd-java/src/net/osmand/render/RenderingRuleSearchRequest.java index 64a4baafd2..3024ef6aff 100644 --- a/OsmAnd-java/src/net/osmand/render/RenderingRuleSearchRequest.java +++ b/OsmAnd-java/src/net/osmand/render/RenderingRuleSearchRequest.java @@ -67,6 +67,7 @@ public class RenderingRuleSearchRequest { values[p.getId()] = savedValues[p.getId()]; } else { fvalues[p.getId()] = savedFvalues[p.getId()]; + values[p.getId()] = savedValues[p.getId()]; } } @@ -166,7 +167,6 @@ public class RenderingRuleSearchRequest { } } 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); } } @@ -180,6 +180,7 @@ public class RenderingRuleSearchRequest { searchResult = true; if (rp.isFloat()) { fvalues[rp.getId()] = rule.getFloatProp(i); + values[rp.getId()] = rule.getIntProp(i); } else { values[rp.getId()] = rule.getIntProp(i); } @@ -202,7 +203,7 @@ public class RenderingRuleSearchRequest { public boolean isSpecified(RenderingRuleProperty property){ if(property.isFloat()){ - return fvalues[property.getId()] != 0; + return fvalues[property.getId()] != 0 || values[property.getId()] != -1; } else { int val = values[property.getId()]; if(property.isColor()){ diff --git a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java index 0848c5a4e3..3f48bf64fa 100644 --- a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java +++ b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java @@ -439,7 +439,8 @@ public class MapRenderRepositories { } - public boolean checkIfMapIsEmpty(int leftX, int rightX, int topY, int bottomY, int zoom){ + // only single thread to read ! + public synchronized boolean checkIfMapIsEmpty(int leftX, int rightX, int topY, int bottomY, int zoom){ final boolean[] empty = new boolean[] {true}; SearchRequest searchRequest = BinaryMapIndexReader.buildSearchRequest(leftX, rightX, topY, bottomY, zoom, null, new ResultMatcher() { diff --git a/OsmAnd/src/net/osmand/plus/render/OsmandRenderer.java b/OsmAnd/src/net/osmand/plus/render/OsmandRenderer.java index d59f142c6e..8f4ee61263 100644 --- a/OsmAnd/src/net/osmand/plus/render/OsmandRenderer.java +++ b/OsmAnd/src/net/osmand/plus/render/OsmandRenderer.java @@ -564,6 +564,7 @@ public class OsmandRenderer { if (shadowColor == 0) { shadowRadius = 0; } + System.out.println("Shadow radius " + shadowRadius); p.setShadowLayer(shadowRadius, 0, 0, shadowColor); } } @@ -713,7 +714,7 @@ public class OsmandRenderer { if (path != null) { if(drawOnlyShadow) { int shadowColor = render.getIntPropertyValue(render.ALL.R_SHADOW_COLOR); - int shadowRadius = render.getIntPropertyValue(render.ALL.R_SHADOW_RADIUS); + int shadowRadius = (int) rc.getComplexValue(render, render.ALL.R_SHADOW_RADIUS, 0); if(shadowColor == 0) { shadowColor = rc.shadowRenderingColor; } diff --git a/OsmAnd/src/net/osmand/plus/render/TextRenderer.java b/OsmAnd/src/net/osmand/plus/render/TextRenderer.java index 542a198c3f..2dc96ad7ef 100644 --- a/OsmAnd/src/net/osmand/plus/render/TextRenderer.java +++ b/OsmAnd/src/net/osmand/plus/render/TextRenderer.java @@ -164,7 +164,7 @@ public class TextRenderer { } if (text.minDistance > 0) { QuadRect boundsSearch = new QuadRect(text.bounds); - boundsSearch.inset(-rc.getDensityValue(Math.max(5.0f, text.minDistance)), -rc.getDensityValue(15)); + boundsSearch.inset(-Math.max(rc.getDensityValue(5.0f), text.minDistance), -rc.getDensityValue(15)); boundIntersections.queryInBox(boundsSearch, tempSearch); // drawTestBox(cv, &boundsSearch, text.pathRotate, paintIcon, text.text, NULL/*paintText*/); for (int i = 0; i < tempSearch.size(); i++) { @@ -216,7 +216,7 @@ public class TextRenderer { } // sest text size before finding intersection (it is used there) - float textSize = rc.getDensityValue(text.textSize); + float textSize = text.textSize; paintText.setTextSize(textSize); paintText.setFakeBoldText(text.bold); paintText.setColor(text.textColor); @@ -323,7 +323,7 @@ public class TextRenderer { }); } - paintText.setTextSize(rc.getDensityValue(text.textSize)); + paintText.setTextSize(text.textSize); Rect bs = new Rect(); paintText.getTextBounds(name, 0, name.length(), bs); text.bounds = new QuadRect(bs.left, bs.top, bs.right, bs.bottom);