Here you can find the source of drawPolyLine(final Graphics g, final Collection> points)
Parameter | Description |
---|---|
g | the graphics context |
points | a collection of points, anything other than a point in this vector is simply skipped |
public static void drawPolyLine(final Graphics g, final Collection<?> points)
//package com.java2s; import java.awt.Graphics; import java.awt.Point; import java.util.Collection; import java.util.Iterator; public class Main { /**//from www . j av a 2 s.c o m * draw the points on the Graphics Context. Uses Graphics.drawPolyLine. * * @param g the graphics context * @param points a collection of points, anything other than a point in this * vector is simply skipped **/ public static void drawPolyLine(final Graphics g, final Collection<?> points) { final int[] xpoints = new int[points.size()]; final int[] ypoints = new int[points.size()]; int npoints = 0; final Iterator<?> iter = points.iterator(); while (iter.hasNext()) { Object obj = iter.next(); if (obj instanceof Point) { final Point p = (Point) obj; xpoints[npoints] = p.x; ypoints[npoints] = p.y; npoints++; } } g.drawPolyline(xpoints, ypoints, npoints); } }