javax.swing.text.MutableAttributeSet Java Examples
The following examples show how to use
javax.swing.text.MutableAttributeSet.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CasAnnotationViewer.java From uima-uimaj with Apache License 2.0 | 7 votes |
/** * Do bold face by spans. */ private void doBoldFaceBySpans() { if (this.boldFaceSpans == null || this.boldFaceSpans.length == 0) { return; } int docLength = this.cas.getDocumentText().length(); int spanLength = this.boldFaceSpans.length - (this.boldFaceSpans.length % 2); int i = 0; while (i < spanLength) { int begin = this.boldFaceSpans[i]; int end = this.boldFaceSpans[i + 1]; if (begin >= 0 && begin <= docLength && end >= 0 && end <= docLength && begin < end) { MutableAttributeSet attrs = new SimpleAttributeSet(); StyleConstants.setBold(attrs, true); StyledDocument doc = (StyledDocument) this.textPane.getDocument(); doc.setCharacterAttributes(begin, end - begin, attrs, false); } i += 2; } }
Example #2
Source File: MWPaneSelectionManager.java From wpcleaner with Apache License 2.0 | 7 votes |
/** * Select previous occurrence of text. */ public void selectPreviousOccurrence() { StyledDocument doc = textPane.getStyledDocument(); int lastStart = Integer.MIN_VALUE; for (int pos = textPane.getSelectionStart(); pos > 0; pos = lastStart) { Element run = doc.getCharacterElement(pos - 1); lastStart = run.getStartOffset(); MutableAttributeSet attr = (MutableAttributeSet) run.getAttributes(); if ((attr != null) && (attr.getAttribute(MWPaneFormatter.ATTRIBUTE_TYPE) != null) && (attr.getAttribute(MWPaneFormatter.ATTRIBUTE_OCCURRENCE) != Boolean.FALSE)) { select(run); return; } } selectLastOccurrence(); }
Example #3
Source File: JConsole.java From MeteoInfo with GNU Lesser General Public License v3.0 | 6 votes |
private AttributeSet setStyle( String fontFamilyName, int size, Color color, boolean bold, boolean italic, boolean underline ) { MutableAttributeSet attr = new SimpleAttributeSet(); if (color != null) { StyleConstants.setForeground(attr, color); } if (fontFamilyName != null) { StyleConstants.setFontFamily(attr, fontFamilyName); } if (size != -1) { StyleConstants.setFontSize(attr, size); } StyleConstants.setBold(attr, bold); StyleConstants.setItalic(attr, italic); StyleConstants.setUnderline(attr, underline); setStyle(attr); return getStyle(); }
Example #4
Source File: RTFAttributes.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public boolean set(MutableAttributeSet target, int parameter) { Number swingValue; if (scale == 1f) swingValue = Integer.valueOf(parameter); else swingValue = new Float(parameter / scale); target.addAttribute(swingName, swingValue); return true; }
Example #5
Source File: RTFAttributes.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public boolean set(MutableAttributeSet target) { /* TODO: There's some ambiguity about whether this should *set* or *toggle* the attribute. */ target.addAttribute(swingName, True); return true; /* true indicates we were successful */ }
Example #6
Source File: Html2Text.java From ObjectLogger with Apache License 2.0 | 5 votes |
@Override public void handleStartTag(HTML.Tag t, MutableAttributeSet a, int pos) { if (stringBuilder.length() != 0 && t.isBlock() && !stringBuilder.toString().endsWith(lineBreak)) { stringBuilder.append(lineBreak); } }
Example #7
Source File: JTermDocument.java From MobyDroid with Apache License 2.0 | 5 votes |
public void write(String text, MutableAttributeSet attrs) { try { insertString(getLength(), text, attrs); limit = getLength(); caret.setDot(limit); } catch (BadLocationException e) { } }
Example #8
Source File: RTFAttributes.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
public boolean set(MutableAttributeSet target, int parameter) { Number swingValue; if (scale == 1f) swingValue = Integer.valueOf(parameter); else swingValue = new Float(parameter / scale); target.addAttribute(swingName, swingValue); return true; }
Example #9
Source File: RTFAttributes.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public boolean set(MutableAttributeSet target, int parameter) { /* See above note in the case that parameter==1 */ Boolean value = ( parameter != 0 ? True : False ); target.addAttribute(swingName, value); return true; /* true indicates we were successful */ }
Example #10
Source File: RTFAttributes.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
public boolean setDefault(MutableAttributeSet target) { if (swingDefault != rtfDefault || ( target.getAttribute(swingName) != null ) ) target.addAttribute(swingName, Boolean.valueOf(rtfDefault)); return true; }
Example #11
Source File: RTFAttributes.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public boolean set(MutableAttributeSet target) { /* TODO: There's some ambiguity about whether this should *set* or *toggle* the attribute. */ target.addAttribute(swingName, True); return true; /* true indicates we were successful */ }
Example #12
Source File: RTFAttributes.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public boolean set(MutableAttributeSet target) { if (swingValue == null) target.removeAttribute(swingName); else target.addAttribute(swingName, swingValue); return true; }
Example #13
Source File: RTFAttributes.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public boolean set(MutableAttributeSet target, int parameter) { Number swingValue; if (scale == 1f) swingValue = Integer.valueOf(parameter); else swingValue = new Float(parameter / scale); target.addAttribute(swingName, swingValue); return true; }
Example #14
Source File: RTFAttributes.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public boolean setDefault(MutableAttributeSet target) { if (swingDefault != rtfDefault || ( target.getAttribute(swingName) != null ) ) target.addAttribute(swingName, Boolean.valueOf(rtfDefault)); return true; }
Example #15
Source File: ButtonGroupDemo.java From radiance with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static void toggleStyleInSelection(JTextPane textPane, Object style) { MutableAttributeSet attrSet = new SimpleAttributeSet(); // Add or remove the style on the entire selection attrSet.addAttribute(style, !hasStyleInSelection(textPane, style)); textPane.getStyledDocument().setCharacterAttributes(textPane.getSelectionStart(), textPane.getSelectionEnd() - textPane.getSelectionStart(), attrSet, false); }
Example #16
Source File: RTFAttributes.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public boolean set(MutableAttributeSet target, int parameter) { Number swingValue; if (scale == 1f) swingValue = Integer.valueOf(parameter); else swingValue = new Float(parameter / scale); target.addAttribute(swingName, swingValue); return true; }
Example #17
Source File: RTFAttributes.java From Java8CN with Apache License 2.0 | 5 votes |
public boolean set(MutableAttributeSet target, int parameter) { /* See above note in the case that parameter==1 */ Boolean value = ( parameter != 0 ? True : False ); target.addAttribute(swingName, value); return true; /* true indicates we were successful */ }
Example #18
Source File: RTFAttributes.java From hottub with GNU General Public License v2.0 | 5 votes |
public boolean setDefault(MutableAttributeSet target) { Number old = (Number)target.getAttribute(swingName); if (old == null) old = swingDefault; if (old != null && ( (scale == 1f && old.intValue() == rtfDefault) || (Math.round(old.floatValue() * scale) == rtfDefault) )) return true; set(target, rtfDefault); return true; }
Example #19
Source File: PGrammarPane.java From PolyGlot with MIT License | 5 votes |
public void addImage(ImageNode image) { try { MutableAttributeSet inputAttributes = getInputAttributes(); inputAttributes.removeAttributes(inputAttributes); StyleConstants.setIcon(inputAttributes, new ImageIcon(image.getImagePath())); inputAttributes.addAttribute(PGTUtil.IMAGE_ID_ATTRIBUTE, image.getId()); imageReplaceSelection(" "); inputAttributes.removeAttributes(inputAttributes); } catch (IOException e) { IOHandler.writeErrorLog(e); InfoBox.error("Image Insertion Error", "Unable to insert image: " + e.getLocalizedMessage(), core.getRootWindow()); } }
Example #20
Source File: RTFAttributes.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public boolean set(MutableAttributeSet target, int parameter) { Number swingValue; if (scale == 1f) swingValue = Integer.valueOf(parameter); else swingValue = new Float(parameter / scale); target.addAttribute(swingName, swingValue); return true; }
Example #21
Source File: RTFAttributes.java From Java8CN with Apache License 2.0 | 5 votes |
public boolean setDefault(MutableAttributeSet target) { if (swingDefault != rtfDefault || ( target.getAttribute(swingName) != null ) ) target.addAttribute(swingName, Boolean.valueOf(rtfDefault)); return true; }
Example #22
Source File: RTFAttributes.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
public boolean set(MutableAttributeSet target, int parameter) { Number swingValue; if (scale == 1f) swingValue = Integer.valueOf(parameter); else swingValue = new Float(parameter / scale); target.addAttribute(swingName, swingValue); return true; }
Example #23
Source File: RTFAttributes.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
public boolean set(MutableAttributeSet target, int parameter) { /* See above note in the case that parameter==1 */ Boolean value = ( parameter != 0 ? True : False ); target.addAttribute(swingName, value); return true; /* true indicates we were successful */ }
Example #24
Source File: RTFAttributes.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public boolean set(MutableAttributeSet target) { if (swingValue == null) target.removeAttribute(swingName); else target.addAttribute(swingName, swingValue); return true; }
Example #25
Source File: RTFAttributes.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public boolean set(MutableAttributeSet target) { if (swingValue == null) target.removeAttribute(swingName); else target.addAttribute(swingName, swingValue); return true; }
Example #26
Source File: RTFAttributes.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public boolean setDefault(MutableAttributeSet target) { Number old = (Number)target.getAttribute(swingName); if (old == null) old = swingDefault; if (old != null && ( (scale == 1f && old.intValue() == rtfDefault) || (Math.round(old.floatValue() * scale) == rtfDefault) )) return true; set(target, rtfDefault); return true; }
Example #27
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
private void setElementColor(Element element, String color) { AttributeSet attrs = element.getAttributes(); Object o = attrs.getAttribute(HTML.Tag.A); if (o instanceof MutableAttributeSet) { MutableAttributeSet a = (MutableAttributeSet) o; a.addAttribute(HTML.Attribute.COLOR, color); } }
Example #28
Source File: RTFAttributes.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public boolean set(MutableAttributeSet target, int parameter) { /* See above note in the case that parameter==1 */ Boolean value = ( parameter != 0 ? True : False ); target.addAttribute(swingName, value); return true; /* true indicates we were successful */ }
Example #29
Source File: RTFAttributes.java From JDKSourceCode1.8 with MIT License | 5 votes |
public boolean set(MutableAttributeSet target, int parameter) { /* See above note in the case that parameter==1 */ Boolean value = ( parameter != 0 ? True : False ); target.addAttribute(swingName, value); return true; /* true indicates we were successful */ }
Example #30
Source File: RTFAttributes.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public boolean set(MutableAttributeSet target, int parameter) { Number swingValue; if (scale == 1f) swingValue = Integer.valueOf(parameter); else swingValue = Float.valueOf(parameter / scale); target.addAttribute(swingName, swingValue); return true; }