gvsig-raster / org.gvsig.raster.tools / trunk / org.gvsig.raster.tools / org.gvsig.raster.tools.app.basic / src / main / java / org / gvsig / raster / tools / app / basic / tool / setviewprojection / SetViewProjectionTocMenuEntry.java @ 2125
History | View | Annotate | Download (3.38 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.tools.app.basic.tool.setviewprojection; |
23 |
|
24 |
import javax.swing.Icon; |
25 |
|
26 |
import org.cresques.Messages; |
27 |
import org.cresques.cts.IProjection; |
28 |
import org.gvsig.andami.IconThemeHelper; |
29 |
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction; |
30 |
import org.gvsig.app.project.documents.view.toc.ITocItem; |
31 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
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.tools.app.basic.RasterToolsUtil; |
36 |
|
37 |
|
38 |
/**
|
39 |
* @author Nacho Brodin (nachobrodin@gmail.com)
|
40 |
*/
|
41 |
public class SetViewProjectionTocMenuEntry extends AbstractTocContextMenuAction implements IGenericToolBarMenuItem { |
42 |
static private SetViewProjectionTocMenuEntry singleton = null; |
43 |
FLayer lyr = null;
|
44 |
|
45 |
public String getGroup() { |
46 |
return "GeoRaster"; |
47 |
} |
48 |
|
49 |
public int getGroupOrder() { |
50 |
return 10; |
51 |
} |
52 |
|
53 |
public int getOrder() { |
54 |
return 20; |
55 |
} |
56 |
|
57 |
public String getText() { |
58 |
return RasterToolsUtil.getText(this, "set_view_projection"); |
59 |
} |
60 |
|
61 |
/**
|
62 |
* Devuelve un objeto unico a dicha clase
|
63 |
* @return
|
64 |
*/
|
65 |
static public SetViewProjectionTocMenuEntry getSingleton() { |
66 |
if (singleton == null) |
67 |
singleton = new SetViewProjectionTocMenuEntry();
|
68 |
return singleton;
|
69 |
} |
70 |
|
71 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
72 |
return true; |
73 |
} |
74 |
|
75 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
76 |
if ((selectedItems == null) || (selectedItems.length != 1)) |
77 |
return false; |
78 |
|
79 |
if (!(selectedItems[0] instanceof IRasterLayerActions)) |
80 |
return false; |
81 |
|
82 |
return ((IRasterLayerActions) selectedItems[0]).isActionEnabled(IRasterLayerActions.SELECT_LAYER); |
83 |
} |
84 |
|
85 |
/**
|
86 |
* M?todo que se ejecuta cuando se pulsa la entrada en el men? contextual del TOC
|
87 |
* correspondiente a "Zoom a la resoluci?n del raster". Aqu? se crear? el mapTool si
|
88 |
* no se ha hecho antes y se cargar?.
|
89 |
*/
|
90 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
91 |
FLayer fLayer = null;
|
92 |
|
93 |
if (selectedItems.length != 1) |
94 |
return;
|
95 |
|
96 |
fLayer = selectedItems[0];
|
97 |
|
98 |
if (!(fLayer instanceof FLyrRaster)) |
99 |
return;
|
100 |
FLyrRaster inputLayer = (FLyrRaster)fLayer; |
101 |
|
102 |
IProjection viewProjection = inputLayer.getMapContext().getProjection(); |
103 |
|
104 |
if(RasterToolsUtil.messageBoxYesOrNot(Messages.getText("overwrite_projection"), null)) { |
105 |
inputLayer.setProjection(viewProjection); |
106 |
} |
107 |
} |
108 |
|
109 |
public Icon getIcon() { |
110 |
return IconThemeHelper.getImageIcon("setviewprojection-raster-icon"); |
111 |
} |
112 |
|
113 |
} |