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

📄 defineedittext.java

📁 java解析flash。对于flash在java上应用非常有帮助。比如解析flash到服务器端
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * JSwiff is an open source Java API for Macromedia Flash file generation
 * and manipulation
 *
 * Copyright (C) 2004-2008 Ralf Terdic (contact@jswiff.com)
 *
 * This program 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.
 *
 * This program 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 this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */
package com.jswiff.swfrecords.tags;

import com.jswiff.io.InputBitStream;
import com.jswiff.io.OutputBitStream;
import com.jswiff.swfrecords.RGBA;
import com.jswiff.swfrecords.Rect;

import java.io.IOException;


/**
 * <p>
 * This tag defines a dynamic text field. A text field can be associated with a
 * variable the contents of the text field are stored in and kept in sync
 * with.
 * </p>
 * 
 * <p>
 * Users may change the value of a text field interactively, unless the
 * <code>readOnly</code> tag is set.
 * </p>
 * 
 * <p>
 * Fonts used by this tag must be defined using <code>DefineFont2</code> (not
 * <code>DefineFont</code>). If the <code>useOutlines</code> flag is cleared, the
 * Flash Player will try to render text using device fonts rather than glyph
 * fonts.
 * </p>
 * 
 * <p>
 * When the <code>html</code> flag is set, the text may contain HTML tags.
 * Allowed tags are:
 * 
 * <ul>
 * <li>
 * <code>&lt;p&gt;...&lt;/p&gt;</code>: paragraph
 * </li>
 * <li>
 * <code>&lt;br&gt;</code>: line break
 * </li>
 * <li>
 * <code>&lt;a href="..."&gt;...&lt;/a&gt;</code>: hyperlink. Optional
 * attributes:
 * 
 * <ul>
 * <li>
 * <code>target</code>: a window name
 * </li>
 * </ul>
 * 
 * </li>
 * <li>
 * <code>&lt;font&gt;...&lt;/font&gt;</code>: font properties. Available
 * attributes:
 * 
 * <ul>
 * <li>
 * <code>face</code>: font name supplied in a <code>DefineFont2</code> tag.
 * </li>
 * <li>
 * <code>size</code> in twips (1/20 px). Leading <code>+</code> or
 * <code>-</code> indicates a relative size
 * </li>
 * <li>
 * <code>color</code> as a <code>#RRGGBB</code> hex value
 * </li>
 * </ul>
 * 
 * </li>
 * <li>
 * <code>&lt;b&gt;...&lt;/b&gt;</code>: bold text
 * </li>
 * <li>
 * <code>&lt;i&gt;...&lt;/i&gt;</code>: italic text
 * </li>
 * <li>
 * <code>&lt;u&gt;...&lt;/u&gt;</code>: underlined text
 * </li>
 * <li>
 * <code>&lt;li&gt;...&lt;/li&gt;</code>: bulleted list. Warning: &lt;ul&gt; is
 * not supported
 * </li>
 * <li>
 * <code>&lt;textformat&gt;...&lt;/textformat&gt;</code> lets you specify
 * formatting attributes:
 * 
 * <ul>
 * <li>
 * <code>leftmargin</code> in twips (1/20 px)
 * </li>
 * <li>
 * <code>rightmargin</code> in twips
 * </li>
 * <li>
 * <code>indent</code> in twips
 * </li>
 * <li>
 * <code>blockindent</code> in twips
 * </li>
 * <li>
 * <code>leading</code> in twips
 * </li>
 * <li>
 * <code>tabstops</code>: comma-separated list in twips
 * </li>
 * </ul>
 * 
 * </li>
 * <li>
 * <code>&lt;tab&gt;</code>: advances to next tab stop (defined with
 * <code>&lt;textformat&gt;</code>)
 * </li>
 * </ul>
 * </p>
 * 
 * <p>
 * Multiple other parameters can be set, e.g. text layout attributes like
 * margins and leading etc.
 * </p>
 *
 * @since SWF 4
 */
public final class DefineEditText extends DefinitionTag {
	/** Left text alignment */
	public static final short ALIGN_LEFT    = 0;
	/** Right text alignment */
	public static final short ALIGN_RIGHT   = 1;
	/** Center text alignment */
	public static final short ALIGN_CENTER  = 2;
	/** Justify text alignment */
	public static final short ALIGN_JUSTIFY = 3;
	private Rect bounds;
	private boolean wordWrap;
	private boolean multiline;
	private boolean password;
	private boolean readOnly;
	private boolean autoSize;
	private boolean noSelect;
	private boolean border;
	private boolean html;
	private boolean useOutlines;
	private int fontId					    = -1;
	private int fontHeight;
	private RGBA textColor;
	private int maxLength;
	private short align;
	private int leftMargin;
	private int rightMargin;
	private int indent;
	private int leading;
	private String variableName;
	private String initialText;
	private boolean hasText;
	private boolean hasTextColor;
	private boolean hasMaxLength;
	private boolean hasFont;
	private boolean hasLayout;

