下面列出了java.awt.font.TextLayout#getCaretInfo ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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;
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}
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);
}