| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| MouseWheelZoomListener |
|
| 2.0;2 |
| 1 | /* | |
| 2 | * Created on 14/mar/2010 | |
| 3 | * Copyright (C) 2010 by Andrea Vacondio. | |
| 4 | * | |
| 5 | * This program is free software; you can redistribute it and/or modify it under the terms of the | |
| 6 | * GNU General Public License as published by the Free Software Foundation; | |
| 7 | * either version 2 of the License. | |
| 8 | * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | |
| 9 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
| 10 | * See the GNU General Public License for more details. | |
| 11 | * You should have received a copy of the GNU General Public License along with this program; | |
| 12 | * if not, write to the Free Software Foundation, Inc., | |
| 13 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 14 | */ | |
| 15 | package org.pdfsam.guiclient.business.listeners; | |
| 16 | ||
| 17 | import java.awt.event.InputEvent; | |
| 18 | import java.awt.event.MouseWheelEvent; | |
| 19 | import java.awt.event.MouseWheelListener; | |
| 20 | ||
| 21 | import org.pdfsam.guiclient.gui.components.JPreviewImage; | |
| 22 | ||
| 23 | /** | |
| 24 | * Listen for the mouse wheel to perform zoom operations on the | |
| 25 | * {@link JPreviewImage} | |
| 26 | * | |
| 27 | * @author Andrea Vacondio | |
| 28 | * | |
| 29 | */ | |
| 30 | public class MouseWheelZoomListener implements MouseWheelListener { | |
| 31 | ||
| 32 | private JPreviewImage image; | |
| 33 | ||
| 34 | /** | |
| 35 | * @param image | |
| 36 | */ | |
| 37 | public MouseWheelZoomListener(JPreviewImage image) { | |
| 38 | 0 | super(); |
| 39 | 0 | this.image = image; |
| 40 | 0 | } |
| 41 | ||
| 42 | /* | |
| 43 | * (non-Javadoc) | |
| 44 | * | |
| 45 | * @seejava.awt.event.MouseWheelListener#mouseWheelMoved(java.awt.event. | |
| 46 | * MouseWheelEvent) | |
| 47 | */ | |
| 48 | @Override | |
| 49 | public void mouseWheelMoved(MouseWheelEvent e) { | |
| 50 | 0 | if ((e.getModifiers() & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK) { |
| 51 | 0 | if (e.getScrollType() == MouseWheelEvent.WHEEL_UNIT_SCROLL) { |
| 52 | 0 | image.zoom(e.getWheelRotation()); |
| 53 | } | |
| 54 | } | |
| 55 | 0 | } |
| 56 | } |