37 |
37 |
import com.iver.cit.gvsig.fmap.MapControl;
|
38 |
38 |
import com.iver.cit.gvsig.fmap.layers.FLayer;
|
39 |
39 |
import com.iver.cit.gvsig.fmap.layers.FLayers;
|
|
40 |
import com.iver.cit.gvsig.fmap.tools.CompoundBehavior;
|
40 |
41 |
import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior;
|
41 |
42 |
import com.iver.cit.gvsig.fmap.tools.Behavior.MouseMovementBehavior;
|
42 |
43 |
import com.iver.cit.gvsig.project.documents.view.gui.BaseView;
|
43 |
|
import com.iver.cit.gvsig.project.documents.view.gui.IView;
|
44 |
44 |
import com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction;
|
45 |
45 |
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem;
|
46 |
46 |
import com.iver.cit.gvsig.project.documents.view.toolListeners.StatusBarListener;
|
... | ... | |
130 |
130 |
* (non-Javadoc)
|
131 |
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 |
132 |
*/
|
133 |
|
public void execute(ITocItem item, FLayer[] selectedItems) {
|
134 |
|
boolean isOpen = false;
|
|
133 |
public void execute(ITocItem item, FLayer[] selectedItems) {
|
|
134 |
if (selectedItems == null || selectedItems.length != 1 || !(selectedItems[0] instanceof FLyrRasterSE)) {
|
|
135 |
RasterToolsUtil.messageBoxError(PluginServices.getText(this,"layers_not_selected"), null);
|
|
136 |
return;
|
|
137 |
}
|
135 |
138 |
|
136 |
|
BaseView theView = (BaseView) PluginServices.getMDIManager().getActiveWindow();
|
137 |
|
MapControl mapCtrl = theView.getMapControl();
|
138 |
|
|
139 |
|
// Listener de eventos de movimiento que pone las coordenadas del rat?n en
|
140 |
|
// la barra de estado
|
141 |
|
StatusBarListener sbl = new StatusBarListener(mapCtrl);
|
|
139 |
BaseView theView = null;
|
|
140 |
GeoLocationDialog dialog = null;
|
142 |
141 |
|
143 |
|
//Comprobamos si no hay capas activas. En este caso no lanzamos la ventana ni activamos la tool
|
144 |
142 |
IWindow[] win = PluginServices.getMDIManager().getAllWindows();
|
145 |
143 |
for (int i = 0; i < win.length; i++) {
|
146 |
|
if (win[i] instanceof IView) {
|
147 |
|
FLayers lyrs = ((IView) win[i]).getMapControl().getMapContext().getLayers();
|
148 |
|
FLayer[] actives = lyrs.getActives();
|
149 |
|
if (actives == null || actives.length == 0)
|
150 |
|
return;
|
|
144 |
if (win[i] instanceof BaseView) {
|
|
145 |
FLayers lyrs = ((BaseView) win[i]).getMapControl().getMapContext().getLayers();
|
|
146 |
for (int j = 0; j < lyrs.getLayersCount(); j++)
|
|
147 |
if(lyrs.getLayer(j).equals(selectedItems[0]))
|
|
148 |
theView = (BaseView)win[i];
|
151 |
149 |
}
|
152 |
150 |
if (win[i] instanceof GeoLocationDialog)
|
153 |
|
isOpen = true;
|
|
151 |
RasterToolsUtil.closeWindow(win[i]);
|
154 |
152 |
}
|
155 |
153 |
|
156 |
|
if (selectedItems == null || selectedItems.length != 1 || !(selectedItems[0] instanceof FLyrRasterSE))
|
|
154 |
if(theView == null) {
|
|
155 |
RasterToolsUtil.messageBoxError(PluginServices.getText(this,"view_not_found"), null);
|
157 |
156 |
return;
|
|
157 |
}
|
158 |
158 |
|
|
159 |
MapControl mapCtrl = theView.getMapControl();
|
|
160 |
|
|
161 |
// Listener de eventos de movimiento que pone las coordenadas del rat?n en
|
|
162 |
// la barra de estado
|
|
163 |
StatusBarListener sbl = new StatusBarListener(mapCtrl);
|
|
164 |
|
159 |
165 |
FLyrRasterSE lyr = (FLyrRasterSE)selectedItems[0];
|
160 |
|
GeoLocationDialog gld = new GeoLocationDialog(lyr, mapCtrl.getViewPort(), theView);
|
161 |
|
if(!isOpen) {
|
162 |
|
Point posit = RasterToolsUtil.iwindowPosition((int)gld.getSizeWindow().getWidth(), (int)gld.getSizeWindow().getHeight());
|
163 |
|
gld.setPosition((int)posit.getX(), (int)posit.getY());
|
164 |
|
RasterToolsUtil.addWindow(gld);
|
165 |
|
}
|
|
166 |
dialog = new GeoLocationDialog(lyr, mapCtrl.getViewPort(), theView);
|
|
167 |
Point posit = RasterToolsUtil.iwindowPosition((int)dialog.getSizeWindow().getWidth(), (int)dialog.getSizeWindow().getHeight());
|
|
168 |
dialog.setPosition((int)posit.getX(), (int)posit.getY());
|
|
169 |
RasterToolsUtil.addWindow(dialog);
|
166 |
170 |
|
167 |
|
gld.init(mapCtrl);
|
168 |
|
loadGeoPanListener(mapCtrl, sbl, gld, lyr);
|
|
171 |
dialog.init(mapCtrl);
|
|
172 |
loadGeoPanListener(mapCtrl, sbl, dialog, lyr);
|
169 |
173 |
mapCtrl.setTool("geoPan");
|
170 |
174 |
}
|
171 |
175 |
|
... | ... | |
177 |
181 |
GeorefPanListener pl = new GeorefPanListener(mapCtrl);
|
178 |
182 |
mb = new GeoRasterBehavior(pl, gld, lyr);
|
179 |
183 |
mapCtrl.addMapTool("geoPan", new Behavior[]{mb, new MouseMovementBehavior(sbl)});
|
|
184 |
} else {
|
|
185 |
Behavior b = mapCtrl.getMapTool("geoPan");
|
|
186 |
if( b instanceof CompoundBehavior &&
|
|
187 |
((CompoundBehavior)b).getBehavior(0) instanceof GeoRasterBehavior) {
|
|
188 |
GeoRasterBehavior beh = (GeoRasterBehavior)((CompoundBehavior)b).getBehavior(0);
|
|
189 |
beh.setLayer(lyr);
|
|
190 |
beh.setITransformIO(gld);
|
|
191 |
}
|
180 |
192 |
}
|
181 |
|
|
182 |
|
if(mb != null) {
|
183 |
|
mb.setLayer(lyr);
|
184 |
|
mb.setITransformIO(gld);
|
185 |
|
}
|
186 |
193 |
}
|
187 |
194 |
|
188 |
195 |
/*
|