01: package bluej.editor;
02:
03: /**
04: * A LineColumn object groups two pieces of information: the line number and the column number.
05: * They represent a position in the editor's text.
06: * A text location represents the gap to the left of the position identified, so
07: * that (0, 0) is the start of the file, (0, 1) is between the first and
08: * second characters in the file, and so on. There is a LineColumn position to
09: * 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 2920 2004-08-20 08:02:09Z damiano $
15: */
16:
17: /*
18: * @author Damiano Bolla, University of Kent at Canterbury, 2004
19: */
20: public class LineColumn {
21: private int line, column;
22:
23: /**
24: * Create a LineColumn representing the text position at the specified line and column
25: *
26: * @param line a line number starting from 0
27: * @param column a column number starting from 0
28: */
29: public LineColumn(int line, int column) {
30: this .line = line;
31: this .column = column;
32: }
33:
34: /**
35: * Sets the line of the text position, leaves the column unchanged.
36: *
37: * @param line the line number starting from zero
38: */
39: public void setLine(int line) {
40: this .line = line;
41: }
42:
43: /**
44: * Returns the line of this text position
45: *
46: * @return the line number of this text position
47: */
48: public int getLine() {
49: return line;
50: }
51:
52: /**
53: * Sets the column where this caret should be, leaves the line unchanged.
54: *
55: * @param column the column number starting from zero
56: */
57: public void setColumn(int column) {
58: this .column = column;
59: }
60:
61: /**
62: * Returns the column of this text location
63: *
64: * @return the column number of this text location
65: */
66: public int getColumn() {
67: return column;
68: }
69:
70: /**
71: * Set both the line and column where of text location
72: *
73: * @param line a line number starting from zero
74: * @param column a column number starting from zero
75: */
76: public void setLineColumn(int line, int column) {
77: this .line = line;
78: this .column = column;
79: }
80:
81: /**
82: * Returns a string representation of this object.
83: *
84: * @return a string that represents this object status
85: */
86: public String toString() {
87: return "line=" + line + " column=" + column;
88: }
89:
90: }
|