/*
 * DisplayUtil.java
 *
 * Copyright 2011 NHN Corp. All rights Reserved.
 * NHN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */
package com.navercorp.utilset.ui;

import android.content.Context;

/**
 * @author Created by
 * @tag DisplayUtil
 */
public class PixelUtils {
	/**
	 * Converts Pixel to DP<br>
	 * @param pixel Pixel
	 * @return DP
	 * @see <a href="http://developer.android.com/guide/practices/screens_support.html#dips-pels">http://developer.android.com/guide/practices/screens_support.html#dips-pels</a>
	 */
	public static int getDpFromPixel(Context context, int pixel) {
		float scale = context.getResources().getDisplayMetrics().density; // get display density

		return (int)(pixel / scale);
	}

	/**
	 * Converts DP to Pixel<br>
	 * 
	 * @param  dp DP
	 * @return Pixel
	 * @see <a href="http://developer.android.com/guide/practices/screens_support.html#dips-pels">http://developer.android.com/guide/practices/screens_support.html#dips-pels</a>
	 */
	public static int getPixelFromDP(Context context, int dp) {
		// Get the screen's density scale		
		float scale = context.getResources().getDisplayMetrics().density;

		// Convert the dps to pixels, based on density scale
		return (int)(dp * scale + 0.5f);
	}
}
@@ -282,16 +282,65 @@
 Utils %7B%0A
+%09private static final float ROUND_FACTOR = 0.5f;%0A
 %09/**%0A%09 *
@@ -1252,16 +1252,204 @@
 y scale%0A
+%09%09// because dp*scale is cast as an integer value, this will cause the result to be truncated.%0A%09%09// Therefore, Adding ROUND_FACTOR helps the result to have properly rounded integer value.%0A
 %09%09return
@@ -1468,19 +1468,27 @@
 scale + 
-0.5f
+ROUND_FACTOR
 );%0A%09%7D%0A%7D

Change magic number 0.5f in PixelUtils to constant ROUND_FACTOR. Explain why ROUND_FACTOR is added.