Java Draw Polygon drawPolygons(final Graphics g, final Collection v)

Here you can find the source of drawPolygons(final Graphics g, final Collection v)

Description

draw a bunch of polygons

License

Open Source License

Parameter

Parameter Description
g the graphics context
v a Container of polygons, other classes are ignored

Declaration

public static void drawPolygons(final Graphics g, final Collection<?> v) 

Method Source Code

//package com.java2s;

import java.awt.Graphics;

import java.awt.Polygon;

import java.util.Collection;
import java.util.Iterator;

public class Main {
    /**/*from  w ww  .ja va2  s . c  om*/
     * draw a bunch of polygons
     * 
     * @param g the graphics context
     * @param v a Container of polygons, other classes are ignored
     **/
    public static void drawPolygons(final Graphics g, final Collection<?> v) {
        drawPolygons(g, v.iterator());
    }

    /**
     * draw a bunch of polygons
     * 
     * @param g the graphics context
     * @param iter an Enumeration of polygons, other classes are ignored
     **/
    public static void drawPolygons(final Graphics g, final Iterator<?> iter) {
        while (iter.hasNext()) {
            final Object obj = iter.next();
            if (obj instanceof Polygon) {
                g.drawPolygon((Polygon) obj);
            }
        }
    }
}

Related

  1. drawPolygon(final Point2D[] points, final Graphics2D g2d, final Paint paint, final boolean fill)