本文整理汇总了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;
}
}
示例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));
}
}
示例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;
}