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;
}
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);
}
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;
}
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);
}
}
}
}
}
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);
}
}
}
Aggregations