public class PointList extends java.lang.Object implements java.io.Serializable, Translatable
int[]. The array is internal, and is constructed and queried by
the client using Points. SWT uses integer arrays when painting
polylines and polygons.| Constructor and Description |
|---|
PointList()
Constructs an empty PointList.
|
PointList(int size)
Constructs a PointList with initial capacity size, but no points.
|
PointList(int[] points)
Constructs a PointList with the given points.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addAll(PointList source)
Appends all of the given points to this PointList.
|
void |
addPoint(int x,
int y)
Adds the input point values to this PointList.
|
void |
addPoint(Point p)
Adds Point p to this PointList.
|
Rectangle |
getBounds()
Returns the smallest Rectangle which contains all Points.
|
PointList |
getCopy()
Creates a copy
|
Point |
getFirstPoint()
Returns the first Point in the list.
|
Point |
getLastPoint()
Returns the last point in the list.
|
Point |
getMidpoint()
Returns the midpoint of the list of Points.
|
Point |
getPoint(int index)
Returns the Point in the list at the specified index.
|
Point |
getPoint(Point p,
int index)
Copies the x and y values at given index into a specified Point.
|
void |
insertPoint(Point p,
int index)
Inserts a given point at a specified index.
|
boolean |
intersects(Rectangle r)
Determines whether any of the line segments represented by this PointList
intersect the given Rectangle.
|
void |
performScale(double factor)
Scales this object by the scale factor.
|
void |
performTranslate(int dx,
int dy)
Translates this object horizontally by
dx and vertically by
dy. |
boolean |
polygonContainsPoint(int x,
int y) |
boolean |
polylineContainsPoint(int x,
int y,
int tolerance) |
void |
removeAllPoints()
Removes all the points stored by this list.
|
Point |
removePoint(int index)
Removes the point at the specified index from the PointList, and returns
it.
|
void |
reverse()
Reverses the order of the points in the list.
|
void |
setPoint(Point pt,
int index)
Overwrites a point at a given index in the list with the specified Point.
|
void |
setSize(int newSize)
Sets the size of this PointList.
|
int |
size()
Returns the number of points in this PointList.
|
int[] |
toIntArray()
Returns the contents of this PointList as an integer array.
|
void |
translate(int x,
int y)
Moves the origin (0,0) of the coordinate system of all the points to the
Point (x,y).
|
void |
translate(Point pt)
Moves the origin (0,0) of the coordinate system of all the points to the
Point pt.
|
void |
transpose()
Transposes all x and y values.
|
public PointList()
public PointList(int[] points)
points - int array where two consecutive ints form the coordinates of a
pointpublic PointList(int size)
size - Number of points to hold.public void addAll(PointList source)
source - the source pointlistpublic void addPoint(Point p)
p - the point to be addedremovePoint(int)public void addPoint(int x,
int y)
x - X value of a point to addy - Y value of a point to addpublic Rectangle getBounds()
public PointList getCopy()
public Point getFirstPoint()
java.lang.IndexOutOfBoundsException - if the list is emptypublic Point getLastPoint()
java.lang.IndexOutOfBoundsException - if the list is emptypublic Point getMidpoint()
java.lang.IndexOutOfBoundsException - if the list is emptypublic Point getPoint(int index)
index - Index of the desired Pointjava.lang.IndexOutOfBoundsException - If the specified index is out of rangepublic Point getPoint(Point p, int index)
Point.p - The Point which will be set with the <x, y> valuesindex - The index being requestedp is returned for conveniencegetPoint(int)public void insertPoint(Point p, int index)
p - Point to be inserted.index - Position where the point is to be inserted.java.lang.IndexOutOfBoundsException - if the index is invalidsetPoint(Point, int)public boolean intersects(Rectangle r)
r - the rectangletrue if the given rectangle intersects any of the
line segments represented by this PointListpublic void performScale(double factor)
TranslatableperformScale in interface Translatablefactor - The scale factorTranslatable.performScale(double)public void performTranslate(int dx,
int dy)
Translatabledx and vertically by
dy.performTranslate in interface Translatabledx - The amount to translate horizontallydy - The amount to translate verticallyTranslatable.performTranslate(int, int)public void removeAllPoints()
public Point removePoint(int index)
index - Index of the point to be removed.java.lang.IndexOutOfBoundsException - if the removal index is beyond the list capacityaddPoint(Point)public void reverse()
public void setPoint(Point pt, int index)
pt - Point which is to be stored at the index.index - Index where the given point is to be stored.public void setSize(int newSize)
newSize - the new sizepublic int size()
public int[] toIntArray()
public final void translate(Point pt)
pt - Position by which all the points will be shifted.translate(int,int)public void translate(int x,
int y)
x - Amount by which all the points will be shifted on the X axis.y - Amount by which all the points will be shifted on the Y axis.translate(Point)public void transpose()
public boolean polygonContainsPoint(int x,
int y)
x - - X coordinate of the pointy - - Y coordinate of the pointGeometry.polygonContainsPoint(PointList, int, int)public boolean polylineContainsPoint(int x,
int y,
int tolerance)
x - - X coordinate of the pointy - - Y coordinate of the pointtolerance - - allowed distance between point and polyline segmentGeometry.polylineContainsPoint(PointList, int, int, int)Copyright (c) IBM Corp. and others 2000, 2011. All Rights Reserved.