java.awt.im.InputMethodRequests Java Examples

The following examples show how to use java.awt.im.InputMethodRequests. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CompositionAreaHandler.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates the composition area.
 */
private void createCompositionArea() {
    synchronized(compositionAreaLock) {
        compositionArea = new CompositionArea();
        if (compositionAreaOwner != null) {
            compositionArea.setHandlerInfo(compositionAreaOwner, inputMethodContext);
        }
        // If the client component is an active client using below-the-spot style, then
        // make the composition window undecorated without a title bar.
        Component client = clientComponent.get();
        if(client != null){
            InputMethodRequests req = client.getInputMethodRequests();
            if (req != null && inputMethodContext.useBelowTheSpotInput()) {
                setCompositionAreaUndecorated(true);
            }
        }
    }
}
 
Example #2
Source File: CompositionAreaHandler.java    From Bytecoder with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the composition area.
 */
private void createCompositionArea() {
    synchronized(compositionAreaLock) {
        compositionArea = new CompositionArea();
        if (compositionAreaOwner != null) {
            compositionArea.setHandlerInfo(compositionAreaOwner, inputMethodContext);
        }
        // If the client component is an active client using below-the-spot style, then
        // make the composition window undecorated without a title bar.
        Component client = clientComponent.get();
        if(client != null){
            InputMethodRequests req = client.getInputMethodRequests();
            if (req != null && inputMethodContext.useBelowTheSpotInput()) {
                setCompositionAreaUndecorated(true);
            }
        }
    }
}
 
Example #3
Source File: CompositionAreaHandler.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates the composition area.
 */
private void createCompositionArea() {
    synchronized(compositionAreaLock) {
        compositionArea = new CompositionArea();
        if (compositionAreaOwner != null) {
            compositionArea.setHandlerInfo(compositionAreaOwner, inputMethodContext);
        }
        // If the client component is an active client using below-the-spot style, then
        // make the composition window undecorated without a title bar.
        Component client = clientComponent.get();
        if(client != null){
            InputMethodRequests req = client.getInputMethodRequests();
            if (req != null && inputMethodContext.useBelowTheSpotInput()) {
                setCompositionAreaUndecorated(true);
            }
        }
    }
}
 
Example #4
Source File: CompositionAreaHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates the composition area.
 */
private void createCompositionArea() {
    synchronized(compositionAreaLock) {
        compositionArea = new CompositionArea();
        if (compositionAreaOwner != null) {
            compositionArea.setHandlerInfo(compositionAreaOwner, inputMethodContext);
        }
        // If the client component is an active client using below-the-spot style, then
        // make the composition window undecorated without a title bar.
        Component client = clientComponent.get();
        if(client != null){
            InputMethodRequests req = client.getInputMethodRequests();
            if (req != null && inputMethodContext.useBelowTheSpotInput()) {
                setCompositionAreaUndecorated(true);
            }
        }
    }
}
 
Example #5
Source File: CompositionAreaHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
public Rectangle getTextLocation(TextHitInfo offset) {
    synchronized (compositionAreaLock) {
        if (compositionAreaOwner == this && isCompositionAreaVisible()) {
            return compositionArea.getTextLocation(offset);
        } else if (composedText != null) {
            // there's composed text, but it's not displayed, so fake a rectangle
            return new Rectangle(0, 0, 0, 10);
        } else {
            InputMethodRequests requests = getClientInputMethodRequests();
            if (requests != null) {
                return requests.getTextLocation(offset);
            } else {
                // passive client, no composed text, so fake a rectangle
                return new Rectangle(0, 0, 0, 10);
            }
        }
    }
}
 
Example #6
Source File: CompositionAreaHandler.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
public Rectangle getTextLocation(TextHitInfo offset) {
    synchronized (compositionAreaLock) {
        if (compositionAreaOwner == this && isCompositionAreaVisible()) {
            return compositionArea.getTextLocation(offset);
        } else if (composedText != null) {
            // there's composed text, but it's not displayed, so fake a rectangle
            return new Rectangle(0, 0, 0, 10);
        } else {
            InputMethodRequests requests = getClientInputMethodRequests();
            if (requests != null) {
                return requests.getTextLocation(offset);
            } else {
                // passive client, no composed text, so fake a rectangle
                return new Rectangle(0, 0, 0, 10);
            }
        }
    }
}
 
Example #7
Source File: CompositionAreaHandler.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public Rectangle getTextLocation(TextHitInfo offset) {
    synchronized (compositionAreaLock) {
        if (compositionAreaOwner == this && isCompositionAreaVisible()) {
            return compositionArea.getTextLocation(offset);
        } else if (composedText != null) {
            // there's composed text, but it's not displayed, so fake a rectangle
            return new Rectangle(0, 0, 0, 10);
        } else {
            InputMethodRequests requests = getClientInputMethodRequests();
            if (requests != null) {
                return requests.getTextLocation(offset);
            } else {
                // passive client, no composed text, so fake a rectangle
                return new Rectangle(0, 0, 0, 10);
            }
        }
    }
}
 
