
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Polygon;
import java.util.*;


public class PolygonSommet 
{
	private int 				x,y;
	private boolean    	        selected;
	
	public PolygonSommet() 
	{
		
	}
	
	public PolygonSommet(int x, int y) 
    {
		this.x = x;
		this.y = y;
		this.selected = false;
    }
	
	 public void draw_polygon_sommet(Graphics g) 
	 {
		 if(selected == true)
		 {
			 g.setColor(Color.red);
		 }
		 else
		 {	 
			 g.setColor(Color.black);
		 }
		 
         g.fillOval(x - 5, y - 5, 10, 10);
         
         /*
         g.setColor(Color.black);
         Iterator iterA = Arete.iterator();
         while (iterA.hasNext()) {
             Arete a = (Arete) iterA.next();
             g.drawLine(a.getOrig().getX(), a.getOrig().getY(), a.getExtr()
                     .getX(), a.getExtr().getY());
         }*/
         
	 }
	 
	 public int getX() { return x; }
	 public int getY() { return y; }
	 
	 public Boolean getSelected() {  return selected; }
	 public void SetSelected(Boolean status) { selected = status; }
	 
	 public void draw_polygon_segment(Graphics g, Polygon p)
	 {
         g.setColor(Color.black);
         g.drawPolygon(p);

         
         //https://www.geeksforgeeks.org/draw-polygon-java-applet/
         
      // join the adjacent vertices 
    //     for (int i = 0; i < numberofpoints - 1; i++) 
    //         g.drawLine(x[i], y[i], x[i + 1], y[i + 1]); 
   
         // join the first and last vertex 
     //    g.drawLine(x[0], y[0], x[numberofpoints - 1], y[numberofpoints - 1]); 
         
        // int xpoints[] = {25, 145, 25, 145, 25};
        // int ypoints[] = {25, 25, 145, 145, 25};
        // int npoints = 5;
         
        // g.drawPolygon(xpoints, ypoints, npoints);

         //while (iterA.hasNext()) 
         //{
         //    g.drawLine(a.getOrig().getX(), a.getOrig().getY(), a.getExtr() .getX(), a.getExtr().getY());
         //}
		 
	 }
}


/*public class PolygonSommet 
{
    private int x, y;
    private String etiquette;
    
    private static Map<String, PolygonSommet> tousLesSommets = new HashMap<String, PolygonSommet>();

    public PolygonSommet(String etiquette, int x, int y) 
    {
        this.etiquette = etiquette;
        setPosition(x, y);
        tousLesSommets.put(etiquette, this);
    }

    public PolygonSommet(int x, int y) {
        this("s" + tousLesSommets.size(), x, y);
    }

    public void setPosition(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public int getX() {
        return x;
    }

    public int getY() {
        return y;
    }

    public String getEtiquette() {
        return etiquette;
    }

    public void setEtiquette(String etiquette) {
        tousLesSommets.remove(this.etiquette);
        this.etiquette = etiquette;
        tousLesSommets.put(etiquette, this);
    }

    public String toString() {
        return "\"" + etiquette + "\" " + x + " " + y;
    }

    public boolean equals(Object o) {
        return o instanceof PolygonSommet && 
                x == ((PolygonSommet) o).x && y == ((PolygonSommet) o).y;
    }

   

    public static int nombreSommets() 
    {
        return tousLesSommets.size();
    }
    
    public static PolygonSommet trouverSommet(String etiquette) 
    {
        return tousLesSommets.get(etiquette);
    }
    
    public static Iterator<PolygonSommet> iterator() 
    {
        return tousLesSommets.values().iterator();
    }
}*/