當前位置: 首頁>>代碼示例>>Java>>正文


Java AttributeSet.getAttributeNames方法代碼示例

本文整理匯總了Java中javax.swing.text.AttributeSet.getAttributeNames方法的典型用法代碼示例。如果您正苦於以下問題:Java AttributeSet.getAttributeNames方法的具體用法?Java AttributeSet.getAttributeNames怎麽用?Java AttributeSet.getAttributeNames使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.text.AttributeSet的用法示例。


在下文中一共展示了AttributeSet.getAttributeNames方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeEmbeddedTags

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
/**
 * Searches for embedded tags in the AttributeSet
 * and writes them out.  It also stores these tags in a vector
 * so that when appropriate the corresponding end tags can be
 * written out.
 *
 * @exception IOException on any I/O error
 */
protected void writeEmbeddedTags(AttributeSet attr) throws IOException {

    // translate css attributes to html
    attr = convertToHTML(attr, oConvAttr);

    Enumeration names = attr.getAttributeNames();
    while (names.hasMoreElements()) {
        Object name = names.nextElement();
        if (name instanceof HTML.Tag) {
            HTML.Tag tag = (HTML.Tag) name;
            if (tag == HTML.Tag.FORM || tags.contains(tag)) {
                continue;
            }
            write('<');
            write(tag.toString());
            Object o = attr.getAttribute(tag);
            if (o != null && o instanceof AttributeSet) {
                writeAttributes((AttributeSet) o);
            }
            write('>');
            tags.addElement(tag);
            tagValues.addElement(o);
        }
    }
}
 
開發者ID:ser316asu,項目名稱:Neukoelln_SER316,代碼行數:34,代碼來源:AltHTMLWriter.java

示例2: convertToHTML40

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
/**
 * Copies the given AttributeSet to a new set, converting
 * any CSS attributes found to arguments of an HTML style
 * attribute.
 */
private static void convertToHTML40(AttributeSet from, MutableAttributeSet to) {
    Enumeration keys = from.getAttributeNames();
    String value = "";
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        if (key instanceof CSS.Attribute) {
            value = value + " " + key + "=" + from.getAttribute(key) + ";";
        }
        else {
            to.addAttribute(key, from.getAttribute(key));
        }
    }
    if (value.length() > 0) {
        to.addAttribute(HTML.Attribute.STYLE, value);
    }
}
 
開發者ID:ser316asu,項目名稱:Neukoelln_SER316,代碼行數:22,代碼來源:AltHTMLWriter.java

