changeset 16302:f2fe778fe293

8169719: WrappedPlainView.modelToView() should return Rectangle2D Reviewed-by: prr, serb, ssadetsky
author alexsch
date Mon, 21 Nov 2016 17:46:48 +0300
parents 540246aa1f83
children df43cdd4bb33
files src/java.desktop/share/classes/javax/swing/text/WrappedPlainView.java
diffstat 1 files changed, 5 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.desktop/share/classes/javax/swing/text/WrappedPlainView.java	Thu Nov 17 14:14:40 2016 +0530
+++ b/src/java.desktop/share/classes/javax/swing/text/WrappedPlainView.java	Mon Nov 21 17:46:48 2016 +0300
@@ -26,6 +26,7 @@
 
 import java.awt.*;
 import java.awt.font.FontRenderContext;
+import java.awt.geom.Rectangle2D;
 import java.lang.ref.SoftReference;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
@@ -750,7 +751,6 @@
          *   valid location in the associated document
          * @see View#modelToView
          */
-        @SuppressWarnings("deprecation")
         public Shape modelToView(int pos, Shape a, Position.Bias b)
                 throws BadLocationException {
             Rectangle alloc = a.getBounds();
@@ -777,9 +777,11 @@
             if (pos > p0) {
                 Segment segment = SegmentCache.getSharedSegment();
                 loadText(segment, p0, pos);
-                alloc.x += Utilities.getTabbedTextWidth(segment, metrics,
-                        alloc.x, WrappedPlainView.this, p0);
+                float x = alloc.x;
+                x += Utilities.getTabbedTextWidth(segment, metrics, x,
+                                                  WrappedPlainView.this, p0);
                 SegmentCache.releaseSharedSegment(segment);
+                return new Rectangle2D.Float(x, alloc.y, alloc.width, alloc.height);
             }
             return alloc;
         }