use of net.osmand.data.FavouritePoint in project Osmand by osmandapp.
the class FavouritesLayer method getFavFromPoint.
private void getFavFromPoint(RotatedTileBox tb, List<? super FavouritePoint> res, int r, int ex, int ey, FavouritePoint n) {
if (n.isVisible()) {
int x = (int) tb.getPixXFromLatLon(n.getLatitude(), n.getLongitude());
int y = (int) tb.getPixYFromLatLon(n.getLatitude(), n.getLongitude());
if (calculateBelongs(ex, ey, x, y, r)) {
res.add(n);
}
}
}
use of net.osmand.data.FavouritePoint in project Osmand by osmandapp.
the class FavouritesLayer method drawPoint.
private void drawPoint(Canvas canvas, RotatedTileBox tileBox, final QuadRect latLonBounds, FavouritePoint o, boolean synced) {
if (o.isVisible() && o.getLatitude() >= latLonBounds.bottom && o.getLatitude() <= latLonBounds.top && o.getLongitude() >= latLonBounds.left && o.getLongitude() <= latLonBounds.right) {
cache.add(o);
int x = (int) tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
int y = (int) tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
FavoriteImageDrawable fid;
if (synced) {
fid = FavoriteImageDrawable.getOrCreateSyncedIcon(view.getContext(), o.getColor());
} else {
fid = FavoriteImageDrawable.getOrCreate(view.getContext(), o.getColor(), true);
}
fid.drawBitmapInCenter(canvas, x, y);
}
}
use of net.osmand.data.FavouritePoint in project Osmand by osmandapp.
the class FavouritesLayer method onDraw.
@Override
public void onDraw(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
if (contextMenuLayer.getMoveableObject() instanceof FavouritePoint) {
FavouritePoint objectInMotion = (FavouritePoint) contextMenuLayer.getMoveableObject();
FavoriteImageDrawable fid;
if (mapMarkersHelper.isSynced(objectInMotion)) {
fid = FavoriteImageDrawable.getOrCreateSyncedIcon(view.getContext(), objectInMotion.getColor());
} else {
fid = FavoriteImageDrawable.getOrCreate(view.getContext(), objectInMotion.getColor(), true);
}
PointF pf = contextMenuLayer.getMovableCenterPoint(tileBox);
fid.drawBitmapInCenter(canvas, pf.x, pf.y);
}
}
use of net.osmand.data.FavouritePoint 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()) {
if (tileBox.getZoom() >= startZoom) {
float iconSize = FavoriteImageDrawable.getOrCreate(view.getContext(), 0, true).getIntrinsicWidth() * 3 / 2.5f;
QuadTree<QuadRect> boundIntersections = initBoundIntersections(tileBox);
// request to load
final QuadRect latLonBounds = tileBox.getLatLonBounds();
List<FavouritePoint> fullObjects = new ArrayList<>();
List<LatLon> fullObjectsLatLon = new ArrayList<>();
List<LatLon> smallObjectsLatLon = new ArrayList<>();
for (FavouritePoint o : getPoints()) {
if (!o.isVisible()) {
continue;
}
float x = tileBox.getPixXFromLatLon(o.getLatitude(), o.getLongitude());
float y = tileBox.getPixYFromLatLon(o.getLatitude(), o.getLongitude());
if (intersects(boundIntersections, x, y, iconSize, iconSize)) {
@ColorInt int col = o.getColor() == 0 || o.getColor() == Color.BLACK ? defaultColor : o.getColor();
paintIcon.setColorFilter(new PorterDuffColorFilter(col, PorterDuff.Mode.MULTIPLY));
canvas.drawBitmap(pointSmall, x - pointSmall.getWidth() / 2, y - pointSmall.getHeight() / 2, paintIcon);
smallObjectsLatLon.add(new LatLon(o.getLatitude(), o.getLongitude()));
} else {
fullObjects.add(o);
fullObjectsLatLon.add(new LatLon(o.getLatitude(), o.getLongitude()));
}
}
for (FavouritePoint o : fullObjects) {
if (o != contextMenuLayer.getMoveableObject()) {
boolean syncedPoint = mapMarkersHelper.isSynced(o);
drawPoint(canvas, tileBox, latLonBounds, o, syncedPoint);
}
}
this.fullObjectsLatLon = fullObjectsLatLon;
this.smallObjectsLatLon = smallObjectsLatLon;
}
}
if (textLayer.isVisible()) {
textLayer.putData(this, cache);
}
}
use of net.osmand.data.FavouritePoint in project Osmand by osmandapp.
the class QuickSearchListItem method getIcon.
public static Drawable getIcon(OsmandApplication app, SearchResult searchResult) {
if (searchResult == null || searchResult.objectType == null) {
return null;
}
int iconId = -1;
switch(searchResult.objectType) {
case CITY:
return getIcon(app, R.drawable.ic_action_building_number);
case VILLAGE:
return getIcon(app, R.drawable.ic_action_home_dark);
case POSTCODE:
case STREET:
return getIcon(app, R.drawable.ic_action_street_name);
case HOUSE:
return getIcon(app, R.drawable.ic_action_building);
case STREET_INTERSECTION:
return getIcon(app, R.drawable.ic_action_intersection);
case POI_TYPE:
if (searchResult.object instanceof AbstractPoiType) {
String iconName = getPoiTypeIconName((AbstractPoiType) searchResult.object);
if (!Algorithms.isEmpty(iconName)) {
iconId = RenderingIcons.getBigIconResourceId(iconName);
}
} else if (searchResult.object instanceof CustomSearchPoiFilter) {
Object res = ((CustomSearchPoiFilter) searchResult.object).getIconResource();
if (res instanceof String && RenderingIcons.containsBigIcon(res.toString())) {
iconId = RenderingIcons.getBigIconResourceId(res.toString());
} else {
iconId = R.drawable.mx_user_defined;
}
}
if (iconId > 0) {
return getIcon(app, iconId);
} else {
return getIcon(app, R.drawable.ic_action_search_dark);
}
case POI:
Amenity amenity = (Amenity) searchResult.object;
String id = getAmenityIconName(app, amenity);
Drawable icon = null;
if (id != null) {
iconId = RenderingIcons.getBigIconResourceId(id);
if (iconId > 0) {
icon = getIcon(app, iconId);
}
}
if (icon == null) {
return getIcon(app, R.drawable.ic_action_search_dark);
} else {
return icon;
}
case LOCATION:
return getIcon(app, R.drawable.ic_action_world_globe);
case FAVORITE:
FavouritePoint fav = (FavouritePoint) searchResult.object;
return FavoriteImageDrawable.getOrCreate(app, fav.getColor(), false);
case FAVORITE_GROUP:
FavoriteGroup group = (FavoriteGroup) searchResult.object;
int color = group.color == 0 || group.color == Color.BLACK ? app.getResources().getColor(R.color.color_favorite) : group.color;
return app.getIconsCache().getPaintedIcon(R.drawable.ic_action_fav_dark, color | 0xff000000);
case REGION:
return getIcon(app, R.drawable.ic_world_globe_dark);
case RECENT_OBJ:
HistoryEntry entry = (HistoryEntry) searchResult.object;
if (entry.getName() != null && !Algorithms.isEmpty(entry.getName().getIconName())) {
String iconName = entry.getName().getIconName();
if (RenderingIcons.containsBigIcon(iconName)) {
iconId = RenderingIcons.getBigIconResourceId(iconName);
} else {
iconId = app.getResources().getIdentifier(iconName, "drawable", app.getPackageName());
}
}
if (iconId <= 0) {
iconId = SearchHistoryFragment.getItemIcon(entry.getName());
}
try {
return getIcon(app, iconId);
} catch (Exception e) {
return getIcon(app, SearchHistoryFragment.getItemIcon(entry.getName()));
}
case WPT:
WptPt wpt = (WptPt) searchResult.object;
return FavoriteImageDrawable.getOrCreate(app, wpt.getColor(), false);
case UNKNOWN_NAME_FILTER:
break;
}
return null;
}
Aggregations