Search in sources :

Example 6 with PointImageDrawable

use of net.osmand.plus.views.PointImageDrawable in project Osmand by osmandapp.

the class AudioNotesLayer method onPrepareBufferImage.

@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
    if (tileBox.getZoom() >= startZoom) {
        OsmandApplication app = getApplication();
        float textScale = getTextScale();
        float iconSize = getIconSize(app);
        QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
        DataTileManager<Recording> recs = plugin.getRecordings();
        final QuadRect latlon = tileBox.getLatLonBounds();
        List<Recording> objects = recs.getObjects(latlon.top, latlon.left, latlon.bottom, latlon.right);
        List<Recording> fullObjects = new ArrayList<>();
        List<LatLon> fullObjectsLatLon = new ArrayList<>();
        List<LatLon> smallObjectsLatLon = new ArrayList<>();
        for (Recording o : objects) {
            if (o != contextMenuLayer.getMoveableObject()) {
                float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
                float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
                if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
                    PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(ctx, ContextCompat.getColor(ctx, R.color.audio_video_icon_color), true);
                    pointImageDrawable.setAlpha(0.8f);
                    pointImageDrawable.drawSmallPoint(canvas, x, y, textScale);
                    smallObjectsLatLon.add(new LatLon(o.getLatitude(), o.getLongitude()));
                } else {
                    fullObjects.add(o);
                    fullObjectsLatLon.add(new LatLon(o.getLatitude(), o.getLongitude()));
                }
            }
        }
        for (Recording o : fullObjects) {
            float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
            float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
            drawRecording(canvas, o, x, y, textScale);
        }
        this.fullObjectsLatLon = fullObjectsLatLon;
        this.smallObjectsLatLon = smallObjectsLatLon;
    }
}
Also used : LatLon(net.osmand.data.LatLon) OsmandApplication(net.osmand.plus.OsmandApplication) ArrayList(java.util.ArrayList) Recording(net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin.Recording) QuadRect(net.osmand.data.QuadRect) PointImageDrawable(net.osmand.plus.views.PointImageDrawable)

Example 7 with PointImageDrawable

use of net.osmand.plus.views.PointImageDrawable in project Osmand by osmandapp.

the class GPXLayer method drawBigPoint.

private void drawBigPoint(Canvas canvas, WptPt wpt, int fileColor, float x, float y, @Nullable MapMarker marker, float textScale) {
    int pointColor = getPointColor(wpt, fileColor);
    PointImageDrawable pointImageDrawable;
    boolean history = false;
    if (marker != null) {
        pointImageDrawable = PointImageDrawable.getOrCreateSyncedIcon(view.getContext(), pointColor, wpt);
        history = marker.history;
    } else {
        pointImageDrawable = PointImageDrawable.getFromWpt(view.getContext(), pointColor, true, wpt);
    }
    pointImageDrawable.drawPoint(canvas, x, y, textScale, history);
}
Also used : PointImageDrawable(net.osmand.plus.views.PointImageDrawable) Paint(android.graphics.Paint) SelectedGpxPoint(net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint)

Example 8 with PointImageDrawable

use of net.osmand.plus.views.PointImageDrawable in project Osmand by osmandapp.

the class GPXLayer method drawSelectedFilesPoints.

