JDK-5084107 : Regression: JTextPane doesn't wrap with RTL ComponentOrientation
Type:Bug
Component:client-libs
Sub-Component:javax.swing
Affected Version:5.0u1
Priority:P2
Status:Resolved
Resolution:Fixed
OS:generic
CPU:generic
Submitted:2004-08-07
Updated:2012-10-09
Resolved:2004-09-22
The Version table provides details related to the release that this issue/RFE will be addressed.
Unresolved : Release in which this issue/RFE will be addressed. Resolved: Release in which this issue/RFE has been resolved. Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.
When a right-to-left ComponentOrientation is set on a JTextPane, it doesn't wrap text. This works properly in JDK 1.4.2.
Comments
CONVERTED DATA
BugTraq+ Release Management Values
COMMIT TO FIX:
1.5.0_01
mustang
FIXED IN:
1.5.0_01
mustang
INTEGRATED IN:
1.5.0_01
mustang
28-09-2004
EVALUATION
Component in question is "JTextPane". I've updated the synopsis and description as appropriate. Committing to 1.5.0_01.
Note, I've been able to reproduce this in Tiger b18. Haven't tried earlier builds.
###@###.### 2004-08-09
======
TextLayout.hitTestChar behavior was changed in 1.5 (08/2003)
For rtl layout
layout.hitTestChar(Float.MAX_VALUE, 0) was TextHitInfo(-1) in 1.4.2
now it is TextHitInfo(0)
GlyphPainter2.getBoundedPosition depends upon -1 value. When we get 0
it assumes the view is unbreakable thus there is no wrapping.
This assumption was incorrect.
javaDoc for TextLayout.hitTestChar
---
public TextHitInfo hitTestChar(float x,
float y,
Rectangle2D bounds)
Returns a TextHitInfo corresponding to the specified
point. Coordinates outside the bounds of the TextLayout map to
hits on the leading edge of the first logical character, or the
trailing edge of the last logical character, as appropriate,
regardless of the position of that character in the line. Only the
direction along the baseline is used to make this evaluation.
Parameters:
x - the x offset from the origin of this TextLayout
y - the y offset from the origin of this TextLayout
bounds - the bounds of the TextLayout
Returns:
a hit describing the character and edge (leading or trailing) under the specified point.
---
GlyphPainter2.getBoundedPosition is incorrect. Using
layout.hitTestChar to get last logical position wich fits into given
span is wrong. The question is what is the correct way.
###@###.### 2004-08-13
---
This should fix getBoundedPosition:
// note: this only works because swing uses TextLayouts that are
// only pure rtl or pure ltr
TextHitInfo hit;
if (layout.isLeftToRight()) {
hit = layout.hitTestChar(len, 0);
} else {
hit = layout.hitTesetChar(layout.getAdvance() - len, 0);
}
return v.getStartOffset() + hit.getCharIndex();
###@###.### 2004-08-27