Screen nextScreen = (Screen) nextDisplayable;
Screen nextScreen = null; if ( nextDisplayable instanceof Screen ) { nextScreen = (Screen) nextDisplayable; }
	public static void setCurrent( Display display, Displayable nextDisplayable ) {		if ( nextDisplayable instanceof Screen ) {			//#if polish.ScreenChangeAnimation.allowConfiguration == true				if (!enableScreenChangeAnimations) {					//#if polish.Bugs.displaySetCurrentFlickers						MasterCanvas.setCurrent(display, nextDisplayable);					//#else						display.setCurrent( nextDisplayable );											//#endif				}			//#endif			try {				Screen nextScreen = (Screen) nextDisplayable;				ScreenChangeAnimation screenAnimation = null;				Displayable lastDisplayable = null;				//#if polish.Bugs.displaySetCurrentFlickers					if ( MasterCanvas.instance != null ) {						//# lastDisplayable = MasterCanvas.instance.currentDisplayable;					}				//#else					lastDisplayable = display.getCurrent();				//#endif					Screen lastScreen = null;				Style screenstyle = null;				//#if polish.ScreenChangeAnimation.forward:defined					if (lastDisplayable != null && lastDisplayable instanceof Screen) {						lastScreen = (Screen) lastDisplayable;						Command lastCommand = lastScreen.lastTriggeredCommand;						if (lastCommand != null && lastCommand.getCommandType() == Command.BACK ) {							screenAnimation = backwardAnimation;							screenstyle = lastScreen.style;						}					}					if ( screenAnimation == null ) {						screenAnimation = forwardAnimation;						screenstyle = nextScreen.style;					}				//#else					if (nextScreen.style != null) {						screenstyle = nextScreen.style;						screenAnimation = (ScreenChangeAnimation) screenstyle.getObjectProperty("screen-change-animation");					}					if (lastDisplayable != null && lastDisplayable instanceof ScreenChangeAnimation ) {						//#debug						System.out.println("StyleSheet: last displayable is a ScreenChangeAnomation" );						lastDisplayable = ((ScreenChangeAnimation) lastDisplayable).nextScreen;					}					if (lastDisplayable != null && lastDisplayable instanceof Screen) {						//#debug						System.out.println("StyleSheet: last displayble is a Screen");						lastScreen = (Screen) lastDisplayable;						if (screenAnimation == null && lastScreen.style != null) {							screenstyle = lastScreen.style;							screenAnimation = (ScreenChangeAnimation) screenstyle.getObjectProperty("screen-change-animation");							//#debug							System.out.println("StyleSheet: Using screen animation of last screen");						}					}					if ( screenAnimation == null ) {						//#debug						System.out.println("StyleSheet: found no screen animation");						//#if polish.Bugs.displaySetCurrentFlickers							MasterCanvas.setCurrent(display, nextDisplayable);						//#else							display.setCurrent( nextDisplayable );												//#endif						return;					}				//#endif								//#if polish.FullCanvasSize:defined					//#= int width = ${polish.FullCanvasWidth};					//#= int height = ${polish.FullCanvasHeight};				//#else					int width = nextScreen.getWidth();					int height = nextScreen.getHeight();				//#endif				Image lastScreenImage = Image.createImage(width, height);				Graphics g = lastScreenImage.getGraphics(); 				if ( lastScreen != null ) {					//#debug					System.out.println("StyleSheet: last screen is painted");					lastScreen.paint( g );				//#if polish.ScreenChangeAnimation.blankColor:defined					} else {						//#= g.setColor( ${polish.ScreenChangeAnimation.blankColor} );						g.fillRect( 0, 0, width, height );				//#endif				}				Image nextScreenImage = Image.createImage(width, height);				g = nextScreenImage.getGraphics();				nextScreen.showNotify();				nextScreen.paint( g );				//#debug				System.out.println("StyleSheet: showing screen animation");				//#if ! polish.ScreenChangeAnimation.forward:defined					//screenAnimation = (ScreenChangeAnimation) screenAnimation.getClass().newInstance();				//#endif				screenAnimation.show( screenstyle, display, width, height, lastScreenImage, nextScreenImage, nextScreen );			} catch (Exception e) {				//#debug error				System.out.println("Screen: unable to copy screen change animation" + e );				display.setCurrent( nextDisplayable );			}					} else {			//#if polish.Bugs.displaySetCurrentFlickers				MasterCanvas.setCurrent(display, nextDisplayable);			//#else				display.setCurrent( nextDisplayable );									//#endif		}	}