示例3: dumpAttributes

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
private String dumpAttributes(StringBuilder sb, AttributeSet attribs) {
    if (sb == null) {
        sb = new StringBuilder();
    }
    
    if (attribs == null) {
        sb.append(" ");
    } else {
        Enumeration en = attribs.getAttributeNames();
        while (en.hasMoreElements()) {
            Object attrName = en.nextElement();
            Object attrValue = attribs.getAttribute(attrName);

            sb.append("'");
            sb.append(attrName.toString());
            sb.append("' = '");
            sb.append(attrValue == null ? "null" : attrValue.toString());
            sb.append("'");
            if (en.hasMoreElements()) {
                sb.append(", ");
            }
        }
    }
    
    return sb.toString();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:MergingOffsetsBagTest.java

示例4: immutize

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
/**
 * Creates unmodifiable copy of the original map converting <code>AttributeSet</code>s
 * to their immutable versions.
 */
public static Map<String, AttributeSet> immutize(Map<String, ? extends AttributeSet> map, Object... filterOutKeys) {
    Map<String, AttributeSet> immutizedMap = new HashMap<String, AttributeSet>();
    
    for(String name : map.keySet()) {
        AttributeSet attribs = map.get(name);
        
        if (filterOutKeys.length == 0) {
            immutizedMap.put(name, AttributesUtilities.createImmutable(attribs));
        } else {
            List<Object> pairs = new ArrayList<Object>();

            // filter out attributes specified by filterOutKeys
            first:
            for(Enumeration<? extends Object> keys = attribs.getAttributeNames(); keys.hasMoreElements(); ) {
                Object key = keys.nextElement();
                
                for(Object filterOutKey : filterOutKeys) {
                    if (Utilities.compareObjects(key, filterOutKey)) {
                        continue first;
                    }
                }
                
                pairs.add(key);
                pairs.add(attribs.getAttribute(key));
            }

            immutizedMap.put(name, AttributesUtilities.createImmutable(pairs.toArray()));
        }
    }
    
    return Collections.unmodifiableMap(immutizedMap);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:37,代碼來源:NbUtils.java

示例5: toAttrSetBuilder

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
static AttrSetBuilder toAttrSetBuilder(AttributeSet attrs) {
    AttrSetBuilder builder = new AttrSetBuilder(attrs.getAttributeCount() << 1);
    Enumeration<?> en = attrs.getAttributeNames();
    while (en.hasMoreElements()) {
        Object key = en.nextElement();
        Object value = attrs.getAttribute(key);
        builder.add(key, value);
    }
    return builder;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:AttrSet.java

示例6: getAllKeys

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
private Collection<?> getAllKeys() {
    HashSet<Object> allKeys = new HashSet<Object>();

    for(AttributeSet delegate : delegates) {
        for(Enumeration<?> keys = delegate.getAttributeNames(); keys.hasMoreElements(); ) {
            Object key = keys.nextElement();
            allKeys.add(key);
        }
    }

    return allKeys;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:13,代碼來源:AttributesUtilities.java

示例7: dumpAttribs

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
private void dumpAttribs(AttributeSet attribs, String name, boolean tokenColoring) {
//        if (!allFcsi[0].getMimePath().getPath().equals("text/x-java")) { //NOI18N
//            return;
//        }

        StringBuilder sb = new StringBuilder();
        sb.append("Attribs for base mime path '"); //NOI18N
        sb.append(allFcsi[0].getMimePath().getPath());
        sb.append("' and "); //NOI18N
        if (tokenColoring) {
            sb.append("token '"); //NOI18N
        } else {
            sb.append("highlight '"); //NOI18N
        }
        sb.append(name);
        sb.append("' = {"); //NOI18N

        Enumeration<?> keys = attribs.getAttributeNames();
        while (keys.hasMoreElements()) {
            Object key = keys.nextElement();
            Object value = attribs.getAttribute(key);

            sb.append("'").append(key).append("' = '").append(value).append("'"); //NOI18N
            if (keys.hasMoreElements()) {
                sb.append(", "); //NOI18N
            }
        }

        sb.append("} CompoundFCS.this = "); //NOI18N
        sb.append(this.toString());

        System.out.println(sb.toString());
    }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:34,代碼來源:CompositeFCS.java

示例8: translate

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
public static Map<Attribute,Object> translate(AttributeSet attrs) {
    int attrCount = attrs.getAttributeCount();
    Map<Attribute,Object> ret = new HashMap<Attribute, Object>(attrCount);
    for (Enumeration<?> attrNames = attrs.getAttributeNames(); attrNames.hasMoreElements();) {
        Object attrName = attrNames.nextElement();
        AttributeTranslateHandler handler = attr2Handler.get(attrName);
        if (handler != null) {
            Object textAttrValue = handler.getTextAttrValue(attrs.getAttribute(attrName));
            if (textAttrValue != null) {
                ret.put(handler.getTextAttr(), textAttrValue);
            }
        } // Unknown attributes are ignored
    }
    return ret;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:AttributedCharSequence.java

示例9: addAttributes

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
public void addAttributes(AttributeSet attr)
{
    Enumeration as = attr.getAttributeNames();
    while(as.hasMoreElements()) {
        Object el = as.nextElement();
        backing.put(el, attr.getAttribute(el));
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:9,代碼來源:MockAttributeSet.java

示例10: containsAttributes

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
public boolean containsAttributes(AttributeSet attributes) {
    Enumeration e = attributes.getAttributeNames();
    while(e.hasMoreElements()) {
        Object key = e.nextElement();
        Object value = attributes.getAttribute(key);
        if(!containsAttribute(key, value)) return false;
    }
    return true;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:DocumentElement.java

示例11: attrValue

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
private static String attrValue(AttributeSet attr, String attrName) {
    for (Enumeration en = attr.getAttributeNames(); en.hasMoreElements(); ) {
        Object name = en.nextElement();
        if (attrName.equalsIgnoreCase(name.toString())) {
            return attrValue(attr, name);
        }
    }
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:ButtonsHTMLParser.java

示例12: adjustAttributes

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
private static AttributeSet adjustAttributes(AttributeSet as) {
    Collection<Object> attrs = new LinkedList<Object>();
    
    for (Enumeration<?> e = as.getAttributeNames(); e.hasMoreElements(); ) {
        Object key = e.nextElement();
        Object value = as.getAttribute(key);
        
        if (value != Boolean.FALSE) {
            attrs.add(key);
            attrs.add(value);
        }
    }
    
    return AttributesUtilities.createImmutable(attrs.toArray());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:ColoringManager.java

示例13: convertToHTML32

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
/**
 * Create an older style of HTML attributes.  This will
 * convert character level attributes that have a StyleConstants
 * mapping over to an HTML tag/attribute.  Other CSS attributes
 * will be placed in an HTML style attribute.
 */
private static void convertToHTML32(AttributeSet from, MutableAttributeSet to) {
    if (from == null) {
        return;
    }
    Enumeration keys = from.getAttributeNames();
    String value = "";
    while (keys.hasMoreElements()) {
        Object key = keys.nextElement();
        if (key instanceof CSS.Attribute) {
            if ((key == CSS.Attribute.FONT_FAMILY)
                || (key == CSS.Attribute.FONT_SIZE)
                || (key == CSS.Attribute.COLOR)) {

                createFontAttribute((CSS.Attribute) key, from, to);
            }
            else if (key == CSS.Attribute.FONT_WEIGHT) {
                // add a bold tag is weight is bold
                //CSS.FontWeight weightValue = (CSS.FontWeight) from.getAttribute(CSS.Attribute.FONT_WEIGHT);
                String weightValue = from.getAttribute(CSS.Attribute.FONT_WEIGHT).toString();
                if (weightValue != null) {
                    int fweight;
                    try {
                        fweight = new Integer(weightValue).intValue();
                    }
                    catch (Exception ex) {
                        fweight = -1;
                    }
                    if ((weightValue.toLowerCase().equals("bold")) || (fweight > 400))
                        to.addAttribute(HTML.Tag.B, SimpleAttributeSet.EMPTY);
                }
            }
            else if (key == CSS.Attribute.FONT_STYLE) {
                String s = from.getAttribute(key).toString();
                if (s.indexOf("italic") >= 0) {
                    to.addAttribute(HTML.Tag.I, SimpleAttributeSet.EMPTY);
                }
            }
            else if (key == CSS.Attribute.TEXT_DECORATION) {
                String decor = from.getAttribute(key).toString();
                if (decor.indexOf("underline") >= 0) {
                    to.addAttribute(HTML.Tag.U, SimpleAttributeSet.EMPTY);
                }
                if (decor.indexOf("line-through") >= 0) {
                    to.addAttribute(HTML.Tag.STRIKE, SimpleAttributeSet.EMPTY);
                }
            }
            else if (key == CSS.Attribute.VERTICAL_ALIGN) {
                String vAlign = from.getAttribute(key).toString();
                if (vAlign.indexOf("sup") >= 0) {
                    to.addAttribute(HTML.Tag.SUP, SimpleAttributeSet.EMPTY);
                }
                if (vAlign.indexOf("sub") >= 0) {
                    to.addAttribute(HTML.Tag.SUB, SimpleAttributeSet.EMPTY);
                }
            }
            else if (key == CSS.Attribute.TEXT_ALIGN) {
                to.addAttribute(HTML.Attribute.ALIGN, from.getAttribute(key).toString());
            }
            else {
                // default is to store in a HTML style attribute
                if (value.length() > 0) {
                    value = value + "; ";
                }
                value = value + key + ": " + from.getAttribute(key);
            }
        }
        else {
            to.addAttribute(key, from.getAttribute(key));
        }
    }
    if (value.length() > 0) {
        to.addAttribute(HTML.Attribute.STYLE, value);
    }
}
 
開發者ID:ser316asu,項目名稱:Wilmersdorf_SER316,代碼行數:81,代碼來源:AltHTMLWriter.java


注:本文中的javax.swing.text.AttributeSet.getAttributeNames方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。