Skip to content

Commit a145004

Browse files
committed
Utils cleanup
1 parent 1ea1480 commit a145004

File tree

1 file changed

+0
-100
lines changed
  • MPChartLib/src/main/java/com/github/mikephil/charting/utils

1 file changed

+0
-100
lines changed

MPChartLib/src/main/java/com/github/mikephil/charting/utils/Utils.java

Lines changed: 0 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
import android.graphics.Paint;
77
import android.graphics.Rect;
88
import android.graphics.drawable.Drawable;
9-
import android.text.StaticLayout;
10-
import android.text.TextPaint;
11-
import android.util.DisplayMetrics;
129
import android.view.MotionEvent;
1310
import android.view.VelocityTracker;
1411
import android.view.ViewConfiguration;
@@ -155,26 +152,6 @@ public static IValueFormatter getDefaultValueFormatter() {
155152
return mDefaultValueFormatter;
156153
}
157154

158-
/**
159-
* rounds the given number to the next significant number
160-
*
161-
* @param number
162-
* @return
163-
*/
164-
public static float roundToNextSignificant(double number) {
165-
if (Double.isInfinite(number) ||
166-
Double.isNaN(number) ||
167-
number == 0.0) {
168-
return 0;
169-
}
170-
171-
final float d = (float) Math.ceil((float) Math.log10(number < 0 ? -number : number));
172-
final int pw = 1 - (int) d;
173-
final float magnitude = (float) Math.pow(10, pw);
174-
final long shifted = Math.round(number * magnitude);
175-
return shifted / magnitude;
176-
}
177-
178155
/**
179156
* Returns a recyclable MPPointF instance.
180157
* Calculates the position around a center point, depending on the distance
@@ -327,83 +304,6 @@ public static void drawXAxisValue(Canvas canvas, String text, float x, float y,
327304
paint.setTextAlign(originalTextAlign);
328305
}
329306

330-
public static void drawMultilineText(Canvas canvas, StaticLayout textLayout,
331-
float x, float y,
332-
TextPaint paint,
333-
MPPointF anchor, float angleDegrees) {
334-
335-
float drawOffsetX = 0.f;
336-
float drawOffsetY = 0.f;
337-
float drawWidth;
338-
float drawHeight;
339-
340-
final float lineHeight = paint.getFontMetrics(mFontMetricsBuffer);
341-
342-
drawWidth = textLayout.getWidth();
343-
drawHeight = textLayout.getLineCount() * lineHeight;
344-
345-
// Android sometimes has pre-padding
346-
drawOffsetX -= mDrawTextRectBuffer.left;
347-
348-
// Android does not snap the bounds to line boundaries,
349-
// and draws from bottom to top.
350-
// And we want to normalize it.
351-
drawOffsetY += drawHeight;
352-
353-
// To have a consistent point of reference, we always draw left-aligned
354-
Paint.Align originalTextAlign = paint.getTextAlign();
355-
paint.setTextAlign(Paint.Align.LEFT);
356-
357-
if (angleDegrees != 0.f) {
358-
359-
// Move the text drawing rect in a way that it always rotates around its center
360-
drawOffsetX -= drawWidth * 0.5f;
361-
drawOffsetY -= drawHeight * 0.5f;
362-
363-
float translateX = x;
364-
float translateY = y;
365-
366-
// Move the "outer" rect relative to the anchor, assuming its centered
367-
if (anchor.x != 0.5f || anchor.y != 0.5f) {
368-
final FSize rotatedSize = getSizeOfRotatedRectangleByDegrees(
369-
drawWidth,
370-
drawHeight,
371-
angleDegrees);
372-
373-
translateX -= rotatedSize.width * (anchor.x - 0.5f);
374-
translateY -= rotatedSize.height * (anchor.y - 0.5f);
375-
FSize.recycleInstance(rotatedSize);
376-
}
377-
378-
canvas.save();
379-
canvas.translate(translateX, translateY);
380-
canvas.rotate(angleDegrees);
381-
382-
canvas.translate(drawOffsetX, drawOffsetY);
383-
textLayout.draw(canvas);
384-
385-
canvas.restore();
386-
} else {
387-
if (anchor.x != 0.f || anchor.y != 0.f) {
388-
389-
drawOffsetX -= drawWidth * anchor.x;
390-
drawOffsetY -= drawHeight * anchor.y;
391-
}
392-
393-
drawOffsetX += x;
394-
drawOffsetY += y;
395-
396-
canvas.save();
397-
398-
canvas.translate(drawOffsetX, drawOffsetY);
399-
textLayout.draw(canvas);
400-
401-
canvas.restore();
402-
}
403-
404-
paint.setTextAlign(originalTextAlign);
405-
}
406-
407307
/**
408308
* Returns a recyclable FSize instance.
409309
* Represents size of a rotated rectangle by degrees.

0 commit comments

Comments
 (0)