本文整理了Java中javax.swing.text.StyledDocument.getParagraphElement()
方法的一些代码示例,展示了StyledDocument.getParagraphElement()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StyledDocument.getParagraphElement()
方法的具体详情如下:
包路径:javax.swing.text.StyledDocument
类名称:StyledDocument
方法名:getParagraphElement
暂无
代码示例来源:origin: net.sf.jt400/jt400
/**
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);
}
代码示例来源:origin: org.swinglabs.swingx/swingx-all
/**
* {@inheritDoc}
*/
@Override
public Element getParagraphElement(int pos) {
return ((StyledDocument) delegate).getParagraphElement(pos);
}
代码示例来源:origin: tmyroadctfig/swingx
/**
* {@inheritDoc}
*/
@Override
public Element getParagraphElement(int pos) {
return ((StyledDocument) delegate).getParagraphElement(pos);
}
代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop
/**
* {@inheritDoc}
*/
public Element getParagraphElement(int pos) {
return ((StyledDocument) delegate).getParagraphElement(pos);
}
代码示例来源:origin: org.netbeans.api/org-openide-text
public Element getParagraphElement(int pos) {
return ((StyledDocument) original).getParagraphElement(pos);
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
public Element getParagraphElement (int pos) {
return ((StyledDocument)original).getParagraphElement (pos);
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
public Element getParagraphElement (int pos) {
return ((StyledDocument)original).getParagraphElement (pos);
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mercurial
@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);
}
}
}
});
代码示例来源:origin: org.netbeans.api/org-openide-text
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
}
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
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
}
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
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
}
}
}
代码示例来源:origin: org.netbeans.api/org-openide-text
/** 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;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
/** 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;
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
/** 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;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-debugger-common2
/**
* 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;
}
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mercurial
StyledDocument sd = (StyledDocument) doc;
int lineOffset = NbDocument.findLineOffset(sd, line);
Element element = sd.getParagraphElement(lineOffset);
AnnotateLine al = elementAnnotations.get(element);
代码示例来源:origin: jcoplien/trygve
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) {
代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-beans
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;
}
代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop
manager.setSelected("font-underline", StyleConstants.isUnderline(set));
elem = document.getParagraphElement(dot);
set = elem.getAttributes();
代码示例来源:origin: org.swinglabs.swingx/swingx-all
manager.setSelected("font-underline", StyleConstants.isUnderline(set));
elem = document.getParagraphElement(dot);
set = elem.getAttributes();
内容来源于网络,如有侵权,请联系作者删除!