Add API to get paragraph bounds if visible#587
Add API to get paragraph bounds if visible#587JordanMartinez merged 1 commit intoFXMisc:masterfrom JordanMartinez:paragraphBounds
Conversation
|
For now, this will do. If we want to change how the bounds works on short/long paragraphs, we can update it in a later PR. |
|
While useful this only works if the paragraph is already fully visible in the view. In my case I am trying to write ParagraphGraphicFactory and would like to display an image at an offset from the top of the paragraph. However the following code: will either throw an exception:
or return Is there any way to get the paragraph bounds if it is only partially visible? My use case here is that I have an offset (int) into the text string. I would like to display an icon to the left of the start of the line where the offset is, thus if I have the following text (a single paragraph):
I would like to display an icon (for example) at the start of the line "I have seldom..." If getting the paragraph bounds is not possible, is it possible to get the text offset of the paragraph within the overall text and then the bounds of a particular character(s) within the paragraph? |
|
Could you open a new issue for this? I'd rather continue the conversation there. Once opened, I'll copy/paste my response below: I'm pretty sure the code does return the bounds of paragraph, even if it's only partially visible. Since we don't have a test verifying that, I could be wrong.
You can use int pos = area.getAbsolutePosition(paragraphIndex, columnIndex)
Bounds b = area.getCharacterBoundsOnScreen(pos, pos + 1);However, since this goes through the same method, I'm not sure if your "partially visible" issue will arise again. Unfortunately, there's no |
Resolves #537