Package java.awt.font

Examples of java.awt.font.TextHitInfo


    ) {
        GeneralPath res = new GeneralPath();

        for (int i=firstEndpoint; i<=secondEndpoint; i++) {
            int endRun = breaker.getLevelRunLimit(i, secondEndpoint);
            TextHitInfo hit1 = TextHitInfo.leading(i);
            TextHitInfo hit2 = TextHitInfo.trailing(endRun-1);

            Line2D caret1 = getCaretShape(hit1, layout, false, true, bounds);
            Line2D caret2 = getCaretShape(hit2, layout, false, true, bounds);

            res.append(connectCarets(caret1, caret2), false);
View Full Code Here


                    }
                    InputMethodRequests imr = client.getInputMethodRequests();
                    if (imr != null) {
                        if (IMManager.belowTheSpot()) {
                            // position window below the spot:
                            TextHitInfo offset = TextHitInfo.leading(0);
                            Rectangle textLoc = imr.getTextLocation(offset);
                            setLocationBelow(textLoc);                          
                        } else {
                            client.dispatchEvent(ime);
                            return;
View Full Code Here

        if (visual == breaker.getCharCount()) {
            return null;
        }

        TextHitInfo newInfo;

        while(visual <= breaker.getCharCount()) {
            visual++;
            newInfo = getHitInfoFromVisual(visual);

            if (newInfo.getCharIndex() >= breaker.logical2segment.length) {
                return newInfo;
            }

            if (hitInfo.getCharIndex() >= 0) { // Don't check for leftmost info
                if (
                        breaker.logical2segment[newInfo.getCharIndex()] !=
                        breaker.logical2segment[hitInfo.getCharIndex()]
                ) {
                    return newInfo; // We crossed segment boundary
                }
            }

            TextRunSegment seg = breaker.runSegments.get(breaker.logical2segment[newInfo
                    .getCharIndex()]);
            if (!seg.charHasZeroAdvance(newInfo.getCharIndex())) {
                return newInfo;
            }
        }

        return null;
View Full Code Here

        if (visual == 0) {
            return null;
        }

        TextHitInfo newInfo;

        while(visual >= 0) {
            visual--;
            newInfo = getHitInfoFromVisual(visual);

            if (newInfo.getCharIndex() < 0) {
                return newInfo;
            }

            // Don't check for rightmost info
            if (hitInfo.getCharIndex() < breaker.logical2segment.length) {
                if (
                        breaker.logical2segment[newInfo.getCharIndex()] !=
                        breaker.logical2segment[hitInfo.getCharIndex()]
                ) {
                    return newInfo; // We crossed segment boundary
                }
            }

            TextRunSegment seg = breaker.runSegments.get(breaker.logical2segment[newInfo
                    .getCharIndex()]);
            if (!seg.charHasZeroAdvance(newInfo.getCharIndex())) {
                return newInfo;
            }
        }

        return null;
View Full Code Here

     */
    public Shape[] getCaretShapes(
            int offset, Rectangle2D bounds,
            TextLayout.CaretPolicy policy, TextLayout layout
    ) {
        TextHitInfo hit1 = TextHitInfo.afterOffset(offset);
        TextHitInfo hit2 = getVisualOtherHit(hit1);

        Shape caret1 = getCaretShape(hit1, layout);

        if (getVisualFromHitInfo(hit1) == getVisualFromHitInfo(hit2)) {
            return new Shape[] {caret1, null};
        }
        Shape caret2 = getCaretShape(hit2, layout);

        TextHitInfo strongHit = policy.getStrongCaret(hit1, hit2, layout);
        return strongHit.equals(hit1) ?
                new Shape[] {caret1, caret2} :
                new Shape[] {caret2, caret1};
    }
View Full Code Here

    ) {
        GeneralPath res = new GeneralPath();

        for (int i=firstEndpoint; i<=secondEndpoint; i++) {
            int endRun = breaker.getLevelRunLimit(i, secondEndpoint);
            TextHitInfo hit1 = TextHitInfo.leading(i);
            TextHitInfo hit2 = TextHitInfo.trailing(endRun-1);

            Line2D caret1 = getCaretShape(hit1, layout, false, true, bounds);
            Line2D caret2 = getCaretShape(hit2, layout, false, true, bounds);

            res.append(connectCarets(caret1, caret2), false);
View Full Code Here

            }
        }
       
        ACIText aText = new ACIText( text, 0, totalChars, committedChars );
        int composedCharLength = totalChars - committedChars;
        TextHitInfo caret=null,visiblePosition=null;
        switch( composedCharLength ) {
            case 0:
                break;
            case 1:
                visiblePosition = caret = ZERO_TRAILING_HIT_INFO;
View Full Code Here

        SimpleInputMethodListener listener2 = new SimpleInputMethodListener("2");
        SimpleInputMethodListener listener3 = new SimpleInputMethodListener("3");
        jtc.addInputMethodListener(listener1);
        jtc.addInputMethodListener(listener2);
        jtc.addInputMethodListener(listener3);
        TextHitInfo textHitInfo = TextHitInfo.afterOffset(0);
        assertNotNull(textHitInfo);
        jtc.setText("JTextComponent");
        jtc.enableInputMethods(true);
        imEventTest(InputMethodEvent.CARET_POSITION_CHANGED, "123", "");
        imEventTest(InputMethodEvent.INPUT_METHOD_TEXT_CHANGED, "", "123");
View Full Code Here

            // vector when the view is created so we don't need to rebuild it
            // every time
            int offset;
            if (text.length() > 0) {
                TextLayout textLayout = new TextLayout(text, font, fontRenderContext);
                TextHitInfo textHitInfo = textLayout.hitTestChar(x, y);
                offset = textHitInfo.getInsertionIndex();
            } else {
                offset = -1;
            }

            return offset + start;
View Full Code Here

        Point2D p = new Point2D.Float(x, y);
        try {
        transform.inverseTransform(p, p);
        } catch (java.awt.geom.NoninvertibleTransformException nite) {;}
        TextHitInfo hit = layout.hitTestChar((float) p.getX(),
                                             (float) p.getY());
        // put this in to be consistent with GlyphLayout
        if (hit.getCharIndex() == -1) {
            return null;
        }
        return new TextHit(hit.getCharIndex(), hit.isLeadingEdge());
    }
View Full Code Here

TOP

Related Classes of java.awt.font.TextHitInfo

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.