Search in sources :

Example 1 with ColoringType

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();
        }
    }
}
Also used : DirectionArrowsCard(net.osmand.plus.track.cards.DirectionArrowsCard) TrackWidthCard(net.osmand.plus.track.cards.TrackWidthCard) SplitIntervalCard(net.osmand.plus.track.cards.SplitIntervalCard) ColorsCard(net.osmand.plus.track.cards.ColorsCard) ColoringType(net.osmand.plus.routing.ColoringType) TrackColoringCard(net.osmand.plus.track.cards.TrackColoringCard) MapActivity(net.osmand.plus.activities.MapActivity)

Example 2 with ColoringType

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();
    }
}
Also used : ShowStartFinishCard(net.osmand.plus.track.cards.ShowStartFinishCard) TrackWidthCard(net.osmand.plus.track.cards.TrackWidthCard) ViewGroup(android.view.ViewGroup) GPXTrackAnalysis(net.osmand.GPXUtilities.GPXTrackAnalysis) ImageView(android.widget.ImageView) View(android.view.View) ScrollView(android.widget.ScrollView) DirectionArrowsCard(net.osmand.plus.track.cards.DirectionArrowsCard) SplitIntervalCard(net.osmand.plus.track.cards.SplitIntervalCard) ScrollView(android.widget.ScrollView) ColoringType(net.osmand.plus.routing.ColoringType) PromoBannerCard(net.osmand.plus.chooseplan.PromoBannerCard) ColoringTypeCard(net.osmand.plus.track.cards.ColoringTypeCard) TrackColoringCard(net.osmand.plus.track.cards.TrackColoringCard) ActionsCard(net.osmand.plus.track.cards.ActionsCard) MapActivity(net.osmand.plus.activities.MapActivity)

Example 3 with ColoringType

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;
}
Also used : ColoringType(net.osmand.plus.routing.ColoringType) GradientScaleType(net.osmand.plus.track.GradientScaleType)

Example 4 with ColoringType

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);
            }
        }
    }
}
Also used : ArrayList(java.util.ArrayList) TrkSegment(net.osmand.GPXUtilities.TrkSegment) QuadRect(net.osmand.data.QuadRect) Paint(android.graphics.Paint) SelectedGpxPoint(net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint) Renderable(net.osmand.plus.views.Renderable) ColoringType(net.osmand.plus.routing.ColoringType) GpxGeometryWay(net.osmand.plus.views.layers.geometry.GpxGeometryWay) GPXFile(net.osmand.GPXUtilities.GPXFile)

Example 5 with ColoringType

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;
}
Also used : ColoringType(net.osmand.plus.routing.ColoringType)

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