protected void setupComputedBackgroundColor ( ) { // temp is just a widget created to evaluate the computed background // color MaterialWidget temp = new MaterialWidget ( Document . get ( ) . createDivElement ( ) ) ; temp . setBackgroundColor ( backgroundColor ) ; // setting a style to make it invisible for the user Style style = temp . getElement ( ) . getStyle ( ) ; style . setPosition ( Position . FIXED ) ; style . setWidth ( 1 , Unit . PX ) ; style . setHeight ( 1 , Unit . PX ) ; style . setLeft ( - 10 , Unit . PX ) ; style . setTop ( - 10 , Unit . PX ) ; style . setZIndex ( - 10000 ) ; // adding it to the body (on Chrome the component must be added to the // DOM before getting computed values). String computed = ColorHelper . setupComputedBackgroundColor ( backgroundColor ) ; // convert rgb to rgba, considering the opacity field if ( opacity < 1 && computed . startsWith ( "rgb(" ) ) { computed = computed . replace ( "rgb(" , "rgba(" ) . replace ( ")" , ", " + opacity + ")" ) ; } computedBackgroundColor = computed ; }
Gets the computed background color based on the backgroundColor CSS class .