use of net.osmand.plus.views.layers.base.OsmandMapLayer in project Osmand by osmandapp.
the class ContextMenuLayer method selectObjectsForContextMenu.
@NonNull
private Map<Object, IContextMenuProvider> selectObjectsForContextMenu(RotatedTileBox tileBox, PointF point, boolean acquireObjLatLon, boolean unknownLocation) {
Map<LatLon, BackgroundType> pressedLatLonFull = new HashMap<>();
Map<LatLon, BackgroundType> pressedLatLonSmall = new HashMap<>();
Map<Object, IContextMenuProvider> selectedObjects = new HashMap<>();
List<Object> s = new ArrayList<>();
for (OsmandMapLayer lt : view.getLayers()) {
if (lt instanceof IContextMenuProvider) {
s.clear();
final IContextMenuProvider l = (IContextMenuProvider) lt;
l.collectObjectsFromPoint(point, tileBox, s, unknownLocation);
for (Object o : s) {
selectedObjects.put(o, l);
if (acquireObjLatLon && l.isObjectClickable(o)) {
LatLon latLon = l.getObjectLocation(o);
BackgroundType backgroundType = DEFAULT_BACKGROUND_TYPE;
if (o instanceof OsmBugsLayer.OpenStreetNote) {
backgroundType = BackgroundType.COMMENT;
}
if (o instanceof FavouritePoint) {
backgroundType = ((FavouritePoint) o).getBackgroundType();
}
if (o instanceof GPXUtilities.WptPt) {
backgroundType = BackgroundType.getByTypeName(((GPXUtilities.WptPt) o).getBackgroundType(), DEFAULT_BACKGROUND_TYPE);
}
if (lt.isPresentInFullObjects(latLon) && !pressedLatLonFull.containsKey(latLon)) {
pressedLatLonFull.put(latLon, backgroundType);
} else if (lt.isPresentInSmallObjects(latLon) && !pressedLatLonSmall.containsKey(latLon)) {
pressedLatLonSmall.put(latLon, backgroundType);
}
}
}
}
}
if (acquireObjLatLon) {
this.pressedLatLonFull = pressedLatLonFull;
this.pressedLatLonSmall = pressedLatLonSmall;
}
return selectedObjects;
}
use of net.osmand.plus.views.layers.base.OsmandMapLayer in project Osmand by osmandapp.
the class MapRouteInfoMenu method getObjectLocation.
private Pair<LatLon, PointDescription> getObjectLocation(OsmandMapTileView mapView, PointF point, RotatedTileBox tileBox) {
List<Object> objects = new ArrayList<>();
for (OsmandMapLayer layer : mapView.getLayers()) {
if (layer instanceof IContextMenuProvider) {
objects.clear();
IContextMenuProvider provider = (IContextMenuProvider) layer;
provider.collectObjectsFromPoint(point, tileBox, objects, true);
for (Object o : objects) {
if (provider.isObjectClickable(o)) {
LatLon latLon = provider.getObjectLocation(o);
PointDescription name = null;
if (o instanceof FavouritePoint) {
name = ((FavouritePoint) o).getPointDescription(mapView.getApplication());
}
return new Pair<>(latLon, name);
}
}
}
}
return null;
}
use of net.osmand.plus.views.layers.base.OsmandMapLayer in project Osmand by osmandapp.
the class OsmandMapTileView method refreshBaseMapInternal.
private void refreshBaseMapInternal(RotatedTileBox tileBox, DrawSettings drawSettings) {
if (tileBox.getPixHeight() == 0 || tileBox.getPixWidth() == 0) {
return;
}
if (bufferBitmapTmp == null || tileBox.getPixHeight() != bufferBitmapTmp.getHeight() || tileBox.getPixWidth() != bufferBitmapTmp.getWidth()) {
bufferBitmapTmp = Bitmap.createBitmap(tileBox.getPixWidth(), tileBox.getPixHeight(), Config.ARGB_8888);
}
long start = SystemClock.elapsedRealtime();
final QuadPoint c = tileBox.getCenterPixelPoint();
Canvas canvas = new Canvas(bufferBitmapTmp);
fillCanvas(canvas, drawSettings);
for (int i = 0; i < layers.size(); i++) {
try {
OsmandMapLayer layer = layers.get(i);
canvas.save();
// rotate if needed
if (!layer.drawInScreenPixels()) {
canvas.rotate(tileBox.getRotate(), c.x, c.y);
}
layer.onPrepareBufferImage(canvas, tileBox, drawSettings);
canvas.restore();
} catch (IndexOutOfBoundsException e) {
// skip it
canvas.restore();
}
}
Bitmap t = bufferBitmap;
synchronized (this) {
bufferImgLoc = tileBox;
bufferBitmap = bufferBitmapTmp;
bufferBitmapTmp = t;
}
long end = SystemClock.elapsedRealtime();
additional.calculateFPS(start, end);
}
Aggregations