Revision 3469

View differences:

org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.8/org.gvsig.raster.tools.app.basic/src/main/assembly/gvsig-plugin-package.xml
1
<assembly>
2
  <id>gvsig-plugin-package</id>
3
  <formats>
4
    <format>zip</format>
5
  </formats>
6
  <baseDirectory>${project.artifactId}</baseDirectory>
7
  <includeBaseDirectory>true</includeBaseDirectory>
8
  <files>
9
    <file>
10
      <source>target/${project.artifactId}-${project.version}.jar</source>
11
      <outputDirectory>lib</outputDirectory>
12
    </file>
13
    <file>
14
      <source>target/package.info</source>
15
    </file>
16
  </files>
17

  
18
  <fileSets>
19
    <fileSet>
20
      <directory>src/main/resources-plugin</directory>
21
      <outputDirectory>.</outputDirectory>
22
    </fileSet>
23
  </fileSets>
24

  
25

  
26
  <dependencySets>
27
    <dependencySet>
28
      <useProjectArtifact>false</useProjectArtifact>
29
	  <useTransitiveDependencies>false</useTransitiveDependencies>
30
      <outputDirectory>lib</outputDirectory>
31
      <includes> 
32
				<include>org.gvsig:org.gvsig.raster.tools.app.basic:jar</include>
33
				<include>org.gvsig:org.gvsig.raster.tools.algorithm.layerdatatype:jar</include>
34
				<include>org.gvsig:org.gvsig.raster.tools.algorithm.saveraster:jar</include>
35
				<include>org.gvsig:org.gvsig.raster.tools.algorithm.swing.api:jar</include>
36
				<include>org.gvsig:org.gvsig.raster.tools.algorithm.swing.impl:jar</include>
37
				<include>org.gvsig:org.gvsig.raster.tools.toolbox.algorithm:jar</include>
38
	  </includes>
39
	</dependencySet>
40
  </dependencySets>
41
</assembly>
0 42

  
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.8/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/SystemGCExtension.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22
package org.gvsig.raster.tools.app.basic;
23

  
24
import org.gvsig.andami.plugins.Extension;
25

  
26

  
27
/**
28
 * @author Nacho Brodin (nachobrodin@gmail.com)
29
 */
30
public class SystemGCExtension extends Extension {
31

  
32
	public void execute(String actionCommand) {
33
		System.gc();
34
	}
35

  
36
	public void initialize() {
37

  
38
	}
39

  
40
	public boolean isEnabled() {
41
		return true;
42
	}
43

  
44
	public boolean isVisible() {
45
		return true;
46
	}
47

  
48
}
0 49

  
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.8/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/MainWindow.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2011-2012 Prodevelop S.L
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 */
21
package org.gvsig.raster.tools.app.basic;
22

  
23
import java.awt.GridBagConstraints;
24
import java.awt.GridBagLayout;
25
import java.awt.event.ActionEvent;
26
import java.awt.event.ActionListener;
27

  
28
import javax.swing.JComponent;
29

  
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.andami.ui.mdiManager.IWindow;
32
import org.gvsig.andami.ui.mdiManager.WindowInfo;
33
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel;
34
import org.gvsig.gui.beans.defaultbuttonspanel.DefaultButtonsPanel;
35

  
36

  
37
/**
38
 * Basic frame for a gvSIG <code>IWindow</code> object. This frame adds buttons 
39
 * of Cancel, Accept and others.
40
 * 
41
 * @author Nacho Brodin (nachobrodin@gmail.com)
42
 */
43
public class MainWindow extends DefaultButtonsPanel implements IWindow, ActionListener {
44
    
45
    private static final long  serialVersionUID = -4401123724140025094L;
46
    private ActionListener     listener         = null;
47
    private WindowInfo         info             = null;
48

  
49
    private Object profile = WindowInfo.EDITOR_PROFILE;
50

  
51
    public MainWindow(JComponent panel, JComponent preview, String title, int w, int h, ActionListener actionListener) {
52
    	this.listener = actionListener;
53
    	
54
    	setLayout(new GridBagLayout());
55
		GridBagConstraints gbc = new GridBagConstraints();
56
		gbc.fill = GridBagConstraints.BOTH;
57
		gbc.weightx = 1;
58
		gbc.weighty = 1;
59
		add(panel, gbc);
60
		
61
		if(preview != null) {
62
			gbc.anchor = GridBagConstraints.NORTH;
63
			gbc.fill = GridBagConstraints.NONE;
64
			gbc.weightx = 0;
65
			gbc.weighty = 0;
66
			gbc.gridx = 1;
67
			add(preview, gbc);
68
		}
69

  
70
        getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT).addActionListener(this);
71
        getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY).addActionListener(this);
72
        getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL).addActionListener(this);
73
        
74
        info = new WindowInfo(WindowInfo.PALETTE | WindowInfo.RESIZABLE);
75
        info.setTitle(title);
76
        info.setWidth(w);
77
        info.setHeight(h);
78
    }
79

  
80
    public WindowInfo getWindowInfo() {
81
        return info;
82
    }
83

  
84
    public Object getWindowProfile() {
85
        return profile;
86
    }
87

  
88
    public void actionPerformed(ActionEvent e) {
89
    	if(e.getSource() == getButtonsPanel().getButton(ButtonsPanel.BUTTON_ACCEPT)) {
90
    		listener.actionPerformed(e);
91
    		PluginServices.getMDIManager().closeWindow(this);
92
    	}
93
    	
94
    	if(e.getSource() == getButtonsPanel().getButton(ButtonsPanel.BUTTON_APPLY)) {
95
    		listener.actionPerformed(e);
96
    	}
97
    	
98
    	if(e.getSource() == getButtonsPanel().getButton(ButtonsPanel.BUTTON_CANCEL)) {
99
    		PluginServices.getMDIManager().closeWindow(this);
100
    	}
101
    }
