Revision 7771

View differences:

trunk/extensions/extWCS/src/com/iver/cit/gvsig/gui/toc/WCSZoomPixelCursorTocMenuEntry.java
11 11
import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior;
12 12
import com.iver.cit.gvsig.fmap.tools.Behavior.MouseMovementBehavior;
13 13
import com.iver.cit.gvsig.fmap.tools.Behavior.PointBehavior;
14
import com.iver.cit.gvsig.gui.toolListeners.StatusBarListener;
15 14
import com.iver.cit.gvsig.gui.toolListeners.WCSZoomPixelCursorListener;
16 15
import com.iver.cit.gvsig.project.documents.view.gui.View;
17 16
import com.iver.cit.gvsig.project.documents.view.toc.TocMenuEntry;
18 17
import com.iver.cit.gvsig.project.documents.view.toc.gui.FPopupMenu;
18
import com.iver.cit.gvsig.project.documents.view.toolListeners.StatusBarListener;
19 19

  
20 20
/** 
21 21
 * @author Nacho Brodin <brodin_ign@gva.es>
trunk/extensions/extRasterTools/src/org/gvsig/rasterTools/saveRaster/SaveRasterModule.java
49 49
import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior;
50 50
import com.iver.cit.gvsig.fmap.tools.Behavior.MouseMovementBehavior;
51 51
import com.iver.cit.gvsig.fmap.tools.Behavior.RectangleBehavior;
52
import com.iver.cit.gvsig.gui.toolListeners.StatusBarListener;
53 52
import com.iver.cit.gvsig.project.documents.view.IProjectView;
54 53
import com.iver.cit.gvsig.project.documents.view.gui.View;
54
import com.iver.cit.gvsig.project.documents.view.toolListeners.StatusBarListener;
55 55

  
56 56

  
57 57
/**
trunk/extensions/extGeoreferencing/src/org/gvsig/georeferencing/gui/dialog/GeoreferencingDialog.java
79 79
import com.iver.cit.gvsig.fmap.tools.Behavior.GeoRedimBehavior;
80 80
import com.iver.cit.gvsig.fmap.tools.Behavior.MouseMovementBehavior;
81 81
import com.iver.cit.gvsig.fmap.tools.Behavior.PointBehavior;
82
import com.iver.cit.gvsig.gui.toolListeners.StatusBarListener;
83 82
import com.iver.cit.gvsig.gui.wizards.WizardListener;
84 83
import com.iver.cit.gvsig.project.Project;
85 84
import com.iver.cit.gvsig.project.documents.view.gui.View;
85
import com.iver.cit.gvsig.project.documents.view.toolListeners.StatusBarListener;
86 86

  
87 87
/**
88 88
 * Panel que contiene el Wizard de georeferenciaci?n con los tabs
trunk/extensions/extCenterViewToPoint/src/com/iver/gvsig/centerviewtopoint/gui/InputCoordinatesPanel.java
74 74
import com.iver.cit.gvsig.fmap.tools.BehaviorException;
75 75
import com.iver.cit.gvsig.fmap.tools.Events.PointEvent;
76 76
import com.iver.cit.gvsig.gui.panels.ColorChooserPanel;
77
import com.iver.cit.gvsig.gui.toolListeners.InfoListener;
77
import com.iver.cit.gvsig.project.documents.view.toolListeners.InfoListener;
78 78
import com.iver.gvsig.centerviewpoint.CenterViewToPointExtension;
79 79

  
80 80
/**
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/DEMO/SingleView.java
93 93
import com.iver.cit.gvsig.fmap.tools.Behavior.PolylineBehavior;
94 94
import com.iver.cit.gvsig.fmap.tools.Behavior.RectangleBehavior;
95 95
import com.iver.cit.gvsig.gui.panels.FPanelAbout;
96
import com.iver.cit.gvsig.gui.toolListeners.AreaListener;
97
import com.iver.cit.gvsig.gui.toolListeners.InfoListener;
98
import com.iver.cit.gvsig.gui.toolListeners.MeasureListener;
99
import com.iver.cit.gvsig.gui.toolListeners.StatusBarListener;
100
import com.iver.cit.gvsig.gui.toolListeners.ZoomInListener;
101 96
import com.iver.cit.gvsig.project.documents.view.MapOverview;
102 97
import com.iver.cit.gvsig.project.documents.view.gui.IView;
103 98
import com.iver.cit.gvsig.project.documents.view.info.gui.FInfoDialog;
104 99
import com.iver.cit.gvsig.project.documents.view.toc.gui.TOC;
100
import com.iver.cit.gvsig.project.documents.view.toolListeners.AreaListener;
101
import com.iver.cit.gvsig.project.documents.view.toolListeners.InfoListener;
102
import com.iver.cit.gvsig.project.documents.view.toolListeners.MeasureListener;
103
import com.iver.cit.gvsig.project.documents.view.toolListeners.StatusBarListener;
104
import com.iver.cit.gvsig.project.documents.view.toolListeners.ZoomInListener;
105 105

  
106 106

  
107 107
/* import java.awt.GridBagLayout;
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/MapOverview.java
69 69
import com.iver.cit.gvsig.fmap.tools.Behavior.DraggerBehavior;
70 70
import com.iver.cit.gvsig.fmap.tools.Behavior.PointBehavior;
71 71
import com.iver.cit.gvsig.fmap.tools.Behavior.RectangleBehavior;
72
import com.iver.cit.gvsig.gui.toolListeners.MapOverviewChangeZoomListener;
73
import com.iver.cit.gvsig.gui.toolListeners.MapOverviewListener;
74
import com.iver.cit.gvsig.gui.toolListeners.MapOverviewPanListener;
72
import com.iver.cit.gvsig.project.documents.view.toolListeners.MapOverviewChangeZoomListener;
73
import com.iver.cit.gvsig.project.documents.view.toolListeners.MapOverviewListener;
74
import com.iver.cit.gvsig.project.documents.view.toolListeners.MapOverviewPanListener;
75 75

  
76 76

  
77 77
/**
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/gui/View.java
69 69
import com.iver.cit.gvsig.fmap.tools.Behavior.PolygonBehavior;
70 70
import com.iver.cit.gvsig.fmap.tools.Behavior.PolylineBehavior;
71 71
import com.iver.cit.gvsig.fmap.tools.Behavior.RectangleBehavior;
72
import com.iver.cit.gvsig.gui.toolListeners.AreaListener;
73
import com.iver.cit.gvsig.gui.toolListeners.InfoListener;
74
import com.iver.cit.gvsig.gui.toolListeners.LinkListener;
75
import com.iver.cit.gvsig.gui.toolListeners.MeasureListener;
76
import com.iver.cit.gvsig.gui.toolListeners.PanListener;
77
import com.iver.cit.gvsig.gui.toolListeners.PointSelectListener;
78
import com.iver.cit.gvsig.gui.toolListeners.PolygonSelectListener;
79
import com.iver.cit.gvsig.gui.toolListeners.RectangleSelectListener;
80
import com.iver.cit.gvsig.gui.toolListeners.SelectImageListener;
81
import com.iver.cit.gvsig.gui.toolListeners.StatusBarListener;
82
import com.iver.cit.gvsig.gui.toolListeners.ZoomInListener;
83
import com.iver.cit.gvsig.gui.toolListeners.ZoomOutListener;
84
import com.iver.cit.gvsig.gui.toolListeners.ZoomPixelCursorListener;
85 72
import com.iver.cit.gvsig.project.documents.view.MapOverview;
86 73
import com.iver.cit.gvsig.project.documents.view.ProjectView;
87 74
import com.iver.cit.gvsig.project.documents.view.toc.gui.TOC;
75
import com.iver.cit.gvsig.project.documents.view.toolListeners.AreaListener;
76
import com.iver.cit.gvsig.project.documents.view.toolListeners.InfoListener;
77
import com.iver.cit.gvsig.project.documents.view.toolListeners.LinkListener;
78
import com.iver.cit.gvsig.project.documents.view.toolListeners.MeasureListener;
79
import com.iver.cit.gvsig.project.documents.view.toolListeners.PanListener;
80
import com.iver.cit.gvsig.project.documents.view.toolListeners.PointSelectListener;
81
import com.iver.cit.gvsig.project.documents.view.toolListeners.PolygonSelectListener;
82
import com.iver.cit.gvsig.project.documents.view.toolListeners.RectangleSelectListener;
83
import com.iver.cit.gvsig.project.documents.view.toolListeners.SelectImageListener;
84
import com.iver.cit.gvsig.project.documents.view.toolListeners.StatusBarListener;
85
import com.iver.cit.gvsig.project.documents.view.toolListeners.ZoomInListener;
86
import com.iver.cit.gvsig.project.documents.view.toolListeners.ZoomOutListener;
87
import com.iver.cit.gvsig.project.documents.view.toolListeners.ZoomPixelCursorListener;
88 88
import com.iver.utiles.console.JConsole;
89 89
import com.iver.utiles.console.JDockPanel;
90 90
import com.iver.utiles.console.ResponseListener;
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/toolListeners/MeasureListener.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig.project.documents.view.toolListeners;
42

  
43
import java.awt.geom.Point2D;
44
import java.text.NumberFormat;
45

  
46
import com.iver.andami.PluginServices;
47
import com.iver.cit.gvsig.fmap.MapContext;
48
import com.iver.cit.gvsig.fmap.MapControl;
49
import com.iver.cit.gvsig.fmap.ViewPort;
50
import com.iver.cit.gvsig.fmap.tools.MeasureListenerImpl;
51
import com.iver.cit.gvsig.fmap.tools.Events.MeasureEvent;
52

  
53

  
54
/**
55
 * DOCUMENT ME!
56
 *
57
 * @author Vicente Caballero Navarro
58
 */
