/** * Highlights specified text region by changing the character attributes */ private void highlightText(int start, int end, SimpleAttributeSet style) { if (start < end) { textPane.getStyledDocument().setCharacterAttributes(start, end - start + 1, style, false); } }
int lenght = pairIntList.get(++i) - start + 1; doc.setCharacterAttributes(start, lenght, alertStyle, false);
StyleConstants.setUnderline(set, random.nextBoolean()); doc.setCharacterAttributes(i, 1, set, true);
doc.setCharacterAttributes(0, doc.getLength(), defaultStyle, false);
private void fadeOntologyURI(StyledDocument doc, int tokenStartIndex, int tokenLength, boolean enclosedByBracket) { // if surrounded by brackets, also render them in grey int start = tokenStartIndex; int length = tokenLength; if (enclosedByBracket) { start--; length = length + 2; } doc.setCharacterAttributes(start, length, ontologyURIStyle, true); }
private void strikeoutEntityIfCrossedOut(OWLEntity entity, StyledDocument doc, int tokenStartIndex, int tokenLength) { if (crossedOutEntities.contains(entity) || strikeThrough) { doc.setCharacterAttributes(tokenStartIndex, tokenLength, strikeOutStyle, false); } }
private void strikeoutEntityIfCrossedOut(OWLEntity entity, StyledDocument doc, int tokenStartIndex, int tokenLength) { if(crossedOutEntities.contains(entity)) { doc.setCharacterAttributes(tokenStartIndex, tokenLength, strikeOutStyle, false); } }
private void strikeoutEntityIfCrossedOut(OWLEntity entity, StyledDocument doc, int tokenStartIndex, int tokenLength) { if(crossedOutEntities.contains(entity) || strikeThrough) { doc.setCharacterAttributes(tokenStartIndex, tokenLength, strikeOutStyle, false); } }
private void strikeoutEntityIfCrossedOut(OWLEntity entity, StyledDocument doc, int tokenStartIndex, int tokenLength) { if(crossedOutEntities.contains(entity) || strikeThrough) { doc.setCharacterAttributes(tokenStartIndex, tokenLength, strikeOutStyle, false); } }
/** Remove guarded mark on a block of a document. * @param doc styled document * @param offset offset to start at * @param len length of text to mark as unguarded * @exception NullPointerException If the <code>doc</code> parameter * is <code>null</code>. */ public static void unmarkGuarded(StyledDocument doc, int offset, int len) { checkDocParameter(doc); doc.setCharacterAttributes(offset, len, ATTR_REMOVE, false); }
/** Mark part of a document as guarded (immutable to the user). * @param doc styled document * @param offset offset to start at * @param len length of text to mark as guarded * @exception NullPointerException If the <code>doc</code> parameter * is <code>null</code>. */ public static void markGuarded(StyledDocument doc, int offset, int len) { checkDocParameter(doc); doc.setCharacterAttributes(offset, len, ATTR_ADD, false); }
Simple AttributeSet changed = new SimpleAttributeSet(); StyleConstants.setForeground(changed, Color.RED); StyleConstants.setBackground(changed, Color.YELLOW); // Change attributes on some text StyledDocument doc = textPane.getStyledDocument(); doc.setCharacterAttributes(20, 4, changed, false);
// Define a keyword attribute SimpleAttributeSet keyWord = new SimpleAttributeSet(); StyleConstants.setForeground(keyWord, Color.RED); StyleConstants.setBackground(keyWord, Color.YELLOW); StyleConstants.setUnderline(keyWord, Boolean.TRUE ); StyleConstants.setBold(keyWord, true); // Change attributes on some text StyledDocument doc = textPane.getStyledDocument(); doc.setCharacterAttributes(start, end - start, keyWord, false);
/** * Highlights specified text region by changing the character attributes */ private void highlightText(int start, int end, SimpleAttributeSet style) { if (start < end) { textPane.getStyledDocument().setCharacterAttributes(start, end - start + 1, style, false); } }
/** Mark part of a document as guarded (immutable to the user). * @param doc styled document * @param offset offset to start at * @param len length of text to mark as guarded * @exception NullPointerException If the <code>doc</code> parameter * is <code>null</code>. */ public static void markGuarded (StyledDocument doc, int offset, int len) { checkDocParameter(doc); doc.setCharacterAttributes (offset, len, ATTR_ADD, false); }
JTextPane textPane = new JTextPane(); textPane.setText( "one\ntwo\nthree\nfour\nfive\nsix\nseven\neight" ); StyledDocument doc = textPane.getStyledDocument(); // Define a keyword attribute SimpleAttributeSet keyWord = new SimpleAttributeSet(); StyleConstants.setForeground(keyWord, Color.RED); StyleConstants.setBackground(keyWord, Color.YELLOW); // Change attributes on some text doc.setCharacterAttributes(0, 5, keyWord, false);
public static void increaseJTextPaneFont(JTextPane jtp) { MutableAttributeSet attrs = jtp.getInputAttributes(); //first get the current size of the font int size = StyleConstants.getFontSize(attrs); //now increase by 2 (or whatever factor you like) StyleConstants.setFontSize(attrs, size * 2); StyledDocument doc = jtp.getStyledDocument(); doc.setCharacterAttributes(0, doc.getLength() + 1, attrs, false); }
public void run() { OWLObjectProperty prop = (OWLObjectProperty) entity; OWLReasoner reasoner = getOWLModelManager().getReasoner(); boolean consistent = reasoner.isConsistent(); if(!consistent || reasoner.getBottomObjectPropertyNode().contains(prop)) { doc.setCharacterAttributes(tokenStartIndex, tokenLength, inconsistentClassStyle, true); } } });
public void run() { OWLReasoner reasoner = getOWLModelManager().getReasoner(); boolean consistent = reasoner.isConsistent(); if (!consistent || !getOWLModelManager().getReasoner().isSatisfiable((OWLClass) curEntity)) { // Paint red because of inconsistency doc.setCharacterAttributes(tokenStartIndex, tokenLength, inconsistentClassStyle, true); } } });
public void removeRow(int index) { int start = getStart(index); int end = getEnd(index); annotations.removeAll(annotations.overlapping(new Span(start, end))); rows.remove(index); editorPane.getStyledDocument() .setCharacterAttributes(start, end - start, DEFAULT, true); fireTableDataChanged(); }