Search in sources :

Example 46 with FavouritePoint

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);
        }
    }
}
Also used : FavouritePoint(net.osmand.data.FavouritePoint) Paint(android.graphics.Paint)

Example 47 with FavouritePoint

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);
    }
}
Also used : FavoriteImageDrawable(net.osmand.plus.base.FavoriteImageDrawable) FavouritePoint(net.osmand.data.FavouritePoint) Paint(android.graphics.Paint)

Example 48 with FavouritePoint

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);
    }
}
Also used : FavouritePoint(net.osmand.data.FavouritePoint) PointF(android.graphics.PointF) FavoriteImageDrawable(net.osmand.plus.base.FavoriteImageDrawable)

Example 49 with FavouritePoint

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);
    }
}
Also used : LatLon(net.osmand.data.LatLon) ColorInt(android.support.annotation.ColorInt) FavouritePoint(net.osmand.data.FavouritePoint) ArrayList(java.util.ArrayList) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) QuadRect(net.osmand.data.QuadRect) FavouritePoint(net.osmand.data.FavouritePoint) Paint(android.graphics.Paint)

Example 50 with FavouritePoint

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;
}
Also used : Amenity(net.osmand.data.Amenity) WptPt(net.osmand.plus.GPXUtilities.WptPt) FavouritePoint(net.osmand.data.FavouritePoint) FavoriteGroup(net.osmand.plus.FavouritesDbHelper.FavoriteGroup) Drawable(android.graphics.drawable.Drawable) FavoriteImageDrawable(net.osmand.plus.base.FavoriteImageDrawable) HistoryEntry(net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry) CustomSearchPoiFilter(net.osmand.search.core.CustomSearchPoiFilter) AbstractPoiType(net.osmand.osm.AbstractPoiType) FavouritePoint(net.osmand.data.FavouritePoint)

Aggregations

FavouritePoint (net.osmand.data.FavouritePoint)51 LatLon (net.osmand.data.LatLon)16 PointDescription (net.osmand.data.PointDescription)10 FavouritesDbHelper (net.osmand.plus.FavouritesDbHelper)10 View (android.view.View)9 ArrayList (java.util.ArrayList)9 AlertDialog (android.support.v7.app.AlertDialog)8 OsmandApplication (net.osmand.plus.OsmandApplication)8 TextView (android.widget.TextView)7 WptPt (net.osmand.plus.GPXUtilities.WptPt)7 MapActivity (net.osmand.plus.activities.MapActivity)7 DialogInterface (android.content.DialogInterface)6 ImageView (android.widget.ImageView)6 Amenity (net.osmand.data.Amenity)6 Paint (android.graphics.Paint)5 AdapterView (android.widget.AdapterView)5 ListView (android.widget.ListView)5 FavoriteGroup (net.osmand.plus.FavouritesDbHelper.FavoriteGroup)5 GPXFile (net.osmand.plus.GPXUtilities.GPXFile)5 Collator (java.text.Collator)4