diff --git a/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.kt b/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.kt index f056104b11..d5b3dccb61 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.kt +++ b/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.kt @@ -342,6 +342,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() { graphData.addBgReadings(menuChartSettings[0][OverviewMenus.CharType.PRE.ordinal], context) if (buildHelper.isDev()) graphData.addBucketedData() graphData.addTreatments(context) + graphData.addEps(context, 0.95) if (menuChartSettings[0][OverviewMenus.CharType.TREAT.ordinal]) graphData.addTherapyEvents() if (menuChartSettings[0][OverviewMenus.CharType.ACT.ordinal]) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt index 1f17b786dd..139d3a8a93 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewData.kt @@ -77,6 +77,8 @@ class OverviewData @Inject constructor( ratioSeries = LineGraphSeries() dsMaxSeries = LineGraphSeries() dsMinSeries = LineGraphSeries() + treatmentsSeries = PointsWithLabelGraphSeries() + epsSeries = PointsWithLabelGraphSeries() } fun initRange() { @@ -261,6 +263,9 @@ class OverviewData @Inject constructor( var activitySeries: FixedLineGraphSeries = FixedLineGraphSeries() var activityPredictionSeries: FixedLineGraphSeries = FixedLineGraphSeries() + var maxEpsValue = 0.0 + val epsScale = Scale() + var epsSeries: PointsWithLabelGraphSeries = PointsWithLabelGraphSeries() var maxTreatmentsValue = 0.0 var treatmentsSeries: PointsWithLabelGraphSeries = PointsWithLabelGraphSeries() var maxTherapyEventValue = 0.0 diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt index 19c547a1d2..426b197249 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/OverviewFragment.kt @@ -973,6 +973,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList graphData.addBgReadings(menuChartSettings[0][OverviewMenus.CharType.PRE.ordinal], context) if (buildHelper.isDev()) graphData.addBucketedData() graphData.addTreatments(context) + graphData.addEps(context, 0.95) if (menuChartSettings[0][OverviewMenus.CharType.TREAT.ordinal]) graphData.addTherapyEvents() if (menuChartSettings[0][OverviewMenus.CharType.ACT.ordinal]) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt index 657939bf7f..0e9fa99b8b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphData/GraphData.kt @@ -89,11 +89,18 @@ class GraphData( maxY = maxOf(maxY, overviewData.maxTreatmentsValue) addSeries(overviewData.treatmentsSeries) overviewData.treatmentsSeries.setOnDataPointTapListener { _, dataPoint -> - if (dataPoint is EffectiveProfileSwitchDataPoint) ToastUtils.showToastInUiThread(context, dataPoint.data.originalCustomizedName) if (dataPoint is BolusDataPoint) ToastUtils.showToastInUiThread(context, dataPoint.label) } } + fun addEps(context: Context?, scale: Double) { + addSeries(overviewData.epsSeries) + overviewData.epsSeries.setOnDataPointTapListener { _, dataPoint -> + if (dataPoint is EffectiveProfileSwitchDataPoint) ToastUtils.showToastInUiThread(context, dataPoint.data.originalCustomizedName) + } + overviewData.epsScale.multiplier = maxY * scale / overviewData.maxEpsValue + } + fun addTherapyEvents() { maxY = maxOf(maxY, overviewData.maxTherapyEventValue) addSeries(overviewData.therapyEventSeries) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/EffectiveProfileSwitchDataPoint.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/EffectiveProfileSwitchDataPoint.kt index 0a9da0d4ae..716a0fd0b7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/EffectiveProfileSwitchDataPoint.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/EffectiveProfileSwitchDataPoint.kt @@ -8,16 +8,12 @@ import info.nightscout.androidaps.interfaces.ResourceHelper class EffectiveProfileSwitchDataPoint( val data: EffectiveProfileSwitch, private val rh: ResourceHelper, - private var yValue: Double + private val scale: Scale ) : DataPointWithLabelInterface { override fun getX(): Double = data.timestamp.toDouble() - override fun getY(): Double = yValue - - override fun setY(y: Double) { - yValue = y - } - + override fun getY(): Double = scale.transform(data.originalPercentage.toDouble()) + override fun setY(y: Double) {} override val label get() = if (data.originalPercentage != 100) data.originalPercentage.toString() + "%" else "" override val duration = 0L override val shape = PointsWithLabelGraphSeries.Shape.PROFILE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/InMemoryGlucoseValueDataPoint.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/InMemoryGlucoseValueDataPoint.kt index a5bf1c8e46..712ef22895 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/InMemoryGlucoseValueDataPoint.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/InMemoryGlucoseValueDataPoint.kt @@ -20,7 +20,7 @@ class InMemoryGlucoseValueDataPoint( override fun getX(): Double = data.timestamp.toDouble() override fun getY(): Double = valueToUnits(profileFunction.getUnits()) override fun setY(y: Double) {} - override val label: String? = null + override val label: String = "" override val duration = 0L override val shape = PointsWithLabelGraphSeries.Shape.BUCKETED_BG override val size = 0.3f diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/TherapyEventDataPoint.kt b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/TherapyEventDataPoint.kt index d3592673b4..af7179b02e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/TherapyEventDataPoint.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/TherapyEventDataPoint.kt @@ -43,7 +43,7 @@ class TherapyEventDataPoint( yValue = y } - override val label get() = if (data.note.isNullOrBlank().not()) data.note else translator.translate(data.type) + override val label get() = if (data.note.isNullOrBlank().not()) data.note!! else translator.translate(data.type) override val duration get() = data.duration override val shape get() = @@ -51,9 +51,9 @@ class TherapyEventDataPoint( data.type == TherapyEvent.Type.NS_MBG -> PointsWithLabelGraphSeries.Shape.MBG data.type == TherapyEvent.Type.FINGER_STICK_BG_VALUE -> PointsWithLabelGraphSeries.Shape.BGCHECK data.type == TherapyEvent.Type.ANNOUNCEMENT -> PointsWithLabelGraphSeries.Shape.ANNOUNCEMENT - data.type == TherapyEvent.Type.APS_OFFLINE -> PointsWithLabelGraphSeries.Shape.OPENAPSOFFLINE + data.type == TherapyEvent.Type.APS_OFFLINE -> PointsWithLabelGraphSeries.Shape.OPENAPS_OFFLINE data.type == TherapyEvent.Type.EXERCISE -> PointsWithLabelGraphSeries.Shape.EXERCISE - duration > 0 -> PointsWithLabelGraphSeries.Shape.GENERALWITHDURATION + duration > 0 -> PointsWithLabelGraphSeries.Shape.GENERAL_WITH_DURATION else -> PointsWithLabelGraphSeries.Shape.GENERAL } diff --git a/app/src/main/java/info/nightscout/androidaps/workflow/PrepareTreatmentsDataWorker.kt b/app/src/main/java/info/nightscout/androidaps/workflow/PrepareTreatmentsDataWorker.kt index 4d7a90d807..2278413459 100644 --- a/app/src/main/java/info/nightscout/androidaps/workflow/PrepareTreatmentsDataWorker.kt +++ b/app/src/main/java/info/nightscout/androidaps/workflow/PrepareTreatmentsDataWorker.kt @@ -53,8 +53,10 @@ class PrepareTreatmentsDataWorker( rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_TREATMENTS_DATA, 0, null)) data.overviewData.maxTreatmentsValue = 0.0 + data.overviewData.maxEpsValue = 0.0 val filteredTreatments: MutableList = ArrayList() val filteredTherapyEvents: MutableList = ArrayList() + val filteredEps: MutableList = ArrayList() repository.getBolusesDataFromTimeToTime(data.overviewData.fromTime, data.overviewData.endTime, true).blockingGet() .map { BolusDataPoint(it, rh, activePlugin, defaultValueHelper) } @@ -72,8 +74,11 @@ class PrepareTreatmentsDataWorker( // ProfileSwitch repository.getEffectiveProfileSwitchDataFromTimeToTime(data.overviewData.fromTime, data.overviewData.endTime, true).blockingGet() - .map { EffectiveProfileSwitchDataPoint(it, rh, data.overviewData.maxBgValue) } - .forEach(filteredTreatments::add) + .map { EffectiveProfileSwitchDataPoint(it, rh, data.overviewData.epsScale) } + .forEach { + data.overviewData.maxEpsValue = maxOf(data.overviewData.maxEpsValue, it.data.originalPercentage.toDouble()) + filteredEps.add(it) + } // OfflineEvent repository.getOfflineEventDataFromTimeToTime(data.overviewData.fromTime, data.overviewData.endTime, true).blockingGet() @@ -119,6 +124,7 @@ class PrepareTreatmentsDataWorker( data.overviewData.treatmentsSeries = PointsWithLabelGraphSeries(filteredTreatments.toTypedArray()) data.overviewData.therapyEventSeries = PointsWithLabelGraphSeries(filteredTherapyEvents.toTypedArray()) + data.overviewData.epsSeries = PointsWithLabelGraphSeries(filteredEps.toTypedArray()) rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_TREATMENTS_DATA, 100, null)) return Result.success() diff --git a/core/src/main/java/info/nightscout/androidaps/data/IobTotal.kt b/core/src/main/java/info/nightscout/androidaps/data/IobTotal.kt index 74bd1713b3..709b7d71c4 100644 --- a/core/src/main/java/info/nightscout/androidaps/data/IobTotal.kt +++ b/core/src/main/java/info/nightscout/androidaps/data/IobTotal.kt @@ -111,7 +111,7 @@ class IobTotal(val time: Long) : DataPointWithLabelInterface { override fun setY(y: Double) {} override val label = "" override val duration = 0L - override val shape = PointsWithLabelGraphSeries.Shape.IOBPREDICTION + override val shape = PointsWithLabelGraphSeries.Shape.IOB_PREDICTION override val size = 0.5f override fun color(context: Context?): Int { diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/DataPointWithLabelInterface.kt b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/DataPointWithLabelInterface.kt index 1878b16d6b..cb414abc71 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/DataPointWithLabelInterface.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/DataPointWithLabelInterface.kt @@ -9,9 +9,9 @@ interface DataPointWithLabelInterface : DataPointInterface { override fun getY(): Double fun setY(y: Double) - val label: String? + val label: String val duration: Long - val shape: PointsWithLabelGraphSeries.Shape? + val shape: PointsWithLabelGraphSeries.Shape val size: Float fun color(context: Context?): Int } \ No newline at end of file diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/PointsWithLabelGraphSeries.java b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/PointsWithLabelGraphSeries.java index fe8fcea185..d66585d173 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/PointsWithLabelGraphSeries.java +++ b/core/src/main/java/info/nightscout/androidaps/plugins/general/overview/graphExtensions/PointsWithLabelGraphSeries.java @@ -1,29 +1,5 @@ package info.nightscout.androidaps.plugins.general.overview.graphExtensions; -/** - * GraphView - * Copyright (C) 2014 Jonas Gehring - *

- * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, - * with the "Linking Exception", which can be found at the license.txt - * file in this program. - *

- * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - *

- * You should have received a copy of the GNU General Public License - * with the "Linking Exception" along with this program; if not, - * write to the author Jonas Gehring . - */ - -/* - * Added by mike - */ - import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; @@ -72,12 +48,12 @@ public class PointsWithLabelGraphSeries e MBG, BGCHECK, ANNOUNCEMENT, - OPENAPSOFFLINE, + OPENAPS_OFFLINE, EXERCISE, GENERAL, - GENERALWITHDURATION, - COBFAILOVER, - IOBPREDICTION, + GENERAL_WITH_DURATION, + COB_FAIL_OVER, + IOB_PREDICTION, BUCKETED_BG } @@ -96,7 +72,7 @@ public class PointsWithLabelGraphSeries e /** * creates the series with data * - * @param data datapoints + * @param data dataPoints */ public PointsWithLabelGraphSeries(E[] data) { super(data); @@ -104,7 +80,7 @@ public class PointsWithLabelGraphSeries e } /** - * inits the internal objects + * init the internal objects * set the defaults */ protected void init() { @@ -155,7 +131,6 @@ public class PointsWithLabelGraphSeries e float scaleX = (float) (graphWidth / diffX); - int i = 0; while (values.hasNext()) { E value = values.next(); @@ -195,18 +170,18 @@ public class PointsWithLabelGraphSeries e float endY = (float) (graphTop - y) + graphHeight; registerDataPoint(endX, endY, value); - float xpluslength = 0; + float xPlusLength = 0; if (duration > 0) { - xpluslength = Math.min(endWithDuration, graphLeft + graphWidth); + xPlusLength = Math.min(endWithDuration, graphLeft + graphWidth); } // draw data point if (!overdraw) { - if (value.getShape() == Shape.BG || value.getShape() == Shape.COBFAILOVER) { + if (value.getShape() == Shape.BG || value.getShape() == Shape.COB_FAIL_OVER) { mPaint.setStyle(Paint.Style.FILL); mPaint.setStrokeWidth(0); canvas.drawCircle(endX, endY, value.getSize() * scaledPxSize, mPaint); - } else if (value.getShape() == Shape.BG || value.getShape() == Shape.IOBPREDICTION || value.getShape() == Shape.BUCKETED_BG) { + } else if (value.getShape() == Shape.BG || value.getShape() == Shape.IOB_PREDICTION || value.getShape() == Shape.BUCKETED_BG) { mPaint.setColor(value.color(graphView.getContext())); mPaint.setStyle(Paint.Style.FILL); mPaint.setStrokeWidth(0); @@ -236,9 +211,8 @@ public class PointsWithLabelGraphSeries e points[2] = new Point((int) (endX - scaledPxSize), (int) (endY + scaledPxSize * 0.67)); mPaint.setStyle(Paint.Style.FILL_AND_STROKE); drawArrows(points, canvas, mPaint); - if (value.getLabel() != null) { + if (!value.getLabel().isEmpty()) drawLabel45Right(endX, endY, value, canvas, scaledPxSize, scaledTextSize); - } } else if (value.getShape() == Shape.CARBS) { mPaint.setStrokeWidth(0); Point[] points = new Point[3]; @@ -247,9 +221,8 @@ public class PointsWithLabelGraphSeries e points[2] = new Point((int) (endX - scaledPxSize), (int) (endY + scaledPxSize * 0.67)); mPaint.setStyle(Paint.Style.FILL_AND_STROKE); drawArrows(points, canvas, mPaint); - if (value.getLabel() != null) { + if (!value.getLabel().isEmpty()) drawLabel45Left(endX, endY, value, canvas, scaledPxSize, scaledTextSize); - } } else if (value.getShape() == Shape.SMB) { mPaint.setStrokeWidth(2); Point[] points = new Point[3]; @@ -261,8 +234,8 @@ public class PointsWithLabelGraphSeries e drawArrows(points, canvas, mPaint); } else if (value.getShape() == Shape.EXTENDEDBOLUS) { mPaint.setStrokeWidth(0); - if (value.getLabel() != null) { - Rect bounds = new Rect((int) endX, (int) endY + 3, (int) (xpluslength), (int) endY + 8); + if (!value.getLabel().isEmpty()) { + Rect bounds = new Rect((int) endX, (int) endY + 3, (int) (xPlusLength), (int) endY + 8); mPaint.setStyle(Paint.Style.FILL_AND_STROKE); canvas.drawRect(bounds, mPaint); mPaint.setTextSize(scaledTextSize); @@ -272,10 +245,13 @@ public class PointsWithLabelGraphSeries e } } else if (value.getShape() == Shape.PROFILE) { Drawable drawable = ContextCompat.getDrawable(graphView.getContext(), R.drawable.ic_ribbon_profile); + assert drawable != null; drawable.setColorFilter(Color.WHITE, PorterDuff.Mode.MULTIPLY); - drawable.setBounds((int) endX - drawable.getIntrinsicWidth() / 2, 0, + drawable.setBounds( + (int) (endX - drawable.getIntrinsicWidth() / 2), + (int) (endY - drawable.getIntrinsicHeight() / 2), (int) (endX + drawable.getIntrinsicWidth() / 2), - drawable.getIntrinsicHeight()); + (int) (endY + drawable.getIntrinsicHeight() / 2)); drawable.draw(canvas); mPaint.setTextSize(scaledTextSize * 0.8f); @@ -284,106 +260,73 @@ public class PointsWithLabelGraphSeries e Rect bounds = new Rect(); mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds); float px = endX - bounds.width() / 2.0f; - float py = (float) (drawable.getIntrinsicHeight() + 30); + float py = endY + drawable.getIntrinsicHeight(); mPaint.setStyle(Paint.Style.FILL); canvas.drawText(value.getLabel(), px, py, mPaint); - - /* - mPaint.setStrokeWidth(0); - if (value.getLabel() != null) { - //mPaint.setTextSize((int) (scaledPxSize * 3)); - mPaint.setTextSize((float) (scaledTextSize * 1.2)); - mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD)); - Rect bounds = new Rect(); - mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds); - float px = endX + bounds.height() / 2.0f; - float py = (float) (graphHeight * ratY + bounds.width() + 10); - canvas.save(); - canvas.rotate(-90, px, py); - mPaint.setStyle(Paint.Style.FILL_AND_STROKE); - canvas.drawText(value.getLabel(), px, py, mPaint); - mPaint.setStyle(Paint.Style.STROKE); - canvas.drawRect(px - 3, bounds.top + py - 3, bounds.right + px + 3, bounds.bottom + py + 3, mPaint); - canvas.restore(); - - } - */ } else if (value.getShape() == Shape.MBG) { mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeWidth(5); - float w = mPaint.getStrokeWidth(); canvas.drawCircle(endX, endY, scaledPxSize, mPaint); } else if (value.getShape() == Shape.BGCHECK) { mPaint.setStyle(Paint.Style.FILL_AND_STROKE); mPaint.setStrokeWidth(0); canvas.drawCircle(endX, endY, scaledPxSize, mPaint); - if (value.getLabel() != null) { + if (!value.getLabel().isEmpty()) { drawLabel45Right(endX, endY, value, canvas, scaledPxSize, scaledTextSize); } } else if (value.getShape() == Shape.ANNOUNCEMENT) { mPaint.setStyle(Paint.Style.FILL_AND_STROKE); mPaint.setStrokeWidth(0); canvas.drawCircle(endX, endY, scaledPxSize, mPaint); - if (value.getLabel() != null) { + if (!value.getLabel().isEmpty()) { drawLabel45Right(endX, endY, value, canvas, scaledPxSize, scaledTextSize); } } else if (value.getShape() == Shape.GENERAL) { mPaint.setStyle(Paint.Style.FILL_AND_STROKE); mPaint.setStrokeWidth(0); canvas.drawCircle(endX, endY, scaledPxSize, mPaint); - if (value.getLabel() != null) { + if (!value.getLabel().isEmpty()) { drawLabel45Right(endX, endY, value, canvas, scaledPxSize, scaledTextSize); } } else if (value.getShape() == Shape.EXERCISE) { mPaint.setStrokeWidth(0); - if (value.getLabel() != null) { + if (!value.getLabel().isEmpty()) { mPaint.setStrokeWidth(0); mPaint.setTextSize((float) (scaledTextSize * 1.2)); mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD)); Rect bounds = new Rect(); mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds); mPaint.setStyle(Paint.Style.STROKE); - float px = endX; float py = graphTop + 20; - canvas.drawText(value.getLabel(), px, py, mPaint); + canvas.drawText(value.getLabel(), endX, py, mPaint); mPaint.setStrokeWidth(5); - canvas.drawRect(px - 3, bounds.top + py - 3, xpluslength + 3, bounds.bottom + py + 3, mPaint); + canvas.drawRect(endX - 3, bounds.top + py - 3, xPlusLength + 3, bounds.bottom + py + 3, mPaint); } - } else if (value.getShape() == Shape.OPENAPSOFFLINE && value.getDuration() != 0) { + } else if (value.getShape() == Shape.OPENAPS_OFFLINE && value.getDuration() != 0) { mPaint.setStrokeWidth(0); - if (value.getLabel() != null) { - //mPaint.setStrokeWidth(0); - //mPaint.setTextSize(scaledTextSize); - //mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD)); - Rect bounds = new Rect(); - //mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds); + if (!value.getLabel().isEmpty()) { mPaint.setStyle(Paint.Style.FILL_AND_STROKE); - float px = endX; - float py = graphTop + 50; - //canvas.drawText(value.getLabel(), px, py, mPaint); mPaint.setStrokeWidth(5); - canvas.drawRect(px - 3, graphTop, xpluslength + 3, graphTop + graphHeight, mPaint); + canvas.drawRect(endX - 3, graphTop, xPlusLength + 3, graphTop + graphHeight, mPaint); } - } else if (value.getShape() == Shape.GENERALWITHDURATION) { + } else if (value.getShape() == Shape.GENERAL_WITH_DURATION) { mPaint.setStrokeWidth(0); - if (value.getLabel() != null) { + if (!value.getLabel().isEmpty()) { mPaint.setStrokeWidth(0); mPaint.setTextSize((float) (scaledTextSize * 1.5)); mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD)); Rect bounds = new Rect(); mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds); mPaint.setStyle(Paint.Style.STROKE); - float px = endX; float py = graphTop + 80; - canvas.drawText(value.getLabel(), px, py, mPaint); + canvas.drawText(value.getLabel(), endX, py, mPaint); mPaint.setStrokeWidth(5); - canvas.drawRect(px - 3, bounds.top + py - 3, xpluslength + 3, bounds.bottom + py + 3, mPaint); + canvas.drawRect(endX - 3, bounds.top + py - 3, xPlusLength + 3, bounds.bottom + py + 3, mPaint); } } // set values above point } - i++; } } @@ -407,27 +350,25 @@ public class PointsWithLabelGraphSeries e } void drawLabel45Right(float endX, float endY, E value, Canvas canvas, Float scaledPxSize, Float scaledTextSize) { - float px = endX; float py = endY - scaledPxSize; canvas.save(); - canvas.rotate(-45, px, py); + canvas.rotate(-45, endX, py); mPaint.setTextSize((float) (scaledTextSize * 0.8)); mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL)); mPaint.setFakeBoldText(true); - canvas.drawText(value.getLabel(), px + scaledPxSize, py, mPaint); + canvas.drawText(value.getLabel(), endX + scaledPxSize, py, mPaint); canvas.restore(); } void drawLabel45Left(float endX, float endY, E value, Canvas canvas, Float scaledPxSize, Float scaledTextSize) { - float px = endX; float py = endY + scaledPxSize; canvas.save(); - canvas.rotate(-45, px, py); + canvas.rotate(-45, endX, py); mPaint.setTextSize((float) (scaledTextSize * 0.8)); mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL)); mPaint.setFakeBoldText(true); mPaint.setTextAlign(Paint.Align.RIGHT); - canvas.drawText(value.getLabel(), px - scaledPxSize, py, mPaint); + canvas.drawText(value.getLabel(), endX - scaledPxSize, py, mPaint); mPaint.setTextAlign(Paint.Align.LEFT); canvas.restore(); } diff --git a/core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/data/AutosensData.kt b/core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/data/AutosensData.kt index 5da825a6d5..c64871e52f 100644 --- a/core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/data/AutosensData.kt +++ b/core/src/main/java/info/nightscout/androidaps/plugins/iob/iobCobCalculator/data/AutosensData.kt @@ -159,9 +159,9 @@ class AutosensData(injector: HasAndroidInjector) : DataPointWithLabelInterface { override fun getY(): Double = scale!!.transform(cob) override fun setY(y: Double) {} - override val label: String? = null + override val label: String = "" override val duration = 0L - override val shape = PointsWithLabelGraphSeries.Shape.COBFAILOVER + override val shape = PointsWithLabelGraphSeries.Shape.COB_FAIL_OVER override val size = 0.5f override fun color(context: Context?): Int { return rh.gac(context,R.attr.cobColor)