59
public class MeasureListener extends MeasureListenerImpl {
60
	/**
61
	 * DOCUMENT ME!
62
	 *
63
	 * @param mc
64
	 */
65
	public MeasureListener(MapControl mc) {
66
		super(mc);
67
	}
68

  
69
	/**
70
	 * DOCUMENT ME!
71
	 *
72
	 * @param event DOCUMENT ME!
73
	 */
74
	public void points(MeasureEvent event) {
75
		double dist = 0;
76
		double distAll = 0;
77

  
78
		ViewPort vp = mapCtrl.getMapContext().getViewPort();
79

  
80
		Point2D p = new Point2D.Double(event.getXs()[0].doubleValue(),event.getYs()[0].doubleValue());//vp.toMapPoint(new Point(event.getXs()[0].intValue(),event.getYs()[0].intValue()));
81
		for (int i = 1; i < (event.getXs().length); i++) {
82
			Point2D p2 = new Point2D.Double(event.getXs()[i].doubleValue(),	event.getYs()[i].doubleValue());// vp.toMapPoint(new Point(event.getXs()[i].intValue(),event.getYs()[i].intValue()));
83
			dist = vp.distanceWorld(p, p2);
84
			distAll += dist;
85
			p = p2;
86
		}
87

  
88
		//System.out.println("Distancia = " + dist + " Distancia Total = " +
89
		//	(distAll));
90
		NumberFormat nf = NumberFormat.getInstance();
91
        nf.setMaximumFractionDigits(2);
92
        if (PluginServices.getMainFrame() != null)
93
        {
94
            PluginServices.getMainFrame().getStatusBar().setMessage("4",
95
    			"Dist:" + nf.format(dist/MapContext.CHANGEM[mapCtrl.getViewPort().getDistanceUnits()]) + "");
96
    		PluginServices.getMainFrame().getStatusBar().setMessage("5",
97
    			"Total:" + nf.format(distAll/MapContext.CHANGEM[mapCtrl.getViewPort().getDistanceUnits()]) + "");
98
        }
99
	}
100
}
0 101

  
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/toolListeners/MapOverviewPanListener.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig.project.documents.view.toolListeners;
42

  
43
import java.awt.Cursor;
44
import java.awt.Image;
45
import java.awt.Point;
46
import java.awt.Toolkit;
47
import java.awt.event.InputEvent;
48
import java.awt.event.MouseEvent;
49
import java.awt.geom.Point2D;
50
import java.awt.geom.Rectangle2D;
51

  
52
import javax.swing.ImageIcon;
53

  
54
import com.iver.cit.gvsig.fmap.MapControl;
55
import com.iver.cit.gvsig.fmap.ViewPort;
56
import com.iver.cit.gvsig.fmap.tools.BehaviorException;
57
import com.iver.cit.gvsig.fmap.tools.Events.MoveEvent;
58
import com.iver.cit.gvsig.fmap.tools.Listeners.PanListener;
59
import com.iver.cit.gvsig.project.documents.view.MapOverview;
60

  
61

  
62
/**
63
 * DOCUMENT ME!
64
 *
65
 * @author Vicente Caballero Navarro
66
 */
