import java.awt.Graphics2D;
import java.awt.geom.*;
import java.awt.*;

public class GBlock extends Block implements Draggable {
   private float width, height;
   private Color color = Color.GRAY;
   private Color colordef=Color.gray;
   Ellipse2D.Float ellipse = null;
   public GBlock (float mass, Vector2D position, Vector2D speed, 
                  float width, float height){
      super(mass, position,speed);
      this.width = width;
      this.height = height;
      ellipse = new Ellipse2D.Float((float)pos_t.getX()-width/2, (float)pos_t.getY()-height/2, width, height);
      fixer=false;
   }
   
   public void draw (Graphics2D g){
      ellipse.setFrame((float)pos_t.getX()-width/2, (float)pos_t.getY()-height/2, width, height);
      g.setColor(color);
      g.fill(ellipse);
   }
   
   public boolean contains (double x, double y){
      return ellipse.contains(x,y);
   }
   
   public boolean contains (Vector2D v) {
      return ellipse.contains(v.getX(), v.getY());
   }
   
   public void drag(double x, double y){
      pos_t = new Vector2D(x,y);
   }
   
   /**
    * Metodo para cambiar el color de una masa cuando se selecciona para graficar
    * @param t Parametro true o false dependiendo si esa masa se grafica o no
    */
   public void plot(boolean t){
	   if(t) colordef=Color.blue;
	   else colordef=Color.gray;
	   color=colordef;
   }  
   
   public void setSelectedColor (){
      color = Color.RED;
   }
   
   public void setDefaultColor() {
      color = colordef;
   }
   
   public void attachNearElement(double x, double y, BlockSpringConfiguration bsc){
   }
}
