gvsig-raster / org.gvsig.raster.georeferencing / trunk / org.gvsig.raster.georeferencing / org.gvsig.raster.georeferencing.app / org.gvsig.raster.georeferencing.app.georeferencingclient / src / main / java / org / gvsig / raster / georeferencing / app / georeferencingclient / listener / LauncherDialogListener.java @ 1724
History | View | Annotate | Download (3.89 KB)
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.georeferencing.app.georeferencingclient.listener; |
23 |
|
24 |
import java.awt.geom.AffineTransform; |
25 |
|
26 |
import org.gvsig.andami.PluginServices; |
27 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
28 |
import org.gvsig.app.project.documents.view.gui.IView; |
29 |
import org.gvsig.fmap.dal.coverage.store.RasterDataStore; |
30 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanel; |
31 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelEvent; |
32 |
import org.gvsig.gui.beans.buttonspanel.ButtonsPanelListener; |
33 |
import org.gvsig.raster.georeferencing.app.georeferencingclient.Georeferencing; |
34 |
import org.gvsig.raster.georeferencing.framework.GeoreferencingFrameworkLocator; |
35 |
import org.gvsig.raster.georeferencing.framework.GeoreferencingFrameworkManager; |
36 |
import org.gvsig.raster.georeferencing.swing.GeoreferencingLauncher; |
37 |
import org.gvsig.raster.georeferencing.swing.GeoreferencingOptionsDataModel; |
38 |
import org.gvsig.raster.georeferencing.swing.GeoreferencingSwingLocator; |
39 |
import org.gvsig.raster.tools.app.basic.RasterToolsUtil; |
40 |
|
41 |
/**
|
42 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
43 |
*/
|
44 |
public class LauncherDialogListener implements ButtonsPanelListener { |
45 |
private GeoreferencingLauncher launcherDialog = null; |
46 |
private Georeferencing app = null; |
47 |
|
48 |
public LauncherDialogListener(
|
49 |
Georeferencing app, |
50 |
GeoreferencingLauncher launcher) { |
51 |
this.launcherDialog = launcher;
|
52 |
this.app = app;
|
53 |
} |
54 |
|
55 |
public void actionButtonPressed(ButtonsPanelEvent e) { |
56 |
//-----------------
|
57 |
// Bot?n de Aceptar
|
58 |
if (e.getButton() == ButtonsPanel.BUTTON_ACCEPT) {
|
59 |
if(launcherDialog != null) { |
60 |
launcherDialog.buildDataModel(); |
61 |
GeoreferencingOptionsDataModel dataModel = GeoreferencingSwingLocator.getSwingManager().getDataModel(); |
62 |
if(dataModel.getType() == Georeferencing.WITH_MAP) {
|
63 |
boolean findView = false; |
64 |
IWindow[] windowList = PluginServices.getMDIManager().getAllWindows();
|
65 |
for (int i = 0; i < windowList.length; i++) |
66 |
if(windowList[i] instanceof IView && windowList[i].getWindowInfo().getTitle().endsWith(": " + dataModel.getSelectedView())) |
67 |
findView = true;
|
68 |
|
69 |
if(!findView) {
|
70 |
RasterToolsUtil.messageBoxError("no_view_found", this); |
71 |
return;
|
72 |
} |
73 |
} |
74 |
|
75 |
RasterDataStore storeToGeoref = dataModel.getDataStore(); |
76 |
//Inicializamos la matriz de transformaci?n en la imagen que vamos a georreferenciar para
|
77 |
//que nos de coordenadas pixel
|
78 |
if(storeToGeoref == null) |
79 |
RasterToolsUtil.messageBoxError("layer_not_loaded", this); |
80 |
else {
|
81 |
storeToGeoref.setAffineTransform(new AffineTransform(1, 0, 0, -1, 0, 0)); |
82 |
GeoreferencingFrameworkManager fManager = GeoreferencingFrameworkLocator.getManager(); |
83 |
fManager.closeWindow(launcherDialog.getComponent()); |
84 |
app.endLauncherDialog(dataModel); |
85 |
} |
86 |
} |
87 |
} |
88 |
|
89 |
//----------------
|
90 |
// Bot?n de Cerrar
|
91 |
if (e.getButton() == ButtonsPanel.BUTTON_CANCEL) {
|
92 |
GeoreferencingFrameworkManager fManager = GeoreferencingFrameworkLocator.getManager(); |
93 |
fManager.closeWindow(launcherDialog.getComponent()); |
94 |
} |
95 |
} |
96 |
|
97 |
} |