1 /*
2 * Copyright (c) 2012, 2016, 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
58
59 public static final int DIRECTION_LTR = 1 << 10;
60 public static final int DIRECTION_RTL = 1 << 11;
61 public static final int DIRECTION_DEFAULT_LTR = 1 << 12;
62 public static final int DIRECTION_DEFAULT_RTL = 1 << 13;
63
64 static final int DIRECTION_MASK = DIRECTION_LTR | DIRECTION_RTL |
65 DIRECTION_DEFAULT_LTR |
66 DIRECTION_DEFAULT_RTL;
67
68 public static final int BOUNDS_CENTER = 1 << 14;
69 public static final int BOUNDS_MASK = BOUNDS_CENTER;
70
71 public static final int TYPE_TEXT = 1 << 0;
72 public static final int TYPE_UNDERLINE = 1 << 1;
73 public static final int TYPE_STRIKETHROUGH = 1 << 2;
74 public static final int TYPE_BASELINE = 1 << 3;
75 public static final int TYPE_TOP = 1 << 4;
76 public static final int TYPE_BEARINGS = 1 << 5;
77
78 public static class Hit {
79 int charIndex;
80 int insertionIndex;
81 boolean leading;
82
83 public Hit(int charIndex, int insertionIndex, boolean leading) {
84 this.charIndex = charIndex;
85 this.insertionIndex = insertionIndex;
86 this.leading = leading;
87 }
88
89 public int getCharIndex() { return charIndex; }
90 public int getInsertionIndex() { return insertionIndex; }
91 public boolean isLeading() { return leading; }
92 }
93
94 /**
95 * Sets the content for the TextLayout. Supports multiple spans (rich text).
96 *
97 * @return returns true is the call modifies the layout internal state.
171 public TextLine[] getLines();
172
173 /**
174 * Returns the GlyphList of text layout.
175 * The runs are returned order visually (rendering order), starting
176 * from the first line.
177 *
178 * @return the runs
179 */
180 public GlyphList[] getRuns();
181
182 /**
183 * Returns the shape of the entire text layout relative to the baseline
184 * of the first line.
185 *
186 * @param type the type of the shapes to include
187 * @return the shape
188 */
189 public Shape getShape(int type, TextSpan filter);
190
191 public Hit getHitInfo(float x, float y);
192
193 public PathElement[] getCaretShape(int offset, boolean isLeading,
194 float x, float y);
195 public PathElement[] getRange(int start, int end, int type,
196 float x, float y);
197 }
|
1 /*
2 * Copyright (c) 2012, 2019, 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
58
59 public static final int DIRECTION_LTR = 1 << 10;
60 public static final int DIRECTION_RTL = 1 << 11;
61 public static final int DIRECTION_DEFAULT_LTR = 1 << 12;
62 public static final int DIRECTION_DEFAULT_RTL = 1 << 13;
63
64 static final int DIRECTION_MASK = DIRECTION_LTR | DIRECTION_RTL |
65 DIRECTION_DEFAULT_LTR |
66 DIRECTION_DEFAULT_RTL;
67
68 public static final int BOUNDS_CENTER = 1 << 14;
69 public static final int BOUNDS_MASK = BOUNDS_CENTER;
70
71 public static final int TYPE_TEXT = 1 << 0;
72 public static final int TYPE_UNDERLINE = 1 << 1;
73 public static final int TYPE_STRIKETHROUGH = 1 << 2;
74 public static final int TYPE_BASELINE = 1 << 3;
75 public static final int TYPE_TOP = 1 << 4;
76 public static final int TYPE_BEARINGS = 1 << 5;
77
78 static final int DEFAULT_TAB_SIZE = 8;
79
80 public static class Hit {
81 int charIndex;
82 int insertionIndex;
83 boolean leading;
84
85 public Hit(int charIndex, int insertionIndex, boolean leading) {
86 this.charIndex = charIndex;
87 this.insertionIndex = insertionIndex;
88 this.leading = leading;
89 }
90
91 public int getCharIndex() { return charIndex; }
92 public int getInsertionIndex() { return insertionIndex; }
93 public boolean isLeading() { return leading; }
94 }
95
96 /**
97 * Sets the content for the TextLayout. Supports multiple spans (rich text).
98 *
99 * @return returns true is the call modifies the layout internal state.
173 public TextLine[] getLines();
174
175 /**
176 * Returns the GlyphList of text layout.
177 * The runs are returned order visually (rendering order), starting
178 * from the first line.
179 *
180 * @return the runs
181 */
182 public GlyphList[] getRuns();
183
184 /**
185 * Returns the shape of the entire text layout relative to the baseline
186 * of the first line.
187 *
188 * @param type the type of the shapes to include
189 * @return the shape
190 */
191 public Shape getShape(int type, TextSpan filter);
192
193 /**
194 * Sets the tab size for the TextLayout.
195 *
196 * @param spaces the number of spaces represented by a tab. Default is 8.
197 * Minimum is 1, lower values will be clamped to 1.
198 * @return returns true if the call modifies the layout internal state.
199 */
200 public boolean setTabSize(int spaces);
201
202 public Hit getHitInfo(float x, float y);
203
204 public PathElement[] getCaretShape(int offset, boolean isLeading,
205 float x, float y);
206 public PathElement[] getRange(int start, int end, int type,
207 float x, float y);
208 }
|