Search in sources :

Example 1 with BackgroundType

use of net.osmand.data.FavouritePoint.BackgroundType 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;
        }
    }
}
Also used : OsmandApplication(net.osmand.plus.OsmandApplication) ArrayList(java.util.ArrayList) QuadRect(net.osmand.data.QuadRect) PointImageDrawable(net.osmand.plus.views.PointImageDrawable) OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) LatLon(net.osmand.data.LatLon) BackgroundType(net.osmand.data.FavouritePoint.BackgroundType)

Example 2 with BackgroundType

use of net.osmand.data.FavouritePoint.BackgroundType 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);
}
Also used : BackgroundType(net.osmand.data.FavouritePoint.BackgroundType) PointImageDrawable(net.osmand.plus.views.PointImageDrawable) OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint)

Example 3 with BackgroundType

use of net.osmand.data.FavouritePoint.BackgroundType in project Osmand by osmandapp.

the class ContextMenuLayer method onDraw.

@Override
public void onDraw(Canvas canvas, RotatedTileBox box, DrawSettings nightMode) {
    MapActivity mapActivity = getMapActivity();
    if (mapActivity == null) {
        return;
    }
    boolean markerCustomized = false;
    if (selectedObject != null) {
        TIntArrayList x = null;
        TIntArrayList y = null;
        if (selectedObject instanceof Amenity) {
            Amenity a = (Amenity) selectedObject;
            x = a.getX();
            y = a.getY();
        } else if (selectedObject instanceof RenderedObject) {
            RenderedObject r = (RenderedObject) selectedObject;
            x = r.getX();
            y = r.getY();
        } else if (selectedObject instanceof AidlMapPointWrapper) {
            markerCustomized = true;
        }
        if (x != null && y != null && x.size() > 2) {
            float px, py, prevX, prevY;
            prevX = box.getPixXFrom31(x.get(0), y.get(0));
            prevY = box.getPixYFrom31(x.get(0), y.get(0));
            for (int i = 1; i < x.size(); i++) {
                px = box.getPixXFrom31(x.get(i), y.get(i));
                py = box.getPixYFrom31(x.get(i), y.get(i));
                canvas.drawLine(prevX, prevY, px, py, outlinePaint);
                prevX = px;
                prevY = py;
            }
        }
    }
    float textScale = 1f;
    if (!pressedLatLonSmall.isEmpty() || !pressedLatLonFull.isEmpty()) {
        textScale = getTextScale();
    }
    for (Entry<LatLon, BackgroundType> entry : pressedLatLonSmall.entrySet()) {
        LatLon latLon = entry.getKey();
        int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
        int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
        BackgroundType background = entry.getValue();
        Bitmap pressedBitmapSmall = background.getTouchBackground(mapActivity, true);
        Rect destRect = getIconDestinationRect(x, y, pressedBitmapSmall.getWidth(), pressedBitmapSmall.getHeight(), textScale);
        canvas.drawBitmap(pressedBitmapSmall, null, destRect, paint);
    }
    for (Entry<LatLon, BackgroundType> entry : pressedLatLonFull.entrySet()) {
        LatLon latLon = entry.getKey();
        int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
        int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
        BackgroundType background = entry.getValue();
        Bitmap pressedBitmap = background.getTouchBackground(mapActivity, false);
        int offsetY = background.getOffsetY(mapActivity, textScale);
        Rect destRect = getIconDestinationRect(x, y - offsetY, pressedBitmap.getWidth(), pressedBitmap.getHeight(), textScale);
        canvas.drawBitmap(pressedBitmap, null, destRect, paint);
    }
    boolean movingMarker = mapQuickActionLayer != null && mapQuickActionLayer.isInMovingMarkerMode();
    boolean downloadingTiles = mapActivity.getDownloadTilesFragment() != null;
    if (movingMarker || downloadingTiles) {
        return;
    }
    if (mInChangeMarkerPositionMode) {
        if (menu != null && menu.getObject() == null) {
            canvas.translate(box.getPixWidth() / 2 - contextMarker.getWidth() / 2, box.getPixHeight() / 2 - contextMarker.getHeight());
            contextMarker.draw(canvas);
        }
        if (mMoveMarkerBottomSheetHelper != null) {
            mMoveMarkerBottomSheetHelper.onDraw(box);
        }
    } else if (mInAddGpxPointMode) {
        canvas.translate(box.getPixWidth() / 2 - contextMarker.getWidth() / 2, box.getPixHeight() / 2 - contextMarker.getHeight());
        contextMarker.draw(canvas);
        if (mAddGpxPointBottomSheetHelper != null) {
            mAddGpxPointBottomSheetHelper.onDraw(box);
        }
    } else if (!markerCustomized) {
        LatLon latLon = null;
        if (menu != null && menu.isActive()) {
            latLon = menu.getLatLon();
        } else if (mapActivity.getTrackMenuFragment() != null) {
            latLon = mapActivity.getTrackMenuFragment().getLatLon();
        }
        if (latLon != null) {
            int x = (int) box.getPixXFromLatLon(latLon.getLatitude(), latLon.getLongitude());
            int y = (int) box.getPixYFromLatLon(latLon.getLatitude(), latLon.getLongitude());
            canvas.translate(x - contextMarker.getWidth() / 2, y - contextMarker.getHeight());
            contextMarker.draw(canvas);
        }
    }
}
Also used : Amenity(net.osmand.data.Amenity) Rect(android.graphics.Rect) AidlMapPointWrapper(net.osmand.aidl.AidlMapPointWrapper) TIntArrayList(gnu.trove.list.array.TIntArrayList) Paint(android.graphics.Paint) NewGpxPoint(net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint) FavouritePoint(net.osmand.data.FavouritePoint) SelectedGpxPoint(net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint) RenderedObject(net.osmand.NativeLibrary.RenderedObject) LatLon(net.osmand.data.LatLon) Bitmap(android.graphics.Bitmap) BackgroundType(net.osmand.data.FavouritePoint.BackgroundType) MapActivity(net.osmand.plus.activities.MapActivity)

Example 4 with BackgroundType

use of net.osmand.data.FavouritePoint.BackgroundType in project Osmand by osmandapp.

the class PointEditorFragmentNew method onCardPressed.

@Override
public void onCardPressed(@NonNull BaseCard card) {
    if (card instanceof IconsCard) {
        setIcon(iconsCard.getSelectedIconId());
        updateNameIcon();
    } else if (card instanceof ColorsCard) {
        int color = ((ColorsCard) card).getSelectedColor();
        updateColorSelector(color);
    } else if (card instanceof ShapesCard) {
        BackgroundType selectedShape = shapesCard.getSelectedShape();
        setBackgroundType(selectedShape);
        updateNameIcon();
        updateSelectedShapeText();
        ((TextView) view.findViewById(R.id.shape_name)).setText(selectedShape.getNameId());
    }
}
Also used : ColorsCard(net.osmand.plus.track.cards.ColorsCard) BackgroundType(net.osmand.data.FavouritePoint.BackgroundType) TextView(android.widget.TextView)

Example 5 with BackgroundType

use of net.osmand.data.FavouritePoint.BackgroundType in project Osmand by osmandapp.

the class ShapesCard method updateContent.

@Override
protected void updateContent() {
    FlowLayout flowLayout = ((FlowLayout) view);
    flowLayout.setHorizontalAutoSpacing(true);
    LayoutInflater inflater = UiUtilities.getInflater(view.getContext(), nightMode);
    int width = getDimen(R.dimen.favorites_select_icon_button_right_padding);
    for (BackgroundType shape : BackgroundType.values()) {
        if (shape.isSelected()) {
            FlowLayout.LayoutParams layoutParams = new FlowLayout.LayoutParams(width, 0);
            flowLayout.addView(createShapeItemView(inflater, shape), layoutParams);
        }
    }
}
Also used : FlowLayout(net.osmand.plus.widgets.FlowLayout) BackgroundType(net.osmand.data.FavouritePoint.BackgroundType) LayoutInflater(android.view.LayoutInflater)

Aggregations

BackgroundType (net.osmand.data.FavouritePoint.BackgroundType)6 LatLon (net.osmand.data.LatLon)3 TIntArrayList (gnu.trove.list.array.TIntArrayList)2 ArrayList (java.util.ArrayList)2 RenderedObject (net.osmand.NativeLibrary.RenderedObject)2 FavouritePoint (net.osmand.data.FavouritePoint)2 OsmNotesPoint (net.osmand.plus.plugins.osmedit.data.OsmNotesPoint)2 OsmPoint (net.osmand.plus.plugins.osmedit.data.OsmPoint)2 PointImageDrawable (net.osmand.plus.views.PointImageDrawable)2 Bitmap (android.graphics.Bitmap)1 Paint (android.graphics.Paint)1 Rect (android.graphics.Rect)1 LayoutInflater (android.view.LayoutInflater)1 TextView (android.widget.TextView)1 NonNull (androidx.annotation.NonNull)1 HashMap (java.util.HashMap)1 CallbackWithObject (net.osmand.CallbackWithObject)1 WptPt (net.osmand.GPXUtilities.WptPt)1 AidlMapPointWrapper (net.osmand.aidl.AidlMapPointWrapper)1 MapObject (net.osmand.core.jni.MapObject)1