use of net.osmand.plus.views.layers.base.OsmandMapLayer in project Osmand by osmandapp.
the class MapTextLayer method initLayer.
@Override
public void initLayer(@NonNull OsmandMapTileView v) {
this.view = v;
paintTextIcon = new Paint();
updateTextSize();
paintTextIcon.setTextAlign(Align.CENTER);
paintTextIcon.setAntiAlias(true);
Map<OsmandMapLayer, Collection<?>> textObjectsLoc = new TreeMap<>((lhs, rhs) -> {
if (view != null) {
float z1 = view.getZorder(lhs);
float z2 = view.getZorder(rhs);
return Float.compare(z1, z2);
}
return 0;
});
textObjectsLoc.putAll(this.textObjects);
this.textObjects = textObjectsLoc;
}
use of net.osmand.plus.views.layers.base.OsmandMapLayer in project Osmand by osmandapp.
the class MapTextLayer method onPrepareBufferImage.
@SuppressWarnings("unchecked")
@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
QuadTree<QuadRect> intersections = initBoundIntersections(tileBox);
for (Map.Entry<OsmandMapLayer, Collection<?>> entry : textObjects.entrySet()) {
OsmandMapLayer l = entry.getKey();
MapTextProvider provider = (MapTextProvider) l;
if (!view.isLayerExists(l) || !provider.isTextVisible()) {
continue;
}
updateTextSize();
paintTextIcon.setFakeBoldText(provider.isFakeBoldText());
float textSize = paintTextIcon.getTextSize();
for (Object o : entry.getValue()) {
LatLon loc = provider.getTextLocation(o);
String name = provider.getText(o);
if (loc == null || TextUtils.isEmpty(name)) {
continue;
}
int r = provider.getTextShift(o, tileBox);
float x = tileBox.getPixXFromLatLon(loc.getLatitude(), loc.getLongitude());
float y = tileBox.getPixYFromLatLon(loc.getLatitude(), loc.getLongitude());
drawWrappedText(canvas, name, intersections, x, y + r + 2 + textSize / 2, settings.isNightMode());
}
}
}
use of net.osmand.plus.views.layers.base.OsmandMapLayer in project Osmand by osmandapp.
the class OsmandAidlApi method registerRemoveMapLayerReceiver.
private void registerRemoveMapLayerReceiver(@NonNull MapActivity mapActivity) {
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
BroadcastReceiver removeMapLayerReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
MapActivity mapActivity = mapActivityRef.get();
String layerId = intent.getStringExtra(AIDL_OBJECT_ID);
String packName = intent.getStringExtra(AIDL_PACKAGE_NAME);
if (mapActivity != null && layerId != null && packName != null) {
ConnectedApp connectedApp = connectedApps.get(packName);
if (connectedApp != null) {
OsmandMapLayer mapLayer = connectedApp.getMapLayers().remove(layerId);
if (mapLayer != null) {
mapActivity.getMapView().removeLayer(mapLayer);
mapActivity.refreshMap();
}
}
}
}
};
registerReceiver(removeMapLayerReceiver, mapActivity, AIDL_REMOVE_MAP_LAYER);
}
use of net.osmand.plus.views.layers.base.OsmandMapLayer in project Osmand by osmandapp.
the class MapContextMenu method getActionsContextMenuAdapter.
public ContextMenuAdapter getActionsContextMenuAdapter(boolean configure) {
MapActivity mapActivity = getMapActivity();
final ContextMenuAdapter menuAdapter = new ContextMenuAdapter(getMyApplication());
if (mapActivity != null) {
LatLon latLon = getLatLon();
for (OsmandMapLayer layer : mapActivity.getMapView().getLayers()) {
layer.populateObjectContextMenu(latLon, getObject(), menuAdapter);
}
mapActivity.getMapActions().addActionsToAdapter(configure ? 0 : latLon.getLatitude(), configure ? 0 : latLon.getLongitude(), menuAdapter, configure ? null : getObject(), configure);
}
return menuAdapter;
}
use of net.osmand.plus.views.layers.base.OsmandMapLayer in project Osmand by osmandapp.
the class ContextMenuLayer method disableLongPressOnMap.
public boolean disableLongPressOnMap(PointF point, RotatedTileBox tileBox) {
MapActivity mapActivity = getMapActivity();
if (mInChangeMarkerPositionMode || mInGpxDetailsMode || mInAddGpxPointMode || mapActivity == null || mapActivity.getMapRouteInfoMenu().isVisible() || MapRouteInfoMenu.waypointsVisible || MapRouteInfoMenu.followTrackVisible || mapActivity.getGpsFilterFragment() != null || mapActivity.getDownloadTilesFragment() != null) {
return true;
}
boolean res = false;
for (OsmandMapLayer lt : view.getLayers()) {
if (lt instanceof IContextMenuProvider) {
if (((IContextMenuProvider) lt).disableLongPressOnMap(point, tileBox)) {
res = true;
break;
}
}
}
return res;
}
Aggregations