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

  1. import java.awt.Color;
  2. import java.awt.Component;
  3. import java.awt.Dimension;
  4. import java.awt.Graphics;
  5. import java.awt.Image;
  6. import java.awt.Panel;
  7. import java.awt.Rectangle;
  8. import java.awt.image.ImageObserver;
  9.  
  10. public class JDPImage extends Panel {
  11.    static boolean activated;
  12.    JDPUser user;
  13.    Image thisImage;
  14.    String imageLoc;
  15.    String prevImageLoc;
  16.    JDPImageLoader imageLoader;
  17.    int iwidth;
  18.    int iheight;
  19.    Image offscreen;
  20.    Rectangle offscreensize;
  21.    // $FF: renamed from: gr java.awt.Graphics
  22.    Graphics field_0;
  23.    Dimension Bounds;
  24.  
  25.    public String getImagePath() {
  26.       return this.imageLoc;
  27.    }
  28.  
  29.    public void setImagePath(String var1) {
  30.       if (var1 != null) {
  31.          if (this.imageLoc == null || !var1.equals(this.imageLoc)) {
  32.             this.imageLoc = var1;
  33.             this.thisImage = null;
  34.             ((Component)this).repaint();
  35.          }
  36.       }
  37.    }
  38.  
  39.    public void paint(Graphics var1) {
  40.       this.update(var1);
  41.    }
  42.  
  43.    public Dimension minimumSize() {
  44.       Dimension var1 = new Dimension(this.iwidth, this.iheight);
  45.       if (this.iwidth == 0 && this.iheight == 0) {
  46.          var1.width = 200;
  47.          var1.height = 30;
  48.       }
  49.  
  50.       return var1;
  51.    }
  52.  
  53.    public JDPImage(JDPUser var1) {
  54.       activated = JDPUser.classactivated;
  55.       if (!activated) {
  56.          System.out.println("Software Violation - this class may only be used in conjunction with JDesignerPro.");
  57.       } else {
  58.          this.user = var1;
  59.       }
  60.    }
  61.  
  62.    public JDPImage(JDPUser var1, String var2) {
  63.       activated = JDPUser.classactivated;
  64.       if (!activated) {
  65.          System.out.println("Software Violation - this class may only be used in conjunction with JDesignerPro.");
  66.       } else {
  67.          this.user = var1;
  68.          this.imageLoc = var2;
  69.       }
  70.    }
  71.  
  72.    public void update(Graphics var1) {
  73.       this.Bounds = ((Component)this).size();
  74.       Rectangle var2 = ((Component)this).bounds();
  75.       if (this.offscreen == null || var2.width != this.offscreensize.width || var2.height != this.offscreensize.height) {
  76.          try {
  77.             this.offscreen = ((Component)this).createImage(var2.width, var2.height);
  78.          } catch (Exception var6) {
  79.             if (this.user.mainmsg != null) {
  80.                this.user.mainmsg.setStatusMsg("Out of Memory. Please increase usable memory", 20);
  81.             }
  82.  
  83.             return;
  84.          }
  85.  
  86.          this.offscreensize = var2;
  87.          this.field_0 = this.offscreen.getGraphics();
  88.       }
  89.  
  90.       if (this.imageLoader != null && this.imageLoader.getImageReady()) {
  91.          this.thisImage = this.imageLoader.thisImage;
  92.          this.imageLoader = null;
  93.       }
  94.  
  95.       this.field_0.setColor(((Component)this).getBackground());
  96.       this.field_0.fillRect(0, 0, this.Bounds.width, this.Bounds.height);
  97.       if (this.imageLoc != null && !this.imageLoc.equals("")) {
  98.          String var3 = this.imageLoc;
  99.  
  100.          try {
  101.             if (this.thisImage != null && this.thisImage.getWidth((ImageObserver)null) > 0) {
  102.                if (this.iwidth == 0) {
  103.                   this.iwidth = this.thisImage.getWidth((ImageObserver)null);
  104.                   this.iheight = this.thisImage.getHeight((ImageObserver)null);
  105.                   ((Component)this).resize(this.iwidth, this.iheight);
  106.                }
  107.  
  108.                if (this.iwidth != 0 && this.iheight != 0) {
  109.                   this.field_0.drawImage(this.thisImage, 0, 0, this.iwidth, this.iheight, (ImageObserver)null);
  110.                } else {
  111.                   this.field_0.drawImage(this.thisImage, 0, 0, (ImageObserver)null);
  112.                }
  113.             } else if (!var3.equals(this.prevImageLoc)) {
  114.                this.iwidth = 0;
  115.                this.iheight = 0;
  116.                this.imageLoader = new JDPImageLoader(this.user, this, var3);
  117.                (new Thread(this.imageLoader)).start();
  118.                this.prevImageLoc = var3;
  119.             } else {
  120.                this.field_0.setColor(Color.black);
  121.                this.field_0.drawRect(0, 0, this.Bounds.width - 1, this.Bounds.height - 1);
  122.                this.field_0.drawString("Image " + var3 + " not found", 3, 12);
  123.             }
  124.          } catch (Exception var7) {
  125.             ((Throwable)var7).printStackTrace();
  126.          }
  127.       } else {
  128.          this.field_0.setColor(Color.black);
  129.          this.field_0.drawRect(0, 0, this.Bounds.width - 1, this.Bounds.height - 1);
  130.          this.field_0.drawString("Image not defined", 3, 12);
  131.       }
  132.  
  133.       var1.drawImage(this.offscreen, 0, 0, (ImageObserver)null);
  134.    }
  135.  
  136.    public void setDimension(int var1, int var2) {
  137.       Dimension var3 = new Dimension(var1, var2);
  138.       this.setDimension(var3);
  139.    }
  140.  
  141.    public void setHeight(int var1) {
  142.       this.setDimension(this.getWidth(), var1);
  143.    }
  144.  
  145.    public int getHeight() {
  146.       return ((Component)this).bounds().height;
  147.    }
  148.  
  149.    public void setDimension(Dimension var1) {
  150.       Dimension var2 = this.minimumSize();
  151.       if (var1.width != var2.width || var1.height != var2.height) {
  152.          this.iwidth = var1.width;
  153.          this.iheight = var1.height;
  154.          ((Component)this).resize(this.iwidth, this.iheight);
  155.          ((Component)this).repaint();
  156.       }
  157.    }
  158.  
  159.    public Dimension getDimension() {
  160.       Dimension var1 = new Dimension(this.iwidth, this.iheight);
  161.       return var1;
  162.    }
  163.  
  164.    public Dimension preferredSize() {
  165.       return this.minimumSize();
  166.    }
  167.  
  168.    public void layout() {
  169.       ((Component)this).repaint();
  170.    }
  171.  
  172.    public void setWidth(int var1) {
  173.       this.setDimension(var1, this.getHeight());
  174.    }
  175.  
  176.    public int getWidth() {
  177.       return ((Component)this).bounds().width;
  178.    }
  179. }
  180.