	/**
	 * Creates a new DefineEditText tag. Specify the character ID of the text
	 * field, its bounds and the name of the variable the contents of the text
	 * field are stored in and kept in sync with.
	 *
	 * @param characterId character ID of the text field
	 * @param bounds the size of the rectangle which completely encloses the
	 * 		  text field.
	 * @param variableName variable name (in dot or slash syntax)
	 */
	public DefineEditText(int characterId, Rect bounds, String variableName) {
		code				  = TagConstants.DEFINE_EDIT_TEXT;
		this.characterId	  = characterId;
		this.bounds			  = bounds;
		this.variableName     = variableName;
	}

	DefineEditText() {
		// empty
	}

	/**
	 * Returns the text alignment (one of the constants <code>ALIGN_LEFT,
	 * ALIGN_RIGHT, ALIGN_CENTER, ALIGN_JUSTIFY</code>). Check with
	 * <code>hasLayout()</code> first if value is set.
	 *
	 * @return text alignment
	 */
	public short getAlign() {
		return align;
	}

	/**
	 * Sets the value of the <code>autoSize</code> flag. If set, the text field
	 * resizes depending on its content size.
	 *
	 * @param autoSize <code>true</code> if flag set, else <code>false</code>
	 */
	public void setAutoSize(boolean autoSize) {
		this.autoSize = autoSize;
	}

	/**
	 * Checks if the <code>autoSize</code> flag is set, i.e. if the text field
	 * is supposed to resize depending on its content size.
	 *
	 * @return <code>true</code> if flag set, else <code>false</code>
	 */
	public boolean isAutoSize() {
		return autoSize;
	}

	/**
	 * Sets the value of the <code>border</code> flag. A set flag causes a
	 * border to be drawn around the text field.
	 *
	 * @param border <code>true</code> if flag set, else <code>false</code>
	 */
	public void setBorder(boolean border) {
		this.border = border;
	}

	/**
	 * Checks if the <code>border</code> flag, causing a border to be drawn
	 * around the text field.
	 *
	 * @return <code>true</code> if <code>border</code> flag is set, else
	 * 		   <code>false</code>
	 */
	public boolean isBorder() {
		return border;
	}

	/**
	 * Returns the bounds of the text field, i.e. the size of the rectangle
	 * which completely encloses the text field.
	 *
	 * @return text field bounds
	 */
	public Rect getBounds() {
		return bounds;
	}

	/**
	 * Sets the font of the text.
	 *
	 * @param fontId character ID of the font
	 * @param fontHeight font height in twips (1/20 px)
	 */
	public void setFont(int fontId, int fontHeight) {
		this.fontId		    = fontId;
		this.fontHeight     = fontHeight;
		hasFont			    = true;
	}

	/**
	 * Returns the font height (in twips, i.e. 1/20 px). Check with
	 * <code>hasFont()</code> first if value is set.
	 *
	 * @return font height in twips
	 */
	public int getFontHeight() {
		return fontHeight;
	}

	/**
	 * Returns the character ID of the used font. Check with
	 * <code>hasFont()</code> first if value is set.
	 *
	 * @return font character ID
	 */
	public int getFontId() {
		return fontId;
	}

	/**
	 * Sets the value of the <code>html</code> flag. If set, html tags are
	 * allowed in the contained text.
	 *
	 * @param html <code>true</code> if flag set, else <code>false</code>
	 */
	public void setHtml(boolean html) {
		this.html = html;
	}

	/**
	 * Returns the <code>html</code> flag, which specifies whether html tags
	 * are allowed in the contained text.
	 *
	 * @return <code>true</code> if <code>html</code> flag is set, otherwise
	 * 		   <code>false</code>
	 */
	public boolean isHtml() {
		return html;
	}

	/**
	 * Returns the text indent in twips (i.e. 1/20 px). Check with
	 * <code>hasLayout()</code> first if value is set.
	 *
	 * @return text indent in twips
	 */
	public int getIndent() {
		return indent;
	}

	/**
	 * Sets the text initially contained in the text field.
	 *
	 * @param initialText initialText
	 */
	public void setInitialText(String initialText) {
		this.initialText     = initialText;
		hasText				 = true;
	}

	/**
	 * Returns the initial text string.  Check with <code>hasText()</code>
	 * first if value is set.
	 *
	 * @return initial text
	 */
	public String getInitialText() {
		return initialText;
	}

	/**
	 * Sets the layout properties of the text: alignment, margins, indentation
	 * and line spacing.
	 *
	 * @param align text alignment, one of the constants <code>ALIGN_LEFT,
	 * 		  ALIGN_RIGHT, ALIGN_CENTER, ALIGN_JUSTIFY</code>
	 * @param leftMargin left text margin in twips (i.e. 1/20 px)
	 * @param rightMargin right text margin
	 * @param indent text indentation in twips
	 * @param leading line spacing in twips
	 */
	public void setLayout(
		short align, int leftMargin, int rightMargin, int indent, int leading) {
		this.align			 = align;
		this.leftMargin		 = leftMargin;
		this.rightMargin     = rightMargin;
		this.indent			 = indent;
		this.leading		 = leading;
		hasLayout			 = true;
	}

	/**
	 * Returns the text leading (line spacing) in twips (i.e. 1/20 px). Check
	 * with <code>hasLayout()</code> first if value is set.
	 *
	 * @return line spacing in twips
	 */
	public int getLeading() {
		return leading;

⌨️ 快捷键说明

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