|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.partnersoft.geometry.xy.XyPolygon
public class XyPolygon
A generalized polygon defined as an ordered list of vertices.
The last vertex is automatically reconnected to the first.
Copyright 2007 Partner Software, Inc.
| Constructor Summary | |
|---|---|
XyPolygon(double... coords)
Defines a polygon via a varargs list of x,y coordinates. |
|
XyPolygon(double[] coordsX,
double[] coordsY)
Defines a polygon using a pair of coordinate arrays. |
|
XyPolygon(double[] coords,
int start,
int length)
|
|
XyPolygon(DynamicDoubleArray coords)
|
|
XyPolygon(java.lang.Iterable<XyPoint> points)
Creates a polygon using the iterable set of XyPoint vertices. |
|
XyPolygon(java.util.List<XyPoint> points)
Creates a polygon from an ordered list of XyPoints. |
|
XyPolygon(XyPoint... points)
Creates a polygon using the varargs list of XyPoint vertices. |
|
| Method Summary | |
|---|---|
java.util.List<XyPolygon> |
choppedIntoPiecesWithMaximumVertexCount(int maximumVertexCount)
Breaks this polygon into smaller polygons until none of them have more than the given number of vertices. |
java.util.List<XyPolygon> |
clippedTo(XyBounds bounds)
Clips this polygon and returns the results. |
boolean |
contains(XyPoint point)
Tests if a point is inside this area. |
boolean |
equals(java.lang.Object nother)
|
double |
getArea()
Returns the 2-dimensional area covered by this... |
XyBounds |
getBounds()
Returns an XyBounds object representing the rectangular extents of this shape. |
XyPoint |
getCentroid()
|
int |
getEdgeCount()
|
double |
getPerimeter()
Returns the total length of the lines and/or curves bounding the area. |
XyPoint |
getStartPoint()
|
int |
getVertexCount()
|
java.util.Iterator<XyPoint> |
iterator()
|
XyPolygon |
scaledBy(double factor)
Return a scaled version of the shape by multiplying all coordinates by the given factor in both dimensions. |
XyPolygon |
scaledBy(double factorX,
double factorY)
|
XyPolygon |
simplifiedWithMinimumDistance(double granularity)
Simplify the polygon by eliminating segments shorter than a given length. |
java.awt.Polygon |
toAwtPolygon()
|
double[] |
toDoubleArray()
Converts vertex list to an array of doubles [x0, y0, x1, y1...]. |
XyPoint[] |
toPointArray()
|
XyPolygon |
toPolygon()
Same as XyArea.toPolygon(XyAngle) with a default angle granularity of
1/60 circle (1 degree, pi/30 radians). |
XyPolygon |
toPolygon(XyAngle granularity)
Converts this area to a polygon which approximates it in some fashion. |
XyPolyline |
toPolyline()
|
java.lang.String |
toString()
|
XyPolygon |
transformedBy(XyTransform transform)
Transform the shape using the given transform. |
XyPolygon |
translatedBy(double offsetX,
double offsetY)
Translate the shape by adding all coordinates to the given x and y offsets. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public XyPolygon(DynamicDoubleArray coords)
public XyPolygon(double[] coords,
int start,
int length)
public XyPolygon(double... coords)
public XyPolygon(double[] coordsX,
double[] coordsY)
coordsX - coordsY - public XyPolygon(XyPoint... points)
points - public XyPolygon(java.lang.Iterable<XyPoint> points)
points - public XyPolygon(java.util.List<XyPoint> points)
points - | Method Detail |
|---|
public XyPolyline toPolyline()
public XyPoint[] toPointArray()
public XyPolygon scaledBy(double factor)
XyShape
scaledBy in interface XyShape<XyPolygon>factor - scaling factor
public XyPolygon scaledBy(double factorX,
double factorY)
public XyPolygon translatedBy(double offsetX,
double offsetY)
XyShape
translatedBy in interface XyShape<XyPolygon>offsetX - offset for the x dimensionoffsetY - offset for the y dimension
public XyPolygon transformedBy(XyTransform transform)
XyShape
transformedBy in interface XyShape<XyPolygon>transform - affine transform to apply.
public double[] toDoubleArray()
public java.util.List<XyPolygon> choppedIntoPiecesWithMaximumVertexCount(int maximumVertexCount)
public java.util.List<XyPolygon> clippedTo(XyBounds bounds)
public XyPolygon simplifiedWithMinimumDistance(double granularity)
granularity - size of the discreteness grid applied to eliminate points that
are too closepublic boolean contains(XyPoint point)
This implementation is derived from an example provided by Wm. Randolph Franklin and found on this page.
Here is the license:
License to Use
Copyright (c) 1970-2003, Wm. Randolph Franklin
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
contains in interface XyArea<XyPolygon>point - point to test for containmentpublic XyPolygon toPolygon()
XyAreaXyArea.toPolygon(XyAngle) with a default angle granularity of
1/60 circle (1 degree, pi/30 radians).
toPolygon in interface XyArea<XyPolygon>public XyPolygon toPolygon(XyAngle granularity)
XyAreaThe angle parameter allows a certain level of control of the output. Essentially it dictates the minimum angular granularity used to approximate curved paths. For example, a circle would be turned into a polygon by placing points around the circle, separated by the given angle.
toPolygon in interface XyArea<XyPolygon>public double getArea()
XyArea
getArea in interface XyArea<XyPolygon>public double getPerimeter()
XyArea
getPerimeter in interface XyArea<XyPolygon>public XyBounds getBounds()
XyShape
getBounds in interface XyShape<XyPolygon>public XyPoint getCentroid()
public XyPoint getStartPoint()
public java.util.Iterator<XyPoint> iterator()
iterator in interface java.lang.Iterable<XyPoint>public java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object nother)
equals in class java.lang.Objectpublic java.awt.Polygon toAwtPolygon()
public int getVertexCount()
public int getEdgeCount()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||