/**
* Draws a sequence of connected lines defined by
* arrays of <i>x</i> and <i>y</i> coordinates.
* Each pair of (<i>x</i>, <i>y</i>) coordinates defines a point.
* The figure is not closed if the first point
* differs from the last point.
* @param xPoints an array of <i>x</i> points
* @param yPoints an array of <i>y</i> points
* @param nPoints the total number of points
* @see java.awt.Graphics#drawPolygon(int[], int[], int)
* @since 1.1
*/
public void drawPolyline(int xPoints[], int yPoints[],
int nPoints) {
if (nPoints == 2) {
draw(new Line2D.Float(xPoints[0], yPoints[0],
xPoints[1], yPoints[1]));
} else if (nPoints > 2) {
Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD, nPoints);
path.moveTo(xPoints[0], yPoints[0]);
for(int i = 1; i < nPoints; i++) {
path.lineTo(xPoints[i], yPoints[i]);
}
draw(path);
}
}
PathGraphics.java 文件源码
java
阅读 28
收藏 0
点赞 0
评论 0
项目:openjdk-jdk10
作者:
评论列表
文章目录