本文整理汇总了Java中javax.accessibility.AccessibleText.WORD属性的典型用法代码示例。如果您正苦于以下问题:Java AccessibleText.WORD属性的具体用法?Java AccessibleText.WORD怎么用?Java AccessibleText.WORD使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.accessibility.AccessibleText
的用法示例。
在下文中一共展示了AccessibleText.WORD属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAfterIndex
public String getAfterIndex(int part, int index) {
int offset = 0;
switch (part) {
case AccessibleText.CHARACTER:
return (index == document.getLength()) ? null : getCharacter(index + 1);
case AccessibleText.WORD:
try {
offset = getWordEnd(index) + 1;
offset = getWordEnd(offset + 1);
} catch (final BadLocationException e) {
return null;
}
return getWord(offset);
case AccessibleText.SENTENCE:
// not implemented yet
default:
return null;
}
}
示例2: getBeforeIndex
public String getBeforeIndex(int part, int index) {
int offset = 0;
switch (part) {
case AccessibleText.CHARACTER:
return (index == 0) ? null : getCharacter(index - 1);
case AccessibleText.WORD:
try {
offset = getWordStart(index) - 1;
offset = getWordStart(offset - 1);
} catch (final BadLocationException e) {
return null;
}
return (offset < 0) ? null : getWord(offset);
case AccessibleText.SENTENCE:
BreakIterator bi = BreakIterator.getSentenceInstance();
bi.setText(getText());
offset = bi.preceding(index);
offset = bi.previous() + 1;
return (offset < 0) ? null : getLine(offset);
default:
return null;
}
}
示例3: getBeforeIndex
public String getBeforeIndex(final int part, final int index) {
int offset = 0;
switch (part) {
case AccessibleText.CHARACTER:
return (index == 0) ? null : getCharacter(index - 1);
case AccessibleText.WORD:
try {
offset = TextUtils.getWordStart(textKit, index) - 1;
} catch (final BadLocationException e) {
return null;
}
return (offset < 0) ? null : getWord(offset);
case AccessibleText.SENTENCE:
Element elem = TextUtils.getParagraphElement(document, index);
offset = elem.getStartOffset() - 1;
return (offset < 0) ? null : getLine(offset);
default:
return null;
}
}
示例4: getAfterIndex
public String getAfterIndex(final int part, final int index) {
int offset = 0;
switch (part) {
case AccessibleText.CHARACTER:
return (index == document.getLength()) ? null
: getCharacter(index + 1);
case AccessibleText.WORD:
try {
offset = TextUtils.getWordEnd(textKit, index)
+ 1;
} catch (final BadLocationException e) {
return null;
}
return getWord(offset);
case AccessibleText.SENTENCE:
Element elem = TextUtils.getParagraphElement(document, index);
offset = elem.getEndOffset() + 1;
return (offset < 0) ? null : getLine(offset);
default:
return null;
}
}
示例5: getAtIndex
/**
* Returns the character, word or sentence at the specified index. The
* <code>part</code> parameter determines what is returned, the character,
* word or sentence after the index.
*
* @param part one of {@link AccessibleText#CHARACTER},
* {@link AccessibleText#WORD} or
* {@link AccessibleText#SENTENCE}, specifying what is returned
* @param index the index
*
* @return the character, word or sentence after <code>index</code>
*/
public String getAtIndex(int part, int index)
{
String result = "";
int startIndex = -1;
int endIndex = -1;
switch(part)
{
case AccessibleText.CHARACTER:
result = String.valueOf(text.charAt(index));
break;
case AccessibleText.WORD:
startIndex = text.lastIndexOf(' ', index);
endIndex = text.indexOf(' ', startIndex + 1);
if (endIndex == -1)
endIndex = startIndex + 1;
result = text.substring(startIndex + 1, endIndex);
break;
case AccessibleText.SENTENCE:
default:
startIndex = text.lastIndexOf('.', index);
endIndex = text.indexOf('.', startIndex + 1);
if (endIndex == -1)
endIndex = startIndex + 1;
result = text.substring(startIndex + 1, endIndex);
break;
}
return result;
}
示例6: getAfterIndex
/**
* Returns the character, word or sentence after the specified index. The
* <code>part</code> parameter determines what is returned, the character,
* word or sentence after the index.
*
* @param part one of {@link AccessibleText#CHARACTER},
* {@link AccessibleText#WORD} or
* {@link AccessibleText#SENTENCE}, specifying what is returned
* @param index the index
*
* @return the character, word or sentence after <code>index</code>
*/
public String getAfterIndex(int part, int index)
{
String result = "";
int startIndex = -1;
int endIndex = -1;
switch(part)
{
case AccessibleText.CHARACTER:
result = String.valueOf(text.charAt(index + 1));
break;
case AccessibleText.WORD:
startIndex = text.indexOf(' ', index);
endIndex = text.indexOf(' ', startIndex + 1);
if (endIndex == -1)
endIndex = startIndex + 1;
result = text.substring(startIndex + 1, endIndex);
break;
case AccessibleText.SENTENCE:
default:
startIndex = text.indexOf('.', index);
endIndex = text.indexOf('.', startIndex + 1);
if (endIndex == -1)
endIndex = startIndex + 1;
result = text.substring(startIndex + 1, endIndex);
break;
}
return result;
}
示例7: getBeforeIndex
/**
* Returns the character, word or sentence before the specified index. The
* <code>part</code> parameter determines what is returned, the character,
* word or sentence before the index.
*
* @param part one of {@link AccessibleText#CHARACTER},
* {@link AccessibleText#WORD} or
* {@link AccessibleText#SENTENCE}, specifying what is returned
* @param index the index
*
* @return the character, word or sentence before <code>index</code>
*/
public String getBeforeIndex(int part, int index)
{
String result = "";
int startIndex = -1;
int endIndex = -1;
switch(part)
{
case AccessibleText.CHARACTER:
result = String.valueOf(text.charAt(index - 1));
break;
case AccessibleText.WORD:
endIndex = text.lastIndexOf(' ', index);
if (endIndex == -1)
endIndex = 0;
startIndex = text.lastIndexOf(' ', endIndex - 1);
result = text.substring(startIndex + 1, endIndex);
break;
case AccessibleText.SENTENCE:
default:
endIndex = text.lastIndexOf('.', index);
if (endIndex == -1)
endIndex = 0;
startIndex = text.lastIndexOf('.', endIndex - 1);
result = text.substring(startIndex + 1, endIndex);
break;
}
return result;
}
示例8: getAtIndex
public String getAtIndex(int part, int index) {
if (document.getLength() <= 0) {
return null; // compatibility
}
switch (part) {
case AccessibleText.CHARACTER:
return getCharacter(index);
case AccessibleText.WORD:
return getWord(index);
case AccessibleText.SENTENCE:
return getLine(index);
default:
return null;
}
}
示例9: getAtIndex
public String getAtIndex(final int part, final int index) {
switch (part) {
case AccessibleText.CHARACTER:
return getCharacter(index);
case AccessibleText.WORD:
return getWord(index);
case AccessibleText.SENTENCE:
return getLine(index);
default:
return null;
}
}