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