< prev index next >

modules/controls/src/main/java/com/sun/javafx/scene/control/skin/Utils.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -52,24 +52,23 @@
 import javafx.scene.input.Mnemonic;
 import javafx.scene.paint.Color;
 import javafx.scene.text.Font;
 import javafx.scene.text.Text;
 import javafx.scene.text.TextBoundsType;
+import javafx.scene.text.HitInfo;
 
 import java.text.Bidi;
-import java.text.BreakIterator;
 import java.util.Locale;
 import java.util.function.Consumer;
 
 import static javafx.scene.control.OverrunStyle.CENTER_ELLIPSIS;
 import static javafx.scene.control.OverrunStyle.CENTER_WORD_ELLIPSIS;
 import static javafx.scene.control.OverrunStyle.CLIP;
 import static javafx.scene.control.OverrunStyle.ELLIPSIS;
 import static javafx.scene.control.OverrunStyle.LEADING_ELLIPSIS;
 import static javafx.scene.control.OverrunStyle.LEADING_WORD_ELLIPSIS;
 import static javafx.scene.control.OverrunStyle.WORD_ELLIPSIS;
-import static javafx.scene.control.skin.TextFieldSkin.TextPosInfo;
 
 /**
  * BE REALLY CAREFUL WITH RESTORING OR RESETTING STATE OF helper NODE AS LEFTOVER
  * STATE CAUSES REALLY ODD NASTY BUGS!
  *

@@ -152,11 +151,11 @@
         // The -2 is a fudge to make sure the result more often matches
         // what we get from using computeTextWidth instead. It's not yet
         // clear what causes the small discrepancies.
         Bounds bounds = helper.getLayoutBounds();
         Point2D endPoint = new Point2D(width - 2, bounds.getMinY() + bounds.getHeight() / 2);
-        final int index = helper.impl_hitTestChar(endPoint).getCharIndex();
+        final int index = helper.hitTest(endPoint).getCharIndex();
         // RESTORE STATE
         helper.setWrappingWidth(DEFAULT_WRAPPING_WIDTH);
         helper.setLineSpacing(DEFAULT_LINE_SPACING);
         helper.setText(DEFAULT_TEXT);
         return index;

@@ -408,17 +407,17 @@
 
         // Find index of character at the bottom left of the text area.
         // This should be the first character of a line that would be clipped.
         Point2D endPoint = new Point2D(0, height - helper.getBaselineOffset());
 
-        int hit = helper.impl_hitTestChar(endPoint).getCharIndex();
+        int hit = helper.hitTest(endPoint).getCharIndex();
         if (hit >= len) {
             helper.setBoundsType(TextBoundsType.LOGICAL); // restore
             return text;
         }
         if (center) {
-            hit = helper.impl_hitTestChar(centerPoint).getCharIndex();
+            hit = helper.hitTest(centerPoint).getCharIndex();
         }
 
         if (hit > 0 && hit < len) {
             // Step one, make a truncation estimate.
 

@@ -475,11 +474,11 @@
 
             // Step two, check if text still overflows after we added the ellipsis.
             // If so, remove one char or word at a time.
             while (true) {
                 helper.setText(result);
-                int hit2 = helper.impl_hitTestChar(endPoint).getCharIndex();
+                int hit2 = helper.hitTest(endPoint).getCharIndex();
                 if (center && hit2 < centerLen) {
                     // No room for text after ellipsis. Maybe there is a newline
                     // here, and the next line falls outside the view.
                     if (hit2 > 0 && result.charAt(hit2-1) == '\n') {
                         hit2--;

@@ -753,30 +752,10 @@
     public static boolean isTwoLevelFocus() {
         return Platform.isSupported(ConditionalFeature.TWO_LEVEL_FOCUS);
     }
 
 
-    // Workaround for RT-26961. HitInfo.getInsertionIndex() doesn't skip
-    // complex character clusters / ligatures.
-    private static BreakIterator charIterator = null;
-    public static int getHitInsertionIndex(TextPosInfo hit, String text) {
-        int charIndex = hit.getCharIndex();
-        if (text != null && !hit.isLeading()) {
-            if (charIterator == null) {
-                charIterator = BreakIterator.getCharacterInstance();
-            }
-            charIterator.setText(text);
-            int next = charIterator.following(charIndex);
-            if (next == BreakIterator.DONE) {
-                charIndex = hit.getInsertionIndex();
-            } else {
-                charIndex = next;
-            }
-        }
-        return charIndex;
-    }
-
     // useful method for linking things together when before a property is
     // necessarily set
     public static <T> void executeOnceWhenPropertyIsNonNull(ObservableValue<T> p, Consumer<T> consumer) {
         if (p == null) return;
 
< prev index next >