1
我有一個雙矩陣,我使用HeatMap類構建了一個heatMap(http://www.mbeckler.org/heatMap/)。當鼠標移動到圖像上時,我使用MouseMotionListener獲取鼠標位置。由於實際的熱圖比熱圖板小,我設定的座標範圍爲獲取鼠標座標(詳情上一個問題:MouseListener for HeatMap in Java HeatMap Panel)位置使用MouseMotionListener在heatMap上的雙矩陣座標
鼠標事件追蹤鼠標移動看起來是這樣的:
public void mouseMoved(MouseEvent e) {
if(e.getPoint().x >= 31 && e.getPoint().y >= 31 && e.getPoint().x <= intensityMap.getWidth()-31 && e.getPoint().y <= intensityMap.getHeight()-31) {
int maxX = (intensityMap.getWidth() - 31)-31;
int maxY = (intensityMap.getHeight() - 31)-31;
intensityMap.add(coordinates);
coordinates.setText("(x,y) = " + "(" + (e.getPoint().x - 31) + "," + (e.getPoint().y - 31) + ")");
coordinates.revalidate();
coordinates.repaint();
}
}
現在,我想將這些鼠標座標位置轉換爲用於繪製heatMap的雙重矩陣的座標位置。根據鼠標事件的總行數是235,總列數是128.雙矩陣的尺寸是37,32。我怎樣才能在heatMap上映射雙重矩陣的座標?