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;
}
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();
}
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);
}
}
}
});
}
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;
}
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);
}
}
}
}
Aggregations