|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.borland.primetime.editor.TextUtilities
A customized collection of methods to deal with various text related activities. We have to use these methods instead of the corresponding ones in javax.swing.text.Utilities because those don't work well for source code.
Field Summary | |
static java.lang.String |
DEBUGGER_END_DELIMITERS
The characters in this string define the end of a token for the ripText methods, when called by the debugger. |
static java.lang.String |
DEBUGGER_START_DELIMITERS
The characters in this string define the start of a token for the ripText methods, when called by the debugger. |
static java.lang.String |
STANDARD_DELIMITERS
The characters in this string define the standard ends of a token for the ripText methods. |
Constructor Summary | |
TextUtilities()
|
Method Summary | |
static int |
drawTabbedText(javax.swing.text.Segment s,
int x,
int y,
java.awt.Graphics g,
javax.swing.text.TabExpander e,
int startOffset)
Draws the given text, expanding any tabs that are contained using the given tab expansion technique. |
static javax.swing.text.Element |
getLineElement(javax.swing.text.JTextComponent c,
int offs)
Determines the element to use for a paragraph/line. |
static int |
getNextWord(javax.swing.text.JTextComponent c,
int offs)
Determines the start of the next word for the given location. |
static int |
getPreviousWord(javax.swing.text.JTextComponent c,
int offs)
Determine the start of the prev word for the given location. |
static int |
getTabbedTextPosition(char[] textArray,
int tabSize,
int offs)
Determines the character offset of a position, converting all spaces to tabs. |
static int |
getTabbedTextPosition(javax.swing.text.JTextComponent c,
javax.swing.text.Element lineElement,
int tabSize,
int offs)
Determines the character offset of a position, converting all spaces to tabs. |
static int |
getTabbedTextPosition(java.lang.String text,
int tabSize,
int offs)
Determines the character offset of a position, converting all spaces to tabs. |
static int |
getTabbedTextWidth(javax.swing.text.Segment s,
java.awt.FontMetrics metrics,
int x,
javax.swing.text.TabExpander e,
int startOffset)
Determines the width of the given segment of text taking tabs into consideration. |
static int |
getTokenEnd(char[] characters,
int startOffset,
int endOffset,
int offset,
java.lang.String delimiters)
Return the offset of the end of a token. |
static int |
getTokenStart(char[] characters,
int startOffset,
int endOffset,
int offset,
java.lang.String delimiters)
Return the offset of the start of a token. |
static int |
getWordEnd(javax.swing.text.JTextComponent c,
int offs)
This method returns the location of the end of the current word, or, if offs is at the end of a word or between words, this method returns the location at the end of the next word. |
static int |
getWordStart(javax.swing.text.JTextComponent c,
int offs)
Determines the start of a word for the given model location. |
static boolean |
isBlankLine(char[] textLine)
Determines whether or not a particular String consists entirely of whitespace. |
static boolean |
isBlankLine(javax.swing.text.JTextComponent c,
javax.swing.text.Element lineElement)
Determines whether or not a particular element consists entirely of whitespace. |
protected static boolean |
isSkipCharacter(char ch,
boolean skipOnUnderline)
This method is used to determine if a character can be skipped when scanning for word boundaries. |
static java.lang.String |
ripTextAt(char[] characters,
int startOffset,
int endOffset,
int offset,
java.lang.String delimiters)
Return the string at the location specified by offset. |
static java.lang.String |
ripTextAt(char[] characters,
int startOffset,
int endOffset,
int offset,
java.lang.String startDelimiters,
java.lang.String endDelimiters)
Return the string at the location specified by offset. |
static java.lang.String |
ripTextAt(EditorPane editor,
int offset)
Return the string at the location specified by offset. |
static java.lang.String |
ripTextAt(EditorPane editor,
int offset,
java.lang.String delimiters)
Return the string at the location specified by offset. |
static java.lang.String |
ripTextAt(EditorPane editor,
int offset,
java.lang.String startDelimiters,
java.lang.String endDelimiters)
Return the string at the location specified by offset. |
Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
Field Detail |
public static final java.lang.String STANDARD_DELIMITERS
public static final java.lang.String DEBUGGER_START_DELIMITERS
public static final java.lang.String DEBUGGER_END_DELIMITERS
Constructor Detail |
public TextUtilities()
Method Detail |
public static final int getWordStart(javax.swing.text.JTextComponent c, int offs) throws javax.swing.text.BadLocationException
This is mostly used for Emacs emulation. CUA usually uses getPreviousWord().
c
- the editoroffs
- the offset in the document >= 0public static final int getWordEnd(javax.swing.text.JTextComponent c, int offs) throws javax.swing.text.BadLocationException
This is mostly used for Emacs emulation. CUA usually uses getNextWord().
c
- The editoroffs
- The offset in the document >= 0public static final int getNextWord(javax.swing.text.JTextComponent c, int offs) throws javax.swing.text.BadLocationException
c
- the editoroffs
- the offset in the document >= 0public static final int getPreviousWord(javax.swing.text.JTextComponent c, int offs) throws javax.swing.text.BadLocationException
c
- the editoroffs
- the offset in the document >= 0public static final javax.swing.text.Element getLineElement(javax.swing.text.JTextComponent c, int offs)
c
- the editoroffs
- the starting offset in the document >= 0public static boolean isBlankLine(javax.swing.text.JTextComponent c, javax.swing.text.Element lineElement) throws javax.swing.text.BadLocationException
c
- the editorlineElement
- the element.public static boolean isBlankLine(char[] textLine)
textLine
- The text to check.public static int getTabbedTextPosition(javax.swing.text.JTextComponent c, javax.swing.text.Element lineElement, int tabSize, int offs) throws javax.swing.text.BadLocationException
c
- the editorlineElement
- the element.tabSize
- the size of an individual taboffs
- The location to check. This offset is relative to the start
of the line (i.e. a position at the start of the line would be 0).public static int getTabbedTextPosition(java.lang.String text, int tabSize, int offs)
text
- The text to check.tabSize
- the size of an individual taboffs
- The location to check. This offset is relative to the start
of the line (i.e. a position at the start of the line would be 0).public static int getTabbedTextPosition(char[] textArray, int tabSize, int offs)
textArray
- The text to check.tabSize
- the size of an individual taboffs
- The location to check. This offset is relative to the start
of the line (i.e. a position at the start of the line would be 0).protected static final boolean isSkipCharacter(char ch, boolean skipOnUnderline)
Note that the underline character '_' is not a skip character for the JBuilder 2.0 editor, but it *is* a skip character for Emacs.
public static final int drawTabbedText(javax.swing.text.Segment s, int x, int y, java.awt.Graphics g, javax.swing.text.TabExpander e, int startOffset)
In this implementation, we assume that all of the text we're drawing is fixed pitch, thus we only need to calculate the character width once.
s
- the source of the textx
- the X origin >= 0y
- the Y origin >= 0g
- the graphics contexte
- how to expand the tabs. If this value is null,
tabs will be expanded as a space character.startOffset
- starting offset of the text in the document >= 0public static final int getTabbedTextWidth(javax.swing.text.Segment s, java.awt.FontMetrics metrics, int x, javax.swing.text.TabExpander e, int startOffset)
In this implementation, we assume that all of the text we're drawing is fixed pitch, thus we only need to calculate the character width once.
s
- the source of the textmetrics
- the font metrics to use for the calculationx
- the X origin >= 0e
- how to expand the tabs. If this value is null,
tabs will be expanded as a space character.startOffset
- starting offset of the text in the document >= 0public static java.lang.String ripTextAt(EditorPane editor, int offset)
characters
- The editor from which to rip a String.offset
- The location in the editor which contains the String of interest.public static java.lang.String ripTextAt(EditorPane editor, int offset, java.lang.String delimiters)
characters
- The editor from which to rip a String.offset
- The location in the editor which contains the String of interest.delimiters
- A String containing the delimiters that define the bounds
of the String.public static java.lang.String ripTextAt(EditorPane editor, int offset, java.lang.String startDelimiters, java.lang.String endDelimiters)
characters
- The editor from which to rip a String.offset
- The location in the editor which contains the String of interest.startDelimiters
- A String containing the delimiters that define the
start of the String.endDelimiters
- A String containing the delimiters that define the
end of the String.public static java.lang.String ripTextAt(char[] characters, int startOffset, int endOffset, int offset, java.lang.String delimiters)
characters
- The array of characters from which to rip a String.startOffset
- The location of the start of the characters of interest
in the array.endOffset
- The location of the end of the characters of interest
in the array.offset
- The location in the array which contains the String of
interest. IMPORTANT: This value is an offset from the
startOffset, not an offset from the start of the array.delimiters
- A String containing the delimiters that define the bounds
of the String.public static java.lang.String ripTextAt(char[] characters, int startOffset, int endOffset, int offset, java.lang.String startDelimiters, java.lang.String endDelimiters)
characters
- The array of characters from which to rip a String.startOffset
- The location of the start of the characters of interest
in the array.endOffset
- The location of the end of the characters of interest
in the array.offset
- The location in the array which contains the String of
interest. IMPORTANT: This value is an offset from the
startOffset, not an offset from the start of the array.startDelimiters
- A String containing the delimiters that define the
start of the String.endDelimiters
- A String containing the delimiters that define the
end of the String.public static int getTokenStart(char[] characters, int startOffset, int endOffset, int offset, java.lang.String delimiters)
characters
- The array of characters to check.startOffset
- The location of the start of the characters of interest
in the array.endOffset
- The location of the end of the characters of interest
in the array.offset
- The location in the array which contains the String of
interest. IMPORTANT: This value is an offset from the
startOffset, not an offset from the start of the array.delimiters
- A String containing the delimiters that define the bounds
of the String.public static int getTokenEnd(char[] characters, int startOffset, int endOffset, int offset, java.lang.String delimiters)
characters
- The array of characters to check.startOffset
- The location of the start of the characters of interest
in the array.endOffset
- The location of the end of the characters of interest
in the array.offset
- The location in the array which contains the String of
interest. IMPORTANT: This value is an offset from the
startOffset, not an offset from the start of the array.delimiters
- A String containing the delimiters that define the bounds
of the String.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |