Revision 4115

View differences:

trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/operations/strategies/DBStrategy.java
176 176
        dbAdapter.stop();
177 177
        
178 178
    }
179

  
180

  
181
	/* (non-Javadoc)
182
	 * @see com.iver.cit.gvsig.fmap.operations.strategies.DefaultStrategy#queryByRect(java.awt.geom.Rectangle2D)
183
	 */
184
	public FBitSet queryByRect(Rectangle2D rect) throws DriverException {
185
        // Nos aprovechamos del SQL para lanzar la consulta
186
        // teniendo en cuenta el boundingbox que toca.
187
        FLyrVect lyr = (FLyrVect) getCapa();
188
        VectorialDBAdapter dbAdapter = (VectorialDBAdapter) ((SingleLayer) capa).getSource();
189
        VectorialDatabaseDriver dbDriver = (VectorialDatabaseDriver) dbAdapter.getDriver();
190
        dbAdapter.start();
191
		ICoordTrans ct = lyr.getCoordTrans();
192
		String strEPSG = lyr.getProjection().getAbrev().substring(5);                
193
        Rectangle2D rectAux = rect;
194
        if (ct != null) {
195
            ICoordTrans invertedCT = ct.getInverted();
196
            rectAux = invertedCT.convert(rectAux);            
197
        }
198

  
199
        FBitSet selection = new FBitSet();
200
        
201
        IFeatureIterator geomIt = dbAdapter.getFeatureIterator(rectAux, strEPSG, null);
202
        if (geomIt == null)
203
        {
204
            return selection;
205
        }
206
        
207
        
208
        DriverAttributes attr = dbAdapter.getDriverAttributes();
209
        boolean bMustClone = false;
210
        if (attr != null)
211
        {
212
            if (attr.isLoadedInMemory())
213
            {
214
                bMustClone = attr.isLoadedInMemory();               
215
            }
216
        }
217

  
218
        
219
        int i;
220
        
221
        while (geomIt.hasNext())
222
        {
223
        	IFeature feat = geomIt.next();
224
            IGeometry geom = feat.getGeometry();
225
            
226
            if (ct != null) {
227
                if (bMustClone)
228
                    geom = geom.cloneGeometry();
229
                geom.reProject(ct);
230
            }
231

  
232
            i = dbDriver.getRowIndexByFID(feat);
233
            if (geom.intersects(rect))
234
            	selection.set(i, true);
235
        }
236
        dbAdapter.stop();
237
        
238
        return selection;
239
	}
179 240
    
180 241

  
181 242
}
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/operations/strategies/ShpStrategy.java
531 531
        int index;
