⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stylesheet.java

📁 j2me is based on j2mepolish, client & server for mobile application. menu sample
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
			//# System.out.println("trying " + fullStyleName);
			//# style = (Style) stylesByName.get( fullStyleName );
			//# if (style != null) {
				//# return style;
			//# }
			//# // 1. try: "screen item":
			//# String styleName = screenCssSelector + " " + itemCssSelector;
			//#debug
			//# System.out.println("trying " + styleName);
			//# style = (Style) stylesByName.get( styleName );
			//# if (style == null) {
				//# // 2. try: "screen*item":
				//# styleName = screenCssSelector + "*" + itemCssSelector;
				//#debug
				//# System.out.println("trying " + styleName);
				//# style = (Style) stylesByName.get( styleName );
				//# if (style == null) {
					//# // 3. try: "parent>item"
					//# styleName = parentCssSelector + ">" + itemCssSelector;
					//#debug
					//# System.out.println("trying " + styleName);
					//# style = (Style) stylesByName.get( styleName );
					//# if (style == null) {
						//# // 4. try: "parent item"
						//# styleName = parentCssSelector + " " + itemCssSelector;
						//#debug
						//# System.out.println("trying " + styleName);
						//# style = (Style) stylesByName.get( styleName );
					//# }
				//# }
			//# }
			//#debug
			//# System.out.println("found style: " + (style != null));
		//# } else {
			//#debug
			//# System.out.println("so far unable to set style: complex item setup");
			//# // this is a tiny bit more complicated....
			//# fullStyleName = null;
		//# }
		//# if (style == null) {
			//# // try just the item:
			//#debug
			//# System.out.println("trying " + itemCssSelector);
			//# style = (Style) stylesByName.get( itemCssSelector );
			//# if (style == null) {
				//#debug
				//# System.out.println("Using default style for item " + item.getClass().getName() );
				//# style = defaultStyle;
			//# }
			//#ifdef polish.debug.debug
				//# else {
					//#debug
					//# System.out.println("Found style " + itemCssSelector );
				//# }
			//#endif
		//# }
		//# if ( fullStyleName != null && style != null ) {
			//# stylesByName.put( fullStyleName, style );
		//# }
		//# return style;
	//# }
	//#endif

	//#ifdef polish.useDynamicStyles
	//# /**
	 //# * Retrieves a dynamic style for the given screen.
	 //# * 
	 //# * @param screen the screen for which a style should be retrieved
	 //# * @return the style for the given screen.
	 //# */
	//# public static Style getStyle(Screen screen) {
		//# Style style = (Style) stylesByName.get( screen.cssSelector );
		//# if (style == null) {
			//# return defaultStyle;
		//# }
		//# return style;
	//# }		
	//#endif
	
	/**
	 * Includes an animation while changing the screen.
	 *  
	 * @param display the display
	 * @param nextDisplayable the new screen, animations are only included for de.enough.polish.ui.Screen classes
	 */
	public static void setCurrent( Display display, Displayable nextDisplayable ) {
		Displayable lastDisplayable = null;
		//#if polish.Bugs.displaySetCurrentFlickers && polish.useFullScreen
			//# if ( MasterCanvas.instance != null ) {
				//# lastDisplayable = MasterCanvas.instance.currentDisplayable;
			//# }
		//#else
			lastDisplayable = display.getCurrent();
		//#endif
		if (nextDisplayable instanceof Alert) {
			Alert alert = (Alert) nextDisplayable;
			if (alert.nextDisplayable == null) {
				alert.nextDisplayable = lastDisplayable;
			}
		}
		//#if !(polish.css.screen-change-animation || polish.ScreenChangeAnimation.forward:defined)
			//#if polish.Bugs.displaySetCurrentFlickers && polish.useFullScreen
				//# MasterCanvas.setCurrent(display, nextDisplayable);
			//#else
				display.setCurrent( nextDisplayable );						
			//#endif			
		//#else
		//# if ( nextDisplayable instanceof AccessibleCanvas ) {
			//#if polish.ScreenChangeAnimation.allowConfiguration == true
				//# if (!enableScreenChangeAnimations) {
					//#if polish.Bugs.displaySetCurrentFlickers && polish.useFullScreen
						//# MasterCanvas.setCurrent(display, nextDisplayable);
					//#else
						//# display.setCurrent( nextDisplayable );						
					//#endif
					//# return;	
				//# }
			//#endif
//# 
			//# try {
				//# Screen nextScreen = null;
				//# if ( nextDisplayable instanceof Screen ) {
					//# nextScreen = (Screen) nextDisplayable;
				//# }
				//# ScreenChangeAnimation screenAnimation = null;
//# 	
				//# 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;
						//# if (nextScreen != null) {
							//# screenstyle = nextScreen.style;
						//# }
					//# }
				//#else					
					//# if (nextScreen != null && nextScreen.style != null) {
						//# screenstyle = nextScreen.style;
						//# screenAnimation = (ScreenChangeAnimation) screenstyle.getObjectProperty(62);
					//# }
					//# if (lastDisplayable != null && lastDisplayable instanceof ScreenChangeAnimation ) {
						//#debug
						//# System.out.println("StyleSheet: last displayable is a ScreenChangeAnimation" );
						//# lastDisplayable = ((ScreenChangeAnimation) lastDisplayable).nextDisplayable;
					//# }
					//# 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(62);
							//#debug
							//# System.out.println("StyleSheet: Using screen animation of last screen");
						//# }
					//# }
					//#if polish.Screen.showScreenChangeAnimationOnlyForScreen
						//# if ( nextScreen == null ) {
							//# screenAnimation = null;
						//# }
					//#endif
					//# if ( screenAnimation == null ) {
						//#debug
						//# System.out.println("StyleSheet: found no screen animation");
						//#if polish.Bugs.displaySetCurrentFlickers && polish.useFullScreen
							//# MasterCanvas.setCurrent(display, nextDisplayable);
						//#else
							//# display.setCurrent( nextDisplayable );						
						//#endif
						//# return;
					//# }
				//#endif
//# 				
				//# int width;
				//# int height;
				//#if polish.FullCanvasSize:defined
					//#= width = ${polish.FullCanvasWidth};
					//#= height = ${polish.FullCanvasHeight};
				//#else
					//#if polish.midp2
						//# width = nextDisplayable.getWidth();
						//# height = nextDisplayable.getHeight();
					//#else
						//# if (nextScreen != null) {
							//# width = lastScreen.getWidth();
							//# height = lastScreen.getHeight();
						//# } else if (nextDisplayable instanceof Canvas) {
							//# width = ((Canvas) nextDisplayable).getWidth();
							//# height = ((Canvas) nextDisplayable).getHeight();
						//# } else {
							//# Canvas canvas = new Canvas() {
								//# public void paint( Graphics g) {}
							//# };
							//# width = canvas.getWidth();
							//# height = canvas.getHeight();
						//# }
					//#endif
				//#endif
				//# Image lastScreenImage = Image.createImage(width, height);
				//# Graphics g = lastScreenImage.getGraphics(); 
				//# if ( lastDisplayable != null && lastDisplayable instanceof AccessibleCanvas) {
					//#debug
					//# System.out.println("StyleSheet: last screen is painted");
					//# ( (AccessibleCanvas)lastDisplayable).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();
				//# AccessibleCanvas nextCanvas = (AccessibleCanvas) nextDisplayable;
				//# nextCanvas.showNotify();
				//# nextCanvas.paint( g );
				//#debug
				//# System.out.println("StyleSheet: showing screen animation " + screenAnimation.getClass().getName() );
				//# if ( screenstyle == null ) {
					//# screenstyle = defaultStyle;
				//# }
				//# screenAnimation.show( screenstyle, display, width, height, lastScreenImage, nextScreenImage, nextCanvas, nextDisplayable );
			//# } catch (Exception e) {
				//#debug error
				//# System.out.println("Screen: unable to start screen change animation" + e );
				//#if polish.Bugs.displaySetCurrentFlickers && polish.useFullScreen
					//# MasterCanvas.setCurrent(display, nextDisplayable);
				//#else
					//# display.setCurrent( nextDisplayable );						
				//#endif
			//# }
//# 			
		//# } else {
			//#if polish.Bugs.displaySetCurrentFlickers && polish.useFullScreen
				//# MasterCanvas.setCurrent(display, nextDisplayable);
			//#else
				//# display.setCurrent( nextDisplayable );						
			//#endif
		//# }
		//#endif
	}
	
	/**
	 * Releases all (memory intensive) resources such as images or RGB arrays of this style sheet.
	 */
	public static void releaseResources() {
		//#if polish.allowImageCaching != false
		if (imagesByName != null) {
			imagesByName.clear();
		}
		//#endif
		//#ifdef polish.useDynamicStyles
			//# Enumeration enumeration = stylesByName.elements();
			//# while (enumeration.hasMoreElements()) {
				//# Style style = (Style) enumeration.nextElement();
				//# style.releaseResources();
			//# }
		//#endif
		//#ifdef polish.StyleSheet.releaseResources:defined
			//#include ${polish.StyleSheet.releaseResources}
		//#endif
	}


	public static Style[] getDynamicStyles() {
		//#if polish.inSkinEditor == true
			//# return (Style[]) dynamicStylesList.toArray( new Style[ dynamicStylesList.size() ] );
			//# }
		//#else
//			java.util.Enumeration enumeration = dynamicStylesByName.elements();
//			Style[] styles = new Style[ dynamicStylesByName.size() ];
//			for (int i=0; i<styles.length; i++) {
//				styles[i] = (Style) enumeration.nextElement();
//			}
//			return styles;
			return new Style[]{ defaultStyle, focusedStyle };
		//#endif
	}
	
	
//#ifdef polish.StyleSheet.additionalMethods:defined
	//#include ${polish.StyleSheet.additionalMethods}
//#endif

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -