本文整理了Java中javax.swing.text.AttributeSet.containsAttribute()
方法的一些代码示例,展示了AttributeSet.containsAttribute()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AttributeSet.containsAttribute()
方法的具体详情如下:
包路径:javax.swing.text.AttributeSet
类名称:AttributeSet
方法名:containsAttribute
暂无
代码示例来源:origin: stackoverflow.com
System.out.println(element);
AttributeSet as = element.getAttributes();
if (as.containsAttribute(ELEM, ICON)) {
System.out.println(StyleConstants.getIcon(as).getClass());
if (as.containsAttribute(ELEM, COMP)) {
System.out.println(StyleConstants.getComponent(as).getClass());
代码示例来源:origin: stackoverflow.com
public void jToolBarInitButtons() {
jTextPane1.addCaretListener(new CaretListener() {
@Override
public void caretUpdate(CaretEvent e) {
StyledDocument styleddoc = (StyledDocument) jTextPane1.getDocument();
AttributeSet attributes = jTextPane1.getCharacterAttributes();
System.out.println("bold " + attributes.containsAttribute(StyleConstants.Bold, Boolean.TRUE));
System.out.println("italic " + attributes.containsAttribute(StyleConstants.Italic, Boolean.TRUE));
}
代码示例来源:origin: stackoverflow.com
AttributeSet attributes = jTextPane1.getCharacterAttributes();
System.out.println( attributes.containsAttribute(StyleConstants.Bold, Boolean.TRUE) );
代码示例来源:origin: stackoverflow.com
private void iterateOverContent(JTextPane tp2) {
for(int i = 0; i < tp.getDocument().getLength(); i++) {
Element elem = ((StyledDocument) tp.getDocument()).getCharacterElement(i);
AttributeSet as = elem.getAttributes();
if (as.containsAttribute(AbstractDocument.ElementNameAttribute, StyleConstants.ComponentElementName)) {
if(StyleConstants.getComponent(as) instanceof JLabel) {
JLabel myLabel = (JLabel)StyleConstants.getComponent(as);
System.out.println(myLabel.getText());
}
}
System.out.println(((StyledDocument) tp.getDocument()).getCharacterElement(i));
}
}
代码示例来源:origin: chatty/chatty
/**
* Checks if the given line contains an attribute indicating that the line
* is already deleted.
*
* @param line The element representing this line
* @return
*/
private boolean isLineDeleted(Element line) {
return line.getAttributes().containsAttribute(Attribute.DELETED_LINE, true);
}
代码示例来源:origin: chatty/chatty
public static boolean hasAttributeKeyValue(Element element, Object key, Object value) {
return element.getAttributes().containsAttribute(key, value);
}
代码示例来源:origin: chatty/chatty
if (rangeStyle.containsAttribute(Attribute.IS_REPLACEMENT, true)) {
rangeText = (String)rangeStyle.getAttribute(Attribute.REPLACED_WITH);
} else {
代码示例来源:origin: chatty/chatty
private void updateDebugInfo() {
if (!Debugging.isEnabled("gifd0")) {
return;
}
synchronized(imageViews) {
int totalViews = 0;
int hiddenViews = 0;
int animated = 0;
for (Map<Long, WeakReference<MyIconView>> e : imageViews.values()) {
for (WeakReference<MyIconView> ref : e.values()) {
MyIconView view = ref.get();
totalViews++;
if (view != null) {
if (!view.getShouldRepaint()) {
hiddenViews++;
}
if (view.getAttributes().containsAttribute(ChannelTextPane.Attribute.ANIMATED, true)) {
animated++;
}
}
}
}
Debugging.printlnTimed("imageViews"+this.hashCode(),
String.format("images: %d views: %d animated: %d hidden: %d",
imageViews.size(), totalViews, animated, hiddenViews));
}
}
代码示例来源:origin: chatty/chatty
@Override
public void paint(Graphics g, Shape a) {
boolean isEmpty = getDocument().getLength() < 2;
Color bgColor = (Color)getAttributes().getAttribute(Attribute.CUSTOM_BACKGROUND);
if (bgColor == null && getAttributes().containsAttribute(Attribute.HIGHLIGHT_LINE, true)) {
bgColor = MyStyleConstants.getHighlightBackground(getAttributes());
}
if (bgColor == null && getAttributes().containsAttribute(Attribute.EVEN, true)) {
bgColor = MyStyleConstants.getBackground2(getAttributes());
}
if (bgColor != null && !isEmpty) {
g.setColor(bgColor);
Rectangle r = a.getBounds();
g.fillRect(0, r.y, getContainer().getWidth(), r.height);
}
Color separatorColor = MyStyleConstants.getSeparatorColor(getAttributes());
if (separatorColor != null && !isEmpty) {
g.setColor(separatorColor);
Rectangle r = a.getBounds();
g.drawLine(0, r.y, getContainer().getWidth(), r.y);
if (bgColor != null) {
g.drawLine(0, r.y+r.height, getContainer().getWidth(), r.y+r.height);
}
}
super.paint(g, a);
}
代码示例来源:origin: stackoverflow.com
System.out.println("Bold " + attributes.containsAttribute(StyleConstants.Bold, Boolean.TRUE));
System.out.println("Italic " + attributes.containsAttribute("Italic " + StyleConstants.Italic, Boolean.TRUE));
System.out.println("Underline " + attributes.containsAttribute(StyleConstants.Underline, Boolean.TRUE));
代码示例来源:origin: chatty/chatty
&& getAttributes().containsAttribute(Attribute.HIGHLIGHT_WORD, true)) {
Color c = StyleConstants.getForeground(getAttributes());
Color c2;
代码示例来源:origin: chatty/chatty
@Override
public float getPreferredSpan(int axis) {
boolean highlightMatchesEnabled = MyStyleConstants.getHighlightMatchesEnabled(getAttributes());
if (axis == View.X_AXIS
&& highlightMatchesEnabled
&& getAttributes().containsAttribute(Attribute.HIGHLIGHT_WORD, true)) {
// Make a bit wider for marking the highlighted word
return super.getPreferredSpan(axis)+3;
}
return super.getPreferredSpan(axis);
}
代码示例来源:origin: chatty/chatty
@Override
public float getPreferredSpan(int axis) {
if (axis == View.Y_AXIS && Debugging.isEnabled("iconold1")) {
float height = super.getPreferredSpan(axis);
return height * 0.7f;
}
if (axis == View.Y_AXIS) {
int fontHeight = MyStyleConstants.getFontHeight(getAttributes());
float height = super.getPreferredSpan(axis);
if (fontHeight >= height) {
return height;
}
float spacing;
if (getAttributes().containsAttribute(Attribute.ANIMATED, true)) {
spacing = StyleConstants.getLineSpacing(getAttributes()) * fontHeight;
} else {
spacing = StyleConstants.getLineSpacing(getAttributes()) * fontHeight + StyleConstants.getSpaceBelow(getAttributes());
if (!Debugging.isEnabled("iconold2")) {
spacing += Math.max(StyleConstants.getSpaceAbove(getAttributes()) - 1 - MARGIN, 0);
}
}
float toFontHeight = Math.max(height - fontHeight - MARGIN, 0);
float availableSpace = Math.max(spacing - MARGIN, 0);
//Debugging.println(toFontHeight+" "+availableSpace);
return height - Math.min(toFontHeight, availableSpace);
}
return super.getPreferredSpan(axis);
}
代码示例来源:origin: chatty/chatty
if (firstElement != null) {
AttributeSet attr = firstElement.getAttributes();
if (attr.containsAttribute(Attribute.IS_BAN_MESSAGE, user)
&& getTimeAgo(firstElement) < MAX_BAN_MESSAGE_COMBINE_TIME) {
if (attr.getAttribute(Attribute.BAN_MESSAGE).equals(newMessage)) {
代码示例来源:origin: chatty/chatty
if (line.getAttributes().containsAttribute(Attribute.COMMAND, command)) {
Element infoElement = getElementContainingAttributeKey(line,
Attribute.IS_APPENDED_INFO);
if (userElement.getAttributes().containsAttribute(Attribute.ID_AUTOMOD, info.data.msgId)) {
changeInfo(line, attr -> {
String existing = (String) attr.getAttribute(Attribute.AUTOMOD_ACTION);
if (line.getAttributes().containsAttribute(Attribute.COMMAND, command)) {
changeInfo(line, attributes -> {
addBy(attributes, info.data.created_by);
内容来源于网络,如有侵权,请联系作者删除!