|
6 | 6 | import android.graphics.Paint; |
7 | 7 | import android.graphics.Rect; |
8 | 8 | import android.graphics.drawable.Drawable; |
9 | | -import android.text.StaticLayout; |
10 | | -import android.text.TextPaint; |
11 | | -import android.util.DisplayMetrics; |
12 | 9 | import android.view.MotionEvent; |
13 | 10 | import android.view.VelocityTracker; |
14 | 11 | import android.view.ViewConfiguration; |
@@ -155,26 +152,6 @@ public static IValueFormatter getDefaultValueFormatter() { |
155 | 152 | return mDefaultValueFormatter; |
156 | 153 | } |
157 | 154 |
|
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 | | - |
178 | 155 | /** |
179 | 156 | * Returns a recyclable MPPointF instance. |
180 | 157 | * 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, |
327 | 304 | paint.setTextAlign(originalTextAlign); |
328 | 305 | } |
329 | 306 |
|
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 | | - |
407 | 307 | /** |
408 | 308 | * Returns a recyclable FSize instance. |
409 | 309 | * Represents size of a rotated rectangle by degrees. |
|
0 commit comments