home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Canvas;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.image.ImageObserver;
-
- public class AMDProgressBar extends Canvas {
- int width_;
- int height_;
- Color outerBorderColor_;
- Color innerBorderColor_;
- Color boxColorA_;
- Color boxColorB_;
- Color barColor_;
- Color backTopColor_;
- Color backBottomColor_;
- Color textColor_;
- Color textShadowColor_;
- Font font_;
- String text_;
- int sinePeriod_;
- int colorSegment_;
- Graphics graphics_;
- Image image_;
- double percent_;
- boolean updateTrim_;
- boolean updateLocations_;
- boolean updateBar_;
- int lastDigits_;
- int halfY_;
- int textX_;
- int textY_;
- // $FF: renamed from: r_ int
- int field_0;
- // $FF: renamed from: g_ int
- int field_1;
- // $FF: renamed from: b_ int
- int field_2;
- int r2_;
- int g2_;
- int b2_;
-
- public AMDProgressBar() {
- this.outerBorderColor_ = Color.black;
- this.innerBorderColor_ = Color.black;
- this.boxColorA_ = new Color(244, 224, 32);
- this.boxColorB_ = new Color(120, 80, 4);
- this.barColor_ = new Color(52, 112, 4);
- this.backTopColor_ = new Color(40, 40, 40);
- this.backBottomColor_ = new Color(76, 76, 76);
- this.textColor_ = new Color(208, 192, 28);
- this.textShadowColor_ = Color.black;
- this.font_ = new Font("TimesRoman", 1, 14);
- this.sinePeriod_ = 87;
- this.colorSegment_ = 7;
- this.lastDigits_ = 1;
- this.setPercent((double)0.0F);
- this.updateTrim_ = true;
- this.updateLocations_ = true;
- this.updateBar_ = true;
- }
-
- public void reshape(int var1, int var2, int var3, int var4) {
- super.reshape(var1, var2, var3, var4);
- this.width_ = var3;
- this.height_ = var4;
- if (this.graphics_ != null) {
- this.graphics_.dispose();
- this.graphics_ = null;
- }
-
- ((Component)this).repaint();
- }
-
- public void update(Graphics var1) {
- this.paint(var1);
- }
-
- public void paint(Graphics var1) {
- if (this.graphics_ == null) {
- this.image_ = ((Component)this).createImage(this.width_, this.height_);
- this.graphics_ = this.image_.getGraphics();
- this.updateTrim_ = true;
- this.updateLocations_ = true;
- this.updateBar_ = true;
- }
-
- if (this.updateTrim_) {
- this.updateTrim();
- }
-
- if (this.updateLocations_) {
- this.updateLocations();
- }
-
- if (this.updateBar_) {
- int var2 = (int)((double)(this.width_ - 6) * this.percent_);
- int var3 = this.width_ - 6 - var2;
- this.graphics_.translate(3, 3);
- if (var2 > 0) {
- this.graphics_.setColor(this.barColor_);
- this.graphics_.fillRect(0, 0, var2, this.height_ - 6);
- }
-
- if (var3 > 0) {
- this.graphics_.setColor(this.backTopColor_);
- this.graphics_.fillRect(var2, 0, var3, this.halfY_);
- this.graphics_.setColor(this.backBottomColor_);
- this.graphics_.fillRect(var2, this.halfY_, var3, this.height_ - 6 - this.halfY_);
- }
-
- this.graphics_.translate(-3, -3);
- this.graphics_.setFont(this.font_);
- this.graphics_.setColor(this.textShadowColor_);
- String var4;
- if (this.text_ == null) {
- var4 = (int)(this.percent_ * (double)100.0F) + "%";
- } else {
- var4 = this.text_;
- }
-
- this.graphics_.drawString(var4, this.textX_ + 1, this.textY_ + 1);
- this.graphics_.setColor(this.textColor_);
- this.graphics_.drawString(var4, this.textX_, this.textY_);
- this.updateBar_ = false;
- }
-
- var1.drawImage(this.image_, 0, 0, (ImageObserver)null);
- }
-
- Color getColor(int var1) {
- double var2 = Math.sin((double)(var1 % this.sinePeriod_) * (double)2.0F * Math.PI / (double)this.sinePeriod_) + (double)1.0F;
- return new Color(this.field_0 + (int)(var2 * (double)(this.r2_ - this.field_0) / (double)2.0F), this.field_1 + (int)(var2 * (double)(this.g2_ - this.field_1) / (double)2.0F), this.field_2 + (int)(var2 * (double)(this.b2_ - this.field_2) / (double)2.0F));
- }
-
- int drawSineLine(int var1, int var2, int var3, int var4, int var5, int var6) {
- boolean var7 = var3 == var5;
- if (var7) {
- int var8 = var3;
- var3 = var4;
- var4 = var8;
- var5 = var6;
- }
-
- boolean var11 = var3 > var5;
- if (var11) {
- var2 *= -1;
- }
-
- this.graphics_.setColor(this.getColor(var1));
- if (var7) {
- this.graphics_.drawLine(var4, var3, var4, var3 + var2);
- } else {
- this.graphics_.drawLine(var3, var4, var3 + var2, var4);
- }
-
- int var9 = 1;
- if (!var11) {
- var2 += this.colorSegment_;
- }
-
- for(var1 += this.colorSegment_; var11 && var3 + var2 - this.colorSegment_ > var5 || !var11 && var3 + var2 < var5; ++var9) {
- this.graphics_.setColor(this.getColor(var1));
- if (var7) {
- this.graphics_.drawLine(var4, var3 + var2 - this.colorSegment_, var4, var3 + var2);
- } else {
- this.graphics_.drawLine(var3 + var2 - this.colorSegment_, var4, var3 + var2, var4);
- }
-
- var2 += var11 ? -this.colorSegment_ : this.colorSegment_;
- var1 += this.colorSegment_;
- }
-
- if (var11) {
- var2 += this.colorSegment_;
- }
-
- this.graphics_.setColor(this.getColor(var1));
- if (var7) {
- this.graphics_.drawLine(var4, var3 + var2 - this.colorSegment_, var4, var5);
- } else {
- this.graphics_.drawLine(var3 + var2 - this.colorSegment_, var4, var5, var4);
- }
-
- return var9;
- }
-
- void drawSineBox(Color var1, Color var2, int var3, int var4, int var5, int var6) {
- this.field_0 = var1.getRed();
- this.field_1 = var1.getGreen();
- this.field_2 = var1.getBlue();
- this.r2_ = var2.getRed();
- this.g2_ = var2.getGreen();
- this.b2_ = var2.getBlue();
- int var7 = var3 + var5;
- int var8 = var4 + var6;
- int var9 = 0;
- int var10 = (int)((double)this.sinePeriod_ / (double)4.0F);
- int var11 = this.drawSineLine(var10, var9, var3, var4, var7, var4);
- var10 += var11 * this.colorSegment_;
- var9 += var11 * this.colorSegment_ - var7 + 1;
- var11 = this.drawSineLine(var10, var9, var7, var4, var7, var8);
- var10 += var11 * this.colorSegment_;
- var9 += var11 * this.colorSegment_ - var8 + 1;
- var11 = this.drawSineLine(var10, var9, var7, var8, var3, var8);
- var10 += var11 * this.colorSegment_;
- var9 += var11 * this.colorSegment_ - var7 + 1;
- this.drawSineLine(var10, var9, var3, var8, var3, var4);
- }
-
- void updateTrim() {
- this.graphics_.setColor(this.outerBorderColor_);
- this.graphics_.drawRect(0, 0, this.width_ - 1, this.height_ - 1);
- this.graphics_.setColor(this.innerBorderColor_);
- this.graphics_.drawRect(2, 2, this.width_ - 5, this.height_ - 5);
- if (this.boxColorB_ != null && !this.boxColorA_.equals(this.boxColorB_)) {
- this.drawSineBox(this.boxColorA_, this.boxColorB_, 1, 1, this.width_ - 3, this.height_ - 3);
- } else {
- this.graphics_.setColor(this.boxColorA_);
- this.graphics_.drawRect(1, 1, this.width_ - 3, this.height_ - 3);
- }
-
- this.updateTrim_ = false;
- }
-
- void updateLocations() {
- this.halfY_ = (this.height_ - 6) / 2;
- FontMetrics var1 = ((Component)this).getFontMetrics(this.font_);
- String var2;
- if (this.text_ == null) {
- if (this.lastDigits_ == 1) {
- var2 = "3";
- } else if (this.lastDigits_ == 2) {
- var2 = "30";
- } else {
- var2 = "100";
- }
- } else {
- var2 = this.text_;
- }
-
- this.textX_ = (this.width_ - var1.stringWidth(var2)) / 2;
- this.textY_ = (this.height_ + var1.getAscent() - var1.getDescent()) / 2;
- this.updateLocations_ = false;
- }
-
- public void setPercent(double var1) {
- if (var1 < (double)0.0F) {
- this.percent_ = (double)0.0F;
- } else if (var1 > (double)1.0F) {
- this.percent_ = (double)1.0F;
- } else {
- this.percent_ = var1;
- }
-
- this.updateBar_ = true;
- byte var3;
- if (var1 < 0.1) {
- var3 = 1;
- } else if (var1 < (double)1.0F) {
- var3 = 2;
- } else {
- var3 = 3;
- }
-
- if (var3 != this.lastDigits_) {
- this.lastDigits_ = var3;
- if (this.text_ == null) {
- this.updateLocations_ = true;
- }
- }
-
- ((Component)this).repaint();
- }
-
- public void setText(String var1) {
- this.text_ = var1;
- this.updateLocations_ = true;
- this.updateBar_ = true;
- ((Component)this).repaint();
- }
-
- public void setBorderColors(Color var1, Color var2) {
- this.outerBorderColor_ = var1;
- this.innerBorderColor_ = var2;
- this.updateTrim_ = true;
- ((Component)this).repaint();
- }
-
- public void setBoxColors(Color var1, Color var2) {
- this.boxColorA_ = var1;
- this.boxColorB_ = var2;
- this.updateTrim_ = true;
- ((Component)this).repaint();
- }
-
- public void setBarColor(Color var1) {
- this.barColor_ = var1;
- this.updateBar_ = true;
- ((Component)this).repaint();
- }
-
- public void setBackgroundColors(Color var1, Color var2) {
- this.backTopColor_ = var1;
- this.backBottomColor_ = var2;
- this.updateBar_ = true;
- ((Component)this).repaint();
- }
-
- public void setTextColors(Color var1, Color var2) {
- this.textColor_ = var1;
- this.textShadowColor_ = var2;
- this.updateBar_ = true;
- ((Component)this).repaint();
- }
-
- public void setFont(Font var1) {
- this.font_ = var1;
- this.updateLocations_ = true;
- this.updateBar_ = true;
- ((Component)this).repaint();
- }
-
- public void setSineProperties(int var1, int var2) {
- this.sinePeriod_ = var1;
- this.colorSegment_ = var2;
- this.updateTrim_ = true;
- ((Component)this).repaint();
- }
- }
-