⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 polyline.java

📁 Java Classic Examples是我买的两本书:《JAVA经典实例》和《java入门经典源代码》里边附送光盘里带的源码
💻 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 + -