Revision 20098 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/tools/ZoomInListenerImpl.java

View differences:

ZoomInListenerImpl.java
56 56

  
57 57

  
58 58
/**
59
 * Implementaci?n de la interfaz RectangleListener como herramienta para
60
 * realizar un zoom m?s.
59
 * <p>Listener for doing a <i>zoom in</i> operation of the extent of the <code>ViewPort</code> of the associated {@link MapControl MapControl}
60
 *  object, defining a rectangular area.</p>
61
 * 
62
 * <p>If the area defined is smaller than 3 pixels x 3 pixels holds the zoom, otherwise, calculates the new extent <i>r</i>
63
 *  with this equations:
64
 *  <code><br>
65
 *   double factor = 1/MapContext.ZOOMINFACTOR;<br>
66
 *	 Rectangle2D rect = event.getWorldCoordRect();<br>
67
 *   Rectangle2D.Double r = new Rectangle2D.Double();<br>
68
 *   ViewPort vp = mapCtrl.getMapContext().getViewPort();<br>   
69
 *   double nuevoX = rect.getMaxX() - ((vp.getExtent().getWidth() * factor) / 2.0);<br>
70
 *   double nuevoY = rect.getMaxY() - ((vp.getExtent().getHeight() * factor) / 2.0);<br>
71
 *   Rectangle2D.Double r; // This will be the new extent<br>
72
 *   r.x = nuevoX;<br>
73
 *   r.y = nuevoY;<br>
74
 *   r.width = vp.getExtent().getWidth() * factor;<br>
75
 *   r.height = vp.getExtent().getHeight() * factor;<br>
76
 *   vp.setExtent(r);
77
 *  </code>
78
 * </p>
79
 * 
80
 * <p>The ultimately extent will be an adaptation from that, calculated by the <code>ViewPort</code>
81
 *  bearing in mind the ratio of the available rectangle where display the graphical information.</p>
61 82
 *
83
 * @see MapContext#ZOOMINFACTOR
84
 * @see ViewPort#setExtent(Rectangle2D)
85
 * @see ZoomOutListenerImpl
86
 * @see ZoomOutRightButtonListener
87
 *
62 88
 * @author Vicente Caballero Navarro
63 89
 */
64 90
public class ZoomInListenerImpl implements RectangleListener {
91
	/**
92
	 * The image to display when the cursor is active.
93
	 */
65 94
	private final Image izoomin = new ImageIcon(MapControl.class.getResource(
66 95
				"images/ZoomInCursor.gif")).getImage();
96

  
97
	/**
98
	 * The cursor used to work with this tool listener.
99
	 * 
100
	 * @see #getCursor()
101
	 */
67 102
	private Cursor cur = Toolkit.getDefaultToolkit().createCustomCursor(izoomin,
68 103
			new Point(16, 16), "");
104

  
105
	/**
106
	 * Reference to the <code>MapControl</code> object that uses.
107
	 */
69 108
	private MapControl mapCtrl;
70 109

  
110

  
71 111
	/**
72
	 * Crea un nuevo RectangleListenerImpl.
112
 	 * <p>Creates a new <code>ZoomInListenerImpl</code> object.</p>
73 113
	 *
74
	 * @param mapCtrl MapControl.
114
	 * @param mapCtrl the <code>MapControl</code> where is defined the rectangle
75 115
	 */
76 116
	public ZoomInListenerImpl(MapControl mapCtrl) {
77 117
		this.mapCtrl = mapCtrl;
78 118
	}
79 119

  
80 120
	/*
121
	 * (non-Javadoc)
81 122
	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.RectangleListener#rectangle(com.iver.cit.gvsig.fmap.tools.Events.RectangleEvent)
82 123
	 */
83 124
	public void rectangle(RectangleEvent event) {
......
110 151
		// mapCtrl.drawMap(false);
111 152
	}
112 153

  
113
	/**
154
	/*
155
	 * (non-Javadoc)
114 156
	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor()
115 157
	 */
116 158
	public Cursor getCursor() {
117 159
		return cur;
118 160
	}
119 161

  
120
	/**
162
	/*
163
	 * (non-Javadoc)
121 164
	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
122 165
	 */
123 166
	public boolean cancelDrawing() {

Also available in: Unified diff