1
2
3
4
5
6
7
8
9
10
11
12 package sk.uniba.euromath.editor.textEditor;
13
14 import org.eclipse.draw2d.geometry.Point;
15 import org.eclipse.draw2d.geometry.Rectangle;
16
17 import sk.uniba.euromath.editor.figures.IEMFigure;
18
19 /***
20 * Locates text into (segment of) one text line. Supposed to implement by
21 * classes <b>drawing<b> text in segment of line. Characters of text are
22 * indexed. First character have index 0.
23 *
24 * @author Tomáš Studva
25 */
26 public interface ITextLocator extends IEMFigure {
27
28 /***
29 * Returns top left point of rectangle bounding character with index
30 * charIndex.
31 *
32 * @param charIndex
33 *
34 * @return most left most top point in smallest rectangle completely
35 * surrounding chracter with index charIndex.
36 */
37 Point getStart(int charIndex);
38
39 /***
40 * Returns top right point of rectangle bounding character with index
41 * charIndex.
42 *
43 * @param charIndex
44 * index of character end retreival
45 *
46 * @return most right most top point in smallest rectangle completely
47 * surrounding chracter with index charIndex.
48 */
49 Point getEnd(int charIndex);
50
51 /***
52 * Returns character's index at location loc.
53 *
54 * @param loc
55 * 2d point
56 * @return character index from start of line at point loc
57 */
58 int getCharIndexAtPos(Point loc);
59
60 /***
61 * Bounds of whole text. Smallest rectangle completely surrounding located
62 * text.
63 *
64 * @return rectangle completely surrounding diplayed text.
65 */
66 Rectangle getTextBounds();
67
68 /***
69 * Bounds of substring of text. Substring consist of characters with indices
70 * greater or equal than start and less or equal end. Smallest rectangle
71 * completely surrounding substring.
72 *
73 * @param start
74 * of substring
75 * @param end
76 * of substring
77 *
78 * @return rectangle completely surrounding substring.
79 */
80 Rectangle getTextBounds(int start, int end);
81
82 /***
83 * @return Returns text located by this ITextLocator.
84 */
85 public String getText();
86
87 /***
88 * Stores the new Text
89 *
90 * @param text
91 * newText
92 */
93 public void updateText(String text);
94 }