View Javadoc
1   /*
2    * Copyright (c) 2005, The JUNG Authors 
3    *
4    * All rights reserved.
5    *
6    * This software is open-source under the BSD license; see either
7    * "license.txt" or
8    * https://github.com/jrtom/jung/blob/master/LICENSE for a description.
9    * Created on Mar 8, 2005
10   *
11   */
12  package edu.uci.ics.jung.visualization.control;
13  
14  import java.awt.geom.Point2D;
15  
16  import edu.uci.ics.jung.visualization.Layer;
17  import edu.uci.ics.jung.visualization.VisualizationServer;
18  import edu.uci.ics.jung.visualization.transform.MutableTransformer;
19  
20  /** 
21   * ViewScalingGraphMouse applies a scaling transform to the View
22   * of the graph. This causes all elements of the graph to grow
23   * larger or smaller. ViewScalingGraphMouse, by default, is activated
24   * by the MouseWheel when the control key is pressed. The control
25   * key modifier can be overridden in the contstructor.
26   * 
27   * @author Tom Nelson
28   */
29  public class ViewScalingControl implements ScalingControl {
30  
31  	/**
32  	 * zoom the display in or out, depending on the direction of the
33  	 * mouse wheel motion.
34  	 */
35      public void scale(VisualizationServer<?, ?> vv, float amount, Point2D from) {
36          MutableTransformer viewTransformer = vv.getRenderContext().getMultiLayerTransformer().getTransformer(Layer.VIEW);
37          viewTransformer.scale(amount, amount, from);
38          vv.repaint();
39      }
40  }