import java.awt.geom.*;
import twaver.TWaverConst;
public class CircleParticle extends AbstractParticle {
private double _radius;
@Override
public String getUIClassID() {
return CircleParticleUI.class.getName();
}
public CircleParticle (
double x,
double y,
double radius,
boolean fixed,
double mass,
double elasticity,
double friction) {
super(x, y, fixed, mass, elasticity, friction);
_radius = radius;
if((Double.valueOf(x) != null) && (Double.valueOf(y) != null)){
this.setLocation(x, y);
}
this.putCustomDraw(true);
this.putCustomDrawShapeFactory(TWaverConst.SHAPE_CIRCLE);
}
@Override
public int getWidth() {
// TODO Auto-generated method stub
if(Double.valueOf(_radius) != null){
return (int) _radius*2;
}
return super.getWidth();
}
@Override
public int getHeight() {
// TODO Auto-generated method stub
if(Double.valueOf(_radius) != null){
return (int) _radius*2;
}
return super.getHeight();
}
public double getRadius() {
return _radius;
}
public void setRadius(double r) {
_radius = r;
}
public void paint() {
if(curr.y > 500) return;
if(Math.pow(curr.x+_radius-330,2) + Math.pow(curr.y+_radius-240, 2) > 150*150){
return;
}
this.setLocation((int)(curr.x - getRadius()), (int)(curr.y - getRadius()));
}
public Interval getProjection(Vector axis) {
double c = curr.dot(axis);
interval.min = c - _radius;
interval.max = c + _radius;
return interval;
}
public Interval getIntervalX() {
interval.min = curr.x - _radius;
interval.max = curr.x + _radius;
return interval;
}
public Interval getIntervalY() {
interval.min = curr.y - _radius;
interval.max = curr.y + _radius;
return interval;
}
}