Search in sources :

Example 1 with AidlMapPointWrapper

use of net.osmand.aidl.AidlMapPointWrapper in project Osmand by osmandapp.

the class MenuController method getMenuController.

public static MenuController getMenuController(@NonNull MapActivity mapActivity, @NonNull LatLon latLon, @NonNull PointDescription pointDescription, @Nullable Object object, @NonNull MenuType menuType) {
    MenuController menuController = null;
    if (object != null) {
        if (object instanceof Amenity) {
            menuController = new AmenityMenuController(mapActivity, pointDescription, (Amenity) object);
        } else if (object instanceof FavouritePoint) {
            if (pointDescription.isParking() || (FavouritePoint.SpecialPointType.PARKING.equals(((FavouritePoint) object).getSpecialPointType()))) {
                menuController = new ParkingPositionMenuController(mapActivity, pointDescription, (FavouritePoint) object);
            } else {
                menuController = new FavouritePointMenuController(mapActivity, pointDescription, (FavouritePoint) object);
            }
        } else if (object instanceof SearchHistoryHelper.HistoryEntry) {
            menuController = new HistoryMenuController(mapActivity, pointDescription, (SearchHistoryHelper.HistoryEntry) object);
        } else if (object instanceof TargetPoint) {
            menuController = new TargetPointMenuController(mapActivity, pointDescription, (TargetPoint) object);
        } else if (object instanceof Recording) {
            menuController = new AudioVideoNoteMenuController(mapActivity, pointDescription, (Recording) object);
        } else if (object instanceof OsmPoint) {
            menuController = new EditPOIMenuController(mapActivity, pointDescription, (OsmPoint) object);
        } else if (object instanceof WptPt) {
            menuController = WptPtMenuController.getInstance(mapActivity, pointDescription, (WptPt) object);
        } else if (object instanceof DownloadMapObject) {
            menuController = new MapDataMenuController(mapActivity, pointDescription, (DownloadMapObject) object);
        } else if (object instanceof OpenStreetNote) {
            menuController = new OsmBugMenuController(mapActivity, pointDescription, (OpenStreetNote) object);
        } else if (object instanceof GpxDisplayItem) {
            menuController = new GpxItemMenuController(mapActivity, pointDescription, (GpxDisplayItem) object);
        } else if (object instanceof MapMarker) {
            menuController = new MapMarkerMenuController(mapActivity, pointDescription, (MapMarker) object);
        } else if (object instanceof TransportStopRoute) {
            menuController = new TransportRouteController(mapActivity, pointDescription, (TransportStopRoute) object);
        } else if (object instanceof TransportStop) {
            menuController = new TransportStopController(mapActivity, pointDescription, (TransportStop) object);
        } else if (object instanceof AidlMapPointWrapper) {
            menuController = new AMapPointMenuController(mapActivity, pointDescription, (AidlMapPointWrapper) object);
        } else if (object instanceof LatLon) {
            if (pointDescription.isMyLocation()) {
                menuController = new MyLocationMenuController(mapActivity, pointDescription);
            }
        } else if (object instanceof AvoidSpecificRoads.AvoidRoadInfo) {
            menuController = new ImpassibleRoadsMenuController(mapActivity, pointDescription, (AvoidSpecificRoads.AvoidRoadInfo) object);
        } else if (object instanceof RenderedObject) {
            menuController = new RenderedObjectMenuController(mapActivity, pointDescription, (RenderedObject) object);
        } else if (object instanceof MapillaryImage) {
            menuController = new MapillaryMenuController(mapActivity, pointDescription, (MapillaryImage) object);
        } else if (object instanceof SelectedGpxPoint) {
            menuController = new SelectedGpxMenuController(mapActivity, pointDescription, (SelectedGpxPoint) object);
        } else if (object instanceof Pair && ((Pair<?, ?>) object).second instanceof SelectedGpxPoint) {
            menuController = new SelectedGpxMenuController(mapActivity, pointDescription, (SelectedGpxPoint) ((Pair<?, ?>) object).second);
        }
    }
    if (menuController == null) {
        menuController = new PointDescriptionMenuController(mapActivity, pointDescription);
    }
    menuController.menuType = menuType;
    menuController.setLatLon(latLon);
    menuController.onCreated();
    return menuController;
}
Also used : TargetPointMenuController(net.osmand.plus.mapcontextmenu.controllers.TargetPointMenuController) WptPt(net.osmand.GPXUtilities.WptPt) HistoryMenuController(net.osmand.plus.mapcontextmenu.controllers.HistoryMenuController) TransportStopController(net.osmand.plus.mapcontextmenu.controllers.TransportStopController) FavouritePoint(net.osmand.data.FavouritePoint) MapMarker(net.osmand.plus.mapmarkers.MapMarker) MapillaryImage(net.osmand.plus.plugins.mapillary.MapillaryImage) AvoidSpecificRoads(net.osmand.plus.helpers.AvoidSpecificRoads) ParkingPositionMenuController(net.osmand.plus.plugins.parking.ParkingPositionMenuController) GpxDisplayItem(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem) GpxItemMenuController(net.osmand.plus.mapcontextmenu.controllers.GpxItemMenuController) AidlMapPointWrapper(net.osmand.aidl.AidlMapPointWrapper) SelectedGpxPoint(net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint) MapDataMenuController(net.osmand.plus.mapcontextmenu.controllers.MapDataMenuController) TargetPoint(net.osmand.plus.helpers.TargetPointsHelper.TargetPoint) RenderedObjectMenuController(net.osmand.plus.mapcontextmenu.controllers.RenderedObjectMenuController) ImpassibleRoadsMenuController(net.osmand.plus.mapcontextmenu.controllers.ImpassibleRoadsMenuController) EditPOIMenuController(net.osmand.plus.plugins.osmedit.menu.EditPOIMenuController) TransportStopRoute(net.osmand.plus.transport.TransportStopRoute) MapMarkerMenuController(net.osmand.plus.mapcontextmenu.controllers.MapMarkerMenuController) PointDescriptionMenuController(net.osmand.plus.mapcontextmenu.controllers.PointDescriptionMenuController) AMapPointMenuController(net.osmand.plus.mapcontextmenu.controllers.AMapPointMenuController) TransportStop(net.osmand.data.TransportStop) Pair(android.util.Pair) Amenity(net.osmand.data.Amenity) FavouritePointMenuController(net.osmand.plus.mapcontextmenu.controllers.FavouritePointMenuController) AudioVideoNoteMenuController(net.osmand.plus.plugins.audionotes.AudioVideoNoteMenuController) OsmBugMenuController(net.osmand.plus.plugins.osmedit.menu.OsmBugMenuController) OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) TransportRouteController(net.osmand.plus.mapcontextmenu.controllers.TransportRouteController) AmenityMenuController(net.osmand.plus.mapcontextmenu.controllers.AmenityMenuController) DownloadMapObject(net.osmand.plus.views.layers.DownloadedRegionsLayer.DownloadMapObject) MyLocationMenuController(net.osmand.plus.mapcontextmenu.controllers.MyLocationMenuController) RenderedObjectMenuController(net.osmand.plus.mapcontextmenu.controllers.RenderedObjectMenuController) PointDescriptionMenuController(net.osmand.plus.mapcontextmenu.controllers.PointDescriptionMenuController) MapMarkerMenuController(net.osmand.plus.mapcontextmenu.controllers.MapMarkerMenuController) EditPOIMenuController(net.osmand.plus.plugins.osmedit.menu.EditPOIMenuController) AMapPointMenuController(net.osmand.plus.mapcontextmenu.controllers.AMapPointMenuController) WptPtMenuController(net.osmand.plus.mapcontextmenu.controllers.WptPtMenuController) MapillaryMenuController(net.osmand.plus.plugins.mapillary.MapillaryMenuController) AudioVideoNoteMenuController(net.osmand.plus.plugins.audionotes.AudioVideoNoteMenuController) GpxItemMenuController(net.osmand.plus.mapcontextmenu.controllers.GpxItemMenuController) OsmBugMenuController(net.osmand.plus.plugins.osmedit.menu.OsmBugMenuController) HistoryMenuController(net.osmand.plus.mapcontextmenu.controllers.HistoryMenuController) MapDataMenuController(net.osmand.plus.mapcontextmenu.controllers.MapDataMenuController) ParkingPositionMenuController(net.osmand.plus.plugins.parking.ParkingPositionMenuController) TargetPointMenuController(net.osmand.plus.mapcontextmenu.controllers.TargetPointMenuController) AmenityMenuController(net.osmand.plus.mapcontextmenu.controllers.AmenityMenuController) SelectedGpxMenuController(net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController) ImpassibleRoadsMenuController(net.osmand.plus.mapcontextmenu.controllers.ImpassibleRoadsMenuController) FavouritePointMenuController(net.osmand.plus.mapcontextmenu.controllers.FavouritePointMenuController) MyLocationMenuController(net.osmand.plus.mapcontextmenu.controllers.MyLocationMenuController) SelectedGpxMenuController(net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController) LatLon(net.osmand.data.LatLon) RenderedObject(net.osmand.NativeLibrary.RenderedObject) OpenStreetNote(net.osmand.plus.plugins.osmedit.OsmBugsLayer.OpenStreetNote) Recording(net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin.Recording) MapillaryMenuController(net.osmand.plus.plugins.mapillary.MapillaryMenuController)

