From 754d1f60076038f938ea0447afb31e83bbf5fdc7 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Thu, 8 Sep 2016 00:27:45 +0200 Subject: [PATCH] Preparation for touch icons --- OsmAnd-java/src/net/osmand/FloatMath.java | 38 --------------- OsmAnd-java/src/net/osmand/NativeLibrary.java | 46 +++++++++++++++++++ OsmAnd-java/src/net/osmand/data/QuadRect.java | 5 ++ 3 files changed, 51 insertions(+), 38 deletions(-) delete mode 100644 OsmAnd-java/src/net/osmand/FloatMath.java diff --git a/OsmAnd-java/src/net/osmand/FloatMath.java b/OsmAnd-java/src/net/osmand/FloatMath.java deleted file mode 100644 index 86cd9f71a5..0000000000 --- a/OsmAnd-java/src/net/osmand/FloatMath.java +++ /dev/null @@ -1,38 +0,0 @@ -package net.osmand; - -/** - * This class can be replaced with more effective on ARM devices - */ -public class FloatMath { - - public static float PI = (float) Math.PI; - - public static float cos(float a) { - return (float) Math.cos(a); - } - - public static float sin(float a) { - return (float) Math.sin(a); - } - - public static float abs(float a) { - return (float) Math.abs(a); - } - - public static float atan2(float py, float px) { - return (float) Math.atan2(py, px); - } - - public static float sqrt(float f) { - return (float) Math.sqrt(f); - } - - public static float max(float a, float b) { - if(a > b) { - return a; - } - return b; - } - - -} diff --git a/OsmAnd-java/src/net/osmand/NativeLibrary.java b/OsmAnd-java/src/net/osmand/NativeLibrary.java index 187bafcc08..520ef5bc91 100644 --- a/OsmAnd-java/src/net/osmand/NativeLibrary.java +++ b/OsmAnd-java/src/net/osmand/NativeLibrary.java @@ -12,10 +12,14 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; +import java.util.LinkedHashMap; +import java.util.Map; import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteRegion; import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteSubregion; import net.osmand.binary.RouteDataObject; +import net.osmand.data.MapObject; +import net.osmand.data.QuadRect; import net.osmand.render.RenderingRuleSearchRequest; import net.osmand.render.RenderingRulesStorage; import net.osmand.router.PrecalculatedRouteDirection; @@ -169,6 +173,12 @@ public class NativeLibrary { String msgIfNothingFound); protected static native boolean initFontType(byte[] byteData, String name, boolean bold, boolean italic); + + protected static native RenderedObject[] searchRenderedObjects(RenderingContext context, int x, int y); + + public RenderedObject[] searchRenderedObjectsFromContext(RenderingContext context, int x, int y) { + return searchRenderedObjects(context, x, y); + } /**/ // Empty native impl @@ -336,5 +346,41 @@ public class NativeLibrary { + public static class RenderedObject extends MapObject { + private Map tags = new LinkedHashMap<>(); + private QuadRect bbox = new QuadRect(); + private int x; + private int y; + + public Map getTags() { + return tags; + } + + public boolean isText() { + return !getName().isEmpty(); + } + + public void setLocation(int x, int y) { + this.x = x; + this.y = y; + } + + public void setBbox(int left, int top, int right, int bottom) { + bbox = new QuadRect(left, top, right, bottom); + } + + public QuadRect getBbox() { + return bbox; + } + + public void setNativeId(long id) { + setId(id); + } + + public void putTag(String t, String v) { + tags.put(t, v); + } + + } } diff --git a/OsmAnd-java/src/net/osmand/data/QuadRect.java b/OsmAnd-java/src/net/osmand/data/QuadRect.java index 36e6aea746..a0b8259b2b 100644 --- a/OsmAnd-java/src/net/osmand/data/QuadRect.java +++ b/OsmAnd-java/src/net/osmand/data/QuadRect.java @@ -67,5 +67,10 @@ public class QuadRect { right -= dx; bottom -= dy; } + + @Override + public String toString() { + return "[" + (float) left + "," + (float) top + " - " + (float) right + "," + (float) bottom + "]"; + } } \ No newline at end of file