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