Example #8
Source File: CompositionAreaHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates the composition area.
 */
private void createCompositionArea() {
    synchronized(compositionAreaLock) {
        compositionArea = new CompositionArea();
        if (compositionAreaOwner != null) {
            compositionArea.setHandlerInfo(compositionAreaOwner, inputMethodContext);
        }
        // If the client component is an active client using below-the-spot style, then
        // make the composition window undecorated without a title bar.
        Component client = clientComponent.get();
        if(client != null){
            InputMethodRequests req = client.getInputMethodRequests();
            if (req != null && inputMethodContext.useBelowTheSpotInput()) {
                setCompositionAreaUndecorated(true);
            }
        }
    }
}
 
Example #9
Source File: CompositionAreaHandler.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Creates the composition area.
 */
private void createCompositionArea() {
    synchronized(compositionAreaLock) {
        compositionArea = new CompositionArea();
        if (compositionAreaOwner != null) {
            compositionArea.setHandlerInfo(compositionAreaOwner, inputMethodContext);
        }
        // If the client component is an active client using below-the-spot style, then
        // make the composition window undecorated without a title bar.
        Component client = clientComponent.get();
        if(client != null){
            InputMethodRequests req = client.getInputMethodRequests();
            if (req != null && inputMethodContext.useBelowTheSpotInput()) {
                setCompositionAreaUndecorated(true);
            }
        }
    }
}
 
Example #10
Source File: JTextComponent.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public InputMethodRequests getInputMethodRequests() {
    if (inputMethodRequestsHandler == null) {
        inputMethodRequestsHandler = new InputMethodRequestsHandler();
        Document doc = getDocument();
        if (doc != null) {
            doc.addDocumentListener((DocumentListener)inputMethodRequestsHandler);
        }
    }

    return inputMethodRequestsHandler;
}
 
Example #11
Source File: CompositionAreaHandler.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the input method request handler of the client component.
 * When using the composition window for an active client (below-the-spot
 * input), input method requests that do not relate to the display of
 * the composed text are forwarded to the client component.
 */
InputMethodRequests getClientInputMethodRequests() {
    Component client = clientComponent.get();
    if (client != null) {
        return client.getInputMethodRequests();
    }

    return null;
}
 
Example #12
Source File: XTextFieldPeer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see java.awt.peer.TextComponentPeer
 */
@Override
public InputMethodRequests getInputMethodRequests() {
    if (xtext != null) return xtext.getInputMethodRequests();
    else  return null;

}
 
Example #13
Source File: CompositionAreaHandler.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public int getInsertPositionOffset() {
    InputMethodRequests req = getClientInputMethodRequests();
    if (req != null) {
        return req.getInsertPositionOffset();
    }

    // we don't have access to the client component's text.
    return 0;
}
 
Example #14
Source File: InputMethodContext.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private InputMethodRequests getReq() {
    if (haveActiveClient() && !useBelowTheSpotInput()) {
        return getClientComponent().getInputMethodRequests();
    } else {
        return getCompositionAreaHandler(false);
    }
}
 
Example #15
Source File: CompositionAreaHandler.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public int getCommittedTextLength() {
    InputMethodRequests req = getClientInputMethodRequests();
    if(req != null) {
        return req.getCommittedTextLength();
    }

    // we don't have access to the client component's text.
    return 0;
}
 
Example #16
Source File: InputMethodContext.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
private InputMethodRequests getReq() {
    if (haveActiveClient() && !useBelowTheSpotInput()) {
        return getClientComponent().getInputMethodRequests();
    } else {
        return getCompositionAreaHandler(false);
    }
}
 
Example #17
Source File: CompositionAreaHandler.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public AttributedCharacterIterator getSelectedText(Attribute[] attributes) {
    InputMethodRequests req = getClientInputMethodRequests();
    if(req != null) {
        return req.getSelectedText(attributes);
    }

    // we don't have access to the client component's text.
    return EMPTY_TEXT;
}
 
Example #18
Source File: JTextComponent.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public InputMethodRequests getInputMethodRequests() {
    if (inputMethodRequestsHandler == null) {
        inputMethodRequestsHandler = new InputMethodRequestsHandler();
        Document doc = getDocument();
        if (doc != null) {
            doc.addDocumentListener((DocumentListener)inputMethodRequestsHandler);
        }
    }

    return inputMethodRequestsHandler;
}
 
Example #19
Source File: CompositionArea.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Positions the composition window near (usually below) the
 * insertion point in the client component if the client
 * component is an active client (below-the-spot input).
 */
