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

📄 stylesheet.java

📁 j2me is based on j2mepolish, client & server for mobile application. menu sample
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
		Item.LAYOUT_DEFAULT,	// default layout
		0x000000,	// font-color
		new Color(0x000000, false),	// font-color
		Font.getFont( Font.FACE_SYSTEM, Font.STYLE_BOLD | Font.STYLE_ITALIC, Font.SIZE_MEDIUM ), //font
		null,	// no background
		null	// no border
		, new short[]{ 209, 1}
		, new Object[]{ Style.FALSE, browsertextbolditalicfocusedStyle}
	);
	public final static Style alertStyle = new Style (
		0,0,0,0,	// default margin
		10,10,5,5,10,5,	// padding
		Item.LAYOUT_EXPAND | Item.LAYOUT_CENTER | Item.LAYOUT_VCENTER,
		defaultFontColor,	// font-color is not defined
		null,	// font-color is not defined
		defaultFont,
		new de.enough.polish.ui.backgrounds.SimpleBackground( new Color( 0xeef1e5, false)),
		null	// no border
		, new short[]{ 39, 1}
		, new Object[]{ new de.enough.polish.ui.containerviews.CarrouselContainerView(), mainscreenfocusedStyle}
	);
	public final static Style menuStyle = new Style (
		2,0,0,0,	// margin
		2,2,2,2,2,2,	// padding
		Item.LAYOUT_DEFAULT,	// default layout
		0xeef1e5,	// font-color
		new Color(0xeef1e5, false),	// font-color
		Font.getFont( Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_MEDIUM ), //font
		new de.enough.polish.ui.backgrounds.BorderedRoundRectBackground( 0xeef1e5,10, 10, 0x848f60, 2),
		null	// no border
		, new short[]{ 1, 16, 39}
		, new Object[]{ menufocusedStyle, new Color( 0x848f60, false), new de.enough.polish.ui.containerviews.SlideUpView()}
	);
	public final static Style browsertextStyle = new Style (
		0,0,0,0,	// default margin
		1,1,1,1,1,1,	// padding
		Item.LAYOUT_DEFAULT,	// default layout
		0x000000,	// font-color
		new Color(0x000000, false),	// font-color
		Font.getDefaultFont(), //font
		null,	// no background
		null	// no border
		, new short[]{ 209, 1}
		, new Object[]{ Style.FALSE, browsertextfocusedStyle}
	);
	public final static Style browserinputStyle = new Style (
		0,0,0,0,	// default margin
		2,2,2,2,2,2,	// padding
		Item.LAYOUT_EXPAND | Item.LAYOUT_LEFT,
		0x000000,	// font-color
		new Color(0x000000, false),	// font-color
		Font.getDefaultFont(), //font
		null,	// no background
		new de.enough.polish.ui.borders.RoundRectBorder( 0x1e5556,1, 10, 10)
		, new short[]{ 209, 1}
		, new Object[]{ Style.FALSE, browserinputfocusedStyle}
	);
	public final static Style browsertextboldStyle = new Style (
		0,0,0,0,	// default margin
		1,1,1,1,1,1,	// padding
		Item.LAYOUT_DEFAULT,	// default layout
		0x000000,	// font-color
		new Color(0x000000, false),	// font-color
		Font.getFont( Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_MEDIUM ), //font
		null,	// no background
		null	// no border
		, new short[]{ 209, 1}
		, new Object[]{ Style.FALSE, browsertextboldfocusedStyle}
	);
	public final static Style browserlinkStyle = new Style (
		0,0,0,0,	// default margin
		1,1,1,1,1,1,	// padding
		Item.LAYOUT_DEFAULT,	// default layout
		0x0000FF,	// font-color
		new Color(0x0000FF, false),	// font-color
		Font.getFont( Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_MEDIUM ), //font
		null,	// no background
		null	// no border
		, new short[]{ 209, 1}
		, new Object[]{ Style.FALSE, browserlinkfocusedStyle}
	);
	public final static Style browsertextitalicStyle = new Style (
		0,0,0,0,	// default margin
		1,1,1,1,1,1,	// padding
		Item.LAYOUT_DEFAULT,	// default layout
		0x000000,	// font-color
		new Color(0x000000, false),	// font-color
		Font.getFont( Font.FACE_SYSTEM, Font.STYLE_ITALIC, Font.SIZE_MEDIUM ), //font
		null,	// no background
		null	// no border
		, new short[]{ 209, 1}
		, new Object[]{ Style.FALSE, browsertextitalicfocusedStyle}
	);
	public final static String lic="GPL";
	public static Style labelStyle = defaultStyle; // no specific label-style has been defined
	static final Hashtable stylesByName = new Hashtable(25);
	static { 	//register referenced and dynamic styles:
		stylesByName.put( "0", mainscreenfocusedStyle );
		stylesByName.put( "1", browsertextbolditalicfocusedStyle );
		stylesByName.put( "2", menufocusedStyle );
		stylesByName.put( "3", browsertextfocusedStyle );
		stylesByName.put( "4", browserinputfocusedStyle );
		stylesByName.put( "5", browsertextboldfocusedStyle );
		stylesByName.put( "6", browserlinkfocusedStyle );
		stylesByName.put( "7", browsertextitalicfocusedStyle );
	}
		
	public static Screen currentScreen;	
	public static Display display;
	public static AnimationThread animationThread;
	//#ifdef polish.i18n.useDynamicTranslations
		//# public static Command OK_CMD = new Command( "OK", Command.OK, 2 );
	//#elifdef polish.command.ok:defined
public static final Command OK_CMD = new Command("OK", Command.OK, 2 );
	//#else
		//# public static final Command OK_CMD = new Command("OK", Command.OK, 2 );
	//#endif
	//#ifdef polish.i18n.useDynamicTranslations
		//# public static Command CANCEL_CMD = new Command("Cancel", Command.CANCEL, 2 );
	//#elifdef polish.command.cancel:defined
public static final Command CANCEL_CMD = new Command("Cancel", Command.CANCEL, 3 );
	//#else
		//# public static final Command CANCEL_CMD = new Command("Cancel", Command.CANCEL, 3 );
	//#endif

	//#if polish.ScreenChangeAnimation.allowConfiguration == true
		//# public static boolean enableScreenChangeAnimations = true;
	//#endif

	/**
	 * Retrieves the image with the given name.
	 * When the image has been cached before, it will be returned immediately.
	 * When it has not been cached before, it either will be loaded directly
	 * or in a background thread. This behaviour is set in the 
	 * <a href="../../../../definitions/polish_xml.html">polish.xml</a> file.
	 * 
	 * @param url the URL of the Image, e.g. "/background.png"
	 * @param parent the object which needs the image, when the image should be loaded
	 * 		   		in the background, the parent need to implement
	 * 				the ImageConsumer interface when it wants to be notified when
	 * 				the picture has been loaded.
	 * @param cache true when the image should be cached for later retrieval.
	 *              This costs RAM obviously, so you should decide carefully if
	 *              large images should be cached.
	 * @return the image when it either was cached or is loaded directly.
 	 *              When the should be loaded in the background, it will be later
	 *              set via the ImageConsumer.setImage()-method.
	 * @throws IOException when the image could not be loaded directly
	 * @see ImageConsumer#setImage(String, Image)
	 */
	public static Image getImage( String url, Object parent, boolean cache )
	throws IOException 
	{
		// check if the image has been cached before:
		//#if polish.allowImageCaching != false
			if ( imagesByName != null ) {
				Image image = (Image) imagesByName.get( url );
				if (image != null) {
					return image;
				}
			}
		//#endif
		//#if ! polish.images.backgroundLoad
			// when images should be loaded directly, try to do so now:
			//#ifdef polish.classes.ImageLoader:defined
				//#= Image image = ${ classname( polish.classes.ImageLoader ) }.loadImage( url );
			//#else
				Image image = Image.createImage( url );
			//#endif
			//#if polish.allowImageCaching != false
				if (cache) {
					if (imagesByName == null ) {
						imagesByName = new Hashtable();
					}
					imagesByName.put( url, image );
				}
			//#endif
			return image;
		//#else
			//# // when images should be loaded in the background, 
			//# // tell the background-thread to do so now:		
			//# if ( ! (parent instanceof ImageConsumer)) {
				//#debug error
				//# System.out.println("StyleSheet.getImage(..) needs an ImageConsumer when images are loaded in the background!");
				//# return null;
			//# }
			//# if (scheduledImagesByName == null ) {
				//# scheduledImagesByName = new Hashtable();
			//# }
			//# ImageQueue queue = (ImageQueue) scheduledImagesByName.get(url);
			//# if (queue != null) {
				//# // this image is already scheduled to load:
				//# queue.addConsumer((ImageConsumer) parent);
				//# return null;
			//# }
			//# scheduledImagesByName.put( url, new ImageQueue( (ImageConsumer) parent, cache ) );
			//# if (imagesByName == null ) {
				//# imagesByName = new Hashtable();
			//# }
			//# if (timer == null) {
				//# timer = new Timer();
			//# }
			//# ImageTask task = new ImageTask( url );
			//# timer.schedule( task, 10 );
			//# return null;
		//#endif
	}
	
	//#ifdef polish.images.backgroundLoad
	//# /**
	 //# * Notifies the GUI items which requested images about the successful loading of thoses images.
	 //# * 
	 //# * @param name the URL of the image
	 //# * @param image the image 
	 //# */
	//# public static void notifyImageConsumers( String name, Image image ) {
		//# ImageQueue queue = (ImageQueue) scheduledImagesByName.remove(name);
		//# if (queue != null) {
			//# if (queue.cache) {
				//# imagesByName.put( name, image );
			//# }
			//# queue.notifyConsumers(name, image);
			//# if (true) {
				//# return;
			//# }
			//# if (currentScreen != null) {
				//# currentScreen.repaint();
			//# }
		//# }
	//# }
	//#endif
	
	/**
	 * Gets the style with the specified name.
	 * 
	 * @param name the name of the style
	 * @return the specified style or null when no style with the given 
	 * 	       name has been defined.
	 */
	public static Style getStyle( String name ) {
		return (Style) stylesByName.get( name );
	}
	
	//#ifdef polish.useDynamicStyles
	//# /**
	 //# * Retrieves the style for the given item.
	 //# * This function is only available when the &lt;buildSetting&gt;-attribute
	 //# * [useDynamicStyles] is enabled.
	 //# * This function allows to set styles without actually using the preprocessing-
	 //# * directive //#style. Beware that this dynamic style retrieval is not as performant
	 //# * as the direct-style-setting with the //#style preprocessing directive.
	 //# *  
	 //# * @param item the item for which the style should be retrieved
	 //# * @return the appropriate style. When no specific style is found,
	 //# *         the default style is returned.
	 //# */
	//# public static Style getStyle( Item item ) {
		//# if (item.screen == null) {
			//#debug error
			//# System.out.println("unable to retrieve style for item [" + item.getClass().getName() + "] without screen.");
			//# return defaultStyle;
		//# }
		//# String itemCssSelector = item.cssSelector;
		//# String screenCssSelector = item.screen.cssSelector;
		//# Style style = null;
		//# String fullStyleName;
		//# StringBuffer buffer = new StringBuffer();
		//# buffer.append( screenCssSelector );
		//# if (item.parent == null) {
			//#debug
			//# System.out.println("item.parent == null");
			//# buffer.append('>').append( itemCssSelector );
			//# fullStyleName = buffer.toString();
			//# style = (Style) stylesByName.get( fullStyleName );
			//# if (style != null) {
				//# return style;
			//# }
			//# style = (Style) stylesByName.get( screenCssSelector + " " + itemCssSelector );
		//# } else if (item.parent.parent == null) {
			//#debug
			//# System.out.println("Item has one parent.");
			//# // this item is propably in a form or list,
			//# // typical hierarchy is for example "form>container>p"                                                 
			//# Item parent = item.parent;
			//# String parentCssSelector = parent.cssSelector;
			//# if (parentCssSelector == null) {
				//# parentCssSelector = parent.createCssSelector();
			//# }
			//#debug
			//# System.out.println( parent.getClass().getName() + "-css-selector: " + parentCssSelector );
			//# buffer.append('>').append( parentCssSelector )
				  //# .append('>').append( itemCssSelector );
			//# fullStyleName = buffer.toString();
			//#debug

⌨️ 快捷键说明

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