use of net.osmand.plus.views.PointImageDrawable in project Osmand by osmandapp.
the class OsmBugsLayer method onPrepareBufferImage.
@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
OsmandApplication app = getApplication();
startZoom = plugin.SHOW_OSM_BUGS_MIN_ZOOM.get();
if (tileBox.getZoom() >= startZoom) {
// request to load
data.queryNewData(tileBox);
List<OpenStreetNote> objects = data.getResults();
if (objects != null) {
float textScale = getTextScale();
float iconSize = getIconSize(app);
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
List<OpenStreetNote> fullObjects = new ArrayList<>();
List<LatLon> fullObjectsLatLon = new ArrayList<>();
List<LatLon> smallObjectsLatLon = new ArrayList<>();
boolean showClosed = plugin.SHOW_CLOSED_OSM_BUGS.get();
for (OpenStreetNote o : objects) {
if (!o.isOpened() && !showClosed) {
continue;
}
float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
int backgroundColorRes;
if (o.isOpened()) {
backgroundColorRes = R.color.osm_bug_unresolved_icon_color;
} else {
backgroundColorRes = R.color.osm_bug_resolved_icon_color;
}
PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(ctx, ContextCompat.getColor(ctx, backgroundColorRes), true, false, DEFAULT_UI_ICON_ID, BackgroundType.COMMENT);
pointImageDrawable.drawSmallPoint(canvas, x, y, textScale);
} else {
fullObjects.add(o);
fullObjectsLatLon.add(new LatLon(o.getLatitude(), o.getLongitude()));
}
}
for (OpenStreetNote o : fullObjects) {
if (!o.isOpened() && !showClosed) {
continue;
}
float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
int iconId;
int backgroundColorRes;
if (o.isOpened()) {
iconId = R.drawable.mx_special_symbol_remove;
backgroundColorRes = R.color.osm_bug_unresolved_icon_color;
} else {
iconId = R.drawable.mx_special_symbol_check_mark;
backgroundColorRes = R.color.osm_bug_resolved_icon_color;
}
BackgroundType backgroundType = BackgroundType.COMMENT;
PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(ctx, ContextCompat.getColor(ctx, backgroundColorRes), true, false, iconId, backgroundType);
int offsetY = backgroundType.getOffsetY(ctx, textScale);
pointImageDrawable.drawPoint(canvas, x, y - offsetY, textScale, false);
}
this.fullObjectsLatLon = fullObjectsLatLon;
this.smallObjectsLatLon = smallObjectsLatLon;
}
}
}
use of net.osmand.plus.views.PointImageDrawable in project Osmand by osmandapp.
the class FavouritesLayer method onPrepareBufferImage.
@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
cache.clear();
if (this.settings.SHOW_FAVORITES.get() && favouritesHelper.isFavoritesLoaded()) {
if (tileBox.getZoom() >= START_ZOOM) {
float textScale = getTextScale();
float iconSize = getIconSize(view.getApplication());
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
// request to load
final QuadRect latLonBounds = tileBox.getLatLonBounds();
List<LatLon> fullObjectsLatLon = new ArrayList<>();
List<LatLon> smallObjectsLatLon = new ArrayList<>();
for (FavoriteGroup group : favouritesHelper.getFavoriteGroups()) {
List<Pair<FavouritePoint, MapMarker>> fullObjects = new ArrayList<>();
boolean synced = isSynced(group);
for (FavouritePoint favoritePoint : group.getPoints()) {
double lat = favoritePoint.getLatitude();
double lon = favoritePoint.getLongitude();
if (favoritePoint.isVisible() && favoritePoint != contextMenuLayer.getMoveableObject() && lat >= latLonBounds.bottom && lat <= latLonBounds.top && lon >= latLonBounds.left && lon <= latLonBounds.right) {
MapMarker marker = null;
if (synced) {
marker = mapMarkersHelper.getMapMarker(favoritePoint);
if (marker == null || marker.history && !view.getSettings().KEEP_PASSED_MARKERS_ON_MAP.get()) {
continue;
}
}
cache.add(favoritePoint);
float x = tileBox.getPixXFromLatLon(lat, lon);
float y = tileBox.getPixYFromLatLon(lat, lon);
if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
@ColorInt int color;
if (marker != null && marker.history) {
color = grayColor;
} else {
color = favouritesHelper.getColorWithCategory(favoritePoint, defaultColor);
}
PointImageDrawable pointImageDrawable = PointImageDrawable.getFromFavorite(view.getContext(), color, true, favoritePoint);
pointImageDrawable.drawSmallPoint(canvas, x, y, textScale);
smallObjectsLatLon.add(new LatLon(lat, lon));
} else {
fullObjects.add(new Pair<>(favoritePoint, marker));
fullObjectsLatLon.add(new LatLon(lat, lon));
}
}
}
for (Pair<FavouritePoint, MapMarker> pair : fullObjects) {
FavouritePoint favoritePoint = pair.first;
float x = tileBox.getPixXFromLatLon(favoritePoint.getLatitude(), favoritePoint.getLongitude());
float y = tileBox.getPixYFromLatLon(favoritePoint.getLatitude(), favoritePoint.getLongitude());
drawBigPoint(canvas, favoritePoint, x, y, pair.second, textScale);
}
}
this.fullObjectsLatLon = fullObjectsLatLon;
this.smallObjectsLatLon = smallObjectsLatLon;
}
}
if (isTextVisible()) {
textLayer.putData(this, cache);
}
}
use of net.osmand.plus.views.PointImageDrawable in project Osmand by osmandapp.
the class OsmEditsLayer method drawPoint.
private void drawPoint(Canvas canvas, OsmPoint osmPoint, float x, float y) {
float textScale = getTextScale();
int iconId = getIconId(osmPoint);
BackgroundType backgroundType = DEFAULT_BACKGROUND_TYPE;
if (osmPoint.getGroup() == OsmPoint.Group.BUG) {
backgroundType = BackgroundType.COMMENT;
}
PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(ctx, ContextCompat.getColor(ctx, R.color.created_poi_icon_color), true, false, iconId, backgroundType);
pointImageDrawable.setAlpha(0.8f);
int offsetY = backgroundType.getOffsetY(ctx, textScale);
pointImageDrawable.drawPoint(canvas, x, y - offsetY, textScale, false);
}
use of net.osmand.plus.views.PointImageDrawable in project Osmand by osmandapp.
the class TransportStopsLayer method onPrepareBufferImage.
@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tb, DrawSettings settings) {
List<TransportStop> objects = null;
boolean nightMode = settings.isNightMode();
OsmandApplication app = getApplication();
if (tb.getZoom() >= startZoomRoute) {
if (stopRoute != null) {
objects = stopRoute.route.getForwardStops();
int color = stopRoute.getColor(app, nightMode);
attrs.paint.setColor(color);
attrs.updatePaints(view.getApplication(), settings, tb);
try {
path.reset();
List<Way> ws = stopRoute.route.getForwardWays();
if (ws != null) {
for (Way w : ws) {
List<Float> tx = new ArrayList<>();
List<Float> ty = new ArrayList<>();
for (int i = 0; i < w.getNodes().size(); i++) {
Node o = w.getNodes().get(i);
float x = tb.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
float y = tb.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
tx.add(x);
ty.add(y);
}
GeometryWay.calculatePath(tb, tx, ty, path);
}
}
attrs.drawPath(canvas, path);
} catch (Exception e) {
// ignore
}
}
}
if (showTransportStops.get() && tb.getZoom() >= startZoom && objects == null) {
data.queryNewData(tb);
objects = data.getResults();
}
if (objects != null) {
Context ctx = getContext();
float textScale = getTextScale();
float iconSize = getIconSize(app);
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tb);
List<TransportStop> fullObjects = new ArrayList<>();
for (TransportStop o : objects) {
float x = tb.getPixXFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
float y = tb.getPixYFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(ctx, ContextCompat.getColor(ctx, R.color.transport_stop_icon_background), true, false, 0, BackgroundType.SQUARE);
pointImageDrawable.setAlpha(0.9f);
pointImageDrawable.drawSmallPoint(canvas, x, y, textScale);
} else {
fullObjects.add(o);
}
}
for (TransportStop o : fullObjects) {
float x = tb.getPixXFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
float y = tb.getPixYFromLatLon(o.getLocation().getLatitude(), o.getLocation().getLongitude());
if (stopRoute != null) {
TransportStopType type = TransportStopType.findType(stopRoute.route.getType());
if (type != null) {
drawPoint(canvas, textScale, x, y, RenderingIcons.getResId(type.getResName()));
}
} else {
drawPoint(canvas, textScale, x, y, R.drawable.mx_highway_bus_stop);
}
}
}
}
use of net.osmand.plus.views.PointImageDrawable in project Osmand by osmandapp.
the class AudioNotesLayer method drawRecording.
private void drawRecording(Canvas canvas, Recording o, float x, float y, float textScale) {
int iconId;
if (o.isPhoto()) {
iconId = R.drawable.mx_special_photo_camera;
} else if (o.isAudio()) {
iconId = R.drawable.mx_special_microphone;
} else {
iconId = R.drawable.mx_special_video_camera;
}
PointImageDrawable pointImageDrawable = PointImageDrawable.getOrCreate(ctx, ContextCompat.getColor(ctx, R.color.audio_video_icon_color), true, iconId);
pointImageDrawable.setAlpha(0.8f);
pointImageDrawable.drawPoint(canvas, x, y, textScale, false);
}
Aggregations