1 /*
2 * Fsgrep is a simple Java application which allows a user to
3 * search all files in a directory structure for lines matching
4 * a given pattern. Its functionality is a combination of the
5 * Unix 'find' and 'grep' utilities.
6 * Visit [http://fsgrep.sourceforge.net/] for more information.
7 *
8 * Copyright (C) 2003-2006 Murali Krishnan [murali_ca_us@users.sourceforge.net]
9 *
10 * Fsgrep is free software; you can redistribute it and/or modify
11 * it under the terms of version 2 of the GNU General Public
12 * License as published by the Free Software Foundation.
13 *
14 * Fsgrep is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with Fsgrep (see the file named LICENSE.txt); if not, write
21 * to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
22 * Boston, MA 02111-1307 USA
23 */
24
25 package mk.fsgrep.util;
26
27
28 import javax.swing.JProgressBar;
29
30
31
32 /***
33 * Draws a text-based progress bar (percentage completion).
34 *
35 * @author Murali Krishnan
36 *
37 */
38 public class GuiProgressBar implements ProgressBar {
39
40 //------------------------------------------------------------
41 //- Class Variables
42
43
44
45 //------------------------------------------------------------
46 //- Class Functions
47
48
49
50 //------------------------------------------------------------
51 //- Instance Variables
52
53 private JProgressBar _bar = null;
54
55
56
57 //------------------------------------------------------------
58 //- Constructors
59
60 public GuiProgressBar(JProgressBar pBar) {
61 _bar = pBar;
62 }
63
64
65 //------------------------------------------------------------
66 //- Accessors
67
68 protected JProgressBar getBar() {return _bar;}
69
70
71
72 //------------------------------------------------------------
73 //- Settors
74
75
76
77 //------------------------------------------------------------
78 //- Private/Protected Utility Functions
79
80
81
82 //------------------------------------------------------------
83 //- Public Interface Functions
84
85 public void update() {
86 getBar().setValue(getBar().getValue() + 1);
87 }
88
89 public void finish() {
90 }
91
92 public void initialize(int total) {
93 getBar().setMinimum(0);
94 getBar().setMaximum(total);
95 getBar().setValue(0);
96 }
97
98
99 //------------------------------------------------------------
100 //- Class Interface Functions
101
102
103
104 //------------------------------------------------------------
105 //- Inner Classes
106
107
108
109 //------------------------------------------------------------
110 //- Main
111
112 }