List of usage examples for javax.swing.text StyleConstants isUnderline
public static boolean isUnderline(AttributeSet a)
From source file:net.sf.jasperreports.engine.util.JEditorPaneHtmlMarkupProcessor.java
@Override protected Map<Attribute, Object> getAttributes(AttributeSet attrSet) { Map<Attribute, Object> attrMap = new HashMap<Attribute, Object>(); if (attrSet.isDefined(StyleConstants.FontFamily)) { attrMap.put(TextAttribute.FAMILY, StyleConstants.getFontFamily(attrSet)); }//ww w . j av a 2 s.c om if (attrSet.isDefined(StyleConstants.Bold)) { attrMap.put(TextAttribute.WEIGHT, StyleConstants.isBold(attrSet) ? TextAttribute.WEIGHT_BOLD : TextAttribute.WEIGHT_REGULAR); } if (attrSet.isDefined(StyleConstants.Italic)) { attrMap.put(TextAttribute.POSTURE, StyleConstants.isItalic(attrSet) ? TextAttribute.POSTURE_OBLIQUE : TextAttribute.POSTURE_REGULAR); } if (attrSet.isDefined(StyleConstants.Underline)) { attrMap.put(TextAttribute.UNDERLINE, StyleConstants.isUnderline(attrSet) ? TextAttribute.UNDERLINE_ON : null); } if (attrSet.isDefined(StyleConstants.StrikeThrough)) { attrMap.put(TextAttribute.STRIKETHROUGH, StyleConstants.isStrikeThrough(attrSet) ? TextAttribute.STRIKETHROUGH_ON : null); } if (attrSet.isDefined(StyleConstants.FontSize)) { attrMap.put(TextAttribute.SIZE, StyleConstants.getFontSize(attrSet)); } if (attrSet.isDefined(StyleConstants.Foreground)) { attrMap.put(TextAttribute.FOREGROUND, StyleConstants.getForeground(attrSet)); } if (attrSet.isDefined(StyleConstants.Background)) { attrMap.put(TextAttribute.BACKGROUND, StyleConstants.getBackground(attrSet)); } //FIXME: why StyleConstants.isSuperscript(attrSet) does return false if (attrSet.isDefined(StyleConstants.Superscript) && !StyleConstants.isSubscript(attrSet)) { attrMap.put(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUPER); } if (attrSet.isDefined(StyleConstants.Subscript) && StyleConstants.isSubscript(attrSet)) { attrMap.put(TextAttribute.SUPERSCRIPT, TextAttribute.SUPERSCRIPT_SUB); } return attrMap; }
From source file:net.java.sip.communicator.impl.gui.main.chat.ChatWritePanel.java
/** * Enables the underline style/*from w w w.ja v a 2s .c o m*/ * @param b TRUE enable - FALSE disable */ public void setUnderlineStyleEnable(boolean b) { StyledEditorKit editorKit = (StyledEditorKit) editorPane.getEditorKit(); MutableAttributeSet attr = editorKit.getInputAttributes(); if (b && !StyleConstants.isUnderline(attr)) { setStyleConstant(new HTMLEditorKit.UnderlineAction(), StyleConstants.Underline); } }
From source file:plugin.notes.gui.NotesView.java
/** * Updates Editing buttons based on the location of the cursor * *@param textPane text pane to update buttons base on *@param pos current text position *///from w ww . j ava 2 s . c o m private void updateButtons(JTextPane textPane, int pos) { StyledDocument doc = textPane.getStyledDocument(); AttributeSet set = doc.getCharacterElement(pos - 1).getAttributes(); AttributeSet set1 = doc.getCharacterElement(pos).getAttributes(); if (StyleConstants.isBold(set) && StyleConstants.isBold(set1)) { highlightButton(boldButton); } else { stdButton(boldButton); } if (StyleConstants.isItalic(set) && StyleConstants.isItalic(set1)) { highlightButton(italicButton); } else { stdButton(italicButton); } if (StyleConstants.isUnderline(set) && StyleConstants.isUnderline(set1)) { highlightButton(underlineButton); } else { stdButton(underlineButton); } int align = StyleConstants.getAlignment(set); stdButton(leftJustifyButton); stdButton(rightJustifyButton); stdButton(centerJustifyButton); if (align == StyleConstants.ALIGN_LEFT) { highlightButton(leftJustifyButton); } else if (align == StyleConstants.ALIGN_RIGHT) { highlightButton(rightJustifyButton); } else if (align == StyleConstants.ALIGN_CENTER) { highlightButton(centerJustifyButton); } int fontSize = StyleConstants.getFontSize(set); for (int i = 0; i < sizeCB.getItemCount(); i++) { String value = (String) sizeCB.getItemAt(i); if (value.equals(Integer.toString(fontSize))) { sizeCB.setSelectedItem(value); break; } } }