408 |
public static final int getRowEnd(JTextComponent c, int offs) |
public static final int getRowEnd(JTextComponent c, int offs) |
409 |
throws BadLocationException |
throws BadLocationException |
410 |
{ |
{ |
411 |
Element root = c.getDocument().getDefaultRootElement(); |
String text = c.getText(); |
|
Element rowElement = root.getElement(root.getElementIndex(offs)); |
|
|
String text = c.getText(rowElement.getStartOffset(), |
|
|
rowElement.getEndOffset()); |
|
412 |
if (text == null) |
if (text == null) |
413 |
return -1; |
return -1; |
414 |
|
|
417 |
// line as the character at position offs |
// line as the character at position offs |
418 |
int high = offs + ((text.length() - 1 - offs) / 2); |
int high = offs + ((text.length() - 1 - offs) / 2); |
419 |
int low = offs; |
int low = offs; |
420 |
int oldHigh = text.length(); |
int oldHigh = text.length() + 1; |
421 |
while (true) |
while (true) |
422 |
{ |
{ |
423 |
if (c.modelToView(high).y != c.modelToView(offs).y) |
if (c.modelToView(high).y != c.modelToView(offs).y) |
451 |
public static final int getRowStart(JTextComponent c, int offs) |
public static final int getRowStart(JTextComponent c, int offs) |
452 |
throws BadLocationException |
throws BadLocationException |
453 |
{ |
{ |
454 |
Element root = c.getDocument().getDefaultRootElement(); |
String text = c.getText(); |
|
Element rowElement = root.getElement(root.getElementIndex(offs)); |
|
|
String text = c.getText(rowElement.getStartOffset(), |
|
|
rowElement.getEndOffset()); |
|
455 |
if (text == null) |
if (text == null) |
456 |
return -1; |
return -1; |
457 |
|
|