home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 139 / dpcs0999.iso / Web / CFserver / data1.cab / Java / CFJava.cab / CFJavaRuntime.cab / netscape / application / ImageAttachment.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-10-01  |  2.3 KB  |  88 lines

  1. package netscape.application;
  2.  
  3. import netscape.util.ClassInfo;
  4. import netscape.util.Codable;
  5. import netscape.util.CodingException;
  6. import netscape.util.Decoder;
  7. import netscape.util.Encoder;
  8.  
  9. public class ImageAttachment extends TextAttachment implements Codable {
  10.    private Image image;
  11.    boolean incrementalBitmap;
  12.    int width;
  13.    int height;
  14.    static final String IMAGE_KEY = "image";
  15.  
  16.    public ImageAttachment() {
  17.       this.image = null;
  18.       this.incrementalBitmap = false;
  19.    }
  20.  
  21.    public ImageAttachment(Image var1) {
  22.       this.image = var1;
  23.       this.incrementalBitmap = false;
  24.    }
  25.  
  26.    ImageAttachment(Bitmap var1, int var2, int var3) {
  27.       this.image = var1;
  28.       this.width = var2;
  29.       this.height = var3;
  30.       this.incrementalBitmap = true;
  31.    }
  32.  
  33.    public void setImage(Image var1) {
  34.       this.image = var1;
  35.    }
  36.  
  37.    public Image image() {
  38.       return this.image;
  39.    }
  40.  
  41.    public int width() {
  42.       if (this.incrementalBitmap) {
  43.          return this.width;
  44.       } else {
  45.          return this.image != null ? this.image.width() : 0;
  46.       }
  47.    }
  48.  
  49.    public int height() {
  50.       if (this.incrementalBitmap) {
  51.          return this.height;
  52.       } else {
  53.          return this.image != null ? this.image.height() : 0;
  54.       }
  55.    }
  56.  
  57.    public void drawInRect(Graphics var1, Rect var2) {
  58.       if (var1 != null && var2 != null) {
  59.          Rect var3 = var1.clipRect();
  60.          if (this.image != null) {
  61.             this.image.drawAt(var1, var2.x, var2.y);
  62.          }
  63.  
  64.       }
  65.    }
  66.  
  67.    public void describeClassInfo(ClassInfo var1) {
  68.       super.describeClassInfo(var1);
  69.       var1.addClass("netscape.application.ImageAttachment", 1);
  70.       var1.addField("image", (byte)18);
  71.    }
  72.  
  73.    public void encode(Encoder var1) throws CodingException {
  74.       super.encode(var1);
  75.       var1.encodeObject("image", this.image);
  76.    }
  77.  
  78.    public void decode(Decoder var1) throws CodingException {
  79.       super.decode(var1);
  80.       this.image = (Image)var1.decodeObject("image");
  81.    }
  82.  
  83.    public void finishDecoding() throws CodingException {
  84.       super.finishDecoding();
  85.       this.incrementalBitmap = false;
  86.    }
  87. }
  88.