colored predictions

This commit is contained in:
Milos Kozak 2017-08-21 15:36:52 +02:00
parent f5143b2ec4
commit ebfc4e3075
9 changed files with 65 additions and 18 deletions

View file

@ -17,7 +17,6 @@ import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSgv;
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin; import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface; import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries; import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
@ -43,7 +42,10 @@ public class BgReading implements DataPointWithLabelInterface {
@DatabaseField @DatabaseField
public String _id = null; // NS _id public String _id = null; // NS _id
public boolean isPrediction = false; // true when drawing predictions as bg points public boolean isCOBPrediction = false; // true when drawing predictions as bg points (COB)
public boolean isaCOBPrediction = false; // true when drawing predictions as bg points (aCOB)
public boolean isIOBPrediction = false; // true when drawing predictions as bg points (IOB)
public boolean isUAMPrediction = false; // true when drawing predictions as bg points (UAM)
public BgReading() { public BgReading() {
} }
@ -181,7 +183,10 @@ public class BgReading implements DataPointWithLabelInterface {
@Override @Override
public PointsWithLabelGraphSeries.Shape getShape() { public PointsWithLabelGraphSeries.Shape getShape() {
return PointsWithLabelGraphSeries.Shape.POINT; if (isPrediction())
return PointsWithLabelGraphSeries.Shape.PREDICTION;
else
return PointsWithLabelGraphSeries.Shape.BG;
} }
@Override @Override
@ -202,7 +207,7 @@ public class BgReading implements DataPointWithLabelInterface {
highLine = Profile.fromMgdlToUnits(OverviewPlugin.bgTargetHigh, units); highLine = Profile.fromMgdlToUnits(OverviewPlugin.bgTargetHigh, units);
} }
int color = MainApp.sResources.getColor(R.color.inrange); int color = MainApp.sResources.getColor(R.color.inrange);
if (isPrediction) if (isPrediction())
color = MainApp.sResources.getColor(R.color.prediction); color = MainApp.sResources.getColor(R.color.prediction);
else if (valueToUnits(units) < lowLine) else if (valueToUnits(units) < lowLine)
color = MainApp.sResources.getColor(R.color.low); color = MainApp.sResources.getColor(R.color.low);
@ -211,4 +216,21 @@ public class BgReading implements DataPointWithLabelInterface {
return color; return color;
} }
@Override
public int getSecondColor() {
if (isIOBPrediction)
return MainApp.sResources.getColor(R.color.iob);
if (isCOBPrediction)
return MainApp.sResources.getColor(R.color.cob);
if (isaCOBPrediction)
return 0x80FFFFFF & MainApp.sResources.getColor(R.color.cob);
if (isUAMPrediction)
return MainApp.sResources.getColor(R.color.uam);
return R.color.mdtp_white;
}
private boolean isPrediction() {
return isaCOBPrediction || isCOBPrediction || isIOBPrediction || isUAMPrediction;
}
} }

View file

@ -242,4 +242,9 @@ public class CareportalEvent implements DataPointWithLabelInterface {
return Color.GRAY; return Color.GRAY;
return Color.GRAY; return Color.GRAY;
} }
@Override
public int getSecondColor() {
return 0;
}
} }

View file

@ -280,4 +280,9 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
public int getColor() { public int getColor() {
return Color.CYAN; return Color.CYAN;
} }
@Override
public int getSecondColor() {
return 0;
}
} }

View file

