View Javadoc

1   
2   package org.catacomb.druid.gui.edit;
3   
4   import org.catacomb.druid.swing.DProgressReport;
5   import org.catacomb.interlish.structure.ProgressReport;
6   
7   
8   import java.awt.Color;
9   
10  
11  public class DruProgressReport extends DruGCPanel implements ProgressReport {
12      static final long serialVersionUID = 1001;
13  
14  
15      DProgressReport dProgressReport;
16  
17  
18      String text;
19      double fraction;
20  
21      double fmin;
22      double fmax;
23  
24      boolean indeterminate;
25  
26      public DruProgressReport() {
27          super();
28  
29          fmin = 0.;
30          fmax = 1.;
31  
32          dProgressReport = new DProgressReport();
33  
34          addSingleDComponent(dProgressReport);
35  
36      }
37  
38      public void setFocus(double min, double max) {
39          fmin = min;
40          fmax = max;
41      }
42  
43  
44      public void setBg(Color c) {
45          dProgressReport.setBg(c);
46          super.setBg(c);
47          setEtchedUpBorder(c);
48  
49      }
50  
51  
52      public void setIndeterminate(boolean b) {
53          indeterminate = b;
54      }
55  
56  
57      public void setStarted() {
58          fraction = 0.;
59          update();
60      }
61  
62  
63      public void setFraction(double f) {
64          indeterminate = false;
65          fraction = fmin + f * (fmax - fmin);
66      }
67  
68      public void setText(String txt) {
69          text = txt;
70          update();
71      }
72  
73  
74      public double getFraction() {
75          return fraction;
76      }
77  
78      public String getText() {
79          return text;
80      }
81  
82      public void update() {
83          if (indeterminate) {
84              dProgressReport.setIndeterminate(true);
85          } else {
86              dProgressReport.setIndeterminate(false);
87              dProgressReport.setValue((int)(fraction * DProgressReport.imax));
88          }
89  
90          if (text != null) {
91              dProgressReport.setString(text);
92          } else {
93              dProgressReport.setString("");
94          }
95      }
96  
97  
98      public void setFinished() {
99          fraction = 1.;
100         update();
101     }
102 
103 
104 }
105 
106 
107 
108 
109 
110 
111 
112