/** Returns the element that represents the paragraph that encloses a given offset within the document. @param offset The offset within the document. @return The element that represents the paragraph. **/ public synchronized Element getParagraphElement (int offset) { return document_.getParagraphElement (offset); }
/** * {@inheritDoc} */ @Override public Element getParagraphElement(int pos) { return ((StyledDocument) delegate).getParagraphElement(pos); }
/** * {@inheritDoc} */ @Override public Element getParagraphElement(int pos) { return ((StyledDocument) delegate).getParagraphElement(pos); }
/** * {@inheritDoc} */ public Element getParagraphElement(int pos) { return ((StyledDocument) delegate).getParagraphElement(pos); }
public Element getParagraphElement(int pos) { return ((StyledDocument) original).getParagraphElement(pos); }
public Element getParagraphElement (int pos) { return ((StyledDocument)original).getParagraphElement (pos); }
public Element getParagraphElement (int pos) { return ((StyledDocument)original).getParagraphElement (pos); }
@Override public void run() { StyledDocument sd = (StyledDocument) doc; Iterator<AnnotateLine> it = lines.iterator(); previousRevisions = Collections.synchronizedMap(new HashMap<String, HgRevision>()); originalFiles = Collections.synchronizedMap(new HashMap<String, File>()); elementAnnotations = Collections.synchronizedMap(new HashMap<Element, AnnotateLine>(lines.size())); while (it.hasNext()) { AnnotateLine line = it.next(); int lineNum = ann2editorPermutation[line.getLineNum() -1]; if (lineNum == -1) { continue; } try { int lineOffset = NbDocument.findLineOffset(sd, lineNum -1); Element element = sd.getParagraphElement(lineOffset); elementAnnotations.put(element, line); } catch (IndexOutOfBoundsException ex) { // TODO how could I get line behind document end? // furtunately user does not spot it Mercurial.LOG.log(Level.INFO, null, ex); } } } });
public void run() { int offset = annoPos.getOffset(); int lineStartOffset = doc.getParagraphElement(offset).getStartOffset(); if (offset != lineStartOffset) { // not at line start -> correct try { annoPos = doc.createPosition(lineStartOffset); } catch (BadLocationException e) { throw new IllegalArgumentException(); // should never fail } } }
public void run() { int offset = annoPos.getOffset(); int lineStartOffset = doc.getParagraphElement(offset).getStartOffset(); if (offset != lineStartOffset) { // not at line start -> correct try { annoPos = doc.createPosition(lineStartOffset); } catch (BadLocationException e) { throw new IllegalArgumentException(); // should never fail } } }
public void run() { int offset = annoPos.getOffset(); int lineStartOffset = doc.getParagraphElement(offset).getStartOffset(); if (offset != lineStartOffset) { // not at line start -> correct try { annoPos = doc.createPosition(lineStartOffset); } catch (BadLocationException e) { throw new IllegalArgumentException(); // should never fail } } }
/** Find the root element of all lines. * All conforming NetBeans documents * should return a valid element. * * @param doc styled document (expecting NetBeans document) * @return the root element * @exception NullPointerException If the <code>doc</code> parameter * is <code>null</code>. */ public static Element findLineRootElement(StyledDocument doc) { checkDocParameter(doc); Element e = doc.getParagraphElement(0).getParentElement(); if (e == null) { // try default root (should work for text/plain) e = doc.getDefaultRootElement(); } return e; }
/** Find the root element of all lines. * All conforming NetBeans documents * should return a valid element. * * @param doc styled document (expecting NetBeans document) * @return the root element * @exception NullPointerException If the <code>doc</code> parameter * is <code>null</code>. */ public static Element findLineRootElement (StyledDocument doc) { checkDocParameter(doc); Element e = doc.getParagraphElement (0).getParentElement (); if (e == null) { // try default root (should work for text/plain) e = doc.getDefaultRootElement (); } return e; }
/** Find the root element of all lines. * All conforming NetBeans documents * should return a valid element. * * @param doc styled document (expecting NetBeans document) * @return the root element * @exception NullPointerException If the <code>doc</code> parameter * is <code>null</code>. */ public static Element findLineRootElement (StyledDocument doc) { checkDocParameter(doc); Element e = doc.getParagraphElement (0).getParentElement (); if (e == null) { // try default root (should work for text/plain) e = doc.getDefaultRootElement (); } return e; }
/** * Map document position to contents of whole line at that position. * SHOULD be combined with addrFromLine to givew: * Address viewToModel(pos) */ private String getLineAt(int pos) { // By default a "paragraph" is a line Element pp = styledDoc.getParagraphElement(pos); int startPos = pp.getStartOffset(); int endPos = pp.getEndOffset(); int length = endPos - startPos; String line = null; try { line = styledDoc.getText(startPos, length); } catch (Exception x) { } return line; }
StyledDocument sd = (StyledDocument) doc; int lineOffset = NbDocument.findLineOffset(sd, line); Element element = sd.getParagraphElement(lineOffset); AnnotateLine al = elementAnnotations.get(element);
public void setBreakpointToEOLAt(int byteOffset, int lineNumber) { final StyledDocument doc = (StyledDocument)editPane.getDocument(); final Element paragraphElement = doc.getParagraphElement(byteOffset); if (paragraphElement.getClass() == BranchElement.class) { final SimpleAttributeSet sas = new SimpleAttributeSet(); StyleConstants.setBackground(sas, Color.cyan); // Look for ending delimiter int length = 1; try { for (int i = byteOffset; ; i++) { if (i >= doc.getLength()) { length = i - byteOffset + 1; break; } else if (doc.getText(i, 1).equals("\n")) { length = i - byteOffset; break; } } } catch (BadLocationException ble) { length = 0; } if (0 < length) { doc.setCharacterAttributes(byteOffset, length, sas, false); } } } public void unsetBreakpointToEOLAt(int byteOffset, int lineNumber) {
static int getRowFirstNonWhite(StyledDocument doc, int offset) throws BadLocationException { Element lineElement = doc.getParagraphElement(offset); int start = lineElement.getStartOffset(); while (start + 1 < lineElement.getEndOffset()) { try { if (doc.getText(start, 1).charAt(0) != ' ') { break; } } catch (BadLocationException ex) { throw (BadLocationException) new BadLocationException( "calling getText(" + start + ", " + (start + 1) + ") on doc of length: " + doc.getLength(), start).initCause(ex); } start++; } return start; }
manager.setSelected("font-underline", StyleConstants.isUnderline(set)); elem = document.getParagraphElement(dot); set = elem.getAttributes();
manager.setSelected("font-underline", StyleConstants.isUnderline(set)); elem = document.getParagraphElement(dot); set = elem.getAttributes();