Java Code Examples for java.awt.im.InputMethodRequests#getTextLocation()

The following examples show how to use java.awt.im.InputMethodRequests#getTextLocation() . 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
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 2
Source File: CompositionAreaHandler.java    From openjdk-8-source 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 3
Source File: CompositionAreaHandler.java    From hottub 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 4
Source File: CompositionAreaHandler.java    From jdk8u-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 5
Source File: CompositionAreaHandler.java    From openjdk-8 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 Bytecoder with Apache License 2.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-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 8
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 9
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 10
Source File: CompositionAreaHandler.java    From TencentKona-8 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 11
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 12
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 13
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 14
Source File: CompositionArea.java    From openjdk-jdk9 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 15
Source File: CompositionArea.java    From jdk8u60 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 16
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 17
Source File: CompositionArea.java    From hottub 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 18
Source File: CompositionArea.java    From jdk8u-dev-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 19
Source File: CompositionArea.java    From openjdk-8-source 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 20
Source File: CompositionArea.java    From dragonwell8_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);
}