package uk.ac.liv.comp285.cw1;
import uk.ac.liv.comp285.cw1.shapes.Point;
public abstract class Shape implements IShape {
protected double angle;
protected Point rotationOrigin;
private Point scaleOrigin;
private double scaleX;
private double scaleY;
public Shape() {
if (CanvasFrame.getPanelCanvas()!=null) {
CanvasFrame.getPanelCanvas().addShape(this);
}
}
public boolean doesCollide(IShape shape) {
Point lowerLeft1=shape.getLowerLeftPoint();
Point upperRight1=shape.getUpperRightPoint();
Point lowerLeft2=getLowerLeftPoint();
Point upperRight2=getUpperRightPoint();
if (upperRight1.getX()
return(false); // no over lap horizontal
}
if (upperRight1.getY()
return(false); // no over lap vertical
}
return(true);
}
@Override
public void setRotation(Point origin, double angle) {
this.angle=angle;
this.rotationOrigin=origin;
}
@Override
public void setScale(Point p,double scaleX,double scaleY) {
this.scaleOrigin=p;
this.scaleX=scaleX;
this.scaleY=scaleY;
}
public Point getScaleOrigin() {
return scaleOrigin;
}
public double getScaleX() {
return scaleX;
}
public double getScaleY() {
return scaleY;
}
}