KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > armedbear > j > View


1 /*
2  * View.java
3  *
4  * Copyright (C) 1998-2003 Peter Graves
5  * $Id: View.java,v 1.3 2003/06/18 23:37:22 piso Exp $
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20  */

21
22 package org.armedbear.j;
23
24 import org.armedbear.j.mail.MailboxEntry;
25
26 public final class View implements Cloneable JavaDoc
27 {
28     Position dot;
29     Position mark;
30     Selection selection;
31     private boolean isColumnSelection;
32     Line topLine;
33     int pixelsAboveTopLine;
34     int shift;
35     int caretCol;
36     int lineNumber;
37     int offs;
38     int topLineNumber;
39     long timestamp;
40
41     private MailboxEntry topEntry;
42     private MailboxEntry dotEntry;
43     private NavigationComponent sidebarComponent;
44
45     public View()
46     {
47     }
48
49     public View(SessionBufferEntry entry)
50     {
51         lineNumber = entry.getDotLineNumber();
52         offs = entry.getDotOffset();
53     }
54
55     public Position getDot()
56     {
57         return dot;
58     }
59
60     public int getDotOffset()
61     {
62         return offs;
63     }
64
65     public void setDot(Position pos)
66     {
67         dot = pos != null ? new Position(pos) : null;
68     }
69
70     public Position getMark()
71     {
72         return mark;
73     }
74
75     public void setMark(Position pos)
76     {
77         mark = pos != null ? new Position(pos) : null;
78     }
79
80     public boolean isColumnSelection()
81     {
82         return isColumnSelection;
83     }
84
85     public void setColumnSelection(boolean b)
86     {
87         isColumnSelection = b;
88     }
89
90     public int getDotLineNumber()
91     {
92         return lineNumber;
93     }
94
95     public Line getTopLine()
96     {
97         return topLine;
98     }
99
100     public int getTopLineNumber()
101     {
102         return topLineNumber;
103     }
104
105     public MailboxEntry getTopEntry()
106     {
107         return topEntry;
108     }
109
110     public void setTopEntry(MailboxEntry entry)
111     {
112         topEntry = entry;
113     }
114
115     public MailboxEntry getDotEntry()
116     {
117         return dotEntry;
118     }
119
120     public void setDotEntry(MailboxEntry entry)
121     {
122         dotEntry = entry;
123     }
124
125     public Selection getSelection()
126     {
127         return selection;
128     }
129
130     public int getShift()
131     {
132         return shift;
133     }
134
135     public int getCaretCol()
136     {
137         return caretCol;
138     }
139
140     public void setCaretCol(int col)
141     {
142         caretCol = col;
143     }
144
145     public NavigationComponent getSidebarComponent()
146     {
147         return sidebarComponent;
148     }
149
150     public void setSidebarComponent(NavigationComponent c)
151     {
152         sidebarComponent = c;
153     }
154
155     public void invalidate()
156     {
157         if (dot != null) {
158             lineNumber = dot.lineNumber();
159             offs = dot.getOffset();
160         }
161         dot = null;
162         mark = null;
163         selection = null;
164         isColumnSelection = false;
165         if (topLine != null)
166             topLineNumber = topLine.lineNumber();
167         topLine = null;
168         pixelsAboveTopLine = 0;
169         if (!(sidebarComponent instanceof DirectoryTree))
170             sidebarComponent = null;
171     }
172
173     protected Object JavaDoc clone()
174     {
175         View view = new View();
176         if (dot != null)
177             view.dot = new Position(dot);
178         if (mark != null)
179             view.mark = new Position(mark);
180         view.selection = selection;
181         view.isColumnSelection = isColumnSelection;
182         view.topLine = topLine;
183         view.shift = shift;
184         view.caretCol = caretCol;
185         view.lineNumber = lineNumber;
186         view.offs = offs;
187         view.topLineNumber = topLineNumber;
188         view.pixelsAboveTopLine = pixelsAboveTopLine;
189         return view;
190     }
191 }
192
Popular Tags