Revision 3712

View differences:

trunk/extensions/extCAD/src/com/iver/cit/gvsig/GeometryExtension.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig;
42

  
43
import java.io.IOException;
44

  
45
import com.iver.andami.PluginServices;
46
import com.iver.andami.messages.NotificationManager;
47
import com.iver.andami.plugins.Extension;
48

  
49
import com.iver.cit.gvsig.fmap.FMap;
50
import com.iver.cit.gvsig.fmap.MapControl;
51
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
52
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter;
53
import com.iver.cit.gvsig.fmap.layers.FLayer;
54
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
55
import com.iver.cit.gvsig.gui.View;
56

  
57

  
58

  
59
/**
60
 * Extensi?n dedicada a controlar las diferentes operaciones sobre el editado
61
 * de una capa.
62
 *
63
 * @author Vicente Caballero Navarro
64
 */
65
public class GeometryExtension implements Extension {
66
	/**
67
	 * @see com.iver.andami.plugins.Extension#inicializar()
68
	 */
69
	public void inicializar() {
70
	}
71

  
72
	/**
73
	 * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
74
	 */
75
	public void execute(String s) {
76
		View vista = (View) PluginServices.getMDIManager().getActiveView();
77
		//PluginServices.getMainFrame().showConsole();
78
		MapControl cadmap=(MapControl)vista.getMapControl();
79
		if (s.compareTo("SPLINE") == 0) {
80
			//Spline.png
81
			///vista.getMapControl().setCadTool("spline");
82
		} else if (s.compareTo("COPY") == 0) {
83
			//Copy.png
84
			///vista.getMapControl().setCadTool("copy");
85
		} else if (s.compareTo("EQUIDISTANCE") == 0) {
86
			//Equidistance.png
87
		} else if (s.compareTo("MATRIZ") == 0) {
88
			//Matriz.png
89
		} else if (s.compareTo("SYMMETRY") == 0) {
90
			//Symmetry.png
91
			///vista.getMapControl().setCadTool("symmetry");
92
		} else if (s.compareTo("ROTATION") == 0) {
93
			//Rotation.png
94
			///vista.getMapControl().setCadTool("rotate");
95
		} else if (s.compareTo("STRETCHING") == 0) {
96
			//Stretching.png
97
			///vista.getMapControl().setCadTool("stretching");
98
		} else if (s.compareTo("SCALE") == 0) {
99
			//Scale.png
100
			///vista.getMapControl().setCadTool("scale");
101
		} else if (s.compareTo("EXTEND") == 0) {
102
			//Extend.png
103
		} else if (s.compareTo("TRIM") == 0) {
104
			//Trim.png
105
		} else if (s.compareTo("UNIT") == 0) {
106
			//Unit.png
107
		} else if (s.compareTo("EXPLOIT") == 0) {
108
			//Exploit.png
109
			///vista.getMapControl().setCadTool("exploit");
110
		} else if (s.compareTo("CHAFLAN") == 0) {
111
			//Chaflan.png
112
		} else if (s.compareTo("JOIN") == 0) {
113
			//Join.png
114
		} else if (s.compareTo("SELECT") == 0) {
115
			///vista.getMapControl().setCadTool("selection");
116
		} else if (s.compareTo("POINT") == 0) {
117
			///vista.getMapControl().setCadTool("point");
118
		} else if (s.compareTo("LINE") == 0) {
119
			///vista.getMapControl().setCadTool("line");
120
		} else if (s.compareTo("POLYLINE") == 0) {
121
			///vista.getMapControl().setCadTool("polyline");
122
		} else if (s.compareTo("CIRCLE") == 0) {
123
			///vista.getMapControl().setCadTool("circle");
124
		} else if (s.compareTo("ARC") == 0) {
125
			///vista.getMapControl().setCadTool("arc");
126
		} else if (s.compareTo("ELLIPSE") == 0) {
127
			///vista.getMapControl().setCadTool("ellipse");
128
		} else if (s.compareTo("RECTANGLE") == 0) {
129
			///vista.getMapControl().setCadTool("rectangle");
130
		} else if (s.compareTo("POLYGON") == 0) {
131
			///vista.getMapControl().setCadTool("polygon");
132
		}
133
		//ViewControls.CANCELED=false;
134
	}
135

  
136
	/**
137
	 * @see com.iver.andami.plugins.Extension#isEnabled()
138
	 */
139
	public boolean isEnabled() {
140
		com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
141
															 .getActiveView();
142

  
143
		if (f == null) {
144
			return false;
145
		}
146

  
147
		if (f.getClass() == View.class) {
148
			FLayer[] l = ((View) f).getModel().getMapContext().getLayers()
149
						  .getActives();
150

  
151
			for (int i = 0; i < l.length; i++) {
152
				if (l[i] instanceof FLyrVect && ((FLyrVect)l[i]).isEditing()) {
153
					return true;
154
				}
155
			}
156
		}
157

  
158
		return false;
159
	}
160

  
161
	/**
162
	 * @see com.iver.andami.plugins.Extension#isVisible()
163
	 */
164
	public boolean isVisible() {
165
		com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
166
															 .getActiveView();
167

  
168
		if (f == null) {
169
			return false;
170
		}
171

  
172
		if (f.getClass() == View.class) {
173
			return true;
174
		} else {
175
			return false;
176
		}
177
	}
178
}
trunk/extensions/extCAD/src/com/iver/cit/gvsig/EditingExtension.java
36 36
            FLayers layers = mapa.getLayers();
