Update look and feel

This commit is contained in:
Victor Shcherb 2011-11-26 13:35:48 +01:00
parent ea5909882b
commit 76996469da
2 changed files with 40 additions and 28 deletions

View file

@ -126,12 +126,12 @@ public class MapActivityLayers {
// 5.5 transport info layer
transportInfoLayer = new TransportInfoLayer(TransportRouteHelper.getInstance());
mapView.addLayer(transportInfoLayer, 5.5f);
// 6. point navigation layer
navigationLayer = new PointNavigationLayer();
mapView.addLayer(navigationLayer, 6);
// 7. point location layer
// 6. point location layer
locationLayer = new PointLocationLayer();
mapView.addLayer(locationLayer, 7);
mapView.addLayer(locationLayer, 6);
// 7. point navigation layer
navigationLayer = new PointNavigationLayer();
mapView.addLayer(navigationLayer, 7);
// 8. map info layer
mapInfoLayer = new MapInfoLayer(activity, routeLayer);
mapView.addLayer(mapInfoLayer, 8);

View file

@ -22,6 +22,7 @@ public class PointLocationLayer implements OsmandMapLayer {
private Paint locationPaint;
private Paint area;
private Paint aroundArea;
private Paint headingPaint;
protected Location lastKnownLocation = null;
@ -42,7 +43,13 @@ public class PointLocationLayer implements OsmandMapLayer {
area = new Paint();
area.setColor(Color.BLUE);
area.setAlpha(40);
area.setAlpha(40);
aroundArea = new Paint();
aroundArea.setColor(Color.rgb(112, 124, 220));
aroundArea.setStyle(Style.STROKE);
aroundArea.setStrokeWidth(1);
aroundArea.setAntiAlias(true);
headingPaint = new Paint();
headingPaint.setColor(Color.BLUE);
@ -66,41 +73,46 @@ public class PointLocationLayer implements OsmandMapLayer {
private RectF getHeadingRect(int locationX, int locationY){
int rad = Math.min(3*view.getWidth()/8, 3*view.getHeight()/8);
int rad = Math.min(3 * view.getWidth() / 8, 3 * view.getHeight() / 8);
return new RectF(locationX - rad, locationY - rad, locationX + rad, locationY + rad);
}
@Override
public void onDraw(Canvas canvas, RectF latLonBounds, RectF tilesRect, boolean nightMode) {
// draw
if(lastKnownLocation == null || view == null){
return;
}
int locationX = view.getMapXForPoint(lastKnownLocation.getLongitude());
int locationY = view.getMapYForPoint(lastKnownLocation.getLatitude());
int radius = MapUtils.getLengthXFromMeters(view.getZoom(), view.getLatitude(), view.getLongitude(),
lastKnownLocation.getAccuracy(), view.getTileSize(), view.getWidth());
if (radius > RADIUS * dm.density) {
int allowedRad = Math.min(view.getWidth() / 2, view.getHeight() / 2);
canvas.drawCircle(locationX, locationY, Math.min(radius, allowedRad), area);
canvas.drawCircle(locationX, locationY, Math.min(radius, allowedRad), aroundArea);
}
// draw bearing/direction/location
if (isLocationVisible(lastKnownLocation)) {
checkAppMode(view.getSettings().getApplicationMode());
int locationX = view.getMapXForPoint(lastKnownLocation.getLongitude());
int locationY = view.getMapYForPoint(lastKnownLocation.getLatitude());
int radius = MapUtils.getLengthXFromMeters(view.getZoom(), view.getLatitude(), view.getLongitude(),
lastKnownLocation.getAccuracy(), view.getTileSize(), view.getWidth());
boolean isBearing = lastKnownLocation.hasBearing();
if(!isBearing){
canvas.drawBitmap(locationIcon, locationX - locationIcon.getWidth() / 2,
locationY - locationIcon.getHeight() / 2, locationPaint);
if (!isBearing) {
canvas.drawBitmap(locationIcon, locationX - locationIcon.getWidth() / 2, locationY - locationIcon.getHeight() / 2,
locationPaint);
}
if (radius > RADIUS * dm.density) {
canvas.drawCircle(locationX, locationY, radius, area);
if (heading != null) {
canvas.drawArc(getHeadingRect(locationX, locationY), heading - HEADING_ANGLE / 2 - 90, HEADING_ANGLE, true, headingPaint);
}
if(heading != null){
canvas.drawArc(getHeadingRect(locationX, locationY),
heading - HEADING_ANGLE/ 2 - 90, HEADING_ANGLE, true, headingPaint);
}
if(isBearing){
if (isBearing) {
float bearing = lastKnownLocation.getBearing();
canvas.rotate(bearing - 90, locationX, locationY);
canvas.drawBitmap(bearingIcon, locationX - bearingIcon.getWidth() / 2,
locationY - bearingIcon.getHeight() / 2, locationPaint);
canvas.drawBitmap(bearingIcon, locationX - bearingIcon.getWidth() / 2, locationY - bearingIcon.getHeight() / 2,
locationPaint);
}
}
}