public class Utilities
extends java.lang.Object
Constructor and Description |
---|
Utilities() |
Modifier and Type | Method and Description |
---|---|
static int |
getLineNumberForOffset(javax.swing.JTextArea a,
int offset)
return the line number that contains the offset.
|
static int |
getLineNumberForOffset(javax.swing.text.JTextComponent comp,
int offset)
return the line number that contains the offset.
|
static int[] |
getLinePosition(javax.swing.JTextPane editor,
int carotPos)
return the index of the start and end of the selection, rounded out
to complete lines.
|
static int |
getOffsetForLineNumber(java.lang.String text,
int line)
given a line number, where zero is the first line, what is the offset?
|
static int |
getRowEnd(javax.swing.JTextArea a,
int offset) |
static int |
getRowEnd(javax.swing.text.JTextComponent editor,
int pos)
return the offset of the last character of the line.
|
static int |
getRowStart(javax.swing.JTextArea a,
int offset) |
static int |
getRowStart(javax.swing.text.JTextComponent editor,
int pos)
return the offset of the first character of the line.
|
static java.lang.String |
getWordAt(javax.swing.JTextPane logTextArea,
int caret)
look for adjacent whitespace to identify the word at the location.
|
public static int getRowStart(javax.swing.text.JTextComponent editor, int pos)
editor
- pos
- public static int getRowEnd(javax.swing.text.JTextComponent editor, int pos)
editor
- pos
- public static int getLineNumberForOffset(javax.swing.JTextArea a, int offset) throws javax.swing.text.BadLocationException
a
- offset
- javax.swing.text.BadLocationException
JTextArea.getLineOfOffset(int)
public static int getLineNumberForOffset(javax.swing.text.JTextComponent comp, int offset) throws javax.swing.text.BadLocationException
comp
- offset
- javax.swing.text.BadLocationException
public static int getOffsetForLineNumber(java.lang.String text, int line)
text
- the text documentline,
- the line number, where zero is the first linepublic static int getRowStart(javax.swing.JTextArea a, int offset) throws javax.swing.text.BadLocationException
javax.swing.text.BadLocationException
public static int getRowEnd(javax.swing.JTextArea a, int offset) throws javax.swing.text.BadLocationException
javax.swing.text.BadLocationException
public static java.lang.String getWordAt(javax.swing.JTextPane logTextArea, int caret) throws javax.swing.text.BadLocationException
logTextArea
- caret
- javax.swing.text.BadLocationException
public static int[] getLinePosition(javax.swing.JTextPane editor, int carotPos)
editor
- the editorcarotPos
- the carot position within the editor.