< prev index next >

src/java.desktop/share/classes/javax/swing/text/ParagraphView.java

Print this page




 229                 posBounds = null;
 230             }
 231             if(posBounds == null) {
 232                 x = 0;
 233             }
 234             else {
 235                 x = posBounds.getBounds().x;
 236             }
 237         }
 238         else {
 239             x = magicPoint.x;
 240         }
 241         return getClosestPositionTo(pos, b, a, direction, biasRet, vIndex, x);
 242     }
 243 
 244     /**
 245      * Returns the closest model position to <code>x</code>.
 246      * <code>rowIndex</code> gives the index of the view that corresponds
 247      * that should be looked in.
 248      * @param pos  position into the model

 249      * @param a the allocated region to render into
 250      * @param direction one of the following values:
 251      * <ul>
 252      * <li><code>SwingConstants.NORTH</code>
 253      * <li><code>SwingConstants.SOUTH</code>
 254      * </ul>
 255      * @param biasRet an array containing the bias that were checked
 256      *  in this method
 257      * @param rowIndex the index of the view
 258      * @param x the x coordinate of interest

 259      * @return the closest model position to <code>x</code>
 260      */
 261     // NOTE: This will not properly work if ParagraphView contains
 262     // other ParagraphViews. It won't raise, but this does not message
 263     // the children views with getNextVisualPositionFrom.
 264     protected int getClosestPositionTo(int pos, Position.Bias b, Shape a,
 265                                        int direction, Position.Bias[] biasRet,
 266                                        int rowIndex, int x)
 267               throws BadLocationException {
 268         JTextComponent text = (JTextComponent)getContainer();
 269         Document doc = getDocument();
 270         View row = getView(rowIndex);
 271         int lastPos = -1;
 272         // This could be made better to check backward positions too.
 273         biasRet[0] = Position.Bias.Forward;
 274         for(int vc = 0, numViews = row.getViewCount(); vc < numViews; vc++) {
 275             View v = row.getView(vc);
 276             int start = v.getStartOffset();
 277             boolean ltr = AbstractDocument.isLeftToRight(doc, start, start + 1);
 278             if(ltr) {




 229                 posBounds = null;
 230             }
 231             if(posBounds == null) {
 232                 x = 0;
 233             }
 234             else {
 235                 x = posBounds.getBounds().x;
 236             }
 237         }
 238         else {
 239             x = magicPoint.x;
 240         }
 241         return getClosestPositionTo(pos, b, a, direction, biasRet, vIndex, x);
 242     }
 243 
 244     /**
 245      * Returns the closest model position to <code>x</code>.
 246      * <code>rowIndex</code> gives the index of the view that corresponds
 247      * that should be looked in.
 248      * @param pos  position into the model
 249      * @param b the bias
 250      * @param a the allocated region to render into
 251      * @param direction one of the following values:
 252      * <ul>
 253      * <li><code>SwingConstants.NORTH</code>
 254      * <li><code>SwingConstants.SOUTH</code>
 255      * </ul>
 256      * @param biasRet an array containing the bias that were checked
 257      *  in this method
 258      * @param rowIndex the index of the view
 259      * @param x the x coordinate of interest
 260      * @throws BadLocationException if a bad location is encountered
 261      * @return the closest model position to <code>x</code>
 262      */
 263     // NOTE: This will not properly work if ParagraphView contains
 264     // other ParagraphViews. It won't raise, but this does not message
 265     // the children views with getNextVisualPositionFrom.
 266     protected int getClosestPositionTo(int pos, Position.Bias b, Shape a,
 267                                        int direction, Position.Bias[] biasRet,
 268                                        int rowIndex, int x)
 269               throws BadLocationException {
 270         JTextComponent text = (JTextComponent)getContainer();
 271         Document doc = getDocument();
 272         View row = getView(rowIndex);
 273         int lastPos = -1;
 274         // This could be made better to check backward positions too.
 275         biasRet[0] = Position.Bias.Forward;
 276         for(int vc = 0, numViews = row.getViewCount(); vc < numViews; vc++) {
 277             View v = row.getView(vc);
 278             int start = v.getStartOffset();
 279             boolean ltr = AbstractDocument.isLeftToRight(doc, start, start + 1);
 280             if(ltr) {


< prev index next >