Revision 12825

View differences:

trunk/extensions/extRasterTools-SE/src-test-ui/org/gvsig/rastertools/properties/panels/TestTransparencyByPixelPanel.java
32 32
		tbp.setControlEnabled(true);
33 33

  
34 34
		frame = new JFrame();
35
		frame.setSize(450,300);
35
		frame.setSize(450, 300);
36 36
		frame.getContentPane().add(tbp);
37 37
		frame.setVisible(true);
38 38
		frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
trunk/extensions/extRasterTools-SE/src-test-ui/org/gvsig/rastertools/geolocation/TestGeoLocationDialog.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 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
package org.gvsig.rastertools.geolocation;
20

  
21
import javax.swing.JFrame;
22
import javax.swing.UIManager;
23

  
24
import org.gvsig.rastertools.geolocation.ui.GeoLocationDialog;
25
import org.gvsig.rastertools.geolocation.ui.GeoLocationPanel;
26

  
27
/**
28
 * Test para el panel de geolocalizaci?n
29
 * @version 30/07/2007
30
 * @author Nacho Brodin (nachobrodin@gmail.com)
31
 *
32
 */
33
public class TestGeoLocationDialog {
34
	private JFrame 			frame = new JFrame();
35

  
36
	public TestGeoLocationDialog() {
37
		super();
38
		initialize();
39
	}
40

  
41
	public static void main(String[] args){
42
		try {
43
			UIManager.setLookAndFeel("com.jgoodies.looks.plastic.PlasticXPLookAndFeel");
44
		} catch( Exception e ) {
45
			System.err.println( "No se puede cambiar al LookAndFeel");
46
		}
47
		new TestGeoLocationDialog();
48
	}
49

  
50
	private void initialize() {
51
		GeoLocationPanel glp = new GeoLocationPanel();
52
		frame.setContentPane(glp);
53

  
54
		frame.setSize(new java.awt.Dimension(220, 230));
55
		frame.setResizable(true);
56
		frame.setTitle("Geolocalizaci?n");
57
		frame.setVisible(true);
58
		frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
59
	}
60
}
0 61

  
trunk/extensions/extRasterTools-SE/config/text.properties
152 152
lr=Inferior derecha
153 153
ll=Inferior izquierda
154 154
rotX=Rotaci?n en X
155
rotY=Rotaci?n en Y
155
rotY=Rotaci?n en Y
156
ux=X
157
uy=Y
158
px=Pix X
159
py=Pix Y
160
rx=Rot X
161
ry=Rot Y
162
geolocation=Geolocalizaci?n
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/RasterModule.java
28 28
import org.gvsig.rastertools.filter.FilterTocMenuEntry;
29 29
import org.gvsig.rastertools.geolocation.behavior.GeoRasterBehavior;
30 30
import org.gvsig.rastertools.geolocation.listener.GeorefPanListener;
31
import org.gvsig.rastertools.geolocation.ui.GeoLocationDialog;
31 32
import org.gvsig.rastertools.histogram.HistogramTocMenuEntry;
32 33
import org.gvsig.rastertools.pixelincrease.PixelncreaseDialog;
33 34
import org.gvsig.rastertools.properties.panels.BandSetupPanel;
......
125 126
			mapCtrl.setTool("selectRasterLayer");
126 127
		}
127 128
		
128
		/*if (actionCommand.equals("GEO_ROTATION")) {
129
			loadGeoRotationListener(mapCtrl, sbl);
130
			mapCtrl.setTool("geoRotation");
131
		}	
132
		
133
		if (actionCommand.equals("GEO_ZOOM")) {
134
			loadGeoZoomListener(mapCtrl, sbl);
135
			mapCtrl.setTool("geoZoom");
136
		}*/
137
		