67
public class MapOverviewPanListener implements PanListener {
68
	private final Image icursor = new ImageIcon(MapControl.class.getResource(
69
				"images/CruxCursor.png")).getImage();
70
	private Cursor cur = Toolkit.getDefaultToolkit().createCustomCursor(icursor,
71
			new Point(16, 16), "");
72
	protected MapControl mapControl;
73

  
74
	/**
75
	 * Crea un nuevo ZoomOutListenerImpl.
76
	 *
77
	 * @param mapControl DOCUMENT ME!
78
	 */
79
	public MapOverviewPanListener(MapControl mapControl) {
80
		this.mapControl = mapControl;
81
	}
82

  
83
	/**
84
	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor()
85
	 */
86
	public Cursor getCursor() {
87
		return cur;
88
	}
89

  
90
	/**
91
	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
92
	 */
93
	public boolean cancelDrawing() {
94
		return true;
95
	}
96

  
97
	/*
98
	public void move(MoveEvent event) throws BehaviorException {
99
		if (!checkModifiers(event.getEvent().getModifiers())){
100
			return;
101
		}
102
		
103
		ViewPort vp = mapControl.getMapContext().getViewPort();
104
		MapOverview mov=(MapOverview) this.mapControl;
105
		ViewPort vpView=mov.getAssociatedMapContext().getViewPort();
106
		if (vp.getExtent() != null) {
107
			Point2D p = vp.toMapPoint(event.getTo());
108
			Rectangle2D r = (Rectangle2D) vpView.getExtent().clone();
109
			r.setRect(p.getX() - (r.getWidth() / 2),
110
				p.getY() - (r.getHeight() / 2), r.getWidth(), r.getHeight());
111
			//vpView.setExtent(r);
112
			double scale;
113
			double escalaX;
114
			double escalaY;
115
			double newHeight;
116
			double newWidth;
117
			double xCenter = r.getCenterX();
118
			double yCenter = r.getCenterY();
119

  
120
			escalaX = mapControl.getWidth() / r.getWidth();
121
			escalaY = mapControl.getHeight() / r.getHeight();
122
			Rectangle2D adjustedExtent = new Rectangle2D.Double();
123

  
124
			if (escalaX < escalaY) {
125
				scale = escalaX;
126
				newHeight = mapControl.getHeight() / scale;
127
				adjustedExtent.setRect(xCenter - (r.getWidth() / 2.0),
128
					yCenter - (newHeight / 2.0), r.getWidth(), newHeight);
129
			} else {
130
				scale = escalaY;
131
				newWidth = mapControl.getWidth() / scale;
132
				adjustedExtent.setRect(xCenter - (newWidth / 2.0),
133
					yCenter - (r.getHeight() / 2.0), newWidth,
134
					r.getHeight());
135
			}
136
			mov.refreshOverView(adjustedExtent);
137
		}
138

  
139
	}
140
	*/
141
	
142
	/** 
143
	 * Es llamado mientras se hace del 'Dragg' del 
144
	 * raton. Pinta el recuadro de la forma.
145
	 **/
146
	public void move(MoveEvent event) throws BehaviorException {
147
		
148
		
149
		if (!checkModifiers(event.getEvent())){
150
			return;
151
		}
152
		System.out.println("mapOvervierPan");
153
		MapOverview mov=(MapOverview) this.mapControl;
154
		ViewPort vp = mov.getViewPort();
155
		ViewPort vpView=mov.getAssociatedMapContext().getViewPort();
156

  
157
		if (vp.getExtent() != null && vpView.getExtent() != null) {
158
			
159
			// recogemos la forma de la vista actual
160
			Rectangle2D curRectangle = (Rectangle2D)vpView.getAdjustedExtent();
161
			// traducimos las coordenadas en px de la ultima posicion del raton 
162
			// a coordenadas de la vista 
163
			Point2D thePoint= vp.toMapPoint( event.getTo());
164
			
165
			Rectangle2D realRectangle = new Rectangle2D.Double();		
166
			double width =curRectangle.getWidth();
167
			double height =curRectangle.getHeight();
168
			// Creamos un rectangulo del mismo tama?o
169
			// con la coordenadas del punto del raton,
170
			// teniendo en cuenta que estas sera el 
171
			// centro del recuadro
172
			realRectangle.setRect(
173
					thePoint.getX() - (width/2),
174
					thePoint.getY() - (height/2),
175
					width,
176
					height				
177
			);
178
			// cambiamos la posicion
179
			mov.refreshOverView(realRectangle);
180
		}
181
	}
182
	
183
	/** 
184
	 * Comprueba que el estado de los botones
185
	 * sea el deseado para esta herramienta.
186
	 **/
187
	private boolean checkModifiers(MouseEvent event) {
188
		
189
		int modifiers = event.getModifiers();
190
		/*
191
		int keyPressedMask = InputEvent.BUTTON2_MASK;
192
		
193
		*** No se porque el boton derecho del raton devuelve
194
		*** un modificador 'Meta + BUTTON3'. Pensaba que deberia
195
		*** devolver 'BUTTON2' ???? 
196
		*/		
197
		int keyPressedMask = InputEvent.BUTTON3_MASK;
198
		return ((modifiers & keyPressedMask) == keyPressedMask);
199
	}
200
}
0 201

  
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/toolListeners/MapOverviewListener.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig.project.documents.view.toolListeners;
42

  
43
import java.awt.Cursor;
44
import java.awt.Image;
45
import java.awt.Point;
46
import java.awt.Toolkit;
47
import java.awt.geom.Point2D;
48
import java.awt.geom.Rectangle2D;
49

  
50
import javax.swing.ImageIcon;
51

  
52
import com.iver.andami.PluginServices;
53
import com.iver.cit.gvsig.fmap.MapControl;
54
import com.iver.cit.gvsig.fmap.ViewPort;
55
import com.iver.cit.gvsig.fmap.tools.BehaviorException;
56
import com.iver.cit.gvsig.fmap.tools.Events.PointEvent;
57
import com.iver.cit.gvsig.fmap.tools.Listeners.PointListener;
58
import com.iver.cit.gvsig.project.documents.view.MapOverview;
59

  
60

  
61
/**
62
 * DOCUMENT ME!
63
 *
64
 * @author Vicente Caballero Navarro
65
 */
