svn-gvsig-desktop / trunk / extensions / extRasterTools-SE / src / org / gvsig / rastertools / vectorizacion / VectorizationTocMenuEntry.java @ 22396
History | View | Annotate | Download (6.92 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007 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.vectorizacion; |
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.gui.IGenericToolBarMenuItem; |
27 |
import org.gvsig.raster.util.RasterToolsUtil; |
28 |
import org.gvsig.rastertools.vectorizacion.clip.ClipData; |
29 |
import org.gvsig.rastertools.vectorizacion.clip.ClipListener; |
30 |
import org.gvsig.rastertools.vectorizacion.clip.ui.ClipPanel; |
31 |
import org.gvsig.rastertools.vectorizacion.filter.GrayConversionData; |
32 |
import org.gvsig.rastertools.vectorizacion.filter.GrayConversionListener; |
33 |
import org.gvsig.rastertools.vectorizacion.filter.ui.GrayConversionPanel; |
34 |
import org.gvsig.rastertools.vectorizacion.vector.VectorData; |
35 |
import org.gvsig.rastertools.vectorizacion.vector.VectorListener; |
36 |
import org.gvsig.rastertools.vectorizacion.vector.ui.VectorPanel; |
37 |
|
38 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
39 |
import com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction; |
40 |
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem; |
41 |
/**
|
42 |
* <code>VectorizationTocMenuEntry</code> es el punto de entrada del menu de vectorizaci?n.
|
43 |
*
|
44 |
* @version 12/06/2008
|
45 |
* @author Nacho Brodin nachobrodin@gmail.com
|
46 |
*/
|
47 |
public class VectorizationTocMenuEntry extends AbstractTocContextMenuAction implements IGenericToolBarMenuItem { |
48 |
static private VectorizationTocMenuEntry singleton = null; |
49 |
|
50 |
/**
|
51 |
* Nadie puede crear una instancia a esta clase ?nica, hay que usar el
|
52 |
* getSingleton()
|
53 |
*/
|
54 |
private VectorizationTocMenuEntry() {}
|
55 |
|
56 |
/**
|
57 |
* Devuelve un objeto unico a dicha clase
|
58 |
* @return
|
59 |
*/
|
60 |
static public VectorizationTocMenuEntry getSingleton() { |
61 |
if (singleton == null) |
62 |
singleton = new VectorizationTocMenuEntry();
|
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 50; |
80 |
} |
81 |
|
82 |
/*
|
83 |
* (non-Javadoc)
|
84 |
* @see com.iver.cit.gvsig.project.documents.contextMenu.AbstractContextMenuAction#getOrder()
|
85 |
*/
|
86 |
public int getOrder() { |
87 |
return 1; |
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, "vectorization"); |
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 |
return true; |
112 |
} |
113 |
|
114 |
/*
|
115 |
* (non-Javadoc)
|
116 |
* @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[])
|
117 |
*/
|
118 |
public boolean isVisible(ITocItem item, FLayer[] selectedItems) { |
119 |
if ((selectedItems == null) || (selectedItems.length != 1)) |
120 |
return false; |
121 |
|
122 |
if (!(selectedItems[0] instanceof FLyrRasterSE)) |
123 |
return false; |
124 |
|
125 |
return ((FLyrRasterSE) selectedItems[0]).isActionEnabled(IRasterLayerActions.FILTER); |
126 |
} |
127 |
|
128 |
/*
|
129 |
* (non-Javadoc)
|
130 |
* @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[])
|
131 |
*/
|
132 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
133 |
FLayer fLayer = null;
|
134 |
|
135 |
if (selectedItems.length != 1) |
136 |
return;
|
137 |
|
138 |
fLayer = selectedItems[0];
|
139 |
|
140 |
if (!(fLayer instanceof FLyrRasterSE)) |
141 |
return;
|
142 |
|
143 |
FLyrRasterSE lyr = (FLyrRasterSE)fLayer; |
144 |
|
145 |
//1-Creamos los modelos de datos
|
146 |
ClipData clipData = new ClipData();
|
147 |
GrayConversionData grayConvData = new GrayConversionData();
|
148 |
VectorData vectorData = new VectorData();
|
149 |
|
150 |
//2-Creamos los paneles
|
151 |
ClipPanel clipPanel = new ClipPanel();
|
152 |
GrayConversionPanel grayConvPanel = new GrayConversionPanel();
|
153 |
VectorPanel vectorPanel = new VectorPanel();
|
154 |
|
155 |
//3-Creamos los listener
|
156 |
ClipListener clipList = new ClipListener(lyr, clipPanel, clipData);
|
157 |
GrayConversionListener grayConvList = new GrayConversionListener(lyr, grayConvPanel, grayConvData);
|
158 |
VectorListener vectorList = new VectorListener(lyr, vectorPanel, vectorData);
|
159 |
|
160 |
//4-Asignamos los observadores
|
161 |
clipData.addObserver(clipPanel); |
162 |
grayConvData.addObserver(grayConvPanel); |
163 |
vectorData.addObserver(vectorPanel); |
164 |
|
165 |
//5-Panel general: creamos el modelo de datos, panel y listener
|
166 |
MainData mainData = new MainData();
|
167 |
MainPanel mainPanel = new MainPanel(lyr, grayConvList.getPreviewRender()); //Usa el render de la conversi?n a escala de gris |
168 |
mainPanel.setPanel(clipPanel); |
169 |
mainPanel.setPanel(grayConvPanel); |
170 |
mainPanel.setPanel(vectorPanel); |
171 |
mainPanel.initialize(); |
172 |
MainListener vectListener = new MainListener((FLyrRasterSE)fLayer, mainPanel, grayConvList, clipList, vectorList);
|
173 |
vectListener.setPreviewRender(grayConvList.getPreviewRender()); |
174 |
mainData.addObserver(mainPanel); |
175 |
grayConvList.setPreviewPanel(mainPanel.getPreviewBasePanel()); |
176 |
|
177 |
//6-Actualizamos los datos
|
178 |
clipData.updateObservers(); |
179 |
grayConvData.updateObservers(); |
180 |
vectorData.updateObservers(); |
181 |
mainData.updateObservers(); |
182 |
|
183 |
//7-Creamos el dialogo
|
184 |
MainDialog dialog = new MainDialog(620, 468, fLayer.getName(), grayConvList.getPreviewRender(), mainPanel); |
185 |
RasterToolsUtil.addWindow(dialog); |
186 |
} |
187 |
|
188 |
/*
|
189 |
* (non-Javadoc)
|
190 |
* @see org.gvsig.rastertools.generictoolbar.IGenericToolBarMenuItem#getIcon()
|
191 |
*/
|
192 |
public Icon getIcon() { |
193 |
return RasterToolsUtil.getIcon("vectorization-icon"); |
194 |
} |
195 |
} |