java - How to detect mouse over on drawn image with awt.Graphics.drawImage() when transformed -
in java swing panel draw image arbitrary transfomation e.g.: public void paintcomponent(graphics g){ affinetransform transform = affinetransform.gettranslateinstance(x, y); affinetransform rotateinstance affinetransform.getrotateinstance(rotx, roty); transform.concatenate(rotateinstance); g.settransform(transform); g.drawimage(image, 0, 0 , null); } what best way detect mouse on over such image? even better: best way detect mouse on over non-transparent pixels? construct shape encloses image, , use affinetransform method createtransformedshape() rotate shape along image. shape method contains() allow position testing in component relative coordinates. complete examples seen here , here . 2 approaches inverse coordinate transformation cited here .