Java Code Examples for org.w3c.css.sac.LexicalUnit#SAC_CENTIMETER
The following examples show how to use
org.w3c.css.sac.LexicalUnit#SAC_CENTIMETER .
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: Measure.java From tm4e with Eclipse Public License 1.0 | 5 votes |
public short getPrimitiveType() { switch (value.getLexicalUnitType()) { case LexicalUnit.SAC_IDENT: return CSS_IDENT; case LexicalUnit.SAC_INTEGER: case LexicalUnit.SAC_REAL: return CSS_NUMBER; case LexicalUnit.SAC_URI: return CSS_URI; case LexicalUnit.SAC_PERCENTAGE: return CSS_PERCENTAGE; case LexicalUnit.SAC_PIXEL: return CSS_PX; case LexicalUnit.SAC_CENTIMETER: return CSS_CM; case LexicalUnit.SAC_EM: return CSS_EMS; case LexicalUnit.SAC_EX: return CSS_EXS; case LexicalUnit.SAC_INCH: return CSS_IN; case LexicalUnit.SAC_STRING_VALUE: return CSS_STRING; case LexicalUnit.SAC_DIMENSION: return CSS_DIMENSION; case LexicalUnit.SAC_OPERATOR_COMMA: return CSS_CUSTOM; // TODO don't think this is right, see bug // #278139 case LexicalUnit.SAC_INHERIT: return CSS_INHERIT; } // TODO Auto-generated method stub throw new UnsupportedOperationException( "NOT YET IMPLEMENTED - LexicalUnit type: " + value.getLexicalUnitType()); }
Example 2
Source File: Measure.java From tm4e with Eclipse Public License 1.0 | 5 votes |
public String getCssText() { // TODO: All LexicalUnit.SAC_OPERATOR_* except for COMMA left undone for // now as it's not even clear whether they should be treated as measures // see bug #278139 switch (value.getLexicalUnitType()) { case LexicalUnit.SAC_INTEGER: return String.valueOf(value.getIntegerValue()); case LexicalUnit.SAC_REAL: return String.valueOf(value.getFloatValue()); case LexicalUnit.SAC_PERCENTAGE: case LexicalUnit.SAC_PIXEL: case LexicalUnit.SAC_CENTIMETER: case LexicalUnit.SAC_EM: case LexicalUnit.SAC_EX: case LexicalUnit.SAC_PICA: case LexicalUnit.SAC_POINT: case LexicalUnit.SAC_INCH: case LexicalUnit.SAC_DEGREE: return String.valueOf(value.getFloatValue()) + value.getDimensionUnitText(); case LexicalUnit.SAC_URI: return "url(" + value.getStringValue() + ")"; case LexicalUnit.SAC_OPERATOR_COMMA: return ","; case LexicalUnit.SAC_INHERIT: return "inherit"; } return value.getStringValue(); }
Example 3
Source File: CSSValueFactory.java From pentaho-reporting with GNU Lesser General Public License v2.1 | 5 votes |
public static CSSNumericValue createLengthValue( LexicalUnit value ) { final short lexicalUnitType = value.getLexicalUnitType(); if ( lexicalUnitType == LexicalUnit.SAC_INTEGER ) { if ( value.getFloatValue() != 0 ) { return null; } return CSSNumericValue.createValue( CSSNumericType.PT, 0 ); } if ( lexicalUnitType == LexicalUnit.SAC_EM ) { return CSSNumericValue.createValue( CSSNumericType.EM, value.getFloatValue() ); } else if ( lexicalUnitType == LexicalUnit.SAC_EX ) { return CSSNumericValue.createValue( CSSNumericType.EX, value.getFloatValue() ); } else if ( lexicalUnitType == LexicalUnit.SAC_PIXEL ) { return CSSNumericValue.createValue( CSSNumericType.PX, value.getFloatValue() ); } else if ( lexicalUnitType == LexicalUnit.SAC_INCH ) { return CSSNumericValue.createValue( CSSNumericType.INCH, value.getFloatValue() ); } else if ( lexicalUnitType == LexicalUnit.SAC_CENTIMETER ) { return CSSNumericValue.createValue( CSSNumericType.CM, value.getFloatValue() ); } else if ( lexicalUnitType == LexicalUnit.SAC_MILLIMETER ) { return CSSNumericValue.createValue( CSSNumericType.MM, value.getFloatValue() ); } else if ( lexicalUnitType == LexicalUnit.SAC_PICA ) { return CSSNumericValue.createValue( CSSNumericType.PC, value.getFloatValue() ); } else if ( lexicalUnitType == LexicalUnit.SAC_POINT ) { return CSSNumericValue.createValue( CSSNumericType.PT, value.getFloatValue() ); } return null; }
Example 4
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 5
Source File: CSSValue.java From birt with Eclipse Public License 1.0 | 4 votes |
public short getPrimitiveType( ) { if ( value instanceof LexicalUnit ) { LexicalUnit lu = (LexicalUnit) value; switch ( lu.getLexicalUnitType( ) ) { case LexicalUnit.SAC_INHERIT : return CSS_IDENT; case LexicalUnit.SAC_INTEGER : case LexicalUnit.SAC_REAL : return CSS_NUMBER; case LexicalUnit.SAC_EM : return CSS_EMS; case LexicalUnit.SAC_EX : return CSS_EXS; case LexicalUnit.SAC_PIXEL : return CSS_PX; case LexicalUnit.SAC_INCH : return CSS_IN; case LexicalUnit.SAC_CENTIMETER : return CSS_CM; case LexicalUnit.SAC_MILLIMETER : return CSS_MM; case LexicalUnit.SAC_POINT : return CSS_PT; case LexicalUnit.SAC_PICA : return CSS_PC; case LexicalUnit.SAC_PERCENTAGE : return CSS_PERCENTAGE; case LexicalUnit.SAC_URI : return CSS_URI; case LexicalUnit.SAC_DEGREE : return CSS_DEG; case LexicalUnit.SAC_GRADIAN : return CSS_GRAD; case LexicalUnit.SAC_RADIAN : return CSS_RAD; case LexicalUnit.SAC_MILLISECOND : return CSS_MS; case LexicalUnit.SAC_SECOND : return CSS_S; case LexicalUnit.SAC_HERTZ : return CSS_KHZ; case LexicalUnit.SAC_KILOHERTZ : return CSS_HZ; case LexicalUnit.SAC_IDENT : return CSS_IDENT; case LexicalUnit.SAC_STRING_VALUE : return CSS_STRING; case LexicalUnit.SAC_ATTR : return CSS_ATTR; case LexicalUnit.SAC_UNICODERANGE : case LexicalUnit.SAC_SUB_EXPRESSION : case LexicalUnit.SAC_FUNCTION : return CSS_STRING; case LexicalUnit.SAC_DIMENSION : return CSS_DIMENSION; } } return CSS_UNKNOWN; }