I am using the Java class HeatMap (by: http://www.mbeckler.org/heatMap/) to generate a heatmap for my matrix. I want to implement a mouselistener which will display the coordinate position (x,y) when the mouse is at some position on the image (heatmap). I have implemented a basic mouse listener for the moment, which shows a message when the mouse pointer is in the HeatMap panel and when it is outside it. But, the problem is, the actual heatmap in the HeatMap panel is smaller than the heatmap panel and also includes a legend. I only want to display the coordinate information when the mouse pointer is hovered on the actual heatmap and not for the area surrounding the heatMap. Can someone help me do this?
Below is the part of code which implements the mouseListener and the HeatMap panel.
public class GUI extends JFrame implements MouseListener {
intensityMap = new HeatMap(dataMatrix, false,HeatMap.Gradient.GRADIENT_Rainbow);
intensityMap.setDrawLegend(true);
intensityMap.addMouseListener(this);
}
public void mouseEntered(MouseEvent e) {
System.out.println("Mouse entered");
}
public void mouseExited(MouseEvent e) {
System.out.println("Mouse exited");
}