Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
5f0b7dfaec
5 changed files with 80 additions and 53 deletions
|
@ -75,16 +75,6 @@ public class AudioNotesLayer extends OsmandMapLayer implements IContextMenuProvi
|
|||
return (int) (r * tb.getDensity());
|
||||
}
|
||||
|
||||
private QuadRect calculateRect(float x, float y, float width, float height) {
|
||||
QuadRect rf;
|
||||
double left = x - width / 2.0d;
|
||||
double top = y - height / 2.0d;
|
||||
double right = left + width;
|
||||
double bottom = top + height;
|
||||
rf = new QuadRect(left, top, right, bottom);
|
||||
return rf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
||||
}
|
||||
|
|
|
@ -70,6 +70,14 @@ public class FavoriteImageDrawable extends Drawable {
|
|||
canvas.translate(-dx, -dy);
|
||||
}
|
||||
|
||||
public void drawBitmapInCenter(Canvas canvas, float x, float y) {
|
||||
float dx = x - getIntrinsicWidth() / 2f;
|
||||
float dy = y - getIntrinsicHeight() / 2f;
|
||||
canvas.translate(dx, dy);
|
||||
draw(canvas);
|
||||
canvas.translate(-dx, -dy);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return 0;
|
||||
|
|
|
@ -1,15 +1,22 @@
|
|||
package net.osmand.plus.views;
|
||||
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Align;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.access.AccessibleToast;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.QuadTree;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.GPXUtilities.GPXFile;
|
||||
import net.osmand.plus.GPXUtilities.TrkSegment;
|
||||
|
@ -27,17 +34,12 @@ import net.osmand.plus.views.MapTextLayer.MapTextProvider;
|
|||
import net.osmand.render.RenderingRuleProperty;
|
||||
import net.osmand.render.RenderingRuleSearchRequest;
|
||||
import net.osmand.render.RenderingRulesStorage;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.Paint.Align;
|
||||
import android.graphics.Paint.Style;
|
||||
import android.graphics.Path;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.PorterDuff.Mode;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
|
||||
public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContextMenuProvider,
|
||||
MapTextProvider<WptPt> {
|
||||
|
@ -53,6 +55,8 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
private boolean isPaint_1;
|
||||
private int cachedHash;
|
||||
private int cachedColor;
|
||||
private Paint paintIcon;
|
||||
private Bitmap pointSmall;
|
||||
|
||||
private static final int startZoom = 7;
|
||||
|
||||
|
@ -74,9 +78,6 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
private List<TrkSegment> points;
|
||||
private GPXFile gpx;
|
||||
|
||||
|
||||
// private Drawable favoriteIcon;
|
||||
|
||||
|
||||
private void initUI() {
|
||||
paint = new Paint();
|
||||
|
@ -107,8 +108,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
paintTextIcon.setAntiAlias(true);
|
||||
|
||||
textLayer = view.getLayerByClass(MapTextLayer.class);
|
||||
//favoriteIcon = BitmapFactory.decodeResource(view.getResources(), R.drawable.poi_favourite);
|
||||
|
||||
|
||||
paintOuter = new Paint();
|
||||
paintOuter.setColor(0x88555555);
|
||||
paintOuter.setAntiAlias(true);
|
||||
|
@ -117,6 +117,9 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
paintInnerCircle.setStyle(Style.FILL_AND_STROKE);
|
||||
paintInnerCircle.setColor(0xddFFFFFF);
|
||||
paintInnerCircle.setAntiAlias(true);
|
||||
|
||||
paintIcon = new Paint();
|
||||
pointSmall = BitmapFactory.decodeResource(view.getResources(), R.drawable.map_white_shield_small);
|
||||
}
|
||||
|
||||
|
||||
|
@ -272,27 +275,53 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
|||
int defPointColor = view.getResources().getColor(R.color.gpx_color_point);
|
||||
int visitedColor = view.getContext().getResources().getColor(R.color.color_ok);
|
||||
if (tileBox.getZoom() >= startZoom) {
|
||||
float iconSize = FavoriteImageDrawable.getOrCreate(view.getContext(), 0,
|
||||
tileBox.getDensity()).getIntrinsicWidth() * 3 / 2.5f;
|
||||
QuadRect bounds = new QuadRect(0, 0, tileBox.getPixWidth(), tileBox.getPixHeight());
|
||||
bounds.inset(-bounds.width()/4, -bounds.height()/4);
|
||||
QuadTree<QuadRect> boundIntersections = new QuadTree<>(bounds, 4, 0.6f);
|
||||
List<QuadRect> result = new ArrayList<>();
|
||||
// request to load
|
||||
final QuadRect latLonBounds = tileBox.getLatLonBounds();
|
||||
for (SelectedGpxFile g : selectedGPXFiles) {
|
||||
List<WptPt> pts = getListStarPoints(g);
|
||||
List<WptPt> fullObjects = new ArrayList<>();
|
||||
int fcolor = g.getColor() == 0 ? defPointColor : g.getColor();
|
||||
|
||||
for (WptPt o : pts) {
|
||||
boolean visit = isPointVisited(o);
|
||||
int pointColor = visit ? visitedColor : o.getColor(fcolor);
|
||||
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(view.getContext(), pointColor,
|
||||
tileBox.getDensity());
|
||||
if (o.lat >= latLonBounds.bottom && o.lat <= latLonBounds.top
|
||||
&& o.lon >= latLonBounds.left && o.lon <= latLonBounds.right) {
|
||||
cache.add(o);
|
||||
int x = (int) tileBox.getPixXFromLatLon(o.lat, o.lon);
|
||||
int y = (int) tileBox.getPixYFromLatLon(o.lat, o.lon);
|
||||
fid.drawBitmapInCenter(canvas, x, y);
|
||||
// canvas.drawBitmap(favoriteIcon, x - favoriteIcon.getWidth() / 2,
|
||||
// y - favoriteIcon.getHeight(), paint);
|
||||
float x = tileBox.getPixXFromLatLon(o.lat, o.lon);
|
||||
float y = tileBox.getPixYFromLatLon(o.lat, o.lon);
|
||||
|
||||
boolean intersects = false;
|
||||
QuadRect visibleRect = calculateRect(x, y, iconSize, iconSize);
|
||||
boundIntersections.queryInBox(new QuadRect(visibleRect.left, visibleRect.top, visibleRect.right, visibleRect.bottom), result);
|
||||
for (QuadRect r : result) {
|
||||
if (QuadRect.intersects(r, visibleRect)) {
|
||||
intersects = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (intersects) {
|
||||
canvas.drawBitmap(pointSmall, x - pointSmall.getWidth() / 2, y - pointSmall.getHeight() / 2, paintIcon);
|
||||
} else {
|
||||
boundIntersections.insert(visibleRect,
|
||||
new QuadRect(visibleRect.left, visibleRect.top, visibleRect.right, visibleRect.bottom));
|
||||
fullObjects.add(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (WptPt o : fullObjects) {
|
||||
float x = tileBox.getPixXFromLatLon(o.lat, o.lon);
|
||||
float y = tileBox.getPixYFromLatLon(o.lat, o.lon);
|
||||
boolean visit = isPointVisited(o);
|
||||
int pointColor = visit ? visitedColor : o.getColor(fcolor);
|
||||
FavoriteImageDrawable fid = FavoriteImageDrawable.getOrCreate(view.getContext(), pointColor,
|
||||
tileBox.getDensity());
|
||||
fid.drawBitmapInCenter(canvas, x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import gnu.trove.list.array.TIntArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.util.MapAlgorithms;
|
||||
|
@ -156,7 +157,16 @@ public abstract class OsmandMapLayer {
|
|||
}
|
||||
return cnt;
|
||||
}
|
||||
|
||||
|
||||
public QuadRect calculateRect(float x, float y, float width, float height) {
|
||||
QuadRect rf;
|
||||
double left = x - width / 2.0d;
|
||||
double top = y - height / 2.0d;
|
||||
double right = left + width;
|
||||
double bottom = top + height;
|
||||
rf = new QuadRect(left, top, right, bottom);
|
||||
return rf;
|
||||
}
|
||||
|
||||
public abstract class MapLayerData<T> {
|
||||
public int ZOOM_THRESHOLD = 1;
|
||||
|
|
|
@ -217,16 +217,6 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
|||
return (int) (r * tb.getDensity());
|
||||
}
|
||||
|
||||
private QuadRect calculateRect(float x, float y, float width, float height) {
|
||||
QuadRect rf;
|
||||
double left = x - width / 2.0d;
|
||||
double top = y - height / 2.0d;
|
||||
double right = left + width;
|
||||
double bottom = top + height;
|
||||
rf = new QuadRect(left, top, right, bottom);
|
||||
return rf;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
|
||||
if(!Algorithms.objectEquals(this.settings.SELECTED_POI_FILTER_FOR_MAP.get(),
|
||||
|
|
Loading…
Reference in a new issue