package mouse;

import java.util.ArrayList;

//http://javascool.gforge.inria.fr/?page=api&api=org/javascool/widgets/CurveOutput.java.html

public class graphique {
	  public static void main(String args[]) {
		    aaapoint p1 = new aaapoint(2,2);
		    aaapoint p2 = new aaapoint(4,6);
		    Rectangle r = new Rectangle(p1,p2);

		    //System.out.println("r " + r + " surface: " + r.surface());  // 8
		    //p1.translater(2,3);

		    // La modification de p1 change la surface du rectangle
		    //System.out.println("r " + r + " surface: " + r.surface());  // 0

		    p1 = new aaapoint(2,2);
		    p2 = new aaapoint(4,6);
		    r = new Rectangle(p1.getX(), p1.getY(), p2.getX(), p2.getY());

		   // System.out.println("r " + r + " surface: " + r.surface());  // 8
		    //p1.translater(2,3);

		    // La modification de p1 n'a pas d'effet sur la surface du rectangle
		    //System.out.println("r " + r + " surface: " + r.surface()); // 8
		    
		    p1 = new aaapoint(2,2);
		    p2 = new aaapoint(4,6);
		    r = new Rectangle(p1.getX(), p1.getY(), p2.getX(), p2.getY());

		    
		    
		    //System.out.println("r " + r + " surface: " + r.surface());  // 8
		    //r.translater(2,3);

		    // La translation de r n'a pas d'effet sur la surface du rectangle
		    // mais ces deux aaapoint ont ete modifie
		    //System.out.println("r " + r + " surface: " + r.surface()); // 8
		    
		    // p1 n'est pas modifie
		    System.out.println("p1 " + p1); // 8		 
		    
		    ArrayList<Rectangle> l= new ArrayList<Rectangle>();
		    l.add(r);
		    
		   // aaapoint p3 = new aaapoint(20,20);
		    //aaapoint p4 = new aaapoint(40,60);
		    //Rectangle r1 = new Rectangle(p3,p4);
		    
		    r = new Rectangle(100,200, 300, 400);
		    l.add(r);
		    System.out.print(r.getY());
		    
		    
		    Object obj = l.get(1);
		    
		    
		  //  l.add(new Rectangle(  new aaapoint(20,20)     , new aaapoint(60,60)));
	
		  //  Object obj = l.get(1);
		    
		  //  System.out.println(l.get(0)); 
		    
		   // for(Rectangle o : l)
		    //{
		    //	System.out.print(0. ); 
		    //}
		
		  }
}




 class aaapoint {
	  private int x;
	  private int y;

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

	  public void translater(int x, int y) {
	    this.x = this.x + x;
	    this.y = this.y + y;
	  }
	  
	  public int compareTo(aaapoint p){
		  if ((this.x == p.x) && (this.y == p.y)){
			  return 0;
		  }
		  else if (this.x < p.x){
			  return -1;
		  }
		  return 1;
	  }

	  public void setX(int x) {
		this.x = x;
	  }

	  public void setY(int y) {
		this.y = y;
	  }

	  public int getX() {
	    return x;
	  }

	  public int getY() {
	    return y;
	  }

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


 class Rectangle {
	  private aaapoint infGauche;
	  private aaapoint supDroit;

	  	private int p1x, p1y, p2x, p2y;
	  
	  public Rectangle() {
		  infGauche = new aaapoint(0,0);
		   supDroit = new aaapoint(1,1);	  
	  }
	  
	  public Rectangle(int x1, int y1, int x2, int y2) {
		  	p1x = x1;
		  	p1y = y1;
		  	p2x = x2;
		  	p2y = y2;
	  }

	   
	  public Rectangle(aaapoint p1, aaapoint p2) {
	    infGauche = p1;
	    supDroit = p2;
	  }

	 public int getY() {
		    return p1x;
		  }
	  
	//  public int surface() {
	 //   return (supDroit.getX() - infGauche.getX())*
	 //           (supDroit.getY() - infGauche.getY());
	 // }

	 // public int compareTo(Rectangle r) {
	//	  if ((this.infGauche.compareTo(r.infGauche) == 0 ) &&
	//			  (this.supDroit.compareTo(r.supDroit) == 0)){
	//		  return 0;
	//	  }
	//	  return (this.infGauche.compareTo(r.infGauche) );
	//  }
	  
	  public void translater (int a, int b){
		  infGauche.setX(infGauche.getX() + a);
		  infGauche.setY(infGauche.getY() + b);
		  supDroit.setX(supDroit.getX() + a);
		  supDroit.setY(supDroit.getY() + b);
	  }

	  public String toString(){
	    return ("inferieur gauche : " + infGauche +
	            " superieur droit : " + supDroit);
	  }


}

