home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Java / JDesignerPro / Jdp3_0.exe / data1.cab / Program_Files / JDPProgressBar.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-04-09  |  2.1 KB  |  98 lines

  1. import java.awt.Canvas;
  2. import java.awt.Color;
  3. import java.awt.Component;
  4. import java.awt.Dimension;
  5. import java.awt.Graphics;
  6. import java.awt.Image;
  7. import java.awt.Rectangle;
  8. import java.awt.image.ImageObserver;
  9.  
  10. public class JDPProgressBar extends Canvas {
  11.    int width;
  12.    int height;
  13.    int percentComplete;
  14.    Color barColor;
  15.    Image offscreen;
  16.    Rectangle offscreensize;
  17.    // $FF: renamed from: gr java.awt.Graphics
  18.    Graphics field_0;
  19.  
  20.    public Dimension minimimSize() {
  21.       Dimension var1 = new Dimension(9, 9);
  22.       return var1;
  23.    }
  24.  
  25.    public synchronized void paint(Graphics var1) {
  26.       Rectangle var2 = ((Component)this).bounds();
  27.       if (this.offscreen == null || var2.width != this.offscreensize.width || var2.height != this.offscreensize.height) {
  28.          this.offscreen = ((Component)this).createImage(var2.width, var2.height);
  29.          this.offscreensize = var2;
  30.          this.field_0 = this.offscreen.getGraphics();
  31.          this.field_0.setFont(((Component)this).getFont());
  32.       }
  33.  
  34.       Color var3 = ((Component)this).getBackground();
  35.       this.field_0 = this.field_0;
  36.       this.field_0.setColor(var3);
  37.       this.field_0.fillRect(0, 0, ((Component)this).bounds().width, ((Component)this).bounds().height);
  38.       this.field_0.setColor(((Component)this).getForeground());
  39.       this.field_0.fillRect(1, 2, (((Component)this).bounds().width - 3) * this.percentComplete / 100, ((Component)this).bounds().height - 3);
  40.       this.field_0.setColor(JDPUtils.darker(var3));
  41.       this.field_0.drawLine(0, 0, ((Component)this).bounds().width - 1, 0);
  42.       this.field_0.drawLine(0, 0, 0, ((Component)this).bounds().height - 1);
  43.       this.field_0.setColor(JDPUtils.darker(JDPUtils.darker(var3)));
  44.       this.field_0.drawLine(1, 1, ((Component)this).bounds().width - 2, 1);
  45.       this.field_0.drawLine(1, 1, 1, ((Component)this).bounds().height - 2);
  46.       this.field_0.setColor(JDPUtils.brighter(var3));
  47.       this.field_0.drawLine(((Component)this).bounds().width - 1, 1, ((Component)this).bounds().width - 1, ((Component)this).bounds().height - 1);
  48.       this.field_0.drawLine(0, ((Component)this).bounds().height - 1, ((Component)this).bounds().width - 1, ((Component)this).bounds().height - 1);
  49.       var1.drawImage(this.offscreen, 0, 0, (ImageObserver)null);
  50.    }
  51.  
  52.    public JDPProgressBar() {
  53.       this.barColor = Color.blue;
  54.       ((Component)this).setForeground(this.barColor);
  55.       this.percentComplete = 0;
  56.    }
  57.  
  58.    public JDPProgressBar(int var1, int var2, Color var3) {
  59.       this.width = var1;
  60.       this.height = var2;
  61.       this.barColor = var3;
  62.       this.percentComplete = 0;
  63.       ((Component)this).reshape(0, 0, var1, var2);
  64.    }
  65.  
  66.    public JDPProgressBar(Color var1) {
  67.       this.barColor = var1;
  68.       ((Component)this).setForeground(var1);
  69.       this.percentComplete = 0;
  70.    }
  71.  
  72.    public synchronized void setPercent(int var1) {
  73.       if (var1 < 0) {
  74.          var1 = 0;
  75.       }
  76.  
  77.       if (var1 > 100) {
  78.          var1 = 100;
  79.       }
  80.  
  81.       this.percentComplete = var1;
  82.       ((Component)this).repaint();
  83.    }
  84.  
  85.    public int getPercent() {
  86.       return this.percentComplete;
  87.    }
  88.  
  89.    public synchronized void update(Graphics var1) {
  90.       this.paint(var1);
  91.    }
  92.  
  93.    public Dimension preferredSize() {
  94.       Dimension var1 = this.minimimSize();
  95.       return var1;
  96.    }
  97. }
  98.