1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| private void jXImagePanelMouseWheelMoved(java.awt.event.MouseWheelEvent evt) {
// System.out.println("jXImagePanelMouseWheelMoved");
Point loc = jXImagePanel.getLocation();
Point mousePos = jXImagePanel.getMousePosition();
System.out.println("");
System.out.println("avant loc = " + jXImagePanel.getLocation() + " - mousePos = " + jXImagePanel.getMousePosition() + " - zoom = " + facteurZoom);
if(evt.getWheelRotation()>0){
// reduire la taille
jXImagePanel.setSize(jXImagePanel.getWidth()/2, jXImagePanel.getHeight()/2);
facteurZoom--;
}else{
// augmenter la taille
facteurZoom++;
jXImagePanel.setLocation(loc.x - mousePos.x, loc.y - mousePos.y);
jXImagePanel.setSize(jXImagePanel.getWidth()*2, jXImagePanel.getHeight()*2);
}
if(jXImagePanel.getWidth() < this.getWidth()) jXImagePanel.setLocation(0, 0);
System.out.println("après loc = " + jXImagePanel.getLocation() + " - mousePos = " + jXImagePanel.getMousePosition() + " - zoom = " + facteurZoom);
} |
Partager