1
2
3
4
5 package org.astrogrid.io.trace;
6 import org.astrogrid.io.ascii.*;
7
8 import javax.swing.JFrame;
9 import javax.swing.JLabel;
10 import javax.swing.JPanel;
11 import javax.swing.JScrollPane;
12 import javax.swing.JSplitPane;
13 import javax.swing.JTextArea;
14 import javax.swing.WindowConstants;
15
16 /***
17 * This is the window used to display data coming through a TraceInput/OutputStream.
18 * It has two parts - the hex values of the characters, and an ASCII display (similar
19 * to the old DOS Debug program)
20 * <p> Generated by VisualAge
21 * @author: M Hill
22 */
23 public class TraceWindow extends JFrame {
24 private JTextArea ivjByteArea = null;
25 private JPanel ivjJFrameContentPane = null;
26 private JScrollPane ivjJScrollPane1 = null;
27 private JSplitPane ivjJSplitPane1 = null;
28 private JTextArea ivjTextArea = null;
29 private int xpos = 0;
30 private JScrollPane ivjJScrollPane2 = null;
31 private JLabel ivjJLabel1 = null;
32 private JLabel ivjJLabel2 = null;
33 private JPanel ivjJPanel1 = null;
34 private JPanel ivjJPanel2 = null;
35
36 /***
37 * TraceWindow constructor.
38 */
39 public TraceWindow() {
40 super();
41 initialize();
42 }
43 /***
44 * TraceWindow constructor comment.
45 * @param title java.lang.String
46 */
47 public TraceWindow(String title) {
48 super(title);
49 }
50 /***
51 * Return the ByteArea property value.
52 * @return JTextArea
53 */
54
55 private JTextArea getByteArea() {
56 if (ivjByteArea == null) {
57 try {
58 ivjByteArea = new JTextArea();
59 ivjByteArea.setName("ByteArea");
60 ivjByteArea.setLineWrap(false);
61 ivjByteArea.setText("");
62 ivjByteArea.setMaximumSize(new java.awt.Dimension(15, 19));
63 ivjByteArea.setColumns(0);
64 ivjByteArea.setPreferredSize(new java.awt.Dimension(15, 19));
65 ivjByteArea.setFont(new java.awt.Font("monospaced", 0, 12));
66 ivjByteArea.setBounds(0, 0, 15, 19);
67 ivjByteArea.setEditable(false);
68 ivjByteArea.setMinimumSize(new java.awt.Dimension(15, 19));
69
70
71 } catch (java.lang.Throwable ivjExc) {
72
73
74 handleException(ivjExc);
75 }
76 }
77 return ivjByteArea;
78 }
79 /***
80 * Return the JFrameContentPane property value.
81 * @return .JPanel
82 */
83
84 private JPanel getJFrameContentPane() {
85 if (ivjJFrameContentPane == null) {
86 try {
87 ivjJFrameContentPane = new JPanel();
88 ivjJFrameContentPane.setName("JFrameContentPane");
89 ivjJFrameContentPane.setLayout(new java.awt.CardLayout());
90 getJFrameContentPane().add(getJSplitPane1(), getJSplitPane1().getName());
91
92
93 } catch (java.lang.Throwable ivjExc) {
94
95
96 handleException(ivjExc);
97 }
98 }
99 return ivjJFrameContentPane;
100 }
101 /***
102 * Return the JLabel1 property value.
103 * @return .JLabel
104 */
105
106 private JLabel getJLabel1() {
107 if (ivjJLabel1 == null) {
108 try {
109 ivjJLabel1 = new JLabel();
110 ivjJLabel1.setName("JLabel1");
111
112 ivjJLabel1.setText("00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F");
113 ivjJLabel1.setMaximumSize(new java.awt.Dimension(400, 20));
114 ivjJLabel1.setPreferredSize(new java.awt.Dimension(400, 20));
115 ivjJLabel1.setFont(new java.awt.Font("monospaced", 1, 12));
116 ivjJLabel1.setMinimumSize(new java.awt.Dimension(10, 20));
117
118
119 } catch (java.lang.Throwable ivjExc) {
120
121
122 handleException(ivjExc);
123 }
124 }
125 return ivjJLabel1;
126 }
127 /***
128 * Return the JLabel2 property value.
129 * @return .JLabel
130 */
131
132 private JLabel getJLabel2() {
133 if (ivjJLabel2 == null) {
134 try {
135 ivjJLabel2 = new JLabel();
136 ivjJLabel2.setName("JLabel2");
137
138 ivjJLabel2.setText("0123456789ABCDEF");
139 ivjJLabel2.setMaximumSize(new java.awt.Dimension(10, 20));
140 ivjJLabel2.setPreferredSize(new java.awt.Dimension(10, 20));
141 ivjJLabel2.setFont(new java.awt.Font("monospaced", 1, 12));
142 ivjJLabel2.setMinimumSize(new java.awt.Dimension(10, 20));
143
144
145 } catch (java.lang.Throwable ivjExc) {
146
147
148 handleException(ivjExc);
149 }
150 }
151 return ivjJLabel2;
152 }
153 /***
154 * Return the JPanel1 property value.
155 * @return Panel
156 */
157
158 private JPanel getJPanel1() {
159 if (ivjJPanel1 == null) {
160 try {
161 ivjJPanel1 = new JPanel();
162 ivjJPanel1.setName("JPanel1");
163 ivjJPanel1.setLayout(new java.awt.BorderLayout());
164 getJPanel1().add(getJScrollPane1(), "Center");
165 getJPanel1().add(getJLabel1(), "North");
166
167
168 } catch (java.lang.Throwable ivjExc) {
169
170
171 handleException(ivjExc);
172 }
173 }
174 return ivjJPanel1;
175 }
176 /***
177 * Return the JPanel2 property value.
178 * @return Panel
179 */
180
181 private JPanel getJPanel2() {
182 if (ivjJPanel2 == null) {
183 try {
184 ivjJPanel2 = new JPanel();
185 ivjJPanel2.setName("JPanel2");
186 ivjJPanel2.setLayout(new java.awt.BorderLayout());
187 getJPanel2().add(getJScrollPane2(), "Center");
188 getJPanel2().add(getJLabel2(), "North");
189
190
191 } catch (java.lang.Throwable ivjExc) {
192
193
194 handleException(ivjExc);
195 }
196 }
197 return ivjJPanel2;
198 }
199 /***
200 * Return the JScrollPane1 property value.
201 * @return ScrollPane
202 */
203
204 private JScrollPane getJScrollPane1() {
205 if (ivjJScrollPane1 == null) {
206 try {
207 ivjJScrollPane1 = new JScrollPane();
208 ivjJScrollPane1.setName("JScrollPane1");
209 ivjJScrollPane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
210 ivjJScrollPane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
211 getJScrollPane1().setViewportView(getByteArea());
212
213
214 } catch (java.lang.Throwable ivjExc) {
215
216
217 handleException(ivjExc);
218 }
219 }
220 return ivjJScrollPane1;
221 }
222 /***
223 * Return the JScrollPane2 property value.
224 * @return JScrollPane
225 */
226
227 private JScrollPane getJScrollPane2() {
228 if (ivjJScrollPane2 == null) {
229 try {
230 ivjJScrollPane2 = new JScrollPane();
231 ivjJScrollPane2.setName("JScrollPane2");
232 ivjJScrollPane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
233 ivjJScrollPane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
234 getJScrollPane2().setViewportView(getTextArea());
235
236
237 } catch (java.lang.Throwable ivjExc) {
238
239
240 handleException(ivjExc);
241 }
242 }
243 return ivjJScrollPane2;
244 }
245 /***
246 * Return the JSplitPane1 property value.
247 * @return JSplitPane
248 */
249
250 private JSplitPane getJSplitPane1() {
251 if (ivjJSplitPane1 == null) {
252 try {
253 ivjJSplitPane1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
254 ivjJSplitPane1.setName("JSplitPane1");
255 ivjJSplitPane1.setContinuousLayout(false);
256 ivjJSplitPane1.setDividerLocation(300);
257 getJSplitPane1().add(getJPanel1(), "left");
258 getJSplitPane1().add(getJPanel2(), "right");
259
260
261 } catch (java.lang.Throwable ivjExc) {
262
263
264 handleException(ivjExc);
265 }
266 }
267 return ivjJSplitPane1;
268 }
269 /***
270 * Return the TextArea property value.
271 * @return JTextArea
272 */
273
274 private JTextArea getTextArea() {
275 if (ivjTextArea == null) {
276 try {
277 ivjTextArea = new JTextArea();
278 ivjTextArea.setName("TextArea");
279 ivjTextArea.setLineWrap(false);
280 ivjTextArea.setText("");
281 ivjTextArea.setMaximumSize(new java.awt.Dimension(15, 19));
282 ivjTextArea.setColumns(0);
283 ivjTextArea.setPreferredSize(new java.awt.Dimension(100, 20));
284 ivjTextArea.setFont(new java.awt.Font("monospaced", 0, 12));
285 ivjTextArea.setBounds(0, 0, 15, 19);
286 ivjTextArea.setEditable(false);
287 ivjTextArea.setMinimumSize(new java.awt.Dimension(15, 19));
288
289
290 } catch (java.lang.Throwable ivjExc) {
291
292
293 handleException(ivjExc);
294 }
295 }
296 return ivjTextArea;
297 }
298 /***
299 * Called whenever the part throws an exception.
300 * @param exception java.lang.Throwable
301 */
302 private void handleException(java.lang.Throwable exception) {
303
304
305
306
307 }
308 /***
309 * Initialize the class.
310 */
311
312 private void initialize() {
313 try {
314
315
316 setName("TraceWindow");
317 setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
318 setSize(585, 315);
319 setTitle("Stream Trace");
320 setContentPane(getJFrameContentPane());
321 } catch (java.lang.Throwable ivjExc) {
322 handleException(ivjExc);
323 }
324
325
326 }
327 /***
328 * main entrypoint - starts the part when it is run as an application
329 * @param args java.lang.String[]
330 */
331 public static void main(java.lang.String[] args) {
332 try {
333 TraceWindow aTraceWindow;
334 aTraceWindow = new TraceWindow();
335 aTraceWindow.addWindowListener(new java.awt.event.WindowAdapter() {
336 public void windowClosing(java.awt.event.WindowEvent e) {
337 System.exit(0);
338 };
339 });
340 aTraceWindow.setVisible(true);
341 } catch (Throwable exception) {
342 System.err.println("Exception occurred in main() of JFrame");
343 exception.printStackTrace(System.out);
344 }
345 }
346 /***
347 * Insert the method's description here.
348 * Creation date: (18/01/00 19:47:05)
349 */
350 public void newLine() {
351
352 xpos = 0;
353 int maxRows = (ivjByteArea.getSize().height/16)-1;
354
355
356
357
358
359
360
361
362 try {
363 while (ivjByteArea.getLineCount()>maxRows) {
364 ivjByteArea.replaceRange("",0,ivjByteArea.getLineEndOffset(1));
365 }
366 while (ivjTextArea.getLineCount()>maxRows) {
367 ivjTextArea.replaceRange("",0,ivjTextArea.getLineEndOffset(1));
368 }
369
370 } catch (Exception e) {
371
372 } /***/
373
374 ivjByteArea.append("" + AsciiCodes.CR + AsciiCodes.LF);
375 ivjTextArea.append("" + AsciiCodes.CR + AsciiCodes.LF);
376
377 }
378 /***
379 * Insert the method's description here.
380 * Creation date: (18/01/00 14:03:15)
381 * @param i int
382 */
383 public void write(int i) {
384
385 String intString = "00" + Integer.toHexString(i);
386 ivjByteArea.append("" + intString.toUpperCase().substring(intString.length()-2) + " ");
387 if (i>31)
388 ivjTextArea.append( "" + (char) i);
389 else
390 ivjTextArea.append(".");
391
392 xpos ++;
393
394 if (xpos == 8) {
395 ivjByteArea.append(" ");
396 }
397
398 if (xpos >= 16) {
399 newLine();
400 }
401
402 }
403 }
404
405
406
407
408
409
410
411
412
413
414
415