View Javadoc

1   /*
2    * Copyright 1999-2006 Faculty of Mathematics, Physics
3    * and Informatics, Comenius University, Bratislava. This file is protected by
4    * the Mozilla Public License version 1.1 (the License); you may not use this
5    * file except in compliance with the License. You may obtain a copy of the
6    * License at http://euromath2.sourceforge.net/license.html Unless required by
7    * applicable law or agreed to in writing, software distributed under the
8    * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9    * OF ANY KIND, either express or implied. See the License for the specific
10   * language governing permissions and limitations under the License.
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  }