Fix #2745. Increased size, calculate properly 360 rounandabout
This commit is contained in:
parent
bafdcde19d
commit
55df0ce6da
6 changed files with 125 additions and 60 deletions
|
@ -189,7 +189,7 @@ public class ShowRouteInfoActivity extends OsmandListActivity {
|
||||||
TextView cumulativeTimeLabel = (TextView) row.findViewById(R.id.cumulative_time);
|
TextView cumulativeTimeLabel = (TextView) row.findViewById(R.id.cumulative_time);
|
||||||
ImageView icon = (ImageView) row.findViewById(R.id.direction);
|
ImageView icon = (ImageView) row.findViewById(R.id.direction);
|
||||||
|
|
||||||
TurnPathHelper.RouteDrawable drawable = new TurnPathHelper.RouteDrawable(getResources());
|
TurnPathHelper.RouteDrawable drawable = new TurnPathHelper.RouteDrawable(getResources(), true);
|
||||||
drawable.setRouteType(model.getTurnType());
|
drawable.setRouteType(model.getTurnType());
|
||||||
icon.setImageDrawable(drawable);
|
icon.setImageDrawable(drawable);
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,24 @@
|
||||||
package net.osmand.plus.views;
|
package net.osmand.plus.views;
|
||||||
|
|
||||||
import android.graphics.*;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.router.TurnType;
|
import net.osmand.router.TurnType;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
|
import android.graphics.Bitmap;
|
||||||
|
import android.graphics.BitmapFactory;
|
||||||
|
import android.graphics.Canvas;
|
||||||
|
import android.graphics.Color;
|
||||||
|
import android.graphics.ColorFilter;
|
||||||
|
import android.graphics.Matrix;
|
||||||
|
import android.graphics.Paint;
|
||||||
import android.graphics.Paint.Style;
|
import android.graphics.Paint.Style;
|
||||||
import android.graphics.Path.Direction;
|
import android.graphics.Path;
|
||||||
|
import android.graphics.PointF;
|
||||||
|
import android.graphics.Rect;
|
||||||
|
import android.graphics.RectF;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class TurnPathHelper {
|
public class TurnPathHelper {
|
||||||
|
|
||||||
//Index of processed turn
|
//Index of processed turn
|
||||||
|
@ -20,7 +29,8 @@ public class TurnPathHelper {
|
||||||
private static final boolean SHOW_STEPS = true;
|
private static final boolean SHOW_STEPS = true;
|
||||||
|
|
||||||
// 72x72
|
// 72x72
|
||||||
public static void calcTurnPath(Path pathForTurn, Path outlay, TurnType turnType, Matrix transform) {
|
public static void calcTurnPath(Path pathForTurn, Path outlay, TurnType turnType,
|
||||||
|
Matrix transform, PointF center, boolean mini) {
|
||||||
if(turnType == null){
|
if(turnType == null){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -177,41 +187,57 @@ public class TurnPathHelper {
|
||||||
pathForTurn.rLineTo(-harrowL / 2, harrowL / 2); // -15 15
|
pathForTurn.rLineTo(-harrowL / 2, harrowL / 2); // -15 15
|
||||||
pathForTurn.rLineTo(hpartArrowL + th, 0); //9 0
|
pathForTurn.rLineTo(hpartArrowL + th, 0); //9 0
|
||||||
} else if(turnType != null && turnType.isRoundAbout() && USE_NEW_RNDB) {
|
} else if(turnType != null && turnType.isRoundAbout() && USE_NEW_RNDB) {
|
||||||
|
|
||||||
int out = turnType.getExitOut();
|
int out = turnType.getExitOut();
|
||||||
boolean leftSide = turnType.isLeftSide();
|
boolean leftSide = turnType.isLeftSide();
|
||||||
float radArrow = 37;
|
float radEndOfArrow = 44;
|
||||||
float radIn = 11;
|
float radInnerCircle = 10;
|
||||||
float radOut = radIn + 6;
|
float radOuterCircle = radInnerCircle + 8;
|
||||||
|
|
||||||
float radBottom = radOut + 8;
|
float radBottom = radOuterCircle + 10;
|
||||||
float radStepInter = radOut + 6;
|
float radStepInter = radOuterCircle + 6;
|
||||||
float radAr = radOut + 4;
|
float radArrowTriangle1 = radOuterCircle + 7;
|
||||||
float radAr2 = radOut + 5;
|
float radArrowTriangle2 = radOuterCircle + 8;
|
||||||
|
|
||||||
float widthStepIn = 8;
|
float widthStepIn = 8;
|
||||||
float widthStepInter = 6;
|
float widthStepInter = 6;
|
||||||
float widthArrow = 22;
|
float widthArrow = 22;
|
||||||
float cx = wa / 2 ;
|
|
||||||
float cy = ha / 2 ;
|
|
||||||
|
|
||||||
|
|
||||||
double dfL = (leftSide ? 1 : -1) * Math.asin(widthStepIn / (2.0 * radBottom));
|
double dfL = (leftSide ? 1 : -1) * Math.asin(widthStepIn / (2.0 * radBottom));
|
||||||
double dfAr2 = (leftSide ? 1 : -1) * Math.asin(widthArrow / (2.0 * radAr2));
|
double dfAr2 = (leftSide ? 1 : -1) * Math.asin(widthArrow / (2.0 * radArrowTriangle2));
|
||||||
double dfStepInter = (leftSide ? 1 : -1) * Math.asin(widthStepInter / radStepInter);
|
double dfStepInter = (leftSide ? 1 : -1) * Math.asin(widthStepInter / radStepInter);
|
||||||
double dfAr = Math.asin(radBottom * Math.sin(dfL) / radAr);
|
double dfAr = Math.asin(radBottom * Math.sin(dfL) / radArrowTriangle1);
|
||||||
double dfOut = Math.asin(radBottom * Math.sin(dfL) / radOut);
|
double dfOut = Math.asin(radBottom * Math.sin(dfL) / radOuterCircle);
|
||||||
double dfStepOut = Math.asin(radStepInter * Math.sin(dfStepInter) / radOut);
|
double dfStepOut = Math.asin(radStepInter * Math.sin(dfStepInter) / radOuterCircle);
|
||||||
double dfIn = Math.asin(radBottom * Math.sin(dfL) / radIn);
|
double dfIn = Math.asin(radBottom * Math.sin(dfL) / radInnerCircle);
|
||||||
double minDelta = Math.abs(dfIn * 2 / Math.PI * 180 ) + 2;
|
double minDelta = Math.abs(dfIn * 2 / Math.PI * 180 ) + 2;
|
||||||
boolean showSteps = SHOW_STEPS;
|
boolean showSteps = SHOW_STEPS && !mini;
|
||||||
// System.out.println("Angle " + dfL + " " + dfOut + " " + dfIn + " " + minDelta + " ");
|
// System.out.println("Angle " + dfL + " " + dfOut + " " + dfIn + " " + minDelta + " ");
|
||||||
double rot = alignRotation(turnType.getTurnAngle(), leftSide, minDelta) / 180 * Math.PI;
|
double rot = alignRotation(turnType.getTurnAngle(), leftSide, minDelta, out) / 180 * Math.PI;
|
||||||
|
|
||||||
|
float cx = wa / 2 ;
|
||||||
|
float cy = ha / 2 ;
|
||||||
|
// align center
|
||||||
|
float potentialArrowEndX = (float) (Math.sin(rot) * radEndOfArrow);
|
||||||
|
float potentialArrowEndY = (float) (Math.cos(rot) * radEndOfArrow);
|
||||||
|
if (potentialArrowEndX > cx) {
|
||||||
|
cx = potentialArrowEndX;
|
||||||
|
} else if (potentialArrowEndX < -cx) {
|
||||||
|
cx = 2 * cx + potentialArrowEndX;
|
||||||
|
}
|
||||||
|
if(potentialArrowEndY > cy) {
|
||||||
|
cy = 2 * cy - potentialArrowEndY;
|
||||||
|
} else if(potentialArrowEndY < -cy) {
|
||||||
|
cy = -potentialArrowEndY;
|
||||||
|
}
|
||||||
|
if(center != null) {
|
||||||
|
center.set(cx, cy);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
RectF qrOut = new RectF(cx - radOut, cy - radOut, cx + radOut, cy + radOut);
|
RectF qrOut = new RectF(cx - radOuterCircle, cy - radOuterCircle, cx + radOuterCircle, cy + radOuterCircle);
|
||||||
RectF qrIn = new RectF(cx - radIn, cy - radIn, cx + radIn, cy + radIn);
|
RectF qrIn = new RectF(cx - radInnerCircle, cy - radInnerCircle, cx + radInnerCircle, cy + radInnerCircle);
|
||||||
if(outlay != null) {
|
if(outlay != null && !mini) {
|
||||||
outlay.addArc(qrOut, 0, 360);
|
outlay.addArc(qrOut, 0, 360);
|
||||||
outlay.addArc(qrIn, 0, -360);
|
outlay.addArc(qrIn, 0, -360);
|
||||||
// outlay.addOval(qrOut, Direction.CCW);
|
// outlay.addOval(qrOut, Direction.CCW);
|
||||||
|
@ -219,7 +245,7 @@ public class TurnPathHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
// move to bottom ring
|
// move to bottom ring
|
||||||
pathForTurn.moveTo(getProjX(dfOut, cx, cy, radOut), getProjY(dfOut, cx, cy, radOut));
|
pathForTurn.moveTo(getProjX(dfOut, cx, cy, radOuterCircle), getProjY(dfOut, cx, cy, radOuterCircle));
|
||||||
if (out <= 1) {
|
if (out <= 1) {
|
||||||
showSteps = false;
|
showSteps = false;
|
||||||
}
|
}
|
||||||
|
@ -235,18 +261,18 @@ public class TurnPathHelper {
|
||||||
// double st = (rot - 2 * dfOut ) / (2 * out - 1);
|
// double st = (rot - 2 * dfOut ) / (2 * out - 1);
|
||||||
// dfStepOut = st;
|
// dfStepOut = st;
|
||||||
if (showSteps) {
|
if (showSteps) {
|
||||||
outlay.moveTo(getProjX(dfOut, cx, cy, radOut), getProjY(dfOut, cx, cy, radOut));
|
outlay.moveTo(getProjX(dfOut, cx, cy, radOuterCircle), getProjY(dfOut, cx, cy, radOuterCircle));
|
||||||
for (int i = 0; i < out - 1; i++) {
|
for (int i = 0; i < out - 1; i++) {
|
||||||
outlay.arcTo(qrOut, startArcAngle(dfOut + i * (st + dfStepOut)), sweepArcAngle(st));
|
outlay.arcTo(qrOut, startArcAngle(dfOut + i * (st + dfStepOut)), sweepArcAngle(st));
|
||||||
arcLineTo(outlay,
|
arcLineTo(outlay,
|
||||||
dfOut + (i + 1) * (st + dfStepOut) - dfStepOut / 2 - dfStepInter / 2, cx, cy, radStepInter);
|
dfOut + (i + 1) * (st + dfStepOut) - dfStepOut / 2 - dfStepInter / 2, cx, cy, radStepInter);
|
||||||
arcLineTo(outlay, dfOut + (i + 1) * (st + dfStepOut) - dfStepOut / 2 + dfStepInter / 2, cx, cy, radStepInter);
|
arcLineTo(outlay, dfOut + (i + 1) * (st + dfStepOut) - dfStepOut / 2 + dfStepInter / 2, cx, cy, radStepInter);
|
||||||
arcLineTo(outlay, dfOut + (i + 1) * (st + dfStepOut), cx, cy, radOut);
|
arcLineTo(outlay, dfOut + (i + 1) * (st + dfStepOut), cx, cy, radOuterCircle);
|
||||||
// pathForTurn.arcTo(qr1, startArcAngle(dfOut), sweepArcAngle(rot - dfOut - dfOut));
|
// pathForTurn.arcTo(qr1, startArcAngle(dfOut), sweepArcAngle(rot - dfOut - dfOut));
|
||||||
}
|
}
|
||||||
outlay.arcTo(qrOut, startArcAngle(rot - dfOut - st), sweepArcAngle(st));
|
outlay.arcTo(qrOut, startArcAngle(rot - dfOut - st), sweepArcAngle(st));
|
||||||
// swipe back
|
// swipe back
|
||||||
arcLineTo(outlay, rot - dfIn, cx, cy, radIn);
|
arcLineTo(outlay, rot - dfIn, cx, cy, radInnerCircle);
|
||||||
outlay.arcTo(qrIn, startArcAngle(rot - dfIn), -sweepArcAngle(rot - dfIn - dfIn));
|
outlay.arcTo(qrIn, startArcAngle(rot - dfIn), -sweepArcAngle(rot - dfIn - dfIn));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,21 +283,21 @@ public class TurnPathHelper {
|
||||||
pathForTurn.arcTo(qrOut, startArcAngle(dfOut), sweepArcAngle(rot - dfOut - dfOut));
|
pathForTurn.arcTo(qrOut, startArcAngle(dfOut), sweepArcAngle(rot - dfOut - dfOut));
|
||||||
|
|
||||||
// up from arc
|
// up from arc
|
||||||
arcLineTo(pathForTurn, rot - dfAr, cx, cy, radAr);
|
arcLineTo(pathForTurn, rot - dfAr, cx, cy, radArrowTriangle1);
|
||||||
// left triangle
|
// left triangle
|
||||||
// arcLineTo(pathForTurn, rot - dfAr2, cx, cy, radAr2); // 1.
|
// arcLineTo(pathForTurn, rot - dfAr2, cx, cy, radAr2); // 1.
|
||||||
// arcQuadTo(pathForTurn, rot - dfAr2, radAr2, rot, radArrow, 0.9f, cx, cy); // 2.
|
// arcQuadTo(pathForTurn, rot - dfAr2, radAr2, rot, radArrow, 0.9f, cx, cy); // 2.
|
||||||
arcQuadTo(pathForTurn, rot - dfAr, radAr, rot - dfAr2, radAr2, rot, radArrow, 4.5f, cx, cy); // 3.
|
arcQuadTo(pathForTurn, rot - dfAr, radArrowTriangle1, rot - dfAr2, radArrowTriangle2, rot, radEndOfArrow, 4.5f, cx, cy); // 3.
|
||||||
|
|
||||||
// arcLineTo(pathForTurn, rot, cx, cy, radArrow); // 1.
|
// arcLineTo(pathForTurn, rot, cx, cy, radArrow); // 1.
|
||||||
arcQuadTo(pathForTurn, rot - dfAr2, radAr2, rot, radArrow, rot + dfAr2, radAr2, 4.5f, cx, cy);
|
arcQuadTo(pathForTurn, rot - dfAr2, radArrowTriangle2, rot, radEndOfArrow, rot + dfAr2, radArrowTriangle2, 4.5f, cx, cy);
|
||||||
// right triangle
|
// right triangle
|
||||||
// arcLineTo(pathForTurn, rot + dfAr2, cx, cy, radAr2); // 1.
|
// arcLineTo(pathForTurn, rot + dfAr2, cx, cy, radAr2); // 1.
|
||||||
arcQuadTo(pathForTurn, rot, radArrow, rot + dfAr2, radAr2, rot + dfAr, radAr, 4.5f, cx, cy);
|
arcQuadTo(pathForTurn, rot, radEndOfArrow, rot + dfAr2, radArrowTriangle2, rot + dfAr, radArrowTriangle1, 4.5f, cx, cy);
|
||||||
|
|
||||||
arcLineTo(pathForTurn, rot + dfAr, cx, cy, radAr);
|
arcLineTo(pathForTurn, rot + dfAr, cx, cy, radArrowTriangle1);
|
||||||
// down to arc
|
// down to arc
|
||||||
arcLineTo(pathForTurn, rot + dfIn, cx, cy, radIn);
|
arcLineTo(pathForTurn, rot + dfIn, cx, cy, radInnerCircle);
|
||||||
// arc
|
// arc
|
||||||
pathForTurn.arcTo(qrIn, startArcAngle(rot + dfIn), sweepArcAngle(-rot - dfIn - dfIn));
|
pathForTurn.arcTo(qrIn, startArcAngle(rot + dfIn), sweepArcAngle(-rot - dfIn - dfIn));
|
||||||
// down
|
// down
|
||||||
|
@ -362,24 +388,34 @@ public class TurnPathHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static float alignRotation(float t, boolean leftSide, double minDelta) {
|
private static float alignRotation(float t, boolean leftSide, double minDelta, int out) {
|
||||||
// t between -180, 180
|
// t between ]-180, 180]
|
||||||
while(t > 180) {
|
while(t > 180) {
|
||||||
t -= 360;
|
t -= 360;
|
||||||
}
|
}
|
||||||
while(t < -180) {
|
while(t <= -180) {
|
||||||
t += 360;
|
t += 360;
|
||||||
}
|
}
|
||||||
|
// rot left - ] 0, 360], right ] -360,0]
|
||||||
float rot = leftSide ? (t + 180) : (t - 180) ;
|
float rot = leftSide ? (t + 180) : (t - 180) ;
|
||||||
|
if(rot == 0) {
|
||||||
|
rot = leftSide ? 360 : -360;
|
||||||
|
}
|
||||||
float delta = (float) minDelta;
|
float delta = (float) minDelta;
|
||||||
if(rot > 360 - delta && rot < 360) {
|
if(rot > 360 - delta && rot <= 360) {
|
||||||
rot = 360 - delta;
|
rot = 360 - delta;
|
||||||
} else if (rot > 0 && rot < delta) {
|
} else if (rot < -360 + delta && rot >= -360) {
|
||||||
rot = delta;
|
|
||||||
} else if (rot < -360 + delta && rot > -360) {
|
|
||||||
rot = -360 + delta;
|
rot = -360 + delta;
|
||||||
} else if (rot < 0 && rot > -delta) {
|
} else if (rot >= 0 && rot < delta) {
|
||||||
|
rot = delta;
|
||||||
|
if(out > 2) {
|
||||||
|
rot = 360 - delta;
|
||||||
|
}
|
||||||
|
} else if (rot <= 0 && rot > -delta) {
|
||||||
rot = -delta;
|
rot = -delta;
|
||||||
|
if(out > 2) {
|
||||||
|
rot = -360 + delta;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return rot;
|
return rot;
|
||||||
}
|
}
|
||||||
|
@ -447,8 +483,10 @@ public class TurnPathHelper {
|
||||||
Path dp = new Path();
|
Path dp = new Path();
|
||||||
Path pOutlay = new Path();
|
Path pOutlay = new Path();
|
||||||
Path dpOutlay = new Path();
|
Path dpOutlay = new Path();
|
||||||
|
private boolean mini;
|
||||||
|
|
||||||
public RouteDrawable(Resources resources){
|
public RouteDrawable(Resources resources, boolean mini){
|
||||||
|
this.mini = mini;
|
||||||
paintRouteDirection = new Paint();
|
paintRouteDirection = new Paint();
|
||||||
paintRouteDirection.setStyle(Style.FILL_AND_STROKE);
|
paintRouteDirection.setStyle(Style.FILL_AND_STROKE);
|
||||||
paintRouteDirection.setColor(resources.getColor(R.color.nav_arrow_distant));
|
paintRouteDirection.setColor(resources.getColor(R.color.nav_arrow_distant));
|
||||||
|
@ -457,7 +495,7 @@ public class TurnPathHelper {
|
||||||
paintRouteDirectionOutlay.setStyle(Style.STROKE);
|
paintRouteDirectionOutlay.setStyle(Style.STROKE);
|
||||||
paintRouteDirectionOutlay.setColor(Color.BLACK);
|
paintRouteDirectionOutlay.setColor(Color.BLACK);
|
||||||
paintRouteDirectionOutlay.setAntiAlias(true);
|
paintRouteDirectionOutlay.setAntiAlias(true);
|
||||||
TurnPathHelper.calcTurnPath(dp, dpOutlay, TurnType.straight(), null);
|
TurnPathHelper.calcTurnPath(dp, dpOutlay, TurnType.straight(), null, null, mini);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -469,7 +507,7 @@ public class TurnPathHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRouteType(TurnType t){
|
public void setRouteType(TurnType t){
|
||||||
TurnPathHelper.calcTurnPath(p, pOutlay, t, null);
|
TurnPathHelper.calcTurnPath(p, pOutlay, t, null, null, mini);
|
||||||
onBoundsChange(getBounds());
|
onBoundsChange(getBounds());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -262,7 +262,7 @@ public class MapInfoWidgetsFactory {
|
||||||
settings = app.getSettings();
|
settings = app.getSettings();
|
||||||
waypointHelper = app.getWaypointHelper();
|
waypointHelper = app.getWaypointHelper();
|
||||||
updateVisibility(false);
|
updateVisibility(false);
|
||||||
turnDrawable = new NextTurnInfoWidget.TurnDrawable(map);
|
turnDrawable = new NextTurnInfoWidget.TurnDrawable(map, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean updateVisibility(boolean visible) {
|
public boolean updateVisibility(boolean visible) {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import net.osmand.plus.OsmandApplication;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.routing.RoutingHelper;
|
import net.osmand.plus.routing.RoutingHelper;
|
||||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||||
|
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopTextView;
|
||||||
import net.osmand.plus.views.TurnPathHelper;
|
import net.osmand.plus.views.TurnPathHelper;
|
||||||
import net.osmand.router.TurnType;
|
import net.osmand.router.TurnType;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
@ -14,10 +15,13 @@ import android.graphics.Color;
|
||||||
import android.graphics.ColorFilter;
|
import android.graphics.ColorFilter;
|
||||||
import android.graphics.Matrix;
|
import android.graphics.Matrix;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
|
import android.graphics.Paint.Align;
|
||||||
import android.graphics.Paint.Style;
|
import android.graphics.Paint.Style;
|
||||||
import android.graphics.Path;
|
import android.graphics.Path;
|
||||||
|
import android.graphics.PointF;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.text.TextPaint;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,7 +40,7 @@ public class NextTurnInfoWidget extends TextInfoWidget {
|
||||||
super(activity);
|
super(activity);
|
||||||
this.app = app;
|
this.app = app;
|
||||||
this.horisontalMini = horisontalMini;
|
this.horisontalMini = horisontalMini;
|
||||||
turnDrawable = new TurnDrawable(activity);
|
turnDrawable = new TurnDrawable(activity, horisontalMini);
|
||||||
if(horisontalMini) {
|
if(horisontalMini) {
|
||||||
setImageDrawable(turnDrawable, false);
|
setImageDrawable(turnDrawable, false);
|
||||||
setTopImageDrawable(null, null);
|
setTopImageDrawable(null, null);
|
||||||
|
@ -53,11 +57,13 @@ public class NextTurnInfoWidget extends TextInfoWidget {
|
||||||
public void setTurnType(TurnType turnType) {
|
public void setTurnType(TurnType turnType) {
|
||||||
boolean vis = updateVisibility(turnType != null);
|
boolean vis = updateVisibility(turnType != null);
|
||||||
if (turnDrawable.setTurnType(turnType) || vis) {
|
if (turnDrawable.setTurnType(turnType) || vis) {
|
||||||
|
turnDrawable.setTextPaint(topTextView.getPaint());
|
||||||
if(horisontalMini) {
|
if(horisontalMini) {
|
||||||
setImageDrawable(turnDrawable, false);
|
setImageDrawable(turnDrawable, false);
|
||||||
} else {
|
} else {
|
||||||
setTopImageDrawable(turnDrawable, turnType == null || turnType.getExitOut() == 0 ? "" :
|
setTopImageDrawable(turnDrawable, "");
|
||||||
turnType.getExitOut() + "");
|
// setTopImageDrawable(turnDrawable, turnType == null || turnType.getExitOut() == 0 ? "" :
|
||||||
|
// turnType.getExitOut() + "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,15 +124,21 @@ public class NextTurnInfoWidget extends TextInfoWidget {
|
||||||
protected int turnImminent;
|
protected int turnImminent;
|
||||||
protected boolean deviatedFromRoute;
|
protected boolean deviatedFromRoute;
|
||||||
private Context ctx;
|
private Context ctx;
|
||||||
|
private boolean mini;
|
||||||
|
private PointF centerText;
|
||||||
|
private TextPaint textPaint;
|
||||||
|
|
||||||
public TurnDrawable(Context ctx) {
|
public TurnDrawable(Context ctx, boolean mini) {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
|
this.mini = mini;
|
||||||
|
centerText = new PointF();
|
||||||
paintBlack = new Paint();
|
paintBlack = new Paint();
|
||||||
paintBlack.setStyle(Style.STROKE);
|
paintBlack.setStyle(Style.STROKE);
|
||||||
paintBlack.setColor(Color.BLACK);
|
paintBlack.setColor(Color.BLACK);
|
||||||
paintBlack.setAntiAlias(true);
|
paintBlack.setAntiAlias(true);
|
||||||
paintBlack.setStrokeWidth(2.5f);
|
paintBlack.setStrokeWidth(2.5f);
|
||||||
|
|
||||||
|
|
||||||
paintRouteDirection = new Paint();
|
paintRouteDirection = new Paint();
|
||||||
paintRouteDirection.setStyle(Style.FILL);
|
paintRouteDirection.setStyle(Style.FILL);
|
||||||
paintRouteDirection.setColor(ctx.getResources().getColor(R.color.nav_arrow));
|
paintRouteDirection.setColor(ctx.getResources().getColor(R.color.nav_arrow));
|
||||||
|
@ -137,8 +149,12 @@ public class NextTurnInfoWidget extends TextInfoWidget {
|
||||||
@Override
|
@Override
|
||||||
protected void onBoundsChange(Rect bounds) {
|
protected void onBoundsChange(Rect bounds) {
|
||||||
Matrix m = new Matrix();
|
Matrix m = new Matrix();
|
||||||
m.setScale(bounds.width() / 72f, bounds.height() / 72f);
|
float scaleX = bounds.width() / 72f;
|
||||||
|
float scaleY = bounds.height() / 72f;
|
||||||
|
m.setScale(scaleX, scaleY);
|
||||||
pathForTurn.transform(m, pathForTurn);
|
pathForTurn.transform(m, pathForTurn);
|
||||||
|
centerText.x = scaleX * centerText.x;
|
||||||
|
centerText.y = scaleY * centerText.y;
|
||||||
pathForTurnOutlay.transform(m, pathForTurnOutlay);
|
pathForTurnOutlay.transform(m, pathForTurnOutlay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,6 +182,17 @@ public class NextTurnInfoWidget extends TextInfoWidget {
|
||||||
canvas.drawPath(pathForTurnOutlay, paintBlack);
|
canvas.drawPath(pathForTurnOutlay, paintBlack);
|
||||||
canvas.drawPath(pathForTurn, paintRouteDirection);
|
canvas.drawPath(pathForTurn, paintRouteDirection);
|
||||||
canvas.drawPath(pathForTurn, paintBlack);
|
canvas.drawPath(pathForTurn, paintBlack);
|
||||||
|
if(textPaint != null ) {
|
||||||
|
if (turnType != null && !mini && turnType.getExitOut() > 0) {
|
||||||
|
canvas.drawText(turnType.getExitOut() + "", centerText.x,
|
||||||
|
centerText.y + textPaint.getTextSize() / 2, textPaint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTextPaint(TextPaint textPaint) {
|
||||||
|
this.textPaint = textPaint;
|
||||||
|
this.textPaint.setTextAlign(Align.CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -186,7 +213,7 @@ public class NextTurnInfoWidget extends TextInfoWidget {
|
||||||
public boolean setTurnType(TurnType turnType) {
|
public boolean setTurnType(TurnType turnType) {
|
||||||
if(turnType != this.turnType) {
|
if(turnType != this.turnType) {
|
||||||
this.turnType = turnType;
|
this.turnType = turnType;
|
||||||
TurnPathHelper.calcTurnPath(pathForTurn, pathForTurnOutlay, turnType, null);
|
TurnPathHelper.calcTurnPath(pathForTurn, pathForTurnOutlay, turnType, null, centerText, mini);
|
||||||
onBoundsChange(getBounds());
|
onBoundsChange(getBounds());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -734,7 +734,7 @@ public class RouteInfoWidgetsFactory {
|
||||||
return bearingControl;
|
return bearingControl;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Path getPathFromTurnType(List<Path> paths, int laneType, Path defaultType, float coef) {
|
private static Path getPathFromTurnType(List<Path> paths, int laneType, Path defaultType, float coef, boolean mini) {
|
||||||
if(laneType == 0) {
|
if(laneType == 0) {
|
||||||
return defaultType;
|
return defaultType;
|
||||||
}
|
}
|
||||||
|
@ -749,7 +749,7 @@ public class RouteInfoWidgetsFactory {
|
||||||
Matrix pathTransform = new Matrix();
|
Matrix pathTransform = new Matrix();
|
||||||
pathTransform.postScale(coef, coef );
|
pathTransform.postScale(coef, coef );
|
||||||
TurnType tp = TurnType.valueOf(laneType, false);
|
TurnType tp = TurnType.valueOf(laneType, false);
|
||||||
TurnPathHelper.calcTurnPath(p, null, tp, pathTransform);
|
TurnPathHelper.calcTurnPath(p, null, tp, pathTransform, null, mini);
|
||||||
paths.set(laneType, p);
|
paths.set(laneType, p);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
@ -889,7 +889,7 @@ public class RouteInfoWidgetsFactory {
|
||||||
leftSide = settings.DRIVING_REGION.get().leftHandDriving;
|
leftSide = settings.DRIVING_REGION.get().leftHandDriving;
|
||||||
|
|
||||||
this.scaleCoefficient = scaleCoefficent;
|
this.scaleCoefficient = scaleCoefficent;
|
||||||
laneStraight = getPathFromTurnType(paths, TurnType.C, null, scaleCoefficient / miniCoeff);
|
laneStraight = getPathFromTurnType(paths, TurnType.C, null, scaleCoefficient / miniCoeff, true);
|
||||||
laneStraightBitmap = TurnPathHelper.getBitmapFromTurnType(ctx.getResources(), bitmapCache, TurnType.C, 0, 0, TurnPathHelper.FIRST_TURN, scaleCoefficient / miniCoeff, leftSide);
|
laneStraightBitmap = TurnPathHelper.getBitmapFromTurnType(ctx.getResources(), bitmapCache, TurnType.C, 0, 0, TurnPathHelper.FIRST_TURN, scaleCoefficient / miniCoeff, leftSide);
|
||||||
paintBlack = new Paint();
|
paintBlack = new Paint();
|
||||||
paintBlack.setStyle(Style.STROKE);
|
paintBlack.setStyle(Style.STROKE);
|
||||||
|
@ -1016,7 +1016,7 @@ public class RouteInfoWidgetsFactory {
|
||||||
paintRouteDirection.setColor(ctx.getResources().getColor(R.color.nav_arrow_distant));
|
paintRouteDirection.setColor(ctx.getResources().getColor(R.color.nav_arrow_distant));
|
||||||
turnType = TurnType.getPrimaryTurn(lanes[i]);
|
turnType = TurnType.getPrimaryTurn(lanes[i]);
|
||||||
}
|
}
|
||||||
Path p = getPathFromTurnType(paths, turnType, laneStraight, scaleCoefficient / miniCoeff);
|
Path p = getPathFromTurnType(paths, turnType, laneStraight, scaleCoefficient / miniCoeff, true);
|
||||||
canvas.drawPath(p, paintBlack);
|
canvas.drawPath(p, paintBlack);
|
||||||
canvas.drawPath(p, paintRouteDirection);
|
canvas.drawPath(p, paintRouteDirection);
|
||||||
canvas.translate(w, 0);
|
canvas.translate(w, 0);
|
||||||
|
|
|
@ -23,7 +23,7 @@ public class TextInfoWidget {
|
||||||
private TextView smallTextView;
|
private TextView smallTextView;
|
||||||
private TextView smallTextViewShadow;
|
private TextView smallTextViewShadow;
|
||||||
private ImageView topImageView;
|
private ImageView topImageView;
|
||||||
private TextView topTextView;
|
protected TextView topTextView;
|
||||||
private boolean explicitlyVisible;
|
private boolean explicitlyVisible;
|
||||||
private OsmandApplication app;
|
private OsmandApplication app;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue