home *** CD-ROM | disk | FTP | other *** search
- package actual;
-
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Graphics;
-
- public class Spinner extends Component {
- float percentDone;
- int totalTicks = 60;
- int currentTick;
- SpinnerThread spinnerThread;
-
- public Spinner() {
- ((Component)this).setForeground(Color.gray);
- ((Component)this).setForeground(Color.lightGray);
- }
-
- public void paint(Graphics var1) {
- byte var2 = 90;
- int var3 = (int)(this.percentDone * 360.0F);
- var1.setColor(((Component)this).getBackground());
- var1.fillArc(3, 3, ((Component)this).getSize().width - 8, ((Component)this).getSize().height - 8, 0, 360);
- var1.setColor(((Component)this).getForeground());
- var1.fillArc(3, 3, ((Component)this).getSize().width - 8, ((Component)this).getSize().height - 8, var2, var3);
- var1.setColor(Color.black);
- var1.drawArc(3, 3, ((Component)this).getSize().width - 8, ((Component)this).getSize().height - 8, 0, 360);
- }
-
- public void setCurrentTick(int var1) {
- this.currentTick = var1;
- if (this.currentTick > this.totalTicks) {
- this.percentDone = 1.0F;
- } else if (this.currentTick == 0) {
- this.percentDone = 0.0F;
- } else {
- this.percentDone = (float)this.currentTick / (float)this.totalTicks;
- }
-
- ((Component)this).repaint();
- }
-
- public void startSpinning() {
- this.spinnerThread = new SpinnerThread(this);
- this.spinnerThread.start();
- }
-
- public void stopSpinning() {
- this.spinnerThread.stop();
- this.spinnerThread = null;
- }
-
- public void setTotalTicks(int var1) {
- this.totalTicks = var1;
- }
-
- public int getTotalTicks() {
- return this.totalTicks;
- }
-
- public int getCurrentTick() {
- return this.currentTick;
- }
- }
-