Java Code Examples for java.awt.font.TextLayout#getCaretInfo()

The following examples show how to use java.awt.font.TextLayout#getCaretInfo() . 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: TextBoxView.java    From SwingBox with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Shape modelToView(int pos, Shape a, Bias b)
        throws BadLocationException
{
    TextLayout layout = getTextLayout();
    int offs = pos - getStartOffset(); // the start position this view is responsible for
    Rectangle alloc = new Rectangle(toRect(a));
    TextHitInfo hit = ((b == Position.Bias.Forward) ? TextHitInfo.afterOffset(offs) : TextHitInfo.beforeOffset(offs));
    float[] locs = layout.getCaretInfo(hit);

    // hint: nie je lepsie to prepisat na setBounds, ktory berie int ?
    alloc.setRect(alloc.getX() + locs[0], alloc.getY(), 1D,
            alloc.getHeight());

    return alloc;
}
 
Example 2
Source File: TextMeasureTests.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    TLExContext tlctx = (TLExContext)ctx;
    TextLayout tl = tlctx.tl;
    TextHitInfo[] hits = tlctx.hits;
    do {
        for (int i = 0; i < hits.length; ++i) {
            tl.getCaretInfo(hits[i]);
        }
    } while (--numReps >= 0);
}
 
Example 3
Source File: TextMeasureTests.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    TLExContext tlctx = (TLExContext)ctx;
    TextLayout tl = tlctx.tl;
    TextHitInfo[] hits = tlctx.hits;
    do {
        for (int i = 0; i < hits.length; ++i) {
            tl.getCaretInfo(hits[i]);
        }
    } while (--numReps >= 0);
}
 
Example 4
Source File: TextMeasureTests.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    TLExContext tlctx = (TLExContext)ctx;
    TextLayout tl = tlctx.tl;
    TextHitInfo[] hits = tlctx.hits;
    do {
        for (int i = 0; i < hits.length; ++i) {
            tl.getCaretInfo(hits[i]);
        }
    } while (--numReps >= 0);
}
 
Example 5
Source File: TextMeasureTests.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    TLExContext tlctx = (TLExContext)ctx;
    TextLayout tl = tlctx.tl;
    TextHitInfo[] hits = tlctx.hits;
    do {
        for (int i = 0; i < hits.length; ++i) {
            tl.getCaretInfo(hits[i]);
        }
    } while (--numReps >= 0);
}
 
Example 6
Source File: TextMeasureTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    TLExContext tlctx = (TLExContext)ctx;
    TextLayout tl = tlctx.tl;
    TextHitInfo[] hits = tlctx.hits;
    do {
        for (int i = 0; i < hits.length; ++i) {
            tl.getCaretInfo(hits[i]);
        }
    } while (--numReps >= 0);
}
 
Example 7
Source File: TextMeasureTests.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    TLExContext tlctx = (TLExContext)ctx;
    TextLayout tl = tlctx.tl;
    TextHitInfo[] hits = tlctx.hits;
    do {
        for (int i = 0; i < hits.length; ++i) {
            tl.getCaretInfo(hits[i]);
        }
    } while (--numReps >= 0);
}
 
Example 8
Source File: TextMeasureTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    TLExContext tlctx = (TLExContext)ctx;
    TextLayout tl = tlctx.tl;
    TextHitInfo[] hits = tlctx.hits;
    do {
        for (int i = 0; i < hits.length; ++i) {
            tl.getCaretInfo(hits[i]);
        }
    } while (--numReps >= 0);
}
 
Example 9
Source File: TextMeasureTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    TLExContext tlctx = (TLExContext)ctx;
    TextLayout tl = tlctx.tl;
    TextHitInfo[] hits = tlctx.hits;
    do {
        for (int i = 0; i < hits.length; ++i) {
            tl.getCaretInfo(hits[i]);
        }
    } while (--numReps >= 0);
}
 
Example 10
Source File: TextMeasureTests.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    TLExContext tlctx = (TLExContext)ctx;
    TextLayout tl = tlctx.tl;
    TextHitInfo[] hits = tlctx.hits;
    do {
        for (int i = 0; i < hits.length; ++i) {
            tl.getCaretInfo(hits[i]);
        }
    } while (--numReps >= 0);
}
 
Example 11
Source File: TextMeasureTests.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    TLExContext tlctx = (TLExContext)ctx;
    TextLayout tl = tlctx.tl;
    TextHitInfo[] hits = tlctx.hits;
    do {
        for (int i = 0; i < hits.length; ++i) {
            tl.getCaretInfo(hits[i]);
        }
    } while (--numReps >= 0);
}
 
Example 12
Source File: TextMeasureTests.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    TLExContext tlctx = (TLExContext)ctx;
    TextLayout tl = tlctx.tl;
    TextHitInfo[] hits = tlctx.hits;
    do {
        for (int i = 0; i < hits.length; ++i) {
            tl.getCaretInfo(hits[i]);
        }
    } while (--numReps >= 0);
}
 
Example 13
Source File: TextMeasureTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    TLExContext tlctx = (TLExContext)ctx;
    TextLayout tl = tlctx.tl;
    TextHitInfo[] hits = tlctx.hits;
    do {
        for (int i = 0; i < hits.length; ++i) {
            tl.getCaretInfo(hits[i]);
        }
    } while (--numReps >= 0);
}
 
Example 14
Source File: TextMeasureTests.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
public void runTest(Object ctx, int numReps) {
    TLExContext tlctx = (TLExContext)ctx;
    TextLayout tl = tlctx.tl;
    TextHitInfo[] hits = tlctx.hits;
    do {
        for (int i = 0; i < hits.length; ++i) {
            tl.getCaretInfo(hits[i]);
        }
    } while (--numReps >= 0);
}