⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 activeclient.java

📁 jdk-6u10-docs java开发宝典
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        }        // translate to screen coordinates        Point location = getLocationOnScreen();        rectangle.translate(location.x, location.y);	return rectangle;    }    /**     * Gets the offset within the composed text for the specified absolute x     * and y coordinates on the screen.     */    public TextHitInfo getLocationOffset(int x, int y) {        // translate from screen coordinates to coordinates in the text layout        Point location = getLocationOnScreen();        Point textOrigin = getTextOrigin();        x -= location.x + textOrigin.x;        y -= location.y + textOrigin.y;                // TextLayout maps locations far outside its bounds to locations within.        // To avoid false hits, we use it only if it actually contains the location.        // We also have to translate the TextHitInfo to be relative to composed text.        TextLayout textLayout = getTextLayout();        if (textLayout != null &&                textLayout.getBounds().contains(x, y)) {            return textLayout.hitTestChar(x, y).getOffsetHit(-getCommittedTextLength());        } else {            return null;        }    }    /**     * Gets the offset of the insert position in the committed text contained     * in the text editing component. In this simple component, that's always     * at the end of the committed text.     */    public int getInsertPositionOffset() {        return getCommittedTextLength();    }    /**     * Gets an iterator providing access to the entire text and attributes     * contained in the text editing component except for uncommitted     * text.     */    public AttributedCharacterIterator getCommittedText(int beginIndex,    		int endIndex, Attribute[] attributes) {        return getCommittedText(beginIndex, endIndex);    }    /**     * Returns null to indicate that the "Undo Commit" feature is not supported     * by this simple text component.     */    public AttributedCharacterIterator cancelLatestCommittedText(Attribute[] attributes) {        return null;    }    private static final AttributedCharacterIterator EMPTY_TEXT =            (new AttributedString("")).getIterator();    /**     * Gets the currently selected text from the text editing component.     * Since this simple text component doesn't support selections, this is     * always an iterator over empty text.     */    public AttributedCharacterIterator getSelectedText(Attribute[] attributes) {        return EMPTY_TEXT;    }}/** * Iterates over the combined text of two AttributedCharacterIterators. * Assumes that no annotation spans the two iterators. */class CompositeIterator implements AttributedCharacterIterator {    AttributedCharacterIterator iterator1;    AttributedCharacterIterator iterator2;    int begin1, end1;    int begin2, end2;    int endIndex;    int currentIndex;    AttributedCharacterIterator currentIterator;    int currentIteratorDelta;        /**     * Constructs a CompositeIterator that iterates over the concatenation     * of iterator1 and iterator2.     * @param iterator1, iterator2 the base iterators that this composite iterator concatenates     */    CompositeIterator(AttributedCharacterIterator iterator1, AttributedCharacterIterator iterator2) {        this.iterator1 = iterator1;        this.iterator2 = iterator2;        begin1 = iterator1.getBeginIndex();        end1 = iterator1.getEndIndex();        begin2 = iterator2.getBeginIndex();        end2 = iterator2.getEndIndex();        endIndex = (end1 - begin1) + (end2 - begin2);        internalSetIndex(0);    }        // CharacterIterator implementation        public char first() {        return internalSetIndex(0);    }        public char last() {        if (endIndex == 0) {            return internalSetIndex(endIndex);        } else {            return internalSetIndex(endIndex - 1);        }    }        public char next() {        if (currentIndex < endIndex) {            return internalSetIndex(currentIndex + 1);        } else {            return DONE;        }    }        public char previous() {        if (currentIndex > 0) {            return internalSetIndex(currentIndex - 1);        } else {            return DONE;        }    }        public char current() {        return currentIterator.setIndex(currentIndex + currentIteratorDelta);    }        public char setIndex(int position) {        if (position < 0 || position > endIndex) {            throw new IllegalArgumentException("invalid index");        }        return internalSetIndex(position);    }        private char internalSetIndex(int position) {        currentIndex = position;        if (currentIndex < end1 - begin1) {            currentIterator = iterator1;            currentIteratorDelta = begin1;        } else {            currentIterator = iterator2;            currentIteratorDelta = begin2 - (end1 - begin1);        }        return currentIterator.setIndex(currentIndex + currentIteratorDelta);    }        public int getBeginIndex() {        return 0;    }        public int getEndIndex() {        return endIndex;    }        public int getIndex() {        return currentIndex;    }        // AttributedCharacterIterator implementation        public int getRunStart() {        return currentIterator.getRunStart() - currentIteratorDelta;    }        public int getRunLimit() {        return currentIterator.getRunLimit() - currentIteratorDelta;    }        public int getRunStart(Attribute attribute) {        return currentIterator.getRunStart(attribute) - currentIteratorDelta;    }        public int getRunLimit(Attribute attribute) {        return currentIterator.getRunLimit(attribute) - currentIteratorDelta;    }    public int getRunStart(Set attributes) {        return currentIterator.getRunStart(attributes) - currentIteratorDelta;    }        public int getRunLimit(Set attributes) {        return currentIterator.getRunLimit(attributes) - currentIteratorDelta;    }        public Map getAttributes() {        return currentIterator.getAttributes();    }        public Set getAllAttributeKeys() {        Set keys = new HashSet(iterator1.getAllAttributeKeys());        keys.addAll(iterator2.getAllAttributeKeys());        return keys;    }        public Object getAttribute(Attribute attribute) {        return currentIterator.getAttribute(attribute);    }        // Object overrides    public Object clone() {        try {            CompositeIterator other = (CompositeIterator) super.clone();            return other;        } catch (CloneNotSupportedException e) {            throw new InternalError();        }    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -