📄 polyline.java
字号:
import java.util.*;
public class PolyLine
{
// Construct a polyline from an array of points
public PolyLine(Point[] points)
{
// Add the points
for(int i = 0; i < points.length; i++)
polyline.add(points[i]);
}
// Construct a polyline from an array of coordinate
public PolyLine(double[][] coords)
{
// Add the points
for(int i = 0; i < coords.length; i++)
polyline.add(new Point(coords[i][0], coords[i][1]));
}
// Add a Point object to the list
public void addPoint(Point point)
{
polyline.add(point); // Add the new point
}
// Add a point to the list
public void addPoint(double x, double y)
{
polyline.add(new Point(x, y));
}
// String representation of a polyline
public String toString()
{
StringBuffer str = new StringBuffer("Polyline:");
Iterator points = polyline.iterator(); // Get an iterator
while(points.hasNext())
str.append(" "+ (Point)points.next()); // Append the current point
return str.toString();
}
private LinkedList polyline = new LinkedList(); // Stores points for polyline
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -