Java Code Examples for org.w3c.dom.css.CSSPrimitiveValue#CSS_GRAD
The following examples show how to use
org.w3c.dom.css.CSSPrimitiveValue#CSS_GRAD .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FloatValue.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Converts the current value into degrees. */ protected static float toDegrees( int unit, float value ) { switch ( unit ) { case CSSPrimitiveValue.CSS_DEG : return value; case CSSPrimitiveValue.CSS_RAD : return (float) ( value * 180 / Math.PI ); case CSSPrimitiveValue.CSS_GRAD : return ( value * 9 / 5 ); default : throw new DOMException( DOMException.INVALID_ACCESS_ERR, "" ); } }
Example 2
Source File: FloatValue.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Converts the current value into radians. */ protected static float toRadians( int unit, float value ) { switch ( unit ) { case CSSPrimitiveValue.CSS_DEG : return ( value * 5 / 9 ); case CSSPrimitiveValue.CSS_RAD : return value; case CSSPrimitiveValue.CSS_GRAD : return (float) ( value * 100 / Math.PI ); default : throw new DOMException( DOMException.INVALID_ACCESS_ERR, "" ); } }
Example 3
Source File: FloatValue.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Converts the current value into gradians. */ protected static float toGradians( int unit, float value ) { switch ( unit ) { case CSSPrimitiveValue.CSS_DEG : return (float) ( value * Math.PI / 180 ); case CSSPrimitiveValue.CSS_RAD : return (float) ( value * Math.PI / 100 ); case CSSPrimitiveValue.CSS_GRAD : return value; default : throw new DOMException( DOMException.INVALID_ACCESS_ERR, "" ); } }
Example 4
Source File: FloatValue.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Converts the actual float value to the given unit type. */ public static float convertFloatValue( short unitType, FloatValue value ) { switch ( unitType ) { case CSSPrimitiveValue.CSS_NUMBER : case CSSPrimitiveValue.CSS_PERCENTAGE : case CSSPrimitiveValue.CSS_EMS : case CSSPrimitiveValue.CSS_EXS : case CSSPrimitiveValue.CSS_DIMENSION : case CSSPrimitiveValue.CSS_PX : if ( value.getPrimitiveType( ) == unitType ) { return value.getFloatValue( ); } break; case CSSPrimitiveValue.CSS_CM : return toCentimeters( unitType, value.getFloatValue( ) ); case CSSPrimitiveValue.CSS_MM : return toMillimeters( unitType, value.getFloatValue( ) ); case CSSPrimitiveValue.CSS_IN : return toInches( unitType, value.getFloatValue( ) ); case CSSPrimitiveValue.CSS_PT : return toPoints( unitType, value.getFloatValue( ) ); case CSSPrimitiveValue.CSS_PC : return toPicas( unitType, value.getFloatValue( ) ); case CSSPrimitiveValue.CSS_DEG : return toDegrees( unitType, value.getFloatValue( ) ); case CSSPrimitiveValue.CSS_RAD : return toRadians( unitType, value.getFloatValue( ) ); case CSSPrimitiveValue.CSS_GRAD : return toGradians( unitType, value.getFloatValue( ) ); case CSSPrimitiveValue.CSS_MS : return toMilliseconds( unitType, value.getFloatValue( ) ); case CSSPrimitiveValue.CSS_S : return toSeconds( unitType, value.getFloatValue( ) ); case CSSPrimitiveValue.CSS_HZ : return toHertz( unitType, value.getFloatValue( ) ); case CSSPrimitiveValue.CSS_KHZ : return tokHertz( unitType, value.getFloatValue( ) ); } throw new DOMException( DOMException.INVALID_ACCESS_ERR, "" ); }