SynthStyle getSeaGlassStyle ( JComponent c , Region r ) { // validate method arguments if ( c == null || r == null ) { throw new IllegalArgumentException ( "Neither comp nor r may be null" ) ; } // if there are no lazy styles registered for the region r, then return // the default style List < LazyStyle > styles = styleMap . get ( r ) ; if ( styles == null || styles . size ( ) == 0 ) { return getDefaultStyle ( ) ; } // Look for the best SynthStyle for this component/region pair. LazyStyle foundStyle = null ; for ( LazyStyle s : styles ) { if ( s . matches ( c ) ) { /* * Replace the foundStyle if foundStyle is null, or if the new * style "s" is more specific (ie, its path was longer), or if * the foundStyle was "simple" and the new style was not (ie: * the foundStyle was for something like Button and the new * style was for something like "MyButton", hence, being more * specific). In all cases, favor the most specific style found. */ if ( foundStyle == null || ( foundStyle . parts . length < s . parts . length ) || ( foundStyle . parts . length == s . parts . length && foundStyle . simple && ! s . simple ) ) { foundStyle = s ; } } } // return the style, if found, or the default style if not found return foundStyle == null ? getDefaultStyle ( ) : foundStyle . getStyle ( c ) ; }
Locate the style associated with the given region and component . This is called from SeaGlassLookAndFeel in the SynthStyleFactory implementation .