implement rendering

git-svn-id: https://osmand.googlecode.com/svn/trunk@501 e29c36b1-1cfa-d876-8d93-3434fc2bb7b8
This commit is contained in:
Victor Shcherb 2010-09-15 15:17:56 +00:00
parent 53d8e49c1d
commit 428fab7854
6 changed files with 440 additions and 342 deletions

View file

@ -54,11 +54,10 @@ public class MapRenderingTypes {
// TODO place text : (ref - shield) // TODO place text : (ref - shield)
// TODO coastline // TODO coastline
// TODO render : bridge (common way), tunnel, hw, railway : construction, proposed public final static int HIGHWAY = 1;
public final static int HIGHWAY = 1; //TODO REVIEW,traffic
public final static int BARRIER = 2; public final static int BARRIER = 2;
public final static int WATERWAY = 3; public final static int WATERWAY = 3;
public final static int RAILWAY = 4;//TODO RENDER public final static int RAILWAY = 4;
public final static int AEROWAY = 5; public final static int AEROWAY = 5;
public final static int AERIALWAY = 6; public final static int AERIALWAY = 6;
public final static int POWER = 7; public final static int POWER = 7;

View file

@ -30,6 +30,7 @@ import android.graphics.RectF;
import android.graphics.Shader; import android.graphics.Shader;
import android.graphics.Bitmap.Config; import android.graphics.Bitmap.Config;
import android.graphics.Paint.Align; import android.graphics.Paint.Align;
import android.graphics.Paint.Cap;
import android.graphics.Paint.Style; import android.graphics.Paint.Style;
import android.graphics.Shader.TileMode; import android.graphics.Shader.TileMode;
import android.text.TextPaint; import android.text.TextPaint;
@ -38,20 +39,14 @@ import android.util.FloatMath;
public class OsmandRenderer implements Comparator<MapRenderObject> { public class OsmandRenderer implements Comparator<MapRenderObject> {
private static final Log log = LogUtil.getLog(OsmandRenderer.class); private static final Log log = LogUtil.getLog(OsmandRenderer.class);
private Paint paintStroke;
private TextPaint paintText; private TextPaint paintText;
private Paint paintFill; private Paint paint;
private Paint paintFillEmpty; private Paint paintFillEmpty;
private Paint paintIcon; private Paint paintIcon;
/// Colors /// Colors
private int clFillScreen = Color.rgb(241, 238, 232); private int clFillScreen = Color.rgb(241, 238, 232);
private PathEffect arrowDashEffect1 = new DashPathEffect(new float[] { 0, 12, 10, 152 }, 0);
private PathEffect arrowDashEffect2 = new DashPathEffect(new float[] { 0, 12, 9, 153 }, 1);
private PathEffect arrowDashEffect3 = new DashPathEffect(new float[] { 0, 18, 2, 154 }, 1);
private PathEffect arrowDashEffect4 = new DashPathEffect(new float[] { 0, 18, 1, 155 }, 1);
private Map<String, PathEffect> dashEffect = new LinkedHashMap<String, PathEffect>(); private Map<String, PathEffect> dashEffect = new LinkedHashMap<String, PathEffect>();
private Map<Integer, Shader> shaders = new LinkedHashMap<Integer, Shader>(); private Map<Integer, Shader> shaders = new LinkedHashMap<Integer, Shader>();
@ -99,35 +94,65 @@ public class OsmandRenderer implements Comparator<MapRenderObject> {
// use to calculate points // use to calculate points
PointF tempPoint = new PointF(); PointF tempPoint = new PointF();
// use to set rendering properties
int color = Color.BLACK;
// polyline props // polyline props
boolean showText = true; boolean showText = true;
PathEffect pathEffect = null;
int shadowLayer = 0;
int shadowColor = 0;
float strokeWidth = 0;
float secondStrokeWidth = 0; RenderingPaintProperties main = new RenderingPaintProperties();
int secondColor = 0; RenderingPaintProperties second = new RenderingPaintProperties();
PathEffect secondEffect = null; RenderingPaintProperties third = new RenderingPaintProperties();
RenderingPaintProperties[] adds = null;
// polygon props }
boolean showPolygon = true;
int colorAround = 0; /* package*/ static class RenderingPaintProperties {
int widthAround = 1; int color;
Shader shader = null; float strokeWidth;
int shadowLayer;
int shadowColor;
boolean fillArea;
PathEffect pathEffect;
Shader shader;
Cap cap;
public void emptyLine(){
color = 0;
strokeWidth = 0;
cap = Cap.BUTT;
pathEffect = null;
fillArea = false;
shader = null;
shadowColor = 0;
shadowLayer = 0;
}
public void updatePaint(Paint p){
p.setStyle(fillArea ? Style.FILL_AND_STROKE : Style.STROKE);
p.setColor(color);
p.setShader(shader);
p.setShadowLayer(shadowLayer, 0, 0, shadowColor);
if (!fillArea) {
p.setStrokeCap(cap);
p.setPathEffect(pathEffect);
p.setStrokeWidth(strokeWidth);
}
}
public void emptyArea(){
color = 0;
strokeWidth = 0;
cap = Cap.BUTT;
fillArea = false;
shader = null;
pathEffect = null;
shadowColor = 0;
shadowLayer = 0;
}
} }
public OsmandRenderer(Context context){ public OsmandRenderer(Context context){
this.context = context; this.context = context;
paintStroke = new Paint();
paintStroke.setStyle(Style.STROKE);
paintStroke.setStrokeWidth(2);
paintStroke.setColor(Color.BLACK);
paintStroke.setAntiAlias(true);
paintIcon = new Paint(); paintIcon = new Paint();
paintIcon.setStyle(Style.STROKE); paintIcon.setStyle(Style.STROKE);
@ -138,11 +163,8 @@ public class OsmandRenderer implements Comparator<MapRenderObject> {
paintText.setTextAlign(Align.CENTER); paintText.setTextAlign(Align.CENTER);
paintText.setAntiAlias(true); paintText.setAntiAlias(true);
paintFill = new Paint(); paint = new Paint();
paintFill.setStyle(Style.FILL_AND_STROKE); paint.setAntiAlias(true);
paintFill.setStrokeWidth(2);
paintFill.setColor(Color.LTGRAY);
paintFill.setAntiAlias(true);
paintFillEmpty = new Paint(); paintFillEmpty = new Paint();
paintFillEmpty.setStyle(Style.FILL); paintFillEmpty.setStyle(Style.FILL);
@ -304,28 +326,23 @@ public class OsmandRenderer implements Comparator<MapRenderObject> {
return rc.tempPoint; return rc.tempPoint;
} }
private PointF drawPolygon(MapRenderObject obj, Canvas canvas, RenderingContext rc) { private PointF drawPolygon(MapRenderObject obj, Canvas canvas, RenderingContext rc) {
Paint paint = paintFill;
float xText = 0; float xText = 0;
float yText = 0; float yText = 0;
int zoom = rc.zoom; int zoom = rc.zoom;
Path path = null; Path path = null;
int type = MapRenderingTypes.getObjectType(obj.getType()); int type = MapRenderingTypes.getObjectType(obj.getType());
int subtype = MapRenderingTypes.getPolygonSubType(obj.getType()); int subtype = MapRenderingTypes.getPolygonSubType(obj.getType());
rc.color = Color.rgb(245, 245, 245); rc.main.emptyArea();
rc.shader = null; rc.second.emptyLine();
rc.colorAround = 0; rc.main.color = Color.rgb(245, 245, 245);
rc.showPolygon = true;
PolygonRenderer.renderPolygon(rc, zoom, type, subtype, this); PolygonRenderer.renderPolygon(rc, zoom, type, subtype, this);
if(!rc.showPolygon){ if(!rc.main.fillArea){
return null; return null;
} }
paint.setColor(rc.color);
for (int i = 0; i < obj.getPointsLength(); i++) { for (int i = 0; i < obj.getPointsLength(); i++) {
PointF p = calcPoint(obj, i, rc); PointF p = calcPoint(obj, i, rc);
xText += p.x; xText += p.x;
@ -341,13 +358,11 @@ public class OsmandRenderer implements Comparator<MapRenderObject> {
if (path != null) { if (path != null) {
xText /= obj.getPointsLength(); xText /= obj.getPointsLength();
yText /= obj.getPointsLength(); yText /= obj.getPointsLength();
paint.setShader(rc.shader); rc.main.updatePaint(paint);
canvas.drawPath(path, paint); canvas.drawPath(path, paint);
if(rc.colorAround != 0){ if(rc.second.strokeWidth != 0){
paintStroke.setPathEffect(null); rc.second.updatePaint(paint);
paintStroke.setColor(rc.colorAround); canvas.drawPath(path, paint);
paintStroke.setStrokeWidth(1);
canvas.drawPath(path, paintStroke);
} }
String name = obj.getName(); String name = obj.getName();
if(name != null){ if(name != null){
@ -490,9 +505,13 @@ public class OsmandRenderer implements Comparator<MapRenderObject> {
private void drawPolyline(MapRenderObject obj, Canvas canvas, RenderingContext rc) { private void drawPolyline(MapRenderObject obj, Canvas canvas, RenderingContext rc) {
int type = MapRenderingTypes.getObjectType(obj.getType()); int type = MapRenderingTypes.getObjectType(obj.getType());
int subtype = MapRenderingTypes.getPolylineSubType(obj.getType()); int subtype = MapRenderingTypes.getPolylineSubType(obj.getType());
rc.main.emptyLine();
rc.second.emptyLine();
rc.third.emptyLine();
rc.adds = null;
PolylineRenderer.renderPolyline(type, subtype, obj.getType(), rc, this); PolylineRenderer.renderPolyline(type, subtype, obj.getType(), rc, this);
if(rc.strokeWidth == 0){ if(rc.main.strokeWidth == 0){
return; return;
} }
int length = obj.getPointsLength(); int length = obj.getPointsLength();
@ -539,32 +558,24 @@ public class OsmandRenderer implements Comparator<MapRenderObject> {
yPrev = p.y; yPrev = p.y;
} }
if (path != null) { if (path != null) {
paintStroke.setPathEffect(rc.pathEffect); rc.main.updatePaint(paint);
if(paintStroke.getShader() != null){ canvas.drawPath(path, paint);
paintStroke.setShader(null); if (rc.second.strokeWidth != 0) {
} rc.second.updatePaint(paint);
paintStroke.setShadowLayer(rc.shadowLayer, 0, 0, rc.shadowColor); canvas.drawPath(path, paint);
paintStroke.setColor(rc.color); if (rc.third.strokeWidth != 0) {
paintStroke.setStrokeWidth(rc.strokeWidth); rc.third.updatePaint(paint);
canvas.drawPath(path, paintStroke); canvas.drawPath(path, paint);
if (rc.secondStrokeWidth > 0) {
paintStroke.setPathEffect(rc.secondEffect);
paintStroke.setShader(null);
if (rc.shadowLayer != 0) {
paintStroke.setShadowLayer(0, 0, 0, 0);
} }
paintStroke.setColor(rc.secondColor);
paintStroke.setStrokeWidth(rc.secondStrokeWidth);
canvas.drawPath(path, paintStroke);
} }
if(type == MapRenderingTypes.HIGHWAY && rc.zoom >= 16 && MapRenderingTypes.isOneWayWay(obj.getType())){ if (rc.adds != null) {
if (rc.shadowLayer != 0) { for (int i = 0; i < rc.adds.length; i++) {
paintStroke.setShadowLayer(0, 0, 0, 0); rc.adds[i].updatePaint(paint);
canvas.drawPath(path, paint);
} }
drawOneWayDirections(canvas, path);
} }
if (obj.getName() != null && rc.showText) { if (obj.getName() != null && rc.showText) {
float w = rc.strokeWidth + 3; float w = rc.main.strokeWidth + 3;
if(w < 10){ if(w < 10){
w = 10; w = 10;
} }
@ -592,33 +603,13 @@ public class OsmandRenderer implements Comparator<MapRenderObject> {
text.drawOnPath = path; text.drawOnPath = path;
text.textColor = Color.BLACK; text.textColor = Color.BLACK;
text.textSize = w; text.textSize = w;
text.vOffset = rc.strokeWidth / 2 - 1; text.vOffset = rc.main.strokeWidth / 2 - 1;
rc.textToDraw.add(text); rc.textToDraw.add(text);
} }
} }
} }
} }
public void drawOneWayDirections(Canvas canvas, Path path){
paintStroke.setColor(0xff6c70d5);
paintStroke.setStrokeWidth(1);
paintStroke.setPathEffect(arrowDashEffect1);
canvas.drawPath(path, paintStroke);
paintStroke.setStrokeWidth(2);
paintStroke.setPathEffect(arrowDashEffect2);
canvas.drawPath(path, paintStroke);
paintStroke.setStrokeWidth(3);
paintStroke.setPathEffect(arrowDashEffect3);
canvas.drawPath(path, paintStroke);
paintStroke.setStrokeWidth(4);
paintStroke.setPathEffect(arrowDashEffect4);
canvas.drawPath(path, paintStroke);
}
} }

View file

@ -10,70 +10,81 @@ public class PointRenderer {
*/ */
public static int getPointBitmap(int zoom, int type, int subType) { public static int getPointBitmap(int zoom, int type, int subType) {
int resId = 0; int resId = 0;
if(type == MapRenderingTypes.HIGHWAY){ switch (type) {
case MapRenderingTypes.HIGHWAY: {
if (zoom >= 16) { if (zoom >= 16) {
if(subType == 38){ if (subType == 38) {
if(zoom > 16){ if (zoom > 16) {
resId = R.drawable.h_traffic_light; resId = R.drawable.h_traffic_light;
} }
} else if(subType == 40){ } else if (subType == 40) {
resId = zoom == 16 ? R.drawable.h_bus_stop_small : R.drawable.h_bus_stop; resId = zoom == 16 ? R.drawable.h_bus_stop_small : R.drawable.h_bus_stop;
} else if(subType == 23){ } else if (subType == 23) {
resId = R.drawable.h_transport_ford; resId = R.drawable.h_transport_ford;
} }
} }
if(subType == 35){ if (subType == 35) {
if(zoom >= 15){ if (zoom >= 15) {
resId = R.drawable.h_mini_round; resId = R.drawable.h_mini_round;
} }
} }
} else if(type == MapRenderingTypes.RAILWAY){ }
if(subType == 13){ break;
if(zoom == 12){ case MapRenderingTypes.RAILWAY: {
if (subType == 13) {
if (zoom == 12) {
resId = R.drawable.h_halt; resId = R.drawable.h_halt;
} else if(zoom == 13 || zoom == 14){ } else if (zoom == 13 || zoom == 14) {
resId = R.drawable.h_station_small; resId = R.drawable.h_station_small;
} else if(zoom >= 15){ } else if (zoom >= 15) {
resId = R.drawable.h_station; resId = R.drawable.h_station;
} }
} else if(subType == 22 || subType == 23){ } else if (subType == 22 || subType == 23) {
if(zoom == 13 || zoom == 14){ if (zoom == 13 || zoom == 14) {
resId = R.drawable.h_halt; resId = R.drawable.h_halt;
} else if(zoom >= 15){ } else if (zoom >= 15) {
resId = R.drawable.h_station_small; resId = R.drawable.h_station_small;
} }
} else if(subType == 25){ } else if (subType == 25) {
if(zoom == 14 || zoom == 15){ if (zoom == 14 || zoom == 15) {
resId = R.drawable.h_level_crossing; resId = R.drawable.h_level_crossing;
} else if(zoom >= 16){ } else if (zoom >= 16) {
resId = R.drawable.h_level_crossing2; resId = R.drawable.h_level_crossing2;
} }
} }
} else if(type == MapRenderingTypes.AEROWAY){ }
if(subType == 1){ break;
if(zoom >= 10 && zoom <= 14){ case MapRenderingTypes.AEROWAY: {
if (subType == 1) {
if (zoom >= 10 && zoom <= 14) {
resId = R.drawable.h_aerodrome; resId = R.drawable.h_aerodrome;
} }
} else if(subType == 10){ } else if (subType == 10) {
if(zoom >= 9 && zoom <= 13){ if (zoom >= 9 && zoom <= 13) {
resId = R.drawable.h_airport; resId = R.drawable.h_airport;
} }
} }
} else if(type == MapRenderingTypes.WATERWAY){ }
if(subType == 8){ break;
case MapRenderingTypes.WATERWAY: {
if (subType == 8) {
if (zoom > 14) { if (zoom > 14) {
resId = R.drawable.h_lock_gate; resId = R.drawable.h_lock_gate;
} }
} }
} else if(type == MapRenderingTypes.AERIALWAY){ }
if(subType == 7){ break;
if(zoom == 13 || zoom == 14){ case MapRenderingTypes.AERIALWAY: {
if (subType == 7) {
if (zoom == 13 || zoom == 14) {
resId = R.drawable.h_halt; resId = R.drawable.h_halt;
} else if(zoom >= 15){ } else if (zoom >= 15) {
resId = R.drawable.h_station_small; resId = R.drawable.h_station_small;
} }
} }
} else if(type == MapRenderingTypes.POWER){ }
break;
case MapRenderingTypes.POWER: {
if (zoom > 14) { if (zoom > 14) {
if (subType == 1) { if (subType == 1) {
resId = R.drawable.h_power_tower; resId = R.drawable.h_power_tower;
@ -81,7 +92,9 @@ public class PointRenderer {
resId = R.drawable.h_power_wind; resId = R.drawable.h_power_wind;
} }
} }
} else if (type == MapRenderingTypes.MAN_MADE) { }
break;
case MapRenderingTypes.MAN_MADE: {
if (subType == 25) { if (subType == 25) {
if (zoom >= 16) { if (zoom >= 16) {
resId = R.drawable.h_tower_water; resId = R.drawable.h_tower_water;
@ -95,7 +108,9 @@ public class PointRenderer {
resId = R.drawable.h_windmill; resId = R.drawable.h_windmill;
} }
} }
} else if(type == MapRenderingTypes.SHOP){ }
break;
case MapRenderingTypes.SHOP: {
if (zoom > 15) { if (zoom > 15) {
switch (subType) { switch (subType) {
case 27: case 27:
@ -128,11 +143,12 @@ public class PointRenderer {
case 16: case 16:
resId = R.drawable.h_shop_convenience; resId = R.drawable.h_shop_convenience;
break; break;
} }
} }
} else if(type == MapRenderingTypes.TOURISM){ }
break;
case MapRenderingTypes.TOURISM: {
if (zoom > 15) { if (zoom > 15) {
switch (subType) { switch (subType) {
case 4: case 4:
@ -166,27 +182,31 @@ public class PointRenderer {
break; break;
} }
} }
} else if(type == MapRenderingTypes.NATURAL){ }
break;
case MapRenderingTypes.NATURAL: {
if (subType == 13) { if (subType == 13) {
if (zoom > 10) { if (zoom > 10) {
resId = R.drawable.h_peak; resId = R.drawable.h_peak;
} }
} else if(subType == 3){ } else if (subType == 3) {
if (zoom > 14) { if (zoom > 14) {
resId = R.drawable.h_cave_entrance; resId = R.drawable.h_cave_entrance;
} }
} else if(subType == 17){ } else if (subType == 17) {
if (zoom >= 14) { if (zoom >= 14) {
resId = R.drawable.h_spring; resId = R.drawable.h_spring;
} }
} else if(subType == 19){ } else if (subType == 19) {
if (zoom == 16) { if (zoom == 16) {
resId = R.drawable.h_tree; resId = R.drawable.h_tree;
} else if (zoom >= 17) { } else if (zoom >= 17) {
resId = R.drawable.h_tree2; resId = R.drawable.h_tree2;
} }
} }
} else if(type == MapRenderingTypes.HISTORIC){ }
break;
case MapRenderingTypes.HISTORIC: {
if (zoom > 15) { if (zoom > 15) {
if (subType == 6) { if (subType == 6) {
resId = R.drawable.h_memorial; resId = R.drawable.h_memorial;
@ -194,31 +214,37 @@ public class PointRenderer {
// something historic // something historic
resId = R.drawable.h_view_point; resId = R.drawable.h_view_point;
} }
} }
} else if(type == MapRenderingTypes.BARRIER){ }
if(subType == 21){ break;
if(zoom >= 15){ case MapRenderingTypes.BARRIER: {
if (subType == 21) {
if (zoom >= 15) {
resId = R.drawable.h_gate2; resId = R.drawable.h_gate2;
} }
} else if(subType == 22){ } else if (subType == 22) {
if(zoom >= 16){ if (zoom >= 16) {
resId = R.drawable.h_liftgate; resId = R.drawable.h_liftgate;
} }
} else if(subType == 26){ } else if (subType == 26) {
if(zoom >= 16){ if (zoom >= 16) {
resId = R.drawable.h_bollard; resId = R.drawable.h_bollard;
} }
} }
} else if(type == MapRenderingTypes.EMERGENCY){ }
if(zoom > 15){ break;
if(subType == 10){ case MapRenderingTypes.EMERGENCY: {
if (zoom > 15) {
if (subType == 10) {
resId = R.drawable.h_firestation; resId = R.drawable.h_firestation;
} else if(subType == 7){ } else if (subType == 7) {
resId = R.drawable.h_sosphone; resId = R.drawable.h_sosphone;
} }
} }
} else if(type == MapRenderingTypes.AMENITY_SUSTENANCE){ }
break;
case MapRenderingTypes.AMENITY_SUSTENANCE: {
if (zoom > 15) { if (zoom > 15) {
switch (subType) { switch (subType) {
case 1: case 1:
@ -242,37 +268,43 @@ public class PointRenderer {
break; break;
} }
} }
} else if(type == MapRenderingTypes.AMENITY_EDUCATION){ }
if (zoom > 15){ break;
if(subType == 2){ case MapRenderingTypes.AMENITY_EDUCATION: {
if (zoom > 15) {
if (subType == 2) {
resId = R.drawable.h_school; resId = R.drawable.h_school;
} else if(subType == 4){ } else if (subType == 4) {
resId = R.drawable.h_library; resId = R.drawable.h_library;
} }
} }
} else if (type == MapRenderingTypes.AMENITY_TRANSPORTATION) { }
break;
case MapRenderingTypes.AMENITY_TRANSPORTATION: {
if (subType == 1 || subType == 2) { if (subType == 1 || subType == 2) {
if (zoom > 14) { if (zoom > 14) {
resId = R.drawable.h_parking; resId = R.drawable.h_parking;
} }
} else if (subType == 4) { } else if (subType == 4) {
if(zoom > 13){ if (zoom > 13) {
resId = R.drawable.h_fuel; resId = R.drawable.h_fuel;
} }
} else if (subType == 17) { } else if (subType == 17) {
if(zoom >= 17){ if (zoom >= 17) {
resId = R.drawable.h_rental_bicycle; resId = R.drawable.h_rental_bicycle;
} }
} else if (subType == 20) { } else if (subType == 20) {
if(zoom >= 16){ if (zoom >= 16) {
resId = R.drawable.h_car_share; resId = R.drawable.h_car_share;
} }
} else if (subType == 18) { } else if (subType == 18) {
if(zoom > 14){ if (zoom > 14) {
resId = R.drawable.h_bus_station; resId = R.drawable.h_bus_station;
} }
} }
} else if (type == MapRenderingTypes.AMENITY_FINANCE) { }
break;
case MapRenderingTypes.AMENITY_FINANCE: {
if (subType == 1) { if (subType == 1) {
if (zoom > 16) { if (zoom > 16) {
resId = R.drawable.h_atm; resId = R.drawable.h_atm;
@ -282,25 +314,31 @@ public class PointRenderer {
resId = R.drawable.h_bank; resId = R.drawable.h_bank;
} }
} }
} else if (type == MapRenderingTypes.AMENITY_HEALTHCARE) { }
break;
case MapRenderingTypes.AMENITY_HEALTHCARE: {
if (subType == 1) { if (subType == 1) {
if (zoom > 15) { if (zoom > 15) {
resId = R.drawable.h_pharmacy; resId = R.drawable.h_pharmacy;
} }
} else if (subType == 2) { } else if (subType == 2) {
if(zoom >= 15){ if (zoom >= 15) {
resId = R.drawable.h_hospital; resId = R.drawable.h_hospital;
} }
} }
} else if (type == MapRenderingTypes.AMENITY_ENTERTAINMENT) { }
break;
case MapRenderingTypes.AMENITY_ENTERTAINMENT: {
if (zoom >= 15) { if (zoom >= 15) {
if (subType == 3) { if (subType == 3) {
resId = R.drawable.h_cinema; resId = R.drawable.h_cinema;
} else if(subType == 9) { } else if (subType == 9) {
resId = R.drawable.h_theatre; resId = R.drawable.h_theatre;
} }
} }
} else if(type == MapRenderingTypes.AMENITY_OTHER){ }
break;
case MapRenderingTypes.AMENITY_OTHER: {
if (zoom > 16) { if (zoom > 16) {
switch (subType) { switch (subType) {
case 10: case 10:
@ -332,14 +370,15 @@ public class PointRenderer {
break; break;
} }
} }
if(zoom >= 16){ if (zoom >= 16) {
if(subType == 26){ if (subType == 26) {
resId = R.drawable.h_place_of_worship; resId = R.drawable.h_place_of_worship;
} else if(subType == 13){ } else if (subType == 13) {
resId = R.drawable.h_prison; resId = R.drawable.h_prison;
} }
} }
} }
}
return resId; return resId;
} }
} }

View file

@ -11,293 +11,298 @@ public class PolygonRenderer {
if (type == MapRenderingTypes.HIGHWAY) { if (type == MapRenderingTypes.HIGHWAY) {
if (subtype == MapRenderingTypes.PL_HW_SERVICE || subtype == MapRenderingTypes.PL_HW_UNCLASSIFIED if (subtype == MapRenderingTypes.PL_HW_SERVICE || subtype == MapRenderingTypes.PL_HW_UNCLASSIFIED
|| subtype == MapRenderingTypes.PL_HW_RESIDENTIAL) { || subtype == MapRenderingTypes.PL_HW_RESIDENTIAL) {
rc.colorAround = Color.rgb(194, 194, 194); rc.second.color = Color.rgb(194, 194, 194);
rc.color = Color.WHITE; rc.second.strokeWidth = 1;
rc.main.color= Color.WHITE;
} else if(subtype == MapRenderingTypes.PL_HW_PEDESTRIAN || subtype == MapRenderingTypes.PL_HW_FOOTWAY){ } else if(subtype == MapRenderingTypes.PL_HW_PEDESTRIAN || subtype == MapRenderingTypes.PL_HW_FOOTWAY){
rc.color = Color.rgb(236, 236, 236); rc.main.color = Color.rgb(236, 236, 236);
rc.colorAround = Color.rgb(176, 176, 176); rc.second.color = Color.rgb(176, 176, 176);
rc.second.strokeWidth = 1;
} }
} else if (type == MapRenderingTypes.RAILWAY) { } else if (type == MapRenderingTypes.RAILWAY) {
if(subtype == 13){ if(subtype == 13){
rc.showPolygon = zoom >= 13; rc.main.fillArea = zoom >= 13;
rc.color = 0xffd4aaaa; rc.main.color = 0xffd4aaaa;
} }
} else if (type == MapRenderingTypes.WATERWAY) { } else if (type == MapRenderingTypes.WATERWAY) {
if(subtype == 3){ if(subtype == 3){
rc.showPolygon = zoom >= 7; rc.main.fillArea = zoom >= 7;
rc.color = 0xffb5d0d0; rc.main.color = 0xffb5d0d0;
} else if(subtype == 4 || subtype == 7 || subtype == 13){ } else if(subtype == 4 || subtype == 7 || subtype == 13){
rc.showPolygon = zoom >= 10; rc.main.fillArea = zoom >= 10;
rc.color = 0xffb5d0d0; rc.main.color = 0xffb5d0d0;
} }
} else if (type == MapRenderingTypes.AEROWAY) { } else if (type == MapRenderingTypes.AEROWAY) {
if(subtype == 1 || subtype == 10){ if(subtype == 1 || subtype == 10){
rc.showPolygon = zoom >= 12; rc.main.fillArea = zoom >= 12;
rc.color = 0x80cccccc; rc.main.color = 0x80cccccc;
} else if(subtype == 2){ } else if(subtype == 2){
rc.showPolygon = zoom >= 15; rc.main.fillArea = zoom >= 15;
rc.color = 0xffcc99ff; rc.main.color = 0xffcc99ff;
} else if(subtype == 9){ } else if(subtype == 9){
// apron // apron
rc.showPolygon = zoom >= 13; rc.main.fillArea = zoom >= 13;
rc.color = 0xffe9d1ff; rc.main.color = 0xffe9d1ff;
} }
} else if (type == MapRenderingTypes.POWER) { } else if (type == MapRenderingTypes.POWER) {
if(subtype == 5 || subtype == 6){ if(subtype == 5 || subtype == 6){
rc.showPolygon = zoom >= 13; rc.main.fillArea = zoom >= 13;
rc.color = 0xffbbbbbb; rc.main.color = 0xffbbbbbb;
} }
} else if (type == MapRenderingTypes.MAN_MADE) { } else if (type == MapRenderingTypes.MAN_MADE) {
rc.showPolygon = zoom > 15; rc.main.fillArea = zoom > 15;
if (subtype == MapRenderingTypes.SUBTYPE_BUILDING) { if (subtype == MapRenderingTypes.SUBTYPE_BUILDING) {
rc.color = Color.rgb(188, 169, 169); rc.main.color = Color.rgb(188, 169, 169);
} else if (subtype == MapRenderingTypes.SUBTYPE_GARAGES) { } else if (subtype == MapRenderingTypes.SUBTYPE_GARAGES) {
rc.color = Color.rgb(221, 221, 221); rc.main.color = Color.rgb(221, 221, 221);
} }
} else if (type == MapRenderingTypes.TOURISM) { } else if (type == MapRenderingTypes.TOURISM) {
if (subtype == 2 || subtype == 7) { if (subtype == 2 || subtype == 7) {
rc.showPolygon = zoom >= 13; rc.main.fillArea = zoom >= 13;
rc.color = 0xfff2caea; rc.main.color = 0xfff2caea;
if(subtype == 7){ if(subtype == 7){
rc.colorAround = 0xff734a08; rc.second.color = 0xff734a08;
rc.pathEffect = o.getDashEffect("9_3"); //$NON-NLS-1$ rc.second.pathEffect = o.getDashEffect("9_3"); //$NON-NLS-1$
if(zoom <= 15){ if(zoom <= 15){
rc.strokeWidth = 1; rc.second.strokeWidth = 1;
} else { } else {
rc.strokeWidth = 2; rc.second.strokeWidth = 2;
} }
} }
} else if(subtype >= 4 && subtype <= 6){ } else if(subtype >= 4 && subtype <= 6){
rc.showPolygon = zoom >= 15; rc.main.fillArea = zoom >= 15;
rc.color = 0xa0ccff99; rc.main.color = 0xa0ccff99;
} else if(subtype == 8){ } else if(subtype == 8){
rc.showPolygon = zoom >= 13; rc.main.fillArea = zoom >= 13;
rc.shader = o.getShader(R.drawable.h_zoo); rc.main.shader = o.getShader(R.drawable.h_zoo);
} }
} else if (type == MapRenderingTypes.NATURAL) { } else if (type == MapRenderingTypes.NATURAL) {
switch(subtype){ switch(subtype){
case 2 : case 2 :
rc.showPolygon = zoom >= 13; rc.main.fillArea = zoom >= 13;
rc.shader = o.getShader(R.drawable.h_beach); rc.main.shader = o.getShader(R.drawable.h_beach);
case 5: case 5:
// TODO coastline // TODO coastline
break; break;
case 7: case 7:
rc.showPolygon = zoom >= 8; rc.main.fillArea = zoom >= 8;
rc.shader = o.getShader(R.drawable.h_glacier); rc.main.shader = o.getShader(R.drawable.h_glacier);
if(zoom >= 10){ if(zoom >= 10){
rc.colorAround = 0xff99ccff; rc.second.color = 0xff99ccff;
rc.widthAround = 2; rc.second.strokeWidth = 2;
} }
break; break;
case 8: case 8:
rc.showPolygon = zoom >= 10; rc.main.fillArea = zoom >= 10;
rc.color = 0xffffffc0; rc.main.color = 0xffffffc0;
break; break;
case 9: case 9:
rc.showPolygon = zoom >= 11; rc.main.fillArea = zoom >= 11;
rc.color = 0xfff2efe9; rc.main.color = 0xfff2efe9;
break; break;
case 11: case 11:
case 22: case 22:
rc.showPolygon = zoom >= 13; rc.main.fillArea = zoom >= 13;
rc.shader = o.getShader(R.drawable.h_marsh); rc.main.shader = o.getShader(R.drawable.h_marsh);
break; break;
case 12 : case 12 :
rc.showPolygon = zoom >= 13; rc.main.fillArea = zoom >= 13;
rc.shader = o.getShader(R.drawable.h_mud); rc.main.shader = o.getShader(R.drawable.h_mud);
break; break;
case 16 : case 16 :
rc.showPolygon = zoom >= 13; rc.main.fillArea = zoom >= 13;
rc.shader = o.getShader(R.drawable.h_scrub); rc.main.shader = o.getShader(R.drawable.h_scrub);
break; break;
case 21: case 21:
rc.showPolygon = zoom >= 7; rc.main.fillArea = zoom >= 7;
rc.color = 0xffb5d0d0; rc.main.color = 0xffb5d0d0;
break; break;
case 23 : case 23 :
rc.showPolygon = zoom >= 8; rc.main.fillArea = zoom >= 8;
rc.color = 0xffaed1a0; rc.main.color = 0xffaed1a0;
break; break;
} }
} else if (type == MapRenderingTypes.LANDUSE) { } else if (type == MapRenderingTypes.LANDUSE) {
switch (subtype) { switch (subtype) {
case 1: case 1:
rc.showPolygon = zoom >= 13; rc.main.fillArea = zoom >= 13;
rc.color = 0xffc8b084; rc.main.color = 0xffc8b084;
break; break;
case 2: case 2:
rc.showPolygon = zoom >= 10; rc.main.fillArea = zoom >= 10;
rc.color = 0xffb5d0d0; rc.main.color = 0xffb5d0d0;
break; break;
case 4: case 4:
rc.showPolygon = zoom >= 12; rc.main.fillArea = zoom >= 12;
if(zoom >= 12 && zoom <= 14){ if(zoom >= 12 && zoom <= 14){
rc.color = 0xffaacbaf; rc.main.color = 0xffaacbaf;
} else if (zoom > 14) { } else if (zoom > 14) {
rc.shader = o.getShader(R.drawable.h_grave_yard); rc.main.shader = o.getShader(R.drawable.h_grave_yard);
} }
break; break;
case 5: case 5:
rc.showPolygon = zoom >= 12; rc.main.fillArea = zoom >= 12;
rc.color = 0xffefc8c8; rc.main.color = 0xffefc8c8;
break; break;
case 3: case 3:
case 6: case 6:
case 13: case 13:
case 16: case 16:
rc.showPolygon = zoom >= 12; rc.main.fillArea = zoom >= 12;
rc.color = 0xff9d9d6c; rc.main.color = 0xff9d9d6c;
break; break;
case 7: case 7:
rc.showPolygon = zoom >= 11; rc.main.fillArea = zoom >= 11;
rc.color = 0xffead8bd; rc.main.color = 0xffead8bd;
break; break;
case 9: case 9:
rc.showPolygon = zoom >= 11; rc.main.fillArea = zoom >= 11;
rc.color = 0xffddbf92; rc.main.color = 0xffddbf92;
break; break;
case 10: case 10:
if(zoom < 8){ if(zoom < 8){
rc.showPolygon = false; rc.main.fillArea = false;
} else if(zoom <= 13){ } else if(zoom <= 13){
rc.color = 0xff8dc56c; rc.main.color = 0xff8dc56c;
} else { } else {
rc.shader = o.getShader(R.drawable.h_forest); rc.main.shader = o.getShader(R.drawable.h_forest);
} }
break; break;
case 11 : case 11 :
rc.color = Color.rgb(223, 209, 214); rc.main.color = Color.rgb(223, 209, 214);
break; break;
case 12: case 12:
case 17: case 17:
rc.showPolygon = zoom >= 12; rc.main.fillArea = zoom >= 12;
rc.color = 0xffcfeca8; rc.main.color = 0xffcfeca8;
break; break;
case 15: case 15:
case 20: case 20:
rc.color = 0xffdfd1d6; rc.main.color = 0xffdfd1d6;
rc.showPolygon = zoom >= 12; rc.main.fillArea = zoom >= 12;
break; break;
case 18: case 18:
rc.showPolygon = zoom >= 12; rc.main.fillArea = zoom >= 12;
rc.color = 0xa0ffa8a8; rc.main.color = 0xa0ffa8a8;
break; break;
case 19: case 19:
rc.showPolygon = zoom >= 10; rc.main.fillArea = zoom >= 10;
rc.shader = o.getShader(R.drawable.h_orchard); rc.main.shader = o.getShader(R.drawable.h_orchard);
break; break;
case 21: case 21:
rc.color = 0xffcfeca8; rc.main.color = 0xffcfeca8;
rc.showPolygon = zoom >= 12; rc.main.fillArea = zoom >= 12;
break; break;
case 22 : case 22 :
rc.showPolygon = zoom >= 7; rc.main.fillArea = zoom >= 7;
rc.color = 0xffb5d0d0; rc.main.color = 0xffb5d0d0;
break; break;
case 23: case 23:
rc.showPolygon = zoom >= 12; rc.main.fillArea = zoom >= 12;
rc.color = 0xffdddddd; rc.main.color = 0xffdddddd;
break; break;
case 24: case 24:
rc.showPolygon = zoom >= 12; rc.main.fillArea = zoom >= 12;
rc.color = 0xffcfeca8; rc.main.color = 0xffcfeca8;
if(zoom >= 15){ if(zoom >= 15){
rc.colorAround = Color.RED; rc.second.color = Color.RED;
rc.second.strokeWidth = 1;
} }
break; break;
case 26: case 26:
rc.showPolygon = zoom >= 13; rc.main.fillArea = zoom >= 13;
rc.shader = o.getShader(R.drawable.h_quarry2); rc.main.shader = o.getShader(R.drawable.h_quarry2);
break; break;
case 27: case 27:
rc.showPolygon = zoom >= 10; rc.main.fillArea = zoom >= 10;
if(zoom < 14){ if(zoom < 14){
rc.color = 0xffabdf96; rc.main.color = 0xffabdf96;
} else { } else {
rc.shader = o.getShader(R.drawable.h_vineyard); rc.main.shader = o.getShader(R.drawable.h_vineyard);
} }
break; break;
} }
} else if (type == MapRenderingTypes.MILITARY) { } else if (type == MapRenderingTypes.MILITARY) {
if(subtype == 3){ if(subtype == 3){
rc.showPolygon = zoom >= 13; rc.main.fillArea = zoom >= 13;
rc.color = 0xffff8f8f; rc.main.color = 0xffff8f8f;
} else if(subtype == 4){ } else if(subtype == 4){
rc.showPolygon = zoom >= 10; rc.main.fillArea = zoom >= 10;
rc.shader = o.getShader(R.drawable.h_danger); rc.main.shader = o.getShader(R.drawable.h_danger);
} }
} else if (type == MapRenderingTypes.LEISURE) { } else if (type == MapRenderingTypes.LEISURE) {
switch (subtype) { switch (subtype) {
case 2: case 2:
case 4: case 4:
rc.showPolygon = zoom >= 13; rc.main.fillArea = zoom >= 13;
rc.color = 0xff33cc99; rc.main.color = 0xff33cc99;
break; break;
case 3: case 3:
rc.showPolygon = zoom >= 12; rc.main.fillArea = zoom >= 12;
rc.color = 0xffb5e3b5; rc.main.color = 0xffb5e3b5;
break; break;
case 5: case 5:
rc.showPolygon = zoom >= 12; rc.main.fillArea = zoom >= 12;
rc.colorAround = 0xff888888; rc.second.color = 0xff888888;
rc.widthAround = 1; rc.second.strokeWidth = 1;
rc.color = 0xff74dcba; rc.main.color = 0xff74dcba;
break; break;
case 6: case 6:
rc.color = 0xff8ad3af; rc.main.color = 0xff8ad3af;
rc.showPolygon = zoom >= 13; rc.main.fillArea = zoom >= 13;
rc.colorAround = 0xff888888; rc.second.color = 0xff888888;
rc.widthAround = 1; rc.second.strokeWidth = 1;
break; break;
case 11: case 11:
if(zoom < 8){ if(zoom < 8){
rc.showPolygon = false; rc.main.fillArea = false;
} else if(zoom >= 8 && zoom <= 12){ } else if(zoom >= 8 && zoom <= 12){
rc.showPolygon = true; rc.main.fillArea = true;
rc.color = 0xffabdf96; rc.main.color = 0xffabdf96;
} else { } else {
rc.showPolygon = true; rc.main.fillArea = true;
rc.shader = o.getShader(R.drawable.h_nr); rc.main.shader = o.getShader(R.drawable.h_nr);
} }
break; break;
case 12: case 12:
rc.showPolygon = zoom >= 12; rc.main.fillArea = zoom >= 12;
rc.color = 0xb0b6fdb6; rc.main.color = 0xb0b6fdb6;
break; break;
case 13: case 13:
rc.color = 0xffccfff1; rc.main.color = 0xffccfff1;
rc.showPolygon = zoom >= 15; rc.main.fillArea = zoom >= 15;
break; break;
case 14: case 14:
case 15: case 15:
rc.showPolygon = zoom >= 12; rc.main.fillArea = zoom >= 12;
rc.color = 0xffcfeca8; rc.main.color = 0xffcfeca8;
break; break;
} }
} else if (type == MapRenderingTypes.AMENITY_HEALTHCARE) { } else if (type == MapRenderingTypes.AMENITY_HEALTHCARE) {
if (subtype == 2) { if (subtype == 2) {
rc.showPolygon = zoom >= 15; rc.main.fillArea = zoom >= 15;
rc.color = 0xfff0f0d8; rc.main.color = 0xfff0f0d8;
rc.colorAround = Color.rgb(212, 168, 158); rc.second.color = Color.rgb(212, 168, 158);
rc.second.strokeWidth = 1;
} }
} else if (type == MapRenderingTypes.AMENITY_TRANSPORTATION) { } else if (type == MapRenderingTypes.AMENITY_TRANSPORTATION) {
if (subtype == 1 || subtype == 2) { if (subtype == 1 || subtype == 2) {
rc.color = Color.rgb(246, 238, 183); rc.main.color = Color.rgb(246, 238, 183);
} }
} else if (type == MapRenderingTypes.AMENITY_ENTERTAINMENT) { } else if (type == MapRenderingTypes.AMENITY_ENTERTAINMENT) {
if (subtype == 3) { if (subtype == 3) {
rc.color = Color.rgb(204, 153, 153); rc.main.color = Color.rgb(204, 153, 153);
} }
} else if (type == MapRenderingTypes.AMENITY_EDUCATION) { } else if (type == MapRenderingTypes.AMENITY_EDUCATION) {
if(subtype == 1 || subtype == 2 || subtype == 3 || subtype == 5){ if(subtype == 1 || subtype == 2 || subtype == 3 || subtype == 5){
rc.showPolygon = zoom >= 15; rc.main.fillArea = zoom >= 15;
rc.color = 0xfff0f0d8; rc.main.color = 0xfff0f0d8;
rc.colorAround = Color.rgb(212, 168, 158); rc.second.color = Color.rgb(212, 168, 158);
rc.second.strokeWidth = 1;
} else { } else {
// draw as building education // draw as building education
rc.color = Color.rgb(188, 169, 169); rc.main.color = Color.rgb(188, 169, 169);
} }
} }
} }

View file

@ -2,24 +2,24 @@ package net.osmand.render;
import net.osmand.osm.MapRenderingTypes; import net.osmand.osm.MapRenderingTypes;
import net.osmand.render.OsmandRenderer.RenderingContext; import net.osmand.render.OsmandRenderer.RenderingContext;
import net.osmand.render.OsmandRenderer.RenderingPaintProperties;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.DashPathEffect;
import android.graphics.PathEffect; import android.graphics.PathEffect;
import android.graphics.Paint.Cap;
public class PolylineRenderer { public class PolylineRenderer {
public static void renderPolyline(int type, int subtype, int objType, RenderingContext rc, OsmandRenderer o){ public static void renderPolyline(int type, int subtype, int objType, RenderingContext rc, OsmandRenderer o){
int zoom = rc.zoom; int zoom = rc.zoom;
int color = Color.BLACK;
boolean showText = true; boolean showText = true;
int color = Color.BLACK;
PathEffect pathEffect = null; PathEffect pathEffect = null;
float strokeWidth = zoom >= 15 ? 1 : 0;
int shadowLayer = 0; int shadowLayer = 0;
int shadowColor = 0; int shadowColor = 0;
float strokeWidth = zoom >= 15 ? 1 : 0;
float secondStrokeWidth = 0;
int secondColor = 0;
PathEffect secondEffect = null;
switch (type) { switch (type) {
case MapRenderingTypes.HIGHWAY: { case MapRenderingTypes.HIGHWAY: {
@ -111,9 +111,9 @@ public class PolylineRenderer {
if (hwType == MapRenderingTypes.PL_HW_CONSTRUCTION || hwType == MapRenderingTypes.PL_HW_PROPOSED) { if (hwType == MapRenderingTypes.PL_HW_CONSTRUCTION || hwType == MapRenderingTypes.PL_HW_PROPOSED) {
strokeWidth = zoom >= 15 ? (zoom == 15 ? 6 : 8) : 0; strokeWidth = zoom >= 15 ? (zoom == 15 ? 6 : 8) : 0;
color = 0xff99cccc; color = 0xff99cccc;
secondColor = Color.WHITE; rc.second.color = Color.WHITE;
secondStrokeWidth = strokeWidth - 1; rc.second.strokeWidth = strokeWidth - 1;
secondEffect = o.getDashEffect("8_6"); //$NON-NLS-1$ rc.second.pathEffect = o.getDashEffect("8_6"); //$NON-NLS-1$
} else { } else {
if (hwType == MapRenderingTypes.PL_HW_TRACK) { if (hwType == MapRenderingTypes.PL_HW_TRACK) {
strokeWidth = zoom >= 14 ? 2f : 0; strokeWidth = zoom >= 14 ? 2f : 0;
@ -166,12 +166,26 @@ public class PolylineRenderer {
} }
} }
} }
if(bridge && zoom > 12){ if(bridge && zoom > 14){
if(secondStrokeWidth == 0){ if(rc.second.strokeWidth == 0){
shadowLayer = 2; rc.second.color = color;
shadowColor = Color.BLACK; rc.second.strokeWidth = strokeWidth;
rc.second.pathEffect = pathEffect;
strokeWidth += 2;
color = Color.BLACK;
pathEffect = null;
if(rc.second.pathEffect == null){
rc.second.cap = Cap.SQUARE;
} else {
color = 0x88ffffff;
}
} }
} }
if(type == MapRenderingTypes.HIGHWAY && rc.zoom >= 16 && MapRenderingTypes.isOneWayWay(objType)){
rc.adds = getOneWayProperties();
}
if (tunnel && zoom > 12 && carRoad) { if (tunnel && zoom > 12 && carRoad) {
pathEffect = o.getDashEffect("4_4"); //$NON-NLS-1$ pathEffect = o.getDashEffect("4_4"); //$NON-NLS-1$
} }
@ -197,27 +211,32 @@ public class PolylineRenderer {
} else if(zoom == 13){ } else if(zoom == 13){
color = 0xff999999; color = 0xff999999;
strokeWidth = 3; strokeWidth = 3;
secondColor = Color.WHITE; rc.second.color = Color.WHITE;
secondStrokeWidth = 1; rc.second.strokeWidth = 1;
secondEffect = o.getDashEffect("8_12"); //$NON-NLS-1$ rc.second.pathEffect = o.getDashEffect("8_12"); //$NON-NLS-1$
} else { } else {
color = 0xff999999; color = 0xff999999;
strokeWidth = 3; strokeWidth = 3;
secondColor = Color.WHITE; rc.second.color = Color.WHITE;
secondStrokeWidth = 1; rc.second.strokeWidth = 1;
if(tunnel){ if(tunnel){
// TODO tunnel rc.second.strokeWidth = 3;
rc.second.pathEffect = o.getDashEffect("4_4"); //$NON-NLS-1$
} else if(bridge){ } else if(bridge){
// TODO bridge rc.third.color = color;
secondStrokeWidth = 5; rc.third.strokeWidth = 1;
strokeWidth = 7; rc.third.pathEffect = o.getDashEffect("12_8_1_0"); //$NON-NLS-1$
rc.second.strokeWidth = 4;
strokeWidth = 5;
color = Color.BLACK ;
} else { } else {
secondEffect = o.getDashEffect("0_11_8_1"); //$NON-NLS-1$ rc.second.strokeWidth = 1;
rc.second.pathEffect = o.getDashEffect("0_11_8_1"); //$NON-NLS-1$
} }
} }
} else if(subtype == 2 ) { } else if(subtype == 2 ) {
color = 0xff44444; color = 0xff444444;
if(zoom < 13){ if(zoom < 13){
strokeWidth = 0; strokeWidth = 0;
} else if(zoom < 15){ } else if(zoom < 15){
@ -248,9 +267,9 @@ public class PolylineRenderer {
if(bridge){ if(bridge){
strokeWidth = 4.5f; strokeWidth = 4.5f;
color = Color.BLACK; color = Color.BLACK;
secondStrokeWidth = 2; rc.second.strokeWidth = 2;
secondColor = Color.GRAY; rc.second.color = Color.GRAY;
secondEffect =o.getDashEffect("4_2"); //$NON-NLS-1$ rc.second.pathEffect = o.getDashEffect("4_2"); //$NON-NLS-1$
} else { } else {
strokeWidth = 2; strokeWidth = 2;
color = Color.GRAY; color = Color.GRAY;
@ -273,9 +292,9 @@ public class PolylineRenderer {
} else { } else {
color = 0xff999999; color = 0xff999999;
strokeWidth = 3; strokeWidth = 3;
secondColor = Color.WHITE; rc.second.color = Color.WHITE;
secondStrokeWidth = 1; rc.second.strokeWidth = 1;
secondEffect = o.getDashEffect("0_1_8_1"); //$NON-NLS-1$ rc.second.pathEffect = o.getDashEffect("0_1_8_1"); //$NON-NLS-1$
} }
} else if (subtype == 8 || subtype == 11) { } else if (subtype == 8 || subtype == 11) {
if(zoom < 15){ if(zoom < 15){
@ -286,8 +305,8 @@ public class PolylineRenderer {
if(tunnel){ if(tunnel){
strokeWidth = 5; strokeWidth = 5;
pathEffect = o.getDashEffect("5_3"); //$NON-NLS-1$ pathEffect = o.getDashEffect("5_3"); //$NON-NLS-1$
secondColor = 0xffcccccc; rc.second.color = 0xffcccccc;
secondStrokeWidth = 3; rc.second.strokeWidth = 3;
} }
} }
} else if (subtype == 10) { } else if (subtype == 10) {
@ -383,8 +402,8 @@ public class PolylineRenderer {
} }
if(zoom > 12 && MapRenderingTypes.getWayLayer(objType) == 1){ if(zoom > 12 && MapRenderingTypes.getWayLayer(objType) == 1){
pathEffect = o.getDashEffect("4_2"); //$NON-NLS-1$ pathEffect = o.getDashEffect("4_2"); //$NON-NLS-1$
secondStrokeWidth = strokeWidth - 2; rc.second.strokeWidth = strokeWidth - 2;
secondColor = Color.WHITE; rc.second.color = Color.WHITE;
} }
} }
break; break;
@ -454,9 +473,19 @@ public class PolylineRenderer {
} }
} }
if(MapRenderingTypes.getWayLayer(objType) == 2 && zoom > 12){ if(MapRenderingTypes.getWayLayer(objType) == 2 && zoom > 12){
if(secondStrokeWidth == 0){ if(rc.second.strokeWidth == 0){
shadowLayer = 2; rc.second.color = color;
shadowColor = Color.BLACK; rc.second.strokeWidth = strokeWidth;
rc.second.pathEffect = pathEffect;
strokeWidth += 2;
color = Color.BLACK;
pathEffect = null;
if(rc.second.pathEffect == null){
rc.second.cap = Cap.SQUARE;
} else {
color = Color.GRAY;
}
} }
} }
} }
@ -592,14 +621,49 @@ public class PolylineRenderer {
break; break;
} }
rc.color = color; rc.main.color = color;
rc.pathEffect = pathEffect; rc.main.pathEffect = pathEffect;
rc.shadowColor = shadowColor; rc.main.shadowColor = shadowColor;
rc.shadowLayer = shadowLayer; rc.main.shadowLayer = shadowLayer;
rc.main.strokeWidth = strokeWidth;
rc.showText = showText; rc.showText = showText;
rc.strokeWidth = strokeWidth;
rc.secondColor = secondColor;
rc.secondEffect = secondEffect;
rc.secondStrokeWidth = secondStrokeWidth;
} }
private static RenderingPaintProperties[] oneWay = null;
public static RenderingPaintProperties[] getOneWayProperties(){
if(oneWay == null){
PathEffect arrowDashEffect1 = new DashPathEffect(new float[] { 0, 12, 10, 152 }, 0);
PathEffect arrowDashEffect2 = new DashPathEffect(new float[] { 0, 12, 9, 153 }, 1);
PathEffect arrowDashEffect3 = new DashPathEffect(new float[] { 0, 18, 2, 154 }, 1);
PathEffect arrowDashEffect4 = new DashPathEffect(new float[] { 0, 18, 1, 155 }, 1);
oneWay = new RenderingPaintProperties[4];
oneWay[0] = new RenderingPaintProperties();
oneWay[0].emptyLine();
oneWay[0].color = 0xff6c70d5;
oneWay[0].strokeWidth = 1;
oneWay[0].pathEffect = arrowDashEffect1;
oneWay[1] = new RenderingPaintProperties();
oneWay[1].emptyLine();
oneWay[1].color = 0xff6c70d5;
oneWay[1].strokeWidth = 2;
oneWay[1].pathEffect = arrowDashEffect2;
oneWay[2] = new RenderingPaintProperties();
oneWay[2].emptyLine();
oneWay[2].color = 0xff6c70d5;
oneWay[2].strokeWidth = 3;
oneWay[2].pathEffect = arrowDashEffect3;
oneWay[3] = new RenderingPaintProperties();
oneWay[3].emptyLine();
oneWay[3].color = 0xff6c70d5;
oneWay[3].strokeWidth = 4;
oneWay[3].pathEffect = arrowDashEffect4;
}
return oneWay;
}
} }

View file

@ -243,8 +243,8 @@ public class OsmandMapTileView extends SurfaceView implements IMapDownloaderCall
public void setZoom(float zoom){ public void setZoom(float zoom){
if ((map == null && zoom < 22) || if ((map == null && zoom < 22 && zoom > 0) ||
((map.getMaximumZoomSupported() + OVERZOOM_IN) >= zoom && map.getMinimumZoomSupported() <= zoom)) { (map != null && (map.getMaximumZoomSupported() + OVERZOOM_IN) >= zoom && map.getMinimumZoomSupported() <= zoom)) {
animatedDraggingThread.stopAnimating(); animatedDraggingThread.stopAnimating();
this.zoom = zoom; this.zoom = zoom;
refreshMap(); refreshMap();