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());
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)); }
AttributeSet attributes = jTextPane1.getCharacterAttributes(); System.out.println( attributes.containsAttribute(StyleConstants.Bold, Boolean.TRUE) );
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)); } }
/** * 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); }
public static boolean hasAttributeKeyValue(Element element, Object key, Object value) { return element.getAttributes().containsAttribute(key, value); }
if (rangeStyle.containsAttribute(Attribute.IS_REPLACEMENT, true)) { rangeText = (String)rangeStyle.getAttribute(Attribute.REPLACED_WITH); } else {
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)); } }
@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); }
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));
&& getAttributes().containsAttribute(Attribute.HIGHLIGHT_WORD, true)) { Color c = StyleConstants.getForeground(getAttributes()); Color c2;
@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); }
@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); }
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)) {
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);