use of net.osmand.plus.routing.ColoringType in project Osmand by osmandapp.
the class TrackAppearanceFragment method onCardPressed.
@Override
public void onCardPressed(@NonNull BaseCard card) {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
if (card instanceof SplitIntervalCard) {
SplitIntervalBottomSheet.showInstance(mapActivity.getSupportFragmentManager(), trackDrawInfo, this);
} else if (card instanceof TrackColoringCard) {
TrackColoringCard trackColoringCard = ((TrackColoringCard) card);
ColoringType currentColoringType = trackColoringCard.getSelectedColoringType();
String routeInfoAttribute = trackColoringCard.getRouteInfoAttribute();
trackDrawInfo.setColoringType(currentColoringType);
trackDrawInfo.setRouteInfoAttribute(routeInfoAttribute);
refreshMap();
if (coloringTypeCard != null) {
coloringTypeCard.setColoringType(currentColoringType);
}
if (colorsCard != null) {
AndroidUiHelper.updateVisibility(colorsCard.getView(), currentColoringType.isTrackSolid());
}
updatePromoCardVisibility();
} else if (card instanceof ColorsCard) {
int color = ((ColorsCard) card).getSelectedColor();
trackDrawInfo.setColor(color);
updateColorItems();
} else if (card instanceof TrackWidthCard) {
updateAppearanceIcon();
} else if (card instanceof DirectionArrowsCard) {
updateAppearanceIcon();
}
}
}
use of net.osmand.plus.routing.ColoringType in project Osmand by osmandapp.
the class TrackAppearanceFragment method setupCards.
private void setupCards() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
ViewGroup container = getCardsContainer();
container.removeAllViews();
cards.clear();
if (!selectedGpxFile.isShowCurrentTrack() && !Algorithms.isEmpty(getDisplaySegmentGroups())) {
splitIntervalCard = new SplitIntervalCard(mapActivity, trackDrawInfo);
addCard(container, splitIntervalCard);
}
addCard(container, new DirectionArrowsCard(mapActivity, trackDrawInfo));
addCard(container, new ShowStartFinishCard(mapActivity, trackDrawInfo));
trackColoringCard = new TrackColoringCard(mapActivity, selectedGpxFile, trackDrawInfo);
addCard(container, trackColoringCard);
setupColorsCard(container);
GPXTrackAnalysis analysis = selectedGpxFile.getTrackAnalysis(app);
ColoringType coloringType = trackDrawInfo.getColoringType();
coloringTypeCard = new ColoringTypeCard(mapActivity, analysis, coloringType);
addCard(container, coloringTypeCard);
promoCard = new PromoBannerCard(mapActivity, true);
addCard(container, promoCard);
trackWidthCard = new TrackWidthCard(mapActivity, trackDrawInfo, new OnNeedScrollListener() {
@Override
public void onVerticalScrollNeeded(int y) {
View view = trackWidthCard.getView();
if (view != null) {
int resultYPosition = view.getTop() + y;
int dialogHeight = getInnerScrollableHeight();
ScrollView scrollView = (ScrollView) getBottomScrollView();
if (resultYPosition > (scrollView.getScrollY() + dialogHeight)) {
scrollView.smoothScrollTo(0, resultYPosition - dialogHeight);
}
}
}
});
addCard(container, trackWidthCard);
addCard(container, new ActionsCard(mapActivity));
updatePromoCardVisibility();
}
}
use of net.osmand.plus.routing.ColoringType in project Osmand by osmandapp.
the class GpxAppearanceInfo method fromJson.
public static GpxAppearanceInfo fromJson(@NonNull JSONObject json) {
GpxAppearanceInfo gpxAppearanceInfo = new GpxAppearanceInfo();
boolean hasAnyParam = json.has("color");
gpxAppearanceInfo.color = json.optInt("color");
hasAnyParam |= json.has("width");
gpxAppearanceInfo.width = json.optString("width");
hasAnyParam |= json.has("show_arrows");
gpxAppearanceInfo.showArrows = json.optBoolean("show_arrows");
hasAnyParam |= json.has("show_start_finish");
gpxAppearanceInfo.showStartFinish = json.optBoolean("show_start_finish");
hasAnyParam |= json.has("split_type");
gpxAppearanceInfo.splitType = GpxSplitType.getSplitTypeByName(json.optString("split_type")).getType();
hasAnyParam |= json.has("split_interval");
gpxAppearanceInfo.splitInterval = json.optDouble("split_interval");
hasAnyParam |= json.has("coloring_type");
gpxAppearanceInfo.coloringType = json.optString("coloring_type");
if (ColoringType.getNullableTrackColoringTypeByName(gpxAppearanceInfo.coloringType) == null) {
hasAnyParam |= json.has("gradient_scale_type");
GradientScaleType scaleType = getScaleType(json.optString("gradient_scale_type"));
ColoringType coloringType = ColoringType.fromGradientScaleType(scaleType);
gpxAppearanceInfo.coloringType = coloringType == null ? null : coloringType.getName(null);
}
hasAnyParam |= json.has("time_span");
gpxAppearanceInfo.timeSpan = json.optLong("time_span");
hasAnyParam |= json.has("wpt_points");
gpxAppearanceInfo.wptPoints = json.optInt("wpt_points");
hasAnyParam |= json.has("total_distance");
gpxAppearanceInfo.totalDistance = (float) json.optDouble("total_distance");
hasAnyParam |= json.has(TAG_SMOOTHING_THRESHOLD);
gpxAppearanceInfo.smoothingThreshold = json.optDouble(TAG_SMOOTHING_THRESHOLD);
hasAnyParam |= json.has(TAG_MIN_FILTER_SPEED);
gpxAppearanceInfo.minFilterSpeed = json.optDouble(TAG_MIN_FILTER_SPEED);
hasAnyParam |= json.has(TAG_MAX_FILTER_SPEED);
gpxAppearanceInfo.maxFilterSpeed = json.optDouble(TAG_MAX_FILTER_SPEED);
hasAnyParam |= json.has(TAG_MIN_FILTER_ALTITUDE);
gpxAppearanceInfo.minFilterAltitude = json.optDouble(TAG_MIN_FILTER_ALTITUDE);
hasAnyParam |= json.has(TAG_MAX_FILTER_ALTITUDE);
gpxAppearanceInfo.maxFilterAltitude = json.optDouble(TAG_MAX_FILTER_ALTITUDE);
hasAnyParam |= json.has(TAG_MAX_FILTER_HDOP);
gpxAppearanceInfo.maxFilterHdop = json.optDouble(TAG_MAX_FILTER_HDOP);
return hasAnyParam ? gpxAppearanceInfo : null;
}
use of net.osmand.plus.routing.ColoringType in project Osmand by osmandapp.
the class GPXLayer method drawSelectedFileSegments.
private void drawSelectedFileSegments(SelectedGpxFile selectedGpxFile, boolean currentTrack, Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
GPXFile gpxFile = selectedGpxFile.getGpxFileToDisplay();
QuadRect correctedQuadRect = getCorrectedQuadRect(tileBox.getLatLonBounds());
String coloringTypeName = getAvailableOrDefaultColoringType(selectedGpxFile);
ColoringType coloringType = ColoringType.getNonNullTrackColoringTypeByName(coloringTypeName);
String routeIndoAttribute = ColoringType.getRouteInfoAttribute(coloringTypeName);
boolean visible = QuadRect.trivialOverlap(tileBox.getLatLonBounds(), calculateTrackBounds(selectedGpxFile.getPointsToDisplay()));
if (!gpxFile.hasTrkPt() && coloringType.isGradient() || !visible) {
segmentsCache.remove(selectedGpxFile.getGpxFile().path);
return;
}
List<TrkSegment> segments = new ArrayList<>();
if (coloringType.isTrackSolid() || coloringType.isRouteInfoAttribute()) {
segments.addAll(selectedGpxFile.getPointsToDisplay());
} else {
segments.addAll(getCachedSegments(selectedGpxFile, coloringType.toGradientScaleType()));
}
for (int segmentIdx = 0; segmentIdx < segments.size(); segmentIdx++) {
TrkSegment ts = segments.get(segmentIdx);
String width = getTrackWidthName(gpxFile, defaultTrackWidthPref.get());
int color = getTrackColor(gpxFile, ts.getColor(cachedColor));
if (ts.renderer == null && !ts.points.isEmpty()) {
Renderable.RenderableSegment renderer;
if (currentTrack) {
renderer = new Renderable.CurrentTrack(ts.points);
} else {
renderer = new Renderable.StandardTrack(ts.points, 17.2);
}
ts.renderer = renderer;
renderer.setGeometryWay(new GpxGeometryWay(wayContext));
}
updatePaints(color, width, selectedGpxFile.isRoutePoints(), currentTrack, settings, tileBox);
if (ts.renderer instanceof Renderable.RenderableSegment) {
Renderable.RenderableSegment renderableSegment = (Renderable.RenderableSegment) ts.renderer;
renderableSegment.setTrackColoringParams(coloringType, routeIndoAttribute, borderPaint);
if (coloringType.isRouteInfoAttribute()) {
renderableSegment.setRoute(getCachedTrack(selectedGpxFile).getCachedRouteSegments(segmentIdx));
boolean drawArrows = isShowArrowsForTrack(selectedGpxFile.getGpxFile());
renderableSegment.drawGeometry(canvas, tileBox, correctedQuadRect, paint.getColor(), paint.getStrokeWidth(), drawArrows);
} else {
renderableSegment.drawSegment(view.getZoom(), paint, canvas, tileBox);
}
}
}
}
use of net.osmand.plus.routing.ColoringType in project Osmand by osmandapp.
the class TrackColoringCard method getSelectedAppearanceItem.
private TrackAppearanceItem getSelectedAppearanceItem() {
if (selectedAppearanceItem == null) {
ColoringType coloringType = trackDrawInfo.getColoringType();
String routeInfoAttribute = trackDrawInfo.getRouteInfoAttribute();
for (TrackAppearanceItem item : appearanceItems) {
if (item.getAttrName().equals(coloringType.getName(routeInfoAttribute))) {
selectedAppearanceItem = item;
break;
}
}
}
return selectedAppearanceItem;
}
Aggregations