66
public class MapOverviewListener implements PointListener {
67
	private final Image izoomout = new ImageIcon(MapControl.class.getResource(
68
				"images/CruxCursor.png")).getImage();
69
	private Cursor cur = Toolkit.getDefaultToolkit().createCustomCursor(izoomout,
70
			new Point(16, 16), "");
71
	protected MapControl mapControl;
72

  
73
	/**
74
	 * Crea un nuevo ZoomOutListenerImpl.
75
	 *
76
	 * @param mapControl DOCUMENT ME!
77
	 */
78
	public MapOverviewListener(MapControl mapControl) {
79
		this.mapControl = mapControl;
80
	}
81

  
82
	/**
83
	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#point(com.iver.cit.gvsig.fmap.tools.PointEvent)
84
	 */
85
	public void point(PointEvent event) {
86
		ViewPort vp = mapControl.getMapContext().getViewPort();
87

  
88
		if (vp.getExtent() != null) {
89
			Point2D p = vp.toMapPoint(event.getPoint());
90
			Rectangle2D r = (Rectangle2D) ((MapOverview) this.mapControl).getAssociatedMapContext()
91
										   .getViewPort().getExtent().clone();
92

  
93
			r.setRect(p.getX() - (r.getWidth() / 2),
94
				p.getY() - (r.getHeight() / 2), r.getWidth(), r.getHeight());
95

  
96
			((MapOverview) this.mapControl).getAssociatedMapContext()
97
			 .getViewPort().setExtent(r);
98
			PluginServices.getMainFrame().enableControls();
99
		}
100
	}
101

  
102
	/**
103
	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor()
104
	 */
105
	public Cursor getCursor() {
106
		return cur;
107
	}
108

  
109
	/**
110
	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
111
	 */
112
	public boolean cancelDrawing() {
113
		return true;
114
	}
115

  
116
	public void pointDoubleClick(PointEvent event) throws BehaviorException {
117
		// TODO Auto-generated method stub
118

  
119
	}
120
}
0 121

  
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/toolListeners/RectangleSelectListener.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig.project.documents.view.toolListeners;
42

  
43
import com.iver.andami.PluginServices;
44
import com.iver.cit.gvsig.fmap.MapControl;
45
import com.iver.cit.gvsig.fmap.tools.BehaviorException;
46
import com.iver.cit.gvsig.fmap.tools.RectangleSelectionListener;
47
import com.iver.cit.gvsig.fmap.tools.Events.RectangleEvent;
48

  
49

  
50
/**
51
 * Extensi?n de la clase RectangleSelectionListener de FMap para poder llamar a
52
 * m?todos de andami o de gvSIG.
53
 *
54
 * @author Vicente Caballero Navarro
55
 */
