UI: EPS scaled
This commit is contained in:
parent
52851bf315
commit
29d1d91de6
12 changed files with 72 additions and 115 deletions
|
@ -342,6 +342,7 @@ class HistoryBrowseActivity : NoSplashAppCompatActivity() {
|
||||||
graphData.addBgReadings(menuChartSettings[0][OverviewMenus.CharType.PRE.ordinal], context)
|
graphData.addBgReadings(menuChartSettings[0][OverviewMenus.CharType.PRE.ordinal], context)
|
||||||
if (buildHelper.isDev()) graphData.addBucketedData()
|
if (buildHelper.isDev()) graphData.addBucketedData()
|
||||||
graphData.addTreatments(context)
|
graphData.addTreatments(context)
|
||||||
|
graphData.addEps(context, 0.95)
|
||||||
if (menuChartSettings[0][OverviewMenus.CharType.TREAT.ordinal])
|
if (menuChartSettings[0][OverviewMenus.CharType.TREAT.ordinal])
|
||||||
graphData.addTherapyEvents()
|
graphData.addTherapyEvents()
|
||||||
if (menuChartSettings[0][OverviewMenus.CharType.ACT.ordinal])
|
if (menuChartSettings[0][OverviewMenus.CharType.ACT.ordinal])
|
||||||
|
|
|
@ -77,6 +77,8 @@ class OverviewData @Inject constructor(
|
||||||
ratioSeries = LineGraphSeries()
|
ratioSeries = LineGraphSeries()
|
||||||
dsMaxSeries = LineGraphSeries()
|
dsMaxSeries = LineGraphSeries()
|
||||||
dsMinSeries = LineGraphSeries()
|
dsMinSeries = LineGraphSeries()
|
||||||
|
treatmentsSeries = PointsWithLabelGraphSeries()
|
||||||
|
epsSeries = PointsWithLabelGraphSeries()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun initRange() {
|
fun initRange() {
|
||||||
|
@ -261,6 +263,9 @@ class OverviewData @Inject constructor(
|
||||||
var activitySeries: FixedLineGraphSeries<ScaledDataPoint> = FixedLineGraphSeries()
|
var activitySeries: FixedLineGraphSeries<ScaledDataPoint> = FixedLineGraphSeries()
|
||||||
var activityPredictionSeries: FixedLineGraphSeries<ScaledDataPoint> = FixedLineGraphSeries()
|
var activityPredictionSeries: FixedLineGraphSeries<ScaledDataPoint> = FixedLineGraphSeries()
|
||||||
|
|
||||||
|
var maxEpsValue = 0.0
|
||||||
|
val epsScale = Scale()
|
||||||
|
var epsSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface> = PointsWithLabelGraphSeries()
|
||||||
var maxTreatmentsValue = 0.0
|
var maxTreatmentsValue = 0.0
|
||||||
var treatmentsSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface> = PointsWithLabelGraphSeries()
|
var treatmentsSeries: PointsWithLabelGraphSeries<DataPointWithLabelInterface> = PointsWithLabelGraphSeries()
|
||||||
var maxTherapyEventValue = 0.0
|
var maxTherapyEventValue = 0.0
|
||||||
|
|
|
@ -973,6 +973,7 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
|
||||||
graphData.addBgReadings(menuChartSettings[0][OverviewMenus.CharType.PRE.ordinal], context)
|
graphData.addBgReadings(menuChartSettings[0][OverviewMenus.CharType.PRE.ordinal], context)
|
||||||
if (buildHelper.isDev()) graphData.addBucketedData()
|
if (buildHelper.isDev()) graphData.addBucketedData()
|
||||||
graphData.addTreatments(context)
|
graphData.addTreatments(context)
|
||||||
|
graphData.addEps(context, 0.95)
|
||||||
if (menuChartSettings[0][OverviewMenus.CharType.TREAT.ordinal])
|
if (menuChartSettings[0][OverviewMenus.CharType.TREAT.ordinal])
|
||||||
graphData.addTherapyEvents()
|
graphData.addTherapyEvents()
|
||||||
if (menuChartSettings[0][OverviewMenus.CharType.ACT.ordinal])
|
if (menuChartSettings[0][OverviewMenus.CharType.ACT.ordinal])
|
||||||
|
|
|
@ -89,11 +89,18 @@ class GraphData(
|
||||||
maxY = maxOf(maxY, overviewData.maxTreatmentsValue)
|
maxY = maxOf(maxY, overviewData.maxTreatmentsValue)
|
||||||
addSeries(overviewData.treatmentsSeries)
|
addSeries(overviewData.treatmentsSeries)
|
||||||
overviewData.treatmentsSeries.setOnDataPointTapListener { _, dataPoint ->
|
overviewData.treatmentsSeries.setOnDataPointTapListener { _, dataPoint ->
|
||||||
if (dataPoint is EffectiveProfileSwitchDataPoint) ToastUtils.showToastInUiThread(context, dataPoint.data.originalCustomizedName)
|
|
||||||
if (dataPoint is BolusDataPoint) ToastUtils.showToastInUiThread(context, dataPoint.label)
|
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() {
|
fun addTherapyEvents() {
|
||||||
maxY = maxOf(maxY, overviewData.maxTherapyEventValue)
|
maxY = maxOf(maxY, overviewData.maxTherapyEventValue)
|
||||||
addSeries(overviewData.therapyEventSeries)
|
addSeries(overviewData.therapyEventSeries)
|
||||||
|
|
|
@ -8,16 +8,12 @@ import info.nightscout.androidaps.interfaces.ResourceHelper
|
||||||
class EffectiveProfileSwitchDataPoint(
|
class EffectiveProfileSwitchDataPoint(
|
||||||
val data: EffectiveProfileSwitch,
|
val data: EffectiveProfileSwitch,
|
||||||
private val rh: ResourceHelper,
|
private val rh: ResourceHelper,
|
||||||
private var yValue: Double
|
private val scale: Scale
|
||||||
) : DataPointWithLabelInterface {
|
) : DataPointWithLabelInterface {
|
||||||
|
|
||||||
override fun getX(): Double = data.timestamp.toDouble()
|
override fun getX(): Double = data.timestamp.toDouble()
|
||||||
override fun getY(): Double = yValue
|
override fun getY(): Double = scale.transform(data.originalPercentage.toDouble())
|
||||||
|
override fun setY(y: Double) {}
|
||||||
override fun setY(y: Double) {
|
|
||||||
yValue = y
|
|
||||||
}
|
|
||||||
|
|
||||||
override val label get() = if (data.originalPercentage != 100) data.originalPercentage.toString() + "%" else ""
|
override val label get() = if (data.originalPercentage != 100) data.originalPercentage.toString() + "%" else ""
|
||||||
override val duration = 0L
|
override val duration = 0L
|
||||||
override val shape = PointsWithLabelGraphSeries.Shape.PROFILE
|
override val shape = PointsWithLabelGraphSeries.Shape.PROFILE
|
||||||
|
|
|
@ -20,7 +20,7 @@ class InMemoryGlucoseValueDataPoint(
|
||||||
override fun getX(): Double = data.timestamp.toDouble()
|
override fun getX(): Double = data.timestamp.toDouble()
|
||||||
override fun getY(): Double = valueToUnits(profileFunction.getUnits())
|
override fun getY(): Double = valueToUnits(profileFunction.getUnits())
|
||||||
override fun setY(y: Double) {}
|
override fun setY(y: Double) {}
|
||||||
override val label: String? = null
|
override val label: String = ""
|
||||||
override val duration = 0L
|
override val duration = 0L
|
||||||
override val shape = PointsWithLabelGraphSeries.Shape.BUCKETED_BG
|
override val shape = PointsWithLabelGraphSeries.Shape.BUCKETED_BG
|
||||||
override val size = 0.3f
|
override val size = 0.3f
|
||||||
|
|
|
@ -43,7 +43,7 @@ class TherapyEventDataPoint(
|
||||||
yValue = y
|
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 duration get() = data.duration
|
||||||
override val shape
|
override val shape
|
||||||
get() =
|
get() =
|
||||||
|
@ -51,9 +51,9 @@ class TherapyEventDataPoint(
|
||||||
data.type == TherapyEvent.Type.NS_MBG -> PointsWithLabelGraphSeries.Shape.MBG
|
data.type == TherapyEvent.Type.NS_MBG -> PointsWithLabelGraphSeries.Shape.MBG
|
||||||
data.type == TherapyEvent.Type.FINGER_STICK_BG_VALUE -> PointsWithLabelGraphSeries.Shape.BGCHECK
|
data.type == TherapyEvent.Type.FINGER_STICK_BG_VALUE -> PointsWithLabelGraphSeries.Shape.BGCHECK
|
||||||
data.type == TherapyEvent.Type.ANNOUNCEMENT -> PointsWithLabelGraphSeries.Shape.ANNOUNCEMENT
|
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
|
data.type == TherapyEvent.Type.EXERCISE -> PointsWithLabelGraphSeries.Shape.EXERCISE
|
||||||
duration > 0 -> PointsWithLabelGraphSeries.Shape.GENERALWITHDURATION
|
duration > 0 -> PointsWithLabelGraphSeries.Shape.GENERAL_WITH_DURATION
|
||||||
else -> PointsWithLabelGraphSeries.Shape.GENERAL
|
else -> PointsWithLabelGraphSeries.Shape.GENERAL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,8 +53,10 @@ class PrepareTreatmentsDataWorker(
|
||||||
|
|
||||||
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_TREATMENTS_DATA, 0, null))
|
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_TREATMENTS_DATA, 0, null))
|
||||||
data.overviewData.maxTreatmentsValue = 0.0
|
data.overviewData.maxTreatmentsValue = 0.0
|
||||||
|
data.overviewData.maxEpsValue = 0.0
|
||||||
val filteredTreatments: MutableList<DataPointWithLabelInterface> = ArrayList()
|
val filteredTreatments: MutableList<DataPointWithLabelInterface> = ArrayList()
|
||||||
val filteredTherapyEvents: MutableList<DataPointWithLabelInterface> = ArrayList()
|
val filteredTherapyEvents: MutableList<DataPointWithLabelInterface> = ArrayList()
|
||||||
|
val filteredEps: MutableList<DataPointWithLabelInterface> = ArrayList()
|
||||||
|
|
||||||
repository.getBolusesDataFromTimeToTime(data.overviewData.fromTime, data.overviewData.endTime, true).blockingGet()
|
repository.getBolusesDataFromTimeToTime(data.overviewData.fromTime, data.overviewData.endTime, true).blockingGet()
|
||||||
.map { BolusDataPoint(it, rh, activePlugin, defaultValueHelper) }
|
.map { BolusDataPoint(it, rh, activePlugin, defaultValueHelper) }
|
||||||
|
@ -72,8 +74,11 @@ class PrepareTreatmentsDataWorker(
|
||||||
|
|
||||||
// ProfileSwitch
|
// ProfileSwitch
|
||||||
repository.getEffectiveProfileSwitchDataFromTimeToTime(data.overviewData.fromTime, data.overviewData.endTime, true).blockingGet()
|
repository.getEffectiveProfileSwitchDataFromTimeToTime(data.overviewData.fromTime, data.overviewData.endTime, true).blockingGet()
|
||||||
.map { EffectiveProfileSwitchDataPoint(it, rh, data.overviewData.maxBgValue) }
|
.map { EffectiveProfileSwitchDataPoint(it, rh, data.overviewData.epsScale) }
|
||||||
.forEach(filteredTreatments::add)
|
.forEach {
|
||||||
|
data.overviewData.maxEpsValue = maxOf(data.overviewData.maxEpsValue, it.data.originalPercentage.toDouble())
|
||||||
|
filteredEps.add(it)
|
||||||
|
}
|
||||||
|
|
||||||
// OfflineEvent
|
// OfflineEvent
|
||||||
repository.getOfflineEventDataFromTimeToTime(data.overviewData.fromTime, data.overviewData.endTime, true).blockingGet()
|
repository.getOfflineEventDataFromTimeToTime(data.overviewData.fromTime, data.overviewData.endTime, true).blockingGet()
|
||||||
|
@ -119,6 +124,7 @@ class PrepareTreatmentsDataWorker(
|
||||||
|
|
||||||
data.overviewData.treatmentsSeries = PointsWithLabelGraphSeries(filteredTreatments.toTypedArray())
|
data.overviewData.treatmentsSeries = PointsWithLabelGraphSeries(filteredTreatments.toTypedArray())
|
||||||
data.overviewData.therapyEventSeries = PointsWithLabelGraphSeries(filteredTherapyEvents.toTypedArray())
|
data.overviewData.therapyEventSeries = PointsWithLabelGraphSeries(filteredTherapyEvents.toTypedArray())
|
||||||
|
data.overviewData.epsSeries = PointsWithLabelGraphSeries(filteredEps.toTypedArray())
|
||||||
|
|
||||||
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_TREATMENTS_DATA, 100, null))
|
rxBus.send(EventIobCalculationProgress(CalculationWorkflow.ProgressData.PREPARE_TREATMENTS_DATA, 100, null))
|
||||||
return Result.success()
|
return Result.success()
|
||||||
|
|
|
@ -111,7 +111,7 @@ class IobTotal(val time: Long) : DataPointWithLabelInterface {
|
||||||
override fun setY(y: Double) {}
|
override fun setY(y: Double) {}
|
||||||
override val label = ""
|
override val label = ""
|
||||||
override val duration = 0L
|
override val duration = 0L
|
||||||
override val shape = PointsWithLabelGraphSeries.Shape.IOBPREDICTION
|
override val shape = PointsWithLabelGraphSeries.Shape.IOB_PREDICTION
|
||||||
override val size = 0.5f
|
override val size = 0.5f
|
||||||
|
|
||||||
override fun color(context: Context?): Int {
|
override fun color(context: Context?): Int {
|
||||||
|
|
|
@ -9,9 +9,9 @@ interface DataPointWithLabelInterface : DataPointInterface {
|
||||||
override fun getY(): Double
|
override fun getY(): Double
|
||||||
fun setY(y: Double)
|
fun setY(y: Double)
|
||||||
|
|
||||||
val label: String?
|
val label: String
|
||||||
val duration: Long
|
val duration: Long
|
||||||
val shape: PointsWithLabelGraphSeries.Shape?
|
val shape: PointsWithLabelGraphSeries.Shape
|
||||||
val size: Float
|
val size: Float
|
||||||
fun color(context: Context?): Int
|
fun color(context: Context?): Int
|
||||||
}
|
}
|
|
@ -1,29 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.general.overview.graphExtensions;
|
package info.nightscout.androidaps.plugins.general.overview.graphExtensions;
|
||||||
|
|
||||||
/**
|
|
||||||
* GraphView
|
|
||||||
* Copyright (C) 2014 Jonas Gehring
|
|
||||||
* <p>
|
|
||||||
* 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.
|
|
||||||
* <p>
|
|
||||||
* 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.
|
|
||||||
* <p>
|
|
||||||
* 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 <g.jjoe64@gmail.com>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Added by mike
|
|
||||||
*/
|
|
||||||
|
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
|
@ -72,12 +48,12 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
||||||
MBG,
|
MBG,
|
||||||
BGCHECK,
|
BGCHECK,
|
||||||
ANNOUNCEMENT,
|
ANNOUNCEMENT,
|
||||||
OPENAPSOFFLINE,
|
OPENAPS_OFFLINE,
|
||||||
EXERCISE,
|
EXERCISE,
|
||||||
GENERAL,
|
GENERAL,
|
||||||
GENERALWITHDURATION,
|
GENERAL_WITH_DURATION,
|
||||||
COBFAILOVER,
|
COB_FAIL_OVER,
|
||||||
IOBPREDICTION,
|
IOB_PREDICTION,
|
||||||
BUCKETED_BG
|
BUCKETED_BG
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +72,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
||||||
/**
|
/**
|
||||||
* creates the series with data
|
* creates the series with data
|
||||||
*
|
*
|
||||||
* @param data datapoints
|
* @param data dataPoints
|
||||||
*/
|
*/
|
||||||
public PointsWithLabelGraphSeries(E[] data) {
|
public PointsWithLabelGraphSeries(E[] data) {
|
||||||
super(data);
|
super(data);
|
||||||
|
@ -104,7 +80,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* inits the internal objects
|
* init the internal objects
|
||||||
* set the defaults
|
* set the defaults
|
||||||
*/
|
*/
|
||||||
protected void init() {
|
protected void init() {
|
||||||
|
@ -155,7 +131,6 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
||||||
|
|
||||||
float scaleX = (float) (graphWidth / diffX);
|
float scaleX = (float) (graphWidth / diffX);
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
while (values.hasNext()) {
|
while (values.hasNext()) {
|
||||||
E value = values.next();
|
E value = values.next();
|
||||||
|
|
||||||
|
@ -195,18 +170,18 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
||||||
float endY = (float) (graphTop - y) + graphHeight;
|
float endY = (float) (graphTop - y) + graphHeight;
|
||||||
registerDataPoint(endX, endY, value);
|
registerDataPoint(endX, endY, value);
|
||||||
|
|
||||||
float xpluslength = 0;
|
float xPlusLength = 0;
|
||||||
if (duration > 0) {
|
if (duration > 0) {
|
||||||
xpluslength = Math.min(endWithDuration, graphLeft + graphWidth);
|
xPlusLength = Math.min(endWithDuration, graphLeft + graphWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw data point
|
// draw data point
|
||||||
if (!overdraw) {
|
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.setStyle(Paint.Style.FILL);
|
||||||
mPaint.setStrokeWidth(0);
|
mPaint.setStrokeWidth(0);
|
||||||
canvas.drawCircle(endX, endY, value.getSize() * scaledPxSize, mPaint);
|
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.setColor(value.color(graphView.getContext()));
|
||||||
mPaint.setStyle(Paint.Style.FILL);
|
mPaint.setStyle(Paint.Style.FILL);
|
||||||
mPaint.setStrokeWidth(0);
|
mPaint.setStrokeWidth(0);
|
||||||
|
@ -236,9 +211,8 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
||||||
points[2] = new Point((int) (endX - scaledPxSize), (int) (endY + scaledPxSize * 0.67));
|
points[2] = new Point((int) (endX - scaledPxSize), (int) (endY + scaledPxSize * 0.67));
|
||||||
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||||
drawArrows(points, canvas, mPaint);
|
drawArrows(points, canvas, mPaint);
|
||||||
if (value.getLabel() != null) {
|
if (!value.getLabel().isEmpty())
|
||||||
drawLabel45Right(endX, endY, value, canvas, scaledPxSize, scaledTextSize);
|
drawLabel45Right(endX, endY, value, canvas, scaledPxSize, scaledTextSize);
|
||||||
}
|
|
||||||
} else if (value.getShape() == Shape.CARBS) {
|
} else if (value.getShape() == Shape.CARBS) {
|
||||||
mPaint.setStrokeWidth(0);
|
mPaint.setStrokeWidth(0);
|
||||||
Point[] points = new Point[3];
|
Point[] points = new Point[3];
|
||||||
|
@ -247,9 +221,8 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
||||||
points[2] = new Point((int) (endX - scaledPxSize), (int) (endY + scaledPxSize * 0.67));
|
points[2] = new Point((int) (endX - scaledPxSize), (int) (endY + scaledPxSize * 0.67));
|
||||||
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||||
drawArrows(points, canvas, mPaint);
|
drawArrows(points, canvas, mPaint);
|
||||||
if (value.getLabel() != null) {
|
if (!value.getLabel().isEmpty())
|
||||||
drawLabel45Left(endX, endY, value, canvas, scaledPxSize, scaledTextSize);
|
drawLabel45Left(endX, endY, value, canvas, scaledPxSize, scaledTextSize);
|
||||||
}
|
|
||||||
} else if (value.getShape() == Shape.SMB) {
|
} else if (value.getShape() == Shape.SMB) {
|
||||||
mPaint.setStrokeWidth(2);
|
mPaint.setStrokeWidth(2);
|
||||||
Point[] points = new Point[3];
|
Point[] points = new Point[3];
|
||||||
|
@ -261,8 +234,8 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
||||||
drawArrows(points, canvas, mPaint);
|
drawArrows(points, canvas, mPaint);
|
||||||
} else if (value.getShape() == Shape.EXTENDEDBOLUS) {
|
} else if (value.getShape() == Shape.EXTENDEDBOLUS) {
|
||||||
mPaint.setStrokeWidth(0);
|
mPaint.setStrokeWidth(0);
|
||||||
if (value.getLabel() != null) {
|
if (!value.getLabel().isEmpty()) {
|
||||||
Rect bounds = new Rect((int) endX, (int) endY + 3, (int) (xpluslength), (int) endY + 8);
|
Rect bounds = new Rect((int) endX, (int) endY + 3, (int) (xPlusLength), (int) endY + 8);
|
||||||
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||||
canvas.drawRect(bounds, mPaint);
|
canvas.drawRect(bounds, mPaint);
|
||||||
mPaint.setTextSize(scaledTextSize);
|
mPaint.setTextSize(scaledTextSize);
|
||||||
|
@ -272,10 +245,13 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
||||||
}
|
}
|
||||||
} else if (value.getShape() == Shape.PROFILE) {
|
} else if (value.getShape() == Shape.PROFILE) {
|
||||||
Drawable drawable = ContextCompat.getDrawable(graphView.getContext(), R.drawable.ic_ribbon_profile);
|
Drawable drawable = ContextCompat.getDrawable(graphView.getContext(), R.drawable.ic_ribbon_profile);
|
||||||
|
assert drawable != null;
|
||||||
drawable.setColorFilter(Color.WHITE, PorterDuff.Mode.MULTIPLY);
|
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),
|
(int) (endX + drawable.getIntrinsicWidth() / 2),
|
||||||
drawable.getIntrinsicHeight());
|
(int) (endY + drawable.getIntrinsicHeight() / 2));
|
||||||
drawable.draw(canvas);
|
drawable.draw(canvas);
|
||||||
|
|
||||||
mPaint.setTextSize(scaledTextSize * 0.8f);
|
mPaint.setTextSize(scaledTextSize * 0.8f);
|
||||||
|
@ -284,106 +260,73 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
||||||
Rect bounds = new Rect();
|
Rect bounds = new Rect();
|
||||||
mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds);
|
mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds);
|
||||||
float px = endX - bounds.width() / 2.0f;
|
float px = endX - bounds.width() / 2.0f;
|
||||||
float py = (float) (drawable.getIntrinsicHeight() + 30);
|
float py = endY + drawable.getIntrinsicHeight();
|
||||||
mPaint.setStyle(Paint.Style.FILL);
|
mPaint.setStyle(Paint.Style.FILL);
|
||||||
canvas.drawText(value.getLabel(), px, py, mPaint);
|
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) {
|
} else if (value.getShape() == Shape.MBG) {
|
||||||
mPaint.setStyle(Paint.Style.STROKE);
|
mPaint.setStyle(Paint.Style.STROKE);
|
||||||
mPaint.setStrokeWidth(5);
|
mPaint.setStrokeWidth(5);
|
||||||
float w = mPaint.getStrokeWidth();
|
|
||||||
canvas.drawCircle(endX, endY, scaledPxSize, mPaint);
|
canvas.drawCircle(endX, endY, scaledPxSize, mPaint);
|
||||||
} else if (value.getShape() == Shape.BGCHECK) {
|
} else if (value.getShape() == Shape.BGCHECK) {
|
||||||
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||||
mPaint.setStrokeWidth(0);
|
mPaint.setStrokeWidth(0);
|
||||||
canvas.drawCircle(endX, endY, scaledPxSize, mPaint);
|
canvas.drawCircle(endX, endY, scaledPxSize, mPaint);
|
||||||
if (value.getLabel() != null) {
|
if (!value.getLabel().isEmpty()) {
|
||||||
drawLabel45Right(endX, endY, value, canvas, scaledPxSize, scaledTextSize);
|
drawLabel45Right(endX, endY, value, canvas, scaledPxSize, scaledTextSize);
|
||||||
}
|
}
|
||||||
} else if (value.getShape() == Shape.ANNOUNCEMENT) {
|
} else if (value.getShape() == Shape.ANNOUNCEMENT) {
|
||||||
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||||
mPaint.setStrokeWidth(0);
|
mPaint.setStrokeWidth(0);
|
||||||
canvas.drawCircle(endX, endY, scaledPxSize, mPaint);
|
canvas.drawCircle(endX, endY, scaledPxSize, mPaint);
|
||||||
if (value.getLabel() != null) {
|
if (!value.getLabel().isEmpty()) {
|
||||||
drawLabel45Right(endX, endY, value, canvas, scaledPxSize, scaledTextSize);
|
drawLabel45Right(endX, endY, value, canvas, scaledPxSize, scaledTextSize);
|
||||||
}
|
}
|
||||||
} else if (value.getShape() == Shape.GENERAL) {
|
} else if (value.getShape() == Shape.GENERAL) {
|
||||||
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||||
mPaint.setStrokeWidth(0);
|
mPaint.setStrokeWidth(0);
|
||||||
canvas.drawCircle(endX, endY, scaledPxSize, mPaint);
|
canvas.drawCircle(endX, endY, scaledPxSize, mPaint);
|
||||||
if (value.getLabel() != null) {
|
if (!value.getLabel().isEmpty()) {
|
||||||
drawLabel45Right(endX, endY, value, canvas, scaledPxSize, scaledTextSize);
|
drawLabel45Right(endX, endY, value, canvas, scaledPxSize, scaledTextSize);
|
||||||
}
|
}
|
||||||
} else if (value.getShape() == Shape.EXERCISE) {
|
} else if (value.getShape() == Shape.EXERCISE) {
|
||||||
mPaint.setStrokeWidth(0);
|
mPaint.setStrokeWidth(0);
|
||||||
if (value.getLabel() != null) {
|
if (!value.getLabel().isEmpty()) {
|
||||||
mPaint.setStrokeWidth(0);
|
mPaint.setStrokeWidth(0);
|
||||||
mPaint.setTextSize((float) (scaledTextSize * 1.2));
|
mPaint.setTextSize((float) (scaledTextSize * 1.2));
|
||||||
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
|
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
|
||||||
Rect bounds = new Rect();
|
Rect bounds = new Rect();
|
||||||
mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds);
|
mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds);
|
||||||
mPaint.setStyle(Paint.Style.STROKE);
|
mPaint.setStyle(Paint.Style.STROKE);
|
||||||
float px = endX;
|
|
||||||
float py = graphTop + 20;
|
float py = graphTop + 20;
|
||||||
canvas.drawText(value.getLabel(), px, py, mPaint);
|
canvas.drawText(value.getLabel(), endX, py, mPaint);
|
||||||
mPaint.setStrokeWidth(5);
|
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);
|
mPaint.setStrokeWidth(0);
|
||||||
if (value.getLabel() != null) {
|
if (!value.getLabel().isEmpty()) {
|
||||||
//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);
|
|
||||||
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
|
||||||
float px = endX;
|
|
||||||
float py = graphTop + 50;
|
|
||||||
//canvas.drawText(value.getLabel(), px, py, mPaint);
|
|
||||||
mPaint.setStrokeWidth(5);
|
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);
|
mPaint.setStrokeWidth(0);
|
||||||
if (value.getLabel() != null) {
|
if (!value.getLabel().isEmpty()) {
|
||||||
mPaint.setStrokeWidth(0);
|
mPaint.setStrokeWidth(0);
|
||||||
mPaint.setTextSize((float) (scaledTextSize * 1.5));
|
mPaint.setTextSize((float) (scaledTextSize * 1.5));
|
||||||
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
|
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
|
||||||
Rect bounds = new Rect();
|
Rect bounds = new Rect();
|
||||||
mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds);
|
mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds);
|
||||||
mPaint.setStyle(Paint.Style.STROKE);
|
mPaint.setStyle(Paint.Style.STROKE);
|
||||||
float px = endX;
|
|
||||||
float py = graphTop + 80;
|
float py = graphTop + 80;
|
||||||
canvas.drawText(value.getLabel(), px, py, mPaint);
|
canvas.drawText(value.getLabel(), endX, py, mPaint);
|
||||||
mPaint.setStrokeWidth(5);
|
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
|
// set values above point
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -407,27 +350,25 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawLabel45Right(float endX, float endY, E value, Canvas canvas, Float scaledPxSize, Float scaledTextSize) {
|
void drawLabel45Right(float endX, float endY, E value, Canvas canvas, Float scaledPxSize, Float scaledTextSize) {
|
||||||
float px = endX;
|
|
||||||
float py = endY - scaledPxSize;
|
float py = endY - scaledPxSize;
|
||||||
canvas.save();
|
canvas.save();
|
||||||
canvas.rotate(-45, px, py);
|
canvas.rotate(-45, endX, py);
|
||||||
mPaint.setTextSize((float) (scaledTextSize * 0.8));
|
mPaint.setTextSize((float) (scaledTextSize * 0.8));
|
||||||
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
|
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
|
||||||
mPaint.setFakeBoldText(true);
|
mPaint.setFakeBoldText(true);
|
||||||
canvas.drawText(value.getLabel(), px + scaledPxSize, py, mPaint);
|
canvas.drawText(value.getLabel(), endX + scaledPxSize, py, mPaint);
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawLabel45Left(float endX, float endY, E value, Canvas canvas, Float scaledPxSize, Float scaledTextSize) {
|
void drawLabel45Left(float endX, float endY, E value, Canvas canvas, Float scaledPxSize, Float scaledTextSize) {
|
||||||
float px = endX;
|
|
||||||
float py = endY + scaledPxSize;
|
float py = endY + scaledPxSize;
|
||||||
canvas.save();
|
canvas.save();
|
||||||
canvas.rotate(-45, px, py);
|
canvas.rotate(-45, endX, py);
|
||||||
mPaint.setTextSize((float) (scaledTextSize * 0.8));
|
mPaint.setTextSize((float) (scaledTextSize * 0.8));
|
||||||
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
|
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
|
||||||
mPaint.setFakeBoldText(true);
|
mPaint.setFakeBoldText(true);
|
||||||
mPaint.setTextAlign(Paint.Align.RIGHT);
|
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);
|
mPaint.setTextAlign(Paint.Align.LEFT);
|
||||||
canvas.restore();
|
canvas.restore();
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,9 +159,9 @@ class AutosensData(injector: HasAndroidInjector) : DataPointWithLabelInterface {
|
||||||
override fun getY(): Double = scale!!.transform(cob)
|
override fun getY(): Double = scale!!.transform(cob)
|
||||||
|
|
||||||
override fun setY(y: Double) {}
|
override fun setY(y: Double) {}
|
||||||
override val label: String? = null
|
override val label: String = ""
|
||||||
override val duration = 0L
|
override val duration = 0L
|
||||||
override val shape = PointsWithLabelGraphSeries.Shape.COBFAILOVER
|
override val shape = PointsWithLabelGraphSeries.Shape.COB_FAIL_OVER
|
||||||
override val size = 0.5f
|
override val size = 0.5f
|
||||||
override fun color(context: Context?): Int {
|
override fun color(context: Context?): Int {
|
||||||
return rh.gac(context,R.attr.cobColor)
|
return rh.gac(context,R.attr.cobColor)
|
||||||
|
|
Loading…
Reference in a new issue