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

📄 screen.java

📁 j2me polish学习的经典代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
				// when the previous screen was in the "normal" mode:				//#if ! tmp.fullScreenInPaint					//# super.setFullScreenMode( true );				//#endif			//#endif					// init components:			int	width = this.screenWidth - (this.marginLeft + this.marginRight);			//#ifdef tmp.menuFullScreen				//#ifdef tmp.useExternalMenuBar					if (!this.menuBar.isInitialised) {						this.menuBar.init( width, width );					}				//#else					if (this.menuOpened) {						if (!this.menuContainer.isInitialised) {							this.menuContainer.init( width, width );						}					} else				//#endif			//#endif			if (this.container != null && !this.container.isInitialised) {				this.container.init( width, width );			}			if (this.gauge != null && !this.gauge.isInitialised) {				this.gauge.init( width, width );			}			//#ifdef tmp.usingTitle				if (this.title != null && !this.title.isInitialised) {					this.title.init( width, width );				}			//#endif			//#ifndef polish.skipTicker				if (this.ticker != null && !this.ticker.isInitialised) {					this.ticker.init( width, width );									}			//#endif			calculateContentArea(0, 0, this.screenWidth, this.screenHeight);		} catch (Exception e) {			//#debug error			System.out.println("error while calling showNotify" + e );		}		// register this screen:		StyleSheet.currentScreen = this;		//#ifdef polish.Vendor.Siemens			this.showNotifyTime = System.currentTimeMillis();		//#endif	}		/**	 * Unregisters this screen and notifies all items that they will not be shown anymore.	 */	public void hideNotify() {		//#if polish.css.repaint-previous-screen			//#if polish.Screen.dontBufferPreviousScreen				this.previousScreen = null;			//#else				this.previousScreenImage = null;			//#endif			//#if !polish.Bugs.noTranslucencyWithDrawRgb				this.previousScreenOverlayBackground = null;			//#endif		//#endif		//#ifdef polish.Vendor.Siemens			// Siemens sometimes calls hideNotify directly			// after showNotify for some reason.			// So hideNotify checks how long the screen			// has been shown - if not long enough,			// the call will be ignored:			if (System.currentTimeMillis() - this.showNotifyTime < 500) {				//#debug				System.out.println("Ignoring hideNotify on Siemens");				return;			}		//#endif		//#debug		System.out.println("hideNotify " + this);		//#if !polish.css.repaint-previous-screen			// un-register this screen:			if (StyleSheet.currentScreen == this) {				StyleSheet.currentScreen = null;			}		//#endif		Item[] items = getRootItems();		for (int i = 0; i < items.length; i++) {			Item item = items[i];			item.hideNotify();		}		if (this.container != null) {			this.container.hideNotify();		}		//#ifdef tmp.ignoreMotorolaTitleCall			this.ignoreMotorolaTitleCall = true;		//#endif	}		/**	 * Sets the style of this screen.	 * 	 * @param style the style	 */	public void setStyle(Style style) {		if (style != this.style ) {			this.style.releaseResources();		}	 			System.out.println("Setting screen-style for " + getClass().getName() );		this.style = style;		this.background = style.background;		this.border = style.border;		this.marginTop = style.marginTop;		this.marginBottom = style.marginBottom;		this.marginLeft = style.marginRight;		this.marginRight = style.marginRight;		if (this.container != null) {			// use the same style for the container - but ignore the background and border settings:			this.container.setStyle(style, true);		}		this.isLayoutVCenter = (( style.layout & Item.LAYOUT_VCENTER ) == Item.LAYOUT_VCENTER);		this.isLayoutBottom = !this.isLayoutVCenter 							&& (( style.layout & Item.LAYOUT_BOTTOM ) == Item.LAYOUT_BOTTOM);		this.isLayoutCenter = (( style.layout & Item.LAYOUT_CENTER ) == Item.LAYOUT_CENTER);		this.isLayoutRight = !this.isLayoutCenter							&& (( style.layout & Item.LAYOUT_RIGHT ) == Item.LAYOUT_RIGHT);		this.isLayoutHorizontalShrink = (style.layout & Item.LAYOUT_SHRINK) == Item.LAYOUT_SHRINK; 		this.isLayoutVerticalShrink = (style.layout & Item.LAYOUT_VSHRINK) == Item.LAYOUT_VSHRINK; 		//#if polish.css.scrollindicator-up-image && !tmp.useScrollBar			String scrollUpUrl = style.getProperty("scrollindicator-up-image");			if (scrollUpUrl != null) {				try {					this.scrollIndicatorUpImage = StyleSheet.getImage(scrollUpUrl, null, true);				} catch (IOException e) {					//#debug error					System.out.println("Unable to load scroll up image" + e );				}			} else {				this.scrollIndicatorUpImage = null;			}		//#endif				//#if polish.css.scrollindicator-down-image && !tmp.useScrollBar			String scrollDownUrl = style.getProperty("scrollindicator-down-image");			if (scrollDownUrl != null) {				try {					this.scrollIndicatorDownImage = StyleSheet.getImage(scrollDownUrl, null, true);				} catch (IOException e) {					//#debug error					System.out.println("Unable to load scroll down image" + e );				}			} else {				this.scrollIndicatorDownImage = null;			}		//#endif				//#if polish.css.scrollindicator-up-image && polish.css.scrollindicator-down-image && !tmp.useScrollBar			if (this.scrollIndicatorUpImage != null && this.scrollIndicatorDownImage != null) {				int height = this.scrollIndicatorUpImage.getHeight() + this.scrollIndicatorDownImage.getHeight();				int width = Math.max( this.scrollIndicatorUpImage.getWidth(), this.scrollIndicatorDownImage.getWidth() );				this.scrollIndicatorWidth = width;				this.scrollIndicatorX = this.screenWidth / 2 - width / 2;				//#ifdef tmp.menuFullScreen					//#ifdef tmp.useExternalMenuBar						this.scrollIndicatorY = this.fullScreenHeight - (this.menuBar.marginBottom + 1 + height);					//#else						this.scrollIndicatorY = this.fullScreenHeight - (height + 1);					//#endif									//#elif polish.vendor.Siemens					// set the position of scroll indicator for Siemens devices 					// on the left side, so that the menu-indicator is visible:					this.scrollIndicatorWidth = width;					this.scrollIndicatorX = 0;					this.scrollIndicatorY = this.screenHeight - height - 1;				//#else					// set position of scroll indicator:					this.scrollIndicatorWidth = width;					this.scrollIndicatorX = this.screenWidth - width - 1;					this.scrollIndicatorY = this.screenHeight - height - 1;				//#endif								}		//#endif		//#if polish.css.scrollindicator-color && !tmp.useScrollBar			Integer scrollIndicatorColorInt = style.getIntProperty( "scrollindicator-color" );			if (scrollIndicatorColorInt != null) {				this.scrollIndicatorColor = scrollIndicatorColorInt.intValue();			}		//#endif		//#if tmp.usingTitle && polish.css.title-style			this.titleStyle = (Style) style.getObjectProperty("title-style");			if (this.titleStyle != null && this.title != null) {				this.title.setStyle(this.titleStyle);				int width = this.screenWidth - (this.marginLeft + this.marginRight);				this.titleHeight = this.title.getItemHeight( width, width );			} else {		//#endif		 //#if tmp.usingTitle		 	if (this.title != null && this.title.isInitialised) {		 		this.title.isInitialised = false;				int width = this.screenWidth - (this.marginLeft + this.marginRight);				this.titleHeight = this.title.getItemHeight( width, width );		 	}		 //#endif		//#if tmp.usingTitle && polish.css.title-style							}		//#endif		//#if tmp.usingTitle && polish.css.title-position			Integer titlePositionInt = style.getIntProperty("title-position");			if (titlePositionInt == null && this.title != null && this.title.style != null) {				titlePositionInt = this.title.style.getIntProperty("title-position");			}			if (titlePositionInt != null) {				this.paintTitleAtTop = (titlePositionInt.intValue() == POSITION_TOP);			}					//#endif		//#if tmp.useScrollBar && polish.css.scrollbar-style			Style scrollbarStyle = (Style) style.getObjectProperty("scrollbar-style");			if (scrollbarStyle != null) {				this.scrollBar.setStyle( scrollbarStyle );			}		//#endif		//#if tmp.useScrollBar && polish.css.scrollbar-position			Integer scrollBarPositionInt = style.getIntProperty( "scrollbar-position" );			if (scrollBarPositionInt == null && this.scrollBar.style != null) {				scrollBarPositionInt = this.scrollBar.style.getIntProperty( "scrollbar-position" );			}			if (scrollBarPositionInt != null) {				this.paintScrollBarOnRightSide = (scrollBarPositionInt.intValue() != POSITION_LEFT);			}		//#endif					//#ifdef polish.css.foreground-image			String foregroundImageUrl = this.style.getProperty("foreground-image");			if (foregroundImageUrl == null) {				this.foregroundImage = null;			} else {				try {					this.foregroundImage = StyleSheet.getImage(foregroundImageUrl, null,true);					//#ifdef polish.css.foreground-x						Integer xInteger = this.style.getIntProperty("foreground-x");						if (xInteger != null) {							this.foregroundX = xInteger.intValue();						}					//#endif					//#ifdef polish.css.foreground-y						Integer yInteger = this.style.getIntProperty("foreground-y");						if (yInteger != null) {							this.foregroundY = yInteger.intValue();						}					//#endif				} catch (IOException e) {					//#debug error					System.out.println("Unable to load foreground-image [" + foregroundImageUrl + "]: " + e);				}			}		//#endif		//#if polish.css.clip-screen-info			Boolean clipScreenInfoBool = style.getBooleanProperty( "clip-screen-info" );			if (clipScreenInfoBool != null) {				this.clipScreenInfo = clipScreenInfoBool.booleanValue();			}		//#endif			//#if polish.css.menubar-style  && tmp.useExternalMenuBar			Style menuBarStyle = (Style) style.getObjectProperty("menubar-style");			if (menuBarStyle != null) {				this.menuBar.setStyle( menuBarStyle );			}		//#endif		//#ifndef polish.skipTicker			//#if polish.css.ticker-position				Integer tickerPositionInt = style.getIntProperty("ticker-position");				if (tickerPositionInt == null && this.ticker != null && this.ticker.style != null) {					tickerPositionInt = this.ticker.style.getIntProperty("ticker-position");				}				if (tickerPositionInt != null) {					this.paintTickerAtTop = (tickerPositionInt.intValue() == POSITION_TOP);				}			//#endif		//#endif		//#if polish.css.repaint-previous-screen			Boolean repaintPreviousScreenBool = style.getBooleanProperty("repaint-previous-screen");			if (repaintPreviousScreenBool != null) {				this.repaintPreviousScreen = repaintPreviousScreenBool.booleanValue();			}		//#endif		//#if polish.css.separate-menubar			Boolean separateMenubarBool = style.getBooleanProperty("separate-menubar");			if (separateMenubarBool != null) {				this.separateMenubar = separateMenubarBool.booleanValue();			}		//#endif		//#if tmp.menuFullScreen			//#if polish.css.background-bottom				Integer backgroundBottomInt = style.getIntProperty("background-bottom");				if (backgroundBottomInt != null) {					this.excludeMenuBarForBackground = backgroundBottomInt.intValue() == 1; 				}			//#endif		//#endif		//#ifdef tmp.usingTitle			//#if polish.css.background-top					Integer backgroundTopInt = style.getIntProperty("background-top");				if (backgroundTopInt != null) {					this.excludeTitleForBackground = backgroundTopInt.intValue() == 1; 				}			//#endif		//#endif	}		/**	 * Animates this Screen.	 * All embedded items are also animated.	 * 	 * @return true when at least one animated item needs a redraw/repaint.	 */	public boolean animate() {		if (!this.isInitialised) {			return false;		}			synchronized (this.paintLock) {			try {				boolean animated = false;				if (this.background != null) {					animated = this.background.animate();				}				//#ifdef tmp.menuFullScreen					//#ifdef tmp.useExternalMenuBar						animated = animated | this.menuBar.animate();					//#else						if (this.menuOpened) {							animated = animated | this.menuContainer.animate();						} else					//#endif				//#endif				if (this.container != null) {					animated = animated | this.container.animate();				}				if (this.gauge != null) {					animated = animated | this.gauge.animate();				}				//#ifdef tmp.usingTitle					if (this.title != null) {						animated = animated | this.title.animate();					}				//#endif				//#ifndef polish.skipTicker					if (this.ticker != null) {						animated = animated | this.ticker.animate();					}

⌨️ 快捷键说明

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