final TimeProvider timeProvider) {
String controller = getAttributes().get("controller");
ScreenController screenController = resolveScreenController(nifty, controller);
String id = getAttributes().get("id");
Screen screen = new Screen(nifty, id, screenController, timeProvider);
screen.setDefaultFocusElement(getAttributes().get("defaultFocusElement"));
String inputMappingClass = getAttributes().get("inputMapping");
if (inputMappingClass != null) {
NiftyInputMapping inputMapping = ClassHelper.getInstance(inputMappingClass, NiftyInputMapping.class);
if (!(screenController instanceof KeyInputHandler)) {
log.info("class [" + controller + "] tries to use inputMapping [" + inputMappingClass + "] but does not implement [" + KeyInputHandler.class.getName() + "]");
} else {
screen.addKeyboardInputHandler(inputMapping, KeyInputHandler.class.cast(screenController));
}
}
String inputMappingPreClass = getAttributes().get("inputMappingPre");
if (inputMappingPreClass != null) {
NiftyInputMapping inputMapping = ClassHelper.getInstance(inputMappingPreClass, NiftyInputMapping.class);
if (!(screenController instanceof KeyInputHandler)) {
log.info("class [" + controller + "] tries to use inputMapping [" + inputMappingPreClass + "] but does not implement [" + KeyInputHandler.class.getName() + "]");
} else {
screen.addPreKeyboardInputHandler(inputMapping, KeyInputHandler.class.cast(screenController));
}
}
Element rootElement = nifty.getRootLayerFactory().createRootLayer("root", nifty, screen, timeProvider);
screen.setRootElement(rootElement);
StopWatch stopWatch = new StopWatch(timeProvider);
stopWatch.start();
for (LayerType layerType : layers) {
layerType.prepare(nifty, screen, rootElement.getElementType());
}
Logger.getLogger(NiftyLoader.class.getName()).info("internal prepare screen (" + id + ") [" + stopWatch.stop() + "]");
stopWatch.start();
for (LayerType layerType : layers) {
LayoutPart layerLayout = nifty.getRootLayerFactory().createRootLayerLayoutPart(nifty);
screen.addLayerElement(
layerType.create(
rootElement,
nifty,
screen,
layerLayout));
}
Logger.getLogger(NiftyLoader.class.getName()).info("internal create screen (" + id + ") [" + stopWatch.stop() + "]");
screen.processAddAndRemoveLayerElements();
nifty.addScreen(id, screen);
}