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


Java AccessibleText类代码示例

本文整理汇总了Java中javax.accessibility.AccessibleText的典型用法代码示例。如果您正苦于以下问题:Java AccessibleText类的具体用法?Java AccessibleText怎么用?Java AccessibleText使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AccessibleText类属于javax.accessibility包,在下文中一共展示了AccessibleText类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCharacterIndexAtPosition

import javax.accessibility.AccessibleText; //导入依赖的package包/类
static int getCharacterIndexAtPosition(final Accessible a, final Component c, final int x, final int y) {
    if (a == null) return 0;

    return CAccessibility.invokeAndWait(new Callable<Integer>() {
        public Integer call() throws Exception {
            final AccessibleContext ac = a.getAccessibleContext();
            if (ac == null) return null;
            final AccessibleText at = ac.getAccessibleText();
            if (at == null) return null;
            // (x, y) passed in as java screen coords - (0, 0) at upper-left corner of screen.
            // Convert to java component-local coords
            final Point componentLocation = ac.getAccessibleComponent().getLocationOnScreen();
            final int localX = x - (int)componentLocation.getX();
            final int localY = y - (int)componentLocation.getY();

            return at.getIndexAtPoint(new Point(localX, localY));
        }
    }, c);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:CAccessibleText.java

示例2: getSelectedTextRange

import javax.accessibility.AccessibleText; //导入依赖的package包/类
static int[] getSelectedTextRange(final Accessible a, final Component c) {
    if (a == null) return new int[2];

    return CAccessibility.invokeAndWait(new Callable<int[]>() {
        public int[] call() {
            final AccessibleContext ac = a.getAccessibleContext();
            if (ac == null) return new int[2];

            final AccessibleText at = ac.getAccessibleText();
            if (at == null) return new int[2];

            final int[] ret = new int[2];
            ret[0] = at.getSelectionStart();
            ret[1] = at.getSelectionEnd();
            return ret;
        }
    }, c);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:CAccessibleText.java

示例3: getLink

import javax.accessibility.AccessibleText; //导入依赖的package包/类
protected String getLink(Point p) {
	final AccessibleContext aC = getAccessibleContext();
	if (aC instanceof AccessibleJLabel) {
		final AccessibleJLabel aL = (AccessibleJLabel) aC;
		final AccessibleText aT = aL.getAccessibleText();
		if (aT == null) {
			return null;
		}
		final int index = aL.getIndexAtPoint(p);
		for (final LinkDescriptor entry : listLinks) {
			if (index >= entry.getStart() && index <= entry.getEnd()) {
				return entry.getUrl();
			}
		}
	}
	return null;
}
 
开发者ID:kaikramer,项目名称:keystore-explorer,代码行数:18,代码来源:ClickableLinkTickerRenderer.java

示例4: getAccessibleText

import javax.accessibility.AccessibleText; //导入依赖的package包/类
public AccessibleText getAccessibleText() {
    if (pane == null) {
        //Cheat just a bit here - will do for now - the text is
        //there, more or less where it should be, and a screen
        //reader should be able to find it;  exact bounds don't
        //make much difference
        pane = new JEditorPane();
        pane.setBounds (panel.getBounds());
        pane.getAccessibleContext().getAccessibleText();
        pane.setFont (panel.getFont());
        CellRendererPane cell = new CellRendererPane();
        cell.add (pane);
    }
    pane.setText(getText());
    pane.selectAll();
    pane.validate();
    return pane.getAccessibleContext().getAccessibleText();
}
 
开发者ID:fifa0329,项目名称:vassal,代码行数:19,代码来源:InstructionsPanel.java

示例5: getAfterIndex

import javax.accessibility.AccessibleText; //导入依赖的package包/类
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,代码行数:20,代码来源:TextComponent.java

示例6: getBeforeIndex

import javax.accessibility.AccessibleText; //导入依赖的package包/类
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,代码行数:24,代码来源:TextComponent.java

示例7: mouseClicked

import javax.accessibility.AccessibleText; //导入依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
    Point point = e.getPoint();
    AccessibleText at = (AccessibleText) label.getAccessibleContext();
    int pos = at.getIndexAtPoint(point);
    AttributeSet as = at.getCharacterAttribute(pos);
    if (label.isEnabled() && as.getAttribute(HTML.Tag.A) != null) {
        label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        SimpleAttributeSet attr=(SimpleAttributeSet)as.getAttribute(HTML.Tag.A);
        String href=(String)attr.getAttribute(HTML.Attribute.HREF);
        fireActionPerformed(
        new ActionEvent(label,ActionEvent.ACTION_PERFORMED,href));
    } else {
        label.setCursor(Cursor.getDefaultCursor());
    }
}
 
开发者ID:pojosontheweb,项目名称:selenium-utils,代码行数:17,代码来源:JLabelHyperlinkHandler.java

示例8: getBeforeIndex

import javax.accessibility.AccessibleText; //导入依赖的package包/类
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,代码行数:21,代码来源:JTextComponent.java

示例9: getAfterIndex

import javax.accessibility.AccessibleText; //导入依赖的package包/类
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,代码行数:24,代码来源:JTextComponent.java


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