102
}
0 103

  
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.8/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/RasterExtension.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22
package org.gvsig.raster.tools.app.basic;
23

  
24
import java.util.ArrayList;
25
import java.util.prefs.Preferences;
26

  
27
import org.gvsig.andami.IconThemeHelper;
28
import org.gvsig.andami.PluginServices;
29
import org.gvsig.andami.plugins.Extension;
30
import org.gvsig.andami.plugins.IExtensionQueryByAction;
31
import org.gvsig.andami.ui.mdiManager.IWindow;
32
import org.gvsig.app.ApplicationLocator;
33
import org.gvsig.app.ApplicationManager;
34
import org.gvsig.app.project.documents.view.ViewDocument;
35
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel;
36
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction;
37
import org.gvsig.app.project.documents.view.toc.ITocItem;
38
import org.gvsig.fmap.dal.coverage.RasterLibrary;
39
import org.gvsig.fmap.dal.coverage.RasterLocator;
40
import org.gvsig.fmap.dal.coverage.store.RasterDataStore;
41
import org.gvsig.fmap.mapcontext.MapContext;
42
import org.gvsig.fmap.mapcontext.layers.FLayer;
43
import org.gvsig.fmap.mapcontext.layers.FLayers;
44
import org.gvsig.raster.algorithm.RasterBaseAlgorithmLibrary;
45
import org.gvsig.raster.fmap.FmapRasterLibrary;
46
import org.gvsig.raster.fmap.layers.DefaultFLyrRaster;
47
import org.gvsig.raster.fmap.layers.FLyrRaster;
48
import org.gvsig.raster.mainplugin.config.Configuration;
49
import org.gvsig.raster.mainplugin.config.ConfigurationEvent;
50
import org.gvsig.raster.mainplugin.config.ConfigurationListener;
51
import org.gvsig.raster.tools.app.basic.raster.gui.preference.RasterPreferences;
52
import org.gvsig.raster.tools.app.basic.raster.gui.wizard.PrepareDataStoreParametersRaw;
53
import org.gvsig.raster.tools.app.basic.raster.gui.wizard.PrepareDataStoreParametersVTR;
54
import org.gvsig.raster.tools.app.basic.raster.gui.wizard.PrepareLayerAskCoordinates;
55
import org.gvsig.raster.tools.app.basic.raster.gui.wizard.PrepareLayerAskWritableDirectory;
56
import org.gvsig.raster.tools.app.basic.raster.process.ClippingProcess;
57
import org.gvsig.raster.tools.app.basic.tool.analysisview.ViewRasterAnalysisTocMenuEntry;
58
import org.gvsig.raster.tools.app.basic.tool.clip.ClippingTocMenuEntry;
59
import org.gvsig.raster.tools.app.basic.tool.colortable.ColorTableTocMenuEntry;
60
import org.gvsig.raster.tools.app.basic.tool.colortable.ui.library.RasterColorTablesFactory;
61
import org.gvsig.raster.tools.app.basic.tool.enhanced.EnhancedTocMenuEntry;
62
import org.gvsig.raster.tools.app.basic.tool.filter.FilterTocMenuEntry;
63
import org.gvsig.raster.tools.app.basic.tool.geolocation.GeoLocationTocMenuEntry;
64
import org.gvsig.raster.tools.app.basic.tool.histogram.HistogramTocMenuEntry;
65
import org.gvsig.raster.tools.app.basic.tool.infobypoint.InfoByRasterPointTocMenuEntry;
66
import org.gvsig.raster.tools.app.basic.tool.layerdatatype.LayerDatatypeTocMenuEntry;
67
import org.gvsig.raster.tools.app.basic.tool.multiresolution.ZoomResolutionLevelTocMenuEntry;
68
import org.gvsig.raster.tools.app.basic.tool.overview.OverviewsTocMenuEntry;
69
import org.gvsig.raster.tools.app.basic.tool.properties.panel.EnhancedPanel;
70
import org.gvsig.raster.tools.app.basic.tool.properties.panel.GeneralPanel;
71
import org.gvsig.raster.tools.app.basic.tool.properties.panel.InfoPanel;
72
import org.gvsig.raster.tools.app.basic.tool.properties.panel.TransparencyPanel;
73
import org.gvsig.raster.tools.app.basic.tool.rasterresolution.ZoomPixelCursorTocMenuEntry;
74
import org.gvsig.raster.tools.app.basic.tool.roi.ROIManagerTocMenuEntry;
75
import org.gvsig.raster.tools.app.basic.tool.saveas.SaveAsTocMenuEntry;
76
import org.gvsig.raster.tools.app.basic.tool.saveviewtoraster.SaveViewToRasterTocMenuEntry;
77
import org.gvsig.raster.tools.app.basic.tool.selectrasterlayer.SelectLayerTocMenuEntry;
78
import org.gvsig.raster.tools.app.basic.tool.setviewprojection.SetViewProjectionTocMenuEntry;
79
import org.gvsig.raster.tools.app.basic.tool.viewexport.SaveViewToImageTocMenuEntry;
80
import org.gvsig.raster.tools.app.basic.toolbox.ToolboxRasterToolsLoader;
81
import org.gvsig.tools.ToolsLocator;
82
import org.gvsig.tools.extensionpoint.ExtensionBuilder;
83
import org.gvsig.tools.extensionpoint.ExtensionPoint;
84
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
85

  
86

  
87
/**
88
 * Extensi?n que adapta a FMap y gvSIG la nueva implementaci?n de raster. Para
89
 * el cuadro de Propiedades de visualizaci?n de raster contiene el contenedor
90
 * base se registran la entrada del men? del TOC y los paneles en el cuadro.
91
 * Para la parte de FMap contiene una nueva capa raster y los drivers
92
 * necesarios.
93
 *
94
 * @author Nacho Brodin (nachobrodin@gmail.com)
95
 */
96
public class RasterExtension extends Extension implements ConfigurationListener, IExtensionQueryByAction {
97
	public static final String         CLIPPING_PROCESS_LABEL   = ClippingProcess.PROCESS_LABEL;
98
	
99
	/**
100
	 * Indica si en el panel de preferencias se refresca automaticamente la vista
101
	 * para mostrar los cambios
102
	 */
103
	public static boolean       autoRefreshView = true;
104

  
105
	/**
106
	 * Indica si se debe preguntar las coordenadas al cargar una capa que no las
107
	 * tenga
108
	 */
109
	public static boolean       askCoordinates = false;
110
	private ExtensionPoint      genericToolBarMenuExtensionPoint  = null;
111

  
112
	public void execute(String actionCommand) {
113
		//Las entradas en GenericToolBarModule est?n registradas con la misma etiqueta que la del actionCommand
114
		//De esta forma pueden recuperarse los TocMenuEntry del punto de extensi?n y ejecutar la acci?n a
115
		//trav?s de este.
116
		ExtensionBuilder ext = getGenericToolBarMenuExtensionPoint().get(actionCommand).getBuilder();
117
		if(ext != null && ext instanceof AbstractTocContextMenuAction) {
118
			IWindow w = PluginServices.getMDIManager().getActiveWindow();
119
			if(w instanceof AbstractViewPanel) {
120
				FLayers lyrs = ((AbstractViewPanel)w).getMapControl().getMapContext().getLayers();
121
				FLayer[] actives = lyrs.getActives();
122
				((AbstractTocContextMenuAction)ext).execute(null, actives);
123
			}
124
		}
125
	}
126

  
127
	public void initialize() {
128
		// Asignamos la configuracion global a FlyrRasterSE
129
		DefaultFLyrRaster.setConfiguration(Configuration.getSingleton());
130

  
131
		Configuration.addValueChangedListener(this);
132
		loadConfigurationValues();
133

  
134
		registerIcons();
135

  
136
		FmapRasterLibrary fmapRaster = new FmapRasterLibrary();
137
		fmapRaster.initialize();
138

  
139
		Preferences prefs = Preferences.userRoot().node("gvsig.foldering");
140
		prefs.put("DataFolder", System.getProperty("user.home"));
141
		ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager();
142

  
143
		// Creaci?n del punto de extensi?n para registrar paneles en el cuadro de propiedades.
144
		if (!extensionPoints.has("RasterSEPropertiesDialog")) {
145
			ExtensionPoint point = extensionPoints.add("RasterSEPropertiesDialog");
146
			point.setDescription("Raster Properties registrable panels (register instances of javax.swing.JPanel)");
147
		}
148

  
149
		// A?adimos la configuracion de Raster a gvSIG
150

  
151
		ExtensionPoint point = extensionPoints.get("AplicationPreferences");
152
		point.append("RasterPreferences", "", RasterPreferences.class);
153

  
154
		// A?adimos paneles al cuadro de propiedades.
155
		point = extensionPoints.get("RasterSEPropertiesDialog");
156
		point.append("info", "", InfoPanel.class);
157
		point.append("transparencia", "", TransparencyPanel.class);
158
		point.append("realce", "", EnhancedPanel.class);
159
		point.append("general_panel", "", GeneralPanel.class);
160

  
161
		// A?adimos las entradas del men?  del toc de raster
162
		point = extensionPoints.get("View_TocActions");
163
		//point.append("RasterSEProperties", "Raster Properties", RasterPropertiesTocMenuEntry.getSingleton());
164
		point.append("SaveAs", "Save as raster layer", SaveAsTocMenuEntry.getSingleton());
165
		point.append("ZoomPixelCursor", "zoom to pixel resolution", ZoomPixelCursorTocMenuEntry.getSingleton());
166
		point.append("ROI", "ROIs for a raster layer", ROIManagerTocMenuEntry.getSingleton());
167
		point.append("Color table", "Color table for a raster layer", ColorTableTocMenuEntry.getSingleton());
168
		point.append("Histogram", "Histogram of a raster layer", HistogramTocMenuEntry.getSingleton());
169
		point.append("Overviews", "Build overviews", OverviewsTocMenuEntry.getSingleton());
170
		
171
		ApplicationManager appGvSigMan = ApplicationLocator.getManager();
172

  
173
		appGvSigMan.registerPrepareOpenDataStoreParameters(new PrepareLayerAskWritableDirectory());
174
		appGvSigMan.registerPrepareOpenDataStoreParameters(new PrepareDataStoreParametersRaw());
175
		appGvSigMan.registerPrepareOpenDataStoreParameters(new PrepareDataStoreParametersVTR());
176

  
177
		appGvSigMan.registerPrepareOpenLayer(new PrepareLayerAskCoordinates());
178

  
179
		appGvSigMan.registerColorTablesFactory(new RasterColorTablesFactory());
180

  
181
		registerMenuElements();
182
		registerProcesses();
183
	}
184
	
185
	private void registerProcesses() {
186
    	RasterBaseAlgorithmLibrary.register(CLIPPING_PROCESS_LABEL, ClippingProcess.class);
187
    	ClippingProcess.registerParameters();
188
	}
189

  
190
	/**
191
	 * Registra los iconos a utilizar en andami.
192
	 */
193
	private void registerIcons() {	
194
		//Actions
195
		IconThemeHelper.registerIcon("action", "menu-layer-icon", this);
196
		IconThemeHelper.registerIcon("action", "menu-process-icon", this);
197
		IconThemeHelper.registerIcon("action", "menu-transgeo-icon", this);
198
		IconThemeHelper.registerIcon("action", "menu-raster-export", this);
199
		
200
		IconThemeHelper.registerIcon("action", "layer-modify-roi", this);
201
		IconThemeHelper.registerIcon("action", "layer-histogram", this);
202
		IconThemeHelper.registerIcon("action", "layer-color-table", this);
203
		IconThemeHelper.registerIcon("action", "layer-modify-overviews", this);
204
		IconThemeHelper.registerIcon("action", "layer-properties-raster", this);
205
		IconThemeHelper.registerIcon("action", "layer-filter-raster", this);
206
		IconThemeHelper.registerIcon("action", "layer-enhanced", this);
207
		IconThemeHelper.registerIcon("action", "view-raster-analysis", this);
208
		IconThemeHelper.registerIcon("action", "view-select-raster-layer", this);
209
		IconThemeHelper.registerIcon("action", "layer-geolocalization", this);
210
		IconThemeHelper.registerIcon("action", "tools-raster-reproject", this);
211
		IconThemeHelper.registerIcon("action", "view-export-georeferenced-raster", this);
212
		IconThemeHelper.registerIcon("action", "layer-saveas", this);
213
		IconThemeHelper.registerIcon("action", "layer-clip-raster", this);
214
		IconThemeHelper.registerIcon("action", "layer-zoom-res-level", this);
215
		IconThemeHelper.registerIcon("action", "layer-info-by-pixel", this);
216
		IconThemeHelper.registerIcon("action", "layer-vectorization", this);
217
		IconThemeHelper.registerIcon("action", "view-export-image", this);
218
		
219
		//Cursor
220
		IconThemeHelper.registerIcon("cursor", "zoom-pixel-cursor", this);
221
		IconThemeHelper.registerIcon("cursor", "hor-arrow-cursor", this);
222
		IconThemeHelper.registerIcon("cursor", "ver-arrow-cursor", this);
223
		IconThemeHelper.registerIcon("cursor", "inclder-arrow-cursor", this);
224
		IconThemeHelper.registerIcon("cursor", "inclizq-arrow-cursor", this);
225
		IconThemeHelper.registerIcon("cursor", "shear-y-cursor", this);
226
		IconThemeHelper.registerIcon("cursor", "shear-x-cursor", this);
227
		IconThemeHelper.registerIcon("cursor", "rotate-cursor", this);
228
		IconThemeHelper.registerIcon("cursor", "rot-inf-der-cursor", this);
229
		IconThemeHelper.registerIcon("cursor", "rot-inf-izq-cursor", this);
230
		IconThemeHelper.registerIcon("cursor", "rot-sup-der-cursor", this);
231
		IconThemeHelper.registerIcon("cursor", "rot-sup-izq-cursor", this);
232
		IconThemeHelper.registerIcon("cursor", "point-select-cursor", this);
233
		IconThemeHelper.registerIcon("cursor", "hand-cursor", this);
234
		IconThemeHelper.registerIcon("cursor", "rectangle-select-cursor", this);
235
		IconThemeHelper.registerIcon("cursor", "not-valid-cursor", this);
236
		IconThemeHelper.registerIcon("cursor", "line-cursor", this);
237
		IconThemeHelper.registerIcon("cursor", "polygon-cursor", this);
238
		IconThemeHelper.registerIcon("cursor", "point-cursor", this);
239
		
240
		//Other
241
		IconThemeHelper.registerIcon(null, "forward-icon", this);
242
		IconThemeHelper.registerIcon(null, "backward-icon", this);
243
		IconThemeHelper.registerIcon(null, "blank-icon", this);
244
		IconThemeHelper.registerIcon(null, "addlayer-icon", this);
245
		IconThemeHelper.registerIcon(null, "delall-icon", this);
246
		IconThemeHelper.registerIcon(null, "back-icon", this);
247
		IconThemeHelper.registerIcon(null, "next-icon", this);
248
		IconThemeHelper.registerIcon(null, "undo-icon", this);	
249
		IconThemeHelper.registerIcon(null, "pixel-increase", this);
250
		IconThemeHelper.registerIcon(null, "pref-raster-icon", this);
251
		IconThemeHelper.registerIcon(null, "back-icon", this);
252
		IconThemeHelper.registerIcon(null, "next-icon", this);
253
		IconThemeHelper.registerIcon(null, "undo-icon", this);
254
		//IconThemeHelper.registerIcon(null, "save-raster", this);
255
		IconThemeHelper.registerIcon(null, "pixel-increase", this);
256
		//IconThemeHelper.registerIcon(null, "select-raster", this);
257
		IconThemeHelper.registerIcon(null, "pref-raster-icon", this);
258
		IconThemeHelper.registerIcon(null, "reset-icon", this);
259
		IconThemeHelper.registerIcon(null, "tfwload-icon", this);
260
		IconThemeHelper.registerIcon(null, "centerraster-icon", this);
261
		IconThemeHelper.registerIcon(null, "increase-icon", this);
262
		IconThemeHelper.registerIcon(null, "decrease-icon", this);
263
		IconThemeHelper.registerIcon(null, "selectzoomarea-icon", this);
264
		IconThemeHelper.registerIcon(null, "prevzoom-icon", this);
265
		IconThemeHelper.registerIcon(null, "fullview-icon", this);
266
		IconThemeHelper.registerIcon(null, "exporttoascii-icon", this);
267
		IconThemeHelper.registerIcon(null, "exporttocsv-icon", this);
268
		IconThemeHelper.registerIcon(null, "importfromcsv-icon", this);
269
		IconThemeHelper.registerIcon(null, "exit-icon", this);
270
		IconThemeHelper.registerIcon(null, "options-icon", this);
271
		IconThemeHelper.registerIcon(null, "add-icon", this);
272
		IconThemeHelper.registerIcon(null, "centerpoint-icon", this);
273
		IconThemeHelper.registerIcon(null, "selectrgb-icon", this);
274
		IconThemeHelper.registerIcon(null, "focus-icon", this);
275
		IconThemeHelper.registerIcon(null, "point-icon", this);
276
		IconThemeHelper.registerIcon(null, "line-icon", this);
277
		IconThemeHelper.registerIcon(null, "polygon-icon", this);
278
		IconThemeHelper.registerIcon(null, "import-icon", this);
279
		IconThemeHelper.registerIcon(null, "round-icon", this);
280
		//IconThemeHelper.registerIcon(null, "rois-icon", this);
281
		IconThemeHelper.registerIcon(null, "fullextent-icon", this);
282
		IconThemeHelper.registerIcon(null, "selecttool-icon", this);
283
		IconThemeHelper.registerIcon(null, "forward-icon", this);
284
		IconThemeHelper.registerIcon(null, "backward-icon", this);
285
		IconThemeHelper.registerIcon(null, "datatype-icon", this);
286
		IconThemeHelper.registerIcon(null, "setviewprojection-raster-icon", this);
287
		IconThemeHelper.registerIcon(null, "gvsig-icon", this);
288
		IconThemeHelper.registerIcon(null, "gvsig-icon16x16", this);
289
	}
290
	
291
	public void registerMenuElements() {
292
		// Creaci?n del punto de extensi?n para registrar paneles en el cuadro de propiedades.
293
		ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager();
294
		ExtensionPoint point = extensionPoints.get("GenericToolBarGroup");
295
		point.setDescription("Punto de extension para los grupos de menus del GenericToolBarPanel");
296

  
297
		point = extensionPoints.get("GenericToolBarMenu");
298
		point.setDescription("Punto de extension para los submenus del GenericToolBarPanel");
299
		//point.append("RasterProperties", "", RasterPropertiesTocMenuEntry.getSingleton());
300
		point.append("SelectLayer", "", SelectLayerTocMenuEntry.getSingleton());
301
		point.append("HistogramPanel", "", HistogramTocMenuEntry.getSingleton());
302
		point.append("ViewColorTable", "",ColorTableTocMenuEntry.getSingleton());
303
		if(RasterLocator.getManager().isOverviewBuilderSupported())
304
			point.append("Overviews", "", OverviewsTocMenuEntry.getSingleton());
305
		point.append("RoisManager", "", ROIManagerTocMenuEntry.getSingleton());
306
		point.append("ViewRasterAnalysis", "", ViewRasterAnalysisTocMenuEntry.getSingleton());
307
		point.append("ZoomResolutionLevel", "", ZoomResolutionLevelTocMenuEntry.getSingleton());
308
		
309
		//point.append("SaveRaster", "", SaveViewToRasterTocMenuEntry.getSingleton());
310
		point.append("SaveAs", "", SaveAsTocMenuEntry.getSingleton());
311
		point.append("ClippingPanel", "", ClippingTocMenuEntry.getSingleton());
312
		point.append("SaveViewToRaster", "", SaveViewToRasterTocMenuEntry.getSingleton());
313
		point.append("SaveViewToImageRaster", "", SaveViewToImageTocMenuEntry.getSingleton());
314

  
315
		point.append("FilterPanel", "", FilterTocMenuEntry.getSingleton());
316
		point.append("EnhancedPanel", "", EnhancedTocMenuEntry.getSingleton());
317
		point.append("InfoByPoint", "", InfoByRasterPointTocMenuEntry.getSingleton());
318
		point.append("LayerDatatype", "", LayerDatatypeTocMenuEntry.getSingleton());
319
		
320
		point.append("GeoLocation", "", GeoLocationTocMenuEntry.getSingleton());
321
		point.append("SetProjection", "", SetViewProjectionTocMenuEntry.getSingleton());
322

  
323
	}
324
	
325
	public boolean isEnabled() {
326
		org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow();
327
		if (f == null)
328
			return false;
329
		if (f instanceof AbstractViewPanel) {
330
			FLayers lyrs = ((AbstractViewPanel)f).getMapControl().getMapContext().getLayers();
331
			for (int i = 0; i < lyrs.getLayersCount(); i++)
332
				if (lyrs.getLayer(i) instanceof FLyrRaster)
333
					return true;
334
		}
335
		return false;
336
	}
337

  
338
	/**
339
	 * Mostramos el control si hay alguna capa cargada.
340
	 */
341
	public boolean isVisible() {
342
		org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow();
343
		if (f == null)
344
			return false;
345

  
346
		if (f instanceof AbstractViewPanel) {
347
			FLayers lyrs = ((AbstractViewPanel)f).getMapControl().getMapContext().getLayers();
348
			if (lyrs.getLayersCount() > 0) 
349
				return true;
350
		}
351

  
352
		return false;
353
	}
354

  
355
	/**
356
	 * Carga los valores de configuracion iniciales
357
	 */
358
	private void loadConfigurationValues() {
359
		autoRefreshView = Configuration.getValue("general_auto_preview", Boolean.TRUE).booleanValue();
360
		askCoordinates = Configuration.getValue("general_ask_coordinates", Boolean.FALSE).booleanValue();
361
		RasterLibrary.defaultNumberOfClasses = Configuration.getValue("general_defaultNumberOfClasses", Integer.valueOf(RasterLibrary.defaultNumberOfClasses)).intValue();
362
		RasterLibrary.cacheSize = Configuration.getValue("cache_size", Long.valueOf(RasterLibrary.cacheSize)).longValue();
363
		RasterLibrary.pageSize = Configuration.getValue("cache_pagesize", Double.valueOf(RasterLibrary.pageSize)).doubleValue();
364
		RasterLibrary.pagsPerGroup = Configuration.getValue("cache_pagspergroup", Integer.valueOf(RasterLibrary.pagsPerGroup)).intValue();
365
		RasterLibrary.blockHeight = Configuration.getValue("cache_blockheight", Integer.valueOf(RasterLibrary.blockHeight)).intValue();
366
		//RasterLibrary.defaultNoDataValue = Configuration.getValue("nodata_value", Double.valueOf(RasterLibrary.defaultNoDataValue)).doubleValue();
367
	}
368

  
369
	@SuppressWarnings("deprecation")
370
	public void actionConfigurationChanged(ConfigurationEvent e) {
371
		if (e.getKey().equals("nodata_transparency_enabled")) {
372
			boolean noDataTransparent = ((Boolean) e.getValue()).booleanValue();
373
			IWindow[] f = PluginServices.getMDIManager().getAllWindows();
374
			if (f == null)
375
				return;
376
			for (int i = 0; i < f.length; i++)
377
				if (f[i] instanceof AbstractViewPanel) {
378
					AbstractViewPanel vista = (AbstractViewPanel) f[i];
379
					ViewDocument model = vista.getModel();
380
					MapContext map = model.getMapContext();
381
					FLayers lyrs = map.getLayers();
382

  
383
					ArrayList<FLayer> list = RasterToolsUtil.getRasterLayerList(lyrs, null);
384
					for (int j = 0; j < list.size(); j++)
385
						if(list.get(j) instanceof FLyrRaster)
386
							((RasterDataStore)((FLyrRaster)list.get(j)).getDataStore()).getNoDataValue().setNoDataTransparent(noDataTransparent);
387
				}
388

  
389
			return;
390
		}
391

  
392
		if (e.getKey().equals("general_auto_preview")) {
393
			if(e.getValue() instanceof String)
394
				autoRefreshView = new Boolean((String) e.getValue()).booleanValue();
395
			if(e.getValue() instanceof Boolean)
396
				autoRefreshView = ((Boolean) e.getValue()).booleanValue();
397
			return;
398
		}
399

  
400
		if (e.getKey().equals("general_ask_coordinates")) {
401
			if(e.getValue() instanceof String)
402
				askCoordinates = new Boolean((String) e.getValue()).booleanValue();
403
			if(e.getValue() instanceof Boolean)
404
				askCoordinates = ((Boolean) e.getValue()).booleanValue();
405
			return;
406
		}
407

  
408
		if (e.getKey().equals("general_defaultNumberOfClasses")) {
409
			if(e.getValue() instanceof String)
410
				try {
411
					RasterLibrary.defaultNumberOfClasses = new Integer(
412
							(String) e.getValue()).intValue();
413
				} catch (NumberFormatException exc) {
414
					//Valor por defecto en el n?mero de clases
415
				}
416

  
417
			if(e.getValue() instanceof Integer)
418
				RasterLibrary.defaultNumberOfClasses = ((Integer) e.getValue()).intValue();
419
			return;
420
		}
421

  
422
		if (e.getKey().equals("cache_size")) {
423
			if(e.getValue() instanceof String)
424
				try {
425
					RasterLibrary.cacheSize = new Long((String) e.getValue()).longValue();
426
				} catch (NumberFormatException exc) {
427
					//Valor por defecto en la cache
428
				}
429
			if(e.getValue() instanceof Long)
430
				RasterLibrary.cacheSize = ((Long) e.getValue()).longValue();
431
			return;
432
		}
433

  
434
		if (e.getKey().equals("cache_pagesize")) {
435
			if(e.getValue() instanceof String)
436
				try {
437
					RasterLibrary.pageSize = new Double((String) e.getValue())
438
							.doubleValue();
439
				} catch (NumberFormatException exc) {
440
					//Valor por defecto en la cache
441
				}
442

  
443
			if(e.getValue() instanceof Double)
444
				RasterLibrary.pageSize = ((Double) e.getValue()).doubleValue();
445
			return;
446
		}
447

  
448
		if (e.getKey().equals("cache_pagspergroup")) {
449
			if(e.getValue() instanceof String)
450
				try {
451
					RasterLibrary.pagsPerGroup = new Integer((String) e
452
							.getValue()).intValue();
453
				} catch (NumberFormatException exc) {
454
					//Valor por defecto en la cache
455
				}
456

  
457
			if(e.getValue() instanceof Integer)
458
				RasterLibrary.pagsPerGroup = ((Integer) e.getValue()).intValue();
459
			return;
460
		}
461

  
462
		if (e.getKey().equals("cache_blockheight")) {
463
			if(e.getValue() instanceof String)
464
				try {
465
					RasterLibrary.blockHeight = new Integer((String) e
466
							.getValue()).intValue();
467
				} catch (NumberFormatException exc) {
468
					//Valor por defecto en la cache
469
				}
470
			if(e.getValue() instanceof Integer)
471
				RasterLibrary.blockHeight = ((Integer) e.getValue()).intValue();
472
			return;
473
		}
474

  
475
		/*if (e.getKey().equals("nodata_value")) {
476
			if(e.getValue() instanceof String)
477
				try {
478
					RasterLibrary.defaultNoDataValue = new Double((String) e
479
							.getValue()).doubleValue();
480
				} catch (NumberFormatException exc) {
481
					//Valor por defecto en valor nodata
482
				}
483

  
484
			if(e.getValue() instanceof Double)
485
				RasterLibrary.defaultNoDataValue = ((Double) e.getValue()).doubleValue();
486
			return;
487
		}*/
488

  
489
	}
490

  
491
	public void execute(ITocItem item, FLayer[] selectedItems) {
492
		this.execute("SELECTIMAGE");
493
	}
494

  
495
	public void postInitialize() {
496
		super.postInitialize();
497
		new ToolboxRasterToolsLoader().registerTool();
498
	}
499
	
500
	public boolean canQueryByAction() {
501
		return true;	
502
	}
503
	
504
	public boolean isEnabled(String action) {
505
		//Las entradas en GenericToolBarModule est?n registradas con la misma etiqueta que el actionCommand
506
		//De esta forma pueden recuperarse los TocMenuEntry del punto de extensi?n y ejecutar isEnable a
507
		//trav?s de este.
508
		if(getGenericToolBarMenuExtensionPoint() != null && getGenericToolBarMenuExtensionPoint().get(action) != null) {
509
			ExtensionBuilder ext = getGenericToolBarMenuExtensionPoint().get(action).getBuilder();
510
			if(ext != null && ext instanceof AbstractTocContextMenuAction) {
511
				IWindow w = PluginServices.getMDIManager().getActiveWindow();
512
				if(w instanceof AbstractViewPanel) {
513
					FLayers lyrs = ((AbstractViewPanel)w).getMapControl().getMapContext().getLayers();
514
					FLayer[] actives = lyrs.getActives();
515
					return ((AbstractTocContextMenuAction)ext).isEnabled(null, actives);
516
				}
517
			}
518
		}
519
		return false;
520
	}
521
	
522
	public boolean isVisible(String action) {
523
		//Las entradas en GenericToolBarModule est?n registradas con la misma etiqueta que el actionCommand
524
		//De esta forma pueden recuperarse los TocMenuEntry del punto de extensi?n y ejecutar isVisible a
525
		//trav?s de este.
526
		if(getGenericToolBarMenuExtensionPoint() != null && getGenericToolBarMenuExtensionPoint().get(action) != null) {
527
			ExtensionBuilder ext = getGenericToolBarMenuExtensionPoint().get(action).getBuilder();
528
			if(ext != null && ext instanceof AbstractTocContextMenuAction) {
529
				IWindow w = PluginServices.getMDIManager().getActiveWindow();
530
				if(w instanceof AbstractViewPanel) {
531
					FLayers lyrs = ((AbstractViewPanel)w).getMapControl().getMapContext().getLayers();
532
					FLayer[] actives = lyrs.getActives();
533
					return ((AbstractTocContextMenuAction)ext).isVisible(null, actives);
534
				}
535
			}
536
		}
537
		return false;
538
	}
539
	
540
	public ExtensionPoint getGenericToolBarMenuExtensionPoint() {
541
		if(genericToolBarMenuExtensionPoint == null) {
542
			ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager();
543
			genericToolBarMenuExtensionPoint = extensionPoints.get("GenericToolBarMenu");
544
		}
545
		return genericToolBarMenuExtensionPoint;
546
	}
547
}
0 548

  
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.8/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/geolocation/ui/GeoLocationOpeningRasterTransfPanel.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22
package org.gvsig.raster.tools.app.basic.tool.geolocation.ui;
23

  
24
import java.awt.GridBagConstraints;
25
import java.awt.GridBagLayout;
26
import java.awt.GridLayout;
27
import java.awt.geom.AffineTransform;
28

  
29
import javax.swing.JPanel;
30

  
31
import org.gvsig.andami.PluginServices;
32
import org.gvsig.fmap.dal.coverage.RasterLocator;
33
import org.gvsig.fmap.dal.coverage.util.MathUtils;
34
import org.gvsig.fmap.mapcontext.ViewPort;
35
import org.gvsig.gui.beans.datainput.DataInputContainer;
36
import org.gvsig.raster.fmap.layers.FLyrRaster;
37
import org.gvsig.raster.tools.app.basic.tool.geolocation.listener.GeoLocationPanelListener;
38

  
39

  
40
/**
41
 * Panel de geolocalizaci?n. Este muestra los par?metros de la matriz de transformaci?n
42
 * que est? aplicandose en esos momentos al raster. 
43
 * 
44
 * @version 12/12/2007
45
 * @author Nacho Brodin (nachobrodin@gmail.com)
46
 *
47
 */