37 37
           if (s.equals("CANCELEDITING")){
38 38
            	for (int i = 0; i < layers.getLayersCount(); i++) {
39
                    if (layers.getLayer(i) instanceof FLyrVect &&
39
                    vista.hideConsole();
40
            		if (layers.getLayer(i) instanceof FLyrVect &&
40 41
                            layers.getLayer(i).isEditing()) {
41 42
                        FLyrVect lv = (FLyrVect) layers.getLayer(i);
42 43
                        //stopEditing(lv);
trunk/extensions/extCAD/src/com/iver/cit/gvsig/StartEditing.java
2 2

  
3 3
import com.iver.andami.PluginServices;
4 4
import com.iver.andami.plugins.Extension;
5

  
6 5
import com.iver.cit.gvsig.fmap.FMap;
7 6
import com.iver.cit.gvsig.fmap.edition.EditionException;
8 7
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter;
......
12 11
import com.iver.cit.gvsig.project.ProjectView;
13 12

  
14 13

  
14

  
15

  
16

  
15 17
/**
16 18
 * DOCUMENT ME!
17 19
 *
......
31 33
        com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
32 34
                                                             .getActiveView();
33 35

  
34
        if (f.getClass() == View.class) {
36
        if (f instanceof View) {
35 37
            View vista = (View) f;
38
            vista.showConsole();
36 39
            ProjectView model = vista.getModel();
37 40
            FMap mapa = model.getMapContext();
38 41
            FLayers layers = mapa.getLayers();
......
48 51
                    lv.setVisible(true);
49 52

  
50 53
                    VectorialEditableAdapter vea = new VectorialEditableAdapter(lv.getSource());
51
                    try {
52
						vea.startEdition();
53
					} catch (EditionException e) {
54
						// TODO Auto-generated catch block
55
						e.printStackTrace();
54
                    try{
55
                    vea.startEdition();
56
                    }catch (EditionException e) {
57
						// TODO: handle exception
56 58
					}
57 59
                    lv.setSource(vea);
58 60
                    lv.setEditing(true);
trunk/extensions/extCAD/src/com/iver/cit/gvsig/CADExtension.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 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
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig;
42

  
43
import java.awt.event.ActionEvent;
44
import java.awt.event.KeyEvent;
45
import java.util.HashMap;
46

  
47
import javax.swing.AbstractAction;
48
import javax.swing.FocusManager;
49
import javax.swing.KeyStroke;
50

  
51
import com.iver.andami.PluginServices;
52
import com.iver.andami.plugins.Extension;
53
import com.iver.cit.gvsig.fmap.MapControl;
54
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter;
55
import com.iver.cit.gvsig.fmap.layers.FLayer;
56
import com.iver.cit.gvsig.fmap.layers.FLayers;
57
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
58
import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior;
59
import com.iver.cit.gvsig.gui.View;
60
import com.iver.cit.gvsig.gui.cad.CADTool;
61
import com.iver.cit.gvsig.gui.cad.CADToolAdapter;
62
import com.iver.cit.gvsig.gui.cad.tools.LineCADTool;
63
import com.iver.utiles.console.ResponseListener;
64
import java.awt.BorderLayout;
65
import java.awt.Cursor;
66
import java.awt.Image;
67
import java.awt.Point;
68
import java.awt.Toolkit;
69
import java.awt.event.ActionEvent;
70
import java.awt.event.ActionListener;
71
import java.awt.event.FocusEvent;
72
import java.awt.event.FocusListener;
73
import java.awt.event.KeyEvent;
74
import java.awt.event.MouseEvent;
75
import java.awt.event.MouseMotionListener;
76
import java.awt.image.MemoryImageSource;
77
import java.beans.PropertyChangeListener;
78
import java.util.HashMap;
79
/**
80
 * Extensi?n dedicada a controlar las diferentes operaciones sobre el editado
81
 * de una capa.
82
 *
83
 * @author Vicente Caballero Navarro
84
 */
85
public class CADExtension implements Extension {
86
   private CADToolAdapter adapter=new CADToolAdapter();
87
   private HashMap namesCadTools = new HashMap();
88
   private boolean isLoad =false;
89
   private MapControl mapControl;
90
   private View view;
91
   public CADToolAdapter getCADToolAdapter(){
92
	   return adapter;
93
   }
94
   /**
95
     * @see com.iver.andami.plugins.Extension#inicializar()
96
     */
97
    public void inicializar() {
98
        LineCADTool line = new LineCADTool();
99
        addCADTool("line", line);
100
    }
101

  
102
    /**
103
     * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
104
     */
105
    public void execute(String s) {
106
        view = (View) PluginServices.getMDIManager().getActiveView();
107

  
108
        //PluginServices.getMainFrame().showConsole();
109
        mapControl = (MapControl) view.getMapControl();
110
        if (!isLoad){
111
        	mapControl.addMapTool("cadtooladapter", new Behavior[]{adapter});
112
        	 view.addConsoleListener("cad", new ResponseListener() {
113
     			public void acceptResponse(String response) {
114
     				adapter.textEntered(response);
115
     				FocusManager fm=FocusManager.getCurrentManager();
116
     				fm.focusPreviousComponent(mapControl);
117
     				/*if (popup.isShowing()){
118
     				    popup.setVisible(false);
119
     				}*/
120

  
121
     			}
122
     		});
123
        }
124
        FLayers layers=mapControl.getMapContext().getLayers();
125
		for (int i=0;i<layers.getLayersCount();i++){
126
			if (layers.getLayer(i).isEditing() && layers.getLayer(i) instanceof FLyrVect){
127
				adapter.setVectorialAdapter((VectorialEditableAdapter)((FLyrVect)layers.getLayer(i)).getSource(),null);
128
				adapter.setMapControl(mapControl);
129
			}
130
		}
131

  
132
        view.getMapControl().setTool("cadtooladapter");
133
        //((CADToolAdapter)vista.getMapControl().getCurrentMapTool());
134
        if (s.compareTo("SPLINE") == 0) {
135
            //Spline.png
136
            ///vista.getMapControl().setCadTool("spline");
137
        } else if (s.compareTo("COPY") == 0) {
138
            //Copy.png
139
            ///vista.getMapControl().setCadTool("copy");
140
        } else if (s.compareTo("EQUIDISTANCE") == 0) {
141
            //Equidistance.png
142
        } else if (s.compareTo("MATRIZ") == 0) {
143
            //Matriz.png
144
        } else if (s.compareTo("SYMMETRY") == 0) {
145
            //Symmetry.png
146
            ///vista.getMapControl().setCadTool("symmetry");
147
        } else if (s.compareTo("ROTATION") == 0) {
148
            //Rotation.png
149
            ///vista.getMapControl().setCadTool("rotate");
150
        } else if (s.compareTo("STRETCHING") == 0) {
151
            //Stretching.png
152
            ///vista.getMapControl().setCadTool("stretching");
153
        } else if (s.compareTo("SCALE") == 0) {
154
            //Scale.png
155
            ///vista.getMapControl().setCadTool("scale");
156
        } else if (s.compareTo("EXTEND") == 0) {
157
            //Extend.png
158
        } else if (s.compareTo("TRIM") == 0) {
159
            //Trim.png
160
        } else if (s.compareTo("UNIT") == 0) {
161
            //Unit.png
162
        } else if (s.compareTo("EXPLOIT") == 0) {
163
            //Exploit.png
164
            ///vista.getMapControl().setCadTool("exploit");
165
        } else if (s.compareTo("CHAFLAN") == 0) {
166
            //Chaflan.png
167
        } else if (s.compareTo("JOIN") == 0) {
168
            //Join.png
169
        } else if (s.compareTo("SELECT") == 0) {
170
            ///vista.getMapControl().setCadTool("selection");
171
        } else if (s.compareTo("POINT") == 0) {
172
            ///vista.getMapControl().setCadTool("point");
173
        } else if (s.compareTo("LINE") == 0) {
174
        	setCADTool("line");
175
        	///vista.getMapControl().setCadTool("line");
176
        } else if (s.compareTo("POLYLINE") == 0) {
177
            ///vista.getMapControl().setCadTool("polyline");
178
        } else if (s.compareTo("CIRCLE") == 0) {
179
            ///vista.getMapControl().setCadTool("circle");
180
        } else if (s.compareTo("ARC") == 0) {
181
            ///vista.getMapControl().setCadTool("arc");
182
        } else if (s.compareTo("ELLIPSE") == 0) {
183
            ///vista.getMapControl().setCadTool("ellipse");
184
        } else if (s.compareTo("RECTANGLE") == 0) {
185
            ///vista.getMapControl().setCadTool("rectangle");
186
        } else if (s.compareTo("POLYGON") == 0) {
187
            ///vista.getMapControl().setCadTool("polygon");
188
        }
189

  
190
        //ViewControls.CANCELED=false;
191
    }
192
    public void addCADTool(String name, CADTool c){
193
		namesCadTools.put(name, c);
194
	}
195
    public void setCADTool(String text){
196
		CADTool ct = (CADTool) namesCadTools.get(text);
197
		if (ct == null) throw new RuntimeException("No such cad tool");
198
		ct.init();
199
		adapter.setCadTool(ct);
200
	}
201
    /**
202
     * @see com.iver.andami.plugins.Extension#isEnabled()
203
     */
204
    public boolean isEnabled() {
205
        com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
206
                                                             .getActiveView();
207

  
208
        if (f == null) {
209
            return false;
210
        }
211

  
212
        if (f.getClass() == View.class) {
213
            FLayer[] l = ((View) f).getModel().getMapContext().getLayers()
214
                          .getActives();
215

  
216
            for (int i = 0; i < l.length; i++) {
217
                if (l[i] instanceof FLyrVect && ((FLyrVect) l[i]).isEditing()) {
218
                    return true;
219
                }
220
            }
221
        }
222

  
223
        return false;
224
    }
225

  
226
    /**
227
     * @see com.iver.andami.plugins.Extension#isVisible()
228
     */
229
    public boolean isVisible() {
230
        com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
231
                                                             .getActiveView();
232

  
233
        if (f == null) {
234
            return false;
235
        }
236

  
237
        if (f.getClass() == View.class) {
238
            return true;
239
        } else {
240
            return false;
241
        }
242
    }
243
	public MapControl getMapControl() {
244
		return this.mapControl;
245
	}
246
	class KeyAction extends AbstractAction{
247

  
248
		private String key;
249

  
250
		public KeyAction(String key){
251
			this.key = key;
252
		}
253

  
254
		/* (non-Javadoc)
255
		 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
256
		 */
257
		public void actionPerformed(ActionEvent e) {
258
			view.focusConsole(key);
259
		}
260

  
261
	}
262

  
263
	class MyAction extends AbstractAction{
264
		private String actionCommand;
265

  
266
		public MyAction(String command){
267
			actionCommand = command;
268
		}
269

  
270
		/**
271
		 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
272
		 */
273
		public void actionPerformed(ActionEvent e) {
274
			adapter.keyPressed(actionCommand);
275
		}
276

  
277
	}
278

  
279
	private void registerKeyStrokes(){
280
		for (char key = '0'; key <= '9'; key++){
281
			Character keyChar = new Character(key);
282
			mapControl.getInputMap(MapControl.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(key), keyChar);
283
			mapControl.getActionMap().put(keyChar, new KeyAction(keyChar+""));
284
		}
285
		for (char key = 'a'; key <= 'z'; key++){
286
			Character keyChar = new Character(key);
287
			mapControl.getInputMap(MapControl.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(key), keyChar);
288
			mapControl.getActionMap().put(keyChar, new KeyAction(keyChar+""));
289
		}
290
		for (char key = 'A'; key <= 'Z'; key++){
291
			Character keyChar = new Character(key);
292
			mapControl.getInputMap(MapControl.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(key), keyChar);
293
			mapControl.getActionMap().put(keyChar, new KeyAction(keyChar+""));
294
		}
295
		//this.getInputMap(WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "enter");
296
        //this.getActionMap().put("enter", new MyAction("enter"));
297
		Character keyChar = new Character(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0).getKeyChar());
298
		mapControl.getInputMap(MapControl.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0),keyChar);
299
		mapControl.getActionMap().put(keyChar, new KeyAction(""));
300
	}
301
}
0 302

  
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/LineCADTool.java
1
package com.iver.cit.gvsig.gui.cad.smc.gen;
1
package com.iver.cit.gvsig.gui.cad.tools;
2 2

  
3
import com.iver.cit.gvsig.fmap.core.DefaultFeature;
3 4
import com.iver.cit.gvsig.fmap.core.GeneralPathX;
4 5
import com.iver.cit.gvsig.fmap.core.ShapeFactory;
5 6
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
6
import com.iver.cit.gvsig.fmap.edition.EditableFeatureSource;
7
import com.iver.cit.gvsig.fmap.edition.cad.TrigonometricalFunctions;
7
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter;
8 8
import com.iver.cit.gvsig.fmap.layers.FBitSet;
9
import com.iver.cit.gvsig.gui.cad.smc.AbstractCADTool;
10
import com.iver.cit.gvsig.gui.cad.smc.gen.CADToolContext.CADToolState;
9
import com.iver.cit.gvsig.gui.cad.tools.smc.LineCADToolContext;//.LineCADToolState;
10
import com.iver.cit.gvsig.gui.cad.tools.smc.LineCADToolContext.LineCADToolState;
11 11

  
12 12
import java.awt.Graphics;
13 13
import java.awt.Graphics2D;
......
57 57
 *   +34 963163400
58 58
 *   dac@iver.es
59 59
 */
60
public class LineCADTool extends AbstractCADTool {
61
    private CADToolContext _fsm;
60
public class LineCADTool extends DefaultCADTool {
61
    private LineCADToolContext _fsm;
62
    private VectorialEditableAdapter vea;
62 63
    private String question;
63
    private EditableFeatureSource efs;
64 64
    private Point2D firstPoint;
65 65
    private Point2D lastPoint;
66 66
    private double angle;
67 67
	private double length;
68 68
public LineCADTool(){
69
	_fsm=new CADToolContext(this);
69
	_fsm=new LineCADToolContext(this);
70 70
}
71 71
    /**
72 72
     * M?todo de incio, para poner el c?digo de todo lo que se requiera de una
73 73
     * carga previa a la utilizaci?n de la herramienta.
74 74
     */
75 75
    public void init() {
76
    	
76

  
77 77
    }
78 78
    public void transition(java.util.BitSet sel, double x, double y){
79 79
		_fsm.addpoint(sel,x,y);
80 80
	}
81 81
    /**
82
     * Inserta el EditableFeatureSource que es sobre el que se hacen las
83
     * operaciones.
84
     *
85
     * @param efs EditableFeatureSource.
86
     */
87
    public void setEditingSource(EditableFeatureSource efs) {
88
        this.efs = efs;
89
    }
90

  
91
  /*  public void transition(java.util.BitSet sel, double x, double y){
92
    	_fsm.addpoint(sel,x,y);
93
    }
94
    */
95
    /**
96 82
     * Equivale al transition del prototipo pero sin pasarle como par? metro el
97 83
     * editableFeatureSource que ya estar? creado.
98 84
     *
......
103 89
    public void addpoint(java.util.BitSet sel, double x, double y) {
104 90
       // _fsm.addpoint(sel, x, y);
105 91

  
106
        CADToolState actualState = (CADToolState)_fsm.getPreviousState();
92
        LineCADToolState actualState = (LineCADToolState)_fsm.getPreviousState();
107 93
      //  CADToolState previousState=(CADToolState)_fsm.getPreviousState();
108 94
        String status = actualState.getName();
109 95
       // String previousstatus=previousState.getName();
110
        
96

  
111 97
        if (status.equals("ExecuteMap.Initial")) {
112 98
        	firstPoint=new Point2D.Double(x,y);
113 99
        	System.out.println("Question : "+question);
114 100
        } else if (status == "ExecuteMap.First") {
115 101
			firstPoint=new Point2D.Double(x,y);
116 102
			System.out.println("Question : "+question);
117
			
103

  
118 104
		} else if (status == "ExecuteMap.Second") {
119 105
			System.out.println("Question : "+question);
120 106
			//firstPoint=lastPoint;
......
124 110
						2);
125 111
				elShape.moveTo(firstPoint.getX(), firstPoint.getY());
126 112
				elShape.lineTo(lastPoint.getX(), lastPoint.getY());
127
				efs.addGeometry(ShapeFactory.createPolyline2D(elShape));
113
				DefaultFeature df=new DefaultFeature(ShapeFactory.createPolyline2D(elShape),null);
114
				vea.addRow(df);
128 115
			} catch (DriverIOException e) {
129 116
				e.printStackTrace();
130 117
			} catch (IOException e) {
131 118
				e.printStackTrace();
132 119
			}
133 120
			firstPoint=lastPoint;
134
		} 
121
		}
135 122

  
136 123
    }
137 124

  
......
164 151
     */
165 152
    public void drawOperation(Graphics g, FBitSet selectedGeometries, double x,
166 153
        double y) {
167
    	CADToolState actualState = _fsm.getState();
154
    	LineCADToolState actualState = _fsm.getState();
168 155
    	 String status = actualState.getName();
169 156

  
170 157
		//if ((status == "ExecuteMap.Second")){// || (status == "5")) {
171 158
			if (firstPoint!=null)
172 159
			drawLine((Graphics2D) g, firstPoint, new Point2D.Double(x, y));
173
		//} 
160
		//}
174 161
	}
175 162

  
176 163
    /**
......
191 178
        // TODO Auto-generated method stub
192 179
    }
193 180
    public void refresh(){
194
    	
181

  
195 182
    }
183
	public void setVectorialAdapter(VectorialEditableAdapter vea) {
184
	this.vea=vea;
185

  
186
	}
196 187
}
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/DefaultCADTool.java
47 47
import com.iver.cit.gvsig.fmap.core.ShapeFactory;
48 48
import com.iver.cit.gvsig.gui.cad.CADTool;
49 49
import com.iver.cit.gvsig.gui.cad.CADToolAdapter;
50
import com.iver.cit.gvsig.gui.cad.CadTool;
51 50

  
52 51

  
53 52
public abstract class DefaultCADTool implements CADTool {
......
55 54
	public void setCadToolAdapter(CADToolAdapter cta){
56 55
		cadToolAdapter = cta;
57 56
	}
58
	
57

  
59 58
	public CADToolAdapter getCadToolAdapter(){
60 59
		return cadToolAdapter;
61 60
	}
62
	
61

  
63 62
	public void drawLine(Graphics2D g, Point2D firstPoint, Point2D endPoint){
64 63
		GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD,
65 64
				2);
......
67 66
		elShape.lineTo(endPoint.getX(), endPoint.getY());
68 67
		ShapeFactory.createPolyline2D(elShape).draw(g,
69 68
			getCadToolAdapter().getMapControl().getViewPort(),
70
			CadTool.drawingSymbol);
71
		
69
			CADTool.drawingSymbol);
70

  
72 71
	}
73 72
}
trunk/extensions/extCAD/src/com/iver/cit/gvsig/StopEditingToShp.java
8 8
import com.iver.andami.PluginServices;
9 9
import com.iver.andami.plugins.Extension;
10 10
import com.iver.cit.gvsig.fmap.FMap;
11
import com.iver.cit.gvsig.fmap.core.IFeature;
12
import com.iver.cit.gvsig.fmap.edition.DefaultRowEdited;
13
import com.iver.cit.gvsig.fmap.edition.IRowEdited;
14 11
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter;
15 12
import com.iver.cit.gvsig.fmap.edition.writers.shp.ShpWriter;
16 13
import com.iver.cit.gvsig.fmap.layers.FLayers;
17 14
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
18
import com.iver.cit.gvsig.fmap.layers.VectorialAdapter;
19 15
import com.iver.cit.gvsig.gui.View;
20 16
import com.iver.cit.gvsig.project.ProjectView;
21 17

  
22 18

  
19

  
20

  
23 21
/**
24 22
 * DOCUMENT ME!
25 23
 *
26 24
 * @author Vicente Caballero Navarro
27 25
 */
28 26
public class StopEditingToShp implements Extension {
29
    /**
27
    private  View vista;
28
	/**
30 29
     * @see com.iver.andami.plugins.Extension#inicializar()
31 30
     */
32 31
    public void inicializar() {
......
39 38
        com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager()
40 39
                                                             .getActiveView();
41 40

  
42
        View vista = (View) f;
41
        vista = (View) f;
42

  
43 43
        ProjectView model = vista.getModel();
44 44
        FMap mapa = model.getMapContext();
45 45
            FLayers layers = mapa.getLayers();
......
70 70
    public void stopEditing(FLyrVect layer) {
71 71
        try {
72 72
            JFileChooser jfc = new JFileChooser();
73

  
74 73
           // if (jfc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
75 74
            /*   FLyrVect layer = (FLyrVect) test.createLayer("prueba",
76 75
                        (VectorialFileDriver) driverManager.getDriver(
......
81 80
        		    File newFile = jfc.getSelectedFile();
82 81

  
83 82
                    ShpWriter writer = new ShpWriter(newFile, layer);
84
                /*    writer.preProcess();
85 83

  
86
                    VectorialAdapter adapter = layer.getSource();
87

  
88
                    for (int i = 0; i < adapter.getShapeCount(); i++) {
89
                        IFeature feat = adapter.getFeature(i);
90
                        IRowEdited editFeat = new DefaultRowEdited(feat,
91
                                IRowEdited.STATUS_MODIFIED);
92
                        writer.process(editFeat);
93
                    }
94

  
95
                    writer.postProcess();
96
*/
97 84
                    VectorialEditableAdapter vea = (VectorialEditableAdapter) layer.getSource();
98 85
                    vea.stopEdition(writer);
99 86
                    layer.setSource(vea.getOriginalAdapter());
100 87
                    layer.setEditing(false);
88
                    vista.hideConsole();
101 89
                }
102 90
            //}
103 91
        } catch (Exception e) {

Also available in: Unified diff