ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/conient/uk/org/iscream/cms/conient/PacketTimer.java
(Generate patch)

Comparing projects/cms/source/conient/uk/org/iscream/cms/conient/PacketTimer.java (file contents):
Revision 1.1 by ajm, Sat Feb 3 19:19:27 2001 UTC vs.
Revision 1.2 by ajm, Sun Feb 4 20:34:05 2001 UTC

# Line 1 | Line 1
1 + //---PACKAGE DECLARATION---
2   package uk.ac.ukc.iscream.conient;
3  
4 + //---IMPORTS---
5   import javax.swing.JProgressBar;
6   import javax.swing.SwingUtilities;
7  
8 + /**
9 + * Shows a countdown timer for packet arrival times.
10 + * When constructed it takes an integer value relating
11 + * to the time in seconds between recieving packets.
12 + *
13 + * This then displays a JProgress bar which updates at
14 + * 10th of a second intervals.
15 + *
16 + * It currently is adjusted by the addition of 1 second
17 + * to account for the possibility of network delay.
18 + *
19 + * @author  $Author$
20 + * @version $Id$
21 + */
22   public class PacketTimer extends JProgressBar implements Runnable {
23  
24 + //---FINAL ATTRIBUTES---
25 +
26 +    /**
27 +     * The current CVS revision of this class
28 +     */
29 +    public static final String REVISION = "$Revision$";
30 +    
31 + //---STATIC METHODS---
32 +
33 + //---CONSTRUCTORS---
34 +
35 +    /**
36 +     * Constructs a new PacketTimer
37 +     *
38 +     * @param timeBetweenPackets the time in seconds between packet arrival
39 +     */
40      public PacketTimer(int timeBetweenPackets) {
41 <        super(JProgressBar.VERTICAL, 0, timeBetweenPackets * 10);
41 >        super(JProgressBar.VERTICAL, 0, (timeBetweenPackets * 10) + 1);
42          _timeBetweenPackets = timeBetweenPackets * 10;
43          setMaximum(_timeBetweenPackets);
44      }
45 +
46 + //---PUBLIC METHODS---
47      
48 +    /**
49 +     * Updates the progress bar every 10th of a second.
50 +     */
51      public void run() {
52 <        while(running) {
52 >        while(_running) {
53              try {
54                  Thread.sleep(100);
55              } catch (InterruptedException e) {
# Line 26 | Line 63 | public class PacketTimer extends JProgressBar implemen
63          }
64      }
65      
66 +    /**
67 +     * Resets the progress bar.
68 +     */
69      public void reset() {
70          SwingUtilities.invokeLater(new Runnable() {
71              public void run() {
# Line 34 | Line 74 | public class PacketTimer extends JProgressBar implemen
74          });
75      }
76      
77 + //---PRIVATE METHODS---
78 +
79 + //---ACCESSOR/MUTATOR METHODS---
80 +
81 + //---ATTRIBUTES---
82 +
83 +    /**
84 +     * Holds the time between packets as used internally by this class
85 +     */
86      private int _timeBetweenPackets;
87 <    private boolean running = true;
87 >    
88 >    /**
89 >     * Used to indicate the state of the thread
90 >     */
91 >    private boolean _running = true;
92 >
93 > //---STATIC ATTRIBUTES---
94 >
95   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines