Search in sources :

Example 6 with GpxDisplayItem

use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.

the class SplitSegmentDialogFragment method getSplitSegments.

@NonNull
private List<GpxDisplayItem> getSplitSegments() {
    List<GpxDisplayItem> splitSegments = new ArrayList<>();
    List<GpxDisplayGroup> result = displayHelper.getGpxFile(true);
    if (result != null && result.size() > 0 && trkSegment.points.size() > 0) {
        for (GpxDisplayGroup group : result) {
            splitSegments.addAll(collectDisplayItemsFromGroup(group));
        }
    }
    return splitSegments;
}
Also used : GpxDisplayGroup(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup) GpxDisplayItem(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem) TIntArrayList(gnu.trove.list.array.TIntArrayList) ArrayList(java.util.ArrayList) NonNull(androidx.annotation.NonNull)

Example 7 with GpxDisplayItem

use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.

the class TrackPointsAdapter method synchronizeGroups.

public void synchronizeGroups(@NonNull List<GpxDisplayGroup> displayGroups) {
    groups.clear();
    pointsGroups.clear();
    DisplayGroupsHolder groupsHolder = DisplayPointsGroupsHelper.getGroups(app, displayGroups, null);
    groups.addAll(groupsHolder.groups);
    for (Map.Entry<GpxDisplayGroup, List<GpxDisplayItem>> entry : groupsHolder.itemGroups.entrySet()) {
        List<WptPt> points = new ArrayList<>();
        for (GpxDisplayItem item : entry.getValue()) {
            points.add(item.locationStart);
        }
        pointsGroups.put(entry.getKey(), points);
    }
    notifyDataSetChanged();
}
Also used : GpxDisplayGroup(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup) WptPt(net.osmand.GPXUtilities.WptPt) DisplayGroupsHolder(net.osmand.plus.track.helpers.DisplayPointsGroupsHelper.DisplayGroupsHolder) ArrayList(java.util.ArrayList) GpxDisplayItem(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 8 with GpxDisplayItem

use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.

the class CommonChartAdapter method prepareChartView.

@Override
protected void prepareChartView() {
    super.prepareChartView();
    chart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {

        @Override
        public void onValueSelected(Entry e, Highlight h) {
            highlight = h;
            for (ExternalValueSelectedListener listener : externalValueSelectedListeners.values()) {
                listener.onValueSelected(e, h);
            }
        }

        @Override
        public void onNothingSelected() {
            for (ExternalValueSelectedListener listener : externalValueSelectedListeners.values()) {
                listener.onNothingSelected();
            }
        }
    });
    chart.setOnChartGestureListener(new OnChartGestureListener() {

        boolean hasTranslated = false;

        float highlightDrawX = -1;

        @Override
        public void onChartGestureStart(MotionEvent me, ChartTouchListener.ChartGesture lastPerformedGesture) {
            hasTranslated = false;
            if (chart.getHighlighted() != null && chart.getHighlighted().length > 0) {
                highlightDrawX = chart.getHighlighted()[0].getDrawX();
            } else {
                highlightDrawX = -1;
            }
            if (externalGestureListener != null) {
                externalGestureListener.onChartGestureStart(me, lastPerformedGesture);
            }
        }

        @Override
        public void onChartGestureEnd(MotionEvent me, ChartTouchListener.ChartGesture lastPerformedGesture) {
            GpxDisplayItem gpxItem = getGpxItem();
            gpxItem.chartMatrix = new Matrix(chart.getViewPortHandler().getMatrixTouch());
            Highlight[] highlights = chart.getHighlighted();
            if (highlights != null && highlights.length > 0) {
                gpxItem.chartHighlightPos = highlights[0].getX();
            } else {
                gpxItem.chartHighlightPos = -1;
            }
            if (externalGestureListener != null) {
                externalGestureListener.onChartGestureEnd(me, lastPerformedGesture, hasTranslated);
            }
        }

        @Override
        public void onChartLongPressed(MotionEvent me) {
        }

        @Override
        public void onChartDoubleTapped(MotionEvent me) {
        }

        @Override
        public void onChartSingleTapped(MotionEvent me) {
        }

        @Override
        public void onChartFling(MotionEvent me1, MotionEvent me2, float velocityX, float velocityY) {
        }

        @Override
        public void onChartScale(MotionEvent me, float scaleX, float scaleY) {
        }

        @Override
        public void onChartTranslate(MotionEvent me, float dX, float dY) {
            hasTranslated = true;
            if (highlightDrawX != -1) {
                Highlight h = chart.getHighlightByTouchPoint(highlightDrawX, 0f);
                if (h != null) {
                    chart.highlightValue(h, true);
                }
            }
        }
    });
}
Also used : OnChartValueSelectedListener(com.github.mikephil.charting.listener.OnChartValueSelectedListener) Highlight(com.github.mikephil.charting.highlight.Highlight) OnChartGestureListener(com.github.mikephil.charting.listener.OnChartGestureListener) GpxDisplayItem(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem) ChartTouchListener(com.github.mikephil.charting.listener.ChartTouchListener) MotionEvent(android.view.MotionEvent) Entry(com.github.mikephil.charting.data.Entry) Matrix(android.graphics.Matrix)

