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 / enhanced / EnhancedTocMenuEntry.java @ 2176
History | View | Annotate | Download (4.42 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.enhanced; |
23 |
|
24 |
import javax.swing.Icon; |
25 |
|
26 |
import org.gvsig.andami.PluginServices; |
27 |
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction; |
28 |
import org.gvsig.app.project.documents.view.toc.ITocItem; |
29 |
import org.gvsig.fmap.dal.coverage.datastruct.BufferHistogram; |
30 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
31 |
import org.gvsig.raster.fmap.layers.FLyrRaster; |
32 |
import org.gvsig.raster.fmap.layers.ILayerState; |
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 |
import org.gvsig.raster.tools.app.basic.raster.process.HistogramProcess; |
37 |
import org.gvsig.raster.tools.app.basic.raster.process.IProcessActions; |
38 |
import org.gvsig.raster.tools.app.basic.raster.process.StatisticsProcess; |
39 |
import org.gvsig.raster.tools.app.basic.tool.enhanced.ui.EnhancedDialog; |
40 |
|
41 |
|
42 |
/**
|
43 |
* Punto de entrada para la funcionalidad de realce por expansi?n del contraste
|
44 |
* 19/02/2008
|
45 |
* @author Nacho Brodin nachobrodin@gmail.com
|
46 |
*/
|
47 |
public class EnhancedTocMenuEntry extends AbstractTocContextMenuAction implements IGenericToolBarMenuItem, IProcessActions { |
48 |
static private EnhancedTocMenuEntry singleton = null; |
49 |
private FLyrRaster lyr = null; |
50 |
|
51 |
/**
|
52 |
* Nadie puede crear una instancia a esta clase ?nica, hay que usar el
|
53 |
* getSingleton()
|
54 |
*/
|
55 |
private EnhancedTocMenuEntry() {}
|
56 |
|
57 |
/**
|
58 |
* Devuelve un objeto unico a dicha clase
|
59 |
* @return
|
60 |
*/
|
61 |
static public EnhancedTocMenuEntry getSingleton() { |
62 |
if (singleton == null) |
63 |
singleton = new EnhancedTocMenuEntry();
|
64 |
return singleton;
|
65 |
} |
66 |
|
67 |
public String getGroup() { |
68 |
return "Enhanced"; |
69 |
} |
70 |
|
71 |
public int getGroupOrder() { |
72 |
return 55; |
73 |
} |
74 |
|
75 |
public int getOrder() { |
76 |
return 0; |
77 |
} |
78 |
|
79 |
public String getText() { |
80 |
return RasterToolsUtil.getText(this, "enhanced_rad"); |
81 |
} |
82 |
|
83 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
84 |
if ((selectedItems == null) || (selectedItems.length != 1)) |
85 |
return false; |
86 |
|
87 |
if (!(selectedItems[0] instanceof ILayerState)) |
88 |
return false; |
89 |
|
90 |
if (!((ILayerState) selectedItems[0]).isOpen()) |
91 |
return false; |
92 |
|
93 |
return true; |
94 |
} |
95 |
|
96 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
97 |
if ((selectedItems == null) || (selectedItems.length != 1)) |
98 |
return false; |
99 |
|
100 |
if (!(selectedItems[0] instanceof IRasterLayerActions)) |
101 |
return false; |
102 |
|
103 |
return ((IRasterLayerActions) selectedItems[0]).isActionEnabled(IRasterLayerActions.ENHANCED); |
104 |
} |
105 |
|
106 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
107 |
if ((selectedItems == null) || (selectedItems.length != 1) || (!(selectedItems[0] instanceof FLyrRaster))) |
108 |
return;
|
109 |
|
110 |
this.lyr = (FLyrRaster)selectedItems[0]; |
111 |
|
112 |
if(!lyr.getDataStore().getStatistics().isCalculated())
|
113 |
StatisticsProcess.launcher(lyr, this);
|
114 |
else
|
115 |
end(null);
|
116 |
} |
117 |
|
118 |
public Icon getIcon() { |
119 |
return RasterToolsUtil.getIcon("layer-enhanced"); |
120 |
} |
121 |
|
122 |
/**
|
123 |
* Lanzamos la ventana al final del proceso de calculo de estad?sticas.
|
124 |
*/
|
125 |
public synchronized void end(Object param) { |
126 |
if(param == null || param instanceof FLyrRaster) { |
127 |
HistogramProcess histogramProcess = new HistogramProcess();
|
128 |
histogramProcess.setActions(this);
|
129 |
histogramProcess.addParam("histogramable", this.lyr.getDataStore().getHistogramComputer()); |
130 |
histogramProcess.start(); |
131 |
} |
132 |
if(param instanceof BufferHistogram) { |
133 |
EnhancedDialog enhancedDialog = new EnhancedDialog(lyr, 760, 421); |
134 |
PluginServices.getMDIManager().addCentredWindow(enhancedDialog); |
135 |
} |
136 |
} |
137 |
|
138 |
public void interrupted() { |
139 |
} |
140 |
|
141 |
} |