86 |
{ |
{ |
87 |
View parent = getParent(); |
View parent = getParent(); |
88 |
if (parent == null) |
if (parent == null) |
89 |
throw new AssertionError("The parent of a View must not be null."); |
return null; |
90 |
|
else |
91 |
return parent.getContainer(); |
return parent.getContainer(); |
92 |
} |
} |
93 |
|
|
94 |
public Document getDocument() |
public Document getDocument() |
507 |
} |
} |
508 |
|
|
509 |
/** |
/** |
510 |
|
* Maps a position in the document into the coordinate space of the View. |
511 |
|
* The output rectangle usually reflects the font height but has a width |
512 |
|
* of zero. |
513 |
|
* |
514 |
|
* This method is deprecated and calls |
515 |
|
* {@link #modelToView(int, Position.Bias, int, Position.Bias, Shape)} with |
516 |
|
* a bias of {@link Position.Bias#Forward}. |
517 |
|
* |
518 |
|
* @param pos the position of the character in the model |
519 |
|
* @param a the area that is occupied by the view |
520 |
|
* |
521 |
|
* @return a rectangle that gives the location of the document position |
522 |
|
* inside the view coordinate space |
523 |
|
* |
524 |
|
* @throws BadLocationException if <code>pos</code> is invalid |
525 |
|
* |
526 |
|
* @deprecated Use {@link #modelToView(int, Shape, Position.Bias)} instead. |
527 |
|
*/ |
528 |
|
public Shape modelToView(int pos, Shape a) throws BadLocationException |
529 |
|
{ |
530 |
|
return modelToView(pos, a, Position.Bias.Forward); |
531 |
|
} |
532 |
|
|
533 |
|
/** |
534 |
* Maps coordinates from the <code>View</code>'s space into a position |
* Maps coordinates from the <code>View</code>'s space into a position |
535 |
* in the document model. |
* in the document model. |
536 |
* |
* |
544 |
*/ |
*/ |
545 |
public abstract int viewToModel(float x, float y, Shape a, Position.Bias[] b); |
public abstract int viewToModel(float x, float y, Shape a, Position.Bias[] b); |
546 |
|
|
547 |
|
/** |
548 |
|
* Maps coordinates from the <code>View</code>'s space into a position |
549 |
|
* in the document model. This method is deprecated and only there for |
550 |
|
* compatibility. |
551 |
|
* |
552 |
|
* @param x the x coordinate in the view space |
553 |
|
* @param y the y coordinate in the view space |
554 |
|
* @param a the allocation of this <code>View</code> |
555 |
|
* |
556 |
|
* @return the position in the document that corresponds to the screen |
557 |
|
* coordinates <code>x, y</code> |
558 |
|
* |
559 |
|
* @deprecated Use {@link #viewToModel(float, float, Shape, Position.Bias[])} |
560 |
|
* instead. |
561 |
|
*/ |
562 |
|
public int viewToModel(float x, float y, Shape a) |
563 |
|
{ |
564 |
|
return viewToModel(x, y, a, new Position.Bias[0]); |
565 |
|
} |
566 |
|
|
567 |
/** |
/** |
568 |
* Dumps the complete View hierarchy. This method can be used for debugging |
* Dumps the complete View hierarchy. This method can be used for debugging |