Example 9 with GpxDisplayItem

use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.

the class DeletePointsTask method doInBackground.

@Override
protected Void doInBackground(Void... params) {
    SavingTrackHelper savingTrackHelper = app.getSavingTrackHelper();
    if (gpx != null) {
        for (GpxDisplayItem item : selectedItems) {
            if (gpx.showCurrentTrack) {
                savingTrackHelper.deletePointData(item.locationStart);
            } else {
                if (item.group.getType() == GpxDisplayItemType.TRACK_POINTS) {
                    gpx.deleteWptPt(item.locationStart);
                } else if (item.group.getType() == GpxDisplayItemType.TRACK_ROUTE_POINTS) {
                    gpx.deleteRtePt(item.locationStart);
                }
            }
        }
        if (!gpx.showCurrentTrack) {
            GPXUtilities.writeGpxFile(new File(gpx.path), gpx);
            boolean selected = app.getSelectedGpxHelper().getSelectedFileByPath(gpx.path) != null;
            if (selected) {
                app.getSelectedGpxHelper().setGpxFileToDisplay(gpx);
            }
        }
        syncGpx(gpx);
    }
    return null;
}
Also used : GpxDisplayItem(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem) SavingTrackHelper(net.osmand.plus.track.helpers.SavingTrackHelper) GPXFile(net.osmand.GPXUtilities.GPXFile) File(java.io.File)

Example 10 with GpxDisplayItem

use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.

the class GPXLayer method drawSelectedFilesSplits.

private void drawSelectedFilesSplits(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles, DrawSettings settings) {
    if (tileBox.getZoom() >= START_ZOOM) {
        // request to load
        OsmandApplication app = view.getApplication();
        for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
            List<GpxDisplayGroup> groups = selectedGpxFile.getDisplayGroups(app);
            if (!Algorithms.isEmpty(groups)) {
                int color = getTrackColor(selectedGpxFile.getGpxFile(), cachedColor);
                paintInnerRect.setColor(color);
                paintInnerRect.setAlpha(179);
                int contrastColor = ColorUtilities.getContrastColor(app, color, false);
                paintTextIcon.setColor(contrastColor);
                paintOuterRect.setColor(contrastColor);
                List<GpxDisplayItem> items = groups.get(0).getModifiableList();
                drawSplitItems(canvas, tileBox, items, settings);
            }
        }
    }
}
Also used : GpxDisplayGroup(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup) OsmandApplication(net.osmand.plus.OsmandApplication) SelectedGpxFile(net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile) GpxDisplayItem(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem) Paint(android.graphics.Paint) SelectedGpxPoint(net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint)

Aggregations

GpxDisplayItem (net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem)35 ArrayList (java.util.ArrayList)8 GPXFile (net.osmand.GPXUtilities.GPXFile)7 TrkSegment (net.osmand.GPXUtilities.TrkSegment)7 WptPt (net.osmand.GPXUtilities.WptPt)7 LatLon (net.osmand.data.LatLon)7 MapActivity (net.osmand.plus.activities.MapActivity)7 GpxDisplayGroup (net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup)7 View (android.view.View)5 LineData (com.github.mikephil.charting.data.LineData)5 List (java.util.List)5 QuadRect (net.osmand.data.QuadRect)5 OrderedLineDataSet (net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet)5 ILineDataSet (com.github.mikephil.charting.interfaces.datasets.ILineDataSet)4 OsmandApplication (net.osmand.plus.OsmandApplication)4 Matrix (android.graphics.Matrix)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3 NonNull (androidx.annotation.NonNull)3 LinkedHashMap (java.util.LinkedHashMap)3