/** * Adds a attribute to the paragraph at offset to prevent trying to delete * it again. * * @param offset */ private void setLineDeleted(int offset) { doc.setParagraphAttributes(offset, 1, styles.deletedLine(), false); }
private void setVariableLineAttributes(int offset, boolean even, boolean updateTimestamp) { doc.setParagraphAttributes(offset, 1, styles.variableLineAttributes(even, updateTimestamp), false); }
private void setLineHighlighted(int offset) { SimpleAttributeSet attr = new SimpleAttributeSet(); attr.addAttribute(Attribute.HIGHLIGHT_LINE, true); doc.setParagraphAttributes(offset, 1, attr, false); }
private void setCustomBackgroundColor(int offset, Color color) { SimpleAttributeSet attr = new SimpleAttributeSet(); attr.addAttribute(Attribute.CUSTOM_BACKGROUND, color); doc.setParagraphAttributes(offset, 1, attr, false); }
private void setLineCommand(int offset, String command) { SimpleAttributeSet attr = new SimpleAttributeSet(); attr.addAttribute(Attribute.COMMAND, command); doc.setParagraphAttributes(offset, 1, attr, false); }
protected StyledDocument createDocument() { DefaultStyledDocument doc = new DefaultStyledDocument(); doc.setParagraphAttributes(0, 1, ((StyledEditorKit) editor.getEditorKit()).getInputAttributes(), true); return doc; }
doc.setParagraphAttributes(0, 1, heading2Style, false); } catch (Exception e)
private void setTabStops() { final Document doc = edit_.getDocument(); if (doc instanceof PlainDocument) { doc.putProperty(PlainDocument.tabSizeAttribute, 8); } else if (doc instanceof DefaultStyledDocument) { final TabStop[] tabs = new TabStop[20]; for (int i = 0; i < tabs.length; i++) { tabs[i] = new TabStop((i+1) * 20); } final TabSet tabSet = new TabSet(tabs); final SimpleAttributeSet attributes = new SimpleAttributeSet(); StyleConstants.setTabSet(attributes, tabSet); final int length = doc.getLength(); ((DefaultStyledDocument) doc).setParagraphAttributes(0, length, attributes, false); } else { ; // do nothing - don't know how to do it } }
SimpleAttributeSet sas = new SimpleAttributeSet(); StyleConstants.setSpaceBelow(sas, spaceBelow); pd.setParagraphAttributes(0, pd.getLength(), sas, false);
doc.setParagraphAttributes(0, 1, heading2Style, false); } catch (Exception e)
doc.setParagraphAttributes(0, 1, heading2Style, false); } catch (BadLocationException e) {
/** * Prints the given text in the given style. Runs the function that actually * adds the text in the Event Dispatch Thread. * * @param text * @param style */ private void print(final String text, final AttributeSet style) { try { String newline = ""; if (newlineRequired) { newline = "\n"; newlineRequired = false; clearSomeChat(); } //System.out.println("1:"+doc.getLength()); doc.insertString(doc.getLength(), newline+text, style); //System.out.println("2:"+doc.getLength()); //this.getHighlighter().addHighlight(doc.getLength(), 10, null); // TODO: check how this works doc.setParagraphAttributes(doc.getLength(), 1, styles.paragraph(), true); scrollDownIfNecessary(); } catch (BadLocationException e) { System.err.println("BadLocationException"); } }
doc.setParagraphAttributes(0, 1, heading2Style, false); } catch (Exception e)
Element paragraph = root.getElement(i); if (changedStyles.contains("paragraph")) { doc.setParagraphAttributes(paragraph.getStartOffset(), 1, paragraph(), false);
doc.setParagraphAttributes(0, 1, heading2Style, false);
StyleConstants.setLeftIndent(whiteAttributes, NumberedParagraphView.NUMBERS_WIDTH); doc.setParagraphAttributes(0, doc.getLength(), whiteAttributes, true); JavaScanner parser = new JavaScanner(new DocumentCharacterIterator(doc)); while (parser.next() != JavaScanner.EOF) {