532 532
        try {
533 533
            va.start();
534
            DriverAttributes attr = va.getDriverAttributes();
535
            boolean bMustClone = false;
536
            if (attr != null)
537
            {
538
                if (attr.isLoadedInMemory())
539
                {
540
                    bMustClone = attr.isLoadedInMemory();               
541
                }
542
            }
534 543

  
535 544
            for (int i=0; i < lstRecs.size(); i++)
536 545
            {
......
538 547
                index = idRec.intValue();
539 548
                IGeometry geom = va.getShape(index);
540 549
                if (ct != null) {
550
                    if (bMustClone)
551
                        geom = geom.cloneGeometry();
541 552
                    geom.reProject(ct);
542 553
                }
543 554
                if (geom.intersects(rect))
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/FGeometry.java
70 70
 * @author FJP
71 71
 */
72 72
public class FGeometry implements IGeometry3D {
73
	/**
74
	 * 
75
	 */
76
	private static final long serialVersionUID = 5431865770186523337L;
73 77
	private FShape shp;
74 78

  
75 79
	/**
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/IRowEdited.java
17 17
	     * 3=> Es una nueva fila a?adida. 
18 18
	     */
19 19
	    int getStatus();
20
	    
21
	    int getIndex();
20 22
}
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/writers/shp/testWriter.java
72 72
					for (int i=0; i < adapter.getShapeCount(); i++)
73 73
					{
74 74
						IFeature feat = adapter.getFeature(i);
75
						IRowEdited editFeat = new DefaultRowEdited(feat, IRowEdited.STATUS_MODIFIED);
75
						IRowEdited editFeat = new DefaultRowEdited(feat, IRowEdited.STATUS_MODIFIED, i);
76 76
						writer.process(editFeat);
77 77
					}
78 78
					writer.postProcess();
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/VectorialEditableAdapter.java
45 45
 *
46 46
 * $Id$
47 47
 * $Log$
48
 * Revision 1.22  2006-02-13 18:18:31  fjp
48
 * Revision 1.23  2006-02-15 18:16:02  fjp
49 49
 * POR TERMINAR
50 50
 *
51
 * Revision 1.22  2006/02/13 18:18:31  fjp
52
 * POR TERMINAR
53
 *
51 54
 * Revision 1.21  2006/02/10 13:28:23  caballero
52 55
 * poder cambiar la selecci?n
53 56
 *
......
146 149
	private VectorialAdapter ova;
147 150
	//private VectorialDriver driver;
148 151
	private Quadtree index;
152
	
153
	
154
	/* private class MyFeatureIterator implements IFeatureIterator
155
	{
156
		int numReg = 0;
157
		Rectangle2D rect;
158
		String epsg;
159
		IFeatureIterator origFeatIt;
160
		boolean bHasNext = true;
161
		
162
		public MyFeatureIterator(Rectangle2D r, String strEPSG) throws DriverException
163
		{
164
			rect = r;
165
			epsg = strEPSG;
166
			origFeatIt = ova.getFeatureIterator(r, epsg);
167
		}
168
		public boolean hasNext() throws DriverException {
169
				return bHasNext;
170
		}
171

  
172
		public IFeature next() throws DriverException {
173
			IFeature aux = origFeatIt.next();
174
			return null;
175
		}
176

  
177
		public void closeIterator() throws DriverException {
178
			
179
		}
180
		
181
	} */
182
	
149 183
	public VectorialEditableAdapter(){
150 184
		super();
151 185
	}
......
277 311
    	int calculatedIndex=getCalculatedIndex(index);
278 312
    	Integer integer = new Integer(calculatedIndex);
279 313
        //Si no est? en el fichero de expansi?n
314
    	DefaultRowEdited edRow=null;    	
280 315
        if (!relations.containsKey(integer)) {
281
            //Si ha sido eliminada
282
            /*if (delRows.get(index)) {
283
                return null;
284
            } else {*/
285
                DefaultRowEdited edRow=null;
286
				try {
287
					edRow = new DefaultRowEdited(ova.getFeature(calculatedIndex),
288
					        DefaultRowEdited.STATUS_ORIGINAL);
289
				} catch (DriverException e) {
290
					// TODO Auto-generated catch block
291
					e.printStackTrace();
292
				}
316
			try {
317
				edRow = new DefaultRowEdited(ova.getFeature(calculatedIndex),
318
				        DefaultRowEdited.STATUS_ORIGINAL, index);
319
			} catch (DriverException e) {
320
				// TODO Auto-generated catch block
321
				e.printStackTrace();
322
			}
293 323

  
294
                return edRow;
295
            //}
324
            return edRow;
296 325
        } else {
297 326
            int num = ((Integer) relations.get(integer)).intValue();
298

  
299
            return expansionFile.getRow(num);
327
            IRowEdited aux = expansionFile.getRow(num);
328
            edRow = new DefaultRowEdited(aux,
329
			        aux.getStatus(), index);
330
            return edRow;
300 331
        }
301 332
    }
302 333
    /**
......
554 585
     * @return Array de ?ndices para su uso con getGeometry, removeGeometry,
555 586
     *         ...
556 587
     */
557
    public int[] getRowsIndexes(Rectangle2D r) {
588
    public int[] getRowsIndexes_OLD(Rectangle2D r) {
558 589
        Envelope e = new Envelope(r.getX(), r.getX() + r.getWidth(), r.getY(),
559 590
                r.getY() + r.getHeight());
560 591
        List l = index.query(e);
......
659 690
		}
660 691
		return FShape.MULTI;
661 692
	}
662
	public IFeatureIterator getFeatureIterator(String strEPSG) throws DriverException {
663
		// TODO Auto-generated method stub
664
		return null;
665
	}
666
	public IFeatureIterator getFeatureIterator(Rectangle2D r, String strEPSG) throws DriverException {
667
		// Recorremos las feature que nos da el adapter
668
		// y luego todas las dem?s.
669
		// TODO:!!!
670
		IFeatureIterator featIt = ova.getFeatureIterator(r, strEPSG);
671
		while (featIt.hasNext())
672
		{
673
			IFeature featOrig = featIt.next();
674
			if (featOrig == null) continue;			
675
	        if (!relations.containsKey(featOrig.getID())) {
676
                DefaultRowEdited edRow=null;
677
				edRow = new DefaultRowEdited(featOrig,
678
					        DefaultRowEdited.STATUS_ORIGINAL);
679
                // return edRow;
680
	        } else {
681
	            int num = ((Integer) relations.get(featOrig.getID())).intValue();
682
	            // return expansionFile.getRow(num);
693
	/**
694
	 * Usar solo cuando est?s seguro de que puedes
695
	 * gastar memoria. Nosotros lo usamos para las 
696
	 * b?squedas por ?ndice espacial con el handle.
697
	 * La idea es usarlo una vez, guardar las geometr?as que 
698
	 * necesitas en ese extent y trabajar con ellas
699
	 * hasta el siguiente cambio de extent.
700
	 * @param r
701
	 * @param strEPSG
702
	 * @return
703
	 * @throws DriverException
704
	 */
705
	public IRowEdited[] getFeatures(Rectangle2D r, String strEPSG) throws DriverException {
706
		// En esta clase suponemos random access.
707
		// Luego tendremos otra clase que sea VectorialEditableDBAdapter
708
		// que reescribir? este m?todo.
709
        Envelope e = new Envelope(r.getX(), r.getX() + r.getWidth(), r.getY(),
710
                r.getY() + r.getHeight());
711
        List l = index.query(e);
712
        IRowEdited[] feats = new IRowEdited[l.size()];
713
        try {
714
	        for (int index = 0; index < l.size(); index++) {
715
	            Integer i = (Integer) l.get(index);
716
	            int inverse = getInversedIndex(i.intValue());
717
				feats[index] = getRow(inverse);
683 718
	        }
684
			
719
		} catch (DriverIOException e1) {
720
			throw new DriverException(e1);
721
		} catch (IOException e1) {
722
			throw new DriverException(e1);
685 723
		}
686
		// Las modificadas:
687
		/* for (int i=0; i < relations.size(); i++)
688
		{
689
			relations.
690
		} */
691
		return null;
724
		
725
		return feats;
692 726
	}
693 727
	
694 728

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/EditableAdapter.java
151 151

  
152 152
                try {
153 153
                    edRow = new DefaultRowEdited(new DefaultRow(ods.getRow(calculatedIndex)),
154
                            DefaultRowEdited.STATUS_ORIGINAL);
154
                            DefaultRowEdited.STATUS_ORIGINAL, index);
155 155
                } catch (DriverException e) {
156 156
                    throw new DriverIOException(e);
157 157
                }
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/DefaultRowEdited.java
8 8

  
9 9
	private IRow row;
10 10
	private int status;
11
	private int index;
11 12

  
12 13
	/**
13 14
	 * Quiz?s conviene que RowEdited tenga un getRow y un getStatus.
......
17 18
	 * @param status
18 19
	 * @param linkedId
19 20
	 */
20
	public DefaultRowEdited(IRow baseRow, int status)
21
	public DefaultRowEdited(IRow baseRow, int status, int index)
21 22
	{
22 23
		this.status = status;
23 24
		row = baseRow;
25
		this.index = index;
24 26
	}
25 27
	public IRow getLinkedRow() {
26 28
		return row;
......
43 45
	public IRow cloneRow() {
44 46
		return row.cloneRow();
45 47
	}
48
	public int getIndex() {
49
		return index;
50
	}
46 51

  
47 52
}
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/MemoryExpansionFile.java
64 64
	 * @see com.iver.cit.gvsig.fmap.edition.ExpansionFile#addRow(IRow)
65 65
	 */
66 66
	public int addRow(IRow row) throws IOException {
67
		int newIndex = rows.size();
67 68
		IRowEdited edRow = new DefaultRowEdited(row,
68
				IRowEdited.STATUS_ADDED);
69
				IRowEdited.STATUS_ADDED, newIndex);
69 70
		rows.add(edRow);
70 71

  
71
		return rows.size() - 1;
72
		return newIndex;
72 73
	}
73 74

  
74 75
	/**
......
83 84
*/
84 85
		//invalidateRow(index);
85 86
		IRowEdited edRow = new DefaultRowEdited(row,
86
				IRowEdited.STATUS_MODIFIED);
87
				IRowEdited.STATUS_MODIFIED, index);
87 88

  
88 89
		rows.add(edRow);
89 90

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/ReadableVectorial.java
151 151
     */
152 152
    public IFeature getFeature(int numReg) throws DriverException;
153 153
    
154
    public IFeatureIterator getFeatureIterator(String strEPSG) throws DriverException;
155
    public IFeatureIterator getFeatureIterator(Rectangle2D r, String strEPSG) throws DriverException;
154
    /* public IFeatureIterator getFeatureIterator(String strEPSG) throws DriverException;
155
    public IFeatureIterator getFeatureIterator(Rectangle2D r, String strEPSG) throws DriverException; */
156 156

  
157 157
	//void setRecordset(SelectableDataSource sds);
158 158

  
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/VectorialAdapter.java
174 174
	 *      espacial. Por defecto, suponemos un buen acceso aleatorio y usamos
175 175
	 *      getFeature(i)
176 176
	 */
177
	public IFeatureIterator getFeatureIterator(Rectangle2D r, String strEPSG)
177
	/* public IFeatureIterator getFeatureIterator(Rectangle2D r, String strEPSG)
178 178
			throws DriverException {
179 179
		try {
180 180
			return new RandomAccessFeatureIterator(driver, getRecordset(), r,
......
191 191
		} catch (DriverLoadException e) {
192 192
			throw new DriverException(e);
193 193
		}
194
	}
194
	} */
195 195

  
196 196
}
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/SelectionCADTool.java
240 240
	}
