Search in sources :

Example 1 with Prediction

use of com.eveningoutpost.dexdrip.Models.Prediction in project xDrip by NightscoutFoundation.

the class BgGraphBuilder method predictiveLines.

private List<Line> predictiveLines() {
    final List<Line> lines = new LinkedList<>();
    final boolean g_prediction = Pref.getBooleanDefaultFalse("show_g_prediction");
    final boolean medtrum = Pref.getBooleanDefaultFalse("show_medtrum_secondary");
    if (medtrum || g_prediction) {
        final List<Prediction> plist = Prediction.latestForGraph(4000, loaded_start, loaded_end);
        if (plist.size() > 0) {
            final List<PointValue> gpoints = new ArrayList<>(plist.size());
            final float yscale = !doMgdl ? (float) Constants.MGDL_TO_MMOLL : 1f;
            for (Prediction p : plist) {
                switch(p.source) {
                    case "EGlucoseRx":
                        final PointValue point = new PointValue(((float) (p.timestamp + (Constants.MINUTE_IN_MS * 10)) / FUZZER), (float) (p.glucose * yscale));
                        gpoints.add(point);
                        break;
                    case "Medtrum2nd":
                        final PointValue mpoint = new PointValue(((float) p.timestamp / FUZZER), (float) (p.glucose * yscale));
                        gpoints.add(mpoint);
                        break;
                }
            }
            if (gpoints.size() > 0) {
                lines.add(new Line(gpoints).setHasLabels(false).setHasPoints(true).setHasLines(false).setPointRadius(1).setColor(ChartUtils.darkenColor(ChartUtils.darkenColor(getCol(X.color_predictive)))));
            }
        }
    }
    return lines;
}
Also used : TrendLine(com.eveningoutpost.dexdrip.Models.Forecast.TrendLine) PolyTrendLine(com.eveningoutpost.dexdrip.Models.Forecast.PolyTrendLine) Line(lecho.lib.hellocharts.model.Line) PointValue(lecho.lib.hellocharts.model.PointValue) Prediction(com.eveningoutpost.dexdrip.Models.Prediction) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList)

Example 2 with Prediction

use of com.eveningoutpost.dexdrip.Models.Prediction in project xDrip-plus by jamorham.

the class BgGraphBuilder method predictiveLines.

private List<Line> predictiveLines() {
    final List<Line> lines = new LinkedList<>();
    final boolean g_prediction = Pref.getBooleanDefaultFalse("show_g_prediction");
    final boolean medtrum = Pref.getBooleanDefaultFalse("show_medtrum_secondary");
    if (medtrum || g_prediction) {
        final List<Prediction> plist = Prediction.latestForGraph(4000, loaded_start, loaded_end);
        if (plist.size() > 0) {
            final List<PointValue> gpoints = new ArrayList<>(plist.size());
            final float yscale = !doMgdl ? (float) Constants.MGDL_TO_MMOLL : 1f;
            for (Prediction p : plist) {
                switch(p.source) {
                    case "EGlucoseRx":
                        final PointValue point = new PointValue(((float) (p.timestamp + (Constants.MINUTE_IN_MS * 10)) / FUZZER), (float) (p.glucose * yscale));
                        gpoints.add(point);
                        break;
                    case "Medtrum2nd":
                        final PointValue mpoint = new PointValue(((float) p.timestamp / FUZZER), (float) (p.glucose * yscale));
                        gpoints.add(mpoint);
                        break;
                }
            }
            if (gpoints.size() > 0) {
                lines.add(new Line(gpoints).setHasLabels(false).setHasPoints(true).setHasLines(false).setPointRadius(1).setColor(ChartUtils.darkenColor(ChartUtils.darkenColor(getCol(X.color_predictive)))));
            }
        }
    }
    return lines;
}
Also used : TrendLine(com.eveningoutpost.dexdrip.Models.Forecast.TrendLine) PolyTrendLine(com.eveningoutpost.dexdrip.Models.Forecast.PolyTrendLine) Line(lecho.lib.hellocharts.model.Line) PointValue(lecho.lib.hellocharts.model.PointValue) Prediction(com.eveningoutpost.dexdrip.Models.Prediction) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList)

Aggregations

PolyTrendLine (com.eveningoutpost.dexdrip.Models.Forecast.PolyTrendLine)2 TrendLine (com.eveningoutpost.dexdrip.Models.Forecast.TrendLine)2 Prediction (com.eveningoutpost.dexdrip.Models.Prediction)2 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 Line (lecho.lib.hellocharts.model.Line)2 PointValue (lecho.lib.hellocharts.model.PointValue)2