48
public class GeoLocationOpeningRasterTransfPanel extends GeolocationBaseClassPanel {
49
	private static final long         serialVersionUID = -7797379892312214949L;
50
	private DataInputContainer	       ulx = null;
51
	private DataInputContainer	       uly = null;
52
	private DataInputContainer	       psx = null;
53
	private DataInputContainer	       psy = null;
54
	private DataInputContainer	       rotx = null;
55
	private DataInputContainer	       roty = null;
56
	
57
		
58
	private JPanel			           coordsPanel = null;
59
	private JPanel			           paramsPanel = null;
60
	
61
	/**
62
     * N?mero de decimales a mostrar
63
     */
64
    private int                        tailValue = 2;
65
	
66
	/**
67
	 * Constructor
68
	 */
69
	public GeoLocationOpeningRasterTransfPanel(GeoLocationPanelListener list) {
70
		this.listener = list;
71
		GridBagLayout gl = new GridBagLayout();
72
		this.setLayout(gl);
73
		setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this, "geolocation"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
74
		
75
		ulx = new DataInputContainer();
76
		ulx.setLabelText(PluginServices.getText(this,"ux"));
77
		ulx.addValueChangedListener(listener);
78
		ulx.addKeyListener(listener);
79
		
80
		uly = new DataInputContainer();
81
		uly.setLabelText(PluginServices.getText(this,"uy"));
82
		uly.addValueChangedListener(listener);
83
		uly.addKeyListener(listener);
84
		
85
		psx = new DataInputContainer();
86
		psx.setLabelText(PluginServices.getText(this,"px"));
87
		psx.addValueChangedListener(listener);
88
		psx.addKeyListener(listener);
89
		
90
		psy = new DataInputContainer();
91
		psy.setLabelText(PluginServices.getText(this,"py"));
92
		psy.addValueChangedListener(listener);
93
		psy.addKeyListener(listener);
94
		
95
		rotx = new DataInputContainer();
96
		rotx.setLabelText(PluginServices.getText(this,"rx"));
97
		rotx.addValueChangedListener(listener);
98
		rotx.addKeyListener(listener);
99
		
100
		roty = new DataInputContainer();
101
		roty.setLabelText(PluginServices.getText(this,"ry"));
102
		roty.addValueChangedListener(listener);
103
		roty.addKeyListener(listener);
104
				
105
		coordsPanel = new JPanel();
106
		GridLayout l = new GridLayout(2, 1);
107
		l.setVgap(2);
108
		coordsPanel.setLayout(l);
109
		
110
		paramsPanel = new JPanel();
111
		GridLayout l1 = new GridLayout(2, 2);
112
		l1.setVgap(2);
113
		paramsPanel.setLayout(l1);
114

  
115
		init();
116
	}
117
	
118
	private void init() {
119
		coordsPanel.add(ulx);
120
		coordsPanel.add(uly);
121
		paramsPanel.add(psx);
122
		paramsPanel.add(psy);
123
		paramsPanel.add(rotx);
124
		paramsPanel.add(roty);
125
				
126
		GridBagConstraints gbc = new GridBagConstraints();
127
				
128
		gbc.fill = GridBagConstraints.HORIZONTAL;
129
		gbc.gridx = 0;
130
		gbc.gridy = 0;
131
		gbc.insets = new java.awt.Insets(1, 1, 1, 1);
132
		this.add(coordsPanel, gbc);
133
		
134
		gbc.gridy = 1;
135
		gbc.weightx = 1.0;
136
		this.add(paramsPanel, gbc);
137
		
138
	}
139
	
140
	/**
141
	 * Activa o desactiva los botones de transformaci?n anterior y siguiente dependiendo
142
	 * del estado de la lista de transformaciones.
143
	 * @return
144
	 */
145
	public void activeButtons() {
146

  
147
	}
148
	
149
	/**
150
	 * Asigna la capa raster del raster seleccionado en el TOC en base 
151
	 * al cual se asigna la georreferenciaci?n al dialogo.
152
	 * @param lyr
153
	 */
154
	public void setParams(FLyrRaster lyr, ViewPort vp) {
155
		setLayer(lyr);
156
		setViewPort(vp);
157
		loadTransform(lyr.getAffineTransform());
158
	}
159

  
160
	/**
161
	 * Carga los par?metros en el dialogo a partir de la capa
162
	 * @param lyr Capa raster
163
	 */
164
	public void loadTransform(AffineTransform at) {
165
		listener.setEnableValueChangeEvent(false);
166
		MathUtils math = RasterLocator.getManager().getMathUtils();
167
		setUlx(String.valueOf(math.format(at.getTranslateX(), tailValue)));
168
		setUly(String.valueOf(math.format(at.getTranslateY(), tailValue)));
169
		setPsx(String.valueOf(math.format(at.getScaleX(), tailValue)));
170
		setPsy(String.valueOf(math.format(at.getScaleY(), tailValue)));
171
		setRotx(String.valueOf(math.format(at.getShearX(), tailValue)));
172
		setRoty(String.valueOf(math.format(at.getShearY(), tailValue)));
173
		listener.setEnableValueChangeEvent(true);
174
	}
175
	
176
	/**
177
	 * Asigna el tama?o de pixel en X
178
	 * @param psx
179
	 */
180
	public void setPsx(String psx) {
181
		this.psx.setValue(psx);
182
	}
183

  
184
	/**
185
	 * Asigna el tama?o de pixel en Y
186
	 * @param psy
187
	 */
188
	public void setPsy(String psy) {
189
		this.psy.setValue(psy);
190
	}
191

  
192
	/**
193
	 * Asigna la rotaci?n en X
194
	 * @param rotx
195
	 */
196
	public void setRotx(String rotx) {
197
		this.rotx.setValue(rotx);
198
	}
199

  
200
	/**
201
	 * Asigna la rotaci?n en Y
202
	 * @param roty
203
	 */
204
	public void setRoty(String roty) {
205
		this.roty.setValue(roty);
206
	}
207

  
208
	/**
209
	 * Asigna la coordenada superior izquierda
210
	 * @param ulx 
211
	 */
212
	public void setUlx(String ulx) {
213
		this.ulx.setValue(ulx);
214
	}
215

  
216
	/**
217
	 * Asigna la coordenada superior derecha
218
	 * @param ulx 
219
	 */
220
	public void setUly(String uly) {
221
		this.uly.setValue(uly);
222
	}
223
	
224
	/**
225
	 * Obtiene el tama?o de pixel en X
226
	 * @return
227
	 */
228
	public DataInputContainer getPsx() {
229
		return psx;
230
	}
231

  
232
	/**
233
	 * Obtiene el tama?o de pixel en Y
234
	 * @return
235
	 */
236
	public DataInputContainer getPsy() {
237
		return psy;
238
	}
239

  
240
	/**
241
	 * Obtiene la rotaci?n en X
242
	 * @return
243
	 */
244
	public DataInputContainer getRotx() {
245
		return rotx;
246
	}
247

  
248
	/**
249
	 * Obtiene la rotaci?n en Y
250
	 * @return
251
	 */
252
	public DataInputContainer getRoty() {
253
		return roty;
254
	}
255

  
256
	/**
257
	 * Obtiene la X de la coordenada superior izquierda
258
	 * @return
259
	 */
260
	public DataInputContainer getUlx() {
261
		return ulx;
262
	}
263

  
264
	/**
265
	 * Obtiene la Y de la coordenada superior izquierda
266
	 * @return
267
	 */
268
	public DataInputContainer getUly() {
269
		return uly;
270
	}
271
	
272
}
0 273

  
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.8/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/geolocation/ui/GeoLocationDialog.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22
package org.gvsig.raster.tools.app.basic.tool.geolocation.ui;
23

  
24
import java.awt.BorderLayout;
25
import java.awt.Dimension;
26
import java.awt.geom.AffineTransform;
27

  
28
import javax.swing.JPanel;
29

  
30
import org.gvsig.andami.PluginServices;
31
import org.gvsig.andami.ui.mdiManager.IWindow;
32
import org.gvsig.andami.ui.mdiManager.IWindowListener;
33
import org.gvsig.andami.ui.mdiManager.WindowInfo;
34
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel;
35
import org.gvsig.fmap.dal.coverage.exception.RmfSerializerException;
36
import org.gvsig.fmap.mapcontext.ViewPort;
37
import org.gvsig.fmap.mapcontext.layers.FLayer;
38
import org.gvsig.fmap.mapcontext.layers.FLayers;
39
import org.gvsig.fmap.mapcontrol.MapControl;
40
import org.gvsig.raster.fmap.layers.FLyrRaster;
41
import org.gvsig.raster.swing.RasterSwingLibrary;
42
import org.gvsig.raster.tools.app.basic.tool.geolocation.behavior.ITransformIO;
43

  
44

  
45
/**
46
 * Dialogo de geolocalizaci?n de raster.
47
 * 
48
 * @version 30/07/2007
49
 * @author Nacho Brodin (nachobrodin@gmail.com)
50
 *
51
 */