56
public class RectangleSelectListener extends RectangleSelectionListener {
57
	/**
58
	 * DOCUMENT ME!
59
	 *
60
	 * @param mapCtrl
61
	 */
62
	public RectangleSelectListener(MapControl mapCtrl) {
63
		super(mapCtrl);
64
	}
65

  
66
	/**
67
	 * DOCUMENT ME!
68
	 *
69
	 * @param event DOCUMENT ME!
70
	 *
71
	 * @throws BehaviorException
72
	 */
73
	public void rectangle(RectangleEvent event) throws BehaviorException {
74
		super.rectangle(event);
75
		PluginServices.getMainFrame().enableControls();
76
	}
77
}
0 78

  
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/toolListeners/AreaListener.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig.project.documents.view.toolListeners;
42

  
43
import java.awt.geom.Point2D;
44
import java.text.NumberFormat;
45

  
46
import com.iver.andami.PluginServices;
47
import com.iver.andami.ui.mdiFrame.MainFrame;
48
import com.iver.cit.gvsig.fmap.MapContext;
49
import com.iver.cit.gvsig.fmap.MapControl;
50
import com.iver.cit.gvsig.fmap.ViewPort;
51
import com.iver.cit.gvsig.fmap.tools.AreaListenerImpl;
52
import com.iver.cit.gvsig.fmap.tools.Events.MeasureEvent;
53

  
54

  
55
/**
56
 * DOCUMENT ME!
57
 *
58
 * @author Vicente Caballero Navarro
59
 */
60
public class AreaListener extends AreaListenerImpl {
61
	/**
62
     * Crea un nuevo AreaListener.
63
     *
64
     * @param vp DOCUMENT ME!
65
     */
66
    public AreaListener(MapControl mc) {
67
    	super(mc);
68
    }
69

  
70
    /**
71
     * DOCUMENT ME!
72
     *
73
     * @param event DOCUMENT ME!
74
     */
75
    public void points(MeasureEvent event) {
76
        this.event = event;
77

  
78
        double dist = 0;
79
        double distAll = 0;
80

  
81
        ViewPort vp = mapCtrl.getMapContext().getViewPort();
82
        for (int i = 0; i < (event.getXs().length - 1); i++) {
83
            dist = 0;
84

  
85
            Point2D p = new Point2D.Double(event.getXs()[i].doubleValue(), event.getYs()[i].doubleValue());//vp.toMapPoint(new Point(event.getXs()[i].intValue(), event.getYs()[i].intValue()));
86
            Point2D p2 = new Point2D.Double(event.getXs()[i + 1].doubleValue(), event.getYs()[i + 1].doubleValue());//vp.toMapPoint(new Point(event.getXs()[i + 1].intValue(), event.getYs()[i + 1].intValue()));
87
            ///dist = vp.toMapDistance((int) p.distance(p2));
88
            dist = vp.distanceWorld(p,p2);
89
            System.out.println("distancia parcial = "+dist);
90
            distAll += dist;
91
        }
92

  
93
       // System.out.println("Per?metro = " + distAll + " ?rea = " +
94
       //     (returnArea(vp.toMapPoint(
95
       //             new Point2D.Double(
96
       //                 event.getXs()[event.getXs().length - 2].doubleValue(),
97
       //                 event.getYs()[event.getYs().length - 2].doubleValue())))));
98
        NumberFormat nf = NumberFormat.getInstance();
99
        nf.setMaximumFractionDigits(2);
100
        MainFrame mF = PluginServices.getMainFrame();
101
        if (mF != null)
102
        {
103
            mF.getStatusBar().setMessage("4",
104
        			"P:" + nf.format(distAll/MapContext.CHANGEM[mapCtrl.getViewPort().getDistanceUnits()]) + "");
105
        		mF.getStatusBar().setMessage("5",
106
        			///"A:" + nf.format(returnArea(vp.toMapPoint(
107
                    ///        new Point2D.Double(
108
                    ///                event.getXs()[event.getXs().length - 2].doubleValue(),
109
                    ///                event.getYs()[event.getYs().length - 2].doubleValue())))/FMap.CHANGEM[mapCtrl.getViewPort().getDistanceUnits()]) + "");
110
        				"A:" + nf.format(returnArea(
111
                                new Point2D.Double(
112
                                        event.getXs()[event.getXs().length - 2].doubleValue(),
113
                                        event.getYs()[event.getYs().length - 2].doubleValue()))/MapContext.CHANGEM[mapCtrl.getViewPort().getDistanceUnits()]) + "");
114
        }
115
    }
116

  
117

  
118
}
0 119

  
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/toolListeners/StatusBarListener.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig.project.documents.view.toolListeners;
42

  
43
import java.awt.Cursor;
44
import java.awt.geom.Point2D;
45
import java.text.NumberFormat;
46

  
47
import org.cresques.cts.IProjection;
48

  
49
import com.iver.andami.PluginServices;
50
import com.iver.andami.ui.mdiFrame.MainFrame;
51
import com.iver.cit.gvsig.fmap.MapContext;
52
import com.iver.cit.gvsig.fmap.MapControl;
53
import com.iver.cit.gvsig.fmap.core.v02.FConstant;
54
import com.iver.cit.gvsig.fmap.tools.BehaviorException;
55
import com.iver.cit.gvsig.fmap.tools.Events.PointEvent;
56
import com.iver.cit.gvsig.fmap.tools.Listeners.PointListener;
57

  
58

  
59
/**
60
 * DOCUMENT ME!
61
 *
62
 * @author Vicente Caballero Navarro
63
 */
64
public class StatusBarListener implements PointListener {
65
	private MapControl mapControl = null;
66
	private NumberFormat nf = null;
67

  
68
	/**
69
	 * Crea un nuevo StatusBarListener.
70
	 *
71
	 * @param mc DOCUMENT ME!
72
	 */
73
	public StatusBarListener(MapControl mc) {
74
		mapControl = mc;
75
		nf = NumberFormat.getInstance();
76
		nf.setMaximumFractionDigits(2);
77
	}
78

  
79
	/**
80
	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor()
81
	 */
82
	public Cursor getCursor() {
83
		return null;
84
	}
85

  
86
	/**
87
	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
88
	 */
89
	public boolean cancelDrawing() {
90
		return false;
91
	}
92

  
93
	/**
94
	 * 050211, jmorell: M?todo modificado para mejorar la manera de mostrar las
95
	 * coordenadas geod?sicas en la barra de estado. Muestra Lat y Lon y aumenta
96
	 * el n?mero de decimales para cuando trabajemos en coordenadas geod?sicas.
97
	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#point(com.iver.cit.gvsig.fmap.tools.Events.PointEvent)
98
	 */
99
	public void point(PointEvent event) throws BehaviorException {
100
		String[] axisText = new String[2];
101
		axisText[0] = "X = ";
102
		axisText[1] = "Y = ";
103
		Point2D p = mapControl.getMapContext().getViewPort().toMapPoint(event.getPoint());
104
		setFractionDigits(p);
105
		axisText = setCoorDisplayText(axisText);
106
		MainFrame mF = PluginServices.getMainFrame();
107

  
108
		if (mF != null)
109
		{
110
            mF.getStatusBar().setMessage("units",
111
                    FConstant.NAMES[mapControl.getMapContext().getViewPort().getDistanceUnits()]);
112
            // FJP: No se debe llamar a setControlValue desde aqu?, porque
113
            // cambia la escala, y con ella el viewPort (adem?s, de
114
            // la vista que no es).
115
            // mF.getStatusBar().setControlValue("scale",String.valueOf(mapControl.getMapContext().getScaleView()));
116
            // Fin
117
			mF.getStatusBar().setMessage("projection", mapControl.getViewPort().getProjection().getAbrev());
118

  
119
			mF.getStatusBar().setMessage("x",
120
					axisText[0] + String.valueOf(nf.format(p.getX()/MapContext.CHANGEM[mapControl.getViewPort().getDistanceUnits()])));
121
			mF.getStatusBar().setMessage("y",
122
					axisText[1] + String.valueOf(nf.format(p.getY()/MapContext.CHANGEM[mapControl.getViewPort().getDistanceUnits()])));
123
		}
124
	}
125

  
126
	/**
127
	 * Aumenta el n?mero de decimales visibles cuando trabajamos con coordeandas
128
	 * geod?sicas. En concreto se a?aden 8 decimales, con lo que logramos una
129
	 * definici?n subm?trica.
130
	 * 050211, jmorell.
131
	 * @param p
132
	 */
133
	private void setFractionDigits(Point2D p) {
134
		IProjection iProj = mapControl.getMapContext().getProjection();
135
		if (iProj.getAbrev().equals("EPSG:4326") || iProj.getAbrev().equals("EPSG:4230")) {
136
			nf.setMaximumFractionDigits(8);
137
		} else {
138
			nf.setMaximumFractionDigits(2);
139
		}
140
	}
141

  
142
	/**
143
	 * Cambia X e Y por Lat y Lon enb la barra de estado cuando trabajamos con
144
	 * coordenadas geod?sicas.
145
	 * 050211, jmorell.
146
	 * @param p
147
	 */
148
	private String[] setCoorDisplayText(String[] axisText) {
149
		IProjection iProj = mapControl.getMapContext().getProjection();
150
		if (iProj.getAbrev().equals("EPSG:4326") || iProj.getAbrev().equals("EPSG:4230")) {
151
			axisText[0] = "Lon = ";
152
			axisText[1] = "Lat = ";
153
		} else {
154
			axisText[0] = "X = ";
155
			axisText[1] = "Y = ";
156
		}
157
		return axisText;
158
	}
159

  
160
	public void pointDoubleClick(PointEvent event) throws BehaviorException {
161
		// TODO Auto-generated method stub
162

  
163
	}
164

  
165
}
0 166

  
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/toolListeners/ZoomInListener.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig.project.documents.view.toolListeners;
42

  
43
import com.iver.andami.PluginServices;
44
import com.iver.cit.gvsig.fmap.MapControl;
45
import com.iver.cit.gvsig.fmap.tools.ZoomInListenerImpl;
46
import com.iver.cit.gvsig.fmap.tools.Events.RectangleEvent;
47

  
48

  
49
/**
50
 * Extensi?n de la clase ZoomInListenerImpl de FMap para poder llamar a m?todos
51
 * de andami o de gvSIG.
52
 *
53
 * @author Vicente Caballero Navarro
54
 */