private void drawSelectedFilesPoints(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles) {
    if (tileBox.getZoom() >= START_ZOOM) {
        float textScale = getTextScale();
        float iconSize = getIconSize(view.getApplication());
        QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
        List<LatLon> fullObjectsLatLon = new ArrayList<>();
        List<LatLon> smallObjectsLatLon = new ArrayList<>();
        Map<WptPt, SelectedGpxFile> pointFileMap = new HashMap<>();
        // request to load
        final QuadRect latLonBounds = tileBox.getLatLonBounds();
        for (SelectedGpxFile g : selectedGPXFiles) {
            List<Pair<WptPt, MapMarker>> fullObjects = new ArrayList<>();
            int fileColor = getFileColor(g);
            boolean synced = isSynced(g.getGpxFile());
            for (WptPt wpt : getListStarPoints(g)) {
                if (wpt.lat >= latLonBounds.bottom && wpt.lat <= latLonBounds.top && wpt.lon >= latLonBounds.left && wpt.lon <= latLonBounds.right && wpt != contextMenuLayer.getMoveableObject() && !isPointHidden(g, wpt)) {
                    pointFileMap.put(wpt, g);
                    MapMarker marker = null;
                    if (synced) {
                        marker = mapMarkersHelper.getMapMarker(wpt);
                        if (marker == null || marker.history && !view.getSettings().KEEP_PASSED_MARKERS_ON_MAP.get()) {
                            continue;
                        }
                    }
                    cache.add(wpt);
                    float x = tileBox.getPixXFromLatLon(wpt.lat, wpt.lon);
                    float y = tileBox.getPixYFromLatLon(wpt.lat, wpt.lon);
                    if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
                        @ColorInt int color;
                        if (marker != null && marker.history) {
                            color = grayColor;
                        } else {
                            color = getPointColor(wpt, fileColor);
                        }
                        PointImageDrawable pointImageDrawable = PointImageDrawable.getFromWpt(view.getContext(), color, true, wpt);
                        pointImageDrawable.drawSmallPoint(canvas, x, y, textScale);
                        smallObjectsLatLon.add(new LatLon(wpt.lat, wpt.lon));
                    } else {
                        fullObjects.add(new Pair<>(wpt, marker));
                        fullObjectsLatLon.add(new LatLon(wpt.lat, wpt.lon));
                    }
                }
                if (wpt == contextMenuLayer.getMoveableObject()) {
                    pointFileMap.put(wpt, g);
                }
            }
            for (Pair<WptPt, MapMarker> pair : fullObjects) {
                WptPt wpt = pair.first;
                float x = tileBox.getPixXFromLatLon(wpt.lat, wpt.lon);
                float y = tileBox.getPixYFromLatLon(wpt.lat, wpt.lon);
                drawBigPoint(canvas, wpt, fileColor, x, y, pair.second, textScale);
            }
        }
        if (trackChartPoints != null && trackChartPoints.getHighlightedPoint() != null) {
            LatLon highlightedPoint = trackChartPoints.getHighlightedPoint();
            chartPointsHelper.drawHighlightedPoint(highlightedPoint, canvas, tileBox);
        }
        this.fullObjectsLatLon = fullObjectsLatLon;
        this.smallObjectsLatLon = smallObjectsLatLon;
        this.pointFileMap = pointFileMap;
    }
}
Also used : WptPt(net.osmand.GPXUtilities.WptPt) MapMarker(net.osmand.plus.mapmarkers.MapMarker) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) QuadRect(net.osmand.data.QuadRect) PointImageDrawable(net.osmand.plus.views.PointImageDrawable) Paint(android.graphics.Paint) SelectedGpxPoint(net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint) LatLon(net.osmand.data.LatLon) ColorInt(androidx.annotation.ColorInt) SelectedGpxFile(net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile) Pair(android.util.Pair)

Example 9 with PointImageDrawable

use of net.osmand.plus.views.PointImageDrawable in project Osmand by osmandapp.

the class TransportStopsLayer method drawPoint.

private void drawPoint(Canvas canvas, float textScale, float x, float y, @DrawableRes int iconId) {
    PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(getContext(), ContextCompat.getColor(getContext(), R.color.transport_stop_icon_background), true, false, iconId, BackgroundType.SQUARE);
    pointImageDrawable.setAlpha(0.9f);
    pointImageDrawable.drawPoint(canvas, x, y, textScale, false);
}
Also used : PointImageDrawable(net.osmand.plus.views.PointImageDrawable)

Example 10 with PointImageDrawable

use of net.osmand.plus.views.PointImageDrawable in project Osmand by osmandapp.

the class POIMapLayer method onPrepareBufferImage.

