1 /*
2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
899 * <p>Note that the AccessibleRole class is also extensible, so
900 * custom component developers can define their own AccessibleRole's
901 * if the set of predefined roles is inadequate.
902 *
903 * @return an instance of AccessibleRole describing the role of the object
904 * @see AccessibleRole
905 */
906 public AccessibleRole getAccessibleRole() {
907 return AccessibleRole.TEXT;
908 }
909
910 /**
911 * Given a point in local coordinates, return the zero-based index
912 * of the character under that Point. If the point is invalid,
913 * this method returns -1.
914 *
915 * @param p the Point in local coordinates
916 * @return the zero-based index of the character under Point p; if
917 * Point is invalid returns -1.
918 */
919 public int getIndexAtPoint(Point p) {
920 View v = getView();
921 if (v != null) {
922 return v.viewToModel(p.x, p.y, getBounds());
923 } else {
924 return -1;
925 }
926 }
927
928 /**
929 * Determine the bounding box of the character at the given
930 * index into the string. The bounds are returned in local
931 * coordinates. If the index is invalid an empty rectangle is
932 * returned.
933 *
934 * @param i the index into the String
935 * @return the screen coordinates of the character's the bounding box,
936 * if index is invalid returns an empty rectangle.
937 */
938 public Rectangle getCharacterBounds(int i) {
|
1 /*
2 * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
899 * <p>Note that the AccessibleRole class is also extensible, so
900 * custom component developers can define their own AccessibleRole's
901 * if the set of predefined roles is inadequate.
902 *
903 * @return an instance of AccessibleRole describing the role of the object
904 * @see AccessibleRole
905 */
906 public AccessibleRole getAccessibleRole() {
907 return AccessibleRole.TEXT;
908 }
909
910 /**
911 * Given a point in local coordinates, return the zero-based index
912 * of the character under that Point. If the point is invalid,
913 * this method returns -1.
914 *
915 * @param p the Point in local coordinates
916 * @return the zero-based index of the character under Point p; if
917 * Point is invalid returns -1.
918 */
919 @SuppressWarnings("deprecation")
920 public int getIndexAtPoint(Point p) {
921 View v = getView();
922 if (v != null) {
923 return v.viewToModel(p.x, p.y, getBounds());
924 } else {
925 return -1;
926 }
927 }
928
929 /**
930 * Determine the bounding box of the character at the given
931 * index into the string. The bounds are returned in local
932 * coordinates. If the index is invalid an empty rectangle is
933 * returned.
934 *
935 * @param i the index into the String
936 * @return the screen coordinates of the character's the bounding box,
937 * if index is invalid returns an empty rectangle.
938 */
939 public Rectangle getCharacterBounds(int i) {
|