Example 2 with AidlMapPointWrapper

use of net.osmand.aidl.AidlMapPointWrapper in project Osmand by osmandapp.

the class AidlMapLayer method onPrepareBufferImage.

@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
    pointsType = getPointsType(tileBox.getZoom());
    if (pointsType == PointsType.INVISIBLE) {
        mapTextLayer.putData(this, Collections.emptyList());
        return;
    }
    displayedPoints.clear();
    imageRequests.clear();
    if (isLayerEnabled()) {
        canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
        String selectedPointId = getSelectedContextMenuPointId();
        for (AidlMapPointWrapper point : aidlLayer.getPoints()) {
            LatLon l = point.getLocation();
            if (l != null) {
                int x = (int) tileBox.getPixXFromLatLon(l.getLatitude(), l.getLongitude());
                int y = (int) tileBox.getPixYFromLatLon(l.getLatitude(), l.getLongitude());
                if (tileBox.containsPoint(x, y, bigIconSize)) {
                    Bitmap image = null;
                    if (pointsType != PointsType.STANDARD) {
                        String imageUri = point.getParams().get(AMapPoint.POINT_IMAGE_URI_PARAM);
                        if (!TextUtils.isEmpty(imageUri)) {
                            image = pointImages.get(imageUri);
                            if (image == null) {
                                imageRequests.add(imageUri);
                            }
                        }
                    }
                    displayedPoints.add(point);
                    boolean selected = selectedPointId != null && selectedPointId.equals(point.getId());
                    drawPoint(canvas, x, y, tileBox, point, image, selected);
                }
            }
        }
        if (imageRequests.size() > 0) {
            executeTaskInBackground(new PointImageReaderTask(this), imageRequests.toArray(new String[0]));
        }
    }
    mapTextLayer.putData(this, displayedPoints);
}
Also used : LatLon(net.osmand.data.LatLon) Bitmap(android.graphics.Bitmap) AidlMapPointWrapper(net.osmand.aidl.AidlMapPointWrapper) AMapPoint(net.osmand.aidlapi.maplayer.point.AMapPoint) Paint(android.graphics.Paint)

