home *** CD-ROM | disk | FTP | other *** search
- package netscape.application;
-
- import java.awt.Rectangle;
- import netscape.util.ClassInfo;
- import netscape.util.Codable;
- import netscape.util.CodingException;
- import netscape.util.Decoder;
- import netscape.util.Encoder;
-
- public class Polygon implements Codable {
- public int numPoints;
- public int[] xPoints;
- public int[] yPoints;
- java.awt.Polygon awtPolygon;
- static final String XPOINTS = "xPoints";
- static final String YPOINTS = "yPoints";
-
- public Polygon() {
- this.awtPolygon = new java.awt.Polygon();
- this.update();
- }
-
- public Polygon(int[] var1, int[] var2, int var3) {
- this.awtPolygon = new java.awt.Polygon(var1, var2, var3);
- this.update();
- }
-
- public void addPoint(int var1, int var2) {
- this.awtPolygon.addPoint(var1, var2);
- this.update();
- }
-
- public Rect boundingRect() {
- Rectangle var1 = this.awtPolygon.getBoundingBox();
- Rect var2 = new Rect(var1.x, var1.y, var1.width, var1.height);
- this.update();
- return var2;
- }
-
- public boolean containsPoint(int var1, int var2) {
- boolean var3 = this.awtPolygon.inside(var1, var2);
- this.update();
- return var3;
- }
-
- public boolean containsPoint(Point var1) {
- return this.containsPoint(var1.x, var1.y);
- }
-
- public void moveBy(int var1, int var2) {
- int[] var5;
- for(int var3 = this.awtPolygon.npoints; var3-- > 0; var5[var3] += var2) {
- var5 = this.awtPolygon.xpoints;
- var5[var3] += var1;
- var5 = this.awtPolygon.ypoints;
- }
-
- }
-
- private void update() {
- this.numPoints = this.awtPolygon.npoints;
- this.xPoints = this.awtPolygon.xpoints;
- this.yPoints = this.awtPolygon.ypoints;
- }
-
- public void describeClassInfo(ClassInfo var1) {
- var1.addClass("netscape.application.Polygon", 1);
- var1.addField("xPoints", (byte)9);
- var1.addField("yPoints", (byte)9);
- }
-
- public void encode(Encoder var1) throws CodingException {
- if (this.numPoints != 0) {
- var1.encodeIntArray("xPoints", this.xPoints, 0, this.numPoints);
- var1.encodeIntArray("yPoints", this.yPoints, 0, this.numPoints);
- }
- }
-
- public void decode(Decoder var1) throws CodingException {
- int[] var3 = var1.decodeIntArray("xPoints");
- int[] var4 = var1.decodeIntArray("yPoints");
- if (var3 != null && var3.length != 0) {
- this.numPoints = var3.length;
-
- for(int var2 = 0; var2 < var3.length; ++var2) {
- this.addPoint(var3[var2], var4[var2]);
- }
-
- }
- }
-
- public void finishDecoding() throws CodingException {
- }
- }
-