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