StylingFactory stylingFactory = StylingFactory.getDefaultInstance();
StyleSheetCompilerFactory inlineCompilerFactory =
new InlineStyleSheetCompilerFactory(null);
StylingEngine stylingEngine = stylingFactory.createStylingEngine(inlineCompilerFactory);
// Create a CSS compiler.
CSSCompilerBuilder builder = new CSSCompilerBuilder();
builder.setStyleSheetCompilerFactory(
DefaultStyleSheetCompilerFactory.getDefaultInstance());
CSSCompiler cssCompiler = builder.getCSSCompiler();
// Compile and push the system default style sheet into the styling
// engine.
CompiledStyleSheet defaultCompiledStyleSheet;
try {
URL url = getClass().getResource("/com/volantis/mcs/runtime/default.css");
InputStream stream = url.openStream();
defaultCompiledStyleSheet = cssCompiler.compile(
new InputStreamReader(stream), null);
} catch (IOException e) {
throw new ExtendedRuntimeException(e);
}
stylingEngine.pushStyleSheet(defaultCompiledStyleSheet);
if (protocol != null &&
protocol.getCompiledDefaultStyleSheet() != null) {
// merge the default style sheet and the current one
stylingEngine.pushStyleSheet(
protocol.getCompiledDefaultStyleSheet());
}
return stylingEngine;
}