@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
    Set<PoiUIFilter> selectedPoiFilters = app.getPoiFilters().getSelectedPoiFilters();
    boolean showTravel = app.getSettings().SHOW_TRAVEL.get();
    boolean routeArticleFilterEnabled = travelRendererHelper.getRouteArticlesProperty().get();
    boolean routeArticlePointsFilterEnabled = travelRendererHelper.getRouteArticlePointsProperty().get();
    boolean routeTrackFilterEnabled = travelRendererHelper.getRouteTracksProperty().get();
    boolean routeTrackAsPoiFilterEnabled = travelRendererHelper.getRouteTracksAsPoiProperty().get();
    PoiUIFilter routeArticleFilter = travelRendererHelper.getRouteArticleFilter();
    PoiUIFilter routeArticlePointsFilter = travelRendererHelper.getRouteArticlePointsFilter();
    PoiUIFilter routeTrackFilter = travelRendererHelper.getRouteTrackFilter();
    String routeArticlePointsFilterByName = routeArticlePointsFilter != null ? routeArticlePointsFilter.getFilterByName() : null;
    if (this.filters != selectedPoiFilters || this.showTravel != showTravel || this.routeArticleFilterEnabled != routeArticleFilterEnabled || this.routeArticlePointsFilterEnabled != routeArticlePointsFilterEnabled || this.routeTrackFilterEnabled != routeTrackFilterEnabled || this.routeTrackAsPoiFilterEnabled != routeTrackAsPoiFilterEnabled || this.routeArticleFilter != routeArticleFilter || this.routeArticlePointsFilter != routeArticlePointsFilter || this.routeTrackFilter != routeTrackFilter || this.fileVisibilityChanged || !Algorithms.stringsEqual(this.routeArticlePointsFilterByName, routeArticlePointsFilterByName)) {
        this.filters = selectedPoiFilters;
        this.showTravel = showTravel;
        this.routeArticleFilterEnabled = routeArticleFilterEnabled;
        this.routeArticlePointsFilterEnabled = routeArticlePointsFilterEnabled;
        this.routeTrackFilterEnabled = routeTrackFilterEnabled;
        this.routeTrackAsPoiFilterEnabled = routeTrackAsPoiFilterEnabled;
        this.routeArticleFilter = routeArticleFilter;
        this.routeArticlePointsFilter = routeArticlePointsFilter;
        this.routeTrackFilter = routeTrackFilter;
        this.routeArticlePointsFilterByName = routeArticlePointsFilterByName;
        this.fileVisibilityChanged = false;
        data.clearCache();
    }
    List<Amenity> fullObjects = new ArrayList<>();
    List<LatLon> fullObjectsLatLon = new ArrayList<>();
    List<LatLon> smallObjectsLatLon = new ArrayList<>();
    if (shouldDraw(tileBox)) {
        data.queryNewData(tileBox);
        List<Amenity> objects = data.getResults();
        if (objects != null) {
            float textScale = getTextScale();
            float iconSize = getIconSize(app);
            QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
            WaypointHelper wph = app.getWaypointHelper();
            for (Amenity o : objects) {
                if (shouldDraw(tileBox, o)) {
                    PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(view.getContext(), getColor(o), true);
                    pointImageDrawable.setAlpha(0.8f);
                    LatLon latLon = o.getLocation();
                    float x = tileBox.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
                    float y = tileBox.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
                    if (tileBox.containsPoint(x, y, iconSize)) {
                        boolean intersects = intersects(boundIntersections, x, y, iconSize, iconSize);
                        boolean shouldShowNearbyPoi = app.getSettings().SHOW_NEARBY_POI.get() && routingHelper.isFollowingMode();
                        if (intersects || shouldShowNearbyPoi && !wph.isAmenityNoPassed(o)) {
                            pointImageDrawable.drawSmallPoint(canvas, x, y, textScale);
                            smallObjectsLatLon.add(latLon);
                        } else {
                            fullObjects.add(o);
                            fullObjectsLatLon.add(latLon);
                        }
                    }
                }
            }
            for (Amenity o : fullObjects) {
                LatLon latLon = o.getLocation();
                int x = (int) tileBox.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
                int y = (int) tileBox.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
                if (tileBox.containsPoint(x, y, iconSize)) {
                    String id = o.getGpxIcon();
                    if (id == null) {
                        id = RenderingIcons.getIconNameForAmenity(o);
                    }
                    if (id != null) {
                        PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(view.getContext(), getColor(o), true, RenderingIcons.getResId(id));
                        pointImageDrawable.setAlpha(0.8f);
                        pointImageDrawable.drawPoint(canvas, x, y, textScale, false);
                    }
                }
            }
            this.fullObjectsLatLon = fullObjectsLatLon;
            this.smallObjectsLatLon = smallObjectsLatLon;
        }
    }
    mapTextLayer.putData(this, fullObjects);
}
Also used : Amenity(net.osmand.data.Amenity) ArrayList(java.util.ArrayList) WaypointHelper(net.osmand.plus.helpers.WaypointHelper) QuadRect(net.osmand.data.QuadRect) PointImageDrawable(net.osmand.plus.views.PointImageDrawable) PoiUIFilter(net.osmand.plus.poi.PoiUIFilter) LatLon(net.osmand.data.LatLon)

Aggregations

PointImageDrawable (net.osmand.plus.views.PointImageDrawable)11 ArrayList (java.util.ArrayList)6 QuadRect (net.osmand.data.QuadRect)6 LatLon (net.osmand.data.LatLon)5 OsmandApplication (net.osmand.plus.OsmandApplication)3 Paint (android.graphics.Paint)2 Pair (android.util.Pair)2 ColorInt (androidx.annotation.ColorInt)2 BackgroundType (net.osmand.data.FavouritePoint.BackgroundType)2 SelectedGpxPoint (net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint)2 MapMarker (net.osmand.plus.mapmarkers.MapMarker)2 OsmNotesPoint (net.osmand.plus.plugins.osmedit.data.OsmNotesPoint)2 OsmPoint (net.osmand.plus.plugins.osmedit.data.OsmPoint)2 Context (android.content.Context)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 WptPt (net.osmand.GPXUtilities.WptPt)1 Amenity (net.osmand.data.Amenity)1 FavouritePoint (net.osmand.data.FavouritePoint)1 TransportStop (net.osmand.data.TransportStop)1