-
public abstract class UtilsUtilities class that has some helper methods. Needs to be initialized by calling Utils.init(...) before usage. Inside the Chart.init() method, this is done, if the Utils are used before that, Utils.init(...) needs to be called manually.
-
-
Field Summary
Fields Modifier and Type Field Description public final static doubleDEG2RADpublic final static floatFDEG2RADpublic final static doubleDOUBLE_EPSILONpublic final static floatFLOAT_EPSILON
-
Method Summary
Modifier and Type Method Description static voidinit(Context context)initialize method, called inside the Chart.init() method. static voidinit(Resources res)initialize method, called inside the Chart.init() method. static floatconvertDpToPixel(float dp)This method converts dp unit to equivalent pixels, depending on devicedensity. static floatconvertPixelsToDp(float px)This method converts device specific pixels to density independentpixels. static intcalcTextWidth(Paint paint, String demoText)calculates the approximate width of a text, depending on a demo textavoid repeated calls (e.g. static intcalcTextHeight(Paint paint, String demoText)calculates the approximate height of a text, depending on a demo textavoid repeated calls (e.g. static floatgetLineHeight(Paint paint)static floatgetLineHeight(Paint paint, Paint.FontMetrics fontMetrics)static floatgetLineSpacing(Paint paint)static floatgetLineSpacing(Paint paint, Paint.FontMetrics fontMetrics)static FSizecalcTextSize(Paint paint, String demoText)Returns a recyclable FSize instance.calculates the approximate size of a text, depending on a demo textavoid repeated calls (e.g. static voidcalcTextSize(Paint paint, String demoText, FSize outputFSize)calculates the approximate size of a text, depending on a demo textavoid repeated calls (e.g. static IValueFormattergetDefaultValueFormatter()static StringformatNumber(float number, int digitCount, boolean separateThousands)Formats the given number to the given number of decimals, and returns thenumber as a string, maximum 35 characters. static StringformatNumber(float number, int digitCount, boolean separateThousands, char separateChar)Formats the given number to the given number of decimals, and returns thenumber as a string, maximum 35 characters. static floatroundToNextSignificant(double number)rounds the given number to the next significant number static intgetDecimals(float number)Returns the appropriate number of decimals to be used for the providednumber. static Array<int>convertIntegers(List<Integer> integers)Converts the provided Integer List to an int array. static voidcopyIntegers(List<Integer> from, Array<int> to)static Array<String>convertStrings(List<String> strings)Converts the provided String List to a String array. static doublenextUp(double d)Replacement for the Math.nextUp(...) method that is only available inHONEYCOMB and higher. static MPPointFgetPosition(MPPointF center, float dist, float angle)Returns a recyclable MPPointF instance.Calculates the position around a center point, depending on the distancefrom the center, and the angle of the position around the center. static voidgetPosition(MPPointF center, float dist, float angle, MPPointF outputPoint)static voidvelocityTrackerPointerUpCleanUpIfNecessary(MotionEvent ev, VelocityTracker tracker)static voidpostInvalidateOnAnimation(View view)Original method view.postInvalidateOnAnimation() only supportd in API >=16, This is a replica of the code from ViewCompat. static intgetMinimumFlingVelocity()static intgetMaximumFlingVelocity()static floatgetNormalizedAngle(float angle)returns an angle between 0.f < 360. static voiddrawImage(Canvas canvas, Drawable drawable, int x, int y, int width, int height)static voiddrawXAxisValue(Canvas c, String text, float x, float y, Paint paint, MPPointF anchor, float angleDegrees)static voiddrawMultilineText(Canvas c, StaticLayout textLayout, float x, float y, TextPaint paint, MPPointF anchor, float angleDegrees)static voiddrawMultilineText(Canvas c, String text, float x, float y, TextPaint paint, FSize constrainedToSize, MPPointF anchor, float angleDegrees)static FSizegetSizeOfRotatedRectangleByDegrees(FSize rectangleSize, float degrees)Returns a recyclable FSize instance.Represents size of a rotated rectangle by degrees. static FSizegetSizeOfRotatedRectangleByRadians(FSize rectangleSize, float radians)Returns a recyclable FSize instance.Represents size of a rotated rectangle by radians. static FSizegetSizeOfRotatedRectangleByDegrees(float rectangleWidth, float rectangleHeight, float degrees)Returns a recyclable FSize instance.Represents size of a rotated rectangle by degrees. static FSizegetSizeOfRotatedRectangleByRadians(float rectangleWidth, float rectangleHeight, float radians)Returns a recyclable FSize instance.Represents size of a rotated rectangle by radians. static intgetSDKInt()-
-
Method Detail
-
init
@Deprecated() static void init(Resources res)
initialize method, called inside the Chart.init() method. backwardscompatibility - to not break existing code
-
convertDpToPixel
static float convertDpToPixel(float dp)
This method converts dp unit to equivalent pixels, depending on devicedensity. NEEDS UTILS TO BE INITIALIZED BEFORE USAGE.
- Parameters:
dp- A value in dp (density independent pixels) unit.
-
convertPixelsToDp
static float convertPixelsToDp(float px)
This method converts device specific pixels to density independentpixels. NEEDS UTILS TO BE INITIALIZED BEFORE USAGE.
- Parameters:
px- A value in px (pixels) unit.
-
calcTextWidth
static int calcTextWidth(Paint paint, String demoText)
calculates the approximate width of a text, depending on a demo textavoid repeated calls (e.g. inside drawing methods)
-
calcTextHeight
static int calcTextHeight(Paint paint, String demoText)
calculates the approximate height of a text, depending on a demo textavoid repeated calls (e.g. inside drawing methods)
-
getLineHeight
static float getLineHeight(Paint paint)
-
getLineHeight
static float getLineHeight(Paint paint, Paint.FontMetrics fontMetrics)
-
getLineSpacing
static float getLineSpacing(Paint paint)
-
getLineSpacing
static float getLineSpacing(Paint paint, Paint.FontMetrics fontMetrics)
-
calcTextSize
static FSize calcTextSize(Paint paint, String demoText)
Returns a recyclable FSize instance.calculates the approximate size of a text, depending on a demo textavoid repeated calls (e.g. inside drawing methods)
-
calcTextSize
static void calcTextSize(Paint paint, String demoText, FSize outputFSize)
calculates the approximate size of a text, depending on a demo textavoid repeated calls (e.g. inside drawing methods)
- Parameters:
outputFSize- An output variable, modified by the function.
-
getDefaultValueFormatter
static IValueFormatter getDefaultValueFormatter()
-
formatNumber
static String formatNumber(float number, int digitCount, boolean separateThousands)
Formats the given number to the given number of decimals, and returns thenumber as a string, maximum 35 characters. If thousands are separated, the separatingcharacter is a dot (".").
- Parameters:
separateThousands- set this to true to separate thousands values
-
formatNumber
static String formatNumber(float number, int digitCount, boolean separateThousands, char separateChar)
Formats the given number to the given number of decimals, and returns thenumber as a string, maximum 35 characters.
- Parameters:
separateThousands- set this to true to separate thousands valuesseparateChar- a caracter to be paced between the "thousands"
-
roundToNextSignificant
static float roundToNextSignificant(double number)
rounds the given number to the next significant number
-
getDecimals
static int getDecimals(float number)
Returns the appropriate number of decimals to be used for the providednumber.
-
convertIntegers
static Array<int> convertIntegers(List<Integer> integers)
Converts the provided Integer List to an int array.
-
copyIntegers
static void copyIntegers(List<Integer> from, Array<int> to)
-
convertStrings
static Array<String> convertStrings(List<String> strings)
Converts the provided String List to a String array.
-
nextUp
static double nextUp(double d)
Replacement for the Math.nextUp(...) method that is only available inHONEYCOMB and higher. Dat's some seeeeek sheeet.
-
getPosition
static MPPointF getPosition(MPPointF center, float dist, float angle)
Returns a recyclable MPPointF instance.Calculates the position around a center point, depending on the distancefrom the center, and the angle of the position around the center.
- Parameters:
angle- in degrees, converted to radians internally
-
getPosition
static void getPosition(MPPointF center, float dist, float angle, MPPointF outputPoint)
-
velocityTrackerPointerUpCleanUpIfNecessary
static void velocityTrackerPointerUpCleanUpIfNecessary(MotionEvent ev, VelocityTracker tracker)
-
postInvalidateOnAnimation
static void postInvalidateOnAnimation(View view)
Original method view.postInvalidateOnAnimation() only supportd in API >=16, This is a replica of the code from ViewCompat.
-
getMinimumFlingVelocity
static int getMinimumFlingVelocity()
-
getMaximumFlingVelocity
static int getMaximumFlingVelocity()
-
getNormalizedAngle
static float getNormalizedAngle(float angle)
returns an angle between 0.f < 360.f (not less than zero, less than 360)
-
drawImage
static void drawImage(Canvas canvas, Drawable drawable, int x, int y, int width, int height)
-
drawXAxisValue
static void drawXAxisValue(Canvas c, String text, float x, float y, Paint paint, MPPointF anchor, float angleDegrees)
-
drawMultilineText
static void drawMultilineText(Canvas c, StaticLayout textLayout, float x, float y, TextPaint paint, MPPointF anchor, float angleDegrees)
-
drawMultilineText
static void drawMultilineText(Canvas c, String text, float x, float y, TextPaint paint, FSize constrainedToSize, MPPointF anchor, float angleDegrees)
-
getSizeOfRotatedRectangleByDegrees
static FSize getSizeOfRotatedRectangleByDegrees(FSize rectangleSize, float degrees)
Returns a recyclable FSize instance.Represents size of a rotated rectangle by degrees.
-
getSizeOfRotatedRectangleByRadians
static FSize getSizeOfRotatedRectangleByRadians(FSize rectangleSize, float radians)
Returns a recyclable FSize instance.Represents size of a rotated rectangle by radians.
-
getSizeOfRotatedRectangleByDegrees
static FSize getSizeOfRotatedRectangleByDegrees(float rectangleWidth, float rectangleHeight, float degrees)
Returns a recyclable FSize instance.Represents size of a rotated rectangle by degrees.
-
getSizeOfRotatedRectangleByRadians
static FSize getSizeOfRotatedRectangleByRadians(float rectangleWidth, float rectangleHeight, float radians)
Returns a recyclable FSize instance.Represents size of a rotated rectangle by radians.
-
getSDKInt
static int getSDKInt()
-
-
-
-