com.androidplot.util
Class PixelUtils

java.lang.Object
  extended by com.androidplot.util.PixelUtils

public class PixelUtils
extends Object


Field Summary
static Map<String,Integer> dimensionConstantLookup
          CODE BELOW IS ADAPTED IN PART FROM MINDRIOT'S SAMPLE CODE HERE: http://stackoverflow.com/questions/8343971/how-to-parse-a-dimension-string-and-convert-it-to-a-dimension-value
 
Constructor Summary
PixelUtils()
           
 
Method Summary
static android.graphics.PointF add(android.graphics.PointF lhs, android.graphics.PointF rhs)
           
static float dpToPix(float dp)
          Converts a dp value to pixels.
static float fractionToPixH(float fraction)
           
static float fractionToPixW(float fraction)
           
static void init(android.content.Context ctx)
          Recalculates scale value etc.
static android.graphics.RectF nearestPixRect(float left, float top, float right, float bottom)
           
static android.graphics.RectF sink(android.graphics.RectF in)
          Converts a sub-pixel accurate RectF to a single pixel accurate rect.
static float spToPix(float sp)
          Converts an sp value to pixels.
static float stringToDimension(String dimension)
           
static android.graphics.PointF sub(android.graphics.PointF lhs, android.graphics.PointF rhs)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dimensionConstantLookup

public static final Map<String,Integer> dimensionConstantLookup
CODE BELOW IS ADAPTED IN PART FROM MINDRIOT'S SAMPLE CODE HERE: http://stackoverflow.com/questions/8343971/how-to-parse-a-dimension-string-and-convert-it-to-a-dimension-value

Constructor Detail

PixelUtils

public PixelUtils()
Method Detail

init

public static void init(android.content.Context ctx)
Recalculates scale value etc. Should be called when an application starts or whenever the screen is rotated.


add

public static android.graphics.PointF add(android.graphics.PointF lhs,
                                          android.graphics.PointF rhs)

sub

public static android.graphics.PointF sub(android.graphics.PointF lhs,
                                          android.graphics.PointF rhs)

sink

public static android.graphics.RectF sink(android.graphics.RectF in)
Converts a sub-pixel accurate RectF to a single pixel accurate rect. This is helpful for clipping operations which dont do a good job with subpixel vals.

Parameters:
in -
Returns:

nearestPixRect

public static android.graphics.RectF nearestPixRect(float left,
                                                    float top,
                                                    float right,
                                                    float bottom)

dpToPix

public static float dpToPix(float dp)
Converts a dp value to pixels.

Parameters:
dp -
Returns:
Pixel value of dp.

spToPix

public static float spToPix(float sp)
Converts an sp value to pixels.

Parameters:
sp -
Returns:
Pixel value of sp.

fractionToPixH

public static float fractionToPixH(float fraction)
Parameters:
fraction - A float value between 0 and 1.
Returns:
Number of pixels fraction represents on the current device's display.

fractionToPixW

public static float fractionToPixW(float fraction)
Parameters:
fraction - A float value between 0 and 1.
Returns:
Number of pixels fraction represents on the current device's display.

stringToDimension

public static float stringToDimension(String dimension)


Copyright © 2010-2013 androidplot.com. All Rights Reserved.