241 241

  
242 242
	/**
243
	 * Equivale al transition del prototipo pero sin pasarle como par? metro el
243
	 * Equivale al transition del prototipo pero sin pasarle como par?metro el
244 244
	 * editableFeatureSource que ya estar? creado.
245 245
	 *
246 246
	 * @param selection
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/CADToolAdapter.java
12 12
import java.awt.geom.Rectangle2D;
13 13
import java.awt.image.MemoryImageSource;
14 14
import java.io.IOException;
15
import java.util.List;
15 16
import java.util.Stack;
16 17

  
17 18
import com.iver.andami.PluginServices;
18 19
import com.iver.cit.gvsig.CADExtension;
19
import com.iver.cit.gvsig.fmap.DriverException;
20
import com.iver.cit.gvsig.fmap.MapControl;
21 20
import com.iver.cit.gvsig.fmap.ViewPort;
22 21
import com.iver.cit.gvsig.fmap.core.Handler;
23
import com.iver.cit.gvsig.fmap.core.IFeature;
24 22
import com.iver.cit.gvsig.fmap.core.IGeometry;
25 23
import com.iver.cit.gvsig.fmap.core.v02.FConstant;
26 24
import com.iver.cit.gvsig.fmap.core.v02.FSymbol;
......
32 30
import com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener;
33 31
import com.iver.cit.gvsig.gui.View;
34 32
import com.iver.cit.gvsig.gui.cad.tools.SelectionCADTool;
33
import com.vividsolutions.jts.geom.Envelope;
34
import com.vividsolutions.jts.index.SpatialIndex;
35 35

  
36 36
public class CADToolAdapter extends Behavior {
37 37
	private Stack cadToolStack = new Stack();
38 38

  
39
	//Para pasarle las coordenadas cuando se produce un evento textEntered
39
	// Para pasarle las coordenadas cuando se produce un evento textEntered
40 40
	private int lastX;
41

  
41 42
	private int lastY;
43

  
42 44
	private FSymbol symbol = new FSymbol(FConstant.SYMBOL_TYPE_POINT, Color.RED);
45

  
43 46
	private Point2D mapAdjustedPoint;
47

  
44 48
	private boolean questionAsked = false;
49

  
45 50
	private Point2D adjustedPoint;
51

  
46 52
	private boolean snapping = false;
53

  
47 54
	private boolean adjustSnapping = false;
55

  
48 56
	private VectorialEditableAdapter vea;
49
	private CADGrid cadgrid=new CADGrid();
50 57

  
58
	private CADGrid cadgrid = new CADGrid();
59

  
60
	private SpatialIndex spatialCache;
61

  
51 62
	/**
52 63
	 * Pinta de alguna manera especial las geometrias seleccionadas para la
53
	 * edici?n. En caso de que el snapping est? activado, pintar? el efecto
54
	 * del mismo.
55
	 *
64
	 * edici?n. En caso de que el snapping est? activado, pintar? el efecto del
65
	 * mismo.
66
	 * 
56 67
	 * @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#paintComponent(java.awt.Graphics)
57 68
	 */
58 69
	public void paintComponent(Graphics g) {
......
60 71
		drawCursor(g);
61 72
		getGrid().drawGrid(g);
62 73
		if (adjustedPoint != null) {
63
			Point2D p=null;
74
			Point2D p = null;
64 75
			if (mapAdjustedPoint != null) {
65 76
				p = mapAdjustedPoint;
66 77
			} else {
67 78
				p = getMapControl().getViewPort().toMapPoint(adjustedPoint);
68 79
			}
69
			((CADTool) cadToolStack.peek()).drawOperation(g,
70
				p.getX(), p.getY());
80
			((CADTool) cadToolStack.peek())
81
					.drawOperation(g, p.getX(), p.getY());
71 82
		}
72 83
	}
73 84

  
......
75 86
	 * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
76 87
	 */
77 88
	public void mouseClicked(MouseEvent e) throws BehaviorException {
78
		if (e.getButton()==MouseEvent.BUTTON3){
89
		if (e.getButton() == MouseEvent.BUTTON3) {
79 90
			CADExtension.showPopup(e);
80 91
		}
81 92
	}
......
101 112
			ViewPort vp = getMapControl().getMapContext().getViewPort();
102 113
			Point2D p;
103 114

  
104
				if (mapAdjustedPoint != null) {
115
			if (mapAdjustedPoint != null) {
105 116
				p = mapAdjustedPoint;
106 117
			} else {
107 118
				p = vp.toMapPoint(adjustedPoint);
108 119
			}
109
			transition(vea,
110
				new double[] { p.getX(), p.getY() });
120
			transition(vea, new double[] { p.getX(), p.getY() });
111 121
		}
112 122
	}
113 123

  
114 124
	/**
115
	 * Ajusta un punto de la imagen que se pasa como  par?metro al grid si ?ste
125
	 * Ajusta un punto de la imagen que se pasa como par?metro al grid si ?ste
116 126
	 * est? activo y devuelve la distancia de un punto al punto ajustado
117
	 *
127
	 * 
118 128
	 * @param point
119
	 * @param mapHandlerAdjustedPoint DOCUMENT ME!
120
	 *
129
	 * @param mapHandlerAdjustedPoint
130
	 *            DOCUMENT ME!
131
	 * 
121 132
	 * @return Distancia del punto que se pasa como par?metro al punto ajustado
122 133
	 */
123 134
	private double adjustToHandler(Point2D point,
124
		Point2D mapHandlerAdjustedPoint) {
125
		//if (selection.cardinality() > 0) {
126
		double rw=getMapControl().getViewPort().toMapDistance(5);
127
		try {
128
			Point2D mapPoint = point;
129
			Rectangle2D r = new Rectangle2D.Double(mapPoint.getX() - rw/2,
130
					mapPoint.getY() - rw/2, rw, rw);
135
			Point2D mapHandlerAdjustedPoint) {
136
		// if (selection.cardinality() > 0) {
137
		double rw = getMapControl().getViewPort().toMapDistance(5);
138
		Point2D mapPoint = point;
139
		Rectangle2D r = new Rectangle2D.Double(mapPoint.getX() - rw / 2,
140
				mapPoint.getY() - rw / 2, rw, rw);
131 141

  
132
			int[] indexes = vea.getRowsIndexes(r);
142
		// int[] indexes = vea.getRowsIndexes(r);
143
		Envelope e = new Envelope(r.getX(), r.getX() + r.getWidth(), r.getY(),
144
				r.getY() + r.getHeight());
145
		List l = getSpatialCache().query(e);
146
		double min = Double.MAX_VALUE;
147
		Point2D argmin = null;
148
		Point2D mapArgmin = null;
133 149

  
134
			double min = Double.MAX_VALUE;
135
			Point2D argmin = null;
136
			Point2D mapArgmin = null;
150
		for (int i = 0; i < l.size(); i++) {
151
			IGeometry geometry = null;
152
			geometry = (IGeometry) l.get(i);// getFeature(indexes[i]);
153
			Handler[] handlers = geometry.getHandlers(IGeometry.SELECTHANDLER);
137 154

  
138
			for (int i = 0; i < indexes.length; i++) {
139
				IGeometry geometry=null;
140
					geometry = vea.getShape(indexes[i]);//getFeature(indexes[i]);
141
				Handler[] handlers = geometry.getHandlers(IGeometry.SELECTHANDLER);
142

  
143
				for (int j = 0; j < handlers.length; j++) {
144
					Point2D handlerPoint = handlers[j].getPoint();
145
					//System.err.println("handlerPoint= "+ handlerPoint);
146
					Point2D handlerImagePoint = handlerPoint;
147
					double dist = handlerImagePoint.distance(point);
148
					if ((dist < getMapControl().getViewPort().toMapDistance(SelectionCADTool.tolerance)) &&
149
							(dist < min)) {
150
						min = dist;
151
						argmin = handlerImagePoint;
152
						mapArgmin = handlerPoint;
153
					}
155
			for (int j = 0; j < handlers.length; j++) {
156
				Point2D handlerPoint = handlers[j].getPoint();
157
				// System.err.println("handlerPoint= "+ handlerPoint);
158
				Point2D handlerImagePoint = handlerPoint;
159
				double dist = handlerImagePoint.distance(point);
160
				if ((dist < getMapControl().getViewPort().toMapDistance(
161
						SelectionCADTool.tolerance))
162
						&& (dist < min)) {
163
					min = dist;
164
					argmin = handlerImagePoint;
165
					mapArgmin = handlerPoint;
154 166
				}
155 167
			}
168
		}
156 169

  
157
			if (argmin != null) {
158
				point.setLocation(argmin);
170
		if (argmin != null) {
171
			point.setLocation(argmin);
159 172

  
160
				//Se hace el casting porque no se quiere redondeo
161
				point.setLocation(argmin.getX(), argmin.getY());
173
			// Se hace el casting porque no se quiere redondeo
174
			point.setLocation(argmin.getX(), argmin.getY());
162 175

  
163
				mapHandlerAdjustedPoint.setLocation(mapArgmin);
176
			mapHandlerAdjustedPoint.setLocation(mapArgmin);
164 177

  
165
				return min;
166
			}
167
		} catch (DriverIOException e) {
168
			// TODO Auto-generated catch block
169
			e.printStackTrace();
178
			return min;
170 179
		}
171 180

  
172 181
		return Double.MAX_VALUE;
......
202 211

  
203 212
		getMapControl().repaint();
204 213
	}
205
	private void clearMouseImage(){
214

  
215
	private void clearMouseImage() {
206 216
		int[] pixels = new int[16 * 16];
207 217
		Image image = Toolkit.getDefaultToolkit().createImage(
208
			new MemoryImageSource(16, 16, pixels, 0, 16));
209
		Cursor transparentCursor =
210
			Toolkit.getDefaultToolkit().createCustomCursor
211
			    (image, new Point(0,0), "invisiblecursor");
218
				new MemoryImageSource(16, 16, pixels, 0, 16));
219
		Cursor transparentCursor = Toolkit.getDefaultToolkit()
220
				.createCustomCursor(image, new Point(0, 0), "invisiblecursor");
212 221

  
213 222
		getMapControl().setCursor(transparentCursor);
214 223
	}
224

  
215 225
	/**
216 226
	 * DOCUMENT ME!
217
	 *
218
	 * @param g DOCUMENT ME!
227
	 * 
228
	 * @param g
229
	 *            DOCUMENT ME!
219 230
	 */
220 231
	private void drawCursor(Graphics g) {
221 232

  
......
230 241
		int size1 = 15;
231 242
		int size2 = 3;
232 243
		g.drawLine((int) (p.getX() - size1), (int) (p.getY()),
233
			(int) (p.getX() + size1), (int) (p.getY()));
244
				(int) (p.getX() + size1), (int) (p.getY()));
234 245
		g.drawLine((int) (p.getX()), (int) (p.getY() - size1),
235
			(int) (p.getX()), (int) (p.getY() + size1));
246
				(int) (p.getX()), (int) (p.getY() + size1));
236 247

  
237 248
		if (adjustedPoint != null) {
238 249
			if (adjustSnapping) {
239 250
				g.setColor(Color.ORANGE);
240 251
				g.drawRect((int) (adjustedPoint.getX() - 6),
241
					(int) (adjustedPoint.getY() - 6), 12, 12);
252
						(int) (adjustedPoint.getY() - 6), 12, 12);
242 253
				g.drawRect((int) (adjustedPoint.getX() - 3),
243
					(int) (adjustedPoint.getY() - 3), 6, 6);
254
						(int) (adjustedPoint.getY() - 3), 6, 6);
244 255
				g.setColor(Color.MAGENTA);
245 256
				g.drawRect((int) (adjustedPoint.getX() - 4),
246
					(int) (adjustedPoint.getY() - 4), 8, 8);
257
						(int) (adjustedPoint.getY() - 4), 8, 8);
247 258

  
248 259
				adjustSnapping = false;
249 260
			} else {
250 261
				g.drawRect((int) (p.getX() - size2), (int) (p.getY() - size2),
251
					(int) (size2 * 2), (int) (size2 * 2));
262
						(int) (size2 * 2), (int) (size2 * 2));
