summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Kennke <roman@kennke.org>2006-12-04 18:33:27 +0000
committerRoman Kennke <roman@kennke.org>2006-12-04 18:33:27 +0000
commit22bd14a3a7ecf5c8a11ffb7ff57d4eef4c1f2cc1 (patch)
tree171b81de2f318348c093c90abec5baddfef2c8ba
parente9dd53beedf24430d77e959f55fb1354e8099dcf (diff)
downloadclasspath-22bd14a3a7ecf5c8a11ffb7ff57d4eef4c1f2cc1.tar.gz
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.
-rw-r--r--ChangeLog6
-rw-r--r--java/awt/font/TextLayout.java24
2 files changed, 16 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 9fa8d2274..f5af97a42 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* gnu/java/lang/management/BeanImpl.java:
diff --git a/java/awt/font/TextLayout.java b/java/awt/font/TextLayout.java
index 2f810cddf..26e784b9a 100644
--- a/java/awt/font/TextLayout.java
+++ b/java/awt/font/TextLayout.java
@@ -1174,16 +1174,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.
@@ -1196,12 +1194,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);
@@ -1215,16 +1213,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.
@@ -1237,12 +1233,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);