src/share/classes/javax/swing/text/GlyphView.java

Print this page




1233          * Provides a way to determine the next visually represented model
1234          * location that one might place a caret.  Some views may not be
1235          * visible, they might not be in the same order found in the model, or
1236          * they just might not allow access to some of the locations in the
1237          * model.
1238          *
1239          * @param v the view to use
1240          * @param pos the position to convert >= 0
1241          * @param b   either <code>Position.Bias.Forward</code>
1242          *                or <code>Position.Bias.Backward</code>
1243          * @param a the allocated region to render into
1244          * @param direction the direction from the current position that can
1245          *  be thought of as the arrow keys typically found on a keyboard.
1246          *  This may be SwingConstants.WEST, SwingConstants.EAST,
1247          *  SwingConstants.NORTH, or SwingConstants.SOUTH.
1248          * @param biasRet  either <code>Position.Bias.Forward</code>
1249          *                 or <code>Position.Bias.Backward</code>
1250          *                 is returned as the zero-th element of this array
1251          * @return the location within the model that best represents the next
1252          *  location visual position.
1253          * @exception BadLocationException
1254          * @exception IllegalArgumentException for an invalid direction
1255          */
1256         public int getNextVisualPositionFrom(GlyphView v, int pos, Position.Bias b, Shape a,
1257                                              int direction,
1258                                              Position.Bias[] biasRet)
1259             throws BadLocationException {
1260 
1261             int startOffset = v.getStartOffset();
1262             int endOffset = v.getEndOffset();
1263             Segment text;
1264 
1265             switch (direction) {
1266             case View.NORTH:
1267             case View.SOUTH:
1268                 if (pos != -1) {
1269                     // Presumably pos is between startOffset and endOffset,
1270                     // since GlyphView is only one line, we won't contain
1271                     // the position to the nort/south, therefore return -1.
1272                     return -1;
1273                 }




1233          * Provides a way to determine the next visually represented model
1234          * location that one might place a caret.  Some views may not be
1235          * visible, they might not be in the same order found in the model, or
1236          * they just might not allow access to some of the locations in the
1237          * model.
1238          *
1239          * @param v the view to use
1240          * @param pos the position to convert &gt;= 0
1241          * @param b   either <code>Position.Bias.Forward</code>
1242          *                or <code>Position.Bias.Backward</code>
1243          * @param a the allocated region to render into
1244          * @param direction the direction from the current position that can
1245          *  be thought of as the arrow keys typically found on a keyboard.
1246          *  This may be SwingConstants.WEST, SwingConstants.EAST,
1247          *  SwingConstants.NORTH, or SwingConstants.SOUTH.
1248          * @param biasRet  either <code>Position.Bias.Forward</code>
1249          *                 or <code>Position.Bias.Backward</code>
1250          *                 is returned as the zero-th element of this array
1251          * @return the location within the model that best represents the next
1252          *  location visual position.
1253          * @exception BadLocationException for a bad location within a document model
1254          * @exception IllegalArgumentException for an invalid direction
1255          */
1256         public int getNextVisualPositionFrom(GlyphView v, int pos, Position.Bias b, Shape a,
1257                                              int direction,
1258                                              Position.Bias[] biasRet)
1259             throws BadLocationException {
1260 
1261             int startOffset = v.getStartOffset();
1262             int endOffset = v.getEndOffset();
1263             Segment text;
1264 
1265             switch (direction) {
1266             case View.NORTH:
1267             case View.SOUTH:
1268                 if (pos != -1) {
1269                     // Presumably pos is between startOffset and endOffset,
1270                     // since GlyphView is only one line, we won't contain
1271                     // the position to the nort/south, therefore return -1.
1272                     return -1;
1273                 }