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; 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); } 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); } public void setSelectedColor (){ color = Color.RED; } public void setDefaultColor() { color = Color.GRAY; } public void attachNearElement(double x, double y, BlockSpringConfiguration bsc){ } }