home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 October / PCO1097.ISO / FilesBBS / WIN95 / IMAP.EXE / IMapArea.class (.txt) < prev    next >
Encoding:
Java Class File  |  1997-09-02  |  3.1 KB  |  145 lines

  1. import java.awt.Polygon;
  2. import java.awt.Rectangle;
  3. import java.net.URL;
  4. import java.util.Vector;
  5.  
  6. class IMapArea {
  7.    private static final int RECT = 1;
  8.    private static final int ELLIPSE = 2;
  9.    private static final int POLY = 3;
  10.    private int shape;
  11.    private Rectangle rect;
  12.    // $FF: renamed from: x int
  13.    private int field_0;
  14.    // $FF: renamed from: y int
  15.    private int field_1;
  16.    // $FF: renamed from: a int
  17.    private int field_2;
  18.    // $FF: renamed from: b int
  19.    private int field_3;
  20.    private Polygon poly;
  21.    public URL url;
  22.    public String target;
  23.    public String status;
  24.    private Vector text = new Vector(10, 5);
  25.    private Vector indent = new Vector(10, 5);
  26.    private int count;
  27.    public int width;
  28.    public int height;
  29.  
  30.    public IMapArea(Rectangle var1) {
  31.       this.shape = 1;
  32.       this.rect = var1;
  33.    }
  34.  
  35.    public IMapArea(int var1, int var2, int var3, int var4) {
  36.       this.shape = 2;
  37.       this.field_0 = var1;
  38.       this.field_1 = var2;
  39.       this.field_2 = Math.abs(var3);
  40.       this.field_3 = Math.abs(var4);
  41.    }
  42.  
  43.    public IMapArea(Polygon var1) {
  44.       this.shape = 3;
  45.       this.poly = var1;
  46.    }
  47.  
  48.    public boolean isRect() {
  49.       return this.shape == 1;
  50.    }
  51.  
  52.    public boolean isEllipse() {
  53.       return this.shape == 2;
  54.    }
  55.  
  56.    public boolean isPoly() {
  57.       return this.shape == 3;
  58.    }
  59.  
  60.    public Rectangle getRect() {
  61.       return this.isRect() ? this.rect : new Rectangle();
  62.    }
  63.  
  64.    public Rectangle getEllipse() {
  65.       return this.isEllipse() ? new Rectangle(this.field_0 - this.field_2, this.field_1 - this.field_3, this.field_2 * 2, this.field_3 * 2) : new Rectangle();
  66.    }
  67.  
  68.    public Polygon getPoly() {
  69.       return this.isPoly() ? this.poly : new Polygon();
  70.    }
  71.  
  72.    public Rectangle getBoundingBox() {
  73.       Rectangle var1 = new Rectangle();
  74.       if (this.isRect()) {
  75.          var1 = this.rect;
  76.       }
  77.  
  78.       if (this.isEllipse()) {
  79.          var1 = this.getEllipse();
  80.       }
  81.  
  82.       if (this.isPoly()) {
  83.          var1 = this.poly.getBoundingBox();
  84.       }
  85.  
  86.       return var1;
  87.    }
  88.  
  89.    public void setURL(URL var1) {
  90.       this.url = var1;
  91.    }
  92.  
  93.    public void setURL(URL var1, String var2) {
  94.       this.url = var1;
  95.       this.target = var2;
  96.    }
  97.  
  98.    public void setStatusMsg(String var1) {
  99.       this.status = var1;
  100.    }
  101.  
  102.    public boolean inside(int var1, int var2) {
  103.       if (this.isRect()) {
  104.          return this.rect.inside(var1, var2);
  105.       } else {
  106.          if (this.isEllipse()) {
  107.             var1 -= this.field_0;
  108.             var2 -= this.field_1;
  109.             if (Math.abs(var1) > this.field_2 || Math.abs(var2) > this.field_3) {
  110.                return false;
  111.             }
  112.  
  113.             double var3 = (double)((int)((double)this.field_3 * Math.sqrt((double)1.0F - (double)(var1 * var1) / (double)(this.field_2 * this.field_2))));
  114.             if ((double)Math.abs(var2) <= var3) {
  115.                return true;
  116.             }
  117.          }
  118.  
  119.          if (this.isPoly()) {
  120.             return this.poly.inside(var1, var2);
  121.          } else {
  122.             return false;
  123.          }
  124.       }
  125.    }
  126.  
  127.    public void addText(int var1, String var2) {
  128.       this.indent.addElement(new Integer(var1));
  129.       this.text.addElement(var2);
  130.       ++this.count;
  131.    }
  132.  
  133.    public String getText(int var1) {
  134.       return var1 >= 0 && var1 < this.count ? (String)this.text.elementAt(var1) : null;
  135.    }
  136.  
  137.    public int getIndent(int var1) {
  138.       return var1 >= 0 && var1 < this.count ? Integer.parseInt(this.indent.elementAt(var1).toString()) : 0;
  139.    }
  140.  
  141.    public int getCount() {
  142.       return this.count;
  143.    }
  144. }
  145.