diff options
author | Mark Wielaard <mark@klomp.org> | 2006-12-05 00:03:01 +0000 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2006-12-05 00:03:01 +0000 |
commit | 99729ee7d09b6adee9caa2a7ba72c1813757648f (patch) | |
tree | 01fae597102147048713c5b2457bbb592f834803 | |
parent | db646790cae1f99be68f70f3a1582ac150b69944 (diff) | |
download | classpath-99729ee7d09b6adee9caa2a7ba72c1813757648f.tar.gz |
* java/awt/font/TextLayout.java
(hitTestChar): Fixed conditions for inclusion of range.
Use layout information in the run for more efficiency.
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | java/awt/font/TextLayout.java | 24 |
2 files changed, 16 insertions, 14 deletions
@@ -1,3 +1,9 @@ +2006-12-04 Roman Kennke <kennke@aicas.com> + + * java/awt/font/TextLayout.java + (hitTestChar): Fixed conditions for inclusion of range. + Use layout information in the run for more efficiency. + 2006-12-04 Andrew John Hughes <gnu_andrew@member.fsf.org> * javax/management/openmbean/OpenType.java: diff --git a/java/awt/font/TextLayout.java b/java/awt/font/TextLayout.java index dde28df0a..dc0e537eb 100644 --- a/java/awt/font/TextLayout.java +++ b/java/awt/font/TextLayout.java @@ -1176,16 +1176,14 @@ public final class TextLayout implements Cloneable // TODO: Perform binary search for maximum efficiency. However, we // need the run location laid out statically to do that. int numRuns = runs.length; - float offs = 0; Run hitRun = null; for (int i = 0; i < numRuns && hitRun == null; i++) { Run run = runs[i]; Rectangle2D lBounds = run.glyphVector.getLogicalBounds(); - if (lBounds.getMinY() + offs <= y && lBounds.getMaxY() + offs > y) + if (lBounds.getMinY() + run.location <= y + && lBounds.getMaxY() + run.location >= y) hitRun = run; - else - offs += lBounds.getHeight(); } // Now we have (hopefully) found a run that hits. Now find the // right character. @@ -1198,12 +1196,12 @@ public final class TextLayout implements Cloneable int gi = i - hitRun.runStart; Rectangle2D lBounds = gv.getGlyphLogicalBounds(gi) .getBounds2D(); - if (lBounds.getMinY() + offs <= y - && lBounds.getMaxY() + offs > y) + if (lBounds.getMinY() + hitRun.location <= y + && lBounds.getMaxY() + hitRun.location >= y) { // Found hit. Now check if we are leading or trailing. boolean leading = true; - if (lBounds.getCenterY() + offs <= y) + if (lBounds.getCenterY() + hitRun.location <= y) leading = false; hitInfo = leading ? TextHitInfo.leading(i) : TextHitInfo.trailing(i); @@ -1217,16 +1215,14 @@ public final class TextLayout implements Cloneable // TODO: Perform binary search for maximum efficiency. However, we // need the run location laid out statically to do that. int numRuns = runs.length; - float offs = 0; Run hitRun = null; for (int i = 0; i < numRuns && hitRun == null; i++) { Run run = runs[i]; Rectangle2D lBounds = run.glyphVector.getLogicalBounds(); - if (lBounds.getMinX() + offs <= x && lBounds.getMaxX() + offs > x) + if (lBounds.getMinX() + run.location <= x + && lBounds.getMaxX() + run.location >= x) hitRun = run; - else - offs += lBounds.getWidth(); } // Now we have (hopefully) found a run that hits. Now find the // right character. @@ -1239,12 +1235,12 @@ public final class TextLayout implements Cloneable int gi = i - hitRun.runStart; Rectangle2D lBounds = gv.getGlyphLogicalBounds(gi) .getBounds2D(); - if (lBounds.getMinX() + offs <= x - && lBounds.getMaxX() + offs > x) + if (lBounds.getMinX() + hitRun.location <= x + && lBounds.getMaxX() + hitRun.location >= x) { // Found hit. Now check if we are leading or trailing. boolean leading = true; - if (lBounds.getCenterX() + offs <= x) + if (lBounds.getCenterX() + hitRun.location <= x) leading = false; hitInfo = leading ? TextHitInfo.leading(i) : TextHitInfo.trailing(i); |