@ -202,6 +202,11 @@ public class ProfileSwitch implements Interval, DataPointWithLabelInterface {
return Color.CYAN; return Color.CYAN;
} }
@Override
public int getSecondColor() {
return 0;
}
public String toString() { public String toString() {
return "ProfileSwitch{" + return "ProfileSwitch{" +
"date=" + date + "date=" + date +

View file

@ -173,6 +173,11 @@ public class Treatment implements DataPointWithLabelInterface {
return Color.CYAN; return Color.CYAN;
} }
@Override
public int getSecondColor() {
return 0;
}
@Override @Override
public void setY(double y) { public void setY(double y) {
yValue = y; yValue = y;

View file

@ -104,7 +104,7 @@ public class APSResult {
BgReading bg = new BgReading(); BgReading bg = new BgReading();
bg.value = iob.getInt(i); bg.value = iob.getInt(i);
bg.date = startTime + i * 5 * 60 * 1000L; bg.date = startTime + i * 5 * 60 * 1000L;
bg.isPrediction = true; bg.isIOBPrediction = true;
array.add(bg); array.add(bg);
} }
} }
@ -114,7 +114,7 @@ public class APSResult {
BgReading bg = new BgReading(); BgReading bg = new BgReading();
bg.value = iob.getInt(i); bg.value = iob.getInt(i);
bg.date = startTime + i * 5 * 60 * 1000L; bg.date = startTime + i * 5 * 60 * 1000L;
bg.isPrediction = true; bg.isaCOBPrediction = true;
array.add(bg); array.add(bg);
} }
} }
@ -124,7 +124,7 @@ public class APSResult {
BgReading bg = new BgReading(); BgReading bg = new BgReading();
bg.value = iob.getInt(i); bg.value = iob.getInt(i);
bg.date = startTime + i * 5 * 60 * 1000L; bg.date = startTime + i * 5 * 60 * 1000L;
bg.isPrediction = true; bg.isCOBPrediction = true;
array.add(bg); array.add(bg);
} }
} }
@ -134,7 +134,7 @@ public class APSResult {
BgReading bg = new BgReading(); BgReading bg = new BgReading();
bg.value = iob.getInt(i); bg.value = iob.getInt(i);
bg.date = startTime + i * 5 * 60 * 1000L; bg.date = startTime + i * 5 * 60 * 1000L;
bg.isPrediction = true; bg.isUAMPrediction = true;
array.add(bg); array.add(bg);
} }
} }

View file

@ -55,4 +55,5 @@ public interface DataPointWithLabelInterface extends DataPointInterface{
PointsWithLabelGraphSeries.Shape getShape(); PointsWithLabelGraphSeries.Shape getShape();
float getSize(); float getSize();
int getColor(); int getColor();
int getSecondColor();
} }

View file

@ -50,14 +50,8 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
* You can also render a custom drawing via {@link com.jjoe64.graphview.series.PointsGraphSeries.CustomShape} * You can also render a custom drawing via {@link com.jjoe64.graphview.series.PointsGraphSeries.CustomShape}
*/ */
public enum Shape { public enum Shape {
/** BG,
* draws a point / circle PREDICTION,
*/
POINT,
/**
* draws a triangle
*/
TRIANGLE, TRIANGLE,
RECTANGLE, RECTANGLE,
BOLUS, BOLUS,
@ -191,9 +185,19 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
// draw data point // draw data point
if (!overdraw) { if (!overdraw) {
if (value.getShape() == Shape.POINT) { if (value.getShape() == Shape.BG) {
mPaint.setStyle(Paint.Style.FILL);
mPaint.setStrokeWidth(0); mPaint.setStrokeWidth(0);
canvas.drawCircle(endX, endY, value.getSize(), mPaint); canvas.drawCircle(endX, endY, value.getSize(), mPaint);
} else if (value.getShape() == Shape.PREDICTION) {
mPaint.setColor(value.getColor());
mPaint.setStyle(Paint.Style.FILL);
mPaint.setStrokeWidth(0);
canvas.drawCircle(endX, endY, value.getSize(), mPaint);
mPaint.setColor(value.getSecondColor());
mPaint.setStyle(Paint.Style.FILL);
mPaint.setStrokeWidth(0);
canvas.drawCircle(endX, endY, value.getSize() / 3, mPaint);
} else if (value.getShape() == Shape.RECTANGLE) { } else if (value.getShape() == Shape.RECTANGLE) {
canvas.drawRect(endX-value.getSize(), endY-value.getSize(), endX+value.getSize(), endY+value.getSize(), mPaint); canvas.drawRect(endX-value.getSize(), endY-value.getSize(), endX+value.getSize(), endY+value.getSize(), mPaint);
} else if (value.getShape() == Shape.TRIANGLE) { } else if (value.getShape() == Shape.TRIANGLE) {
@ -244,7 +248,6 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
} 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, value.getSize(), mPaint); canvas.drawCircle(endX, endY, value.getSize(), 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);

View file

@ -4,6 +4,7 @@
<color name="basal">#00ffff</color> <color name="basal">#00ffff</color>
<color name="iob">#FFFB8C00</color> <color name="iob">#FFFB8C00</color>
<color name="cob">#8BC34A</color> <color name="cob">#8BC34A</color>
<color name="uam">#ffea00</color>
<color name="ratio">#FFFFFF</color> <color name="ratio">#FFFFFF</color>
<color name="inrange">#00FF00</color> <color name="inrange">#00FF00</color>
<color name="low">#FF0000</color> <color name="low">#FF0000</color>