public static int getDimensionValue(String d) {  if(d==null) { return 0; } try { if(d.endsWith("in") || d.endsWith("in")) { return (int)((Float.valueOf(d.substring(0, d.length()-2)).floatValue())*72000.0f); } else if(d.endsWith("cm") || d.endsWith("CM")) { return (int)((Float.valueOf(d.substring(0, d.length()-2)).floatValue())*72000.0f/2.54f); } else if(d.endsWith("mm") || d.endsWith("MM")) { return (int)((Float.valueOf(d.substring(0, d.length()-2)).floatValue())*7200.0f/2.54f); } else if(d.endsWith("px") || d.endsWith("PX")) { return (int)((Float.valueOf(d.substring(0, d.length()-2)).floatValue())/96.0f*72000.0f); } else { return (int)((Float.valueOf(d).floatValue( ))); } } catch(NumberFormatException ex) { ex.printStackTrace(); return 0; } }
public static int getDimensionValue( CSSValue value ) { return getDimensionValue( value, 0 ); }
    public static int getDimensionValue(String d)    {    	    	if(d==null)    	{    		return 0;    	}    	try    	{	    	if(d.endsWith("in") || d.endsWith("in")) //$NON-NLS-1$ //$NON-NLS-2$	    	{	    		return (int)((Float.valueOf(d.substring(0, d.length()-2)).floatValue())*72000.0f);	    	}	    	else if(d.endsWith("cm") || d.endsWith("CM"))  //$NON-NLS-1$//$NON-NLS-2$	    	{	    		return (int)((Float.valueOf(d.substring(0, d.length()-2)).floatValue())*72000.0f/2.54f);	    	}	    	else if(d.endsWith("mm") || d.endsWith("MM")) //$NON-NLS-1$ //$NON-NLS-2$	    	{	    		return (int)((Float.valueOf(d.substring(0, d.length()-2)).floatValue())*7200.0f/2.54f);	    	}	    	else if(d.endsWith("px") || d.endsWith("PX"))  //$NON-NLS-1$//$NON-NLS-2$	    	{	    		return (int)((Float.valueOf(d.substring(0, d.length()-2)).floatValue())/96.0f*72000.0f);//set as 96dpi	    	}	    	else	    	{	    		return (int)((Float.valueOf(d).floatValue( )));	    	}    	}    	catch(NumberFormatException ex)    	{    		ex.printStackTrace();    		return 0;    	}    }