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

📄 fsdefinetextfield.java

📁 利用opensource的开源jar实现生成flash文件
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        */
    public void setRightMargin(int aNumber)
    {
        rightMargin = aNumber;
    }

    /** Gets the indentation of the first line of text in twips.

        @param aNumber the indentation for the first line.
        */
    public void setIndent(int aNumber)
    {
        indent = aNumber;
    }

    /** Sets the leading in twips.

        @param aNumber the value for the leading.
        */
    public void setLeading(int aNumber)
    {
        leading = aNumber;
    }

    /** Sets the name of the variable the value in the text field will be assigned to.

        @param aString the name of the variable.
        */
    public void setVariableName(String aString)
    {
        variableName = aString;
    }

    /** Sets the value that will initially be displayed in the text field.

        @param aString the initial text displayed.
        */
    public void setInitialText(String aString)
    {
        initialText = aString;
    }

    /** Sets the attributes for the object. The Hashtable contains a list of key-value pairs. The key is one of the pre-defined attribute names while the value is an instance of a wrapper class (Boolean, Integer or String) that will be assigned to the specified attribute.

        @param attributes the list of attributes for the object.
        */
    public void setAttributes(Hashtable attributes)
    {
        if (attributes.get(WordWrapped) != null)
            setWordWrapped(((Boolean)attributes.get(WordWrapped)).booleanValue());
        if (attributes.get(Multiline) != null)
            setMultiline(((Boolean)attributes.get(Multiline)).booleanValue());
        if (attributes.get(Password) != null)
            setPassword(((Boolean)attributes.get(Password)).booleanValue());
        if (attributes.get(ReadOnly) != null)
            setReadOnly(((Boolean)attributes.get(ReadOnly)).booleanValue());
        if (attributes.get(Selectable) != null)
            setSelectable(((Boolean)attributes.get(Selectable)).booleanValue());
        if (attributes.get(Bordered) != null)
            setBordered(((Boolean)attributes.get(Bordered)).booleanValue());
        if (attributes.get(HTML) != null)
            setHTML(((Boolean)attributes.get(HTML)).booleanValue());
// Flash 6
        if (attributes.get(AutoSize) != null)
            setAutoSize(((Boolean)attributes.get(AutoSize)).booleanValue());
// End Flash 6
        if (attributes.get(UseFontGlyphs) != null)
            setUseFontGlyphs(((Boolean)attributes.get(UseFontGlyphs)).booleanValue());
        if (attributes.get(FontIdentifier) != null)
            setFontIdentifier(((Integer)attributes.get(FontIdentifier)).intValue());
        if (attributes.get(FontHeight) != null)
            setFontHeight(((Integer)attributes.get(FontHeight)).intValue());
        if (attributes.get(Color) != null)
            setColor((FSColor)attributes.get(Color));
        if (attributes.get(MaxLength) != null)
            setMaxLength(((Integer)attributes.get(MaxLength)).intValue());
        if (attributes.get(LeftMargin) != null)
            setLeftMargin(((Integer)attributes.get(LeftMargin)).intValue());
        if (attributes.get(RightMargin) != null)
            setRightMargin(((Integer)attributes.get(RightMargin)).intValue());
        if (attributes.get(Indent) != null)
            setIndent(((Integer)attributes.get(Indent)).intValue());
        if (attributes.get(Leading) != null)
            setLeading(((Integer)attributes.get(Leading)).intValue());
        if (attributes.get(VariableName) != null)
            setVariableName((String)attributes.get(VariableName));
        if (attributes.get(InitialText) != null)
            setInitialText((String)attributes.get(InitialText));
    }

    public Object clone()
    {
        FSDefineTextField anObject = (FSDefineTextField)super.clone();
        
        anObject.bounds = (bounds != null) ? (FSBounds)bounds.clone() : null;
        anObject.color = (color != null) ? (FSColor)color.clone() : null;

        return anObject;
    }

    public boolean equals(Object anObject)
    {
        boolean result = false;
        
        if (super.equals(anObject))
        {
            FSDefineTextField typedObject = (FSDefineTextField)anObject;
            
            if (bounds != null)
                result = bounds.equals(typedObject.bounds);
            else
                result = bounds == typedObject.bounds;

            result = result && wordWrapped == typedObject.wordWrapped;
            result = result && multiline == typedObject.multiline;
            result = result && password == typedObject.password;
            result = result && readOnly == typedObject.readOnly;
            result = result && reserved1 == typedObject.reserved1;
// Flash 6
            result = result && autoSize == typedObject.autoSize;
// End Flash 6
            result = result && selectable == typedObject.selectable;
            result = result && bordered == typedObject.bordered;
            result = result && reserved2 == typedObject.reserved2;
            result = result && html == typedObject.html;
            result = result && useFontGlyphs == typedObject.useFontGlyphs;
            result = result && fontIdentifier == typedObject.fontIdentifier;
            result = result && fontHeight == typedObject.fontHeight;

            if (color != null)
                result = result && color.equals(typedObject.color);
            else
                result = result && color == typedObject.color;

            result = result && maxLength == typedObject.maxLength;
            
            if (containsLayoutInfo())
            {
                result = result && alignment == typedObject.alignment;
                result = result && leftMargin == typedObject.leftMargin;
                result = result && rightMargin == typedObject.rightMargin;
                result = result && indent == typedObject.indent;
                result = result && leading == typedObject.leading;
            }

            if (variableName != null)
                result = result && variableName.equals(typedObject.variableName);
            else
                result = result && variableName == typedObject.variableName;
                
            if (initialText != null)
                result = result && initialText.equals(typedObject.initialText);
            else
                result = result && initialText == typedObject.initialText;
       }
        return result;
    }

    public void appendDescription(StringBuffer buffer, int depth)
    {
        buffer.append(name());
        
        if (depth > 0)
        {
            buffer.append(": { ");
            Transform.append(buffer, "bounds", bounds, depth);
            Transform.append(buffer, "wordWrapped", wordWrapped);
            Transform.append(buffer, "multiline", multiline);
            Transform.append(buffer, "password", password);
            Transform.append(buffer, "readOnly", readOnly);
// Flash 6
            Transform.append(buffer, "autoSize", autoSize);
// End Flash 6
            Transform.append(buffer, "selectable", selectable);
            Transform.append(buffer, "bordered", bordered);
            Transform.append(buffer, "HTML", html);
            Transform.append(buffer, "useFontGlyphs", useFontGlyphs);
            Transform.append(buffer, "fontIdentifier", fontIdentifier);
            Transform.append(buffer, "fontHeight", fontHeight);
            Transform.append(buffer, "color", color, depth);
            Transform.append(buffer, "maxLength", maxLength);
            Transform.append(buffer, "alignment", alignment);
            Transform.append(buffer, "leftMargin", leftMargin);
            Transform.append(buffer, "rightMargin", rightMargin);
            Transform.append(buffer, "indent", indent);
            Transform.append(buffer, "leading", leading);
            Transform.append(buffer, "variableName", variableName);
            Transform.append(buffer, "initalText", initialText);
            buffer.append("}");
        }
    }

    public int length(FSCoder coder)
    {
        boolean _containsFont = containsFont();
        boolean _containsColor = containsColor();
        boolean _containsMaxLength = containsMaxLength();
        boolean _containsText = containsText();
        
        super.length(coder);
    
        coder.context[FSCoder.TransparentColors] = 1;

        length += bounds.length(coder);
        length += 2;
        length += (_containsFont) ? 4 : 0;
        length += (_containsColor) ? color.length(coder) : 0;
        length += (_containsMaxLength) ? 2 : 0;
        length += (containsLayoutInfo()) ? 9 : 0;
        length += coder.strlen(variableName, true);
        length += (_containsText) ? coder.strlen(initialText, true) : 0;
        
        coder.context[FSCoder.TransparentColors] = 0;
        
        return length;
    }
    
    public void encode(FSCoder coder)
    {
        boolean _containsFont = containsFont();
        boolean _containsColor = containsColor();
        boolean _containsMaxLength = containsMaxLength();
        boolean _containsText = containsText();
        
        super.encode(coder);
        
        coder.context[FSCoder.TransparentColors] = 1;

        bounds.encode(coder);
        coder.writeBits(_containsText ? 1 : 0, 1);
        coder.writeBits(wordWrapped ? 1 : 0, 1);
        coder.writeBits(multiline ? 1 : 0, 1);
        coder.writeBits(password ? 1 : 0, 1);
        coder.writeBits(readOnly ? 1 : 0, 1);
        coder.writeBits(_containsColor ? 1 : 0, 1);
        coder.writeBits(_containsMaxLength ? 1 : 0, 1);
        coder.writeBits(_containsFont ? 1 : 0, 1);
        coder.writeBits(0, 1);
        coder.writeBits(autoSize ? 1 : 0, 1);
        coder.writeBits(containsLayoutInfo() ? 1 : 0, 1);
        coder.writeBits(selectable ? 1 : 0, 1);
        coder.writeBits(bordered ? 1 : 0, 1);
        coder.writeBits(0, 1);
        coder.writeBits(html ? 1 : 0, 1);
        coder.writeBits(useFontGlyphs ? 1 : 0, 1);
    
        if (_containsFont)
        {
            coder.writeWord(fontIdentifier, 2);
            coder.writeWord(fontHeight, 2);
        }
    
        if (_containsColor)
            color.encode(coder);
    
        if (_containsMaxLength)
            coder.writeWord(maxLength, 2);
    
        if (containsLayoutInfo())
        {
            coder.writeWord((alignment != Transform.VALUE_NOT_SET) ? alignment : 0, 1);
            coder.writeWord((leftMargin != Transform.VALUE_NOT_SET) ? leftMargin : 0, 2);
            coder.writeWord((rightMargin != Transform.VALUE_NOT_SET) ? rightMargin : 0, 2);
            coder.writeWord((indent != Transform.VALUE_NOT_SET) ? indent : 0, 2);
            coder.writeWord((leading != Transform.VALUE_NOT_SET) ? leading : 0, 2);
        }
    
        coder.writeString(variableName);
        coder.writeWord(0, 1);
    
        if (_containsText)
        {
            coder.writeString(initialText);
            coder.writeWord(0, 1);
        }
        coder.context[FSCoder.TransparentColors] = 0;
        coder.endObject(name());
    }
    
    public void decode(FSCoder coder)
    {
        boolean _containsFont = false;
        boolean _containsColor = false;
        boolean _containsMaxLength = false;
        boolean _containsText = false;
        boolean _containsLayout = false;

        super.decode(coder);

        coder.context[FSCoder.TransparentColors] = 1;

        bounds = new FSBounds(coder);

        _containsText = coder.readBits(1, false) != 0 ? true : false;
        wordWrapped = coder.readBits(1, false) != 0 ? true : false;
        multiline = coder.readBits(1, false) != 0 ? true : false;
        password = coder.readBits(1, false) != 0 ? true : false;
        readOnly = coder.readBits(1, false) != 0 ? true : false;
        _containsColor = coder.readBits(1, false) != 0 ? true : false;
        _containsMaxLength = coder.readBits(1, false) != 0 ? true : false;
        _containsFont = coder.readBits(1, false) != 0 ? true : false;
        reserved1 = coder.readBits(1, false);
        autoSize = coder.readBits(1, false) != 0 ? true : false;
        _containsLayout = coder.readBits(1, false) != 0 ? true : false;
        selectable = coder.readBits(1, false) != 0 ? true : false;
        bordered = coder.readBits(1, false) != 0 ? true : false;
        reserved2 = coder.readBits(1, false) != 0 ? true : false;
        html = coder.readBits(1, false) != 0 ? true : false;
        useFontGlyphs = coder.readBits(1, false) != 0 ? true : false;
        
        if (_containsFont)
        {
             fontIdentifier = coder.readWord(2, false);
             fontHeight = coder.readWord(2, false);
        }

        if (_containsColor)
            color = new FSColor(coder);

        if (_containsMaxLength)
            maxLength = coder.readWord(2, false);

        if (_containsLayout)
        {
            alignment = coder.readWord(1, false);
            leftMargin = coder.readWord(2, false);
            rightMargin = coder.readWord(2, false);
            indent = coder.readWord(2, false);
            leading = coder.readWord(2, false);
        }

        variableName = coder.readString();

        if (_containsText)
            initialText = coder.readString();

        coder.context[FSCoder.TransparentColors] = 0;
        coder.endObject(name());
    }
    
    private boolean containsColor()
    {
        return color != null;
    }
    
    private boolean containsFont()
    {
        return fontIdentifier != 0 && fontHeight != 0;
    }
    
    private boolean containsMaxLength()
    {
        return maxLength > 0;
    }
    
    private boolean containsLayoutInfo()
    {
        boolean layout = false;
        
        layout = alignment != Transform.VALUE_NOT_SET;
        layout = layout || leftMargin != Transform.VALUE_NOT_SET;
        layout = layout || rightMargin != Transform.VALUE_NOT_SET;
        layout = layout || indent != Transform.VALUE_NOT_SET;
        layout = layout || leading != Transform.VALUE_NOT_SET;
        
        return layout;
    }

    private boolean containsText()
    {
        return initialText != null && initialText.length() > 0;
    }    
}

⌨️ 快捷键说明

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