52
public class GeoLocationDialog extends JPanel implements IWindow, IWindowListener, ITransformIO {
53
	private static final long serialVersionUID = 7362459094802955247L;
54
	private GeoLocationPanel  geolocationPanel = null;
55

  
56
	/**
57
	 * Posici?n de la ventana en X y en Y
58
	 */
59
	private int               posWindowX       = 0;
60
	private int               posWindowY       = 0;
61

  
62
	private int               widthWindow      = 272;
63
	private int               heightWindow     = 155;
64

  
65
	private String            lastTool         = null;
66
	private AbstractViewPanel          view             = null;
67

  
68
	/**
69
	 * Constructor
70
	 */
71
	public GeoLocationDialog() {
72
		BorderLayout bl = new BorderLayout(5, 5);
73
		this.setLayout(bl);
74
		
75
		this.add(getGeoLocationPanel());
76
	}
77
	
78
	/**
79
	 * Constructor. Asigna la capa raster.
80
	 *
81
	 */
82
	public GeoLocationDialog(FLyrRaster lyr, ViewPort vp, AbstractViewPanel view) {
83
		this.view = view;
84
		BorderLayout bl = new BorderLayout(5, 5);
85
		this.setLayout(bl);
86

  
87
		this.add(getGeoLocationPanel());
88
		getGeoLocationPanel().setParams(lyr, vp);
89
	}
90
	
91
	/**
92
	 * Obtiene la vista asociada a este dialogo
93
	 * @return BaseView
94
	 */
95
	public AbstractViewPanel getAssociateView() {
96
		return view;
97
	}
98
	
99
	/**
100
	 * Asigna la posici?n de la ventana
101
	 * @param x Posici?n en X
102
	 * @param y Posici?n en Y
103
	 */
104
	public void setPosition(int x, int y) {
105
		this.posWindowX = x;
106
		this.posWindowY = y;
107
	}
108
	
109
	/**
110
	 * Obtiene el tama?o de la ventana
111
	 * @return
112
	 */
113
	public Dimension getSizeWindow() {
114
		return new Dimension(widthWindow, heightWindow);
115
	}
116
	
117
	/**
118
	 * Referencia la capa que est? seleccionada
119
	 *
120
	 */
121
	private void loadLayer(ViewPort vp) {
122
		if(getGeoLocationPanel().getLayer() != null)
123
			return;
124
		//Este c?digo es para poder lanzar la funcionalidad desde la barra de herramientas y no desde el TOC
125
		FLayers flyrs = getGeoLocationPanel().getMapCtrl().getMapContext().getLayers();
126
		FLayer[] actives = flyrs.getActives();
127
		for (int i = 0; i < actives.length; i++) {
128
			if(actives[i] instanceof FLyrRaster) {
129
				getGeoLocationPanel().setParams(((FLyrRaster)actives[i]), vp);
130
				break;
131
			}
132
		}
133
	}
134
	
135
	/**
136
	 * Acciones de inicializaci?n
137
	 *
138
	 */
139
	public void init(MapControl mapCtrl) {
140
		geolocationPanel.setMapCtrl(mapCtrl);
141
		lastTool = mapCtrl.getCurrentTool();
142
		loadLayer(mapCtrl.getViewPort());
143
		FLyrRaster lyr = getGeoLocationPanel().getLayer();
144
		if(lyr != null) {
145
			lyr.getAffineTransformHistorical().clear();
146
			lyr.getAffineTransformHistorical().add(lyr.getDataStore().getAffineTransform());
147
			loadTransform(lyr.getDataStore().getAffineTransform());
148
		}
149
		activeButtons();
150
	}
151
	
152
	/**
153
	 * Carga los par?metros en el dialogo a partir de la capa
154
	 * @param lyr Capa raster
155
	 */
156
	public void loadTransform(AffineTransform at) {
157
		geolocationPanel.loadTransform(at);
158
	}
159
	
160
	/**
161
	 * Activa o desactiva los botones de transformaci?n anterior y siguiente dependiendo
162
	 * del estado de la lista de transformaciones.
163
	 * @return
164
	 */
165
	public void applyTransformation() {
166
		geolocationPanel.setModify(true);
167
		geolocationPanel.activeButtons();	
168
	}
169
	/**
170
	 * Obtiene el panel con el histograma
171
	 * @return HistogramPanel
172
	 */
173
	public GeoLocationPanel getGeoLocationPanel(){
174
		if (geolocationPanel == null) 
175
			geolocationPanel = new GeoLocationPanel(this);
176
		
177
		return geolocationPanel;
178
	}
179

  
180
	/**
181
	 * Activa o desactiva los botones de transformaci?n anterior y siguiente dependiendo
182
	 * del estado de la lista de transformaciones.
183
	 * @return
184
	 */
185
	public void activeButtons() {
186
		getGeoLocationPanel().activeButtons();
187
	}
188
	
189
	/*
190
	 * (non-Javadoc)
191
	 * @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo()
192
	 */
193
	public WindowInfo getWindowInfo() {
194
		WindowInfo m_viewinfo=new WindowInfo(WindowInfo.MODELESSDIALOG | WindowInfo.RESIZABLE);
195
		m_viewinfo.setHeight(heightWindow);
196
		m_viewinfo.setWidth(widthWindow);
197
		m_viewinfo.setX(posWindowX);
198
		m_viewinfo.setY(posWindowY);
199
		return m_viewinfo;
200
	}
201

  
202
	/**
203
	 * Asigna el ?ltimo tool seleccionado antes de abrir el di?logo para 
204
	 * restaurarlo cuando se cierre este.
205
	 * @param tool
206
	 */
207
	public void setLastTool(String tool) {
208
		this.lastTool = tool;
209
	}
210
	
211
	/*
212
	 * (non-Javadoc)
213
	 * @see com.iver.andami.ui.mdiManager.IWindowListener#windowActivated()
214
	 */
215
	public void windowActivated() {
216
	}
217

  
218
	/*
219
	 * (non-Javadoc)
220
	 * @see com.iver.andami.ui.mdiManager.IWindowListener#windowClosed()
221
	 */
222
	public void windowClosed() {
223
		//Se consulta si se desean salvar los cambios
224
		if(geolocationPanel.getModify()) {
225
			if(RasterSwingLibrary.messageBoxYesOrNot(PluginServices.getText(this,"aviso_salir_salvando"), geolocationPanel)) {
226
				try {
227
					geolocationPanel.getLayer().saveGeoToRmf();
228
				} catch (RmfSerializerException e1) {
229
					RasterSwingLibrary.messageBoxError(PluginServices.getText(this,"error_salvando_rmf"), geolocationPanel, e1);
230
				}
231
			}
232
			geolocationPanel.setModify(false);
233
		}
234
		
235
		//Restauramos la tool que hab?a antes de de activar la actual
236
		if(lastTool != null)
237
			getGeoLocationPanel().getMapCtrl().setTool(lastTool);
238
		
239
		//TODO: Si queremos usar la funcionalidad de geolocalizaci?n desde la barra de herramientas deberemos 
240
		//, al cerrar la ventana, asignar la capa raster de GeoRasterBehevior a null ya que sino se aplicar?n las
241
		//transformaciones sobre la ?ltima capa que se abri? desde el men? del TOC
242
	}
243

  
244
	public Object getWindowProfile() {
245
		return WindowInfo.PROPERTIES_PROFILE;
246
	}
247
}
0 248

  
org.gvsig.raster.tools/tags/org.gvsig.raster.tools-2.2.8/org.gvsig.raster.tools.app.basic/src/main/java/org/gvsig/raster/tools/app/basic/tool/geolocation/ui/GeoLocationPanel.java
1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22
package org.gvsig.raster.tools.app.basic.tool.geolocation.ui;
23

  
24
import java.awt.Dimension;
25
import java.awt.GridBagConstraints;
26
import java.awt.GridBagLayout;
27
import java.awt.GridLayout;
28
import java.awt.geom.AffineTransform;
29

  
30
import javax.swing.ImageIcon;
31
import javax.swing.JButton;
32
import javax.swing.JPanel;
33

  
34
import org.gvsig.andami.IconThemeHelper;
35
import org.gvsig.andami.PluginServices;
36
import org.gvsig.fmap.dal.coverage.RasterLocator;
37
import org.gvsig.fmap.dal.coverage.util.Historical;
38
import org.gvsig.fmap.dal.coverage.util.MathUtils;
39
import org.gvsig.fmap.mapcontext.ViewPort;
40
import org.gvsig.gui.beans.datainput.DataInputContainer;
41
import org.gvsig.raster.fmap.layers.FLyrRaster;
42
import org.gvsig.raster.tools.app.basic.tool.geolocation.listener.GeoLocationPanelListener;
43

  
44

  
45
/**
46
 * Panel de geolocalizaci?n. Este muestra los par?metros de la matriz de transformaci?n
47
 * que est? aplicandose en esos momentos al raster. Los par?metros son variados en 
48
 * tiempo real a medida que modificamos la georreferenciaci?n con las herramientas.
49
 * 
50
 * @version 30/07/2007
51
 * @author Nacho Brodin (nachobrodin@gmail.com)
52
 *
53
 */
