|
Runtime | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.gmf.runtime.draw2d.ui.geometry.PointListUtilities
public class PointListUtilities
A set of utility methods around manipulating PointList objects
Field Summary | |
---|---|
static int |
DEFAULT_BEZIERLINES
Constant that is the default number of lines that a bezier is approximated by as a polyline point list. |
Constructor Summary | |
---|---|
PointListUtilities()
|
Method Summary | |
---|---|
static PointList |
calcSmoothPolyline(PointList points,
int nSmoothFactor,
int nBezierSteps)
Method calcSmoothPolyline. |
static PointList |
calcSmoothPolyline(PointList points,
int nSmoothFactor,
int nBezierSteps,
int nStartIndex,
int nEndIndex)
Calculates the smooth polyline equivalent of the given points list. |
static Point |
calculatePointRelativeToLine(PointList pointList,
int fromLine,
int fromEnd,
boolean isPercentage)
Finds a point relative to the pointList passed in based on the parameters passed in. |
static boolean |
containsPoint(PointList points,
Point point)
Utility method used to check if a point is contained inside a polygon |
static PointList |
copyPoints(PointList pointsFrom)
copyPoints This method is necessary because of an apparrent defect in the getCopy() routine of PointList class. |
static PointList |
createPointsFromRect(Rectangle rBox)
createPointsFromRect |
protected static double |
distanceAlong(java.util.List mySegments,
Point aPoint)
Method distanceAlong. |
static boolean |
findIntersections(PointList points,
PointList poly,
PointList intersections,
PointList distances)
Method findIntersections. |
static int |
findNearestLineSegIndexOfPoint(PointList points,
Point ptCoord)
Method findNearestLineSegIndexOfPoint. |
static java.util.List |
getLineSegments(PointList points)
Method getLineSegments. |
static LineSeg |
getNearestSegment(java.util.List mySegments,
int xCoord,
int yCoord)
Static utility method to get the nearest segment in the polyline from the given coordinates. |
static Point |
getPointsInfimum(PointList points)
Method getPointsSupremum. |
static long |
getPointsLength(PointList points)
Method getPointsLength. |
static Point |
getPointsSupremum(PointList points)
Method getPointsSupremum. |
protected static long |
length(java.util.List mySegments)
Method length. |
static boolean |
normalizeSegments(PointList points)
Normalizes the line segments in the polyline. |
static boolean |
normalizeSegments(PointList points,
int straightLineTolerance)
Normalizes the line segments in the polyline. |
static Point |
pickClosestPoint(PointList points,
Point p)
Assumption: Points in the PointList and Point p lie on the same line. |
static Point |
pickFarestPoint(PointList points,
Point p)
Assumption: Points in the PointList and Point p lie on the same line. |
protected static Point |
pointOn(java.util.List mySegments,
long theDistance,
LineSeg.KeyPoint fromKeyPoint,
Point ptResult)
Method pointOn. |
static Point |
pointOn(PointList points,
long theDistance,
LineSeg.KeyPoint fromKeyPoint,
Point ptResult)
Calculate the point on the polyline given a distance from a key point. |
static PointList |
routeAroundPoint(PointList points,
Point ptCenter,
int nHeight,
int nWidth,
int nSmoothFactor,
int nInclineOffset,
boolean bTop)
Method routeAroundPoint. |
static PointList |
routeAroundPoly(PointList points,
PointList poly,
int nSmoothFactor,
boolean bShortestDistance,
boolean bIncludeIntersectionPoints,
int nBuffer)
Routes this polyline around another polyline that is presumably intersecting with it. |
static PointList |
routeAroundRect(PointList points,
Rectangle rBox,
int nSmoothFactor,
boolean bIncludeIntersectionPoints,
int nBuffer)
Method routeAroundRect. |
protected static double |
segmentDistance(java.util.List mySegments,
LineSeg theSegment,
LineSeg.KeyPoint uptoKeyPoint)
Method segmentDistance. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int DEFAULT_BEZIERLINES
Constructor Detail |
---|
public PointListUtilities()
Method Detail |
---|
public static boolean normalizeSegments(PointList points)
points
- PointList
to be normalized
boolean
true
if segments were changed, false
otherwisepublic static boolean normalizeSegments(PointList points, int straightLineTolerance)
points
- PointList
to normalizestraightLineTolerance
- the tolerance value within which indicates the line is straight in
relative coordinates.
boolean
true
if segments were changed, false
otherwisepublic static Point getPointsSupremum(PointList points)
points
- PointList to calculate the highest point from.
public static Point getPointsInfimum(PointList points)
points
- PointList to calculate the minimum point from.
public static PointList createPointsFromRect(Rectangle rBox)
rBox
- Rectangle to base the PointList from
public static PointList routeAroundRect(PointList points, Rectangle rBox, int nSmoothFactor, boolean bIncludeIntersectionPoints, int nBuffer)
points
- PointList that will be modified to route around the given rectanglerBox
- the Rectangle
around which the routing will occur.nSmoothFactor
- the int
smooth factor to route the line with
0 - None, 15 - some, 30 - lotsbIncludeIntersectionPoints
- the boolean
determining whether to include the
points that intersect with the rectangle in the newly routed polyline.nBuffer
- the int
buffer around the rectangle.
PointList
that is the newly routed version of points
of null
if operation was not successful or if the calculation is not possible.public static java.util.List getLineSegments(PointList points)
LineSeg
objects
points
- PointList to get LineSeg equivalents of.
public static PointList routeAroundPoly(PointList points, PointList poly, int nSmoothFactor, boolean bShortestDistance, boolean bIncludeIntersectionPoints, int nBuffer)
points
- the PointList
that is to be modified based on
the routing calculations made around the poly
parameter.poly
- the PolylinePointList
around which the routing will occur.nSmoothFactor
- the int
smooth factor to route the line with
0 - None, 15 - some, 30 - lotsbShortestDistance
- the boolean
determining whether to use the
shortest distance possible to achieve this or else minimally modify the existing polyline.bIncludeIntersectionPoints
- the boolean
determining whether to include the
points that intersect with the rectangle in the newly routed polyline.nBuffer
- the int
buffer around the rectangle.
PointList
that is the newly routed version of points
of null
if operation was not successful or if the calculation is not possible.public static PointList copyPoints(PointList pointsFrom)
pointsFrom
-
public static final PointList calcSmoothPolyline(PointList points, int nSmoothFactor, int nBezierSteps)
points
- the PointList
that is used to calculate the
smooth point list from.nSmoothFactor
- the int
smooth factor to smooth the line with
0 - None, 15 - some, 30 - lotsnBezierSteps
- the int
number of line steps used to approximate the smooth curve
public static PointList calcSmoothPolyline(PointList points, int nSmoothFactor, int nBezierSteps, int nStartIndex, int nEndIndex)
points
- the PointList
that is used to calculate the smooth bezier approximation.nSmoothFactor
- the int
smooth factor to smooth the line with
0 - None, 15 - some, 30 - lotsnBezierSteps
- the int
number of line steps used to approximate the smooth curvenStartIndex
- the int
index in the line to start from to create the smooth approximationnEndIndex
- the int
index in the line to end at to create the smooth approximation
public static Point pointOn(PointList points, long theDistance, LineSeg.KeyPoint fromKeyPoint, Point ptResult)
points
- the PointList
to calculate the point on the polyline.theDistance
- the long
x coordinate of the pointfromKeyPoint
- the int
constant value indicating the key point
Origin, Terminus, MidpointptResult
- the Point
where the resulting point value is set.
public static long getPointsLength(PointList points)
points
- PointList to calculate the length of.
protected static long length(java.util.List mySegments)
mySegments
- List of line segments to calculate the length of.
public static LineSeg getNearestSegment(java.util.List mySegments, int xCoord, int yCoord)
mySegments
- the List
of LineSeg
objectsxCoord
- the int
x coordinate of the pointyCoord
- the int
y coordinate of the point
LineSeg
by reference which is closest to the given coordinates.protected static Point pointOn(java.util.List mySegments, long theDistance, LineSeg.KeyPoint fromKeyPoint, Point ptResult)
pointOn
.
mySegments
- theDistance
- the long
x coordinate of the pointfromKeyPoint
- the int
constant value indicating the key point
Origin, Terminus, MidpointptResult
- the Point
where the resulting point value is set.
protected static double distanceAlong(java.util.List mySegments, Point aPoint)
mySegments
- aPoint
- Point to calculate the distance along the polyline of.
protected static double segmentDistance(java.util.List mySegments, LineSeg theSegment, LineSeg.KeyPoint uptoKeyPoint)
mySegments
- theSegment
- uptoKeyPoint
-
public static PointList routeAroundPoint(PointList points, Point ptCenter, int nHeight, int nWidth, int nSmoothFactor, int nInclineOffset, boolean bTop)
points
- PointList to modifyptCenter
- the Point
around which the routing will occur.nHeight
- the int
height to route around the point.nWidth
- the int
width to route around the point.nSmoothFactor
- the int
smooth factor to route the line with
0 - None, 15 - some, 30 - lotsnInclineOffset
- the int
amount to incline the routed points.bTop
- the boolean
route above or below the point on the line.
PointList
that is the newly routed version of points
of null
if operation was not successful or if the calculation is not possible.public static int findNearestLineSegIndexOfPoint(PointList points, Point ptCoord)
points
- PointList to calculate the nearest line segment of.ptCoord
- the Point
to test containment of.
public static boolean findIntersections(PointList points, PointList poly, PointList intersections, PointList distances)
points
- PointList to calculate interesections with.poly
- the PointList
to calculate intersections with.intersections
- the PointList
containing the resulting calculated
intersection points.distances
- the PointList
containing point values representing the
distance along the polyline the intersections occur.
public static Point calculatePointRelativeToLine(PointList pointList, int fromLine, int fromEnd, boolean isPercentage)
pointList
- the PointList
fromLine
- distance off the linefromEnd
- distance from the starting point of the line (i.e. distance from source end along the line)isPercentage
- is the fromEnd given as a percentage?
public static Point pickClosestPoint(PointList points, Point p)
PointList
and Point
p lie on the same line.
Returns the Point
from the PointList
closest to @param p
points
- - the list of points to select the result fromp
- - the point to which the closest point must be found
Point
from the PointList
closest to @param ppublic static Point pickFarestPoint(PointList points, Point p)
PointList
and Point
p lie on the same line.
Returns the Point
from the PointList
closest to @param p
points
- - the list of points to select the result fromp
- - the point to which the closest point must be found
Point
from the PointList
closest to @param ppublic static boolean containsPoint(PointList points, Point point)
points
- the polygonpoint
- point to check
|
Runtime | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Guidelines for using Eclipse APIs.
Copyright (c) IBM Corp., Borland Software Corp., and others 2005,2006. All rights reserved.