Friday, 21 November 2008

Classes used with TextBox

In code representation of lines Vector collection should be placed in separate class. TextArray instance which is strictly connected with used text box object, has parse method that creates Vector container of all lines, and getLine(int i) method that gives text box access to needed String variables. It’s created when text box is created, and right after that first parsing is called, so the array is ready to be printed out whenever text box is ready for it. Text box, object that is responsible only for display will simply get each line of its text array and print it out on the screen.

To allow text scrolling another class is needed. Scrolling class, which is also tightly connected with given text box, is responsible for all calculations connected with scrolling elements. From text box point of view its purpose is to give indexes of first and last line displayed inside text box. Scrolling class deals with all height and index moving calculations and produces just those two numbers that are used by textbox to get proper lines from TextArray.

No comments: