home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2002 June / INTERNET92.ISO / pc / software / windows / building / visual_dhtml / visualdhtmlwin9x_nt.exe / OCslide1.___ (.txt) < prev    next >
Encoding:
Java Class File  |  2001-10-19  |  3.2 KB  |  197 lines

  1. import java.awt.Color;
  2. import java.awt.Component;
  3. import java.awt.Dimension;
  4. import java.awt.Event;
  5. import java.awt.Graphics;
  6. import java.awt.Image;
  7. import java.awt.Panel;
  8.  
  9. class OCsliderRGB extends Panel {
  10.    public int RGBcomp = 0;
  11.    public Color bgColor;
  12.    private boolean paint_called;
  13.    private boolean first_run;
  14.    private Image off;
  15.    private Graphics g_off;
  16.    private Image sloff;
  17.    private Graphics g_sloff;
  18.    private Image aroff;
  19.    private Graphics g_aroff;
  20.    private Image erase;
  21.    // $FF: renamed from: ds java.awt.Dimension
  22.    private Dimension field_0;
  23.    public int sVal;
  24.    private int arrow_step;
  25.    private int arrow_pos;
  26.    private int last_arrow_pos;
  27.    private int arrow_width;
  28.    private int arrow_height;
  29.    private int slide_height;
  30.    private int slide_width;
  31.    private int slide_x;
  32.    private int slide_y;
  33.  
  34.    private void initArrow() {
  35.       this.aroff = ((Component)this).createImage(this.arrow_width, this.arrow_height);
  36.       this.g_aroff = this.aroff.getGraphics();
  37.       this.g_aroff.setColor(this.bgColor);
  38.       this.g_aroff.fillRect(0, 0, this.arrow_width, this.arrow_height);
  39.       this.g_aroff.setColor(Color.black);
  40.       int var1 = 0;
  41.       int var2 = 0;
  42.       int var3 = 8;
  43.  
  44.       do {
  45.          this.g_aroff.drawLine(var1, var2, var1 + var3, var2);
  46.          ++var2;
  47.          ++var1;
  48.          var3 -= 2;
  49.       } while(var3 >= 0);
  50.  
  51.    }
  52.  
  53.    private void figureSizing() {
  54.       this.slide_width = this.field_0.width - this.arrow_width - 2;
  55.       this.slide_x = this.arrow_width / 2;
  56.       this.slide_y = this.field_0.height - (this.arrow_height + 1);
  57.    }
  58.  
  59.    OCsliderRGB(int var1) {
  60.       this.bgColor = ACutilb.windowColor;
  61.       this.first_run = false;
  62.       this.sVal = 0;
  63.       this.arrow_step = 0;
  64.       this.arrow_pos = 0;
  65.       this.last_arrow_pos = 0;
  66.       this.arrow_width = 9;
  67.       this.arrow_height = 7;
  68.       this.slide_height = 6;
  69.       this.RGBcomp = var1;
  70.    }
  71.  
  72.    public void paint(Graphics var1) {
  73.       this.paint_called = true;
  74.       this.paintIt();
  75.    }
  76.  
  77.    private synchronized void paintIt() {
  78.       if (this.paint_called) {
  79.          if (!this.first_run) {
  80.             ((Component)this).setBackground(this.bgColor);
  81.             if (this.field_0.height >= 1 && this.field_0.width >= 1) {
  82.                this.off = ((Component)this).createImage(this.field_0.width, this.field_0.height);
  83.                this.g_off = this.off.getGraphics();
  84.                this.erase = ((Component)this).createImage(this.arrow_width, this.arrow_height);
  85.                Graphics var1 = this.erase.getGraphics();
  86.                var1.setColor(this.bgColor);
  87.                var1.fillRect(0, 0, this.arrow_width, this.arrow_height);
  88.                this.initSlider();
  89.                this.initArrow();
  90.                this.drawArrow();
  91.                this.g_off.drawImage(this.sloff, this.slide_x, this.slide_y, this);
  92.                this.first_run = true;
  93.                this.paintIt();
  94.             }
  95.          } else {
  96.             ((Component)this).getGraphics().drawImage(this.off, 0, 0, this);
  97.          }
  98.       }
  99.    }
  100.  
  101.    public void resize(Dimension var1) {
  102.       if (var1.width * var1.height > 0) {
  103.          this.field_0 = var1;
  104.          this.figureSizing();
  105.          super.resize(var1);
  106.       }
  107.    }
  108.  
  109.    public void resize(int var1, int var2) {
  110.       if (var1 * var2 > 0) {
  111.          this.field_0 = new Dimension(var1, var2);
  112.          this.figureSizing();
  113.          super.resize(var1, var2);
  114.       }
  115.    }
  116.  
  117.    private void drawArrow() {
  118.       this.g_off.drawImage(this.erase, this.last_arrow_pos, this.field_0.height - this.slide_height - this.arrow_height - 2, this);
  119.       this.g_off.drawImage(this.aroff, this.arrow_pos, this.field_0.height - this.slide_height - this.arrow_height - 2, this);
  120.    }
  121.  
  122.    private void initSlider() {
  123.       this.sloff = ((Component)this).createImage(this.slide_width, this.slide_height);
  124.       this.g_sloff = this.sloff.getGraphics();
  125.       int var1 = 0;
  126.       int var2 = 0;
  127.       int var3 = 0;
  128.       float var4 = 0.0F;
  129.       float var5 = 0.0F;
  130.       float var6 = 0.0F;
  131.       if (this.RGBcomp == 0) {
  132.          var4 = 255.0F / (float)this.slide_width;
  133.       } else if (this.RGBcomp == 1) {
  134.          var5 = 255.0F / (float)this.slide_width;
  135.       } else if (this.RGBcomp == 2) {
  136.          var6 = 255.0F / (float)this.slide_width;
  137.       }
  138.  
  139.       for(int var7 = 0; var7 < this.slide_width; var7 += 4) {
  140.          this.g_sloff.setColor(new Color(var1, var2, var3));
  141.          this.g_sloff.fillRect(var7, 0, var7 + 4, this.slide_height);
  142.          if (this.RGBcomp == 0) {
  143.             var1 = (int)(var4 * (float)var7);
  144.          } else if (this.RGBcomp == 1) {
  145.             var2 = (int)(var5 * (float)var7);
  146.          } else if (this.RGBcomp == 2) {
  147.             var3 = (int)(var6 * (float)var7);
  148.          }
  149.       }
  150.  
  151.    }
  152.  
  153.    public boolean mouseDown(Event var1, int var2, int var3) {
  154.       if (var2 > this.slide_x && var2 < this.slide_x + this.slide_width) {
  155.          this.arrow_pos = var2 - this.slide_x;
  156.          this.drawArrow();
  157.          this.paintIt();
  158.          ((Component)this).requestFocus();
  159.          this.last_arrow_pos = this.arrow_pos;
  160.          this.postChangeVal();
  161.          return true;
  162.       } else {
  163.          return true;
  164.       }
  165.    }
  166.  
  167.    public int getVal() {
  168.       return (int)((float)this.arrow_pos / (float)this.slide_width * 255.0F);
  169.    }
  170.  
  171.    private void postChangeVal() {
  172.       super.postEvent(new Event(this, 901, (new Integer(this.getVal())).toString()));
  173.    }
  174.  
  175.    public void setPos(int var1) {
  176.       this.sVal = var1;
  177.       this.arrow_pos = (int)((float)var1 / 255.0F * (float)this.slide_width);
  178.       if (this.first_run) {
  179.          this.drawArrow();
  180.       }
  181.  
  182.       this.last_arrow_pos = this.arrow_pos;
  183.       if (this.first_run) {
  184.          this.paintIt();
  185.       }
  186.  
  187.    }
  188.  
  189.    public void reshape(int var1, int var2, int var3, int var4) {
  190.       if (var3 * var4 > 0) {
  191.          this.field_0 = new Dimension(var3, var4);
  192.          this.figureSizing();
  193.          super.reshape(var1, var2, var3, var4);
  194.       }
  195.    }
  196. }
  197.