if (shape.isVisible()) {
Bounds transformedBounds = shape.getTransformedBounds();
// Translate bounds to group coordinates
Point origin = shape.getOrigin();
transformedBounds = transformedBounds.translate(origin.x, origin.y);
if (transformedBounds.contains(x, y)) {
// Transform location into shape coordinates
AffineTransform affineTransform = shape.getTransforms().getAffineTransform();
java.awt.Point location = new java.awt.Point(x - origin.x, y - origin.y);