void updateWindowLocation() {
    InputMethodRequests req = handler.getClientInputMethodRequests();
    if (req == null) {
        // not an active client
        return;
    }

    Point windowLocation = new Point();

    Rectangle caretRect = req.getTextLocation(null);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension windowSize = compositionWindow.getSize();
    final int SPACING = 2;

    if (caretRect.x + windowSize.width > screenSize.width) {
        windowLocation.x = screenSize.width - windowSize.width;
    } else {
        windowLocation.x = caretRect.x;
    }

    if (caretRect.y + caretRect.height + SPACING + windowSize.height > screenSize.height) {
        windowLocation.y = caretRect.y - SPACING - windowSize.height;
    } else {
        windowLocation.y = caretRect.y + caretRect.height + SPACING;
    }

    compositionWindow.setLocation(windowLocation);
}
 
Example #20
Source File: CompositionAreaHandler.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public int getInsertPositionOffset() {
    InputMethodRequests req = getClientInputMethodRequests();
    if (req != null) {
        return req.getInsertPositionOffset();
    }

    // we don't have access to the client component's text.
    return 0;
}
 
Example #21
Source File: CompositionArea.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Positions the composition window near (usually below) the
 * insertion point in the client component if the client
 * component is an active client (below-the-spot input).
 */
void updateWindowLocation() {
    InputMethodRequests req = handler.getClientInputMethodRequests();
    if (req == null) {
        // not an active client
        return;
    }

    Point windowLocation = new Point();

    Rectangle caretRect = req.getTextLocation(null);
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension windowSize = compositionWindow.getSize();
    final int SPACING = 2;

    if (caretRect.x + windowSize.width > screenSize.width) {
        windowLocation.x = screenSize.width - windowSize.width;
    } else {
        windowLocation.x = caretRect.x;
    }

    if (caretRect.y + caretRect.height + SPACING + windowSize.height > screenSize.height) {
        windowLocation.y = caretRect.y - SPACING - windowSize.height;
    } else {
        windowLocation.y = caretRect.y + caretRect.height + SPACING;
    }

    compositionWindow.setLocation(windowLocation);
}
 
Example #22
Source File: InputMethodContext.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private InputMethodRequests getReq() {
    if (haveActiveClient() && !useBelowTheSpotInput()) {
        return getClientComponent().getInputMethodRequests();
    } else {
        return getCompositionAreaHandler(false);
    }
}
 
Example #23
Source File: CompositionAreaHandler.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public int getInsertPositionOffset() {
    InputMethodRequests req = getClientInputMethodRequests();
    if (req != null) {
        return req.getInsertPositionOffset();
    }

    // we don't have access to the client component's text.
    return 0;
}
 
Example #24
Source File: CompositionAreaHandler.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public AttributedCharacterIterator getSelectedText(Attribute[] attributes) {
    InputMethodRequests req = getClientInputMethodRequests();
    if(req != null) {
        return req.getSelectedText(attributes);
    }

    // we don't have access to the client component's text.
    return EMPTY_TEXT;
}
 
Example #25
Source File: CompositionAreaHandler.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public int getInsertPositionOffset() {
    InputMethodRequests req = getClientInputMethodRequests();
    if (req != null) {
        return req.getInsertPositionOffset();
    }

    // we don't have access to the client component's text.
    return 0;
}
 
Example #26
Source File: CompositionAreaHandler.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public int getCommittedTextLength() {
    InputMethodRequests req = getClientInputMethodRequests();
    if(req != null) {
        return req.getCommittedTextLength();
    }

    // we don't have access to the client component's text.
    return 0;
}
 
Example #27
Source File: JTextComponent.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public InputMethodRequests getInputMethodRequests() {
    if (inputMethodRequestsHandler == null) {
        inputMethodRequestsHandler = new InputMethodRequestsHandler();
        Document doc = getDocument();
        if (doc != null) {
            doc.addDocumentListener((DocumentListener)inputMethodRequestsHandler);
        }
    }

    return inputMethodRequestsHandler;
}
 
Example #28
Source File: CompositionAreaHandler.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public int getCommittedTextLength() {
    InputMethodRequests req = getClientInputMethodRequests();
    if(req != null) {
        return req.getCommittedTextLength();
    }

    // we don't have access to the client component's text.
    return 0;
}
 
Example #29
Source File: XTextFieldPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @see java.awt.peer.TextComponentPeer
 */
@Override
public InputMethodRequests getInputMethodRequests() {
    if (xtext != null) return xtext.getInputMethodRequests();
    else  return null;

}
 
Example #30
Source File: CompositionAreaHandler.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public AttributedCharacterIterator getCommittedText(int beginIndex,
                                                   int endIndex,
                                                   Attribute[] attributes) {
    InputMethodRequests req = getClientInputMethodRequests();
    if(req != null) {
        return req.getCommittedText(beginIndex, endIndex, attributes);
    }

    // we don't have access to the client component's text.
    return EMPTY_TEXT;
}