KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > bluej > editor > LineColumn


1 package bluej.editor;
2
3 /**
4  * A LineColumn object groups two pieces of information: the line number and the column number.
5  * They represent a position in the editor's text.
6  * A text location represents the gap to the left of the position identified, so
7  * that (0, 0) is the start of the file, (0, 1) is between the first and
8  * second characters in the file, and so on. There is a LineColumn position to
9  * the right of the last character on a line.
10  *
11  * @definition An invalid LineColumn is one that, at the time of use, points to an area outside the
12  * text being edited.
13  *
14  * @version $Id: LineColumn.java,v 1.1 2004/08/20 08:02:09 damiano Exp $
15  */

16
17 /*
18  * @author Damiano Bolla, University of Kent at Canterbury, 2004
19  */

20 public class LineColumn
21 {
22     private int line,column;
23     
24     /**
25      * Create a LineColumn representing the text position at the specified line and column
26      *
27      * @param line a line number starting from 0
28      * @param column a column number starting from 0
29      */

30     public LineColumn(int line, int column)
31     {
32         this.line = line;
33         this.column = column;
34     }
35
36
37     /**
38      * Sets the line of the text position, leaves the column unchanged.
39      *
40      * @param line the line number starting from zero
41      */

42     public void setLine(int line)
43     {
44         this.line = line;
45     }
46
47
48     /**
49      * Returns the line of this text position
50      *
51      * @return the line number of this text position
52      */

53     public int getLine()
54     {
55         return line;
56     }
57
58
59     /**
60      * Sets the column where this caret should be, leaves the line unchanged.
61      *
62      * @param column the column number starting from zero
63      */

64     public void setColumn(int column)
65     {
66         this.column = column;
67     }
68
69
70     /**
71      * Returns the column of this text location
72      *
73      * @return the column number of this text location
74      */

75     public int getColumn()
76     {
77         return column;
78     }
79
80
81     /**
82      * Set both the line and column where of text location
83      *
84      * @param line a line number starting from zero
85      * @param column a column number starting from zero
86      */

87     public void setLineColumn(int line, int column)
88     {
89         this.line = line;
90         this.column = column;
91     }
92
93     /**
94      * Returns a string representation of this object.
95      *
96      * @return a string that represents this object status
97      */

98     public String JavaDoc toString ()
99     {
100         return "line="+line+" column="+column;
101     }
102     
103 }
104
Popular Tags