gvsig-raster / org.gvsig.raster.reproject / branches / org.gvsig.raster.reproject_dataaccess_refactoring / org.gvsig.raster.reproject.app.reprojectclient / src / main / java / org / gvsig / raster / reproject / app / ReprojectTocMenuEntry.java @ 2367
History | View | Annotate | Download (3.8 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.reproject.app; |
23 |
|
24 |
import javax.swing.Icon; |
25 |
|
26 |
import org.gvsig.andami.IconThemeHelper; |
27 |
import org.gvsig.andami.PluginServices; |
28 |
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction; |
29 |
import org.gvsig.app.project.documents.view.toc.ITocItem; |
30 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
31 |
import org.gvsig.i18n.Messages; |
32 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
33 |
import org.gvsig.raster.fmap.layers.IRasterLayerActions; |
34 |
import org.gvsig.raster.mainplugin.toolbar.IGenericToolBarMenuItem; |
35 |
import org.gvsig.raster.reproject.algorithm.RasterReprojectionSwingLocator; |
36 |
import org.gvsig.raster.reproject.algorithm.swing.api.RasterReprojectionPanel; |
37 |
import org.gvsig.raster.reproject.algorithm.swing.api.ReprojectionPanelDataModel; |
38 |
|
39 |
|
40 |
/**
|
41 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
42 |
*/
|
43 |
public class ReprojectTocMenuEntry extends AbstractTocContextMenuAction |
44 |
implements IGenericToolBarMenuItem {
|
45 |
static private ReprojectTocMenuEntry singleton = null; |
46 |
private ReprojectListener listener = null; |
47 |
|
48 |
public String getGroup() { |
49 |
return "GeoRaster"; |
50 |
} |
51 |
|
52 |
public int getGroupOrder() { |
53 |
return 10; |
54 |
} |
55 |
|
56 |
public int getOrder() { |
57 |
return 10; |
58 |
} |
59 |
|
60 |
public String getText() { |
61 |
return Messages.getText("toc_reproject"); |
62 |
} |
63 |
|
64 |
/**
|
65 |
* Devuelve un objeto unico a dicha clase
|
66 |
* @return
|
67 |
*/
|
68 |
static public ReprojectTocMenuEntry getSingleton() { |
69 |
if (singleton == null) |
70 |
singleton = new ReprojectTocMenuEntry();
|
71 |
return singleton;
|
72 |
} |
73 |
|
74 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
75 |
return true; |
76 |
} |
77 |
|
78 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
79 |
if ((selectedItems == null) || (selectedItems.length != 1)) |
80 |
return false; |
81 |
|
82 |
if (!(selectedItems[0] instanceof IRasterLayerActions)) |
83 |
return false; |
84 |
|
85 |
return ((IRasterLayerActions) selectedItems[0]).isActionEnabled(IRasterLayerActions.REPROJECT); |
86 |
} |
87 |
|
88 |
/**
|
89 |
* M?todo que se ejecuta cuando se pulsa la entrada en el men? contextual del TOC
|
90 |
* correspondiente a "Zoom a la resoluci?n del raster". Aqu? se crear? el mapTool si
|
91 |
* no se ha hecho antes y se cargar?.
|
92 |
*/
|
93 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
94 |
if (selectedItems.length == 1) { |
95 |
FLayer lyr = selectedItems[0];
|
96 |
if (lyr instanceof FLyrRaster) { |
97 |
ReprojectionPanelDataModel dataModel = new ReprojectionPanelDataModelImpl((FLyrRaster)lyr);
|
98 |
RasterReprojectionPanel reprojectPanel = RasterReprojectionSwingLocator.getSwingManager().createRasterReprojectPanel(dataModel); |
99 |
|
100 |
ReprojectWindow window = new ReprojectWindow(reprojectPanel.getComponent(), Messages.getText("reprojection"), 360, 460); |
101 |
listener = new ReprojectListener(lyr, dataModel, window, reprojectPanel);
|
102 |
reprojectPanel.addButtonsListener(listener); |
103 |
PluginServices.getMDIManager().addCentredWindow(window); |
104 |
} |
105 |
} |
106 |
} |
107 |
|
108 |
public Icon getIcon() { |
109 |
return IconThemeHelper.getImageIcon("tools-raster-reproject"); |
110 |
} |
111 |
|
112 |
public void interrupted() { |
113 |
|
114 |
} |
115 |
} |