Package 

Class Utils


  • 
    public abstract class Utils
    
                        

    Utilities 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.

    • Method Detail

      • init

         static void init(Context context)

        initialize method, called inside the Chart.init() method.

      • 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)

      • 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.
      • 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 values
        separateChar - 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.

      • 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
      • postInvalidateOnAnimation

         static void postInvalidateOnAnimation(View view)

        Original method view.postInvalidateOnAnimation() only supportd in API >=16, This is a replica of the code from ViewCompat.

      • getNormalizedAngle

         static float getNormalizedAngle(float angle)

        returns an angle between 0.f < 360.f (not less than zero, less than 360)

      • 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.