Example 3 with AidlMapPointWrapper

use of net.osmand.aidl.AidlMapPointWrapper in project Osmand by osmandapp.

the class AidlMapLayer method getSelectedContextMenuPointId.

private String getSelectedContextMenuPointId() {
    MapActivity mapActivity = getMapActivity();
    if (mapActivity != null) {
        MapContextMenu mapContextMenu = mapActivity.getContextMenu();
        Object object = mapContextMenu.getObject();
        if (mapContextMenu.isVisible() && object instanceof AidlMapPointWrapper) {
            AidlMapPointWrapper aMapPoint = (AidlMapPointWrapper) object;
            return aMapPoint.getId();
        }
    }
    return null;
}
Also used : AidlMapPointWrapper(net.osmand.aidl.AidlMapPointWrapper) MapContextMenu(net.osmand.plus.mapcontextmenu.MapContextMenu) MapActivity(net.osmand.plus.activities.MapActivity)

Example 4 with AidlMapPointWrapper

use of net.osmand.aidl.AidlMapPointWrapper in project Osmand by osmandapp.

the class AidlMapLayer method getFromPoint.

private void getFromPoint(RotatedTileBox tb, PointF point, List<? super AidlMapPointWrapper> points) {
    if (view != null) {
        int ex = (int) point.x;
        int ey = (int) point.y;
        int radius = getPointRadius(tb);
        for (AidlMapPointWrapper p : aidlLayer.getPoints()) {
            LatLon position = p.getLocation();
            if (position != null) {
                int x = (int) tb.getPixXFromLatLon(position.getLatitude(), position.getLongitude());
                int y = (int) tb.getPixYFromLatLon(position.getLatitude(), position.getLongitude());
                if (Math.abs(x - ex) <= radius && Math.abs(y - ey) <= radius) {
                    points.add(p);
                }
            }
        }
    }
}
Also used : LatLon(net.osmand.data.LatLon) AidlMapPointWrapper(net.osmand.aidl.AidlMapPointWrapper) AMapPoint(net.osmand.aidlapi.maplayer.point.AMapPoint) Paint(android.graphics.Paint)

