/** * Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}. */ public Value createValue(LexicalUnit lu, CSSEngine engine) throws DOMException { if (lu.getLexicalUnitType() == LexicalUnit.SAC_RGBCOLOR) { lu = lu.getParameters(); Value red = createColorComponent(lu); lu = lu.getNextLexicalUnit().getNextLexicalUnit(); Value green = createColorComponent(lu); lu = lu.getNextLexicalUnit().getNextLexicalUnit(); Value blue = createColorComponent(lu); return createRGBColor(red, green, blue); } return super.createValue(lu, engine); }
private DOMException createInvalidRGBComponentUnitDOMException (short type) { Object[] p = new Object[] { getPropertyName(), new Integer(type) }; String s = Messages.formatMessage("invalid.rgb.component.unit", p); return new DOMException(DOMException.NOT_SUPPORTED_ERR, s); }
/** * Creates a color component from a lexical unit. */ protected Value createColorComponent(LexicalUnit lu) throws DOMException { switch (lu.getLexicalUnitType()) { 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 createInvalidRGBComponentUnitDOMException (lu.getLexicalUnitType()); }
/** * Creates a color component from a lexical unit. */ protected Value createColorComponent(LexicalUnit lu) throws DOMException { switch (lu.getLexicalUnitType()) { 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 createInvalidRGBComponentUnitDOMException (lu.getLexicalUnitType()); }
/** * Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}. */ public Value createValue(LexicalUnit lu, CSSEngine engine) throws DOMException { if (lu.getLexicalUnitType() == LexicalUnit.SAC_RGBCOLOR) { lu = lu.getParameters(); Value red = createColorComponent(lu); lu = lu.getNextLexicalUnit().getNextLexicalUnit(); Value green = createColorComponent(lu); lu = lu.getNextLexicalUnit().getNextLexicalUnit(); Value blue = createColorComponent(lu); return createRGBColor(red, green, blue); } return super.createValue(lu, engine); }
/** * Creates a color component from a lexical unit. */ protected Value createColorComponent(LexicalUnit lu) throws DOMException { switch (lu.getLexicalUnitType()) { 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 createInvalidRGBComponentUnitDOMException (lu.getLexicalUnitType()); }
private DOMException createInvalidRGBComponentUnitDOMException (short type) { Object[] p = new Object[] { getPropertyName(), (int) type}; String s = Messages.formatMessage("invalid.rgb.component.unit", p); return new DOMException(DOMException.NOT_SUPPORTED_ERR, s); }
/** * Implements {@link ValueManager#createValue(LexicalUnit,CSSEngine)}. */ public Value createValue(LexicalUnit lu, CSSEngine engine) throws DOMException { if (lu.getLexicalUnitType() == LexicalUnit.SAC_RGBCOLOR) { lu = lu.getParameters(); Value red = createColorComponent(lu); lu = lu.getNextLexicalUnit().getNextLexicalUnit(); Value green = createColorComponent(lu); lu = lu.getNextLexicalUnit().getNextLexicalUnit(); Value blue = createColorComponent(lu); return createRGBColor(red, green, blue); } return super.createValue(lu, engine); }
private DOMException createInvalidRGBComponentUnitDOMException (short type) { Object[] p = new Object[] { getPropertyName(), (int) type}; String s = Messages.formatMessage("invalid.rgb.component.unit", p); return new DOMException(DOMException.NOT_SUPPORTED_ERR, s); }