/** * Returns the y-coordinate of the line containing an offset.<p> * * The default implementation is equivalent to: * <pre> * int line = textArea.getLineOfOffset(offs); * int startOffs = textArea.getLineStartOffset(line); * return modelToView(startOffs).y; * </pre> * * Subclasses that can calculate this value more quickly than traditional * {@link #modelToView(JTextComponent, int)} calls should override this * method to do so. This method may be used when the entire bounding box * isn't needed, to speed up rendering. * * @param offs The offset info the document. * @return The y-coordinate of the top of the offset, or <code>-1</code> if * this text area doesn't yet have a positive size or the line is * hidden (i.e. from folding). * @throws BadLocationException If <code>offs</code> isn't a valid offset * into the document. */ public int yForLineContaining(int offs) throws BadLocationException { Rectangle r = modelToView(textArea, offs); return r!=null ? r.y : -1; }
/** * Returns the y-coordinate of the line containing an offset.<p> * * The default implementation is equivalent to: * <pre> * int line = textArea.getLineOfOffset(offs); * int startOffs = textArea.getLineStartOffset(line); * return modelToView(startOffs).y</code> * </pre> * * Subclasses that can calculate this value more quickly than traditional * {@link #modelToView(JTextComponent, int)} calls should override this * method to do so. This method may be used when the entire bounding box * isn't needed, to speed up rendering. * * @param offs The offset info the document. * @return The y-coordinate of the top of the offset, or <code>-1</code> if * this text area doesn't yet have a positive size. * @throws BadLocationException If <code>offs</code> isn't a valid offset * into the document. */ public int yForLineContaining(int offs) throws BadLocationException { Rectangle r = modelToView(textArea, offs); return r!=null ? r.y : -1; }
/** * Returns the y-coordinate of the line containing an offset.<p> * * The default implementation is equivalent to: * <pre> * int line = textArea.getLineOfOffset(offs); * int startOffs = textArea.getLineStartOffset(line); * return modelToView(startOffs).y</code> * </pre> * * Subclasses that can calculate this value more quickly than traditional * {@link #modelToView(JTextComponent, int)} calls should override this * method to do so. This method may be used when the entire bounding box * isn't needed, to speed up rendering. * * @param offs The offset info the document. * @return The y-coordinate of the top of the offset, or <code>-1</code> if * this text area doesn't yet have a positive size. * @throws BadLocationException If <code>offs</code> isn't a valid offset * into the document. */ public int yForLineContaining(int offs) throws BadLocationException { Rectangle r = modelToView(textArea, offs); return r!=null ? r.y : -1; }
/** * Returns the y-coordinate of the line containing an offset.<p> * * The default implementation is equivalent to: * <pre> * int line = textArea.getLineOfOffset(offs); * int startOffs = textArea.getLineStartOffset(line); * return modelToView(startOffs).y; * </pre> * * Subclasses that can calculate this value more quickly than traditional * {@link #modelToView(JTextComponent, int)} calls should override this * method to do so. This method may be used when the entire bounding box * isn't needed, to speed up rendering. * * @param offs The offset info the document. * @return The y-coordinate of the top of the offset, or <code>-1</code> if * this text area doesn't yet have a positive size or the line is * hidden (i.e. from folding). * @throws BadLocationException If <code>offs</code> isn't a valid offset * into the document. */ public int yForLineContaining(int offs) throws BadLocationException { Rectangle r = modelToView(textArea, offs); return r!=null ? r.y : -1; }