KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > prefuse > controls > WheelZoomControl


1 package prefuse.controls;
2
3 import java.awt.Point JavaDoc;
4 import java.awt.event.MouseWheelEvent JavaDoc;
5
6 import prefuse.Display;
7 import prefuse.visual.VisualItem;
8
9 /**
10  * Zooms the display using the mouse scroll wheel, changing the scale of the
11  * viewable region.
12  *
13  * @author bobruney
14  * @author mathis ahrens
15  * @author <a HREF="http://jheer.org">jeffrey heer</a>
16  */

17 public class WheelZoomControl extends AbstractZoomControl {
18     
19     private Point JavaDoc m_point = new Point JavaDoc();
20     
21     /**
22      * @see prefuse.controls.Control#itemWheelMoved(prefuse.visual.VisualItem, java.awt.event.MouseWheelEvent)
23      */

24     public void itemWheelMoved(VisualItem item, MouseWheelEvent JavaDoc e) {
25         if ( m_zoomOverItem )
26             mouseWheelMoved(e);
27     }
28     
29     /**
30      * @see java.awt.event.MouseWheelListener#mouseWheelMoved(java.awt.event.MouseWheelEvent)
31      */

32     public void mouseWheelMoved(MouseWheelEvent JavaDoc e) {
33         Display display = (Display)e.getComponent();
34         m_point.x = display.getWidth()/2;
35         m_point.y = display.getHeight()/2;
36         zoom(display, m_point,
37              1 + 0.1f * e.getWheelRotation(), false);
38     }
39     
40 } // end of class WheelZoomControl
41
Popular Tags