1 /*
2 * Copyright (c) 1997, 2015, 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
1228 return c.getComponentOrientation().isLeftToRight();
1229 }
1230
1231
1232 /**
1233 * Provides a way to determine the next visually represented model
1234 * location that one might place a caret. Some views may not be visible,
1235 * they might not be in the same order found in the model, or they just
1236 * might not allow access to some of the locations in the model.
1237 * <p>
1238 * This implementation assumes the views are layed out in a logical
1239 * manner. That is, that the view at index x + 1 is visually after
1240 * the View at index x, and that the View at index x - 1 is visually
1241 * before the View at x. There is support for reversing this behavior
1242 * only if the passed in <code>View</code> is an instance of
1243 * <code>CompositeView</code>. The <code>CompositeView</code>
1244 * must then override the <code>flipEastAndWestAtEnds</code> method.
1245 *
1246 * @param v View to query
1247 * @param pos the position to convert >= 0
1248 * @param a the allocated region to render into
1249 * @param direction the direction from the current position that can
1250 * be thought of as the arrow keys typically found on a keyboard;
1251 * this may be one of the following:
1252 * <ul>
1253 * <li><code>SwingConstants.WEST</code>
1254 * <li><code>SwingConstants.EAST</code>
1255 * <li><code>SwingConstants.NORTH</code>
1256 * <li><code>SwingConstants.SOUTH</code>
1257 * </ul>
1258 * @param biasRet an array contain the bias that was checked
1259 * @return the location within the model that best represents the next
1260 * location visual position
1261 * @exception BadLocationException
1262 * @exception IllegalArgumentException if <code>direction</code> is invalid
1263 */
1264 static int getNextVisualPositionFrom(View v, int pos, Position.Bias b,
1265 Shape alloc, int direction,
1266 Position.Bias[] biasRet)
1267 throws BadLocationException {
1268 if (v.getViewCount() == 0) {
|
1 /*
2 * Copyright (c) 1997, 2017, 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
1228 return c.getComponentOrientation().isLeftToRight();
1229 }
1230
1231
1232 /**
1233 * Provides a way to determine the next visually represented model
1234 * location that one might place a caret. Some views may not be visible,
1235 * they might not be in the same order found in the model, or they just
1236 * might not allow access to some of the locations in the model.
1237 * <p>
1238 * This implementation assumes the views are layed out in a logical
1239 * manner. That is, that the view at index x + 1 is visually after
1240 * the View at index x, and that the View at index x - 1 is visually
1241 * before the View at x. There is support for reversing this behavior
1242 * only if the passed in <code>View</code> is an instance of
1243 * <code>CompositeView</code>. The <code>CompositeView</code>
1244 * must then override the <code>flipEastAndWestAtEnds</code> method.
1245 *
1246 * @param v View to query
1247 * @param pos the position to convert >= 0
1248 * @param alloc the allocated region to render into
1249 * @param direction the direction from the current position that can
1250 * be thought of as the arrow keys typically found on a keyboard;
1251 * this may be one of the following:
1252 * <ul>
1253 * <li><code>SwingConstants.WEST</code>
1254 * <li><code>SwingConstants.EAST</code>
1255 * <li><code>SwingConstants.NORTH</code>
1256 * <li><code>SwingConstants.SOUTH</code>
1257 * </ul>
1258 * @param biasRet an array contain the bias that was checked
1259 * @return the location within the model that best represents the next
1260 * location visual position
1261 * @exception BadLocationException
1262 * @exception IllegalArgumentException if <code>direction</code> is invalid
1263 */
1264 static int getNextVisualPositionFrom(View v, int pos, Position.Bias b,
1265 Shape alloc, int direction,
1266 Position.Bias[] biasRet)
1267 throws BadLocationException {
1268 if (v.getViewCount() == 0) {
|