/** * Return an integer value from 0-255 for a component of an RGB color. * * @param color typed value from the CSS parser, which may be an INTEGER or a * PERCENTAGE * @return integer value from 0-255 * @throws IllegalArgumentException if the color is not an INTEGER or * PERCENTAGE value */ private static int getRgbComponentValue(LexicalUnit color) { switch (color.getLexicalUnitType()) { case LexicalUnit.SAC_INTEGER: return Math.min(color.getIntegerValue(), 255); case LexicalUnit.SAC_PERCENTAGE: return (int) Math.min(color.getFloatValue() * 255, 255); default: throw new CSSException(CSSException.SAC_SYNTAX_ERR, "RGB component value must be integer or percentage, was " + color, null); } }
public short getCssValueType() { if (value_ instanceof List) { return CSS_VALUE_LIST; } if ((value_ instanceof LexicalUnit) && (((LexicalUnit) value_).getLexicalUnitType() == LexicalUnit.SAC_INHERIT)) { return CSS_INHERIT; } return CSS_PRIMITIVE_VALUE; }
private boolean isIdentOrNumber(LexicalUnit lu) { short type = lu.getLexicalUnitType(); switch (type) { case LexicalUnit.SAC_IDENT: case LexicalUnit.SAC_INTEGER: return true; default: return false; } }
private void expectComma(LexicalUnit lu) { if (lu.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { throw createInvalidLexicalUnitDOMException (lu.getLexicalUnitType()); } }
private void expectIdent(LexicalUnit lu) { if (lu.getLexicalUnitType() != LexicalUnit.SAC_IDENT) { throw createInvalidLexicalUnitDOMException (lu.getLexicalUnitType()); } }
private void expectComma(LexicalUnit lu) { if (lu.getLexicalUnitType() != LexicalUnit.SAC_OPERATOR_COMMA) { throw createInvalidLexicalUnitDOMException (lu.getLexicalUnitType()); } }
private static Value valueOf(LexicalUnit value) { switch (value.getLexicalUnitType()) { case LexicalUnit.SAC_ATTR: return new IdentValue("attr(" + value.getStringValue() + ")"); + value.getLexicalUnitType());
/** * Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}. */ public Value createValue(LexicalUnit lu, CSSEngine engine) throws DOMException { if (lu.getLexicalUnitType() == LexicalUnit.SAC_INHERIT) { return SVGValueConstants.INHERIT_VALUE; } return super.createValue(lu, engine); }
public Value createValue(LexicalUnit lu, CSSEngine engine) throws DOMException { if (lu.getLexicalUnitType() == LexicalUnit.SAC_INHERIT) { return InheritValue.INSTANCE; } return super.createValue(lu, engine); } }
/** * Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}. */ public Value createValue(LexicalUnit lu, CSSEngine engine) throws DOMException { if (lu.getLexicalUnitType() == LexicalUnit.SAC_INHERIT) { return SVGValueConstants.INHERIT_VALUE; } return super.createValue(lu, engine); }
protected CSSValue lookupValue( final LexicalUnit value ) { if ( value.getLexicalUnitType() != LexicalUnit.SAC_IDENT ) { return null; } return (CSSValue) constants.get( value.getStringValue().toLowerCase() ); }
private static String parseAttributeType( LexicalUnit unit ) { if ( unit == null ) { return null; } if ( unit.getLexicalUnitType() == LexicalUnit.SAC_IDENT ) { return unit.getStringValue(); } return null; }
public static CSSPrimitiveValue newPrimitiveValue(LexicalUnit value) { if (value.getLexicalUnitType() == LexicalUnit.SAC_RGBCOLOR) { // RGBColor return new RGBColorImpl(value); } //TODO add cases for Rect, Counter return new Measure(value); }
protected CSSValue parseValue( final LexicalUnit value ) { if ( value.getLexicalUnitType() == LexicalUnit.SAC_URI ) { return new CSSStringValue( CSSStringType.URI, value.getStringValue() ); } else if ( value.getLexicalUnitType() == LexicalUnit.SAC_STRING_VALUE ) { return new CSSStringValue( CSSStringType.STRING, value.getStringValue() ); } return null; } }
protected CSSValue parseWidth( final LexicalUnit value ) { if ( value.getLexicalUnitType() == LexicalUnit.SAC_IDENT ) { if ( value.getStringValue().equalsIgnoreCase( "dash" ) ) { return TextDecorationWidth.DASH; } if ( value.getStringValue().equalsIgnoreCase( "bold" ) ) { return TextDecorationWidth.BOLD; } } return super.parseWidth( value ); }
public CSSValue createValue( StyleKey name, LexicalUnit value ) { if ( value.getLexicalUnitType() == LexicalUnit.SAC_INTEGER ) { return CSSNumericValue.createValue( CSSNumericType.NUMBER, value.getIntegerValue() ); } return null; }
public CSSValue createValue( StyleKey name, LexicalUnit value ) { if ( value.getLexicalUnitType() == LexicalUnit.SAC_IDENT ) { if ( value.getStringValue().equalsIgnoreCase( "none" ) ) { return new CSSConstant( "none" ); } } return CSSValueFactory.createNumericValue( value ); } }
public CSSValue createValue( StyleKey name, LexicalUnit value ) { if ( value.getLexicalUnitType() == LexicalUnit.SAC_IDENT ) { if ( value.getStringValue().equalsIgnoreCase( "none" ) ) { return new CSSValueList( new CSSValue[] { KerningMode.NONE } ); } } return super.createValue( name, value ); } }
public CSSValue createValue( StyleKey name, LexicalUnit value ) { if ( value.getLexicalUnitType() != LexicalUnit.SAC_IDENT ) { return null; } String ident = value.getStringValue(); if ( ident.equalsIgnoreCase( "auto" ) ) { return CSSAutoValue.getInstance(); } return new CSSConstant( ident ); } }
protected CSSValue lookupValue( final LexicalUnit value ) { CSSValue constant = super.lookupValue( value ); if ( constant != null ) { return constant; } else if ( value.getLexicalUnitType() == LexicalUnit.SAC_PERCENTAGE ) { return CSSNumericValue.createValue( CSSNumericType.PERCENTAGE, value.getFloatValue() ); } return CSSValueFactory.createLengthValue( value ); } }