Merge banaan en develop

This commit is contained in:
Yorick
2015-04-07 11:35:05 +02:00
11 changed files with 378 additions and 140 deletions
+12 -31
View File
@@ -19,7 +19,6 @@ public abstract class DrawObject
double rotation;
double scale;
private Image image;
private Image rotateImage;
protected boolean selected;
private Rectangle2D rektAngle;
private Rectangle2D upperLeftCorner;
@@ -36,7 +35,6 @@ public abstract class DrawObject
public DrawObject(String filename, Point2D position)
{
image = new ImageIcon(filename).getImage();
rotateImage = new ImageIcon("rotate.png").getImage();
scale = 1;
rotation = 0;
this.position = position;
@@ -55,7 +53,7 @@ public abstract class DrawObject
// image.getHeight(null)/2);
AffineTransform rotate = AffineTransform.getRotateInstance(Math.toRadians(rotation), position.getX() + image.getWidth(null) / 2, position.getY() + image.getHeight(null) / 2);
g.transform(rotate);
//g.transform(rotate);
g.setColor(rectangleColor);
g.setStroke(new BasicStroke(7));
rektAngle = new Rectangle2D.Double((int) position.getX(), (int) position.getY(), image.getWidth(null), image.getHeight(null));
@@ -163,38 +161,17 @@ public abstract class DrawObject
}
/**
*
* @param corners
* @return if there is a collision
* Checking collision.
* @param object. the drawObject to check collision with.
* @return if there is a collision.
*/
public boolean collision(DrawObject object)
{
// Point2D[] ownCorners = getCorners();
Point2D[] objectCorners = object.getCorners();
Shape ownShape = new Rectangle2D.Double(-9, -9, image.getWidth(null) + 13, image.getHeight(null) + 13);
ownShape = getTransformSelection().createTransformedShape(ownShape);
// Shape otherShape = new Rectangle2D.Double(-9,
// -9,object.getImage().getWidth(null) +
// 13,object.getImage().getHeight(null) + 13);
// otherShape =
// getTransformSelection().createTransformedShape(otherShape);
if (ownShape.contains(objectCorners[0]))
Shape ownShape = getRectangle();
Rectangle2D otherRectangle = object.getTransform().createTransformedShape(object.getImageRectangle()).getBounds2D();
if(ownShape.intersects(otherRectangle))
return true;
else if (ownShape.contains(objectCorners[1]))
return true;
else if (ownShape.contains(objectCorners[2]))
return true;
else if (ownShape.contains(objectCorners[3]))
return true;
// if(otherShape.contains(ownCorners[0]))
// return true;
// else if(otherShape.contains(ownCorners[1]))
// return true;
// else if(otherShape.contains(ownCorners[2]))
// return true;
// else if(otherShape.contains(ownCorners[3]))
// return true;
else
else
return false;
}
@@ -305,5 +282,9 @@ public abstract class DrawObject
{
this.rectangleColor = rectangleColor;
}
public Rectangle2D getImageRectangle() {
return new Rectangle2D.Double(0,0, image.getWidth(null), image.getHeight(null));
}
}