You can create a Shape
to exactly match the Image
shape, and then use its contains
method to determine if the mouse was clicked inside.
To take into account the Image
rotation, you can apply the corresponding Transform
rotation to the Shape
.
I created a shapeFromImage
method that does this; he gets Image
and its position and returns the corresponding Shape
:
public static Shape shapeFromImage(Image image, float x, float y) {
In your example, you can use it as follows:
float positionX; float positionY; if (angle == 90) { highlightEdge.setCenterOfRotation(highlightEdge.getWidth(), 0); highlightEdge.rotate(new Float(angle)); positionX = testPoint.x - 56; positionY = testPoint.y; highlightEdge.draw(positionX, positionY); } ...
source share