Hello,

Could you review the fix:
  bug: https://bugs.openjdk.java.net/browse/JDK-8163124
  webrev: http://cr.openjdk.java.net/~alexsch/8163124/webrev.00

The text position can have floating point value on HiDPI display. The Caret interface should be updated to allow use floating point positions.

  The fix adds the following public API with floating point positions:
  javax.swing.text.Caret.getMagicCaretPosition2D()
  javax.swing.text.Caret.setMagicCaretPosition2D(Point2D p)
  javax.swing.text.JTextComponent.modelToView2D(int pos)
  javax.swing.text.JTextComponent.viewToModel2D(Point2D pt)
javax.swing.text.ParagraphView.getClosestPositionTo(int pos, Position.Bias b, Shape a, int direction, Position.Bias[], int rowIndex, float x)


The fix replaces Caret.getMagicCaretPosition()/setMagicCaretPosition(Point p) to Caret.getMagicCaretPosition2D()/setMagicCaretPosition2D(Point2D p) in all places except DefaultCaret because DefaultCaret extends Rectangle so its coordinates always have int values. I have filled a separated enhancement for this JDK-8163174 Add DefaultCaret2D which supports floating point API

To make a custom caret use floating point API it is also necessary that PlainView.modelToView() returns a rectangle with floating point values. It can be done after the fix
    JDK-8156217 Selected text is shifted on HiDPI display
which implements Utilities.getTabbedTextWidth(Segment s, FontMetrics metrics, float x, TabExpander e, int startOffset) method.
  I have filled a separated issue on it:
    JDK-8163175 PlainView.modelToView() method should return Rectangle2D

 Thanks,
 Alexandr.

Reply via email to