📄 fakestringcustomitem.java
字号:
//#condition polish.LibraryBuild// generated by de.enough.doc2java.Doc2Java (www.enough.de) on Sat Dec 06 15:06:43 CET 2003/* * Copyright (c) 2004-2005 Robert Virkus / Enough Software * * This file is part of J2ME Polish. * * J2ME Polish is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * J2ME Polish is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with J2ME Polish; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Commercial licenses are also available, please * refer to the accompanying LICENSE.txt or visit * http://www.j2mepolish.org for details. */package de.enough.polish.ui;import de.enough.polish.util.BitMapFont;import de.enough.polish.util.BitMapFontViewer;import de.enough.polish.util.TextUtil;import javax.microedition.lcdui.Font;import javax.microedition.lcdui.Graphics;/** * Meant for classes that want to be compatible with javax.microedition.lcdui.CustomItem for IDEs only while extending de.enough.polish.ui.StringItem in reality. * * <p>Subclasses can change the hierarchy with preprocessing like this: * <pre> * public class MyCustomItem * //#if polish.LibraryBuild * extends FakeStringCustomItem * //#else * //# extends StringItem * //#endif * </pre> * </p> * <p>This allows subclasses to access all fields and methods of the J2ME Polish item class.</p> * <p>Note that this class can never be used in reality. Ever.</p> * * @since J2ME Polish 1.3 * @author Robert Virkus, robert@enough.de */public class FakeStringCustomItem extends FakeCustomItem{ protected String text; protected String[] textLines; protected int textColor; protected Font font; //#ifdef polish.css.font-bitmap protected BitMapFont bitMapFont; protected BitMapFontViewer bitMapFontViewer; //#endif //#ifdef polish.css.text-wrap protected boolean useSingleLine; protected boolean clipText; protected int xOffset; private int textWidth; private boolean isHorizontalAnimationDirectionRight; private boolean isSkipHorizontalAnimation; //#endif //#ifdef polish.css.text-horizontal-adjustment protected int textHorizontalAdjustment; //#endif //#ifdef polish.css.text-vertical-adjustment protected int textVerticalAdjustment; //#endif //#ifdef polish.css.text-effect protected TextEffect textEffect; //#endif /** * Creates a new <code>StringItem</code> object. Calling this * constructor is equivalent to calling * * <pre><code> * StringItem(label, text, Item.PLAIN, null); * </code></pre> * * @param label the Item label * @param text the text contents * @see #StringItem(String, String, int, Style) */ public FakeStringCustomItem( String label, String text) { this( label, text, PLAIN ); } /** * Creates a new <code>StringItem</code> object. Calling this * constructor is equivalent to calling * * <pre><code> * StringItem(label, text, Item.PLAIN, style); * </code></pre> * * @param label the Item label * @param text the text contents * @param style the style * @see #StringItem(String, String, int, Style) */ public FakeStringCustomItem( String label, String text, Style style ) { this( label, text, PLAIN, style ); } /** * Creates a new <code>StringItem</code> object with the given label, * textual content, and appearance mode. * Either label or text may be present or <code>null</code>. * * <p>The <code>appearanceMode</code> parameter * (see <a href="Item.html#appearance">Appearance Modes</a>) * is a hint to the platform of the application's intended use * for this <code>StringItem</code>. To provide hyperlink- or * button-like behavior, * the application should associate a default <code>Command</code> with this * <code>StringItem</code> and add an * <code>ItemCommandListener</code> to this * <code>StringItem</code>. * * <p>Here is an example showing the use of a * <code>StringItem</code> as a button: </p> * <pre><code> * StringItem strItem = new StringItem("Default: ", "Set", Item.BUTTON); * strItem.setDefaultCommand( * new Command("Set", Command.ITEM, 1); * // icl is ItemCommandListener * strItem.setItemCommandListener(icl); * </code></pre> * * @param label the StringItem's label, or null if no label * @param text the StringItem's text contents, or null if the contents are initially empty * @param appearanceMode the appearance mode of the StringItem, one of Item.PLAIN, Item.HYPERLINK, or Item.BUTTON * @throws IllegalArgumentException if appearanceMode invalid * @since MIDP 2.0 */ public FakeStringCustomItem( String label, String text, int appearanceMode) { this( label, text, appearanceMode, null ); } /** * Creates a new <code>StringItem</code> object with the given label, * textual content, and appearance mode. * Either label or text may be present or <code>null</code>. * * <p>The <code>appearanceMode</code> parameter * (see <a href="Item.html#appearance">Appearance Modes</a>) * is a hint to the platform of the application's intended use * for this <code>StringItem</code>. To provide hyperlink- or * button-like behavior, * the application should associate a default <code>Command</code> with this * <code>StringItem</code> and add an * <code>ItemCommandListener</code> to this * <code>StringItem</code>. * * <p>Here is an example showing the use of a * <code>StringItem</code> as a button: </p> * <pre><code> * StringItem strItem = new StringItem("Default: ", "Set", Item.BUTTON); * strItem.setDefaultCommand( * new Command("Set", Command.ITEM, 1); * // icl is ItemCommandListener * strItem.setItemCommandListener(icl); * </code></pre> * * @param label the StringItem's label, or null if no label * @param text the StringItem's text contents, or null if the contents are initially empty * @param appearanceMode the appearance mode of the StringItem, one of Item.PLAIN, Item.HYPERLINK, or Item.BUTTON * @param style the style for this item * @throws IllegalArgumentException if appearanceMode invalid * @since MIDP 2.0 */ public FakeStringCustomItem( String label, String text, int appearanceMode, Style style ) { super( label, LAYOUT_DEFAULT, appearanceMode, style ); this.text = text; } //#if polish.css.text-effect || polish.css.text-wrap /* (non-Javadoc) * @see de.enough.polish.ui.Item#animate() */ public boolean animate() { boolean animated = super.animate(); //#if polish.css.text-effect if (this.textEffect != null) { animated |= this.textEffect.animate(); } //#endif //#if polish.css.text-wrap if (this.useSingleLine && this.clipText) { if (this.isSkipHorizontalAnimation) { this.isSkipHorizontalAnimation = false; } else { if (this.isHorizontalAnimationDirectionRight) { this.xOffset++; if (this.xOffset >= 0) { this.isHorizontalAnimationDirectionRight = false; } } else { this.xOffset--; if (this.xOffset + this.textWidth < this.contentWidth) { this.isHorizontalAnimationDirectionRight = true; } } animated = true; this.isSkipHorizontalAnimation = true; } } //#endif return animated; } //#endif //#if polish.css.text-wrap /* (non-Javadoc) * @see de.enough.polish.ui.Item#defocus(de.enough.polish.ui.Style) */ protected void defocus(Style originalStyle) { super.defocus(originalStyle); if (this.clipText) { this.xOffset = 0; } } //#endif //#ifdef polish.css.text-effect /* (non-Javadoc) * @see de.enough.polish.ui.Item#hideNotify() */ protected void hideNotify() { if (this.textEffect != null) { this.textEffect.hideNotify(); } super.hideNotify(); } //#endif //#ifdef polish.css.text-effect /* (non-Javadoc) * @see de.enough.polish.ui.Item#showNotify() */ protected void showNotify() { if (this.textEffect != null) { this.textEffect.showNotify(); } super.showNotify(); } //#endif /** * Gets the text contents of the <code>StringItem</code>, or * <code>null</code> if the <code>StringItem</code> is * empty. * * @return a string with the content of the item * @see #setText(java.lang.String) */ public String getText() { return this.text; } /** * Sets the text contents of the <code>StringItem</code>. * If text * is <code>null</code>, * the <code>StringItem</code> * is set to be empty. * * @param text the new content * @see #getText() */ public void setText( String text) { setText( text, null ); } /** * Sets the text contents of the <code>StringItem</code> along with a style. * If text is <code>null</code>, * the <code>StringItem</code> * is set to be empty. * * @param text the new content * @param style the new style, is ignored when null * @see #getText()
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -