StyledDOMOptimizer optimizer = createStyledDOMOptimizer(configuration,
context);
// Create the generator.
DOMThemeGenerator generator = new DefaultDOMThemeGenerator();
RuleBuilderFactory ruleBuilderFactory = new RuleBuilderFactory();
// Add the type rule extractor, but only if type rules are to be
// generated.
if (context.generateTypeRules()) {
RuleExtractor typeRuleExtractor = new TypeRuleExtractor(
ruleBuilderFactory);
generator.addRuleExtractor(typeRuleExtractor);
}
// Add the class rule extractor.
StylesClassRuleExtractorFactory stylesClassRuleExtractorFactory =
new StylesClassRuleExtractorFactoryImpl(ruleBuilderFactory);
RuleExtractor classRuleExtractor = new ClassRuleExtractor(
stylesClassRuleExtractorFactory,
OptimalClassNameGenerator.getDefaultInstance());
generator.addRuleExtractor(classRuleExtractor);
// Add the rule group extractor.
RuleExtractor groupRuleExtractor = new GroupRuleExtractor();
generator.addRuleExtractor(groupRuleExtractor);
// Create the extractor which uses both the optimizer and the
// generator and return it.
return new DefaultStyledDOMThemeExtractor(optimizer, generator);
}