138 129
		if (actionCommand.equals("GEO_PAN")) {
139
			loadGeoPanListener(mapCtrl, sbl);
130
			GeoLocationDialog gld = null;
131
			if(!GeoLocationDialog.isOpen) {
132
				gld = new GeoLocationDialog(mapCtrl);
133
				PluginServices.getMDIManager().addWindow(gld);
134
			}
135
			loadGeoPanListener(mapCtrl, sbl, gld);
140 136
			mapCtrl.setTool("geoPan");
141 137
		}
142 138
		
......
167 163
	/**
168 164
	 * Carga el listener de selecci?n de raster en el MapControl.
169 165
	 */
170
	private void loadGeoPanListener(MapControl mapCtrl, StatusBarListener sbl) {
166
	private void loadGeoPanListener(MapControl mapCtrl, StatusBarListener sbl, GeoLocationDialog gld) {
171 167
		if (mapCtrl.getNamesMapTools().get("geoPan") == null) {
172 168
			GeorefPanListener pl = new GeorefPanListener(mapCtrl);
173
			GeoRasterBehavior mb = new GeoRasterBehavior(pl);
169
			GeoRasterBehavior mb = new GeoRasterBehavior(pl, gld);
174 170
			mapCtrl.addMapTool("geoPan", new Behavior[]{mb, new MouseMovementBehavior(sbl)});
175 171

  
176 172
		}
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/geolocation/ui/GeoLocationDialog.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 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
package org.gvsig.rastertools.geolocation.ui;
20

  
21
import java.awt.BorderLayout;
22
import java.awt.geom.AffineTransform;
23

  
24
import javax.swing.JPanel;
25

  
26
import org.gvsig.fmap.raster.layers.FLyrRasterSE;
27
import org.gvsig.raster.util.MathUtils;
28
import org.gvsig.raster.util.RasterUtilities;
29
import org.gvsig.rastertools.geolocation.behavior.ITransformIO;
30

  
31
import com.iver.andami.PluginServices;
32
import com.iver.andami.ui.mdiManager.IWindow;
33
import com.iver.andami.ui.mdiManager.IWindowListener;
34
import com.iver.andami.ui.mdiManager.WindowInfo;
35
import com.iver.cit.gvsig.fmap.MapControl;
36
import com.iver.cit.gvsig.fmap.layers.FLayer;
37
import com.iver.cit.gvsig.fmap.layers.FLayers;
38
import com.iver.cit.gvsig.project.documents.view.gui.IView;
39

  
40
/**
41
 * 
42
 * @version 30/07/2007
43
 * @author Nacho Brodin (nachobrodin@gmail.com)
44
 *
45
 */
46
public class GeoLocationDialog extends JPanel implements IWindow, IWindowListener, ITransformIO {
47
		private static final long          serialVersionUID = 7362459094802955247L;
48
		/**
49
	     * N?mero de decimales a mostrar
50
	     */
51
	    private int                        tailValue = 2;
52
		private GeoLocationPanel           geolocationPanel = null;
53
		/**
54
		 * Controla que haya una ?nica instancia de la ventana
55
		 */
56
		public static boolean              isOpen = false;
57
	    /**
58
	     * Posici?n de la ventana en X y en Y
59
	     */
60
	    private int                        posWindowX = 0;
61
	    private int                        posWindowY = 0;
62
	    
63
	    private int                        widthWindow = 220;
64
	    private int                        heightWindow = 160;
65
	    
66
	    private String                     lastTool = null;
67
	    private MapControl                 mapCtrl = null;
68
	    
69
		
70
		/**
71
		 * Crea la ventana del histograma con un ancho y alto.
72
		 * @param width Ancho de la ventana
73
		 * @param height Alto de la ventana
74
		 */
75
		public GeoLocationDialog(MapControl mapCtrl) {
76
			this.mapCtrl = mapCtrl;
77
			BorderLayout bl = new BorderLayout(5, 5);
78
			this.setLayout(bl);
79
			this.add(getGeoLocationPanel());
80
			
81
			//Calculo de la posici?n de la ventana
82
			IWindow[] list = PluginServices.getMDIManager().getAllWindows();
83
			for (int i = 0; i < list.length; i++) {
84
				if(list[i] instanceof IView) {
85
					WindowInfo wInfo = PluginServices.getMDIManager().getWindowInfo(list[i]);
86
					posWindowX = wInfo.getX() + (wInfo.getWidth() / 2) - (widthWindow / 2);
87
					posWindowY = wInfo.getY() + (wInfo.getHeight() / 2) - (heightWindow / 2);
88
				}	
89
			}
90
			
91
			//Carga de par?metros
92
			FLayers flyrs = mapCtrl.getMapContext().getLayers();
93
			FLayer[] actives = flyrs.getActives();
94
			for (int i = 0; i < actives.length; i++) {
95
				if(actives[i] instanceof FLyrRasterSE) {
96
					loadTransform(((FLyrRasterSE)actives[i]).getAffineTransform());
97
					break;
98
				}
99
			}
100
			
101
		}
102
		
103
		/**
104
		 * Carga los par?metros en el dialogo a partir de la capa
105
		 * @param lyr Capa raster
106
		 */
107
		public void loadTransform(AffineTransform at) {
108
			geolocationPanel.setUlx(String.valueOf(MathUtils.format(at.getTranslateX(), tailValue)));
109
			geolocationPanel.setUly(String.valueOf(MathUtils.format(at.getTranslateY(), tailValue)));
110
			geolocationPanel.setPsx(String.valueOf(MathUtils.format(at.getScaleX(), tailValue)));
111
			geolocationPanel.setPsy(String.valueOf(MathUtils.format(at.getScaleY(), tailValue)));
112
			geolocationPanel.setRotx(String.valueOf(MathUtils.format(at.getShearX(), tailValue)));
113
			geolocationPanel.setRoty(String.valueOf(MathUtils.format(at.getShearY(), tailValue)));
114
		}
115

  
116
		/**
117
		 * Obtiene el panel con el histograma
118
		 * @return HistogramPanel
119
		 */
120
		public GeoLocationPanel getGeoLocationPanel(){
121
			if (geolocationPanel == null) 
122
				geolocationPanel = new GeoLocationPanel();
123
			
124
			return geolocationPanel;
125
		}
126

  
127
		/*
128
		 * (non-Javadoc)
129
		 * @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
130
		 */
131
		public WindowInfo getWindowInfo() {
132
			WindowInfo m_viewinfo=new WindowInfo(WindowInfo.RESIZABLE);
133
			m_viewinfo.setHeight(heightWindow);
134
			m_viewinfo.setWidth(widthWindow);
135
			m_viewinfo.setX(posWindowX);
136
			m_viewinfo.setY(posWindowY);
137
			return m_viewinfo;
138
		}
139

  
140
		/**
141
		 * Asigna el ?ltimo tool seleccionado antes de abrir el di?logo para 
142
		 * restaurarlo cuando se cierre este.
143
		 * @param tool
144
		 */
145
		public void setLastTool(String tool) {
146
			this.lastTool = tool;
147
		}
148
		
149
		/*
150
		 * (non-Javadoc)
151
		 * @see com.iver.andami.ui.mdiManager.IWindowListener#windowActivated()
152
		 */
153
		public void windowActivated() {
154
			isOpen = true;
155
		}
156

  
157
		/*
158
		 * (non-Javadoc)
159
		 * @see com.iver.andami.ui.mdiManager.IWindowListener#windowClosed()
160
		 */
161
		public void windowClosed() {
162
			//Restauramos la tool que hab?a antes de de activar la actual
163
			if(lastTool != null)
164
				mapCtrl.setTool(lastTool);
165
			isOpen = false;
166
		}
167
}
0 168

  
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/geolocation/ui/GeoLocationPanel.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 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
package org.gvsig.rastertools.geolocation.ui;
20

  
21
import java.awt.BorderLayout;
22
import java.awt.FlowLayout;
23
import java.awt.GridLayout;
24

  
25
import javax.swing.ImageIcon;
26
import javax.swing.JButton;
27
import javax.swing.JPanel;
28

  
29
import org.gvsig.gui.beans.datainput.DataInputContainer;
30

  
31
import com.iver.andami.PluginServices;
32
import com.iver.cit.gvsig.project.documents.layout.gui.Layout;
33

  
34
/**
35
 * 
36
 * @version 30/07/2007
37
 * @author Nacho Brodin (nachobrodin@gmail.com)
38
 *
39
 */
40
public class GeoLocationPanel extends JPanel {
41

  
42
	private DataInputContainer	ulx = null;
43
	private DataInputContainer	uly = null;
44
	private DataInputContainer	psx = null;
45
	private DataInputContainer	psy = null;
46
	private DataInputContainer	rotx = null;
47
	private DataInputContainer	roty = null;
48
	private JButton			    first = null;
49
	private JButton			    save = null;
50
	private JButton			    back = null;
51
	private JButton		 	    next = null;
52
	
53
	private JPanel			    coordsPanel = null;
54
	private JPanel			    paramsPanel = null;
55
	private JPanel			    buttonsPanel = null;
56
	
57
	/**
58
	 * Constructor
59
	 */
60
	public GeoLocationPanel() {
61
		ImageIcon backIcon = null;
62
		ImageIcon nextIcon = null;
63
		ImageIcon saveIcon = null;
64
		ImageIcon firstIcon = null;
65
		try {
66
			backIcon = new ImageIcon(getClass().getClassLoader().getResource("images/back.png"));
67
			nextIcon = new ImageIcon(getClass().getClassLoader().getResource("images/next.png"));
68
			saveIcon = new ImageIcon(getClass().getClassLoader().getResource("images/save.png")); 
69
			firstIcon = new ImageIcon(getClass().getClassLoader().getResource("images/undo.png"));
70
		} catch(NullPointerException e) {
71
			
72
		}
73
		
74
		GridLayout gl = new GridLayout(3, 1);
75
		this.setLayout(gl);
76
		setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this, "geolocation"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
77
		ulx = new DataInputContainer();
78
		ulx.setLabelText(PluginServices.getText(this,"ux"));
79
		uly = new DataInputContainer();
80
		uly.setLabelText(PluginServices.getText(this,"uy"));
81
		psx = new DataInputContainer();
82
		psx.setLabelText(PluginServices.getText(this,"px"));
83
		psy = new DataInputContainer();
84
		psy.setLabelText(PluginServices.getText(this,"py"));
85
		rotx = new DataInputContainer();
86
		rotx.setLabelText(PluginServices.getText(this,"rx"));
87
		roty = new DataInputContainer();
88
		roty.setLabelText(PluginServices.getText(this,"ry"));
89
		first = new JButton(firstIcon);
90
		save = new JButton(saveIcon);
91
		back = new JButton(backIcon);
92
		next = new JButton(nextIcon);
93
		
94
		coordsPanel = new JPanel();
95
		//coordsPanel.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray, 1));
96
		coordsPanel.setLayout(new GridLayout(2, 1));
97
		paramsPanel = new JPanel();
98
		//paramsPanel.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray, 1));
99
		paramsPanel.setLayout(new GridLayout(2, 2));
100
		buttonsPanel = new JPanel();
101
		//buttonsPanel.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray, 1));
102
		FlowLayout ly = new FlowLayout();
103
		ly.setVgap(0);
104
		ly.setAlignment(FlowLayout.RIGHT);
105
		buttonsPanel.setLayout(ly);
106
		
107
		init();
108
	}
109
	
110
	private void init() {
111
		coordsPanel.add(ulx);
112
		coordsPanel.add(uly);
113
		paramsPanel.add(psx);
114
		paramsPanel.add(psy);
115
		paramsPanel.add(rotx);
116
		paramsPanel.add(roty);
117
		buttonsPanel.add(back);
118
		buttonsPanel.add(next);
119
		buttonsPanel.add(first);
120
		buttonsPanel.add(save);
121
				
122
		this.add(coordsPanel);
123
		this.add(paramsPanel);
124
		this.add(buttonsPanel);
125
	}
126

  
127
	/**
128
	 * Asigna el tama?o de pixel en X
129
	 * @param psx
130
	 */
131
	public void setPsx(String psx) {
132
		this.psx.setValue(psx);
133
	}
134

  
135
	/**
136
	 * Asigna el tama?o de pixel en Y
137
	 * @param psy
138
	 */
139
	public void setPsy(String psy) {
140
		this.psy.setValue(psy);
141
	}
142

  
143
	/**
144
	 * Asigna la rotaci?n en X
145
	 * @param rotx
146
	 */
147
	public void setRotx(String rotx) {
148
		this.rotx.setValue(rotx);
149
	}
150

  
151
	/**
152
	 * Asigna la rotaci?n en Y
153
	 * @param roty
154
	 */
155
	public void setRoty(String roty) {
156
		this.roty.setValue(roty);
157
	}
158

  
159
	/**
160
	 * Asigna la coordenada superior izquierda
161
	 * @param ulx 
162
	 */
163
	public void setUlx(String ulx) {
164
		this.ulx.setValue(ulx);
165
	}
166

  
167
	/**
168
	 * Asigna la coordenada superior derecha
169
	 * @param ulx 
170
	 */
171
	public void setUly(String uly) {
172
		this.uly.setValue(uly);
173
	}
174
	
175
}
0 176

  
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/geolocation/behavior/RotationBehavior.java
93 93
	 *
94 94
	 * @param zili listener.
95 95
	 */
96
	public RotationBehavior(GeoRasterBehavior grb, Cursor cur) {
96
	public RotationBehavior(GeoRasterBehavior grb, Cursor cur, ITransformIO windowIO) {
97 97
		grBehavior = grb;
98 98
		defaultCursor = cur;
99
		this.trIO = windowIO;
99 100
	}
100 101

  
101 102
	/**
......
245 246
			rotation -= incrRot;
246 247
						
247 248
		beforePoint = vp.toMapPoint(e.getPoint());
249
		if(boxRot != null)
250
			trIO.loadTransform(boxRot);
248 251
		grBehavior.getMapControl().repaint();
249 252
	}
250 253
	
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/geolocation/behavior/TransformationBehavior.java
37 37
	protected Cursor                    defaultCursor = null;
38 38
	protected GeoRasterBehavior         grBehavior = null;
39 39
	protected FLyrRasterSE              lyr = null;
40
	protected Color					rectangleColor = Color.RED;
40
	protected Color                     rectangleColor = Color.RED;
41
	protected ITransformIO				trIO = null;
41 42
	
42 43
	/**
43 44
	 * Consulta si la tool est? activada o no
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/geolocation/behavior/ScaleBehavior.java
96 96
	 *
97 97
	 * @param zili listener.
98 98
	 */
99
	public ScaleBehavior(GeoRasterBehavior grb, Cursor cur) {
99
	public ScaleBehavior(GeoRasterBehavior grb, Cursor cur, ITransformIO windowIO) {
100 100
		grBehavior = grb;
101 101
		defaultCursor = cur;
102
		this.trIO = windowIO;
102 103
	}
103 104

  
104 105
	/**
......
339 340
	            tmpLr = new Point2D.Double(tmpLr.getX(), tmpLr.getY() + difY);
340 341
		    }
341 342
			
343
			//Asignaci?n de las coordenadas temporales al dialogo
344
			assignTransformToDialog();
345
			
342 346
			grBehavior.getMapControl().repaint();
343 347
		}
344 348
	}
345 349
	
346 350
	/**
351
	 * Asigna las coordenadas temporales en el dialogo.
352
	 */
353
	public void assignTransformToDialog() {
354
		Point2D ul = new Point2D.Double();
355
		Point2D lr = new Point2D.Double();
356
		AffineTransform tr = grBehavior.getLayer().getAffineTransform();
357
		tr.transform(tmpUl, ul);
358
		tr.transform(tmpLr, lr);
359
		endWidth = Math.abs(tmpUl.getX() - tmpLr.getX());
360
		escale = endWidth / initWidth;
361
		AffineTransform esc = new AffineTransform(escale, 0, 0, escale, 0, 0);
362
		AffineTransform at = new AffineTransform(tr.getScaleX(), tr.getShearY(), 
363
												tr.getShearX(), tr.getScaleY(), 
364
												ul.getX(), ul.getY());
365
		esc.preConcatenate(at);
366
		trIO.loadTransform(esc);	
367
	}
368
	
369
	/**
347 370
	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#setListener(org.gvsig.georeferencing.fmap.tools.ToolListener)
348 371
	 */
349 372
	public void setListener(ToolListener listener) {
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/geolocation/behavior/GeoRasterBehavior.java
53 53
	 *
54 54
	 * @param zili listener.
55 55
	 */
56
	public GeoRasterBehavior(PanListener zili) {
56
	public GeoRasterBehavior(PanListener zili, ITransformIO windowIO) {
57 57
		cur = zili.getCursor();
58
		translate = new TranslateBehavior(this, cur);
59
		scale = new ScaleBehavior(this, cur);
60
		rotate = new RotationBehavior(this, cur);
58
		translate = new TranslateBehavior(this, cur, windowIO);
59
		scale = new ScaleBehavior(this, cur, windowIO);
60
		rotate = new RotationBehavior(this, cur, windowIO);
61 61
	}
62 62
	
63 63
	/**
......
101 101
	 * Si no est? activo el cursor por defecto capturamos el punto 
102 102
	 * seleccionado en coordenadas del mundo real.
103 103
	 */
104
	public void mousePressed(MouseEvent e) throws BehaviorException {
105
		/*Graphics2D g = (Graphics2D)getMapControl().getGraphics();
106
		FLyrRasterSE lyr = getLayer();
107
		if(lyr != null) {
108
			Rectangle2D extent = lyr.getFullExtent();
109
			Point2D p1 = getMapControl().getViewPort().fromMapPoint(extent.getMinX(), extent.getMaxY());
110
			Point2D p2 = getMapControl().getViewPort().fromMapPoint(extent.getMaxX(), extent.getMinY());
111
			Extent ex = RasterUtilities.calculateAdjustedView(	new Extent(p1, p2), 
112
																new Extent(	getMapControl().getViewPort().getAdjustedExtent().getMinX(),
113
																		getMapControl().getViewPort().getAdjustedExtent().getMaxY(),
114
																		getMapControl().getViewPort().getAdjustedExtent().getMaxX(),
115
																		getMapControl().getViewPort().getAdjustedExtent().getMinY()));*/
116
		
104
	public void mousePressed(MouseEvent e) throws BehaviorException {		
117 105
		if(scale.isActiveTool())
118 106
			scale.mousePressed(e);
119 107
		else if(translate.isActiveTool())
120 108
			translate.mousePressed(e);
121 109
		else if(rotate.isActiveTool())
122 110
			rotate.mousePressed(e);
123
		
124
		
125 111
	}
126 112
	
127 113
	/**
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/geolocation/behavior/ITransformIO.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2007 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
package org.gvsig.rastertools.geolocation.behavior;
20

  
21
import java.awt.geom.AffineTransform;
22

  
23
/**
24
 * Interfaz para entrada y salida de datos que tienen que ver con transformaciones
25
 * de georreferenciaci?n. 
26
 * 
27
 * @version 30/07/2007
28
 * @author Nacho Brodin (nachobrodin@gmail.com)
29
 *
30
 */
31
public interface ITransformIO {
32
	/**
33
	 * Carga los par?metros de una transformaci?n af?n
34
	 * @param transform
35
	 */
36
	public void loadTransform(AffineTransform transform);
37
}
0 38

  
trunk/extensions/extRasterTools-SE/src/org/gvsig/rastertools/geolocation/behavior/TranslateBehavior.java
26 26
import java.awt.HeadlessException;
27 27
import java.awt.Image;
28 28
import java.awt.Point;
29
import java.awt.Rectangle;
30 29
import java.awt.Toolkit;
31 30
import java.awt.event.MouseEvent;
32 31
import java.awt.geom.AffineTransform;
33 32
import java.awt.geom.NoninvertibleTransformException;
34 33
import java.awt.geom.Point2D;
35
import java.awt.image.BufferedImage;
36 34

  
37 35
import javax.swing.ImageIcon;
38 36
import javax.swing.JOptionPane;
......
77 75
	 *
78 76
	 * @param zili listener.
79 77
	 */
80
	public TranslateBehavior(GeoRasterBehavior grb, Cursor cur) {
78
	public TranslateBehavior(GeoRasterBehavior grb, Cursor cur, ITransformIO windowIO) {
81 79
		grBehavior = grb;
82 80
		defaultCursor = cur;
81
		this.trIO = windowIO;
83 82
	}
84 83
		
85 84
	/**
......
248 247
		if(isMoveable){
249 248
			ViewPort vp = grBehavior.getMapControl().getMapContext().getViewPort();
250 249
			ptoFin = vp.toMapPoint(e.getPoint());
250
			
251
			//Asignaci?n de las coordenadas temporales al dialogo
252
			assignTransformToDialog();
253
			
251 254
			grBehavior.getMapControl().repaint();
252 255
		}
253 256
	}
254 257
	
258
	/**
259
	 * Asigna las coordenadas temporales en el dialogo.
260
	 */
261
	public void assignTransformToDialog() {
262
		AffineTransform atNew = null;
263
		double distX = ptoFin.getX() - ptoIni.getX();
264
		double distY = ptoFin.getY() - ptoIni.getY();
265
		AffineTransform atOld = grBehavior.getLayer().getAffineTransform();
266
		//La nueva matriz de transformaci?n es la vieja m?s la distancia desplazada
267
		atNew = new AffineTransform(atOld.getScaleX(), atOld.getShearY(),
268
									atOld.getShearX(), atOld.getScaleY(),
269
									atOld.getTranslateX() + distX, 
270
									atOld.getTranslateY() + distY);
271
		trIO.loadTransform(atNew);	
272
	}
273
	
255 274
	/* (non-Javadoc)
256 275
	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#getListener()
257 276
	 */
trunk/libraries/libRaster/doc/Notas.txt
91 91
Cambios FMap
92 92
	FPanelLocConfig (Para obtener el mapcontrol del localizador)
93 93
	CompoundBehavior (evento para la ventana de zoom)
94
	_fwAndami (WindowInfo para cerrar ventanas asociadas a la capa)
94
	_fwAndami (WindowInfo [setAdicionalInfo] para cerrar ventanas asociadas a la capa)
95 95
	
96 96
Pruebas
97 97
	Abrir un jpg, tif, ecw y mrsid. 
trunk/libraries/libRaster/src/org/gvsig/raster/dataset/RasterDataset.java
148 148
	 */
149 149
	public static RasterDataset open(IProjection proj, Object param) throws NotSupportedExtensionException, RasterDriverException {
150 150
		String idFormat = null;
151
	
151
		
152 152
		if(param instanceof String)
153 153
			idFormat = ((String)param).toLowerCase().substring(((String)param).lastIndexOf('.') + 1);
154 154
		if(param instanceof IRegistrableRasterFormat)
......
200 200
	 */
201 201
	protected void init() {
202 202
		//Creamos el gestor de Rmf
203
		String f = getFName().substring(0, getFName().lastIndexOf("."));
203
		int last =  getFName().lastIndexOf(".");
204
		if(last == -1)
205
			last = getFName().length();
206
		String f = getFName().substring(0, last);
204 207
		f = f + ".rmf";
205 208
		rmfBlocksManager = new RmfBlocksManager(f);
206 209
	}
......
227 230
	public RasterDataset(IProjection proj, Object param) {
228 231
		super(proj, param);
229 232
		if(param instanceof String)
230
			setFileSize(new File(((String)param)).length());
233
			setFileSize(new File(getFName()).length());
231 234
	}
235

  
232 236
	
233 237
	/**
234 238
	 * Carga un fichero raster. Puede usarse para calcular el extent e instanciar 
trunk/libraries/libRaster/src/org/gvsig/raster/dataset/GeoInfo.java
56 56
    public GeoInfo(IProjection p, Object param) {
57 57
        proj = p;
58 58
        if(param instanceof String)
59
        	name = ((String)param);
59
        	name = translateFileName((String)param);
60 60
        else if(param instanceof IRegistrableRasterFormat)
61 61
        	name = ((IRegistrableRasterFormat)param).getFormatID();
62 62
        else
......
64 64
        ownTransformation = new AffineTransform();
65 65
        externalTransformation = new AffineTransform();
66 66
    }
67
    
68
	/**
69
	 * Traduce el nombre del fichero por un alias asignado por el propio 
70
	 * driver. Cuando es traducido por un alias el driver intentar? abrir el alias y no 
71
	 * el fichero. Esto es util porque algunos formatos tienen la extensi?n en el fichero de
72
	 * cabecera pero lo que se abre realmente es el fichero de datos. 
73
	 * @param fileName
74
	 * @return
75
	 */
76
	public String translateFileName(String fileName) {
77
		return fileName;
78
	}
67 79

  
68 80
    public String getFName() {
69 81
        return name;
trunk/libraries/libRaster/src/org/gvsig/raster/dataset/io/GdalDriver.java
83 83
		extensionPoints.add("RasterReader", "rmf", GdalDriver.class); //Raster Matrix Format
84 84
		extensionPoints.add("RasterReader", "nos", GdalDriver.class);
85 85
		extensionPoints.add("RasterReader", "kap", GdalDriver.class); 
86
		extensionPoints.add("RasterReader", "hdr", GdalDriver.class);
86 87
	}
87 88
	
88 89
	public GdalDriver(IProjection proj, Object param)throws NotSupportedExtensionException {
89 90
		super(proj, param);
90
		setParam(param);
91 91
		try {
92 92
			if(param instanceof String) {
93
				file = new GdalNative(((String)param));
93
				setParam(translateFileName((String)param));
94
				file = new GdalNative(translateFileName((String)param));
94 95
				ownTransformation = file.getOwnTransformation();
95 96
				externalTransformation = (AffineTransform)ownTransformation.clone();
96 97
				load();			
97 98
			}else {
99
				setParam(param);
98 100
				//TODO: FUNCIONALIDAD: Formatos gestionados por gdal que no tienen extensi?n. Estos tendr?n un objeto IRegistrableRasterFormat Por ej: Grass
99 101
			}
100 102
			bandCount = file.getRasterCount(); 
......
140 142
		}
141 143
	}
142 144
		
145
	/*
146
	 * (non-Javadoc)
147
	 * @see org.gvsig.raster.dataset.RasterDataset#translateFileName(java.lang.String)
148
	 */
149
	public String translateFileName(String fileName) {
150
		if(fileName.endsWith("hdr"))
151
			return fileName.substring(0, fileName.lastIndexOf("."));
152
		return fileName;
153
	}
154
	
143 155
	/**
144 156
	 * Asigna el extent de la vista actual. existe un fichero .rmf debemos hacer una transformaci?n
145 157
	 * de la vista asignada ya que la petici?n viene en coordenadas del fichero .rmf y la vista (v)

Also available in: Unified diff