/**
 *
 * Beschreibung
 *
 * @version 1.0 vom 05.10.2012
 * @author 
 */

import java.util.ArrayList;
import java.awt.Graphics;

public class GPolygon extends GeoObject {

    // Anfang Attribute
    private ArrayList<GLine> lines = new ArrayList<GLine>();
    // Ende Attribute

    public GPolygon(ArrayList<GPoint> points) {;
        for (int i = 0; i < points.size()-1; i++) {
            GLine s = new GLine(points.get(i), points.get(i+1));
            lines.add(s);
        } // end of for
        GLine s = new GLine(points.get(points.size()-1), points.get(0));
        lines.add(s);
    }

    // Anfang Methoden
    public boolean dependsOn(GeoObject p) {
        boolean res = false;
        for (GLine b : lines) {
            if (b.dependsOn(p)) {
                res = true;
            } // end of if
        } // end of for
        return res;
    }

    public void draw(Graphics gr) {
        gr.setColor(getColor());
        for (GLine s : lines) {
            s.draw(gr);
        } // end of for
    }

    // Ende Methoden
} // end of GPolygon