252 263
			}
253 264
		}
254 265
	}
255 266

  
256 267
	/**
257 268
	 * DOCUMENT ME!
258
	 *
269
	 * 
259 270
	 * @param point
260 271
	 */
261 272
	private void calculateSnapPoint(Point point) {
262
		//Se comprueba el ajuste a rejilla
273
		// Se comprueba el ajuste a rejilla
263 274

  
264
		Point2D gridAdjustedPoint = getMapControl().getViewPort().toMapPoint(point);
275
		Point2D gridAdjustedPoint = getMapControl().getViewPort().toMapPoint(
276
				point);
265 277
		double minDistance = Double.MAX_VALUE;
266
		CADTool ct=(CADTool)cadToolStack.peek();
267
		if (ct instanceof SelectionCADTool && ((SelectionCADTool)ct).getStatus().equals("ExecuteMap.Initial")){
268
			mapAdjustedPoint=gridAdjustedPoint;
269
			adjustedPoint=(Point2D)point.clone();
270
		}else{
278
		CADTool ct = (CADTool) cadToolStack.peek();
279
		if (ct instanceof SelectionCADTool
280
				&& ((SelectionCADTool) ct).getStatus().equals(
281
						"ExecuteMap.Initial")) {
282
			mapAdjustedPoint = gridAdjustedPoint;
283
			adjustedPoint = (Point2D) point.clone();
284
		} else {
271 285

  
272
			minDistance= getGrid().adjustToGrid(gridAdjustedPoint);
286
			minDistance = getGrid().adjustToGrid(gridAdjustedPoint);
273 287
			if (minDistance < Double.MAX_VALUE) {
274
				adjustedPoint = getMapControl().getViewPort().fromMapPoint(gridAdjustedPoint);
288
				adjustedPoint = getMapControl().getViewPort().fromMapPoint(
289
						gridAdjustedPoint);
275 290
				mapAdjustedPoint = gridAdjustedPoint;
276 291
			} else {
277 292
				mapAdjustedPoint = null;
......
279 294
		}
280 295
		Point2D handlerAdjustedPoint = null;
281 296

  
282
		//Se comprueba el ajuste a los handlers
297
		// Se comprueba el ajuste a los handlers
283 298
		if (mapAdjustedPoint != null) {
284
			handlerAdjustedPoint = (Point2D) mapAdjustedPoint.clone(); //getMapControl().getViewPort().toMapPoint(point);
299
			handlerAdjustedPoint = (Point2D) mapAdjustedPoint.clone(); // getMapControl().getViewPort().toMapPoint(point);
285 300
		} else {
286
			handlerAdjustedPoint = getMapControl().getViewPort().toMapPoint(point);
301
			handlerAdjustedPoint = getMapControl().getViewPort().toMapPoint(
302
					point);
287 303
		}
288 304

  
289 305
		Point2D mapPoint = new Point2D.Double();
......
291 307

  
292 308
		if (distance < minDistance) {
293 309
			adjustSnapping = true;
294
			adjustedPoint = getMapControl().getViewPort().fromMapPoint(handlerAdjustedPoint);
310
			adjustedPoint = getMapControl().getViewPort().fromMapPoint(
311
					handlerAdjustedPoint);
295 312
			mapAdjustedPoint = mapPoint;
296 313
			minDistance = distance;
297 314
		}
298 315

  
299
		//Si no hay ajuste
316
		// Si no hay ajuste
300 317
		if (minDistance == Double.MAX_VALUE) {
301 318
			adjustedPoint = point;
302 319
			mapAdjustedPoint = null;
......
312 329
		ViewPort vp = getMapControl().getViewPort();
313 330
		// Point2D pReal = vp.toMapPoint(e.getPoint());
314 331

  
315
		Point2D pReal = new Point2D.Double(vp.getAdjustedExtent().getCenterX()
316
				, vp.getAdjustedExtent().getCenterY());
332
		Point2D pReal = new Point2D.Double(vp.getAdjustedExtent().getCenterX(),
333
				vp.getAdjustedExtent().getCenterY());
317 334
		int amount = e.getWheelRotation();
318
        double nuevoX;
319
        double nuevoY;
320
        double factor;
335
		double nuevoX;
336
		double nuevoY;
337
		double factor;
321 338

  
322 339
		if (amount > 0) // nos acercamos
323 340
		{
324 341
			factor = 0.9;
325
		}
326
		else // nos alejamos
342
		} else // nos alejamos
327 343
		{
328 344
			factor = 1.2;
329 345
		}
330
        Rectangle2D.Double r = new Rectangle2D.Double();
331
        if (vp.getExtent()!=null)
332
        {
333
	        nuevoX = pReal.getX() - ((vp.getExtent().getWidth() * factor) / 2.0);
334
	        nuevoY = pReal.getY() - ((vp.getExtent().getHeight() * factor) / 2.0);
335
	        r.x = nuevoX;
336
	        r.y = nuevoY;
337
	        r.width = vp.getExtent().getWidth() * factor;
338
	        r.height = vp.getExtent().getHeight() * factor;
346
		Rectangle2D.Double r = new Rectangle2D.Double();
347
		if (vp.getExtent() != null) {
348
			nuevoX = pReal.getX()
349
					- ((vp.getExtent().getWidth() * factor) / 2.0);
350
			nuevoY = pReal.getY()
351
					- ((vp.getExtent().getHeight() * factor) / 2.0);
352
			r.x = nuevoX;
353
			r.y = nuevoY;
354
			r.width = vp.getExtent().getWidth() * factor;
355
			r.height = vp.getExtent().getHeight() * factor;
339 356

  
340
	        vp.setExtent(r);
341
        }
357
			vp.setExtent(r);
358
		}
342 359
	}
343 360

  
344 361
	/**
345 362
	 * M?todo que realiza las transiciones en las herramientas en funci?n de un
346 363
	 * texto introducido en la consola
347
	 *
348
	 * @param text DOCUMENT ME!
364
	 * 
365
	 * @param text
366
	 *            DOCUMENT ME!
349 367
	 */
350 368
	public void textEntered(String text) {
351 369
		if (text == null) {
352 370
			transition("cancel");
353 371
		} else {
354
		/*	if ("".equals(text)) {
355
				transition("aceptar");
356
			} else {*/
357
				text = text.trim();
372
			/*
373
			 * if ("".equals(text)) { transition("aceptar"); } else {
374
			 */
375
			text = text.trim();
358 376

  
359
				String[] numbers = text.split(",");
360
				double[] values = null;
377
			String[] numbers = text.split(",");
378
			double[] values = null;
361 379

  
362
				try {
363
					if (numbers.length == 2) {
364
						//punto
365
						values = new double[] {
366
								Double.parseDouble(numbers[0]),
367
								Double.parseDouble(numbers[1])
368
							};
369
						transition( vea,
370
							values);
371
					} else if (numbers.length == 1) {
372
						//valor
373
						values = new double[] { Double.parseDouble(numbers[0]) };
374
						transition( vea,
375
							values[0]);
376
					}
377
				} catch (NumberFormatException e) {
378
					transition( vea,
379
						text);
380
			try {
381
				if (numbers.length == 2) {
382
					// punto
383
					values = new double[] { Double.parseDouble(numbers[0]),
384
							Double.parseDouble(numbers[1]) };
385
					transition(vea, values);
386
				} else if (numbers.length == 1) {
387
					// valor
388
					values = new double[] { Double.parseDouble(numbers[0]) };
389
					transition(vea, values[0]);
380 390
				}
381
			//}
391
			} catch (NumberFormatException e) {
392
				transition(vea, text);
393
			}
394
			// }
382 395
		}
383 396
		getMapControl().repaint();
384 397
	}
385 398

  
386 399
	/**
387 400
	 * Transici?n por comando ("cancel", actionCommand de una herramienta, etc).
388
	 *
389
	 * @param text DOCUMENT ME!
401
	 * 
402
	 * @param text
403
	 *            DOCUMENT ME!
390 404
	 */
391 405
	public void transition(String text) {
392
		transition( vea, text);
406
		transition(vea, text);
393 407
		// getMapControl().repaint();
394 408
	}
395 409

  
......
398 412
	 */
399 413
	public void configureMenu() {
400 414
		String[] desc = ((CADTool) cadToolStack.peek()).getDescriptions();
401
		//String[] labels = ((CADTool) cadToolStack.peek()).getCurrentTransitions();
415
		// String[] labels = ((CADTool)
416
		// cadToolStack.peek()).getCurrentTransitions();
402 417
		CADExtension.clearMenu();
403 418

  
404 419
		for (int i = 0; i < desc.length; i++) {
405 420
			if (desc[i] != null) {
406
				CADExtension.addMenuEntry(desc[i]);//, labels[i]);
421
				CADExtension.addMenuEntry(desc[i]);// , labels[i]);
407 422
			}
408 423
		}
409 424

  
......
411 426

  
412 427
	/**
413 428
	 * DOCUMENT ME!
414
	 *
415
	 * @param text DOCUMENT ME!
416
	 * @param source DOCUMENT ME!
417
	 * @param sel DOCUMENT ME!
418
	 * @param values DOCUMENT ME!
429
	 * 
430
	 * @param text
431
	 *            DOCUMENT ME!
432
	 * @param source
433
	 *            DOCUMENT ME!
434
	 * @param sel
435
	 *            DOCUMENT ME!
436
	 * @param values
437
	 *            DOCUMENT ME!
419 438
	 */
420
	private void transition( VectorialEditableAdapter source,
421
		double[] values) {
439
	private void transition(VectorialEditableAdapter source, double[] values) {
422 440
		questionAsked = true;
423
		if (!cadToolStack.isEmpty()){
424
		    CADTool ct = (CADTool) cadToolStack.peek();
425
		    ///String[] trs = ct.getAutomaton().getCurrentTransitions();
426
		    boolean esta = true;
427
		  /*  for (int i = 0; i < trs.length; i++) {
428
                if (trs[i].toUpperCase().equals(text.toUpperCase()))
429
                    esta = true;
430
            }
431
		    */
432
		    if (!esta){
433
		        askQuestion();
434
		    }else{
435
				ct.transition(values[0],values[1]);
436
				//Si es la transici?n que finaliza una geometria hay que redibujar la vista.
441
		if (!cadToolStack.isEmpty()) {
442
			CADTool ct = (CADTool) cadToolStack.peek();
443
			// /String[] trs = ct.getAutomaton().getCurrentTransitions();
444
			boolean esta = true;
445
			/*
446
			 * for (int i = 0; i < trs.length; i++) { if
447
			 * (trs[i].toUpperCase().equals(text.toUpperCase())) esta = true; }
448
			 */
449
			if (!esta) {
450
				askQuestion();
451
			} else {
452
				ct.transition(values[0], values[1]);
453
				// Si es la transici?n que finaliza una geometria hay que
454
				// redibujar la vista.
437 455

  
438 456
				askQuestion();
439
			/*	if ((ret & Automaton.AUTOMATON_FINISHED) == Automaton.AUTOMATON_FINISHED) {
440
					popCadTool();
441

  
442
					if (cadToolStack.isEmpty()) {
443
						pushCadTool(new com.iver.cit.gvsig.gui.cad.smc.gen.CADTool());//new SelectionCadTool());
444
						PluginServices.getMainFrame().setSelectedTool("selection");
445
					}
446

  
447
					askQuestion();
448

  
449
					getMapControl().drawMap(false);
450
				} else {
451
					if (((CadTool) cadToolStack.peek()).getAutomaton().checkState('c')) {
452
						getMapControl().drawMap(false);
453
					}
454

  
455
					if (!questionAsked) {
456
						askQuestion();
457
					}
458
				}
459

  
460
				configureMenu();*/
461
		    }
457
				/*
458
				 * if ((ret & Automaton.AUTOMATON_FINISHED) ==
459
				 * Automaton.AUTOMATON_FINISHED) { popCadTool();
460
				 * 
461
				 * if (cadToolStack.isEmpty()) { pushCadTool(new
462
				 * com.iver.cit.gvsig.gui.cad.smc.gen.CADTool());//new
463
				 * SelectionCadTool());
464
				 * PluginServices.getMainFrame().setSelectedTool("selection"); }
465
				 * 
466
				 * askQuestion();
467
				 * 
468
				 * getMapControl().drawMap(false); } else { if (((CadTool)
469
				 * cadToolStack.peek()).getAutomaton().checkState('c')) {
470
				 * getMapControl().drawMap(false); }
471
				 * 
472
				 * if (!questionAsked) { askQuestion(); } }
473
				 * 
474
				 * configureMenu();
475
				 */
476
			}
462 477
		}
463 478
		configureMenu();
464 479
		PluginServices.getMainFrame().enableControls();
465 480
	}
481

  
466 482
	/**
467 483
	 * DOCUMENT ME!
468
	 *
469
	 * @param text DOCUMENT ME!
470
	 * @param source DOCUMENT ME!
471
	 * @param sel DOCUMENT ME!
472
	 * @param values DOCUMENT ME!
484
	 * 
485
	 * @param text
486
	 *            DOCUMENT ME!
487
	 * @param source
488
	 *            DOCUMENT ME!
489
	 * @param sel
490
	 *            DOCUMENT ME!
491
	 * @param values
492
	 *            DOCUMENT ME!
473 493
	 */
474
	private void transition( VectorialEditableAdapter source,
475
		double value) {
494
	private void transition(VectorialEditableAdapter source, double value) {
476 495
		questionAsked = true;
477
		if (!cadToolStack.isEmpty()){
478
		    CADTool ct = (CADTool) cadToolStack.peek();
479
		    ct.transition(value);
496
		if (!cadToolStack.isEmpty()) {
497
			CADTool ct = (CADTool) cadToolStack.peek();
498
			ct.transition(value);
480 499
			askQuestion();
481
		    }
500
		}
482 501
		configureMenu();
483 502
		PluginServices.getMainFrame().enableControls();
484 503
	}
485
	private void transition(VectorialEditableAdapter source,
486
			String option) {
487
			questionAsked = true;
488
			if (!cadToolStack.isEmpty()){
489
			    CADTool ct = (CADTool) cadToolStack.peek();
490
			    ct.transition(option);
491
				askQuestion();
492
			    }
493
			configureMenu();
494
			PluginServices.getMainFrame().enableControls();
504

  
505
	private void transition(VectorialEditableAdapter source, String option) {
506
		questionAsked = true;
507
		if (!cadToolStack.isEmpty()) {
508
			CADTool ct = (CADTool) cadToolStack.peek();
509
			ct.transition(option);
510
			askQuestion();
511
		}
512
		configureMenu();
513
		PluginServices.getMainFrame().enableControls();
495 514
	}
515

  
496 516
	/**
497 517
	 * DOCUMENT ME!
498
	 *
499
	 * @param value DOCUMENT ME!
518
	 * 
519
	 * @param value
520
	 *            DOCUMENT ME!
500 521
	 */
501 522
	public void setGrid(boolean value) {
502 523
		getGrid().setUseGrid(value);
......
506 527

  
507 528
	/**
508 529
	 * DOCUMENT ME!
509
	 *
510
	 * @param activated DOCUMENT ME!
530
	 * 
531
	 * @param activated
532
	 *            DOCUMENT ME!
511 533
	 */
512 534
	public void setSnapping(boolean activated) {
513 535
		snapping = activated;
......
515 537

  
516 538
	/**
517 539
	 * DOCUMENT ME!
518
	 *
519
	 * @param x DOCUMENT ME!
520
	 * @param y DOCUMENT ME!
521
	 * @param dist DOCUMENT ME!
540
	 * 
541
	 * @param x
542
	 *            DOCUMENT ME!
543
	 * @param y
544
	 *            DOCUMENT ME!
545
	 * @param dist
546
	 *            DOCUMENT ME!
522 547
	 */
523 548
	public void getSnapPoint(double x, double y, double dist) {
524 549
	}
......
528 553
	 */
529 554
	public ToolListener getListener() {
530 555
		return new ToolListener() {
531
				/**
532
				 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor()
533
				 */
534
				public Cursor getCursor() {
535
					return null;
536
				}
556
			/**
557
			 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor()
558
			 */
559
			public Cursor getCursor() {
560
				return null;
561
			}
537 562

  
538
				/**
539
				 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
540
				 */
541
				public boolean cancelDrawing() {
542
					return false;
543
				}
544
			};
563
			/**
564
			 * @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing()
565
			 */
566
			public boolean cancelDrawing() {
567
				return false;
568
			}
569
		};
545 570
	}
546 571

  
547 572
	/**
548 573
	 * DOCUMENT ME!
549
	 *
574
	 * 
550 575
	 * @return DOCUMENT ME!
551 576
	 */
552 577
	public CADTool getCadTool() {
......
555 580

  
556 581
	/**
557 582
	 * DOCUMENT ME!
558
	 *
559
	 * @param cadTool DOCUMENT ME!
583
	 * 
584
	 * @param cadTool
585
	 *            DOCUMENT ME!
560 586
	 */
561 587
	public void pushCadTool(CADTool cadTool) {
562 588
		cadToolStack.push(cadTool);
563 589
		cadTool.setCadToolAdapter(this);
564
		//cadTool.initializeStatus();
565
		//cadTool.setVectorialAdapter(vea);
566
		/*int ret = cadTool.transition(null, editableFeatureSource, selection,
567
				new double[0]);
568

  
569
		if ((ret & Automaton.AUTOMATON_FINISHED) == Automaton.AUTOMATON_FINISHED) {
570
			popCadTool();
571

  
572
			if (cadToolStack.isEmpty()) {
573
				pushCadTool(new com.iver.cit.gvsig.gui.cad.smc.gen.CADTool());//new SelectionCadTool());
574
				PluginServices.getMainFrame().setSelectedTool("selection");
575
			}
576

  
577
			askQuestion();
578

  
579
			getMapControl().drawMap(false);
580
		}
581
		*/
590
		// cadTool.initializeStatus();
591
		// cadTool.setVectorialAdapter(vea);
592
		/*
593
		 * int ret = cadTool.transition(null, editableFeatureSource, selection,
594
		 * new double[0]);
595
		 * 
596
		 * if ((ret & Automaton.AUTOMATON_FINISHED) ==
597
		 * Automaton.AUTOMATON_FINISHED) { popCadTool();
598
		 * 
599
		 * if (cadToolStack.isEmpty()) { pushCadTool(new
600
		 * com.iver.cit.gvsig.gui.cad.smc.gen.CADTool());//new
601
		 * SelectionCadTool());
602
		 * PluginServices.getMainFrame().setSelectedTool("selection"); }
603
		 * 
604
		 * askQuestion();
605
		 * 
606
		 * getMapControl().drawMap(false); }
607
		 */
582 608
	}
583 609

  
584 610
	/**
......
592 618
	 * DOCUMENT ME!
593 619
	 */
594 620
	public void askQuestion() {
595
		CADTool cadtool=(CADTool) cadToolStack.peek();
596
		/*if (cadtool..getStatus()==0){
597
			PluginServices.getMainFrame().addTextToConsole("\n" +cadtool.getName());
598
		}
599
*/
621
		CADTool cadtool = (CADTool) cadToolStack.peek();
622
		/*
623
		 * if (cadtool..getStatus()==0){
624
		 * PluginServices.getMainFrame().addTextToConsole("\n"
625
		 * +cadtool.getName()); }
626
		 */
600 627
		View vista = (View) PluginServices.getMDIManager().getActiveView();
601
		vista.getConsolePanel().addText("\n" + cadtool.getQuestion()+">");
602
		//***PluginServices.getMainFrame().addTextToConsole("\n" + cadtool.getQuestion());
628
		vista.getConsolePanel().addText("\n" + cadtool.getQuestion() + ">");
629
		// ***PluginServices.getMainFrame().addTextToConsole("\n" +
630
		// cadtool.getQuestion());
603 631
		questionAsked = true;
604 632

  
605 633
	}
606 634

  
607 635
	/**
608 636
	 * DOCUMENT ME!
609
	 *
610
	 * @param cadTool DOCUMENT ME!
637
	 * 
638
	 * @param cadTool
639
	 *            DOCUMENT ME!
611 640
	 */
612 641
	public void setCadTool(CADTool cadTool) {
613 642
		cadToolStack.clear();
......
617 646

  
618 647
	/**
619 648
	 * DOCUMENT ME!
620
	 *
649
	 * 
621 650
	 * @return DOCUMENT ME!
622 651
	 */
623 652
	public VectorialEditableAdapter getVectorialAdapter() {
......
626 655

  
627 656
	/**
628 657
	 * DOCUMENT ME!
629
	 *
630
	 * @param editableFeatureSource DOCUMENT ME!
631
	 * @param selection DOCUMENT ME!
658
	 * 
659
	 * @param editableFeatureSource
660
	 *            DOCUMENT ME!
661
	 * @param selection
662
	 *            DOCUMENT ME!
632 663
	 */
633
	public void setVectorialAdapter(
634
		VectorialEditableAdapter vea) {
664
	public void setVectorialAdapter(VectorialEditableAdapter vea) {
635 665
		this.vea = vea;
636 666
	}
637 667

  
638 668
	/**
639 669
	 * DOCUMENT ME!
640
	 *
670
	 * 
641 671
	 * @return DOCUMENT ME!
642 672
	 */
643
	/*public CadMapControl getCadMapControl() {
644
		return cadMapControl;
645
	}
646
*/
673
	/*
674
	 * public CadMapControl getCadMapControl() { return cadMapControl; }
675
	 */
647 676
	/**
648 677
	 * DOCUMENT ME!
649
	 *
650
	 * @param cadMapControl DOCUMENT ME!
678
	 * 
679
	 * @param cadMapControl
680
	 *            DOCUMENT ME!
651 681
	 */
652
	/*public void setCadMapControl(CadMapControl cadMapControl) {
653
		this.cadMapControl = cadMapControl;
654
	}
655
*/
682
	/*
683
	 * public void setCadMapControl(CadMapControl cadMapControl) {
684
	 * this.cadMapControl = cadMapControl; }
685
	 */
656 686

  
657 687
	/**
658 688
	 * Elimina las geometr?as seleccionadas actualmente
659 689
	 */
660 690
	private void delete() {
661 691
		vea.startComplexRow();
662
		FBitSet selection=getVectorialAdapter().getSelection();
692
		FBitSet selection = getVectorialAdapter().getSelection();
663 693
		try {
664
			int[] indexesToDel=new int[selection.cardinality()];
665
			int j=0;
666
			for (int i = selection.nextSetBit(0); i >= 0;
667
					i = selection.nextSetBit(i + 1)) {
668
				indexesToDel[j++]=i;
669
				///vea.removeRow(i);
694
			int[] indexesToDel = new int[selection.cardinality()];
695
			int j = 0;
696
			for (int i = selection.nextSetBit(0); i >= 0; i = selection
697
					.nextSetBit(i + 1)) {
698
				indexesToDel[j++] = i;
699
				// /vea.removeRow(i);
670 700
			}
671
			for (j=indexesToDel.length-1;j>=0;j--){
701
			for (j = indexesToDel.length - 1; j >= 0; j--) {
672 702
				vea.removeRow(indexesToDel[j]);
673 703
			}
674 704
		} catch (DriverIOException e) {
......
691 721

  
692 722
	/**
693 723
	 * DOCUMENT ME!
694
	 *
724
	 * 
695 725
	 * @param b
696 726
	 */
697 727
	public void setAdjustGrid(boolean b) {
......
700 730

  
701 731
	/**
702 732
	 * DOCUMENT ME!
703
	 *
733
	 * 
704 734
	 * @param actionCommand
705 735
	 */
706 736
	public void keyPressed(String actionCommand) {
707 737
		if (actionCommand.equals("eliminar")) {
708 738
			delete();
709 739
		} else if (actionCommand.equals("escape")) {
710
			if (getMapControl().getTool().equals("cadtooladapter")){
740
			if (getMapControl().getTool().equals("cadtooladapter")) {
711 741
				CADTool ct = (CADTool) cadToolStack.peek();
712 742
				ct.end();
713 743
				cadToolStack.clear();
......
722 752
		PluginServices.getMainFrame().enableControls();
723 753

  
724 754
	}
725
	public CADGrid getGrid(){
755

  
756
	public CADGrid getGrid() {
726 757
		return cadgrid;
727 758
	}
759

  
760
	/**
761
	 * @return Returns the spatialCache.
762
	 */
763
	public SpatialIndex getSpatialCache() {
764
		return spatialCache;
765
	}
766

  
767
	/**
768
	 * @param spatialCache
769
	 *            The spatialCache to set.
770
	 */
771
	public void setSpatialCache(SpatialIndex spatialCache) {
772
		this.spatialCache = spatialCache;
773
	}
728 774
}

Also available in: Unified diff