home *** CD-ROM | disk | FTP | other *** search
Java Source | 1996-08-14 | 1.0 KB | 50 lines |
- // Zone.java
- // 23.02.96
- //
- // a zone
-
- package cybcerone.orient;
-
- import java.awt.Rectangle;
-
- import cybcerone.utils.Scaler;
-
- /**
- * A named zone on a map.
- */
- public class Zone {
- private Rectangle placement;
- private String name;
-
- public Zone (String name, Rectangle placement) {
- this.name = name;
- this.placement = placement;
- }
-
- public Zone (String name, int x1, int y1, int x2, int y2) {
- this (name, Scaler.scale (x1, y1, x2-x1, y2-y1));
- }
-
- /**
- * of the form: xxxx:yyyy:wwww:hhhh:child
- */
- public Zone (String text) {
- this (text.substring (20),
- Integer.parseInt (text.substring (0, 4)),
- Integer.parseInt (text.substring (5, 9)),
- Integer.parseInt (text.substring (10, 14)),
- Integer.parseInt (text.substring (15, 19)));
- }
-
- public Rectangle getCoords () { return placement; }
- public String getName () { return name; }
-
- public String toString () {
- return ("Zone[" + name + ", " + placement + "]");
- }
-
- public boolean inside (int x, int y) {
- return placement.inside (x, y);
- }
- }
-