# HG changeset patch # User leifs # Date 1454602003 -3600 # Thu Feb 04 17:06:43 2016 +0100 # Node ID 5708cf19c3ed17f0a06881fa645b517f436fa52c # Parent 791cdba30972eecf7d73d0ebc7416897a89f2678 8143158: [Text, TextFlow] Make public API from internal "impl" APIs (parts 1+2 of 4) diff --git a/apps/toys/Hello/src/main/java/a11y/HelloText.java b/apps/toys/Hello/src/main/java/a11y/HelloText.java --- a/apps/toys/Hello/src/main/java/a11y/HelloText.java +++ b/apps/toys/Hello/src/main/java/a11y/HelloText.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -46,7 +46,7 @@ @Override public void start(Stage stage) { final Text text = new Text("01234"); - text.impl_selectionFillProperty().set(Color.BLUE); + text.selectionFillProperty().set(Color.BLUE); text.setFont(Font.font(50)); Label l1 = new Label("name"); diff --git a/apps/toys/Hello/src/main/java/hello/HelloTextFlow.java b/apps/toys/Hello/src/main/java/hello/HelloTextFlow.java new file mode 100644 --- /dev/null +++ b/apps/toys/Hello/src/main/java/hello/HelloTextFlow.java @@ -0,0 +1,147 @@ +/* + * Copyright (c) 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 + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package hello; + +import javafx.application.Application; +import javafx.geometry.Point2D; +import javafx.scene.*; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.paint.*; +import javafx.scene.shape.Path; +import javafx.scene.text.*; +import javafx.stage.Stage; + +import static javafx.scene.paint.Color.*; + +public class HelloTextFlow extends Application { + final Path caret = new Path(); + final Path highlight = new Path(); + + int caretPos = -1; + int anchorPos = -1; + + @Override public void start(Stage stage) { + stage.setTitle("Hello TextFlow"); + + Text text1 = mkText(0, 3); + Text text2 = mkText(3, 7); + + TextFlow textFlow = + new TextFlow(text1, + new ImageView(new Image("hello/duke.jpg", 30f, 30f, true, true, false)), + text2) { + { + setCursor(Cursor.TEXT); + setOnMousePressed(e -> { + HitInfo hit = hitTest(new Point2D(e.getX(), e.getY())); + caretPos = anchorPos = hit.getInsertionIndex(); + caret.getElements().clear(); + highlight.getElements().clear(); + text1.setSelectionStart(-1); + text1.setSelectionEnd(-1); + text2.setSelectionStart(-1); + text2.setSelectionEnd(-1); + caret.getElements().addAll(caretShape(hit.getCharIndex(), hit.isLeading())); + }); + setOnMouseDragged(e -> { + HitInfo hit = hitTest(new Point2D(e.getX(), e.getY())); + caretPos = hit.getInsertionIndex(); + caret.getElements().clear(); + highlight.getElements().clear(); + if (anchorPos >= 0 && caretPos != anchorPos) { + int i1 = Math.min(caretPos, anchorPos); + int i2 = Math.max(caretPos, anchorPos); + int len1 = text1.getText().length(); + if (i1 < len1) { + text1.setSelectionStart(i1); + if (i2 < len1) { + text1.setSelectionEnd(i2); + } else { + text1.setSelectionEnd(len1); + } + } else { + text1.setSelectionStart(-1); + text1.setSelectionEnd(-1); + } + + if (i2 > len1 + 1) { + if (i1 < len1 + 1) { + text2.setSelectionStart(0); + } else if (i1 >= len1 + 1) { + text2.setSelectionStart(i1 - len1 - 1); + } + text2.setSelectionEnd(i2 - len1 - 1); + } else { + text2.setSelectionStart(-1); + text2.setSelectionEnd(-1); + } + + highlight.getElements().addAll(rangeShape(i1, i2)); + } else { + caret.getElements().addAll(caretShape(hit.getCharIndex(), hit.isLeading())); + } + }); + + caret.setStrokeWidth(1); + caret.setFill(BLACK); + caret.setStroke(BLACK); + + highlight.setStroke(null); + highlight.setFill(LIGHTBLUE); + } + + @Override public void layoutChildren() { + super.layoutChildren(); + + caret.getElements().clear(); + highlight.getElements().clear(); + if (anchorPos >= 0 && caretPos != anchorPos) { + highlight.getElements().addAll(rangeShape(Math.min(caretPos, anchorPos), + Math.max(caretPos, anchorPos))); + } else { + caret.getElements().addAll(caretShape(caretPos, true)); + } + } + + }; + + Scene scene = new Scene(new Group(highlight, textFlow, caret), 600, 400); + textFlow.prefWidthProperty().bind(scene.widthProperty()); + stage.setScene(scene); + stage.show(); + } + + private Text mkText(int start, int end) { + StringBuilder sb = new StringBuilder(); + for (int i = start; i < end; i++) { + sb.append(i + ". Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n"); + } + Text t = new Text(sb.toString()); + + return t; + } +} diff --git a/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/PasswordFieldBehavior.java b/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/PasswordFieldBehavior.java --- a/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/PasswordFieldBehavior.java +++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/PasswordFieldBehavior.java @@ -1,5 +1,5 @@ /* - * 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 @@ -26,7 +26,7 @@ package com.sun.javafx.scene.control.behavior; import javafx.scene.control.PasswordField; -import static javafx.scene.control.skin.TextFieldSkin.TextPosInfo; +import javafx.scene.text.HitInfo; /** * Password field behavior. @@ -48,7 +48,7 @@ protected void selectWord() { selectAll(); } - protected void mouseDoubleClick(TextPosInfo hit) { + protected void mouseDoubleClick(HitInfo hit) { getNode().selectAll(); } diff --git a/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TextAreaBehavior.java b/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TextAreaBehavior.java --- a/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TextAreaBehavior.java +++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TextAreaBehavior.java @@ -1,5 +1,5 @@ /* - * 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 @@ -44,13 +44,12 @@ import javafx.scene.input.KeyEvent; import javafx.scene.input.MouseButton; import javafx.scene.input.MouseEvent; +import javafx.scene.text.HitInfo; import javafx.stage.Screen; import javafx.stage.Window; import java.util.function.Predicate; -import static javafx.scene.control.skin.TextAreaSkin.TextPosInfo; - import static com.sun.javafx.PlatformUtil.isMac; import static com.sun.javafx.PlatformUtil.isWindows; import static javafx.scene.control.skin.TextInputControlSkin.TextUnit; @@ -343,9 +342,8 @@ // if the primary button was pressed if (e.getButton() == MouseButton.PRIMARY && !(e.isMiddleButtonDown() || e.isSecondaryButtonDown())) { - TextPosInfo hit = skin.getIndex(e.getX(), e.getY()); - int i = Utils.getHitInsertionIndex(hit, textArea.textProperty().getValueSafe()); -// int i = skin.getInsertionPoint(e.getX(), e.getY()); + HitInfo hit = skin.getIndex(e.getX(), e.getY()); + int i = hit.getInsertionIndex(); final int anchor = textArea.getAnchor(); final int caretPosition = textArea.getCaretPosition(); if (e.getClickCount() < 2 && @@ -488,7 +486,7 @@ skin.setCaretAnimating(play); } - protected void mouseDoubleClick(TextPosInfo hit) { + protected void mouseDoubleClick(HitInfo hit) { final TextArea textArea = getNode(); textArea.previousWord(); if (isWindows()) { @@ -498,7 +496,7 @@ } } - protected void mouseTripleClick(TextPosInfo hit) { + protected void mouseTripleClick(HitInfo hit) { // select the line skin.moveCaret(TextUnit.PARAGRAPH, Direction.BEGINNING, false); skin.moveCaret(TextUnit.PARAGRAPH, Direction.END, true); diff --git a/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TextFieldBehavior.java b/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TextFieldBehavior.java --- a/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TextFieldBehavior.java +++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/behavior/TextFieldBehavior.java @@ -42,12 +42,12 @@ import javafx.scene.input.ContextMenuEvent; import javafx.scene.input.KeyEvent; import javafx.scene.input.MouseEvent; +import javafx.scene.text.HitInfo; import javafx.stage.Screen; import javafx.stage.Window; import com.sun.javafx.PlatformUtil; import com.sun.javafx.geom.transform.Affine3D; -import static javafx.scene.control.skin.TextFieldSkin.TextPosInfo; import static com.sun.javafx.PlatformUtil.isMac; import static com.sun.javafx.PlatformUtil.isWindows; @@ -257,9 +257,8 @@ // if the primary button was pressed if (e.isPrimaryButtonDown() && !(e.isMiddleButtonDown() || e.isSecondaryButtonDown())) { - TextPosInfo hit = skin.getIndex(e.getX(), e.getY()); - String text = textField.textProperty().getValueSafe(); - int i = Utils.getHitInsertionIndex(hit, text); + HitInfo hit = skin.getIndex(e.getX(), e.getY()); + int i = hit.getInsertionIndex(); final int anchor = textField.getAnchor(); final int caretPosition = textField.getCaretPosition(); if (e.getClickCount() < 2 && @@ -397,11 +396,11 @@ e.consume(); } - protected void mouseSingleClick(TextPosInfo hit) { + protected void mouseSingleClick(HitInfo hit) { skin.positionCaret(hit, false); } - protected void mouseDoubleClick(TextPosInfo hit) { + protected void mouseDoubleClick(HitInfo hit) { final TextField textField = getNode(); textField.previousWord(); if (isWindows()) { @@ -411,7 +410,7 @@ } } - protected void mouseTripleClick(TextPosInfo hit) { + protected void mouseTripleClick(HitInfo hit) { getNode().selectAll(); } diff --git a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/Utils.java b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/Utils.java --- a/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/Utils.java +++ b/modules/controls/src/main/java/com/sun/javafx/scene/control/skin/Utils.java @@ -1,5 +1,5 @@ /* - * 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 @@ -54,9 +54,9 @@ 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; @@ -67,7 +67,6 @@ 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 @@ -154,7 +153,7 @@ // 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); @@ -410,13 +409,13 @@ // 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) { @@ -477,7 +476,7 @@ // 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. @@ -755,26 +754,6 @@ } - // 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 void executeOnceWhenPropertyIsNonNull(ObservableValue p, Consumer consumer) { diff --git a/modules/controls/src/main/java/javafx/scene/control/skin/TextAreaSkin.java b/modules/controls/src/main/java/javafx/scene/control/skin/TextAreaSkin.java --- a/modules/controls/src/main/java/javafx/scene/control/skin/TextAreaSkin.java +++ b/modules/controls/src/main/java/javafx/scene/control/skin/TextAreaSkin.java @@ -1,5 +1,5 @@ /* - * 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 @@ -28,7 +28,6 @@ import com.sun.javafx.scene.control.behavior.BehaviorBase; import com.sun.javafx.scene.control.behavior.TextAreaBehavior; import com.sun.javafx.scene.control.skin.Utils; -import com.sun.javafx.scene.text.HitInfo; import javafx.animation.KeyFrame; import javafx.animation.Timeline; import javafx.application.Platform; @@ -63,6 +62,7 @@ import javafx.scene.shape.Path; import javafx.scene.shape.PathElement; import javafx.scene.text.Text; +import javafx.scene.text.HitInfo; import javafx.util.Duration; import java.util.List; @@ -399,19 +399,9 @@ caretHandle.setOnMouseDragged(e -> { Text textNode = getTextNode(); Point2D tp = textNode.localToScene(0, 0); - Point2D p = new Point2D(e.getSceneX() - tp.getX() + 10/*??*/ - pressX + caretHandle.getWidth() / 2, + Point2D p = new Point2D(e.getSceneX() - tp.getX() - pressX + caretHandle.getWidth() / 2, e.getSceneY() - tp.getY() - pressY - 6); - HitInfo hit = textNode.impl_hitTestChar(translateCaretPosition(p)); - int pos = hit.getCharIndex(); - if (pos > 0) { - int oldPos = textNode.getImpl_caretPosition(); - textNode.setImpl_caretPosition(pos); - PathElement element = textNode.getImpl_caretShape()[0]; - if (element instanceof MoveTo && ((MoveTo)element).getY() > e.getY() - getTextTranslateY()) { - hit.setCharIndex(pos - 1); - } - textNode.setImpl_caretPosition(oldPos); - } + HitInfo hit = textNode.hitTest(translateCaretPosition(p)); positionCaret(hit, false); e.consume(); }); @@ -420,25 +410,18 @@ TextArea control1 = getSkinnable(); Text textNode = getTextNode(); Point2D tp = textNode.localToScene(0, 0); - Point2D p = new Point2D(e.getSceneX() - tp.getX() + 10/*??*/ - pressX + selectionHandle1.getWidth() / 2, + Point2D p = new Point2D(e.getSceneX() - tp.getX() - pressX + selectionHandle1.getWidth() / 2, e.getSceneY() - tp.getY() - pressY + selectionHandle1.getHeight() + 5); - HitInfo hit = textNode.impl_hitTestChar(translateCaretPosition(p)); - int pos = hit.getCharIndex(); + HitInfo hit = textNode.hitTest(translateCaretPosition(p)); if (control1.getAnchor() < control1.getCaretPosition()) { // Swap caret and anchor control1.selectRange(control1.getCaretPosition(), control1.getAnchor()); } + int pos = hit.getCharIndex(); if (pos > 0) { if (pos >= control1.getAnchor()) { pos = control1.getAnchor(); } - int oldPos = textNode.getImpl_caretPosition(); - textNode.setImpl_caretPosition(pos); - PathElement element = textNode.getImpl_caretShape()[0]; - if (element instanceof MoveTo && ((MoveTo)element).getY() > e.getY() - getTextTranslateY()) { - hit.setCharIndex(pos - 1); - } - textNode.setImpl_caretPosition(oldPos); } positionCaret(hit, true); e.consume(); @@ -448,25 +431,18 @@ TextArea control1 = getSkinnable(); Text textNode = getTextNode(); Point2D tp = textNode.localToScene(0, 0); - Point2D p = new Point2D(e.getSceneX() - tp.getX() + 10/*??*/ - pressX + selectionHandle2.getWidth() / 2, + Point2D p = new Point2D(e.getSceneX() - tp.getX() - pressX + selectionHandle2.getWidth() / 2, e.getSceneY() - tp.getY() - pressY - 6); - HitInfo hit = textNode.impl_hitTestChar(translateCaretPosition(p)); - int pos = hit.getCharIndex(); + HitInfo hit = textNode.hitTest(translateCaretPosition(p)); if (control1.getAnchor() > control1.getCaretPosition()) { // Swap caret and anchor control1.selectRange(control1.getCaretPosition(), control1.getAnchor()); } + int pos = hit.getCharIndex(); if (pos > 0) { if (pos <= control1.getAnchor() + 1) { pos = Math.min(control1.getAnchor() + 2, control1.getLength()); } - int oldPos = textNode.getImpl_caretPosition(); - textNode.setImpl_caretPosition(pos); - PathElement element = textNode.getImpl_caretShape()[0]; - if (element instanceof MoveTo && ((MoveTo)element).getY() > e.getY() - getTextTranslateY()) { - hit.setCharIndex(pos - 1); - } - textNode.setImpl_caretPosition(oldPos); positionCaret(hit, true); } e.consume(); @@ -509,25 +485,15 @@ * * @param x the x coordinate of the point. * @param y the y coordinate of the point. - * @return a {@code TextPosInfo} object describing the index and forward bias. + * @return a {@code HitInfo} object describing the index and forward bias. */ - public TextPosInfo getIndex(double x, double y) { + public HitInfo getIndex(double x, double y) { // adjust the event to be in the same coordinate space as the // text content of the textInputControl Text textNode = getTextNode(); Point2D p = new Point2D(x - textNode.getLayoutX(), y - getTextTranslateY()); - HitInfo hit = textNode.impl_hitTestChar(translateCaretPosition(p)); - int pos = hit.getCharIndex(); - if (pos > 0) { - int oldPos = textNode.getImpl_caretPosition(); - textNode.setImpl_caretPosition(pos); - PathElement element = textNode.getImpl_caretShape()[0]; - if (element instanceof MoveTo && ((MoveTo)element).getY() > y - getTextTranslateY()) { - hit.setCharIndex(pos - 1); - } - textNode.setImpl_caretPosition(oldPos); - } - return new TextPosInfo(hit); + HitInfo hit = textNode.hitTest(translateCaretPosition(p)); + return hit; }; /** {@inheritDoc} */ @@ -617,12 +583,13 @@ } double hitX = moveRight ? caretBounds.getMaxX() : caretBounds.getMinX(); double hitY = (caretBounds.getMinY() + caretBounds.getMaxY()) / 2; - HitInfo hit = textNode.impl_hitTestChar(new Point2D(hitX, hitY)); - Path charShape = new Path(textNode.impl_getRangeShape(hit.getCharIndex(), hit.getCharIndex() + 1)); + HitInfo hit = textNode.hitTest(new Point2D(hitX, hitY)); + boolean leading = hit.isLeading(); + Path charShape = new Path(textNode.rangeShape(hit.getCharIndex(), hit.getCharIndex() + 1)); if ((moveRight && charShape.getLayoutBounds().getMaxX() > caretBounds.getMaxX()) || (!moveRight && charShape.getLayoutBounds().getMinX() < caretBounds.getMinX())) { - hit.setLeading(!hit.isLeading()); - positionCaret(hit, false); + leading = !leading; + positionCaret(hit.getInsertionIndex(), leading, false, false); } else { // We're at beginning or end of line. Try moving up / down. int dot = textArea.getCaretPosition(); @@ -655,35 +622,23 @@ double x = (targetCaretX >= 0) ? targetCaretX : (caretBounds.getMaxX()); // Find a text position for the target x,y. - HitInfo hit = textNode.impl_hitTestChar(translateCaretPosition(new Point2D(x, targetLineMidY))); + HitInfo hit = textNode.hitTest(translateCaretPosition(new Point2D(x, targetLineMidY))); int pos = hit.getCharIndex(); // Save the old pos temporarily while testing the new one. - int oldPos = textNode.getImpl_caretPosition(); - boolean oldBias = textNode.isImpl_caretBias(); - textNode.setImpl_caretBias(hit.isLeading()); - textNode.setImpl_caretPosition(pos); + int oldPos = textNode.getCaretPosition(); + boolean oldBias = textNode.isCaretBias(); + textNode.setCaretBias(hit.isLeading()); + textNode.setCaretPosition(pos); tmpCaretPath.getElements().clear(); - tmpCaretPath.getElements().addAll(textNode.getImpl_caretShape()); + tmpCaretPath.getElements().addAll(textNode.getCaretShape()); tmpCaretPath.setLayoutX(textNode.getLayoutX()); tmpCaretPath.setLayoutY(textNode.getLayoutY()); Bounds tmpCaretBounds = tmpCaretPath.getLayoutBounds(); // The y for the middle of the row we found. double foundLineMidY = (tmpCaretBounds.getMinY() + tmpCaretBounds.getMaxY()) / 2; - textNode.setImpl_caretBias(oldBias); - textNode.setImpl_caretPosition(oldPos); - - if (pos > 0) { - if (nLines > 0 && foundLineMidY > targetLineMidY) { - // We went too far and ended up after a newline. - hit.setCharIndex(pos - 1); - } - - if (pos >= textArea.getLength() && getCharacter(pos - 1) == '\n') { - // Special case for newline at end of text. - hit.setLeading(true); - } - } + textNode.setCaretBias(oldBias); + textNode.setCaretPosition(oldPos); // Test if the found line is in the correct direction and move // the caret. @@ -691,7 +646,7 @@ (nLines > 0 && foundLineMidY > caretBounds.getMaxY()) || (nLines < 0 && foundLineMidY < caretBounds.getMinY())) { - positionCaret(hit, select, extendSelection); + positionCaret(hit.getInsertionIndex(), hit.isLeading(), select, extendSelection); targetCaretX = x; } } @@ -792,7 +747,7 @@ Text p = (Text)node; int pEnd = pStart + p.textProperty().getValueSafe().length(); if (pEnd >= start) { - return p.impl_getUnderlineShape(start - pStart, end - pStart); + return p.underlineShape(start - pStart, end - pStart); } pStart = pEnd + 1; } @@ -806,7 +761,7 @@ Text p = (Text)node; int pEnd = pStart + p.textProperty().getValueSafe().length(); if (pEnd >= start) { - return p.impl_getRangeShape(start - pStart, end - pStart); + return p.rangeShape(start - pStart, end - pStart); } pStart = pEnd + 1; } @@ -966,20 +921,19 @@ * @param hit the new position and forward bias of the caret. * @param select whether to extend selection to the new position. */ - public void positionCaret(TextPosInfo hit, boolean select) { - positionCaret(hit, select, false); + public void positionCaret(HitInfo hit, boolean select) { + positionCaret(hit.getInsertionIndex(), hit.isLeading(), select, false); } - private void positionCaret(TextPosInfo hit, boolean select, boolean extendSelection) { - int pos = Utils.getHitInsertionIndex(hit, getSkinnable().getText()); + private void positionCaret(int pos, boolean leading, boolean select, boolean extendSelection) { boolean isNewLine = (pos > 0 && pos <= getSkinnable().getLength() && getSkinnable().getText().codePointAt(pos-1) == 0x0a); // special handling for a new line - if (!hit.isLeading() && isNewLine) { - hit.setLeading(true); + if (!leading && isNewLine) { + leading = true; pos -= 1; } @@ -993,15 +947,7 @@ getSkinnable().positionCaret(pos); } - setForwardBias(hit.isLeading()); - } - - private void positionCaret(HitInfo hit, boolean select) { - positionCaret(new TextPosInfo(hit), select); - } - - private void positionCaret(HitInfo hit, boolean select, boolean extendSelection) { - positionCaret(new TextPosInfo(hit), select, extendSelection); + setForwardBias(leading); } /** {@inheritDoc} */ @@ -1026,7 +972,7 @@ } characterBoundingPath.getElements().clear(); - characterBoundingPath.getElements().addAll(paragraphNode.impl_getRangeShape(characterIndex, characterIndex + 1)); + characterBoundingPath.getElements().addAll(paragraphNode.rangeShape(characterIndex, characterIndex + 1)); characterBoundingPath.setLayoutX(paragraphNode.getLayoutX()); characterBoundingPath.setLayoutY(paragraphNode.getLayoutY()); @@ -1101,7 +1047,7 @@ paragraphNode.fontProperty().bind(textArea.fontProperty()); paragraphNode.fillProperty().bind(textFillProperty()); - paragraphNode.impl_selectionFillProperty().bind(highlightTextFillProperty()); + paragraphNode.selectionFillProperty().bind(highlightTextFillProperty()); } private double getScrollTopMax() { @@ -1113,8 +1059,8 @@ } private int getInsertionPoint(Text paragraphNode, double x, double y) { - TextPosInfo hitInfo = new TextPosInfo(paragraphNode.impl_hitTestChar(new Point2D(x, y))); - return Utils.getHitInsertionIndex(hitInfo, paragraphNode.getText()); + HitInfo hitInfo = paragraphNode.hitTest(new Point2D(x, y)); + return hitInfo.getInsertionIndex(); } private int getNextInsertionPoint(Text paragraphNode, double x, int from, @@ -1231,11 +1177,11 @@ private void updateTextNodeCaretPos(int pos) { Text textNode = getTextNode(); if (isForwardBias()) { - textNode.setImpl_caretPosition(pos); + textNode.setCaretPosition(pos); } else { - textNode.setImpl_caretPosition(pos - 1); + textNode.setCaretPosition(pos - 1); } - textNode.impl_caretBiasProperty().set(isForwardBias()); + textNode.caretBiasProperty().set(isForwardBias()); } @@ -1408,7 +1354,7 @@ updateTextNodeCaretPos(anchorPos - paragraphOffset); caretPath.getElements().clear(); - caretPath.getElements().addAll(paragraphNode.getImpl_caretShape()); + caretPath.getElements().addAll(paragraphNode.getCaretShape()); caretPath.setLayoutX(paragraphNode.getLayoutX()); caretPath.setLayoutY(paragraphNode.getLayoutY()); @@ -1437,7 +1383,7 @@ updateTextNodeCaretPos(caretPos - paragraphOffset); caretPath.getElements().clear(); - caretPath.getElements().addAll(paragraphNode.getImpl_caretShape()); + caretPath.getElements().addAll(paragraphNode.getCaretShape()); caretPath.setLayoutX(paragraphNode.getLayoutX()); @@ -1458,13 +1404,13 @@ Text textNode = (Text)paragraphNode; int paragraphLength = textNode.getText().length() + 1; if (end > start && start < paragraphLength) { - textNode.setImpl_selectionStart(start); - textNode.setImpl_selectionEnd(Math.min(end, paragraphLength)); + textNode.setSelectionStart(start); + textNode.setSelectionEnd(Math.min(end, paragraphLength)); Path selectionHighlightPath = new Path(); selectionHighlightPath.setManaged(false); selectionHighlightPath.setStroke(null); - PathElement[] selectionShape = textNode.getImpl_selectionShape(); + PathElement[] selectionShape = textNode.getSelectionShape(); if (selectionShape != null) { selectionHighlightPath.getElements().addAll(selectionShape); } @@ -1474,8 +1420,8 @@ selectionHighlightPath.setLayoutY(textNode.getLayoutY()); updateHighlightFill(); } else { - textNode.setImpl_selectionStart(-1); - textNode.setImpl_selectionEnd(-1); + textNode.setSelectionStart(-1); + textNode.setSelectionEnd(-1); selectionHighlightGroup.setVisible(false); } start = Math.max(0, start - paragraphLength); diff --git a/modules/controls/src/main/java/javafx/scene/control/skin/TextFieldSkin.java b/modules/controls/src/main/java/javafx/scene/control/skin/TextFieldSkin.java --- a/modules/controls/src/main/java/javafx/scene/control/skin/TextFieldSkin.java +++ b/modules/controls/src/main/java/javafx/scene/control/skin/TextFieldSkin.java @@ -1,5 +1,5 @@ /* - * 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 @@ -28,7 +28,6 @@ import com.sun.javafx.scene.control.behavior.BehaviorBase; import com.sun.javafx.scene.control.behavior.TextAreaBehavior; import com.sun.javafx.scene.control.behavior.TextInputControlBehavior; -import com.sun.javafx.scene.control.skin.Utils; import javafx.beans.binding.BooleanBinding; import javafx.beans.binding.DoubleBinding; import javafx.beans.binding.ObjectBinding; @@ -59,10 +58,10 @@ import javafx.scene.shape.PathElement; import javafx.scene.shape.Rectangle; import javafx.scene.text.Text; +import javafx.scene.text.HitInfo; import java.util.List; import com.sun.javafx.scene.control.behavior.TextFieldBehavior; import com.sun.javafx.scene.control.behavior.PasswordFieldBehavior; -import com.sun.javafx.scene.text.HitInfo; /** * Default skin implementation for the {@link TextField} control. @@ -212,7 +211,7 @@ } }); textNode.fillProperty().bind(textFillProperty()); - textNode.impl_selectionFillProperty().bind(new ObjectBinding() { + textNode.selectionFillProperty().bind(new ObjectBinding() { { bind(highlightTextFillProperty(), textFillProperty(), control.focusedProperty()); } @Override protected Paint computeValue() { return control.isFocused() ? highlightTextFillProperty().get() : textFillProperty().get(); @@ -230,7 +229,7 @@ selectionHighlightPath.layoutXProperty().bind(textTranslateX); selectionHighlightPath.visibleProperty().bind(control.anchorProperty().isNotEqualTo(control.caretPositionProperty()).and(control.focusedProperty())); selectionHighlightPath.fillProperty().bind(highlightFillProperty()); - textNode.impl_selectionShapeProperty().addListener(observable -> { + textNode.selectionShapeProperty().addListener(observable -> { updateSelection(); }); @@ -249,8 +248,8 @@ } }); caretPath.layoutXProperty().bind(textTranslateX); - textNode.impl_caretShapeProperty().addListener(observable -> { - caretPath.getElements().setAll(textNode.impl_caretShapeProperty().get()); + textNode.caretShapeProperty().addListener(observable -> { + caretPath.getElements().setAll(textNode.caretShapeProperty().get()); if (caretPath.getElements().size() == 0) { // The caret pos is invalid. updateTextNodeCaretPos(control.getCaretPosition()); @@ -331,7 +330,7 @@ caretHandle.setOnMouseDragged(e -> { Point2D p = new Point2D(caretHandle.getLayoutX() + e.getX() + pressX - textNode.getLayoutX(), caretHandle.getLayoutY() + e.getY() - pressY - 6); - HitInfo hit = textNode.impl_hitTestChar(p); + HitInfo hit = textNode.hitTest(p); positionCaret(hit, false); e.consume(); }); @@ -342,17 +341,17 @@ Point2D tp = textNode.localToScene(0, 0); Point2D p = new Point2D(e.getSceneX() - tp.getX() + 10/*??*/ - pressX + selectionHandle1.getWidth() / 2, e.getSceneY() - tp.getY() - pressY - 6); - HitInfo hit = textNode.impl_hitTestChar(p); - int pos = hit.getCharIndex(); + HitInfo hit = textNode.hitTest(p); if (control.getAnchor() < control.getCaretPosition()) { // Swap caret and anchor control.selectRange(control.getCaretPosition(), control.getAnchor()); } + int pos = hit.getInsertionIndex(); if (pos >= 0) { if (pos >= control.getAnchor() - 1) { - hit.setCharIndex(Math.max(0, control.getAnchor() - 1)); + pos = Math.max(0, control.getAnchor() - 1); } - positionCaret(hit, true); + positionCaret(pos, hit.isLeading(), true); } e.consume(); } @@ -364,17 +363,17 @@ Point2D tp = textNode.localToScene(0, 0); Point2D p = new Point2D(e.getSceneX() - tp.getX() + 10/*??*/ - pressX + selectionHandle2.getWidth() / 2, e.getSceneY() - tp.getY() - pressY - 6); - HitInfo hit = textNode.impl_hitTestChar(p); - int pos = hit.getCharIndex(); + HitInfo hit = textNode.hitTest(p); if (control.getAnchor() > control.getCaretPosition()) { // Swap caret and anchor control.selectRange(control.getCaretPosition(), control.getAnchor()); } + int pos = hit.getInsertionIndex(); if (pos > 0) { if (pos <= control.getAnchor()) { - hit.setCharIndex(Math.min(control.getAnchor() + 1, control.getLength())); + pos = Math.min(control.getAnchor() + 1, control.getLength()); } - positionCaret(hit, true); + positionCaret(pos, hit.isLeading(), true); } e.consume(); } @@ -478,14 +477,14 @@ * * @param x the x coordinate of the point. * @param y the y coordinate of the point. - * @return a {@code TextPosInfo} object describing the index and forward bias. + * @return a {@code HitInfo} object describing the index and forward bias. */ - public TextPosInfo getIndex(double x, double y) { + public HitInfo getIndex(double x, double y) { // adjust the event to be in the same coordinate space as the // text content of the textInputControl Point2D p = new Point2D(x - textTranslateX.get() - snappedLeftInset(), y - snappedTopInset()); - return new TextPosInfo(textNode.impl_hitTestChar(p)); + return textNode.hitTest(p); } // Public for behavior @@ -495,21 +494,18 @@ * @param hit the new position and forward bias of the caret. * @param select whether to extend selection to the new position. */ - public void positionCaret(TextPosInfo hit, boolean select) { + public void positionCaret(HitInfo hit, boolean select) { + positionCaret(hit.getInsertionIndex(), hit.isLeading(), select); + } + + private void positionCaret(int pos, boolean leading, boolean select) { TextField textField = getSkinnable(); - int pos = Utils.getHitInsertionIndex(hit, textField.textProperty().getValueSafe()); - if (select) { textField.selectPositionCaret(pos); } else { textField.positionCaret(pos); } - - setForwardBias(hit.isLeading()); - } - - private void positionCaret(HitInfo hit, boolean select) { - positionCaret(new TextPosInfo(hit), select); + setForwardBias(leading); } /** {@inheritDoc} */ @@ -524,7 +520,7 @@ height = textNodeBounds.getMaxY(); } else { characterBoundingPath.getElements().clear(); - characterBoundingPath.getElements().addAll(textNode.impl_getRangeShape(index, index + 1)); + characterBoundingPath.getElements().addAll(textNode.rangeShape(index, index + 1)); characterBoundingPath.setLayoutX(textNode.getLayoutX()); characterBoundingPath.setLayoutY(textNode.getLayoutY()); @@ -545,12 +541,12 @@ /** {@inheritDoc} */ @Override protected PathElement[] getUnderlineShape(int start, int end) { - return textNode.impl_getUnderlineShape(start, end); + return textNode.underlineShape(start, end); } /** {@inheritDoc} */ @Override protected PathElement[] getRangeShape(int start, int end) { - return textNode.impl_getRangeShape(start, end); + return textNode.rangeShape(start, end); } /** {@inheritDoc} */ @@ -597,13 +593,14 @@ } double hitX = moveRight ? caretBounds.getMaxX() : caretBounds.getMinX(); double hitY = (caretBounds.getMinY() + caretBounds.getMaxY()) / 2; - HitInfo hit = textNode.impl_hitTestChar(new Point2D(hitX, hitY)); - Path charShape = new Path(textNode.impl_getRangeShape(hit.getCharIndex(), hit.getCharIndex() + 1)); + HitInfo hit = textNode.hitTest(new Point2D(hitX, hitY)); + boolean leading = hit.isLeading(); + Path charShape = new Path(textNode.rangeShape(hit.getCharIndex(), hit.getCharIndex() + 1)); if ((moveRight && charShape.getLayoutBounds().getMaxX() > caretBounds.getMaxX()) || (!moveRight && charShape.getLayoutBounds().getMinX() < caretBounds.getMinX())) { - hit.setLeading(!hit.isLeading()); + leading = !leading; } - positionCaret(hit, false); + positionCaret(hit.getInsertionIndex(), leading, false); } /** {@inheritDoc} */ @@ -716,11 +713,11 @@ private void updateTextNodeCaretPos(int pos) { if (pos == 0 || isForwardBias()) { - textNode.setImpl_caretPosition(pos); + textNode.setCaretPosition(pos); } else { - textNode.setImpl_caretPosition(pos - 1); + textNode.setCaretPosition(pos - 1); } - textNode.impl_caretBiasProperty().set(isForwardBias()); + textNode.caretBiasProperty().set(isForwardBias()); } private void createPromptNode() { @@ -743,16 +740,16 @@ IndexRange newValue = textField.getSelection(); if (newValue == null || newValue.getLength() == 0) { - textNode.impl_selectionStartProperty().set(-1); - textNode.impl_selectionEndProperty().set(-1); + textNode.selectionStartProperty().set(-1); + textNode.selectionEndProperty().set(-1); } else { - textNode.impl_selectionStartProperty().set(newValue.getStart()); + textNode.selectionStartProperty().set(newValue.getStart()); // This intermediate value is needed to force selection shape layout. - textNode.impl_selectionEndProperty().set(newValue.getStart()); - textNode.impl_selectionEndProperty().set(newValue.getEnd()); + textNode.selectionEndProperty().set(newValue.getStart()); + textNode.selectionEndProperty().set(newValue.getEnd()); } - PathElement[] elements = textNode.impl_selectionShapeProperty().get(); + PathElement[] elements = textNode.selectionShapeProperty().get(); if (elements == null) { selectionHighlightPath.getElements().clear(); } else { diff --git a/modules/controls/src/main/java/javafx/scene/control/skin/TextInputControlSkin.java b/modules/controls/src/main/java/javafx/scene/control/skin/TextInputControlSkin.java --- a/modules/controls/src/main/java/javafx/scene/control/skin/TextInputControlSkin.java +++ b/modules/controls/src/main/java/javafx/scene/control/skin/TextInputControlSkin.java @@ -1,5 +1,5 @@ /* - * 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 @@ -69,6 +69,7 @@ import javafx.scene.shape.PathElement; import javafx.scene.shape.Shape; import javafx.scene.shape.VLineTo; +import javafx.scene.text.HitInfo; import javafx.stage.Window; import javafx.util.Duration; import java.lang.ref.WeakReference; @@ -79,7 +80,6 @@ import javafx.css.converter.BooleanConverter; import javafx.css.converter.PaintConverter; import com.sun.javafx.scene.control.behavior.TextInputControlBehavior; -import com.sun.javafx.scene.text.HitInfo; import com.sun.javafx.tk.FontMetrics; import com.sun.javafx.tk.Toolkit; import static com.sun.javafx.PlatformUtil.isWindows; @@ -986,51 +986,4 @@ default: super.executeAccessibleAction(action, parameters); } } - - /** - * This class represents the hit information for a Text node. - */ - public static class TextPosInfo { - - TextPosInfo(HitInfo hit) { - this(hit.getCharIndex(), hit.isLeading()); - } - - /** - * Create a TextPosInfo object representing a text index and forward bias. - * - * @param charIndex the character index. - * @param leading whether the hit is on the leading edge of the character. If it is false, it represents the trailing edge. - */ - public TextPosInfo(int charIndex, boolean leading) { - setCharIndex(charIndex); - setLeading(leading); - } - - /** - * The index of the character which this hit information refers to. - */ - private int charIndex; - public int getCharIndex() { return charIndex; } - void setCharIndex(int charIndex) { this.charIndex = charIndex; } - - /** - * Indicates whether the hit is on the leading edge of the character. - * If it is false, it represents the trailing edge. - */ - private boolean leading; - public boolean isLeading() { return leading; } - void setLeading(boolean leading) { this.leading = leading; } - - /** - * Returns the index of the insertion position. - */ - public int getInsertionIndex() { - return leading ? charIndex : charIndex + 1; - } - - @Override public String toString() { - return "charIndex: " + charIndex + ", isLeading: " + leading; - } - } } diff --git a/modules/graphics/src/main/java/com/sun/javafx/scene/text/TextLayout.java b/modules/graphics/src/main/java/com/sun/javafx/scene/text/TextLayout.java --- a/modules/graphics/src/main/java/com/sun/javafx/scene/text/TextLayout.java +++ b/modules/graphics/src/main/java/com/sun/javafx/scene/text/TextLayout.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -75,6 +75,22 @@ public static final int TYPE_TOP = 1 << 4; public static final int TYPE_BEARINGS = 1 << 5; + public static class Hit { + int charIndex; + int insertionIndex; + boolean leading; + + public Hit(int charIndex, int insertionIndex, boolean leading) { + this.charIndex = charIndex; + this.insertionIndex = insertionIndex; + this.leading = leading; + } + + public int getCharIndex() { return charIndex; } + public int getInsertionIndex() { return insertionIndex; } + public boolean isLeading() { return leading; } + } + /** * Sets the content for the TextLayout. Supports multiple spans (rich text). * @@ -172,7 +188,8 @@ */ public Shape getShape(int type, TextSpan filter); - public HitInfo getHitInfo(float x, float y); + public Hit getHitInfo(float x, float y); + public PathElement[] getCaretShape(int offset, boolean isLeading, float x, float y); public PathElement[] getRange(int start, int end, int type, diff --git a/modules/graphics/src/main/java/com/sun/javafx/text/PrismTextLayout.java b/modules/graphics/src/main/java/com/sun/javafx/text/PrismTextLayout.java --- a/modules/graphics/src/main/java/com/sun/javafx/text/PrismTextLayout.java +++ b/modules/graphics/src/main/java/com/sun/javafx/text/PrismTextLayout.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -44,7 +44,6 @@ import com.sun.javafx.geom.transform.BaseTransform; import com.sun.javafx.geom.transform.Translate2D; import com.sun.javafx.scene.text.GlyphList; -import com.sun.javafx.scene.text.HitInfo; import com.sun.javafx.scene.text.TextLayout; import com.sun.javafx.scene.text.TextSpan; import java.text.Bidi; @@ -407,12 +406,14 @@ return result; } - public HitInfo getHitInfo(float x, float y) { + public Hit getHitInfo(float x, float y) { + int charIndex = -1; + boolean leading = false; + ensureLayout(); - HitInfo info = new HitInfo(); int lineIndex = getLineIndex(y); if (lineIndex >= getLineCount()) { - info.setCharIndex(getCharCount()); + charIndex = getCharCount(); } else { if (isMirrored()) { x = getMirroringWidth() - x; @@ -433,15 +434,15 @@ } if (run != null) { int[] trailing = new int[1]; - info.setCharIndex(run.getStart() + run.getOffsetAtX(x, trailing)); - info.setLeading(trailing[0] == 0); + charIndex = run.getStart() + run.getOffsetAtX(x, trailing); + leading = (trailing[0] == 0); } else { //empty line, set to line break leading - info.setCharIndex(line.getStart()); - info.setLeading(true); + charIndex = line.getStart(); + leading = true; } } - return info; + return new Hit(charIndex, -1, leading); } public PathElement[] getRange(int start, int end, int type, diff --git a/modules/graphics/src/main/java/com/sun/javafx/tk/DummyToolkit.java b/modules/graphics/src/main/java/com/sun/javafx/tk/DummyToolkit.java --- a/modules/graphics/src/main/java/com/sun/javafx/tk/DummyToolkit.java +++ b/modules/graphics/src/main/java/com/sun/javafx/tk/DummyToolkit.java @@ -1,5 +1,5 @@ /* - * 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 @@ -61,7 +61,6 @@ import com.sun.javafx.perf.PerformanceTracker; import com.sun.javafx.runtime.async.AsyncOperation; import com.sun.javafx.runtime.async.AsyncOperationListener; -import com.sun.javafx.scene.text.HitInfo; import com.sun.javafx.scene.text.TextLayoutFactory; import com.sun.scenario.DelayedRunnable; import com.sun.scenario.animation.AbstractMasterTimer; @@ -252,11 +251,6 @@ } @Override - public HitInfo convertHitInfoToFX(Object hit) { - throw new UnsupportedOperationException("Not supported yet."); - } - - @Override public Filterable toFilterable(Image img) { throw new UnsupportedOperationException("Not supported yet."); } diff --git a/modules/graphics/src/main/java/com/sun/javafx/tk/Toolkit.java b/modules/graphics/src/main/java/com/sun/javafx/tk/Toolkit.java --- a/modules/graphics/src/main/java/com/sun/javafx/tk/Toolkit.java +++ b/modules/graphics/src/main/java/com/sun/javafx/tk/Toolkit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -83,7 +83,6 @@ import com.sun.javafx.runtime.async.AsyncOperation; import com.sun.javafx.runtime.async.AsyncOperationListener; import com.sun.javafx.scene.SceneHelper; -import com.sun.javafx.scene.text.HitInfo; import com.sun.javafx.scene.text.TextLayoutFactory; import com.sun.javafx.sg.prism.NGCamera; import com.sun.javafx.sg.prism.NGLightBase; @@ -660,7 +659,6 @@ public abstract Dimension2D getBestCursorSize(int preferredWidth, int preferredHeight); public abstract int getMaximumCursorColors(); public abstract PathElement[] convertShapeToFXPath(Object shape); - public abstract HitInfo convertHitInfoToFX(Object hit); public abstract Filterable toFilterable(Image img); public abstract FilterContext getFilterContext(Object config); diff --git a/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/QuantumToolkit.java b/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/QuantumToolkit.java --- a/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/QuantumToolkit.java +++ b/modules/graphics/src/main/java/com/sun/javafx/tk/quantum/QuantumToolkit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -92,7 +92,6 @@ import com.sun.javafx.perf.PerformanceTracker; import com.sun.javafx.runtime.async.AbstractRemoteResource; import com.sun.javafx.runtime.async.AsyncOperationListener; -import com.sun.javafx.scene.text.HitInfo; import com.sun.javafx.scene.text.TextLayoutFactory; import com.sun.javafx.sg.prism.NGNode; import com.sun.javafx.tk.AppletWindow; @@ -1047,14 +1046,6 @@ return elements.toArray(new PathElement[elements.size()]); } - @Override public HitInfo convertHitInfoToFX(Object hit) { - Integer textHitPos = (Integer) hit; - HitInfo hitInfo = new HitInfo(); - hitInfo.setCharIndex(textHitPos); - hitInfo.setLeading(true); - return hitInfo; - } - @Override public Filterable toFilterable(Image img) { return PrImage.create((com.sun.prism.Image) img.impl_getPlatformImage()); } diff --git a/modules/graphics/src/main/java/com/sun/javafx/scene/text/HitInfo.java b/modules/graphics/src/main/java/javafx/scene/text/HitInfo.java rename from modules/graphics/src/main/java/com/sun/javafx/scene/text/HitInfo.java rename to modules/graphics/src/main/java/javafx/scene/text/HitInfo.java --- a/modules/graphics/src/main/java/com/sun/javafx/scene/text/HitInfo.java +++ b/modules/graphics/src/main/java/javafx/scene/text/HitInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -23,36 +23,77 @@ * questions. */ -package com.sun.javafx.scene.text; +package javafx.scene.text; + +import java.text.BreakIterator; + +import com.sun.javafx.scene.text.TextLayout; /** * Represents the hit information in a Text node. + * + * @since 9 */ public class HitInfo { + private int charIndex; + private boolean leading; + private int insertionIndex; + private String text; + + /** + * Create a HitInfo object representing a text index and forward bias. + * + * @param charIndex the character index. + * @param leading whether the hit is on the leading edge of the character. If it is false, it represents the trailing edge. + */ + HitInfo(int charIndex, int insertionIndex, boolean leading, String text) { + this.charIndex = charIndex; + this.leading = leading; + this.insertionIndex = insertionIndex; + this.text = text; + } + /** * The index of the character which this hit information refers to. */ - private int charIndex; public int getCharIndex() { return charIndex; } - public void setCharIndex(int charIndex) { this.charIndex = charIndex; } /** * Indicates whether the hit is on the leading edge of the character. * If it is false, it represents the trailing edge. */ - private boolean leading; public boolean isLeading() { return leading; } - public void setLeading(boolean leading) { this.leading = leading; } + private static BreakIterator charIterator = null; /** * Returns the index of the insertion position. */ public int getInsertionIndex() { - return leading ? charIndex : charIndex + 1; + if (insertionIndex == -1) { + insertionIndex = charIndex; + if (!leading) { + if (text != null) { + // Skip complex character clusters / ligatures. + if (charIterator == null) { + charIterator = BreakIterator.getCharacterInstance(); + } + charIterator.setText(text); + int next = charIterator.following(insertionIndex); + if (next == BreakIterator.DONE) { + insertionIndex += 1; + } else { + insertionIndex = next; + } + } else { + insertionIndex += 1; + } + } + } + return insertionIndex; } @Override public String toString() { - return "charIndex: " + charIndex + ", isLeading: " + leading; + return "charIndex: " + charIndex + ", isLeading: " + leading + ", insertionIndex: " + getInsertionIndex(); } } diff --git a/modules/graphics/src/main/java/javafx/scene/text/Text.java b/modules/graphics/src/main/java/javafx/scene/text/Text.java --- a/modules/graphics/src/main/java/javafx/scene/text/Text.java +++ b/modules/graphics/src/main/java/javafx/scene/text/Text.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -34,7 +34,11 @@ import com.sun.javafx.geom.TransformedShape; import com.sun.javafx.geom.transform.BaseTransform; import com.sun.javafx.scene.DirtyBits; -import com.sun.javafx.scene.text.*; +import com.sun.javafx.scene.text.GlyphList; +import com.sun.javafx.scene.text.TextLayout; +import com.sun.javafx.scene.text.TextLayoutFactory; +import com.sun.javafx.scene.text.TextLine; +import com.sun.javafx.scene.text.TextSpan; import com.sun.javafx.sg.prism.NGNode; import com.sun.javafx.sg.prism.NGShape; import com.sun.javafx.sg.prism.NGText; @@ -387,10 +391,10 @@ @Override public String getName() { return "text"; } @Override public void invalidated() { needsFullTextLayout(); - setImpl_selectionStart(-1); - setImpl_selectionEnd(-1); - setImpl_caretPosition(-1); - setImpl_caretBias(true); + setSelectionStart(-1); + setSelectionEnd(-1); + setCaretPosition(-1); + setCaretBias(true); // MH: Functionality copied from store() method, // which was removed. @@ -776,232 +780,159 @@ } /** - * @treatAsPrivate implementation detail - * @deprecated This is an internal API that is not intended - * for use and will be removed in the next version + * Shape of selection in local coordinates. + * + * @since 9 */ - @Deprecated - public final PathElement[] getImpl_selectionShape() { - return impl_selectionShapeProperty().get(); + public final PathElement[] getSelectionShape() { + return selectionShapeProperty().get(); } - /** - * Shape of selection in local coordinates. - * - * @treatAsPrivate implementation detail - * @deprecated This is an internal API that is not intended - * for use and will be removed in the next version - */ - @Deprecated - public final ReadOnlyObjectProperty impl_selectionShapeProperty() { + public final ReadOnlyObjectProperty selectionShapeProperty() { return getTextAttribute().impl_selectionShapeProperty(); } /** - * @treatAsPrivate implementation detail - * @deprecated This is an internal API that is not intended - * for use and will be removed in the next version + * Selection start index in the content. + * set to {@code -1} to unset selection. + * + * @since 9 */ - @Deprecated - public final void setImpl_selectionStart(int value) { + public final void setSelectionStart(int value) { if (value == -1 && (attributes == null || attributes.impl_selectionStart == null)) { return; } - impl_selectionStartProperty().set(value); + selectionStartProperty().set(value); } - /** - * @treatAsPrivate implementation detail - * @deprecated This is an internal API that is not intended - * for use and will be removed in the next version - */ - @Deprecated - public final int getImpl_selectionStart() { + public final int getSelectionStart() { if (attributes == null || attributes.impl_selectionStart == null) { return DEFAULT_SELECTION_START; } return attributes.getImpl_selectionStart(); } - /** - * Selection start index in the content. - * set to {@code -1} to unset selection. - * - * @treatAsPrivate implementation detail - * @deprecated This is an internal API that is not intended - * for use and will be removed in the next version - */ - @Deprecated - public final IntegerProperty impl_selectionStartProperty() { + public final IntegerProperty selectionStartProperty() { return getTextAttribute().impl_selectionStartProperty(); } /** - * @treatAsPrivate implementation detail - * @deprecated This is an internal API that is not intended - * for use and will be removed in the next version + * Selection end index in the content. + * set to {@code -1} to unset selection. + * + * @since 9 */ - @Deprecated - public final void setImpl_selectionEnd(int value) { + public final void setSelectionEnd(int value) { if (value == -1 && (attributes == null || attributes.impl_selectionEnd == null)) { return; } - impl_selectionEndProperty().set(value); + selectionEndProperty().set(value); } - /** - * @treatAsPrivate implementation detail - * @deprecated This is an internal API that is not intended - * for use and will be removed in the next version - */ - @Deprecated - public final int getImpl_selectionEnd() { + public final int getSelectionEnd() { if (attributes == null || attributes.impl_selectionEnd == null) { return DEFAULT_SELECTION_END; } return attributes.getImpl_selectionEnd(); } - /** - * Selection end index in the content. - * set to {@code -1} to unset selection. - * - * @treatAsPrivate implementation detail - * @deprecated This is an internal API that is not intended - * for use and will be removed in the next version - */ - @Deprecated - public final IntegerProperty impl_selectionEndProperty() { + public final IntegerProperty selectionEndProperty() { return getTextAttribute().impl_selectionEndProperty(); } /** - * @treatAsPrivate implementation detail - * @deprecated This is an internal API that is not intended - * for use and will be removed in the next version + * The fill color of selected text. + * + * @since 9 */ - @Deprecated - public final ObjectProperty impl_selectionFillProperty() { + public final ObjectProperty selectionFillProperty() { return getTextAttribute().impl_selectionFillProperty(); } - /** - * @treatAsPrivate implementation detail - * @deprecated This is an internal API that is not intended - * for use and will be removed in the next version - */ - @Deprecated - public final PathElement[] getImpl_caretShape() { - return impl_caretShapeProperty().get(); + public final void setSelectionFill(Paint paint) { + selectionFillProperty().set(paint); + } + public final Paint getSelectionFill() { + return selectionFillProperty().get(); } /** * Shape of caret in local coordinates. * - * @treatAsPrivate implementation detail - * @deprecated This is an internal API that is not intended - * for use and will be removed in the next version - */ - @Deprecated - public final ReadOnlyObjectProperty impl_caretShapeProperty() { + * @since 9 + */ + public final PathElement[] getCaretShape() { + return caretShapeProperty().get(); + } + + public final ReadOnlyObjectProperty caretShapeProperty() { return getTextAttribute().impl_caretShapeProperty(); } /** - * @treatAsPrivate implementation detail - * @deprecated This is an internal API that is not intended - * for use and will be removed in the next version + * caret index in the content. + * set to {@code -1} to unset caret. + * + * @since 9 */ - @Deprecated - public final void setImpl_caretPosition(int value) { + public final void setCaretPosition(int value) { if (value == -1 && (attributes == null || attributes.impl_caretPosition == null)) { return; } - impl_caretPositionProperty().set(value); + caretPositionProperty().set(value); } - /** - * @treatAsPrivate implementation detail - * @deprecated This is an internal API that is not intended - * for use and will be removed in the next version - */ - @Deprecated - public final int getImpl_caretPosition() { + public final int getCaretPosition() { if (attributes == null || attributes.impl_caretPosition == null) { return DEFAULT_CARET_POSITION; } return attributes.getImpl_caretPosition(); } - /** - * caret index in the content. - * set to {@code -1} to unset caret. - * - * @treatAsPrivate implementation detail - * @deprecated This is an internal API that is not intended - * for use and will be removed in the next version - */ - @Deprecated - public final IntegerProperty impl_caretPositionProperty() { + public final IntegerProperty caretPositionProperty() { return getTextAttribute().impl_caretPositionProperty(); } /** - * @treatAsPrivate implementation detail - * @deprecated This is an internal API that is not intended - * for use and will be removed in the next version + * caret bias in the content. {@code true} means a bias towards the leading character edge. + * (true=leading/false=trailing) + * + * @since 9 */ - @Deprecated - public final void setImpl_caretBias(boolean value) { + public final void setCaretBias(boolean value) { if (value && (attributes == null || attributes.impl_caretBias == null)) { return; } - impl_caretBiasProperty().set(value); + caretBiasProperty().set(value); } - /** - * @treatAsPrivate implementation detail - * @deprecated This is an internal API that is not intended - * for use and will be removed in the next version - */ - @Deprecated - public final boolean isImpl_caretBias() { + public final boolean isCaretBias() { if (attributes == null || attributes.impl_caretBias == null) { return DEFAULT_CARET_BIAS; } return getTextAttribute().isImpl_caretBias(); } - /** - * caret bias in the content. true means a bias towards forward character - * (true=leading/false=trailing) - * - * @treatAsPrivate implementation detail - * @deprecated This is an internal API that is not intended - * for use and will be removed in the next version - */ - @Deprecated - public final BooleanProperty impl_caretBiasProperty() { + public final BooleanProperty caretBiasProperty() { return getTextAttribute().impl_caretBiasProperty(); } /** * Maps local point to index in the content. * - * @treatAsPrivate implementation detail - * @deprecated This is an internal API that is not intended - * for use and will be removed in the next version + * @since 9 */ - @Deprecated - public final HitInfo impl_hitTestChar(Point2D point) { + public final HitInfo hitTest(Point2D point) { if (point == null) return null; TextLayout layout = getTextLayout(); double x = point.getX() - getX(); double y = point.getY() - getY() + getYRendering(); - return layout.getHitInfo((float)x, (float)y); + TextLayout.Hit layoutHit = layout.getHitInfo((float)x, (float)y); + return new HitInfo(layoutHit.getCharIndex(), layoutHit.getInsertionIndex(), + layoutHit.isLeading(), getText()); } private PathElement[] getRange(int start, int end, int type) { @@ -1016,26 +947,35 @@ } /** + * Returns shape for the caret at given index and bias. + * + * @since 9 + */ + public final PathElement[] caretShape(int charIndex, boolean caretBias) { + if (0 <= charIndex && charIndex <= getTextInternal().length()) { + float x = (float)getX(); + float y = (float)getY() - getYRendering(); + return getTextLayout().getCaretShape(charIndex, caretBias, x, y); + } else { + return null; + } + } + + /** * Returns shape for the range of the text in local coordinates. * - * @treatAsPrivate implementation detail - * @deprecated This is an internal API that is not intended - * for use and will be removed in the next version + * @since 9 */ - @Deprecated - public final PathElement[] impl_getRangeShape(int start, int end) { + public final PathElement[] rangeShape(int start, int end) { return getRange(start, end, TextLayout.TYPE_TEXT); } /** * Returns shape for the underline in local coordinates. * - * @treatAsPrivate implementation detail - * @deprecated This is an internal API that is not intended - * for use and will be removed in the next version + * @since 9 */ - @Deprecated - public final PathElement[] impl_getUnderlineShape(int start, int end) { + public final PathElement[] underlineShape(int start, int end) { return getRange(start, end, TextLayout.TYPE_UNDERLINE); } @@ -1477,11 +1417,11 @@ } if (impl_isDirty(DirtyBits.TEXT_SELECTION)) { Object fillObj = null; - int start = getImpl_selectionStart(); - int end = getImpl_selectionEnd(); + int start = getSelectionStart(); + int end = getSelectionEnd(); int length = getTextInternal().length(); if (0 <= start && start < end && end <= length) { - Paint fill = impl_selectionFillProperty().get(); + Paint fill = selectionFillProperty().get(); fillObj = fill != null ? Toolkit.getPaintAccessor().getPlatformPaint(fill) : null; } peer.setSelection(start, end, fillObj); @@ -1691,8 +1631,8 @@ impl_selectionBinding = new ObjectBinding() { {bind(impl_selectionStartProperty(), impl_selectionEndProperty());} @Override protected PathElement[] computeValue() { - int start = getImpl_selectionStart(); - int end = getImpl_selectionEnd(); + int start = getSelectionStart(); + int end = getSelectionEnd(); return getRange(start, end, TextLayout.TYPE_TEXT); } }; @@ -1767,7 +1707,6 @@ return impl_selectionEnd; } - @Deprecated private ObjectProperty impl_caretShape; private ObjectBinding impl_caretBinding; @@ -1897,21 +1836,21 @@ } case FONT: return getFont(); case CARET_OFFSET: { - int sel = getImpl_caretPosition(); + int sel = getCaretPosition(); if (sel >= 0) return sel; return getText().length(); } case SELECTION_START: { - int sel = getImpl_selectionStart(); + int sel = getSelectionStart(); if (sel >= 0) return sel; - sel = getImpl_caretPosition(); + sel = getCaretPosition(); if (sel >= 0) return sel; return getText().length(); } case SELECTION_END: { - int sel = getImpl_selectionEnd(); + int sel = getSelectionEnd(); if (sel >= 0) return sel; - sel = getImpl_caretPosition(); + sel = getCaretPosition(); if (sel >= 0) return sel; return getText().length(); } @@ -1948,12 +1887,12 @@ case OFFSET_AT_POINT: { Point2D point = (Point2D)parameters[0]; point = screenToLocal(point); - return impl_hitTestChar(point).getCharIndex(); + return hitTest(point).getCharIndex(); } case BOUNDS_FOR_RANGE: { int start = (Integer)parameters[0]; int end = (Integer)parameters[1]; - PathElement[] elements = impl_getRangeShape(start, end + 1); + PathElement[] elements = rangeShape(start, end + 1); /* Each bounds is defined by a MoveTo (top-left) followed by * 4 LineTo (to top-right, bottom-right, bottom-left, back to top-left). */ diff --git a/modules/graphics/src/main/java/javafx/scene/text/TextFlow.java b/modules/graphics/src/main/java/javafx/scene/text/TextFlow.java --- a/modules/graphics/src/main/java/javafx/scene/text/TextFlow.java +++ b/modules/graphics/src/main/java/javafx/scene/text/TextFlow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -39,6 +39,7 @@ import javafx.scene.AccessibleRole; import javafx.scene.Node; import javafx.scene.layout.Pane; +import javafx.scene.shape.PathElement; import javafx.css.StyleableDoubleProperty; import javafx.css.StyleableObjectProperty; import javafx.css.CssMetaData; @@ -150,6 +151,7 @@ private TextLayout layout; private boolean needsContent; private boolean inLayout; + // private static final PathElement[] EMPTY_PATH_ELEMENT_ARRAY = new PathElement[0]; /** * Creates an empty TextFlow layout. @@ -180,6 +182,42 @@ } } + /** + * Maps local point to index in the content. + * + * @since 9 + */ + public final HitInfo hitTest(javafx.geometry.Point2D point) { + if (point != null) { + TextLayout layout = getTextLayout(); + double x = point.getX()/* - getX()*/; + double y = point.getY()/* - getY()/* + getYRendering()*/; + TextLayout.Hit layoutHit = layout.getHitInfo((float)x, (float)y); + return new HitInfo(layoutHit.getCharIndex(), layoutHit.getInsertionIndex(), + layoutHit.isLeading(), null/*getText()*/); + } else { + return null; + } + } + + /** + * Returns shape of caret in local coordinates. + * + * @since 9 + */ + public PathElement[] caretShape(int charIndex, boolean leading) { + return getTextLayout().getCaretShape(charIndex, leading, 0, 0); + } + + /** + * Returns shape for the range of the text in local coordinates. + * + * @since 9 + */ + public final PathElement[] rangeShape(int start, int end) { + return getRange(start, end, TextLayout.TYPE_TEXT); + } + @Override public boolean usesMirroring() { return false; @@ -300,6 +338,15 @@ inLayout = false; } + private PathElement[] getRange(int start, int end, int type) { + TextLayout layout = getTextLayout(); + // int length = textLayout().getCharCount(); + // if (0 <= start && start < end && end <= length) { + return layout.getRange(start, end, type, 0, 0); + // } + // return EMPTY_PATH_ELEMENT_ARRAY; + } + private static class EmbeddedSpan implements TextSpan { RectBounds bounds; Node node; diff --git a/modules/graphics/src/test/java/test/com/sun/javafx/pgstub/StubTextLayout.java b/modules/graphics/src/test/java/test/com/sun/javafx/pgstub/StubTextLayout.java --- a/modules/graphics/src/test/java/test/com/sun/javafx/pgstub/StubTextLayout.java +++ b/modules/graphics/src/test/java/test/com/sun/javafx/pgstub/StubTextLayout.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 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 @@ -130,13 +130,10 @@ } @Override - public HitInfo getHitInfo(float x, float y) { + public Hit getHitInfo(float x, float y) { // TODO this probably needs to be entirely rewritten... if (text == null) { - final HitInfo hit = new HitInfo(); - hit.setCharIndex(0); - hit.setLeading(true); - return hit; + return new Hit(0, -1, true); } final double fontSize = (font == null ? 0 : ((Font)font).getSize()); @@ -157,9 +154,7 @@ throw new IllegalStateException("Asked for hit info out of x range"); } - final HitInfo hit = new HitInfo(); - hit.setCharIndex(offset + charPos); - return hit; + return new Hit(offset + charPos, -1, true); } @Override diff --git a/modules/graphics/src/test/java/test/com/sun/javafx/pgstub/StubToolkit.java b/modules/graphics/src/test/java/test/com/sun/javafx/pgstub/StubToolkit.java --- a/modules/graphics/src/test/java/test/com/sun/javafx/pgstub/StubToolkit.java +++ b/modules/graphics/src/test/java/test/com/sun/javafx/pgstub/StubToolkit.java @@ -1,5 +1,5 @@ /* - * 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 @@ -39,7 +39,6 @@ import com.sun.javafx.perf.PerformanceTracker; import com.sun.javafx.runtime.async.AsyncOperation; import com.sun.javafx.runtime.async.AsyncOperationListener; -import com.sun.javafx.scene.text.HitInfo; import com.sun.javafx.scene.text.TextLayoutFactory; import com.sun.javafx.tk.*; import com.sun.prism.BasicStroke; @@ -636,11 +635,6 @@ } @Override - public HitInfo convertHitInfoToFX(Object hit) { - return (HitInfo) hit; - } - - @Override public Filterable toFilterable(Image img) { return StubFilterable.create((StubPlatformImage)img.impl_getPlatformImage()); }