All labes scaled
COB is not here
This commit is contained in:
parent
24b9326602
commit
d683ea2f0c
1 changed files with 17 additions and 19 deletions
|
@ -47,6 +47,11 @@ import java.util.Iterator;
|
||||||
* @author jjoe64
|
* @author jjoe64
|
||||||
*/
|
*/
|
||||||
public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> extends BaseSeries<E> {
|
public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> extends BaseSeries<E> {
|
||||||
|
// 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
|
* choose a predefined shape to render for
|
||||||
* each data point.
|
* each data point.
|
||||||
|
@ -72,9 +77,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
||||||
OPENAPSOFFLINE,
|
OPENAPSOFFLINE,
|
||||||
EXERCISE,
|
EXERCISE,
|
||||||
GENERAL,
|
GENERAL,
|
||||||
GENERALWITHDURATION,
|
GENERALWITHDURATION
|
||||||
BG,
|
|
||||||
PREDICTION
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -196,8 +199,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
||||||
|
|
||||||
// draw data point
|
// draw data point
|
||||||
if (!overdraw) {
|
if (!overdraw) {
|
||||||
if (value.getShape() == Shape.BG) {
|
if (value.getShape() == Shape.POINT) {
|
||||||
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.RECTANGLE) {
|
} else if (value.getShape() == Shape.RECTANGLE) {
|
||||||
|
@ -226,7 +228,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
||||||
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((int) (value.getSize() * 2.5));
|
mPaint.setTextSize((int) (scaledTextSize * 2.5));
|
||||||
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(), endX, endY, mPaint);
|
canvas.drawText(value.getLabel(), endX, endY, mPaint);
|
||||||
|
@ -234,12 +236,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
||||||
} else if (value.getShape() == Shape.PROFILE) {
|
} else if (value.getShape() == Shape.PROFILE) {
|
||||||
mPaint.setStrokeWidth(0);
|
mPaint.setStrokeWidth(0);
|
||||||
if (value.getLabel() != null) {
|
if (value.getLabel() != null) {
|
||||||
//mPaint.setTextSize((int) (value.getSize() * 6));
|
mPaint.setTextSize((int) (value.getSize() * 3));
|
||||||
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(scaledTextSize);
|
mPaint.setTextSize(scaledTextSize);
|
||||||
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
|
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
|
||||||
Rect bounds = new Rect();
|
Rect bounds = new Rect();
|
||||||
|
@ -256,6 +253,7 @@ 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);
|
||||||
|
@ -282,7 +280,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
||||||
mPaint.setStrokeWidth(0);
|
mPaint.setStrokeWidth(0);
|
||||||
if (value.getLabel() != null) {
|
if (value.getLabel() != null) {
|
||||||
mPaint.setStrokeWidth(0);
|
mPaint.setStrokeWidth(0);
|
||||||
mPaint.setTextSize((int) (value.getSize() * 3));
|
mPaint.setTextSize((int) (scaledTextSize * 3));
|
||||||
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);
|
||||||
|
@ -297,7 +295,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
||||||
mPaint.setStrokeWidth(0);
|
mPaint.setStrokeWidth(0);
|
||||||
if (value.getLabel() != null) {
|
if (value.getLabel() != null) {
|
||||||
mPaint.setStrokeWidth(0);
|
mPaint.setStrokeWidth(0);
|
||||||
mPaint.setTextSize((int) (value.getSize() * 3));
|
mPaint.setTextSize(scaledTextSize);
|
||||||
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);
|
||||||
|
@ -312,7 +310,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
||||||
mPaint.setStrokeWidth(0);
|
mPaint.setStrokeWidth(0);
|
||||||
if (value.getLabel() != null) {
|
if (value.getLabel() != null) {
|
||||||
mPaint.setStrokeWidth(0);
|
mPaint.setStrokeWidth(0);
|
||||||
mPaint.setTextSize((int) (value.getSize() * 3));
|
mPaint.setTextSize(scaledTextSize * 3);
|
||||||
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);
|
||||||
|
@ -366,7 +364,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
||||||
float py = endY + value.getSize();
|
float py = endY + value.getSize();
|
||||||
canvas.save();
|
canvas.save();
|
||||||
canvas.rotate(-45, px, py);
|
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.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
|
||||||
mPaint.setFakeBoldText(true);
|
mPaint.setFakeBoldText(true);
|
||||||
mPaint.setTextAlign(Paint.Align.RIGHT);
|
mPaint.setTextAlign(Paint.Align.RIGHT);
|
||||||
|
@ -378,7 +376,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
|
||||||
float py = endY - value.getSize();
|
float py = endY - value.getSize();
|
||||||
canvas.save();
|
canvas.save();
|
||||||
canvas.rotate(-45, px, py);
|
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.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
|
||||||
mPaint.setFakeBoldText(true);
|
mPaint.setFakeBoldText(true);
|
||||||
canvas.drawText(value.getLabel(), px + value.getSize(), py, mPaint);
|
canvas.drawText(value.getLabel(), px + value.getSize(), py, mPaint);
|
||||||
|
|
Loading…
Reference in a new issue