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