55
public class ZoomInListener extends ZoomInListenerImpl {
56
	/**
57
	 * DOCUMENT ME!
58
	 *
59
	 * @param mapCtrl
60
	 */
61
	public ZoomInListener(MapControl mapCtrl) {
62
		super(mapCtrl);
63
	}
64

  
65
	/**
66
	 * DOCUMENT ME!
67
	 *
68
	 * @param event DOCUMENT ME!
69
	 */
70
	public void rectangle(RectangleEvent event) {
71
		super.rectangle(event);
72
		if (PluginServices.getMainFrame() != null)
73
		    PluginServices.getMainFrame().enableControls();
74
	}
75
}
0 76

  
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/toolListeners/ZoomOutListener.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig.project.documents.view.toolListeners;
42

  
43
import com.iver.andami.PluginServices;
44
import com.iver.cit.gvsig.fmap.MapControl;
45
import com.iver.cit.gvsig.fmap.tools.ZoomOutListenerImpl;
46
import com.iver.cit.gvsig.fmap.tools.Events.PointEvent;
47

  
48

  
49
/**
50
 * Extensi?n de la clase ZoomOutListenerImpl de FMap para poder llamar a
51
 * m?todos de andami o de gvSIG.
52
 *
53
 * @author Vicente Caballero Navarro
54
 */
55
public class ZoomOutListener extends ZoomOutListenerImpl {
56
	/**
57
	 * DOCUMENT ME!
58
	 *
59
	 * @param mapCtrl
60
	 */
61
	public ZoomOutListener(MapControl mapCtrl) {
62
		super(mapCtrl);
63
	}
64

  
65
	/**
66
	 * DOCUMENT ME!
67
	 *
68
	 * @param event DOCUMENT ME!
69
	 */
70
	public void point(PointEvent event) {
71
		super.point(event);
72
		PluginServices.getMainFrame().enableControls();
73
	}
74
}
0 75

  
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/toolListeners/PanListener.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig.project.documents.view.toolListeners;
42

  
43
import com.iver.andami.PluginServices;
44
import com.iver.cit.gvsig.fmap.MapControl;
45
import com.iver.cit.gvsig.fmap.tools.PanListenerImpl;
46
import com.iver.cit.gvsig.fmap.tools.Events.MoveEvent;
47

  
48

  
49
/**
50
 * Extensi?n de la clase PanListenerImpl de FMap para poder llamar a m?todos de
51
 * andami o de gvSIG.
52
 *
53
 * @author Vicente Caballero Navarro
54
 */
55
public class PanListener extends PanListenerImpl {
56
	/**
57
	 * DOCUMENT ME!
58
	 *
59
	 * @param mapCtrl
60
	 */
61
	public PanListener(MapControl mapCtrl) {
62
		super(mapCtrl);
63
	}
64

  
65
	/**
66
	 * DOCUMENT ME!
67
	 *
68
	 * @param event DOCUMENT ME!
69
	 */
70
	public void move(MoveEvent event) {
71
		super.move(event);
72
		PluginServices.getMainFrame().enableControls();
73
	}
74
}
0 75

  
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/toolListeners/MapOverviewChangeZoomListener.java
1
/**
2
 * 
3
 */
4
package com.iver.cit.gvsig.project.documents.view.toolListeners;
5

  
6
import java.awt.Cursor;
7
import java.awt.Image;
8
import java.awt.Point;
9
import java.awt.Toolkit;
10
import java.awt.event.InputEvent;
11
import java.awt.event.MouseEvent;
12
import java.awt.geom.Rectangle2D;
13

  
14
import javax.swing.ImageIcon;
15

  
16
import com.iver.cit.gvsig.fmap.MapControl;
17
import com.iver.cit.gvsig.fmap.ViewPort;
18
import com.iver.cit.gvsig.fmap.tools.BehaviorException;
19
import com.iver.cit.gvsig.fmap.tools.Events.MoveEvent;
20
import com.iver.cit.gvsig.fmap.tools.Events.RectangleEvent;
21
import com.iver.cit.gvsig.fmap.tools.Listeners.PanListener;
22
import com.iver.cit.gvsig.fmap.tools.Listeners.RectangleListener;
23
import com.iver.cit.gvsig.project.documents.view.MapOverview;
24

  
25
/**
26
 * @author jmvivo
27
 *
28
 */
29

  
30

  
31

  
32
public class MapOverviewChangeZoomListener implements RectangleListener, PanListener {
33
	private final Image izoomin = new ImageIcon(MapControl.class.getResource(
34
	"images/ZoomInCursor.gif")).getImage();
35
	private Cursor cur = Toolkit.getDefaultToolkit().createCustomCursor(izoomin,new Point(16, 16), "");
36
	protected MapControl mapControl;
37
	
38
	/**
39
	 * Crea un nuevo MapOverviewChangeZoomListener.
40
	 *
41
	 * @param mapControl Control de mapa asociado
42
	 */
43
	public MapOverviewChangeZoomListener(MapControl mapControl) {
44
		this.mapControl=mapControl;
45
	}
46
	
47
	/**
48
	 * Cambia el zoom. Es llamado cuando finaliza de
49
	 * pintar el recuadro
50
	 *
51
	 * 
52
	 *
53
	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.RectangleListener#rectangle(com.iver.cit.gvsig.fmap.tools.Events.RectangleEvent)	
54
	 */
55
	public void rectangle(RectangleEvent event) throws BehaviorException {
56
		
57
		if (!checkModifiers(event.getEvent())){
58
			return;
59
		}
60
		MapOverview mov=(MapOverview) this.mapControl;
61
		ViewPort vpView=mov.getAssociatedMapContext().getViewPort();
62
		ViewPort vp = mov.getViewPort();
63
		
64
		if (vp.getExtent() != null && vpView.getExtent() != null) {
65
			
66
			// Recuperamos las coordenadas del evento en px
67
			Rectangle2D pxRectangle = event.getPixelCoordRect();
68
			// Recuperamos las coordenadas del evento en coordenadas de la vista de localizador
69
			Rectangle2D realRectangle = event.getWorldCoordRect();			
70
			
71
			if ((pxRectangle.getWidth() < 3) && (pxRectangle.getHeight() < 3))
72
			{
73
				// rectangulo < 3 px no hacemos nada
74
				return;
75
	
76
			} else {
77
				// Cambiamos la extension de la vista asociada al localizador
78
				vpView.setExtent(realRectangle);				
79
			}
80
			
81
		}
82

  
83

  
84
	}
85

  
86
	/** 
87
	 * (non-Javadoc)
88
	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor()
89
	 **/
90
	public Cursor getCursor() {
91
		return this.cur;
92
	}
93

  
94
	/* (non-Javadoc)
95
	 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
96
	 */
97
	public boolean cancelDrawing() {		
98
		return true; //???
99
	}
100
	
101
	/** 
102
	 * Es llamado mientras se hace del 'Dragg' del 
103
	 * raton. Pinta el recuadro de la forma.
104
	 **/
105
	public void move(MoveEvent event) throws BehaviorException {
106
		
107
		
108
		if (!checkModifiers(event.getEvent())){
109
			return;
110
		}
111
		System.out.println("mapOvervierChangeZoom");
112
		MapOverview mov=(MapOverview) this.mapControl;
113
		ViewPort vpView=mov.getAssociatedMapContext().getViewPort();
114
		ViewPort vp = mov.getViewPort();	
115
		
116
		if (vp.getExtent() != null && vpView.getExtent() != null) {
117

  
118
			// Creamos un recuadro con las coordenadas del raton
119
			// traducidas a la del mapa
120
			Rectangle2D realRectangle = new Rectangle2D.Double();			
121
			realRectangle.setFrameFromDiagonal(vp.toMapPoint(event.getFrom()),vp.toMapPoint(event.getTo()));			
122
			
123
			// Establecemos la forma
124
			mov.refreshOverView(realRectangle);
125
		}
126
		
127
		
128
		
129
	}
130
	
131
	/** 
132
	 * Comprueba que el estado de los botones
133
	 * sea el deseado para esta herramienta.
134
	 **/
135
	private boolean checkModifiers(MouseEvent event) {	
136
		int modifiers = event.getModifiers();
137
		int keyPressedMask = InputEvent.BUTTON1_MASK;
138
		return ((modifiers & keyPressedMask) == keyPressedMask);
139
	}
140
	
141
}
0 142

  
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/view/toolListeners/SelectImageListener.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
*
3
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
*
5
* This program is free software; you can redistribute it and/or
6
* modify it under the terms of the GNU General Public License
7
* as published by the Free Software Foundation; either version 2
8
* of the License, or (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
*
19
* For more information, contact:
20
*
21
*  Generalitat Valenciana
22
*   Conselleria d'Infraestructures i Transport
23
*   Av. Blasco Ib??ez, 50
24
*   46010 VALENCIA
25
*   SPAIN
26
*
27
*      +34 963862235
28
*   gvsig@gva.es
29
*      www.gvsig.gva.es
30
*
31
*    or
32
*
33
*   IVER T.I. S.A
34
*   Salamanca 50
35
*   46005 Valencia
36
*   Spain
37
*
38
*   +34 963163400
39
*   dac@iver.es
40
*/
41
package com.iver.cit.gvsig.project.documents.view.toolListeners;
42

  
43
import java.awt.geom.Point2D;
44
import java.awt.geom.Rectangle2D;
45

  
46
import javax.swing.JScrollBar;
47

  
48
import com.iver.andami.PluginServices;
49
import com.iver.cit.gvsig.fmap.DriverException;
50
import com.iver.cit.gvsig.fmap.MapControl;
51
import com.iver.cit.gvsig.fmap.ViewPort;
52
import com.iver.cit.gvsig.fmap.layers.FLayer;
53
import com.iver.cit.gvsig.fmap.layers.FLayers;
54
import com.iver.cit.gvsig.fmap.layers.FLyrRaster;
55
import com.iver.cit.gvsig.fmap.tools.SelectImageListenerImpl;
56
import com.iver.cit.gvsig.fmap.tools.Events.PointEvent;
57
import com.iver.cit.gvsig.project.documents.view.gui.View;
58

  
59

  
60
/**
61
* Extensi?n de la clase SelectImageListenerImple de FMap. Esta clase 
62
* permite capturar el evento de la selecci?n de un punto sobre la vista
63
* . Controlara que capa de la pila que est? visible cae dentro del punto
64
* seleccionado poniendo esta capa como activa. En caso de que haya varias 
65
* capas visibles sobre ese punto, pondr? como activa la capa superior. 
66
*
67
* @author Nacho Brodin <brodin_ign@gva.es>
68
*/
69
public class SelectImageListener extends SelectImageListenerImpl {
70
	
71
	FLyrRaster 			layer = null;
72
	Rectangle2D extentLayer = null;
73
	/**
74
	 * Contructor 
75
	 * @param mapCtrl
76
	 */
77
	public SelectImageListener(MapControl mapCtrl) {
78
		super(mapCtrl);
79
	}
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff