当前位置: 首页>>代码示例>>Java>>正文


Java AccessibleText.WORD属性代码示例

本文整理汇总了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;
    }
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:19,代码来源:TextComponent.java

示例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;
    }
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:23,代码来源:TextComponent.java

示例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;
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:20,代码来源:JTextComponent.java

示例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;
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:JTextComponent.java

示例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;
}
 
开发者ID:vilie,项目名称:javify,代码行数:40,代码来源:JLabel.java

示例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;
}
 
开发者ID:vilie,项目名称:javify,代码行数:40,代码来源:JLabel.java

示例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;
}
 
开发者ID:vilie,项目名称:javify,代码行数:40,代码来源:JLabel.java

示例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;
    }
}
 
开发者ID:mike10004,项目名称:appengine-imaging,代码行数:15,代码来源:TextComponent.java

示例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;
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:12,代码来源:JTextComponent.java


注:本文中的javax.accessibility.AccessibleText.WORD属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。