Example 5 with AidlMapPointWrapper

use of net.osmand.aidl.AidlMapPointWrapper in project Osmand by osmandapp.

the class ContextMenuLayer method onDraw.

@Override
public void onDraw(Canvas canvas, RotatedTileBox box, DrawSettings nightMode) {
    MapActivity mapActivity = getMapActivity();
    if (mapActivity == null) {
        return;
    }
    boolean markerCustomized = false;
    if (selectedObject != null) {
        TIntArrayList x = null;
        TIntArrayList y = null;
        if (selectedObject instanceof Amenity) {
            Amenity a = (Amenity) selectedObject;
            x = a.getX();
            y = a.getY();
        } else if (selectedObject instanceof RenderedObject) {
            RenderedObject r = (RenderedObject) selectedObject;
            x = r.getX();
            y = r.getY();
        } else if (selectedObject instanceof AidlMapPointWrapper) {
            markerCustomized = true;
        }
        if (x != null && y != null && x.size() > 2) {
            float px, py, prevX, prevY;
            prevX = box.getPixXFrom31(x.get(0), y.get(0));
            prevY = box.getPixYFrom31(x.get(0), y.get(0));
            for (int i = 1; i < x.size(); i++) {
                px = box.getPixXFrom31(x.get(i), y.get(i));
                py = box.getPixYFrom31(x.get(i), y.get(i));
                canvas.drawLine(prevX, prevY, px, py, outlinePaint);
                prevX = px;
                prevY = py;
            }
        }
    }
    float textScale = 1f;
    if (!pressedLatLonSmall.isEmpty() || !pressedLatLonFull.isEmpty()) {
        textScale = getTextScale();
    }
    for (Entry<LatLon, BackgroundType> entry : pressedLatLonSmall.entrySet()) {
        LatLon latLon = entry.getKey();
        int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
        int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
        BackgroundType background = entry.getValue();
        Bitmap pressedBitmapSmall = background.getTouchBackground(mapActivity, true);
        Rect destRect = getIconDestinationRect(x, y, pressedBitmapSmall.getWidth(), pressedBitmapSmall.getHeight(), textScale);
        canvas.drawBitmap(pressedBitmapSmall, null, destRect, paint);
    }
    for (Entry<LatLon, BackgroundType> entry : pressedLatLonFull.entrySet()) {
        LatLon latLon = entry.getKey();
        int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
        int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
        BackgroundType background = entry.getValue();
        Bitmap pressedBitmap = background.getTouchBackground(mapActivity, false);
        int offsetY = background.getOffsetY(mapActivity, textScale);
        Rect destRect = getIconDestinationRect(x, y - offsetY, pressedBitmap.getWidth(), pressedBitmap.getHeight(), textScale);
        canvas.drawBitmap(pressedBitmap, null, destRect, paint);
    }
    boolean movingMarker = mapQuickActionLayer != null && mapQuickActionLayer.isInMovingMarkerMode();
    boolean downloadingTiles = mapActivity.getDownloadTilesFragment() != null;
    if (movingMarker || downloadingTiles) {
        return;
    }
    if (mInChangeMarkerPositionMode) {
        if (menu != null && menu.getObject() == null) {
            canvas.translate(box.getPixWidth() / 2 - contextMarker.getWidth() / 2, box.getPixHeight() / 2 - contextMarker.getHeight());
            contextMarker.draw(canvas);
        }
        if (mMoveMarkerBottomSheetHelper != null) {
            mMoveMarkerBottomSheetHelper.onDraw(box);
        }
    } else if (mInAddGpxPointMode) {
        canvas.translate(box.getPixWidth() / 2 - contextMarker.getWidth() / 2, box.getPixHeight() / 2 - contextMarker.getHeight());
        contextMarker.draw(canvas);
        if (mAddGpxPointBottomSheetHelper != null) {
            mAddGpxPointBottomSheetHelper.onDraw(box);
        }
    } else if (!markerCustomized) {
        LatLon latLon = null;
        if (menu != null && menu.isActive()) {
            latLon = menu.getLatLon();
        } else if (mapActivity.getTrackMenuFragment() != null) {
            latLon = mapActivity.getTrackMenuFragment().getLatLon();
        }
        if (latLon != null) {
            int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
            int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
            canvas.translate(x - contextMarker.getWidth() / 2, y - contextMarker.getHeight());
            contextMarker.draw(canvas);
        }
    }
}
Also used : Amenity(net.osmand.data.Amenity) Rect(android.graphics.Rect) AidlMapPointWrapper(net.osmand.aidl.AidlMapPointWrapper) TIntArrayList(gnu.trove.list.array.TIntArrayList) Paint(android.graphics.Paint) NewGpxPoint(net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint) FavouritePoint(net.osmand.data.FavouritePoint) SelectedGpxPoint(net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint) RenderedObject(net.osmand.NativeLibrary.RenderedObject) LatLon(net.osmand.data.LatLon) Bitmap(android.graphics.Bitmap) BackgroundType(net.osmand.data.FavouritePoint.BackgroundType) MapActivity(net.osmand.plus.activities.MapActivity)

Aggregations

AidlMapPointWrapper (net.osmand.aidl.AidlMapPointWrapper)6 LatLon (net.osmand.data.LatLon)4 Paint (android.graphics.Paint)3 Bitmap (android.graphics.Bitmap)2 RenderedObject (net.osmand.NativeLibrary.RenderedObject)2 AMapPoint (net.osmand.aidlapi.maplayer.point.AMapPoint)2 Amenity (net.osmand.data.Amenity)2 FavouritePoint (net.osmand.data.FavouritePoint)2 MapActivity (net.osmand.plus.activities.MapActivity)2 SelectedGpxPoint (net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint)2 Rect (android.graphics.Rect)1 Pair (android.util.Pair)1 TIntArrayList (gnu.trove.list.array.TIntArrayList)1 WptPt (net.osmand.GPXUtilities.WptPt)1 BackgroundType (net.osmand.data.FavouritePoint.BackgroundType)1 TransportStop (net.osmand.data.TransportStop)1 AvoidSpecificRoads (net.osmand.plus.helpers.AvoidSpecificRoads)1 TargetPoint (net.osmand.plus.helpers.TargetPointsHelper.TargetPoint)1 MapContextMenu (net.osmand.plus.mapcontextmenu.MapContextMenu)1 AMapPointMenuController (net.osmand.plus.mapcontextmenu.controllers.AMapPointMenuController)1