Revision 30 org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.impl/src/main/java/org/gvsig/vectorediting/lib/impl/DefaultEditingBehavior.java
DefaultEditingBehavior.java | ||
---|---|---|
17 | 17 |
import org.cresques.cts.IProjection; |
18 | 18 |
import org.gvsig.andami.PluginServices; |
19 | 19 |
import org.gvsig.andami.ui.mdiFrame.MainFrame; |
20 |
import org.gvsig.app.ApplicationLocator; |
|
20 | 21 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
21 | 22 |
import org.gvsig.app.project.documents.view.toolListeners.StatusBarListener; |
22 | 23 |
import org.gvsig.fmap.geom.Geometry; |
... | ... | |
51 | 52 |
|
52 | 53 |
private FLyrVect currentLayer; |
53 | 54 |
|
54 |
private EditingService activatedTool;
|
|
55 |
private EditingService activeService;
|
|
55 | 56 |
|
56 | 57 |
private EditingServiceParameter currentParam; |
57 |
|
|
58 |
|
|
58 | 59 |
private Point adjustedPoint; |
59 | 60 |
|
60 | 61 |
private StatusBarListener sbl = null; |
... | ... | |
83 | 84 |
if (layer.isActive() && layer.isEditing()) { |
84 | 85 |
view.showConsole(); |
85 | 86 |
getMapControl().setTool("VectorEditing"); |
87 |
cleanBehavior(); |
|
86 | 88 |
} |
87 | 89 |
else if (!layer.isEditing() && layer.isActive()) { |
88 | 90 |
setCurrentLayer((FLyrVect) layer); |
... | ... | |
91 | 93 |
PluginServices.getMainFrame().setSelectedTool("ZOOM_IN"); |
92 | 94 |
} |
93 | 95 |
setCurrentLayer((FLyrVect) layer); |
96 |
|
|
94 | 97 |
} |
95 | 98 |
|
96 | 99 |
} |
... | ... | |
104 | 107 |
public void visibilityChanged(LayerEvent e) {} |
105 | 108 |
}; |
106 | 109 |
|
110 |
public void cleanBehavior() { |
|
111 |
activeService = null; |
|
112 |
currentParam = null; |
|
113 |
|
|
114 |
DefaultViewPanel view = getActiveView(); |
|
115 |
view.getConsolePanel().addText("\nSeleccione un herramienta\n", JConsole.MESSAGE); |
|
116 |
ApplicationLocator.getManager().refreshMenusAndToolBars(); |
|
117 |
} |
|
118 |
|
|
107 | 119 |
public DefaultEditingBehavior(MapControl mapControl) { |
108 | 120 |
// TODO Auto-generated constructor stub |
109 | 121 |
if (mapControl != null) { |
... | ... | |
123 | 135 |
public void activateTool(String name) { |
124 | 136 |
|
125 | 137 |
EditingManager manager = EditingLocator.getManager(); |
126 |
|
|
138 |
|
|
127 | 139 |
if (currentLayer != null) { |
128 |
EditingService tool = (EditingService) manager.getEditingService(name,
|
|
140 |
EditingService service = (EditingService) manager.getEditingService(name,
|
|
129 | 141 |
currentLayer); |
130 |
if (tool != null) {
|
|
131 |
this.activatedTool = tool;
|
|
142 |
if (service != null) {
|
|
143 |
this.activatedTool = service;
|
|
132 | 144 |
tool.start(); |
133 | 145 |
getNextParameter(); |
134 | 146 |
} |
... | ... | |
174 | 186 |
} |
175 | 187 |
|
176 | 188 |
private void getNextParameter() { |
177 |
currentParam = activatedTool.getNextParameter();
|
|
189 |
currentParam = activeService.getNextParameter();
|
|
178 | 190 |
if (currentParam == null) { |
179 |
activatedTool.finishOperation();
|
|
191 |
activeService.finishOperation();
|
|
180 | 192 |
mapControl.rePaintDirtyLayers(); |
181 |
activatedTool.start();
|
|
193 |
activeService.start();
|
|
182 | 194 |
getNextParameter(); |
183 | 195 |
} |
184 | 196 |
else { |
... | ... | |
253 | 265 |
|
254 | 266 |
public void mouseClicked(MouseEvent e) throws BehaviorException { |
255 | 267 |
// TODO Auto-generated method stub |
256 |
if (activatedTool != null) {
|
|
268 |
if (activeService != null) {
|
|
257 | 269 |
if (currentParam != null) { |
258 | 270 |
switch (currentParam.getType()) { |
259 | 271 |
case EditingServiceParameter.TYPE_POINT: |
260 | 272 |
ViewPort vp = mapControl.getViewPort(); |
261 | 273 |
Point2D point; |
262 | 274 |
point = vp.toMapPoint(e.getX(), e.getY()); |
263 |
this.activatedTool.setValueParameter(currentParam, point);
|
|
275 |
this.activeService.setValueParameter(currentParam, point);
|
|
264 | 276 |
|
265 | 277 |
case EditingServiceParameter.TYPE_LIST_POINTS: |
266 | 278 |
case EditingServiceParameter.TYPE_OPTION: |
... | ... | |
297 | 309 |
@SuppressWarnings("deprecation") |
298 | 310 |
public void paintComponent(MapControlDrawer mapControlDrawer) { |
299 | 311 |
super.paintComponent(mapControlDrawer); |
300 |
if (activatedTool == null || adjustedPoint == null) {
|
|
312 |
if (activeService == null || adjustedPoint == null) {
|
|
301 | 313 |
return; |
302 | 314 |
} |
303 | 315 |
Point2D p = null; |
304 | 316 |
|
305 | 317 |
p = getMapControl().getViewPort().toMapPoint(adjustedPoint); |
306 |
Geometry helperGeo = activatedTool.drawOperation(p);
|
|
318 |
Geometry helperGeo = activeService.drawOperation(p);
|
|
307 | 319 |
if (helperGeo != null) { |
308 | 320 |
mapControl.getMapControlDrawer().draw(helperGeo, |
309 | 321 |
MapControlLocator.getMapControlManager().getAxisReferenceSymbol()); |
... | ... | |
364 | 376 |
double[] values = new double[] { Double.parseDouble(numbers[0]), |
365 | 377 |
Double.parseDouble(numbers[1]) }; |
366 | 378 |
Point2D point = new Point2D.Double(values[0], values[1]); |
367 |
this.activatedTool.setValueParameter(currentParam, point);
|
|
379 |
this.activeService.setValueParameter(currentParam, point);
|
|
368 | 380 |
|
369 | 381 |
} |
370 | 382 |
else { |
Also available in: Unified diff