Search in sources :

Example 6 with ColoringType

use of net.osmand.plus.routing.ColoringType in project Osmand by osmandapp.

the class TrackColoringCard method listStaticAppearanceItems.

private List<TrackAppearanceItem> listStaticAppearanceItems() {
    List<TrackAppearanceItem> staticItems = new ArrayList<>();
    for (ColoringType coloringType : ColoringType.getTrackColoringTypes()) {
        if (coloringType.isRouteInfoAttribute()) {
            continue;
        }
        boolean isAvailable = coloringType.isAvailableForDrawingTrack(app, selectedGpxFile, null);
        staticItems.add(new TrackAppearanceItem(coloringType.getName(null), coloringType.getHumanString(app, null), coloringType.getIconId(), isAvailable || trackDrawInfo.isCurrentRecording()));
    }
    return staticItems;
}
Also used : ColoringType(net.osmand.plus.routing.ColoringType) ArrayList(java.util.ArrayList)

Example 7 with ColoringType

use of net.osmand.plus.routing.ColoringType in project Osmand by osmandapp.

the class RouteLayer method drawLocations.

public void drawLocations(RotatedTileBox tb, Canvas canvas, double topLatitude, double leftLongitude, double bottomLatitude, double rightLongitude) {
    if (helper.isPublicTransportMode()) {
        int currentRoute = transportHelper.getCurrentRoute();
        List<TransportRouteResult> routes = transportHelper.getRoutes();
        TransportRouteResult route = routes != null && routes.size() > currentRoute ? routes.get(currentRoute) : null;
        routeGeometry.clearRoute();
        publicTransportRouteGeometry.updateRoute(tb, route);
        if (route != null) {
            LatLon start = transportHelper.getStartLocation();
            Location startLocation = new Location("transport");
            startLocation.setLatitude(start.getLatitude());
            startLocation.setLongitude(start.getLongitude());
            publicTransportRouteGeometry.drawSegments(tb, canvas, topLatitude, leftLongitude, bottomLatitude, rightLongitude, startLocation, 0);
        }
    } else {
        RouteCalculationResult route = helper.getRoute();
        boolean directTo = route.getRouteService() == RouteService.DIRECT_TO;
        boolean straight = route.getRouteService() == RouteService.STRAIGHT;
        publicTransportRouteGeometry.clearRoute();
        ColoringType actualColoringType = isColoringAvailable(routeColoringType, routeInfoAttribute) ? routeColoringType : ColoringType.DEFAULT;
        routeGeometry.setRouteStyleParams(getRouteLineColor(), getRouteLineWidth(tb), directionArrowsColor, actualColoringType, routeInfoAttribute);
        routeGeometry.updateRoute(tb, route);
        if (directTo) {
            routeGeometry.drawSegments(tb, canvas, topLatitude, leftLongitude, bottomLatitude, rightLongitude, null, 0);
        } else if (straight) {
            routeGeometry.drawSegments(tb, canvas, topLatitude, leftLongitude, bottomLatitude, rightLongitude, helper.getLastFixedLocation(), route.getCurrentStraightAngleRoute());
        } else {
            routeGeometry.drawSegments(tb, canvas, topLatitude, leftLongitude, bottomLatitude, rightLongitude, helper.getLastProjection(), route.getCurrentStraightAngleRoute());
        }
        List<RouteDirectionInfo> rd = helper.getRouteDirections();
        Iterator<RouteDirectionInfo> it = rd.iterator();
        if (!directTo && tb.getZoom() >= 14 && shouldShowTurnArrows()) {
            List<Location> actionPoints = calculateActionPoints(topLatitude, leftLongitude, bottomLatitude, rightLongitude, helper.getLastProjection(), helper.getRoute().getRouteLocations(), helper.getRoute().getCurrentRoute(), it, tb.getZoom());
            drawAction(tb, canvas, actionPoints);
        }
        if (directTo) {
            // add projection point on original route
            double[] projectionOnRoute = calculateProjectionOnRoutePoint(helper, tb);
            if (projectionOnRoute != null) {
                drawProjectionPoint(canvas, projectionOnRoute);
            }
        }
    }
}
Also used : TransportRouteResult(net.osmand.router.TransportRouteResult) LatLon(net.osmand.data.LatLon) RouteCalculationResult(net.osmand.plus.routing.RouteCalculationResult) ColoringType(net.osmand.plus.routing.ColoringType) RouteDirectionInfo(net.osmand.plus.routing.RouteDirectionInfo) Location(net.osmand.Location)

Example 8 with ColoringType

use of net.osmand.plus.routing.ColoringType in project Osmand by osmandapp.

the class RouteLineAppearanceFragment method createPreviewRouteLineInfo.

private PreviewRouteLineInfo createPreviewRouteLineInfo() {
    OsmandSettings settings = requireSettings();
    int colorDay = settings.CUSTOM_ROUTE_COLOR_DAY.getModeValue(appMode);
    int colorNight = settings.CUSTOM_ROUTE_COLOR_NIGHT.getModeValue(appMode);
    ColoringType coloringType = settings.ROUTE_COLORING_TYPE.getModeValue(appMode);
    String routeInfoAttribute = settings.ROUTE_INFO_ATTRIBUTE.getModeValue(appMode);
    String widthKey = settings.ROUTE_LINE_WIDTH.getModeValue(appMode);
    boolean showTurnArrows = settings.ROUTE_SHOW_TURN_ARROWS.getModeValue(appMode);
    PreviewRouteLineInfo previewRouteLineInfo = new PreviewRouteLineInfo(colorDay, colorNight, coloringType, routeInfoAttribute, widthKey, showTurnArrows);
    previewRouteLineInfo.setIconId(appMode.getNavigationIcon().getIconId());
    previewRouteLineInfo.setIconColor(appMode.getProfileColor(isNightMode()));
    return previewRouteLineInfo;
}
Also used : ColoringType(net.osmand.plus.routing.ColoringType) PreviewRouteLineInfo(net.osmand.plus.routing.PreviewRouteLineInfo) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings)

