Java Code Examples for org.w3c.dom.css.CSSPrimitiveValue#CSS_IN
The following examples show how to use
org.w3c.dom.css.CSSPrimitiveValue#CSS_IN .
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 | 6 votes |
/** * Converts the current value into centimeters. */ protected static float toCentimeters( int type, float value ) { switch ( type ) { case CSSPrimitiveValue.CSS_CM : return value; case CSSPrimitiveValue.CSS_MM : return ( value / 10 ); case CSSPrimitiveValue.CSS_IN : return ( value * 2.54f ); case CSSPrimitiveValue.CSS_PT : return ( value * 2.54f / 72 ); case CSSPrimitiveValue.CSS_PC : return ( value * 2.54f / 6 ); default : throw new DOMException( DOMException.INVALID_ACCESS_ERR, "" ); } }
Example 2
Source File: FloatValue.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Converts the current value into inches. */ protected static float toInches( int type, float value ) { switch ( type ) { case CSSPrimitiveValue.CSS_CM : return ( value / 2.54f ); case CSSPrimitiveValue.CSS_MM : return ( value / 25.4f ); case CSSPrimitiveValue.CSS_IN : return value; case CSSPrimitiveValue.CSS_PT : return ( value / 72 ); case CSSPrimitiveValue.CSS_PC : return ( value / 6 ); default : throw new DOMException( DOMException.INVALID_ACCESS_ERR, "" ); } }
Example 3
Source File: FloatValue.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Converts the current value into millimeters. */ protected static float toMillimeters( int unit, float value ) { switch ( unit ) { case CSSPrimitiveValue.CSS_CM : return ( value * 10 ); case CSSPrimitiveValue.CSS_MM : return value; case CSSPrimitiveValue.CSS_IN : return ( value * 25.4f ); case CSSPrimitiveValue.CSS_PT : return ( value * 25.4f / 72 ); case CSSPrimitiveValue.CSS_PC : return ( value * 25.4f / 6 ); default : throw new DOMException( DOMException.INVALID_ACCESS_ERR, "" ); } }
Example 4
Source File: FloatValue.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Converts the current value into points. */ protected static float toPoints( int unit, float value ) { switch ( unit ) { case CSSPrimitiveValue.CSS_CM : return ( value * 72 / 2.54f ); case CSSPrimitiveValue.CSS_MM : return ( value * 72 / 25.4f ); case CSSPrimitiveValue.CSS_IN : return ( value * 72 ); case CSSPrimitiveValue.CSS_PT : return value; case CSSPrimitiveValue.CSS_PC : return ( value * 12 ); default : throw new DOMException( DOMException.INVALID_ACCESS_ERR, "" ); } }
Example 5
Source File: FloatValue.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Converts the current value into picas. */ protected static float toPicas( int unit, float value ) { switch ( unit ) { case CSSPrimitiveValue.CSS_CM : return ( value * 6 / 2.54f ); case CSSPrimitiveValue.CSS_MM : return ( value * 6 / 25.4f ); case CSSPrimitiveValue.CSS_IN : return ( value * 6 ); case CSSPrimitiveValue.CSS_PT : return ( value / 12 ); case CSSPrimitiveValue.CSS_PC : return value; default : throw new DOMException( DOMException.INVALID_ACCESS_ERR, "" ); } }
Example 6
Source File: ChartReportStyleProcessor.java From birt with Eclipse Public License 1.0 | 5 votes |
private int getSize( CSSValue value ) { // Copied from // org.eclipse.birt.report.engine.layout.pdf.util.PropertyUtil.getDimensionValueConsiderDpi() if ( value != null && ( value instanceof FloatValue ) ) { FloatValue fv = (FloatValue) value; float v = fv.getFloatValue( ); switch ( fv.getPrimitiveType( ) ) { case CSSPrimitiveValue.CSS_CM : return (int) ( v * 72 / 2.54 ); case CSSPrimitiveValue.CSS_IN : return (int) ( v * 72 ); case CSSPrimitiveValue.CSS_MM : return (int) ( v * 7.2 / 2.54 ); case CSSPrimitiveValue.CSS_PC : return (int) ( v * 12 ); case CSSPrimitiveValue.CSS_PX : return (int) ( v / dpi * 72f ); case CSSPrimitiveValue.CSS_PT : return (int) v; case CSSPrimitiveValue.CSS_NUMBER : return (int) ( v / 1000 ); } } return 0; }
Example 7
Source File: HTMLVisionOptimize.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Get the border width from a style. It don't support '%'. * * @param style * @param borderNum * @return */ private int getBorderWidthValue( IStyle style, int borderNum ) { if ( null == style ) { return 0; } if ( IStyle.STYLE_BORDER_TOP_WIDTH != borderNum && IStyle.STYLE_BORDER_RIGHT_WIDTH != borderNum && IStyle.STYLE_BORDER_BOTTOM_WIDTH != borderNum && IStyle.STYLE_BORDER_LEFT_WIDTH != borderNum ) { return 0; } CSSValue value = style.getProperty( borderNum ); if ( value != null && ( value instanceof FloatValue ) ) { FloatValue fv = (FloatValue) value; float v = fv.getFloatValue( ); switch ( fv.getPrimitiveType( ) ) { case CSSPrimitiveValue.CSS_CM : return (int) ( v * 72000 / 2.54 ); case CSSPrimitiveValue.CSS_IN : return (int) ( v * 72000 ); case CSSPrimitiveValue.CSS_MM : return (int) ( v * 7200 / 2.54 ); case CSSPrimitiveValue.CSS_PT : return (int) ( v * 1000 ); case CSSPrimitiveValue.CSS_NUMBER : return (int) v; } } return 0; }
Example 8
Source File: OdfUtil.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Returns the dimension value in inches. */ public static double getDimensionValue( CSSValue value, int dpi ) { if ( value != null && ( value instanceof FloatValue ) ) { FloatValue fv = (FloatValue) value; float v = fv.getFloatValue( ); switch ( fv.getPrimitiveType( ) ) { case CSSPrimitiveValue.CSS_CM : return ( v / 2.54 ); case CSSPrimitiveValue.CSS_IN : return ( v ); case CSSPrimitiveValue.CSS_MM : return ( v / 25.4 ); case CSSPrimitiveValue.CSS_PC : return ( v * 12 * 1000 ); case CSSPrimitiveValue.CSS_PX : return ( v / dpi ); case CSSPrimitiveValue.CSS_PT : return ( v / 72 ); case CSSPrimitiveValue.CSS_NUMBER : return v; } } return 0; }
Example 9
Source File: AbstractLengthManager.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * Implements {@link * ValueManager#computeValue(CSSStylableElement,String,CSSEngine,int,StyleMap,Value)}. */ public Value computeValue( CSSStylableElement elt, CSSEngine engine, int idx, Value value ) { if ( value.getCssValueType( ) == CSSValue.CSS_PRIMITIVE_VALUE ) { switch ( value.getPrimitiveType( ) ) { case CSSPrimitiveValue.CSS_NUMBER : case CSSPrimitiveValue.CSS_PX : case CSSPrimitiveValue.CSS_MM : case CSSPrimitiveValue.CSS_CM : case CSSPrimitiveValue.CSS_IN : case CSSPrimitiveValue.CSS_PT : case CSSPrimitiveValue.CSS_PC : return value; case CSSPrimitiveValue.CSS_EMS : float v = value.getFloatValue( ); Value fontSize = (Value) elt.getComputedStyle( ) .getProperty( IStyle.STYLE_FONT_SIZE ); float fs = fontSize.getFloatValue( ); return new FloatValue( fontSize.getPrimitiveType( ), v * fs ); case CSSPrimitiveValue.CSS_EXS : v = value.getFloatValue( ); fontSize = (Value) elt.getComputedStyle( ) .getProperty( IStyle.STYLE_FONT_SIZE ); fs = fontSize.getFloatValue( ); return new FloatValue( fontSize.getPrimitiveType( ), v * fs * 0.5f ); } } return value; }
Example 10
Source File: ContainerArea.java From birt with Eclipse Public License 1.0 | 5 votes |
protected int getDimensionValue( CSSValue value, int referenceLength ) { if ( value != null && ( value instanceof FloatValue ) ) { FloatValue fv = (FloatValue) value; float v = fv.getFloatValue( ); switch ( fv.getPrimitiveType( ) ) { case CSSPrimitiveValue.CSS_CM : return (int) ( v * 72000 / 2.54 ); case CSSPrimitiveValue.CSS_IN : return (int) ( v * 72000 ); case CSSPrimitiveValue.CSS_MM : return (int) ( v * 7200 / 2.54 ); case CSSPrimitiveValue.CSS_PC : return (int) ( v * 12 * 1000 ); case CSSPrimitiveValue.CSS_PX : float dpi = getResolution( ); return (int) ( v / dpi * 72000f ); case CSSPrimitiveValue.CSS_PT : return (int) ( v * 1000 ); case CSSPrimitiveValue.CSS_NUMBER : return (int) v; case CSSPrimitiveValue.CSS_PERCENTAGE : return (int) ( referenceLength * v / 100.0 ); } } return 0; }
Example 11
Source File: PDFAbstractLM.java From birt with Eclipse Public License 1.0 | 5 votes |
protected int getDimensionValue( CSSValue value, int referenceLength ) { if ( value != null && ( value instanceof FloatValue ) ) { FloatValue fv = (FloatValue) value; float v = fv.getFloatValue( ); switch ( fv.getPrimitiveType( ) ) { case CSSPrimitiveValue.CSS_CM : return (int) ( v * 72000 / 2.54 ); case CSSPrimitiveValue.CSS_IN : return (int) ( v * 72000 ); case CSSPrimitiveValue.CSS_MM : return (int) ( v * 7200 / 2.54 ); case CSSPrimitiveValue.CSS_PT : return (int) ( v * 1000 ); case CSSPrimitiveValue.CSS_NUMBER : return (int) v; case CSSPrimitiveValue.CSS_PERCENTAGE : return (int) ( referenceLength * v/100.0 ); } } return 0; }
Example 12
Source File: Layout.java From birt with Eclipse Public License 1.0 | 5 votes |
protected int getDimensionValue( CSSValue value, int referenceLength ) { if ( value != null && ( value instanceof FloatValue ) ) { FloatValue fv = (FloatValue) value; float v = fv.getFloatValue( ); switch ( fv.getPrimitiveType( ) ) { case CSSPrimitiveValue.CSS_CM : return (int) ( v * 72000 / 2.54 ); case CSSPrimitiveValue.CSS_IN : return (int) ( v * 72000 ); case CSSPrimitiveValue.CSS_MM : return (int) ( v * 7200 / 2.54 ); case CSSPrimitiveValue.CSS_PT : return (int) ( v * 1000 ); case CSSPrimitiveValue.CSS_NUMBER : return (int) v; case CSSPrimitiveValue.CSS_PERCENTAGE : return (int) ( referenceLength * v / 100.0 ); } } return 0; }
Example 13
Source File: PropertyUtil.java From birt with Eclipse Public License 1.0 | 5 votes |
public static int getDimensionValueConsiderDpi( CSSValue value, IContent content ) { if ( value != null && ( value instanceof FloatValue ) ) { FloatValue fv = (FloatValue) value; float v = fv.getFloatValue( ); switch ( fv.getPrimitiveType( ) ) { case CSSPrimitiveValue.CSS_CM : return (int) ( v * 72000 / 2.54 ); case CSSPrimitiveValue.CSS_IN : return (int) ( v * 72000 ); case CSSPrimitiveValue.CSS_MM : return (int) ( v * 7200 / 2.54 ); case CSSPrimitiveValue.CSS_PC : return (int) ( v * 12 * 1000 ); case CSSPrimitiveValue.CSS_PX : ReportDesignHandle designHandle = content .getReportContent( ).getDesign( ).getReportDesign( ); int dpi = designHandle.getImageDPI( ); if ( dpi == 0 ) { dpi = 96; } return (int) ( v / dpi * 72000f ); case CSSPrimitiveValue.CSS_PT : return (int) ( v * 1000 ); case CSSPrimitiveValue.CSS_NUMBER : return (int) v; } } return 0; }
Example 14
Source File: PropertyUtil.java From birt with Eclipse Public License 1.0 | 5 votes |
private static int getDimensionValue( CSSValue value, int dpi, int referenceLength ) { if ( value != null && ( value instanceof FloatValue ) ) { FloatValue fv = (FloatValue) value; float v = fv.getFloatValue( ); switch ( fv.getPrimitiveType( ) ) { case CSSPrimitiveValue.CSS_CM : return (int) ( v * 72000 / 2.54 ); case CSSPrimitiveValue.CSS_IN : return (int) ( v * 72000 ); case CSSPrimitiveValue.CSS_MM : return (int) ( v * 7200 / 2.54 ); case CSSPrimitiveValue.CSS_PC : return (int) ( v * 12 * 1000 ); case CSSPrimitiveValue.CSS_PX : return (int) ( v / dpi * 72000f ); case CSSPrimitiveValue.CSS_PT : return (int) ( v * 1000 ); case CSSPrimitiveValue.CSS_NUMBER : return (int) v; case CSSPrimitiveValue.CSS_PERCENTAGE : return (int) ( referenceLength * v / 100.0 ); } } return 0; }
Example 15
Source File: AbstractLengthManager.java From birt with Eclipse Public License 1.0 | 4 votes |
/** * Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}. */ public Value createValue( LexicalUnit lu, CSSEngine engine ) throws DOMException { switch ( lu.getLexicalUnitType( ) ) { case LexicalUnit.SAC_EM : return new FloatValue( CSSPrimitiveValue.CSS_EMS, lu .getFloatValue( ) ); case LexicalUnit.SAC_EX : return new FloatValue( CSSPrimitiveValue.CSS_EXS, lu .getFloatValue( ) ); case LexicalUnit.SAC_PIXEL : return new FloatValue( CSSPrimitiveValue.CSS_PX, lu .getFloatValue( ) ); case LexicalUnit.SAC_CENTIMETER : return new FloatValue( CSSPrimitiveValue.CSS_CM, lu .getFloatValue( ) ); case LexicalUnit.SAC_MILLIMETER : return new FloatValue( CSSPrimitiveValue.CSS_MM, lu .getFloatValue( ) ); case LexicalUnit.SAC_INCH : return new FloatValue( CSSPrimitiveValue.CSS_IN, lu .getFloatValue( ) ); case LexicalUnit.SAC_POINT : return new FloatValue( CSSPrimitiveValue.CSS_PT, lu .getFloatValue( ) ); case LexicalUnit.SAC_PICA : return new FloatValue( CSSPrimitiveValue.CSS_PC, lu .getFloatValue( ) ); case LexicalUnit.SAC_INTEGER : return new FloatValue( CSSPrimitiveValue.CSS_NUMBER, lu .getIntegerValue( ) ); case LexicalUnit.SAC_REAL : return new FloatValue( CSSPrimitiveValue.CSS_NUMBER, lu .getFloatValue( ) ); case LexicalUnit.SAC_PERCENTAGE : return new FloatValue( CSSPrimitiveValue.CSS_PERCENTAGE, lu .getFloatValue( ) ); } throw createInvalidLexicalUnitDOMException( lu.getLexicalUnitType( ) ); }
Example 16
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, "" ); }