/** * Converts a value to a color * * @param value * @return Color */ public static Color color(CSSValue value) { RGBColor rgbColorValue = ((CSSPrimitiveValue)value).getRGBColorValue(); int r = (int)rgbColorValue.getRed().getFloatValue(CSSPrimitiveValue.CSS_NUMBER); int g = (int)rgbColorValue.getGreen().getFloatValue(CSSPrimitiveValue.CSS_NUMBER); int b = (int)rgbColorValue.getBlue().getFloatValue(CSSPrimitiveValue.CSS_NUMBER); return new Color(r, g, b); }
private RGB createRGB(LexicalUnit value) { RGBColor rgbColor = new RGBColorImpl(value); int green = ((int) rgbColor.getGreen().getFloatValue(CSSPrimitiveValue.CSS_NUMBER)); int red = ((int) rgbColor.getRed().getFloatValue(CSSPrimitiveValue.CSS_NUMBER)); int blue = ((int) rgbColor.getBlue().getFloatValue(CSSPrimitiveValue.CSS_NUMBER)); return new RGB(red, green, blue); }
public static Color toSWTColor(Element element, String attributeName) { Document document = element.getOwnerDocument(); ViewCSS viewCSS = (ViewCSS) document.getDocumentElement(); CSSStyleDeclaration computedStyle = viewCSS.getComputedStyle(element, null); SVGPaint svgPaint = (SVGPaint) computedStyle.getPropertyCSSValue(attributeName); if (svgPaint.getPaintType() == SVGPaint.SVG_PAINTTYPE_RGBCOLOR) { RGBColor rgb = svgPaint.getRGBColor(); float red = rgb.getRed().getFloatValue(CSSValue.CSS_PRIMITIVE_VALUE); float green = rgb.getGreen().getFloatValue(CSSValue.CSS_PRIMITIVE_VALUE); float blue = rgb.getBlue().getFloatValue(CSSValue.CSS_PRIMITIVE_VALUE); return SWTResourceManager.getColor((int) red, (int) green, (int) blue); } return null; }
@Override public RGBColor getRGBColorValue() throws DOMException { if (value_ instanceof RGBColor) { return (RGBColor) value_; } throw new DOMExceptionImpl(DOMException.INVALID_ACCESS_ERR, DOMExceptionImpl.RGBCOLOR_ERROR); }
/** * 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 ) { CSSPrimitiveValue pvalue = (CSSPrimitiveValue) value; int primitiveType = pvalue.getPrimitiveType( ); if ( primitiveType == CSSPrimitiveValue.CSS_IDENT ) { String ident = pvalue.getStringValue( ); // Search for a direct computed value. Value v = (Value) computedValues.get( ident ); if ( v != null ) { return v; } // Must be a system color... if ( values.get( ident ) == null ) { throw new InternalError( ); } return (Value) engine.getCSSContext( ).getSystemColor( ident ); } if ( primitiveType == CSSPrimitiveValue.CSS_RGBCOLOR ) { RGBColor color = value.getRGBColorValue( ); CSSPrimitiveValue red = color.getRed( ); CSSPrimitiveValue green = color.getGreen( ); CSSPrimitiveValue blue = color.getBlue( ); return createRGBColor( createColorComponent( red ), createColorComponent( green ), createColorComponent( blue ) ); } } return super.computeValue( elt, engine, idx, value ); }
public RGBColor getRGBColorValue() throws DOMException { return this; }
public RGBColor getRGBColorValue() throws DOMException { throw new DOMException(DOMException.INVALID_ACCESS_ERR, "RGBCOLOR_ERROR"); }
public static ColorRGBA toColor(RGBColor rgb) { return new ColorRGBA(rgb.getRed().getPrimitiveType() / 255f, rgb.getGreen().getPrimitiveType() / 255f, rgb.getBlue().getPrimitiveType() / 255f, 1f); }
public RGBColor getRGBColorValue( ) throws DOMException { return this; }
public RGBColor getRGBColorValue( ) throws DOMException { throw createDOMException( ); }
public RGBColor getRGBColorValue( ) throws DOMException { return null; }
/** * <b>DOM</b>: Implements {@link * org.w3c.dom.css.CSSPrimitiveValue#getRGBColorValue()}. */ public RGBColor getRGBColorValue() throws DOMException { return this; }
/** * <b>DOM</b>: Implements {@link * org.w3c.dom.css.CSSPrimitiveValue#getRGBColorValue()}. */ public RGBColor getRGBColorValue() throws DOMException { throw new DOMException(DOMException.INVALID_ACCESS_ERR, ""); }
/** * <b>DOM</b>: Implements {@link * org.w3c.dom.svg.SVGColor#getRGBColor()}. */ public RGBColor getRGBColor() { return this; }
/** * Returns the RGBColor value for this SVGColor. * For the SVG 1.1 ECMAScript binding. */ public RGBColor getRgbColor() { return this; }
public RGBColor getRGBColor();