org.microemu.device.impl
Class Polygon

java.lang.Object
  extended by org.microemu.device.impl.Shape
      extended by org.microemu.device.impl.Polygon
All Implemented Interfaces:
java.lang.Cloneable

public class Polygon
extends org.microemu.device.impl.Shape

This class is intended for storing georaphical polygons such as boundary data for wards, coastlines etc.

Extracted from uk.ac.leeds.ccg.geotools.GeoPolygon

Since:
0.5.0
Author:
James Macgill, Mathieu Van Loon - getPointsAsArrayX, getPointsAsArrayY, dropVector

Field Summary
 int npoints
          Number of points in polygon.
 int[] xpoints
          Array of points.
 int[] ypoints
          Array of points.
 
Constructor Summary
Polygon()
          Create an empty polygon.
Polygon(int[] xpoints, int[] ypoints, int npoints)
          Construct a polygon with full details.
Polygon(Polygon poly)
          Construct a GeoPolygon based on an existing GeoPolygon.
 
Method Summary
 void addPoint(int x, int y)
          Add a vertex to the polygon.
 boolean contains(int x, int y)
          Tests to see if a point is contained by this polygon.
 org.microemu.device.impl.Rectangle getBounds()
           
 
Methods inherited from class org.microemu.device.impl.Shape
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

npoints

public int npoints
Number of points in polygon.


xpoints

public int[] xpoints
Array of points.


ypoints

public int[] ypoints
Array of points.

Constructor Detail

Polygon

public Polygon()
Create an empty polygon.


Polygon

public Polygon(int[] xpoints,
               int[] ypoints,
               int npoints)
Construct a polygon with full details.

Parameters:
id - Polygon ID.
xcent - X-coordinate of centroid.
ycent - Y-coordinate of centroid.
xpoints - Array of x values (npoints in size).
ypoints - Array of y values (npoints in size).
npoints - Number of points.

Polygon

public Polygon(Polygon poly)
Construct a GeoPolygon based on an existing GeoPolygon.

Parameters:
poly - GeoPolygon to clone.
Method Detail

addPoint

public void addPoint(int x,
                     int y)
Add a vertex to the polygon.

Parameters:
x - X-coordinate of point to add.
y - Y-coordinate of point to add.

getBounds

public org.microemu.device.impl.Rectangle getBounds()
Specified by:
getBounds in class org.microemu.device.impl.Shape

contains

public boolean contains(int x,
                        int y)
Tests to see if a point is contained by this polygon.

Specified by:
contains in class org.microemu.device.impl.Shape
Parameters:
p - The GeoPoint to test.
Returns:
boolean True if point is contained by this polygon.


Copyright © 2001-2009 MicroEmulator Team. All Rights Reserved.