home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / Share / Java / CoolMap / HINTPOT.CLA (.txt) < prev    next >
Encoding:
Java Class File  |  1996-09-17  |  4.7 KB  |  213 lines

  1. import java.applet.AudioClip;
  2. import java.awt.Polygon;
  3. import java.net.MalformedURLException;
  4. import java.net.URL;
  5. import java.util.StringTokenizer;
  6.  
  7. class hintpot {
  8.    public Polygon polyMyArea = new Polygon();
  9.    public imgarea m_parent;
  10.    public String szHint;
  11.    public String szURLDescription;
  12.    public URL uURL;
  13.    public String auSourceName;
  14.    public AudioClip auSource;
  15.    public int audioMode;
  16.    public int openMode;
  17.    private boolean bHintVisible = false;
  18.    private boolean bUseFrame = false;
  19.    public String szFrame;
  20.    public boolean bInitialised = false;
  21.    public boolean bUsed = true;
  22.  
  23.    public hintpot() {
  24.    }
  25.  
  26.    public hintpot(String var1, imgarea var2) {
  27.       int var3 = 0;
  28.       int var4 = 0;
  29.       int var5 = 0;
  30.       int var6 = 0;
  31.       int var7 = 0;
  32.       int var8 = 0;
  33.       String var9 = "";
  34.       boolean var10 = false;
  35.       this.m_parent = var2;
  36.       StringTokenizer var11 = new StringTokenizer(var1, "#");
  37.  
  38.       try {
  39.          this.szURLDescription = var11.nextToken();
  40.       } catch (Exception var20) {
  41.          this.szHint = "Unable to determine URL";
  42.       }
  43.  
  44.       if (this.szHint != null && this.szHint.equals("No tooltips")) {
  45.          this.szHint = null;
  46.       }
  47.  
  48.       try {
  49.          this.auSourceName = var11.nextToken();
  50.       } catch (Exception var19) {
  51.          this.szHint = "Unable to determine audio file";
  52.       }
  53.  
  54.       try {
  55.          this.audioMode = Integer.valueOf(var11.nextToken());
  56.       } catch (Exception var18) {
  57.          this.szHint = "Unable to determine audio mode";
  58.       }
  59.  
  60.       try {
  61.          this.openMode = Integer.valueOf(var11.nextToken());
  62.       } catch (Exception var17) {
  63.          this.szHint = "Unable to determine open mode";
  64.       }
  65.  
  66.       try {
  67.          this.szFrame = var11.nextToken();
  68.       } catch (Exception var16) {
  69.          this.szHint = "Unable to determine title";
  70.       }
  71.  
  72.       try {
  73.          this.uURL = new URL(this.m_parent.m_parent.getDocumentBase(), this.szURLDescription);
  74.       } catch (MalformedURLException var15) {
  75.          this.uURL = null;
  76.       }
  77.  
  78.       if (this.uURL != null) {
  79.          this.szURLDescription = this.uURL.toString();
  80.       } else {
  81.          this.szURLDescription = "Invalid URL";
  82.       }
  83.  
  84.       if (this.szURLDescription != null) {
  85.          try {
  86.             var3 = Integer.parseInt(var11.nextToken());
  87.             var6 = Integer.parseInt(var11.nextToken());
  88.             var4 = Integer.parseInt(var11.nextToken());
  89.             var7 = Integer.parseInt(var11.nextToken());
  90.          } catch (Exception var14) {
  91.             this.szURLDescription = null;
  92.             this.debug("Error: At least two points must be specified for hintpot '" + this.szHint + "'");
  93.          }
  94.  
  95.          try {
  96.             var5 = Integer.parseInt(var9 = var11.nextToken());
  97.             var8 = Integer.parseInt(var11.nextToken());
  98.          } catch (Exception var13) {
  99.             var10 = true;
  100.          }
  101.  
  102.          if (var10) {
  103.             this.polyMyArea.addPoint(var3, var6);
  104.             this.polyMyArea.addPoint(var4, var6);
  105.             this.polyMyArea.addPoint(var4, var7);
  106.             this.polyMyArea.addPoint(var3, var7);
  107.             this.bInitialised = true;
  108.          } else {
  109.             this.polyMyArea.addPoint(var3, var6);
  110.             this.polyMyArea.addPoint(var4, var7);
  111.             this.polyMyArea.addPoint(var5, var8);
  112.  
  113.             while(!this.bInitialised) {
  114.                try {
  115.                   var3 = Integer.parseInt(var9 = var11.nextToken());
  116.                   var6 = Integer.parseInt(var11.nextToken());
  117.                   this.polyMyArea.addPoint(var3, var6);
  118.                } catch (Exception var12) {
  119.                   this.bInitialised = true;
  120.                }
  121.             }
  122.          }
  123.  
  124.          if (!var9.equals("")) {
  125.             this.szHint = var9;
  126.          }
  127.       }
  128.  
  129.    }
  130.  
  131.    public void copy(hintpot var1) {
  132.       this.polyMyArea = var1.polyMyArea;
  133.       this.m_parent = var1.m_parent;
  134.       this.szHint = var1.szHint;
  135.       this.szURLDescription = var1.szURLDescription;
  136.       this.uURL = var1.uURL;
  137.       this.bHintVisible = var1.bHintVisible;
  138.       this.bUseFrame = var1.bUseFrame;
  139.       this.szFrame = var1.szFrame;
  140.       this.bInitialised = var1.bInitialised;
  141.       this.bUsed = var1.bUsed;
  142.    }
  143.  
  144.    public boolean MouseMove(int var1, int var2, int var3) {
  145.       if (this.m_parent.makeStatic > 0) {
  146.          return true;
  147.       } else {
  148.          if (this.polyMyArea.inside(var1, var2)) {
  149.             this.m_parent.setStatusText(this.szURLDescription, true);
  150.             this.m_parent.setNewHintText(this.szHint);
  151.             if (this.m_parent.m_parent.mapMode == 1 && this.m_parent.selHotAreaIndex != var3) {
  152.                this.m_parent.preHotAreaIndex = this.m_parent.selHotAreaIndex;
  153.                this.m_parent.selHotAreaIndex = var3;
  154.             }
  155.  
  156.             if (!this.bHintVisible) {
  157.                this.bHintVisible = true;
  158.             }
  159.  
  160.             if (this.m_parent.bHintChanged) {
  161.                this.m_parent.m_parent.mapImageArea.preHotAreaIndex = -1;
  162.                if (this.audioMode == 0 && this.auSource != null && common.soundOff == 0) {
  163.                   this.auSource.play();
  164.                }
  165.  
  166.                this.m_parent.parseHint();
  167.                this.m_parent.m_parent.m_common.setTheCursor(12);
  168.             }
  169.          } else {
  170.             this.m_parent.setStatusText(this.szURLDescription, false);
  171.             if (this.bHintVisible) {
  172.                this.bHintVisible = false;
  173.             }
  174.          }
  175.  
  176.          return this.bHintVisible;
  177.       }
  178.    }
  179.  
  180.    public void MouseUp(int var1, int var2) {
  181.       if (this.polyMyArea.inside(var1, var2) && this.bHintVisible) {
  182.          URL var3;
  183.          if (this.m_parent.m_parent.m_common.disableLevel == 2) {
  184.             this.m_parent.m_parent.mapImageArea.szHintText = "CoolMap is fetching " + this.m_parent.m_parent.m_common.homeURL + ".  Please wait...";
  185.             var3 = this.m_parent.m_parent.m_common.uhomeURL;
  186.          } else {
  187.             this.m_parent.m_parent.mapImageArea.szHintText = "CoolMap is fetching " + this.szURLDescription + ".  Please wait...";
  188.             var3 = this.uURL;
  189.          }
  190.  
  191.          this.m_parent.m_parent.mapImageArea.makeStatic = 1;
  192.          this.m_parent.m_parent.mapImageArea.parseHint();
  193.          this.m_parent.m_parent.mapImageArea.paint(this.m_parent.m_parent.gcOn);
  194.          if (this.audioMode == 1 && this.auSource != null && common.soundOff == 0) {
  195.             this.auSource.play();
  196.          }
  197.  
  198.          if (this.openMode == 1) {
  199.             this.m_parent.m_parent.getAppletContext().showDocument(var3, "_blank");
  200.          } else {
  201.             this.m_parent.m_parent.getAppletContext().showDocument(var3);
  202.          }
  203.  
  204.          this.m_parent.m_parent.showStatus("Fetching " + this.szURLDescription);
  205.       }
  206.  
  207.    }
  208.  
  209.    private void debug(String var1) {
  210.       this.debug(var1);
  211.    }
  212. }
  213.