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


Java AttributeSet.containsAttribute方法代碼示例

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


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

示例1: findNextUnused

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
private int findNextUnused(JTextComponent comp, int offset) {
    try {
        BaseDocument doc = Utilities.getDocument(comp);
        int lineStart = Utilities.getRowStart(doc, offset);
        // "unused-browseable" in java.editor/.../ColoringManager and csl.api/.../ColoringManager
        HighlightsSequence s = HighlightingManager.getInstance(comp).getBottomHighlights().getHighlights(lineStart, Integer.MAX_VALUE);
        int lastUnusedEndOffset = -1;

        while (s.moveNext()) {
            AttributeSet attrs = s.getAttributes();
            if (attrs != null && attrs.containsAttribute("unused-browseable", Boolean.TRUE)) {
                
                if (lastUnusedEndOffset != s.getStartOffset() && s.getStartOffset() >= offset) {
                    return s.getStartOffset();
                }
                lastUnusedEndOffset = s.getEndOffset();
            }
        }

        return -1;
    } catch (BadLocationException ex) {
        Exceptions.printStackTrace(ex);
        return -1;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:NextErrorAction.java

示例2: Highlighting

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
/** Creates a new instance of Highlighting */
public Highlighting(Document doc) {
    AttributeSet firstLineFontColor = MimeLookup.getLookup(MimePath.get("text/x-java")).lookup(FontColorSettings.class).getTokenFontColors("javadoc-first-sentence"); //NOI18N
    AttributeSet commentFontColor = MimeLookup.getLookup(MimePath.get("text/x-java")).lookup(FontColorSettings.class).getTokenFontColors("comment"); //NOI18N
    if(firstLineFontColor != null && commentFontColor != null) {
        Collection<Object> attrs = new LinkedList<Object>();
        for (Enumeration<?> e = firstLineFontColor.getAttributeNames(); e.hasMoreElements(); ) {
            Object key = e.nextElement();
            Object value = firstLineFontColor.getAttribute(key);

            if (!commentFontColor.containsAttribute(key, value)) {
                attrs.add(key);
                attrs.add(value);
            }
        }
        fontColor = AttributesUtilities.createImmutable(attrs.toArray());
    } else {
        fontColor = AttributesUtilities.createImmutable();
        LOG.warning("FontColorSettings for javadoc-first-sentence or comment are not available."); //NOI18N
    }
    this.document = doc;
    hierarchy = TokenHierarchy.get(document);
    if (hierarchy != null) {
        hierarchy.addTokenHierarchyListener(WeakListeners.create(TokenHierarchyListener.class, this, hierarchy));
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:Highlighting.java

示例3: containsAttribute

import javax.swing.text.AttributeSet; //導入方法依賴的package包/類
public boolean containsAttribute(Object key, Object value) {
    for(AttributeSet delegate : delegates) {
        if (delegate.containsAttribute(key, value)) {
            return true;
        }
    }

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


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