Fix multitouch layer
This commit is contained in:
parent
acfaa7632c
commit
f80f6338dd
5 changed files with 20 additions and 25 deletions
|
@ -51,7 +51,6 @@ import android.graphics.Shader.TileMode;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.util.FloatMath;
|
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
|
||||||
public class OsmandRenderer {
|
public class OsmandRenderer {
|
||||||
|
@ -184,8 +183,8 @@ public class OsmandRenderer {
|
||||||
Bitmap bmp, RenderingRuleSearchRequest render, final MapTileDownloader mapTileDownloader) {
|
Bitmap bmp, RenderingRuleSearchRequest render, final MapTileDownloader mapTileDownloader) {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if (rc.width > 0 && rc.height > 0 && searchResultHandler != null) {
|
if (rc.width > 0 && rc.height > 0 && searchResultHandler != null) {
|
||||||
rc.cosRotateTileSize = FloatMath.cos((float) Math.toRadians(rc.rotate)) * TILE_SIZE;
|
rc.cosRotateTileSize = (float) (Math.cos(Math.toRadians(rc.rotate)) * TILE_SIZE);
|
||||||
rc.sinRotateTileSize = FloatMath.sin((float) Math.toRadians(rc.rotate)) * TILE_SIZE;
|
rc.sinRotateTileSize = (float) (Math.sin(Math.toRadians(rc.rotate)) * TILE_SIZE);
|
||||||
try {
|
try {
|
||||||
if(Looper.getMainLooper() != null && library.useDirectRendering()) {
|
if(Looper.getMainLooper() != null && library.useDirectRendering()) {
|
||||||
final Handler h = new Handler(Looper.getMainLooper());
|
final Handler h = new Handler(Looper.getMainLooper());
|
||||||
|
@ -249,8 +248,8 @@ public class OsmandRenderer {
|
||||||
cv.drawColor(rc.defaultColor);
|
cv.drawColor(rc.defaultColor);
|
||||||
}
|
}
|
||||||
if (objects != null && !objects.isEmpty() && rc.width > 0 && rc.height > 0) {
|
if (objects != null && !objects.isEmpty() && rc.width > 0 && rc.height > 0) {
|
||||||
rc.cosRotateTileSize = FloatMath.cos((float) Math.toRadians(rc.rotate)) * TILE_SIZE;
|
rc.cosRotateTileSize = (float) (Math.cos((float) Math.toRadians(rc.rotate)) * TILE_SIZE);
|
||||||
rc.sinRotateTileSize = FloatMath.sin((float) Math.toRadians(rc.rotate)) * TILE_SIZE;
|
rc.sinRotateTileSize = (float) (Math.sin((float) Math.toRadians(rc.rotate)) * TILE_SIZE);
|
||||||
|
|
||||||
// put in order map
|
// put in order map
|
||||||
List<MapDataObjectPrimitive> pointsArray = new ArrayList<OsmandRenderer.MapDataObjectPrimitive>();
|
List<MapDataObjectPrimitive> pointsArray = new ArrayList<OsmandRenderer.MapDataObjectPrimitive>();
|
||||||
|
|
|
@ -29,7 +29,6 @@ import android.graphics.PointF;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.graphics.Typeface;
|
import android.graphics.Typeface;
|
||||||
import android.util.FloatMath;
|
|
||||||
|
|
||||||
public class TextRenderer {
|
public class TextRenderer {
|
||||||
|
|
||||||
|
@ -145,13 +144,13 @@ public class TextRenderer {
|
||||||
}
|
}
|
||||||
|
|
||||||
// determine difference close to 180/0 degrees
|
// determine difference close to 180/0 degrees
|
||||||
if (Math.abs(FloatMath.sin(tRot - sRot)) < 0.3) {
|
if (Math.abs(Math.sin(tRot - sRot)) < 0.3) {
|
||||||
// rotate t box
|
// rotate t box
|
||||||
// (calculate offset for t center suppose we rotate around s center)
|
// (calculate offset for t center suppose we rotate around s center)
|
||||||
float diff = (float) (-Math.atan2(tRect.centerX() - sRect.centerX(), tRect.centerY() - sRect.centerY()) + Math.PI / 2);
|
float diff = (float) (-Math.atan2(tRect.centerX() - sRect.centerX(), tRect.centerY() - sRect.centerY()) + Math.PI / 2);
|
||||||
diff -= sRot;
|
diff -= sRot;
|
||||||
double left = sRect.centerX() + dist * FloatMath.cos(diff) - tRect.width() / 2;
|
double left = sRect.centerX() + dist * Math.cos(diff) - tRect.width() / 2;
|
||||||
double top = sRect.centerY() - dist * FloatMath.sin(diff) - tRect.height() / 2;
|
double top = sRect.centerY() - dist * Math.sin(diff) - tRect.height() / 2;
|
||||||
QuadRect nRect = new QuadRect(left, top, left + tRect.width(), top + tRect.height());
|
QuadRect nRect = new QuadRect(left, top, left + tRect.width(), top + tRect.height());
|
||||||
return QuadRect.intersects(nRect, sRect);
|
return QuadRect.intersects(nRect, sRect);
|
||||||
}
|
}
|
||||||
|
@ -458,7 +457,7 @@ public class TextRenderer {
|
||||||
boolean inside = points[i].x >= 0 && points[i].x <= rc.width &&
|
boolean inside = points[i].x >= 0 && points[i].x <= rc.width &&
|
||||||
points[i].x >= 0 && points[i].y <= rc.height;
|
points[i].x >= 0 && points[i].y <= rc.height;
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
float d = FloatMath.sqrt(fsqr(points[i].x - points[i - 1].x) +
|
float d = (float) Math.sqrt(fsqr(points[i].x - points[i - 1].x) +
|
||||||
fsqr(points[i].y - points[i - 1].y));
|
fsqr(points[i].y - points[i - 1].y));
|
||||||
distances[i-1]= d;
|
distances[i-1]= d;
|
||||||
roadLength += d;
|
roadLength += d;
|
||||||
|
|
|
@ -9,7 +9,6 @@ import org.apache.commons.logging.Log;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.util.FloatMath;
|
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
|
|
||||||
|
|
||||||
|
@ -96,7 +95,7 @@ public class MultiTouchSupport {
|
||||||
Float x2 = (Float) getX.invoke(event, 1);
|
Float x2 = (Float) getX.invoke(event, 1);
|
||||||
Float y1 = (Float) getY.invoke(event, 0);
|
Float y1 = (Float) getY.invoke(event, 0);
|
||||||
Float y2 = (Float) getY.invoke(event, 1);
|
Float y2 = (Float) getY.invoke(event, 1);
|
||||||
float distance = FloatMath.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
|
float distance = (float) Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
|
||||||
float angle = 0;
|
float angle = 0;
|
||||||
boolean angleDefined = false;
|
boolean angleDefined = false;
|
||||||
if(x1 != x2 || y1 != y2) {
|
if(x1 != x2 || y1 != y2) {
|
||||||
|
|
|
@ -31,7 +31,6 @@ import android.graphics.Path;
|
||||||
import android.graphics.PointF;
|
import android.graphics.PointF;
|
||||||
import android.graphics.PorterDuff.Mode;
|
import android.graphics.PorterDuff.Mode;
|
||||||
import android.graphics.PorterDuffColorFilter;
|
import android.graphics.PorterDuffColorFilter;
|
||||||
import android.util.FloatMath;
|
|
||||||
|
|
||||||
public class RouteLayer extends OsmandMapLayer {
|
public class RouteLayer extends OsmandMapLayer {
|
||||||
|
|
||||||
|
@ -204,7 +203,7 @@ public class RouteLayer extends OsmandMapLayer {
|
||||||
canvas.drawPath(pth, actionPaint);
|
canvas.drawPath(pth, actionPaint);
|
||||||
double angleRad = Math.atan2(y - py, x - px);
|
double angleRad = Math.atan2(y - py, x - px);
|
||||||
double angle = (angleRad * 180 / Math.PI) + 90f;
|
double angle = (angleRad * 180 / Math.PI) + 90f;
|
||||||
double distSegment = FloatMath.sqrt((y - py) * (y - py) + (x - px) * (x - px));
|
double distSegment = Math.sqrt((y - py) * (y - py) + (x - px) * (x - px));
|
||||||
if (distSegment == 0) {
|
if (distSegment == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -285,7 +284,7 @@ public class RouteLayer extends OsmandMapLayer {
|
||||||
int y = lst.get(i + 3);
|
int y = lst.get(i + 3);
|
||||||
float angleRad = (float) Math.atan2(y - py, x - px);
|
float angleRad = (float) Math.atan2(y - py, x - px);
|
||||||
float angle = (float) (angleRad * 180 / Math.PI) + 90f;
|
float angle = (float) (angleRad * 180 / Math.PI) + 90f;
|
||||||
float distSegment = FloatMath.sqrt((y - py) * (y - py) + (x - px) * (x - px));
|
float distSegment = (float) Math.sqrt((y - py) * (y - py) + (x - px) * (x - px));
|
||||||
if(distSegment == 0) {
|
if(distSegment == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ import android.graphics.Path;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.RectF;
|
import android.graphics.RectF;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.util.FloatMath;
|
|
||||||
|
|
||||||
public class TurnPathHelper {
|
public class TurnPathHelper {
|
||||||
|
|
||||||
|
@ -216,22 +215,22 @@ public class TurnPathHelper {
|
||||||
float tsRad = (float) ((to - step / 8 + 180) * Math.PI / 180f);
|
float tsRad = (float) ((to - step / 8 + 180) * Math.PI / 180f);
|
||||||
float tsRad2 = (float) ((to + step / 8 + 180) * Math.PI / 180f);
|
float tsRad2 = (float) ((to + step / 8 + 180) * Math.PI / 180f);
|
||||||
pathForTurn.arcTo(r, prev, to - step / 6 - prev + init );
|
pathForTurn.arcTo(r, prev, to - step / 6 - prev + init );
|
||||||
pathForTurn.lineTo(cx + (r1 + 10) * FloatMath.sin(tsRad), cy - (r1 + 10) * FloatMath.cos(tsRad));
|
pathForTurn.lineTo(cx + (r1 + 10) * (float) Math.sin(tsRad), cy - (r1 + 10) * (float) Math.cos(tsRad));
|
||||||
pathForTurn.lineTo(cx + (r1 + 10) * FloatMath.sin(tsRad2), cy - (r1 + 10) * FloatMath.cos(tsRad2));
|
pathForTurn.lineTo(cx + (r1 + 10) * (float) Math.sin(tsRad2), cy - (r1 + 10) * (float) Math.cos(tsRad2));
|
||||||
// not necessary for next arcTo
|
// not necessary for next arcTo
|
||||||
//pathForTurn.lineTo(cx + (r1 + 0) * FloatMath.sin(tsRad2), cy - (r1 + 0) * FloatMath.cos(tsRad2));
|
//pathForTurn.lineTo(cx + (r1 + 0) * (float) Math.sin(tsRad2), cy - (r1 + 0) * (float) Math.cos(tsRad2));
|
||||||
prev = to + step / 6 + init;
|
prev = to + step / 6 + init;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float angleRad = (float) ((180 + sweepAngle) * Math.PI / 180f);
|
float angleRad = (float) ((180 + sweepAngle) * Math.PI / 180f);
|
||||||
|
|
||||||
pathForTurn.lineTo(cx + (r1 + 4) * FloatMath.sin(angleRad), cy - (r1 + 4) * FloatMath.cos(angleRad));
|
pathForTurn.lineTo(cx + (r1 + 4) * (float) Math.sin(angleRad), cy - (r1 + 4) * (float) Math.cos(angleRad));
|
||||||
pathForTurn.lineTo(cx + (r1 + 6) * FloatMath.sin(angleRad + angleToRot/2), cy - (r1 + 6) * FloatMath.cos(angleRad + angleToRot/2));
|
pathForTurn.lineTo(cx + (r1 + 6) * (float) Math.sin(angleRad + angleToRot/2), cy - (r1 + 6) * (float) Math.cos(angleRad + angleToRot/2));
|
||||||
pathForTurn.lineTo(cx + (r1 + 14) * FloatMath.sin(angleRad - angleToRot/2), cy - (r1 + 12) * FloatMath.cos(angleRad - angleToRot/2));
|
pathForTurn.lineTo(cx + (r1 + 14) * (float) Math.sin(angleRad - angleToRot/2), cy - (r1 + 12) * (float) Math.cos(angleRad - angleToRot/2));
|
||||||
pathForTurn.lineTo(cx + (r1 + 6) * FloatMath.sin(angleRad - 3*angleToRot/2), cy - (r1 + 6) * FloatMath.cos(angleRad - 3*angleToRot/2));
|
pathForTurn.lineTo(cx + (r1 + 6) * (float) Math.sin(angleRad - 3*angleToRot/2), cy - (r1 + 6) * (float) Math.cos(angleRad - 3*angleToRot/2));
|
||||||
pathForTurn.lineTo(cx + (r1 + 4) * FloatMath.sin(angleRad - angleToRot), cy - (r1 + 4) * FloatMath.cos(angleRad - angleToRot));
|
pathForTurn.lineTo(cx + (r1 + 4) * (float) Math.sin(angleRad - angleToRot), cy - (r1 + 4) * (float) Math.cos(angleRad - angleToRot));
|
||||||
pathForTurn.lineTo(cx + r2 * FloatMath.sin(angleRad - angleToRot), cy - r2 * FloatMath.cos(angleRad - angleToRot));
|
pathForTurn.lineTo(cx + r2 * (float) Math.sin(angleRad - angleToRot), cy - r2 * (float) Math.cos(angleRad - angleToRot));
|
||||||
|
|
||||||
r.set(cx - r2, cy - r2, cx + r2, cy + r2);
|
r.set(cx - r2, cy - r2, cx + r2, cy + r2);
|
||||||
pathForTurn.arcTo(r, 360 + sweepAngle + 90, -sweepAngle);
|
pathForTurn.arcTo(r, 360 + sweepAngle + 90, -sweepAngle);
|
||||||
|
|
Loading…
Reference in a new issue