root / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / enhanced / EnhancedTocMenuEntry.java @ 20948
History | View | Annotate | Download (5.78 KB)
1 | 19135 | nbrodin | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2006 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.enhanced; |
||
20 | |||
21 | 19205 | nbrodin | import java.util.ArrayList; |
22 | |||
23 | 19135 | nbrodin | import javax.swing.Icon; |
24 | |||
25 | import org.gvsig.fmap.raster.layers.FLyrRasterSE; |
||
26 | import org.gvsig.fmap.raster.layers.ILayerState; |
||
27 | import org.gvsig.fmap.raster.layers.IRasterLayerActions; |
||
28 | 19288 | nbrodin | import org.gvsig.raster.IProcessActions; |
29 | import org.gvsig.raster.RasterProcess; |
||
30 | 19135 | nbrodin | import org.gvsig.raster.gui.IGenericToolBarMenuItem; |
31 | 20647 | nbrodin | import org.gvsig.raster.util.RasterToolsUtil; |
32 | 19135 | nbrodin | import org.gvsig.rastertools.enhanced.ui.EnhancedDialog; |
33 | 19288 | nbrodin | import org.gvsig.rastertools.statistics.StatisticsProcess; |
34 | 19135 | nbrodin | |
35 | import com.iver.andami.PluginServices; |
||
36 | 19205 | nbrodin | import com.iver.andami.ui.mdiManager.IWindow; |
37 | 19135 | nbrodin | import com.iver.cit.gvsig.fmap.layers.FLayer; |
38 | 19205 | nbrodin | import com.iver.cit.gvsig.fmap.layers.FLayers; |
39 | import com.iver.cit.gvsig.project.documents.view.gui.View; |
||
40 | 19135 | nbrodin | import com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction; |
41 | import com.iver.cit.gvsig.project.documents.view.toc.ITocItem; |
||
42 | |||
43 | /**
|
||
44 | * Punto de entrada para la funcionalidad de realce por expansi?n del contraste
|
||
45 | * 19/02/2008
|
||
46 | * @author Nacho Brodin nachobrodin@gmail.com
|
||
47 | */
|
||
48 | 19288 | nbrodin | public class EnhancedTocMenuEntry extends AbstractTocContextMenuAction implements IGenericToolBarMenuItem, IProcessActions { |
49 | static private EnhancedTocMenuEntry singleton = null; |
||
50 | private FLyrRasterSE lyr = null; |
||
51 | private ArrayList lyrsRaster = null; |
||
52 | 19135 | nbrodin | |
53 | /**
|
||
54 | * Nadie puede crear una instancia a esta clase ?nica, hay que usar el
|
||
55 | * getSingleton()
|
||
56 | */
|
||
57 | private EnhancedTocMenuEntry() {}
|
||
58 | |||
59 | /**
|
||
60 | * Devuelve un objeto unico a dicha clase
|
||
61 | * @return
|
||
62 | */
|
||
63 | static public EnhancedTocMenuEntry getSingleton() { |
||
64 | if (singleton == null) |
||
65 | singleton = new EnhancedTocMenuEntry();
|
||
66 | return singleton;
|
||
67 | } |
||
68 | |||
69 | /*
|
||
70 | * (non-Javadoc)
|
||
71 | * @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getGroup()
|
||
72 | */
|
||
73 | public String getGroup() { |
||
74 | return "RasterProcess"; |
||
75 | } |
||
76 | |||
77 | /*
|
||
78 | * (non-Javadoc)
|
||
79 | * @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getGroupOrder()
|
||
80 | */
|
||
81 | public int getGroupOrder() { |
||
82 | return 55; |
||
83 | } |
||
84 | |||
85 | /*
|
||
86 | * (non-Javadoc)
|
||
87 | * @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getOrder()
|
||
88 | */
|
||
89 | public int getOrder() { |
||
90 | return 0; |
||
91 | } |
||
92 | |||
93 | /*
|
||
94 | * (non-Javadoc)
|
||
95 | * @see com.iver.cit.gvsig.project.documents.IContextMenuAction#getText()
|
||
96 | */
|
||
97 | public String getText() { |
||
98 | 20647 | nbrodin | return RasterToolsUtil.getText(this, "enhanced_rad"); |
99 | 19135 | nbrodin | } |
100 | |||
101 | /*
|
||
102 | * (non-Javadoc)
|
||
103 | * @see com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction#isEnabled(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
|
||
104 | */
|
||
105 | public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
||
106 | if ((selectedItems == null) || (selectedItems.length != 1)) |
||
107 | return false; |
||
108 | |||
109 | if (!(selectedItems[0] instanceof ILayerState)) |
||
110 | return false; |
||
111 | |||
112 | if (!((ILayerState) selectedItems[0]).isOpen()) |
||
113 | return false; |
||
114 | |||
115 | return true; |
||
116 | } |
||
117 | |||
118 | /*
|
||
119 | * (non-Javadoc)
|
||
120 | * @see com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction#isVisible(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
|
||
121 | */
|
||
122 | public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
||
123 | if ((selectedItems == null) || (selectedItems.length != 1)) |
||
124 | return false; |
||
125 | |||
126 | if (!(selectedItems[0] instanceof FLyrRasterSE)) |
||
127 | return false; |
||
128 | |||
129 | return ((FLyrRasterSE) selectedItems[0]).isActionEnabled(IRasterLayerActions.ENHANCED); |
||
130 | } |
||
131 | |||
132 | /*
|
||
133 | * (non-Javadoc)
|
||
134 | * @see com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction#execute(com.iver.cit.gvsig.project.documents.view.toc.ITocItem, com.iver.cit.gvsig.fmap.layers.FLayer[])
|
||
135 | */
|
||
136 | public void execute(ITocItem item, FLayer[] selectedItems) { |
||
137 | if ((selectedItems == null) || (selectedItems.length != 1) || (!(selectedItems[0] instanceof FLyrRasterSE))) |
||
138 | return;
|
||
139 | 19205 | nbrodin | |
140 | IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow(); |
||
141 | 19288 | nbrodin | lyrsRaster = new ArrayList(); |
142 | 19205 | nbrodin | |
143 | if(activeWindow instanceof View) { |
||
144 | FLayers lyrs = ((View)activeWindow).getMapControl().getMapContext().getLayers();
|
||
145 | for (int i = 0; i < lyrs.getLayersCount(); i++) { |
||
146 | if(lyrs.getLayer(i) instanceof FLyrRasterSE) |
||
147 | lyrsRaster.add(lyrs.getLayer(i)); |
||
148 | } |
||
149 | } |
||
150 | 19288 | nbrodin | |
151 | this.lyr = (FLyrRasterSE)selectedItems[0]; |
||
152 | 19296 | nbrodin | if(!lyr.getDataSource().getStatistics().isCalculated()) {
|
153 | RasterProcess process = new StatisticsProcess();
|
||
154 | process.addParam("layer", lyr);
|
||
155 | process.addParam("force", new Boolean(false)); |
||
156 | process.setActions(this);
|
||
157 | process.start(); |
||
158 | } else
|
||
159 | end(null);
|
||
160 | 19135 | nbrodin | } |
161 | |||
162 | /*
|
||
163 | * (non-Javadoc)
|
||
164 | * @see org.gvsig.rastertools.generictoolbar.IGenericToolBarMenuItem#getIcon()
|
||
165 | */
|
||
166 | public Icon getIcon() { |
||
167 | 20647 | nbrodin | return RasterToolsUtil.getIcon("brush-icon"); |
168 | 19135 | nbrodin | } |
169 | 19288 | nbrodin | |
170 | /**
|
||
171 | * Lanzamos la ventana al final del proceso de calculo de estad?sticas.
|
||
172 | */
|
||
173 | public void end(Object param) { |
||
174 | 20948 | nbrodin | EnhancedDialog enhancedDialog = new EnhancedDialog(lyr, lyrsRaster, 760, 410); |
175 | 20647 | nbrodin | RasterToolsUtil.addWindow(enhancedDialog); |
176 | 19288 | nbrodin | } |
177 | |||
178 | public void interrupted() { |
||
179 | } |
||
180 | 19135 | nbrodin | } |