Example 9 with ColoringType

use of net.osmand.plus.routing.ColoringType in project Osmand by osmandapp.

the class GPXLayer method drawDirectionArrows.

private void drawDirectionArrows(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles) {
    if (!tileBox.isZoomAnimated()) {
        QuadRect correctedQuadRect = getCorrectedQuadRect(tileBox.getLatLonBounds());
        for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
            boolean showArrows = isShowArrowsForTrack(selectedGpxFile.getGpxFile());
            String coloringTypeName = getAvailableOrDefaultColoringType(selectedGpxFile);
            ColoringType coloringType = ColoringType.getNonNullTrackColoringTypeByName(coloringTypeName);
            if (!showArrows || coloringType.isRouteInfoAttribute() || !QuadRect.trivialOverlap(correctedQuadRect, calculateTrackBounds(selectedGpxFile.getPointsToDisplay()))) {
                continue;
            }
            String width = getTrackWidthName(selectedGpxFile.getGpxFile(), defaultTrackWidthPref.get());
            float trackWidth = getTrackWidth(width, defaultTrackWidth);
            int trackColor = getTrackColor(selectedGpxFile.getGpxFile(), cachedColor);
            List<TrkSegment> segments = coloringType.isGradient() ? getCachedSegments(selectedGpxFile, coloringType.toGradientScaleType()) : selectedGpxFile.getPointsToDisplay();
            for (TrkSegment segment : segments) {
                if (segment.renderer instanceof Renderable.RenderableSegment) {
                    ((Renderable.RenderableSegment) segment.renderer).drawGeometry(canvas, tileBox, correctedQuadRect, trackColor, trackWidth, true);
                }
            }
        }
    }
}
Also used : SelectedGpxFile(net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile) ColoringType(net.osmand.plus.routing.ColoringType) TrkSegment(net.osmand.GPXUtilities.TrkSegment) QuadRect(net.osmand.data.QuadRect) Paint(android.graphics.Paint) SelectedGpxPoint(net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint)

Example 10 with ColoringType

use of net.osmand.plus.routing.ColoringType in project Osmand by osmandapp.

the class GPXLayer method getAvailableOrDefaultColoringType.

private String getAvailableOrDefaultColoringType(SelectedGpxFile selectedGpxFile) {
    GPXFile gpxFile = selectedGpxFile.getGpxFileToDisplay();
    if (hasTrackDrawInfoForTrack(gpxFile)) {
        return trackDrawInfo.getColoringType().getName(trackDrawInfo.getRouteInfoAttribute());
    }
    GpxDataItem dataItem = null;
    String defaultColoringType = ColoringType.TRACK_SOLID.getName(null);
    ColoringType coloringType = null;
    String routeInfoAttribute = null;
    boolean isCurrentTrack = gpxFile.showCurrentTrack;
    if (isCurrentTrack) {
        coloringType = currentTrackColoringTypePref.get();
        routeInfoAttribute = currentTrackRouteInfoAttributePref.get();
    } else {
        dataItem = gpxDbHelper.getItem(new File(gpxFile.path));
        if (dataItem != null) {
            coloringType = ColoringType.getNonNullTrackColoringTypeByName(dataItem.getColoringType());
            routeInfoAttribute = ColoringType.getRouteInfoAttribute(dataItem.getColoringType());
        }
    }
    if (coloringType == null) {
        return defaultColoringType;
    } else if (!coloringType.isAvailableInSubscription(view.getApplication(), routeInfoAttribute, false)) {
        return defaultColoringType;
    } else if (getCachedTrack(selectedGpxFile).isColoringTypeAvailable(coloringType, routeInfoAttribute)) {
        return coloringType.getName(routeInfoAttribute);
    } else {
        if (!isCurrentTrack) {
            gpxDbHelper.updateColoringType(dataItem, defaultColoringType);
        }
        return defaultColoringType;
    }
}
Also used : ColoringType(net.osmand.plus.routing.ColoringType) GpxDataItem(net.osmand.plus.track.helpers.GPXDatabase.GpxDataItem) GPXFile(net.osmand.GPXUtilities.GPXFile) GPXFile(net.osmand.GPXUtilities.GPXFile) SelectedGpxFile(net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile) File(java.io.File)

Aggregations

ColoringType (net.osmand.plus.routing.ColoringType)13 GPXFile (net.osmand.GPXUtilities.GPXFile)4 Paint (android.graphics.Paint)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 GPXTrackAnalysis (net.osmand.GPXUtilities.GPXTrackAnalysis)2 TrkSegment (net.osmand.GPXUtilities.TrkSegment)2 QuadRect (net.osmand.data.QuadRect)2 MapActivity (net.osmand.plus.activities.MapActivity)2 SelectedGpxPoint (net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint)2 GradientScaleType (net.osmand.plus.track.GradientScaleType)2 DirectionArrowsCard (net.osmand.plus.track.cards.DirectionArrowsCard)2 SplitIntervalCard (net.osmand.plus.track.cards.SplitIntervalCard)2 TrackColoringCard (net.osmand.plus.track.cards.TrackColoringCard)2 TrackWidthCard (net.osmand.plus.track.cards.TrackWidthCard)2 SelectedGpxFile (net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile)2 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 ImageView (android.widget.ImageView)1 ScrollView (android.widget.ScrollView)1