Search in sources :

Example 11 with GpxDataItem

use of net.osmand.plus.GPXDatabase.GpxDataItem in project Osmand by osmandapp.

the class GPXLayer method drawXAxisPoints.

private void drawXAxisPoints(Canvas canvas, RotatedTileBox tileBox) {
    int color = trackChartPoints.getSegmentColor();
    if (color == 0) {
        GpxDataItem gpxDataItem = null;
        if (!trackChartPoints.getGpx().showCurrentTrack) {
            gpxDataItem = view.getApplication().getGpxDatabase().getItem(new File(trackChartPoints.getGpx().path));
        }
        color = gpxDataItem != null ? gpxDataItem.getColor() : 0;
        if (trackChartPoints.getGpx().showCurrentTrack) {
            color = currentTrackColor;
        }
        if (color == 0) {
            color = cachedColor;
        }
        trackChartPoints.setSegmentColor(color);
    }
    paintGridCircle.setColor(color);
    paintGridCircle.setAlpha(255);
    QuadRect latLonBounds = tileBox.getLatLonBounds();
    float r = 3 * tileBox.getDensity();
    List<WptPt> xAxisPoints = trackChartPoints.getXAxisPoints();
    if (xAxisPoints != null) {
        for (int i = 0; i < xAxisPoints.size(); i++) {
            WptPt axisPoint = xAxisPoints.get(i);
            if (axisPoint != null) {
                if (axisPoint.getLatitude() >= latLonBounds.bottom && axisPoint.getLatitude() <= latLonBounds.top && axisPoint.getLongitude() >= latLonBounds.left && axisPoint.getLongitude() <= latLonBounds.right) {
                    float x = tileBox.getPixXFromLatLon(axisPoint.getLatitude(), axisPoint.getLongitude());
                    float y = tileBox.getPixYFromLatLon(axisPoint.getLatitude(), axisPoint.getLongitude());
                    canvas.drawCircle(x, y, r + 2 * (float) Math.ceil(tileBox.getDensity()), paintGridOuterCircle);
                    canvas.drawCircle(x, y, r + (float) Math.ceil(tileBox.getDensity()), paintGridCircle);
                }
            }
        }
    }
}
Also used : WptPt(net.osmand.plus.GPXUtilities.WptPt) GpxDataItem(net.osmand.plus.GPXDatabase.GpxDataItem) SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) GPXFile(net.osmand.plus.GPXUtilities.GPXFile) File(java.io.File) QuadRect(net.osmand.data.QuadRect) Paint(android.graphics.Paint)

Example 12 with GpxDataItem

use of net.osmand.plus.GPXDatabase.GpxDataItem in project Osmand by osmandapp.

the class GPXLayer method drawSelectedFileSegments.

private void drawSelectedFileSegments(SelectedGpxFile selectedGpxFile, boolean currentTrack, Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
    GpxDataItem gpxDataItem = null;
    if (!currentTrack) {
        gpxDataItem = view.getApplication().getGpxDatabase().getItem(new File(selectedGpxFile.getGpxFile().path));
    }
    List<TrkSegment> segments = selectedGpxFile.getPointsToDisplay();
    for (TrkSegment ts : segments) {
        int color = gpxDataItem != null ? gpxDataItem.getColor() : 0;
        if (currentTrack) {
            color = currentTrackColor;
        }
        if (color == 0) {
            color = ts.getColor(cachedColor);
        }
        if (// only do once (CODE HERE NEEDS TO BE UI INSTEAD)
        ts.renders.isEmpty() && !ts.points.isEmpty()) {
            // hmmm. 0-point tracks happen, but.... how?
            if (currentTrack) {
                ts.renders.add(new Renderable.CurrentTrack(ts.points));
            } else {
                ts.renders.add(new Renderable.StandardTrack(ts.points, 17.2));
            }
        }
        updatePaints(color, selectedGpxFile.isRoutePoints(), currentTrack, settings, tileBox);
        ts.drawRenderers(view.getZoom(), paint, canvas, tileBox);
    }
}
Also used : GpxDataItem(net.osmand.plus.GPXDatabase.GpxDataItem) TrkSegment(net.osmand.plus.GPXUtilities.TrkSegment) SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) GPXFile(net.osmand.plus.GPXUtilities.GPXFile) File(java.io.File) Paint(android.graphics.Paint)

Aggregations

GpxDataItem (net.osmand.plus.GPXDatabase.GpxDataItem)12 GPXFile (net.osmand.plus.GPXUtilities.GPXFile)9 SelectedGpxFile (net.osmand.plus.GpxSelectionHelper.SelectedGpxFile)9 File (java.io.File)7 Paint (android.graphics.Paint)5 ArrayList (java.util.ArrayList)3 ListPopupWindow (android.support.v7.widget.ListPopupWindow)2 View (android.view.View)2 AdapterView (android.widget.AdapterView)2 ArrayAdapter (android.widget.ArrayAdapter)2 CompoundButton (android.widget.CompoundButton)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 List (java.util.List)2 ASelectedGpxFile (net.osmand.aidl.gpx.ASelectedGpxFile)2 GPXTrackAnalysis (net.osmand.plus.GPXUtilities.GPXTrackAnalysis)2 WptPt (net.osmand.plus.GPXUtilities.WptPt)2 GpxDisplayGroup (net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup)2 OsmandSettings (net.osmand.plus.OsmandSettings)2 AppearanceListItem (net.osmand.plus.dialogs.ConfigureMapMenu.AppearanceListItem)2