54
public class GeoLocationPanel extends GeolocationBaseClassPanel {
55
	private static final long         serialVersionUID = -7797379892312214949L;
56
	private DataInputContainer	       ulx             = null;
57
	private DataInputContainer	       uly             = null;
58
	private DataInputContainer	       psx             = null;
59
	private DataInputContainer	       psy             = null;
60
	private DataInputContainer	       rotx            = null;
61
	private DataInputContainer	       roty            = null;
62
	private JButton                    first           = null;
63
	private JButton                    save            = null;
64
	private JButton                    back            = null;
65
	private JButton                    next            = null;
66
	private JButton                    apply           = null;
67
	private JButton                    reset           = null;
68
	private JButton                    tfwload         = null;
69
	private JButton                    center          = null;
70
	private JButton                    focus           = null;
71
	
72
	private JPanel			           coordsPanel     = null;
73
	private JPanel			           paramsPanel     = null;
74
	private JPanel			           buttonsPanel    = null;
75
		
76
	/**
77
	 * Constructor
78
	 */
79
	public GeoLocationPanel(GeoLocationDialog dialog) {
80
		ImageIcon backIcon = null;
81
		ImageIcon nextIcon = null;
82
		ImageIcon saveIcon = null;
83
		ImageIcon firstIcon = null;
84
		ImageIcon resetIcon = null;
85
		ImageIcon tfwLoadIcon = null;
86
		ImageIcon centerRasterIcon = null;
87
		ImageIcon focusIcon = null;
88
		try {
89
			backIcon = IconThemeHelper.getImageIcon("back-icon");
90
			nextIcon = IconThemeHelper.getImageIcon("next-icon");
91
			saveIcon = IconThemeHelper.getImageIcon("layer-saveas"); 
92
			firstIcon = IconThemeHelper.getImageIcon("undo-icon");
93
			resetIcon = IconThemeHelper.getImageIcon("reset-icon");
94
			centerRasterIcon = IconThemeHelper.getImageIcon("centerraster-icon");
95
			tfwLoadIcon = IconThemeHelper.getImageIcon("tfwload-icon");
96
			focusIcon = IconThemeHelper.getImageIcon("focus-icon");
97
		} catch(NullPointerException e) {
98
			
99
		}
100
		
101
		listener = new GeoLocationPanelListener(this, dialog);
102
		
103
		GridBagLayout gl = new GridBagLayout();
104
		this.setLayout(gl);
105
		setBorder(javax.swing.BorderFactory.createTitledBorder(null, PluginServices.getText(this, "geolocation"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
106
		ulx = new DataInputContainer();
107
		ulx.setLabelText(PluginServices.getText(this,"ux"));
108
		ulx.addValueChangedListener(listener);
109
		
110
		uly = new DataInputContainer();
111
		uly.setLabelText(PluginServices.getText(this,"uy"));
112
		uly.addValueChangedListener(listener);
113
		
114
		psx = new DataInputContainer();
115
		psx.setLabelText(PluginServices.getText(this,"px"));
116
		psx.addValueChangedListener(listener);
117
		
118
		psy = new DataInputContainer();
119
		psy.setLabelText(PluginServices.getText(this,"py"));
120
		psy.addValueChangedListener(listener);
121
		
122
		rotx = new DataInputContainer();
123
		rotx.setLabelText(PluginServices.getText(this,"rx"));
124
		rotx.addValueChangedListener(listener);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff