Java Reference
In-Depth Information
str.append(" "+ nextPoint);
// Output the
current point
nextPoint = nextPoint.getNext();
// Make the next
point current
return str.toString();
private ListPoint start;
// First ListPoint
in the list
private ListPoint end;
// Last ListPoint in
the list
Directory "TryPolyLine"
This source file also goes in the TryPolyLine directory.
You might want to be able to add a point to the list by specifying a coordinate pair. You could overload
the addPoint() method to do this:
// Add a point defined by a coordinate pair to the list
public void addPoint(double x, double y) {
addPoint(new Point(x, y));
Directory "TryPolyLine"
You just created a new Point object in the expression that is the argument to the other version of ad-
dPoint() .
You might also want to create a PolyLine object from an array of coordinates. The constructor to do this
would be:
// Construct a polyline from an array of coordinates
public PolyLine(double[][] coords) {
if(coords != null) {
for(int i = 0; i < coords.length ; ++i) {
addPoint(coords[i][0], coords[i][1]);
Search WWH ::

Custom Search