Dear users, Please note that, from Monday, August 16, 2019, RSA keys shorter than 2048bit will no longer be accepted for security reasons. Please update your keys as needed before this date. If you need assistance with regard to this process, please contact sia@list.lu

Thank you for your understanding.

Commit 60a0375c authored by Nico Mack's avatar Nico Mack

Bug fix in ShapeBackground inner class of WordCloud corona

parent e42a1115
......@@ -39,6 +39,7 @@ import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;
......@@ -88,20 +89,24 @@ public class WordCloud extends Corona implements InformationReceiver<String> {
private class ShapeBackground implements Background {
private Shape background;
private java.awt.Point shapeCentre;
private Rectangle bounds;
public ShapeBackground(Shape shape) {
this.background = shape;
Rectangle2D bounds = this.background.getBounds2D();
shapeCentre = new java.awt.Point((int) bounds.getWidth() / 2, (int) bounds.getHeight() / 2);
Rectangle2D shapeBounds = shape.getBounds2D();
AffineTransform origin = AffineTransform.getTranslateInstance(-shapeBounds.getX(), -shapeBounds.getY());
this.background = origin.createTransformedShape(shape);
this.bounds = this.background.getBounds();
}
/** {@inheritDoc} */
@Override
public boolean isInBounds(Collidable collidable) {
final java.awt.Point position = (java.awt.Point) collidable.getPosition().clone();
position.translate(-shapeCentre.x, -shapeCentre.y);
return this.background.contains(position);
final java.awt.Point position = collidable.getPosition();
final Dimension size = collidable.getDimension();
final java.awt.Point tail = new java.awt.Point(position.x + size.width, position.y + size.height);
return this.background.contains(position) && this.background.contains(tail);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment