home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 22 / AMUG_22-1.ISO / Files / Internet / Java / applet-iconbar-1.0.sit / applet-iconbar / afIcon2.class (.txt) next >
Encoding:
Java Class File  |  1997-09-10  |  4.5 KB  |  190 lines  |  [Clss/CWIE]

  1. import java.awt.Canvas;
  2. import java.awt.Color;
  3. import java.awt.Component;
  4. import java.awt.Dimension;
  5. import java.awt.Event;
  6. import java.awt.Font;
  7. import java.awt.FontMetrics;
  8. import java.awt.Graphics;
  9. import java.awt.Image;
  10. import java.awt.image.ImageObserver;
  11.  
  12. class afIcon2 extends Canvas {
  13.    String Label;
  14.    String Descr;
  15.    afIconBar mum;
  16.    Image photo;
  17.    boolean fullb;
  18.    boolean Sinin;
  19.    int val;
  20.    boolean cente;
  21.    boolean mouseisdown;
  22.    boolean buttisup;
  23.    boolean mouseisover;
  24.    int hori;
  25.    int vert;
  26.    // $FF: renamed from: f java.awt.Font
  27.    Font field_0;
  28.    // $FF: renamed from: fm java.awt.FontMetrics
  29.    FontMetrics field_1;
  30.    private Image offScreenImage;
  31.    private Dimension offScreenSize;
  32.    private Graphics offScreenGraphics;
  33.  
  34.    void overthetop() {
  35.       this.mum.overthetop(this.val);
  36.    }
  37.  
  38.    public boolean mouseEnter(Event evt, int x, int y) {
  39.       this.mouseisover = true;
  40.       this.overthetop();
  41.       ((Component)this).repaint();
  42.       return true;
  43.    }
  44.  
  45.    public boolean mouseExit(Event evt, int x, int y) {
  46.       this.mouseisover = false;
  47.       ((Component)this).repaint();
  48.       return true;
  49.    }
  50.  
  51.    public void paint(Graphics g) {
  52.       g.setFont(this.field_0);
  53.       g.setColor(this.mum.nickCol);
  54.       int widAp = ((Component)this).size().width;
  55.       int heiAp = ((Component)this).size().height;
  56.       g.fillRect(0, 0, widAp + 1, heiAp + 1);
  57.       int l = this.field_1.stringWidth(this.Label);
  58.       int h = this.field_1.getHeight();
  59.       this.hori = (widAp - l) / 2;
  60.       this.vert = (heiAp + h / 2) / 2;
  61.       if (!this.cente) {
  62.          this.vert += 15;
  63.       }
  64.  
  65.       if (this.photo != null) {
  66.          int wid = this.photo.getWidth(this);
  67.          int hei = this.photo.getHeight(this);
  68.          int widMultip = widAp / wid + 1;
  69.          int heiMultip = heiAp / hei + 1;
  70.          int phori = 19 - (this.val - 1) * 33;
  71.          int pvert = 1;
  72.          if (this.buttisup) {
  73.             g.drawImage(this.photo, phori, pvert, this);
  74.          } else {
  75.             g.drawImage(this.photo, phori + 1, pvert + 1, this);
  76.          }
  77.       }
  78.  
  79.       if (this.fullb) {
  80.          this.mouseisover = true;
  81.       }
  82.  
  83.       if (this.mouseisover) {
  84.          g.setColor(this.mum.nickCol);
  85.          g.draw3DRect(0, 0, widAp - 1, heiAp - 1, true);
  86.       }
  87.  
  88.       if (this.buttisup) {
  89.          g.setColor(this.mum.nickCol);
  90.          g.fillRect(0, 0, widAp, 3);
  91.          g.fillRect(0, 34, widAp, 20);
  92.          g.fillRect(0, 0, 22, heiAp);
  93.          g.fillRect(widAp - 23, 0, 35, heiAp);
  94.          if (this.mouseisover) {
  95.             g.setColor(this.mum.nickCol);
  96.             g.draw3DRect(0, 0, widAp - 1, heiAp - 1, true);
  97.          }
  98.  
  99.          if (this.Sinin) {
  100.             g.setColor(Color.white);
  101.             g.drawString(this.Label, this.hori + 1, this.vert + 1);
  102.          }
  103.  
  104.          g.setColor(this.mum.nickCol2);
  105.          g.drawString(this.Label, this.hori, this.vert);
  106.       } else if (!this.buttisup) {
  107.          g.setColor(this.mum.nickCol);
  108.          g.fillRect(0, 0, widAp, 4);
  109.          g.fillRect(0, 35, widAp, 20);
  110.          g.fillRect(0, 0, 23, heiAp);
  111.          g.fillRect(widAp - 22, 0, 35, heiAp);
  112.          g.setColor(this.mum.nickCol);
  113.          g.draw3DRect(0, 0, widAp - 1, heiAp - 1, false);
  114.          if (this.Sinin) {
  115.             g.setColor(Color.white);
  116.             g.drawString(this.Label, this.hori + 2, this.vert + 2);
  117.          }
  118.  
  119.          g.setColor(this.mum.nickCol2);
  120.          g.drawString(this.Label, this.hori + 1, this.vert + 1);
  121.       }
  122.  
  123.    }
  124.  
  125.    public boolean mouseUp(Event evt, int x, int y) {
  126.       this.mouseisdown = false;
  127.       this.buttisup = true;
  128.       this.mouseisover = true;
  129.       this.buttonclick();
  130.       ((Component)this).repaint();
  131.       return true;
  132.    }
  133.  
  134.    public void distroy() {
  135.       this.offScreenGraphics.dispose();
  136.    }
  137.  
  138.    public void mouser() {
  139.       this.mouseisover = false;
  140.       ((Component)this).repaint();
  141.    }
  142.  
  143.    public final synchronized void update(Graphics g) {
  144.       Dimension d = ((Component)this).size();
  145.       if (this.offScreenImage == null || d.width != this.offScreenSize.width || d.height != this.offScreenSize.height) {
  146.          this.offScreenImage = ((Component)this).createImage(d.width, d.height);
  147.          this.offScreenSize = d;
  148.          this.offScreenGraphics = this.offScreenImage.getGraphics();
  149.       }
  150.  
  151.       this.paint(this.offScreenGraphics);
  152.       g.drawImage(this.offScreenImage, 0, 0, (ImageObserver)null);
  153.    }
  154.  
  155.    public boolean mouseDown(Event evt, int x, int y) {
  156.       this.mouseisdown = true;
  157.       this.buttisup = false;
  158.       this.mouseisover = false;
  159.       ((Component)this).repaint();
  160.       return true;
  161.    }
  162.  
  163.    void buttonclick() {
  164.       this.mum.buttonclick(this.val);
  165.    }
  166.  
  167.    public afIcon2(int v, afIconBar dad, Image tasphoto, String lab, String Des, boolean cent) {
  168.       this.mum = dad;
  169.       this.Label = lab;
  170.       this.Descr = Des;
  171.       this.val = v;
  172.       this.photo = tasphoto;
  173.       this.fullb = this.mum.fullb;
  174.       this.Sinin = this.mum.Sinkin;
  175.       String Face = this.mum.Face;
  176.       boolean Bolder = this.mum.Bolder;
  177.       this.field_0 = new Font(Face, 0, 12);
  178.       if (Bolder) {
  179.          this.field_0 = new Font(Face, 1, 12);
  180.          ((Component)this).setBackground(this.mum.nickCol);
  181.       }
  182.  
  183.       this.field_1 = ((Component)this).getFontMetrics(this.field_0);
  184.       this.cente = cent;
  185.       this.mouseisdown = false;
  186.       this.buttisup = true;
  187.       ((Component)this).repaint();
  188.    }
  189. }
  190.