From d683ea2f0c58ba4502fe995f02b08b39fa728bb3 Mon Sep 17 00:00:00 2001 From: Roumen Georgiev Date: Thu, 30 Nov 2017 11:28:26 +0200 Subject: [PATCH] All labes scaled COB is not here --- .../PointsWithLabelGraphSeries.java | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphExtensions/PointsWithLabelGraphSeries.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphExtensions/PointsWithLabelGraphSeries.java index 0ee61d33be..a5fe5b7700 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphExtensions/PointsWithLabelGraphSeries.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphExtensions/PointsWithLabelGraphSeries.java @@ -47,6 +47,11 @@ import java.util.Iterator; * @author jjoe64 */ public class PointsWithLabelGraphSeries extends BaseSeries { + // Default spSize + int spSize = 12; + // Convert the sp to pixels + Context context = MainApp.instance().getApplicationContext(); + float scaledTextSize = spSize * context.getResources().getDisplayMetrics().scaledDensity; /** * choose a predefined shape to render for * each data point. @@ -72,9 +77,7 @@ public class PointsWithLabelGraphSeries e OPENAPSOFFLINE, EXERCISE, GENERAL, - GENERALWITHDURATION, - BG, - PREDICTION + GENERALWITHDURATION } /** @@ -196,11 +199,10 @@ public class PointsWithLabelGraphSeries e // draw data point if (!overdraw) { - if (value.getShape() == Shape.BG) { - mPaint.setStyle(Paint.Style.FILL); + if (value.getShape() == Shape.POINT) { mPaint.setStrokeWidth(0); canvas.drawCircle(endX, endY, value.getSize(), 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); } else if (value.getShape() == Shape.TRIANGLE) { mPaint.setStrokeWidth(0); @@ -226,7 +228,7 @@ public class PointsWithLabelGraphSeries e 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((int) (value.getSize() * 2.5)); + mPaint.setTextSize((int) (scaledTextSize * 2.5)); mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL)); mPaint.setFakeBoldText(true); canvas.drawText(value.getLabel(), endX, endY, mPaint); @@ -234,12 +236,7 @@ public class PointsWithLabelGraphSeries e } else if (value.getShape() == Shape.PROFILE) { mPaint.setStrokeWidth(0); if (value.getLabel() != null) { - //mPaint.setTextSize((int) (value.getSize() * 6)); - int spSize = 14; - //your sp size - // Convert the sp to pixels - Context context = MainApp.instance().getApplicationContext(); - float scaledTextSize = spSize * context.getResources().getDisplayMetrics().scaledDensity; + mPaint.setTextSize((int) (value.getSize() * 3)); mPaint.setTextSize(scaledTextSize); mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD)); Rect bounds = new Rect(); @@ -256,6 +253,7 @@ public class PointsWithLabelGraphSeries e } else if (value.getShape() == Shape.MBG) { mPaint.setStyle(Paint.Style.STROKE); mPaint.setStrokeWidth(5); + float w = mPaint.getStrokeWidth(); canvas.drawCircle(endX, endY, value.getSize(), mPaint); } else if (value.getShape() == Shape.BGCHECK) { mPaint.setStyle(Paint.Style.FILL_AND_STROKE); @@ -282,7 +280,7 @@ public class PointsWithLabelGraphSeries e mPaint.setStrokeWidth(0); if (value.getLabel() != null) { mPaint.setStrokeWidth(0); - mPaint.setTextSize((int) (value.getSize() * 3)); + mPaint.setTextSize((int) (scaledTextSize * 3)); mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD)); Rect bounds = new Rect(); mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds); @@ -297,7 +295,7 @@ public class PointsWithLabelGraphSeries e mPaint.setStrokeWidth(0); if (value.getLabel() != null) { mPaint.setStrokeWidth(0); - mPaint.setTextSize((int) (value.getSize() * 3)); + mPaint.setTextSize(scaledTextSize); mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD)); Rect bounds = new Rect(); mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds); @@ -312,7 +310,7 @@ public class PointsWithLabelGraphSeries e mPaint.setStrokeWidth(0); if (value.getLabel() != null) { mPaint.setStrokeWidth(0); - mPaint.setTextSize((int) (value.getSize() * 3)); + mPaint.setTextSize(scaledTextSize * 3); mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD)); Rect bounds = new Rect(); mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds); @@ -366,7 +364,7 @@ public class PointsWithLabelGraphSeries e float py = endY + value.getSize(); canvas.save(); canvas.rotate(-45, px, py); - mPaint.setTextSize((int) (value.getSize() * 2.5)); + mPaint.setTextSize((float) (scaledTextSize*0.8)); mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL)); mPaint.setFakeBoldText(true); mPaint.setTextAlign(Paint.Align.RIGHT); @@ -378,11 +376,11 @@ public class PointsWithLabelGraphSeries e float py = endY - value.getSize(); canvas.save(); canvas.rotate(-45, px, py); - mPaint.setTextSize((int) (value.getSize() * 2.5)); + mPaint.setTextSize((float) (scaledTextSize*0.8)); mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL)); mPaint.setFakeBoldText(true); canvas.drawText(value.getLabel(), px + value.getSize(), py, mPaint); canvas.restore(); } } -} +}