Revision 1763
branches/FMap_piloto_CAD_Layout_version/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/dxf/write/DxfWriter.java | ||
---|---|---|
97 | 97 |
|
98 | 98 |
for (int i=0;i<geoms.length;i++) { |
99 | 99 |
if (geoms[i].getGeometryType()==FShape.POINT) { |
100 |
System.out.println("Punto encontrado."); |
|
100 |
//System.out.println("Punto encontrado.");
|
|
101 | 101 |
FPoint2D point = new FPoint2D(0,0); |
102 | 102 |
double[] pointCoords = new double[6]; |
103 | 103 |
GeneralPathXIterator pointIt = geoms[i].getGeneralPathXIterator(); |
... | ... | |
120 | 120 |
pv.add(py); |
121 | 121 |
entityMaker.createPoint(pv); |
122 | 122 |
} else if (geoms[i].getGeometryType()==FShape.LINE) { |
123 |
System.out.println("L?nea encontrada."); |
|
123 |
//System.out.println("L?nea encontrada.");
|
|
124 | 124 |
double[] lineCoords = new double[6]; |
125 | 125 |
GeneralPathXIterator lineIt = geoms[i].getGeneralPathXIterator(); |
126 | 126 |
int j = 0; |
... | ... | |
219 | 219 |
sev.add(polylineLayer); |
220 | 220 |
entityMaker.endSeq();*/ |
221 | 221 |
} else if (geoms[i].getGeometryType()==FShape.ARC) { |
222 |
System.out.println("ARC encontrado."); |
|
222 |
//System.out.println("ARC encontrado.");
|
|
223 | 223 |
FShape[] shapes = geoms[i].getShapes(); |
224 | 224 |
FArc2D fArc = (FArc2D)(shapes[0]); |
225 | 225 |
Point2D[] pts = new Point2D[3]; |
... | ... | |
230 | 230 |
double radius = center.distance(pts[0]); |
231 | 231 |
double initAngle=TrigonometricalFunctions.getAngle(center, pts[0]); |
232 | 232 |
initAngle = Math.toDegrees(initAngle); |
233 |
System.out.println("initAngle = " + initAngle); |
|
233 |
//System.out.println("initAngle = " + initAngle);
|
|
234 | 234 |
double midAngle=TrigonometricalFunctions.getAngle(center, pts[1]); |
235 | 235 |
midAngle = Math.toDegrees(midAngle); |
236 |
System.out.println("midAngle = " + midAngle); |
|
236 |
//System.out.println("midAngle = " + midAngle);
|
|
237 | 237 |
double endAngle=TrigonometricalFunctions.getAngle(center, pts[2]); |
238 | 238 |
endAngle = Math.toDegrees(endAngle); |
239 |
System.out.println("endAngle = " + endAngle); |
|
239 |
//System.out.println("endAngle = " + endAngle);
|
|
240 | 240 |
|
241 | 241 |
// 050307, jmorell: Resoluci?n de un bug sobre el sentido de |
242 | 242 |
// los arcos. |
243 |
if (!TrigonometricalFunctions.isCCW(pts[0],pts[1],pts[2])){ |
|
243 |
/*if (!TrigonometricalFunctions.isCCW(pts[0],pts[1],pts[2])){
|
|
244 | 244 |
double aux=initAngle; |
245 | 245 |
initAngle=endAngle; |
246 | 246 |
endAngle=aux; |
247 |
} |
|
247 |
}*/
|
|
248 | 248 |
|
249 | 249 |
/*FArc2D arc = (FArc2D)(shapes[0]); |
250 | 250 |
Point2D center = arc.getCenter(); |
... | ... | |
282 | 282 |
av.add(ae); |
283 | 283 |
entityMaker.createArc(av); |
284 | 284 |
} else if (geoms[i].getGeometryType()==FShape.CIRCLE) { |
285 |
System.out.println("CIRCLE encontrado."); |
|
285 |
//System.out.println("CIRCLE encontrado.");
|
|
286 | 286 |
FShape[] shapes = geoms[i].getShapes(); |
287 | 287 |
FCircle2D circle = (FCircle2D)(shapes[0]); |
288 | 288 |
Point2D center = circle.getCenter(); |
... | ... | |
304 | 304 |
av.add(ar); |
305 | 305 |
entityMaker.createCircle(av); |
306 | 306 |
} else if (geoms[i].getGeometryType()==FShape.ELLIPSE) { |
307 |
System.out.println("ELLIPSE encontrada."); |
|
307 |
//System.out.println("ELLIPSE encontrada.");
|
|
308 | 308 |
FShape[] shapes = geoms[i].getShapes(); |
309 | 309 |
FEllipse2D fElip = (FEllipse2D)(shapes[0]); |
310 | 310 |
Point2D center = new Point2D.Double((fElip.getInit().getX()+fElip.getEnd().getX())/2, (fElip.getInit().getY()+fElip.getEnd().getY())/2); |
311 | 311 |
double mAxisL = fElip.getDist()*2; |
312 |
System.out.println("mAxisL = " + mAxisL); |
|
312 |
//System.out.println("mAxisL = " + mAxisL);
|
|
313 | 313 |
/*System.out.println("mAxisL/(center.distance(fElip.getEnd()))*2 = " + mAxisL/(center.distance(fElip.getEnd()))*2); |
314 | 314 |
minToMaj.setData(new Double(mAxisL/()*2));*/ |
315 | 315 |
double maAxisL = fElip.getInit().distance(fElip.getEnd()); |
... | ... | |
331 | 331 |
endPointOfMajorAxis = pAux; |
332 | 332 |
} |
333 | 333 |
double mToMAR = mAxisL/maAxisL; |
334 |
System.out.println("mToMar = " + mToMAR); |
|
334 |
//System.out.println("mToMar = " + mToMAR);
|
|
335 | 335 |
DxfGroup arcLayer = new DxfGroup(8, "default"); |
336 | 336 |
DxfGroup x = new DxfGroup(); |
337 | 337 |
DxfGroup y = new DxfGroup(); |
... | ... | |
428 | 428 |
entityMaker.endSeq();*/ |
429 | 429 |
// Para escribir LwPolylines. |
430 | 430 |
} else if (geoms[i] instanceof FGeometryCollection) { |
431 |
System.out.println("Polil?nea encontrada (Soluci?n provisional)."); |
|
431 |
//System.out.println("Polil?nea encontrada (Soluci?n provisional).");
|
|
432 | 432 |
FGeometryCollection gc = (FGeometryCollection)geoms[i]; |
433 | 433 |
FShape[] fShapes = gc.getShapes(); |
434 | 434 |
//double[] lineCoords = new double[6]; |
... | ... | |
444 | 444 |
Point2D last = new Point2D.Double(); |
445 | 445 |
for (int j=0;j<fShapes.length;j++) { |
446 | 446 |
if (fShapes[j] instanceof FPolyline2D && !(fShapes[j] instanceof FArc2D)) { |
447 |
System.out.println("L?nea encontrada dentro de la polil?nea."); |
|
447 |
//System.out.println("L?nea encontrada dentro de la polil?nea.");
|
|
448 | 448 |
FPolyline2D fLine = (FPolyline2D)fShapes[j]; |
449 | 449 |
double[] lineCoords = new double[6]; |
450 | 450 |
PathIterator lineIt = fLine.getPathIterator(new AffineTransform()); |
... | ... | |
483 | 483 |
} |
484 | 484 |
} |
485 | 485 |
} else if (fShapes[j] instanceof FArc2D) { |
486 |
System.out.println("Arco encontrada dentro de la polil?nea."); |
|
486 |
//System.out.println("Arco encontrada dentro de la polil?nea.");
|
|
487 | 487 |
FArc2D fArc = (FArc2D)fShapes[j]; |
488 | 488 |
double[] lineCoords = new double[6]; |
489 | 489 |
/*PathIterator lineIt = fLine.getPathIterator(new AffineTransform()); |
... | ... | |
493 | 493 |
pts[1] = fArc.getMid(); |
494 | 494 |
pts[2] = fArc.getEnd(); |
495 | 495 |
Point2D center = fArc.getCenter(); //TrigonometricalFunctions.getCenter(pts[0], pts[1], pts[2]); |
496 |
System.out.println("pts[0] = " + pts[0]); |
|
497 |
System.out.println("pts[1] = " + pts[1]); |
|
498 |
System.out.println("center = " + center); |
|
499 |
System.out.println("pts[2] = " + pts[2]); |
|
496 |
//System.out.println("pts[0] = " + pts[0]);
|
|
497 |
//System.out.println("pts[1] = " + pts[1]);
|
|
498 |
//System.out.println("center = " + center);
|
|
499 |
//System.out.println("pts[2] = " + pts[2]);
|
|
500 | 500 |
double initAngRad = TrigonometricalFunctions.getAngle(center, pts[0]); |
501 | 501 |
double endAngRad = TrigonometricalFunctions.getAngle(center, pts[2]); |
502 | 502 |
double angleRad = endAngRad-initAngRad; |
branches/FMap_piloto_CAD_Layout_version/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/CommandRecord.java | ||
---|---|---|
50 | 50 |
* |
51 | 51 |
* @author Vicente Caballero Navarro |
52 | 52 |
*/ |
53 |
interface CommandRecord { |
|
53 |
public interface CommandRecord {
|
|
54 | 54 |
/** |
55 | 55 |
* A?ade un nuevo comando a la pila de deshacer(undos) y borra la de rehacer(redos). |
56 | 56 |
* |
branches/FMap_piloto_CAD_Layout_version/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/AddGeometryCommand.java | ||
---|---|---|
35 | 35 |
* @see com.iver.cit.gvsig.fmap.edition.Command#redo() |
36 | 36 |
*/ |
37 | 37 |
public void redo() throws DriverIOException, IOException { |
38 |
index=efs.getGeometryCount(); |
|
39 |
((DefaultEditableFeatureSource)efs).doAddGeometry(geometry); |
|
38 |
//index=efs.getGeometryCount();
|
|
39 |
index=((DefaultEditableFeatureSource)efs).doAddGeometry(geometry);
|
|
40 | 40 |
|
41 | 41 |
} |
42 | 42 |
} |
branches/FMap_piloto_CAD_Layout_version/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/MemoryCommandRecord.java | ||
---|---|---|
78 | 78 |
*/ |
79 | 79 |
public void pushCommand(Command command) |
80 | 80 |
throws IOException, DriverIOException { |
81 |
if (command instanceof CommandCollection && ((CommandCollection)command).commands.isEmpty()){ |
|
82 |
return; |
|
83 |
} |
|
84 |
|
|
81 | 85 |
undos.add(command); |
82 | 86 |
redos.clear(); |
87 |
|
|
83 | 88 |
} |
84 | 89 |
|
85 | 90 |
/** |
branches/FMap_piloto_CAD_Layout_version/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/cad/TrigonometricalFunctions.java | ||
---|---|---|
184 | 184 |
if (p1.equals(p2) || p2.equals(p3) || p1.equals(p3)) { |
185 | 185 |
return null; |
186 | 186 |
} |
187 |
|
|
187 |
|
|
188 | 188 |
Point2D[] perp1 = getPerpendicular(p1, p2, |
189 | 189 |
new Point2D.Double((p1.getX() + p2.getX()) / 2, |
190 | 190 |
(p1.getY() + p2.getY()) / 2)); |
... | ... | |
195 | 195 |
return getIntersection(perp1[0], perp1[1], perp2[0], perp2[1]); |
196 | 196 |
} |
197 | 197 |
|
198 |
|
|
198 | 199 |
/** |
199 |
* Obtiene el centro del circulo que pasa por los puntos p1, p2 y p3 |
|
200 |
* |
|
201 |
* @param p1 |
|
202 |
* @param p2 |
|
203 |
* @param p3 |
|
204 |
* |
|
205 |
* @return Devuelve el punto o null si no hay ning?n c?rculo (puntos |
|
206 |
* alineados) |
|
207 |
*/ |
|
208 |
public static Point2D getCircleCenter(Point2D p1, Point2D p2, Point2D p3) { |
|
209 |
double xC; |
|
210 |
double yC; |
|
211 |
double w; |
|
212 |
double h; |
|
213 |
|
|
214 |
// Calculamos 2 secantes, tiramos perpendiculares por sus puntos |
|
215 |
// medios y obtenemos el centro. Luego calculamos el radio. |
|
216 |
// Puntos medios de los segmentos. |
|
217 |
double xm1; |
|
218 |
|
|
219 |
// Calculamos 2 secantes, tiramos perpendiculares por sus puntos |
|
220 |
// medios y obtenemos el centro. Luego calculamos el radio. |
|
221 |
// Puntos medios de los segmentos. |
|
222 |
double ym1; |
|
223 |
|
|
224 |
// Calculamos 2 secantes, tiramos perpendiculares por sus puntos |
|
225 |
// medios y obtenemos el centro. Luego calculamos el radio. |
|
226 |
// Puntos medios de los segmentos. |
|
227 |
double xm2; |
|
228 |
|
|
229 |
// Calculamos 2 secantes, tiramos perpendiculares por sus puntos |
|
230 |
// medios y obtenemos el centro. Luego calculamos el radio. |
|
231 |
// Puntos medios de los segmentos. |
|
232 |
double ym2; |
|
233 |
xm1 = (p1.getX() + p2.getX()) / 2.0; |
|
234 |
ym1 = (p1.getY() + p2.getY()) / 2.0; |
|
235 |
xm2 = (p2.getX() + p3.getX()) / 2.0; |
|
236 |
ym2 = (p2.getY() + p3.getY()) / 2.0; |
|
237 |
|
|
238 |
/* |
|
239 |
* g.setColor(Color.GRAY); g.draw3DRect((int)xm1, (int) ym1, 1, 1, |
|
240 |
* true); g.draw3DRect((int)xm2, (int) ym2, 1, 1, true); |
|
241 |
*/ |
|
242 |
|
|
243 |
// Pendientes de las perpendiculares y constantes |
|
244 |
double mP1 = 0; |
|
245 |
|
|
246 |
/* |
|
247 |
* g.setColor(Color.GRAY); g.draw3DRect((int)xm1, (int) ym1, 1, 1, |
|
248 |
* true); g.draw3DRect((int)xm2, (int) ym2, 1, 1, true); |
|
249 |
*/ |
|
250 |
|
|
251 |
// Pendientes de las perpendiculares y constantes |
|
252 |
double mP2 = 0; |
|
253 |
|
|
254 |
/* |
|
255 |
* g.setColor(Color.GRAY); g.draw3DRect((int)xm1, (int) ym1, 1, 1, |
|
256 |
* true); g.draw3DRect((int)xm2, (int) ym2, 1, 1, true); |
|
257 |
*/ |
|
258 |
|
|
259 |
// Pendientes de las perpendiculares y constantes |
|
260 |
double A1; |
|
261 |
|
|
262 |
/* |
|
263 |
* g.setColor(Color.GRAY); g.draw3DRect((int)xm1, (int) ym1, 1, 1, |
|
264 |
* true); g.draw3DRect((int)xm2, (int) ym2, 1, 1, true); |
|
265 |
*/ |
|
266 |
|
|
267 |
// Pendientes de las perpendiculares y constantes |
|
268 |
double A2; |
|
269 |
boolean bPerp1 = false; |
|
270 |
boolean bPerp2 = false; |
|
271 |
|
|
272 |
if ((p2.getY() - p1.getY()) == 0) { |
|
273 |
A1 = ym1; |
|
274 |
bPerp1 = true; |
|
275 |
} else { |
|
276 |
mP1 = (p2.getX() - p1.getX()) / (p1.getY() - p2.getY()); |
|
277 |
A1 = ym1 - (xm1 * mP1); |
|
278 |
} |
|
279 |
|
|
280 |
if ((p2.getY() - p3.getY()) == 0) { |
|
281 |
A2 = ym2; |
|
282 |
bPerp2 = true; |
|
283 |
} else { |
|
284 |
mP2 = (p3.getX() - p2.getX()) / (p2.getY() - p3.getY()); |
|
285 |
A2 = ym2 - (xm2 * mP2); |
|
286 |
} |
|
287 |
|
|
288 |
if (mP2 == mP1) { |
|
289 |
return null; // Error, 3 puntos alineados. No puede pasar un arco |
|
290 |
} else { |
|
291 |
xC = (A2 - A1) / (mP1 - mP2); |
|
292 |
|
|
293 |
if (!bPerp1) { |
|
294 |
yC = (xC * mP1) + A1; |
|
295 |
} else { |
|
296 |
yC = (xC * mP2) + A2; |
|
297 |
} |
|
298 |
} |
|
299 |
|
|
300 |
return new Point2D.Double(xC, yC); |
|
301 |
} |
|
302 |
|
|
303 |
/** |
|
304 | 200 |
* Obtiene un c?rculo a partir de 3 puntos. Devuelve null si no se puede |
305 | 201 |
* crear el c?ruclo porque los puntos est?n alineados |
306 | 202 |
* |
... | ... | |
314 | 210 |
// Graphics |
315 | 211 |
// g) |
316 | 212 |
{ |
317 |
Point2D center = getCircleCenter(p1, p2, p3);
|
|
213 |
Point2D center = getCenter(p1, p2, p3); |
|
318 | 214 |
|
319 | 215 |
double Radio = p1.distance(center); |
320 | 216 |
double xR = center.getX() - Radio; |
branches/FMap_piloto_CAD_Layout_version/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/AddFFrameCommand.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.fmap.edition; |
|
42 |
|
|
43 |
import java.io.IOException; |
|
44 |
|
|
45 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
|
46 |
|
|
47 |
|
|
48 |
public class AddFFrameCommand implements Command{ |
|
49 |
|
|
50 |
/** |
|
51 |
* @see com.iver.cit.gvsig.fmap.edition.Command#undo() |
|
52 |
*/ |
|
53 |
public void undo() throws DriverIOException, IOException { |
|
54 |
} |
|
55 |
|
|
56 |
/** |
|
57 |
* @see com.iver.cit.gvsig.fmap.edition.Command#redo() |
|
58 |
*/ |
|
59 |
public void redo() throws DriverIOException, IOException { |
|
60 |
} |
|
61 |
|
|
62 |
} |
|
0 | 63 |
branches/FMap_piloto_CAD_Layout_version/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/DefaultEditableFeatureSource.java | ||
---|---|---|
23 | 23 |
* @author Vicente Caballero Navarro |
24 | 24 |
*/ |
25 | 25 |
public class DefaultEditableFeatureSource implements EditableFeatureSource { |
26 |
/* |
|
27 |
* Fichero en el que se guardan las nuevas geometr?as, producto de adiciones |
|
28 |
* o de modificaciones |
|
29 |
*/ |
|
26 | 30 |
private ExpansionFile expansionFile; |
31 |
/* |
|
32 |
* Fuente de datos original que se est? editando |
|
33 |
*/ |
|
27 | 34 |
private OriginalFeatureAdapter ofa; |
35 |
/* |
|
36 |
* Geometr?as modificadas de la fuente de datos original |
|
37 |
*/ |
|
28 | 38 |
private BitSet delgeometries = new BitSet(); |
39 |
/* |
|
40 |
* Establece una relaci?n entre los ?ndices de las geometr?as en el EditableFeatureSource |
|
41 |
* y los ?ndices en el fichero de expansi?n |
|
42 |
*/ |
|
29 | 43 |
private HashMap relations = new HashMap(); |
30 | 44 |
private int numAdd = 0; |
45 |
// ?ndice espacial |
|
31 | 46 |
private Quadtree index; |
32 | 47 |
private Image selectionImage; |
33 |
private CommandRecord cr; |
|
34 |
private FBitSet fbitset; |
|
35 |
private boolean complex = false; |
|
36 |
private CommandCollection commands = null; |
|
48 |
protected CommandRecord cr; |
|
49 |
private FBitSet seleccion; |
|
50 |
/** Flag que indica que hay que tomar las siguientes operaciones como una operaci?n at?mica **/ |
|
51 |
protected boolean complex = false; |
|
52 |
protected CommandCollection commands = null; |
|
37 | 53 |
|
38 | 54 |
/** |
39 | 55 |
* Crea un nuevo AbstractEditableFeatureSource. |
... | ... | |
47 | 63 |
expansionFile = ef; |
48 | 64 |
this.ofa = ofa; |
49 | 65 |
this.cr = new MemoryCommandRecord(); |
50 |
fbitset = bitset;
|
|
66 |
seleccion = bitset;
|
|
51 | 67 |
} |
52 | 68 |
|
53 | 69 |
/** |
... | ... | |
59 | 75 |
*/ |
60 | 76 |
public void startEdition() throws EditionException { |
61 | 77 |
if (ofa!=null){ |
62 |
ofa.startEdition();
|
|
78 |
ofa.startEdition(); |
|
63 | 79 |
} |
64 | 80 |
try { |
65 | 81 |
expansionFile.open(); |
... | ... | |
144 | 160 |
throws IOException, DriverIOException { |
145 | 161 |
Integer integer = new Integer(index); |
146 | 162 |
|
163 |
//Si no est? en el fichero de expansi?n |
|
147 | 164 |
if (!relations.containsKey(integer)) { |
165 |
//Si ha sido eliminada |
|
148 | 166 |
if (delgeometries.get(index)) { |
149 | 167 |
return null; |
150 | 168 |
} else { |
... | ... | |
303 | 321 |
*/ |
304 | 322 |
public void undoRemoveGeometry(int index) |
305 | 323 |
throws IOException, DriverIOException { |
324 |
// Si la relaci?n |
|
306 | 325 |
if (relations.containsKey(new Integer(index))) { |
307 | 326 |
expansionFile.validateGeometry(((Integer) relations.get( |
308 | 327 |
new Integer(index))).intValue()); |
... | ... | |
326 | 345 |
* expansion file a justo despues de la penultima geometr?a |
327 | 346 |
* |
328 | 347 |
* @param geometryIndex ?ndice de la geometr?a que se quiere deshacer su |
329 |
* movimiento
|
|
348 |
* modificaci?n
|
|
330 | 349 |
* @param previousExpansionFileIndex ?ndice que ten?a antes la geometr?a en |
331 | 350 |
* el expansionFile. Si vale -1 quiere decir que es una |
332 | 351 |
* modificaci?n de una geometr?a original y por tanto no hay que |
... | ... | |
337 | 356 |
*/ |
338 | 357 |
public void undoModifyGeometry(int geometryIndex, |
339 | 358 |
int previousExpansionFileIndex) throws IOException, DriverIOException { |
359 |
/* |
|
360 |
* Si la acci?n de modificar se realiz? sobre una geometr?a original |
|
361 |
*/ |
|
340 | 362 |
if (previousExpansionFileIndex == -1) { |
341 |
//eliminar geometr?a del expansion file. |
|
342 |
//expansionFile.invalidateGeometry(geometryIndex); |
|
363 |
//Se obtiene la geometr?a para actualizar el ?ndice |
|
343 | 364 |
IGeometry g = getGeometry(geometryIndex); |
344 | 365 |
Rectangle2D r = g.getBounds2D(); |
366 |
//Se elimina de las relaciones y del fichero de expansi?n |
|
345 | 367 |
relations.remove(new Integer(geometryIndex)); |
368 |
expansionFile.deleteLastGeometry(); |
|
346 | 369 |
|
370 |
//Se actualizan los ?ndices |
|
347 | 371 |
IGeometry gAnt = getGeometry(geometryIndex); |
348 | 372 |
Rectangle2D rAnt = gAnt.getBounds2D(); |
349 | 373 |
this.index.remove(new Envelope(r.getX(), r.getX() + r.getWidth(), |
... | ... | |
352 | 376 |
this.index.insert(new Envelope(rAnt.getX(), |
353 | 377 |
rAnt.getX() + rAnt.getWidth(), rAnt.getY(), |
354 | 378 |
rAnt.getY() + rAnt.getHeight()), new Integer(geometryIndex)); |
355 |
expansionFile.deleteLastGeometry(); |
|
356 |
|
|
357 |
numAdd--; |
|
358 | 379 |
} else { |
380 |
|
|
381 |
//Se obtiene la geometr?a para actualizar el ?ndice |
|
359 | 382 |
IGeometry g = null; |
360 | 383 |
g = getGeometry(geometryIndex); |
361 | 384 |
|
... | ... | |
364 | 387 |
r.getY(), r.getY() + r.getHeight()), |
365 | 388 |
new Integer(geometryIndex)); |
366 | 389 |
|
390 |
//Se actualiza la relaci?n de ?ndices |
|
367 | 391 |
Integer integer = new Integer(geometryIndex); |
368 | 392 |
relations.put(new Integer(geometryIndex), |
369 | 393 |
new Integer(previousExpansionFileIndex)); |
394 |
|
|
395 |
//Se recupera la geometr?a |
|
370 | 396 |
expansionFile.validateGeometry(previousExpansionFileIndex); |
397 |
|
|
398 |
//Se actualizan los ?ndices |
|
371 | 399 |
g = getGeometry(geometryIndex); |
372 | 400 |
r = g.getBounds2D(); |
373 | 401 |
this.index.insert(new Envelope(r.getX(), r.getX() + r.getWidth(), |
... | ... | |
378 | 406 |
|
379 | 407 |
/** |
380 | 408 |
* A?ade una geometria al fichero de expansi?n y guarda la correspondencia |
381 |
* en una tabla asociada.
|
|
409 |
* en la tabla relations.
|
|
382 | 410 |
* |
383 | 411 |
* @param g geometr?a a guardar. |
384 | 412 |
* |
... | ... | |
389 | 417 |
*/ |
390 | 418 |
public int doAddGeometry(IGeometry g) throws DriverIOException, IOException { |
391 | 419 |
int virtualIndex=0; |
420 |
//A?ade la geometr?a |
|
392 | 421 |
if (ofa!=null){ |
393 | 422 |
virtualIndex = ofa.getGeometryCount() + numAdd; |
394 | 423 |
}else{ |
... | ... | |
398 | 427 |
relations.put(new Integer(virtualIndex), new Integer(pos)); |
399 | 428 |
numAdd++; |
400 | 429 |
|
430 |
//Actualiza el ?ndice espacial |
|
401 | 431 |
Rectangle2D r = g.getBounds2D(); |
402 | 432 |
index.insert(new Envelope(r.getX(), r.getX() + r.getWidth(), r.getY(), |
403 | 433 |
r.getY() + r.getHeight()), new Integer(virtualIndex)); |
404 | 434 |
|
405 |
// System.err.println(this.index.size()); |
|
406 | 435 |
return virtualIndex; |
407 | 436 |
} |
408 | 437 |
|
... | ... | |
423 | 452 |
|
424 | 453 |
IGeometry g = null; |
425 | 454 |
|
455 |
//Si la geometr?a no ha sido modificada |
|
426 | 456 |
if (!relations.containsKey(integer)) { |
427 | 457 |
delgeometries.set(index, true); |
428 | 458 |
g = ofa.getGeometry(index); |
... | ... | |
432 | 462 |
expansionFile.invalidateGeometry(num); |
433 | 463 |
} |
434 | 464 |
|
465 |
//Se actualiza el ?ndice |
|
435 | 466 |
if (g != null) { |
436 | 467 |
Rectangle2D r = g.getBounds2D(); |
437 | 468 |
this.index.remove(new Envelope(r.getX(), r.getX() + r.getWidth(), |
438 | 469 |
r.getY(), r.getY() + r.getHeight()), new Integer(index)); |
439 | 470 |
} |
440 |
|
|
441 |
// System.err.println(this.index.size()); |
|
442 | 471 |
} |
443 | 472 |
|
444 | 473 |
/** |
... | ... | |
464 | 493 |
|
465 | 494 |
IGeometry gAnt = null; |
466 | 495 |
|
496 |
//Si la geometr?a no ha sido modificada |
|
467 | 497 |
if (!relations.containsKey(integer)) { |
468 | 498 |
int expansionIndex = expansionFile.addGeometry(g); |
469 | 499 |
relations.put(integer, new Integer(expansionIndex)); |
... | ... | |
478 | 508 |
rAnt.getY() + rAnt.getHeight()), new Integer(index)); |
479 | 509 |
this.index.insert(new Envelope(r.getX(), r.getX() + r.getWidth(), |
480 | 510 |
r.getY(), r.getY() + r.getHeight()), new Integer(index)); |
481 |
|
|
482 |
//pos=expansionIndex; |
|
483 | 511 |
} else { |
512 |
//Obtenemos el ?ndice en el fichero de expansi?n |
|
484 | 513 |
int num = ((Integer) relations.get(integer)).intValue(); |
485 | 514 |
pos = num; |
515 |
//Obtenemos la geometr?a para actualiza el ?ndice espacialposteriormente |
|
486 | 516 |
gAnt = expansionFile.getGeometry(num); |
517 |
/* |
|
518 |
* Se modifica la geometr?a y nos guardamos el ?ndice dentro del fichero |
|
519 |
* de expansi?n en el que se encuentra la geometr?a modificada |
|
520 |
*/ |
|
487 | 521 |
num = expansionFile.modifyGeometry(num, g); |
522 |
/* |
|
523 |
* Actualiza la relaci?n del ?ndice de la geometr?a al ?ndice en el fichero |
|
524 |
* de expansi?n. |
|
525 |
*/ |
|
488 | 526 |
relations.put(integer, new Integer(num)); |
489 | 527 |
|
490 | 528 |
//Se modifica el ?ndice espacial |
... | ... | |
497 | 535 |
r.getY(), r.getY() + r.getHeight()), new Integer(index)); |
498 | 536 |
} |
499 | 537 |
|
500 |
// System.err.println(this.index.size()); |
|
501 | 538 |
return pos; |
502 | 539 |
} |
503 | 540 |
|
... | ... | |
510 | 547 |
* @see com.iver.cit.gvsig.fmap.edition.EditableFeatureSource#undo() |
511 | 548 |
*/ |
512 | 549 |
public void undo() throws DriverIOException, IOException { |
513 |
fbitset.clear();
|
|
550 |
seleccion.clear();
|
|
514 | 551 |
|
515 | 552 |
if (moreUndoCommands()) { |
516 | 553 |
cr.undoCommand(); |
... | ... | |
526 | 563 |
* @see com.iver.cit.gvsig.fmap.edition.EditableFeatureSource#redo() |
527 | 564 |
*/ |
528 | 565 |
public void redo() throws DriverIOException, IOException { |
529 |
fbitset.clear();
|
|
566 |
seleccion.clear();
|
|
530 | 567 |
|
531 | 568 |
if (moreRedoCommands()) { |
532 | 569 |
cr.redoCommand(); |
branches/FMap_piloto_CAD_Layout_version/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/VectorialFileAdapter.java | ||
---|---|---|
170 | 170 |
return (Rectangle2D)getFileDriver().getFullExtent().clone(); |
171 | 171 |
} catch (IOException e) { |
172 | 172 |
throw new DriverIOException(e); |
173 |
} catch (NullPointerException e) { |
|
174 |
return new Rectangle2D.Double(0,0,500,500); |
|
173 | 175 |
} |
174 | 176 |
} |
175 | 177 |
|
branches/FMap_piloto_CAD_Layout_version/libraries/libFMap/src/com/iver/cit/gvsig/fmap/tools/Behavior/RectangleBehavior.java | ||
---|---|---|
86 | 86 |
g.drawImage(img, 0, 0, null); |
87 | 87 |
g.setColor(Color.black); |
88 | 88 |
g.setXORMode(Color.white); |
89 |
|
|
89 |
|
|
90 | 90 |
// Borramos el anterior |
91 | 91 |
Rectangle r = new Rectangle(); |
92 |
|
|
93 | 92 |
// Dibujamos el actual |
94 | 93 |
if ((m_FirstPoint != null) && (m_LastPoint != null)) { |
94 |
super.paintComponent(g); |
|
95 | 95 |
r.setFrameFromDiagonal(m_FirstPoint, m_LastPoint); |
96 | 96 |
g.drawRect(r.x, r.y, r.width, r.height); |
97 |
}else{ |
|
98 |
super.paintComponent(g); |
|
97 | 99 |
} |
98 | 100 |
} |
99 | 101 |
|
... | ... | |
132 | 134 |
Point pScreen = e.getPoint(); |
133 | 135 |
|
134 | 136 |
ViewPort vp = getMapControl().getMapContext().getViewPort(); |
135 |
|
|
137 |
if (m_FirstPoint!=null){ |
|
136 | 138 |
p1 = vp.toMapPoint(m_FirstPoint); |
137 | 139 |
p2 = vp.toMapPoint(pScreen); |
138 | 140 |
|
... | ... | |
147 | 149 |
RectangleEvent event = new RectangleEvent(r, e, rectPixel); |
148 | 150 |
listener.rectangle(event); |
149 | 151 |
} |
150 |
|
|
152 |
} |
|
151 | 153 |
m_FirstPoint = null; |
152 | 154 |
m_LastPoint = null; |
153 | 155 |
} |
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/LayoutRedoExtension.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 com.iver.andami.PluginServices; |
|
44 |
import com.iver.andami.plugins.Extension; |
|
45 |
import com.iver.andami.ui.mdiManager.View; |
|
46 |
|
|
47 |
import com.iver.cit.gvsig.fmap.FMap; |
|
48 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
|
49 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
50 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.EditableVectorialLayer; |
|
51 |
import com.iver.cit.gvsig.gui.cad.CadMapControl; |
|
52 |
import com.iver.cit.gvsig.gui.layout.Layout; |
|
53 |
import com.iver.cit.gvsig.project.ProjectView; |
|
54 |
|
|
55 |
import java.io.IOException; |
|
56 |
|
|
57 |
|
|
58 |
/** |
|
59 |
* DOCUMENT ME! |
|
60 |
* |
|
61 |
* @author Vicente Caballero Navarro |
|
62 |
*/ |
|
63 |
public class LayoutRedoExtension implements Extension { |
|
64 |
/** |
|
65 |
* @see com.iver.andami.plugins.Extension#inicializar() |
|
66 |
*/ |
|
67 |
public void inicializar() { |
|
68 |
} |
|
69 |
|
|
70 |
/** |
|
71 |
* @see com.iver.andami.plugins.Extension#execute(java.lang.String) |
|
72 |
*/ |
|
73 |
public void execute(String actionCommand) { |
|
74 |
Layout l = (Layout) PluginServices.getMDIManager().getActiveView(); |
|
75 |
|
|
76 |
try { |
|
77 |
l.getCadToolAdapter().getEditableFeatureSource().redo(); |
|
78 |
} catch (DriverIOException e) { |
|
79 |
e.printStackTrace(); |
|
80 |
} catch (IOException e) { |
|
81 |
e.printStackTrace(); |
|
82 |
} |
|
83 |
|
|
84 |
l.refresh(); |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* @see com.iver.andami.plugins.Extension#isEnabled() |
|
89 |
*/ |
|
90 |
public boolean isEnabled() { |
|
91 |
Layout layout = (Layout) PluginServices.getMDIManager().getActiveView(); |
|
92 |
|
|
93 |
return layout.getCadToolAdapter().getEditableFeatureSource() |
|
94 |
.moreRedoCommands(); |
|
95 |
} |
|
96 |
|
|
97 |
/** |
|
98 |
* @see com.iver.andami.plugins.Extension#isVisible() |
|
99 |
*/ |
|
100 |
public boolean isVisible() { |
|
101 |
View f = PluginServices.getMDIManager().getActiveView(); |
|
102 |
|
|
103 |
if (f == null) { |
|
104 |
return false; |
|
105 |
} |
|
106 |
|
|
107 |
if (f.getClass() == Layout.class) { |
|
108 |
Layout layout = (Layout) f; |
|
109 |
|
|
110 |
return true; //layout.m_Display.getMapControl().getMapContext().getLayers().layerCount() > 0; |
|
111 |
} else { |
|
112 |
return false; |
|
113 |
} |
|
114 |
} |
|
115 |
} |
|
0 | 116 |
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/StopEditing.java | ||
---|---|---|
46 | 46 |
|
47 | 47 |
import com.iver.andami.PluginServices; |
48 | 48 |
import com.iver.andami.plugins.Extension; |
49 |
|
|
50 | 49 |
import com.iver.cit.gvsig.fmap.FMap; |
51 | 50 |
import com.iver.cit.gvsig.fmap.edition.EditionException; |
52 | 51 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
... | ... | |
100 | 99 |
} |
101 | 100 |
} |
102 | 101 |
} |
103 |
|
|
104 |
/** |
|
102 |
/** |
|
105 | 103 |
* @see com.iver.andami.plugins.Extension#isEnabled() |
106 | 104 |
*/ |
107 | 105 |
public boolean isEnabled() { |
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/LayoutUndoExtension.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 com.iver.andami.PluginServices; |
|
44 |
import com.iver.andami.plugins.Extension; |
|
45 |
import com.iver.andami.ui.mdiManager.View; |
|
46 |
|
|
47 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
|
48 |
import com.iver.cit.gvsig.gui.layout.Layout; |
|
49 |
|
|
50 |
import java.io.IOException; |
|
51 |
|
|
52 |
|
|
53 |
/** |
|
54 |
* DOCUMENT ME! |
|
55 |
* |
|
56 |
* @author Vicente Caballero Navarro |
|
57 |
*/ |
|
58 |
public class LayoutUndoExtension implements Extension { |
|
59 |
/** |
|
60 |
* @see com.iver.andami.plugins.Extension#inicializar() |
|
61 |
*/ |
|
62 |
public void inicializar() { |
|
63 |
} |
|
64 |
|
|
65 |
/** |
|
66 |
* @see com.iver.andami.plugins.Extension#execute(java.lang.String) |
|
67 |
*/ |
|
68 |
public void execute(String actionCommand) { |
|
69 |
Layout l = (Layout) PluginServices.getMDIManager().getActiveView(); |
|
70 |
|
|
71 |
try { |
|
72 |
l.getCadToolAdapter().getEditableFeatureSource().undo(); |
|
73 |
} catch (DriverIOException e) { |
|
74 |
e.printStackTrace(); |
|
75 |
} catch (IOException e) { |
|
76 |
e.printStackTrace(); |
|
77 |
} |
|
78 |
l.refresh(); |
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* @see com.iver.andami.plugins.Extension#isEnabled() |
|
83 |
*/ |
|
84 |
public boolean isEnabled() { |
|
85 |
Layout layout = (Layout) PluginServices.getMDIManager().getActiveView(); |
|
86 |
|
|
87 |
return layout.getCadToolAdapter().getEditableFeatureSource() |
|
88 |
.moreUndoCommands(); |
|
89 |
} |
|
90 |
|
|
91 |
/** |
|
92 |
* @see com.iver.andami.plugins.Extension#isVisible() |
|
93 |
*/ |
|
94 |
public boolean isVisible() { |
|
95 |
View f = PluginServices.getMDIManager().getActiveView(); |
|
96 |
|
|
97 |
if (f == null) { |
|
98 |
return false; |
|
99 |
} |
|
100 |
|
|
101 |
if (f.getClass() == Layout.class) { |
|
102 |
Layout layout = (Layout) f; |
|
103 |
|
|
104 |
return true; //layout.m_Display.getMapControl().getMapContext().getLayers().layerCount() > 0; |
|
105 |
} else { |
|
106 |
return false; |
|
107 |
} |
|
108 |
} |
|
109 |
} |
|
0 | 110 |
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/StartEditing.java | ||
---|---|---|
71 | 71 |
* @see com.iver.andami.plugins.Extension#execute(java.lang.String) |
72 | 72 |
*/ |
73 | 73 |
public void execute(String actionCommand) { |
74 |
|
|
74 | 75 |
com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager() |
75 | 76 |
.getActiveView(); |
76 | 77 |
|
... | ... | |
78 | 79 |
View vista = (View) f; |
79 | 80 |
ProjectView model = vista.getModel(); |
80 | 81 |
FMap mapa = model.getMapContext(); |
81 |
final EditableVectorialLayer capa = (EditableVectorialLayer) mapa.getLayers().getActives()[0];
|
|
82 |
PluginServices.backgroundExecution(new Runnable() {
|
|
83 |
public void run() {
|
|
84 |
try {
|
|
85 |
capa.startEdition();
|
|
86 |
} catch (EditionException e) {
|
|
87 |
e.printStackTrace();
|
|
88 |
}
|
|
89 |
}
|
|
90 |
});
|
|
82 |
EditableVectorialLayer capa = (EditableVectorialLayer) mapa.getLayers().getActives()[0]; |
|
83 |
PluginServices.getMDIManager().setWaitCursor();
|
|
84 |
try {
|
|
85 |
capa.startEdition();
|
|
86 |
} catch (EditionException e) {
|
|
87 |
// TODO Auto-generated catch block
|
|
88 |
e.printStackTrace(); |
|
89 |
} |
|
90 |
PluginServices.getMDIManager().restoreCursor();
|
|
91 |
vista.getMapControl().getMapControl().drawMap(false);
|
|
91 | 92 |
} |
92 | 93 |
} |
93 | 94 |
|
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/LayoutControls.java | ||
---|---|---|
54 | 54 |
import com.iver.cit.gvsig.fmap.edition.EditionException; |
55 | 55 |
import com.iver.cit.gvsig.gui.layout.FLayoutZooms; |
56 | 56 |
import com.iver.cit.gvsig.gui.layout.Layout; |
57 |
import com.iver.cit.gvsig.gui.layout.fframes.IFFrame; |
|
57 | 58 |
|
58 | 59 |
import org.apache.log4j.Logger; |
59 | 60 |
|
... | ... | |
94 | 95 |
layout.setTool(Layout.RECTANGLETEXT); |
95 | 96 |
} else if (s.compareTo("SELECT") == 0) { |
96 | 97 |
layout.setTool(Layout.SELECT); |
98 |
} else if (s.compareTo("CADSELECT") == 0) { |
|
99 |
layout.setCadTool("selection"); |
|
100 |
for (int i=0;i<layout.getFFrames().size();i++){ |
|
101 |
((IFFrame)layout.getFFrames().get(i)).setSelected(false); |
|
102 |
} |
|
97 | 103 |
} else if (s.compareTo("POINT") == 0) { |
98 | 104 |
layout.setCadTool("point"); |
99 | 105 |
} else if (s.compareTo("LINE") == 0) { |
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/cad/tools/ExploitCadTool.java | ||
---|---|---|
143 | 143 |
public Automaton getAutomaton() { |
144 | 144 |
return exploitStatus; |
145 | 145 |
} |
146 |
|
|
147 |
/** |
|
148 |
* @see com.iver.cit.gvsig.gui.cad.CadTool#getName() |
|
149 |
*/ |
|
150 |
public String getName() { |
|
151 |
return "EXPLOTAR"; |
|
152 |
} |
|
146 | 153 |
} |
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/cad/tools/SelectionCadTool.java | ||
---|---|---|
76 | 76 |
public class SelectionCadTool extends AbstractCadTool { |
77 | 77 |
private static Status[] STATUS = { |
78 | 78 |
new Status(""), new Status(""), |
79 |
new Status("Siguiente punto del rect?ngulo de selecci?n"),
|
|
79 |
new Status("Precise punto del rect?ngulo de selecci?n"),
|
|
80 | 80 |
new Status(""), new Status("Precise punto de estiramiento"), |
81 | 81 |
}; |
82 | 82 |
public final static int tolerance = 5; |
... | ... | |
125 | 125 |
.getHandlers(FGeometry.SELECTHANDLER); |
126 | 126 |
|
127 | 127 |
IGeometry clonedGeometry = null; |
128 |
|
|
128 |
|
|
129 | 129 |
for (int j = 0; j < handlers.length; j++) { |
130 | 130 |
Point2D handlerPoint = handlers[j].getPoint(); |
131 | 131 |
|
... | ... | |
239 | 239 |
x, y, w, h)); |
240 | 240 |
|
241 | 241 |
for (int i = 0; i < indexes.length; i++) { |
242 |
if (firstPoint.getX()<lastPoint.getX()){ |
|
242 | 243 |
if (rect.contains(editingSource.getGeometry(indexes[i]) |
243 | 244 |
.getBounds2D())) { |
244 | 245 |
selectedGeometries.set(indexes[i], true); |
245 | 246 |
} |
247 |
}else{ |
|
248 |
if (editingSource.getGeometry(indexes[i]).intersects(rect)){ |
|
249 |
selectedGeometries.set(indexes[i], true); |
|
250 |
} |
|
246 | 251 |
} |
252 |
} |
|
247 | 253 |
} catch (DriverIOException e) { |
248 | 254 |
e.printStackTrace(); |
249 | 255 |
} catch (IOException e) { |
... | ... | |
301 | 307 |
elShape.lineTo(x, y); |
302 | 308 |
elShape.lineTo(firstPoint.getX(), y); |
303 | 309 |
elShape.lineTo(firstPoint.getX(), firstPoint.getY()); |
304 |
ShapeFactory.createPolyline2D(elShape).draw((Graphics2D) g, |
|
305 |
getAT(), |
|
306 |
CadTool.selectSymbol); |
|
310 |
ShapeFactory.createPolyline2D(elShape).draw((Graphics2D) g,
|
|
311 |
getAT(),
|
|
312 |
CadTool.selectSymbol);
|
|
307 | 313 |
} else if (status == 4) { |
308 | 314 |
for (int i = 0; i < selectedGeometry.size(); i++) { |
309 | 315 |
Handler h = (Handler) selectedHandler.get(i); |
... | ... | |
337 | 343 |
public Automaton getAutomaton() { |
338 | 344 |
return selectionStatus; |
339 | 345 |
} |
346 |
|
|
347 |
/** |
|
348 |
* @see com.iver.cit.gvsig.gui.cad.CadTool#getName() |
|
349 |
*/ |
|
350 |
public String getName() { |
|
351 |
return "SELECCI?N"; |
|
352 |
} |
|
340 | 353 |
} |
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/cad/tools/LineCadTool.java | ||
---|---|---|
172 | 172 |
|
173 | 173 |
if ((status == 1) || (status == 5)) { |
174 | 174 |
drawLine((Graphics2D) g, firstPoint, new Point2D.Double(x, y)); |
175 |
System.err.println("angulo: " + |
|
175 |
/*System.err.println("angulo: " +
|
|
176 | 176 |
TrigonometricalFunctions.getAngle(firstPoint, |
177 |
new Point2D.Double(x, y))); |
|
177 |
new Point2D.Double(x, y)));*/
|
|
178 | 178 |
} else if (status == 2) { |
179 | 179 |
length = firstPoint.distance(x, y); |
180 | 180 |
|
... | ... | |
208 | 208 |
public Automaton getAutomaton() { |
209 | 209 |
return lineStatus; |
210 | 210 |
} |
211 |
|
|
212 |
/** |
|
213 |
* @see com.iver.cit.gvsig.gui.cad.CadTool#getName() |
|
214 |
*/ |
|
215 |
public String getName() { |
|
216 |
return "L?NEA"; |
|
217 |
} |
|
211 | 218 |
} |
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/cad/tools/PolygonCadTool.java | ||
---|---|---|
69 | 69 |
*/ |
70 | 70 |
public class PolygonCadTool extends AbstractCadTool { |
71 | 71 |
private static Status[] STATUS = { |
72 |
new Status("Indique n?mero de lados"), |
|
72 |
new Status("Indique n?mero de lados[5]"),
|
|
73 | 73 |
new Status("Precise centro del pol?gono"), |
74 | 74 |
new Status("Inscrito en el c?rculo[I] o Circunscrito[C]"), |
75 |
new Status("Precise r?dio"), new Status("Precise r?dio") |
|
75 |
new Status("Precise r?dio"), |
|
76 |
new Status(""), |
|
77 |
new Status(""), |
|
78 |
new Status(""), |
|
79 |
new Status("Precise centro del pol?gono") |
|
80 |
|
|
76 | 81 |
}; |
77 | 82 |
private Poligono polygonStatus = new Poligono(); |
78 | 83 |
private int numLines = 4; |
... | ... | |
138 | 143 |
} |
139 | 144 |
|
140 | 145 |
ret = ret | polygonStatus.transition("cancel"); |
146 |
}else if (status==7){ |
|
147 |
numLines = 5; |
|
141 | 148 |
} |
142 | 149 |
|
143 | 150 |
return ret; |
... | ... | |
269 | 276 |
public Automaton getAutomaton() { |
270 | 277 |
return polygonStatus; |
271 | 278 |
} |
279 |
|
|
280 |
/** |
|
281 |
* @see com.iver.cit.gvsig.gui.cad.CadTool#getName() |
|
282 |
*/ |
|
283 |
public String getName() { |
|
284 |
return "POL?GONO"; |
|
285 |
} |
|
272 | 286 |
} |
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/cad/tools/ScaleCadTool.java | ||
---|---|---|
67 | 67 |
public class ScaleCadTool extends AbstractCadTool { |
68 | 68 |
private static Status[] STATUS = { |
69 | 69 |
new Status("Precise punto base"), |
70 |
new Status("Precise factor de escala"), |
|
70 |
new Status("Precise factor de escala[2]"),
|
|
71 | 71 |
}; |
72 | 72 |
private Escalar scaleStatus = new Escalar(); |
73 | 73 |
private Point2D firstPoint; |
... | ... | |
140 | 140 |
} |
141 | 141 |
|
142 | 142 |
ret = ret | scaleStatus.transition("cancel"); |
143 |
}else if (status == 4) { |
|
144 |
try { |
|
145 |
for (int i = 0; i < editingSource.getGeometryCount(); i++) { |
|
146 |
if (selectedGeometries.get(i)) { |
|
147 |
IGeometry geometry = editingSource.getGeometry(i); |
|
148 |
geometry.scale(firstPoint, 2, 2); |
|
149 |
editingSource.modifyGeometry(i, geometry); |
|
150 |
} |
|
151 |
} |
|
152 |
} catch (DriverIOException e) { |
|
153 |
e.printStackTrace(); |
|
154 |
} catch (IOException e1) { |
|
155 |
e1.printStackTrace(); |
|
156 |
} |
|
157 |
|
|
158 |
ret = ret | scaleStatus.transition("cancel"); |
|
143 | 159 |
} |
144 | 160 |
|
161 |
|
|
145 | 162 |
return ret; |
146 | 163 |
} |
147 | 164 |
|
... | ... | |
204 | 221 |
public Automaton getAutomaton() { |
205 | 222 |
return scaleStatus; |
206 | 223 |
} |
224 |
|
|
225 |
/** |
|
226 |
* @see com.iver.cit.gvsig.gui.cad.CadTool#getName() |
|
227 |
*/ |
|
228 |
public String getName() { |
|
229 |
return "ESCALAR"; |
|
230 |
} |
|
207 | 231 |
} |
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/cad/tools/SymmetryCadTool.java | ||
---|---|---|
238 | 238 |
public Automaton getAutomaton() { |
239 | 239 |
return symmetryStatus; |
240 | 240 |
} |
241 |
|
|
242 |
/** |
|
243 |
* @see com.iver.cit.gvsig.gui.cad.CadTool#getName() |
|
244 |
*/ |
|
245 |
public String getName() { |
|
246 |
return "SIMETR?A"; |
|
247 |
} |
|
241 | 248 |
} |
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/cad/tools/PointCadTool.java | ||
---|---|---|
62 | 62 |
* @author Vicente Caballero Navarro |
63 | 63 |
*/ |
64 | 64 |
public class PointCadTool extends AbstractCadTool { |
65 |
private static Status[] STATUS = { new Status("Precise un punto"),new Status("Precise un punto") }; |
|
65 |
private static Status[] STATUS = { |
|
66 |
new Status("Precise un punto"), |
|
67 |
new Status("Precise un punto") }; |
|
66 | 68 |
private Punto pointStatus = new Punto(); |
67 | 69 |
|
68 | 70 |
/** |
... | ... | |
122 | 124 |
public Automaton getAutomaton() { |
123 | 125 |
return pointStatus; |
124 | 126 |
} |
127 |
|
|
128 |
/** |
|
129 |
* @see com.iver.cit.gvsig.gui.cad.CadTool#getName() |
|
130 |
*/ |
|
131 |
public String getName() { |
|
132 |
return "PUNTO"; |
|
133 |
} |
|
125 | 134 |
|
126 | 135 |
|
127 | 136 |
} |
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/cad/tools/SplineCadTool.java | ||
---|---|---|
217 | 217 |
else if (i == 2) return 3 * t * t * (1 - t); |
218 | 218 |
else return t * t * t; |
219 | 219 |
} |
220 |
|
|
221 |
/** |
|
222 |
* @see com.iver.cit.gvsig.gui.cad.CadTool#getName() |
|
223 |
*/ |
|
224 |
public String getName() { |
|
225 |
return "SPLINE"; |
|
226 |
} |
|
220 | 227 |
|
221 | 228 |
|
222 | 229 |
|
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/cad/tools/PolyLineCadTool.java | ||
---|---|---|
302 | 302 |
if (status == 1) { |
303 | 303 |
for (int i = 0; i < list.size(); i++) { |
304 | 304 |
((IGeometry) list.get(i)).cloneGeometry().draw((Graphics2D) g, |
305 |
getAT(),
|
|
306 |
CadTool.modifySymbol);
|
|
305 |
getAT(), |
|
306 |
CadTool.modifySymbol); |
|
307 | 307 |
} |
308 | 308 |
|
309 | 309 |
drawLine((Graphics2D) g, antPoint, new Point2D.Double(x, y)); |
310 | 310 |
} else if ((status == 2) || (status == 3)) { |
311 | 311 |
for (int i = 0; i < list.size(); i++) { |
312 | 312 |
((IGeometry) list.get(i)).cloneGeometry().draw((Graphics2D) g, |
313 |
getAT(),
|
|
314 |
CadTool.modifySymbol);
|
|
313 |
getAT(), |
|
314 |
CadTool.modifySymbol); |
|
315 | 315 |
} |
316 | 316 |
|
317 | 317 |
Point2D point = new Point2D.Double(x, y); |
... | ... | |
429 | 429 |
|
430 | 430 |
if (ig != null) { |
431 | 431 |
ig.draw((Graphics2D) g, |
432 |
getAT(),
|
|
433 |
CadTool.modifySymbol);
|
|
432 |
getAT(), |
|
433 |
CadTool.modifySymbol); |
|
434 | 434 |
} |
435 | 435 |
} |
436 | 436 |
} |
... | ... | |
441 | 441 |
public Automaton getAutomaton() { |
442 | 442 |
return polylineStatus; |
443 | 443 |
} |
444 |
|
|
445 |
/** |
|
446 |
* @see com.iver.cit.gvsig.gui.cad.CadTool#getName() |
|
447 |
*/ |
|
448 |
public String getName() { |
|
449 |
return "POLIL?NEA"; |
|
450 |
} |
|
444 | 451 |
} |
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/cad/tools/EllipseCadTool.java | ||
---|---|---|
183 | 183 |
public Automaton getAutomaton() { |
184 | 184 |
return ellipseStatus; |
185 | 185 |
} |
186 |
|
|
187 |
/** |
|
188 |
* @see com.iver.cit.gvsig.gui.cad.CadTool#getName() |
|
189 |
*/ |
|
190 |
public String getName() { |
|
191 |
return "ELIPSE"; |
|
192 |
} |
|
186 | 193 |
} |
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/cad/tools/RotateCadTool.java | ||
---|---|---|
221 | 221 |
public Automaton getAutomaton() { |
222 | 222 |
return rotateStatus; |
223 | 223 |
} |
224 |
|
|
225 |
/** |
|
226 |
* @see com.iver.cit.gvsig.gui.cad.CadTool#getName() |
|
227 |
*/ |
|
228 |
public String getName() { |
|
229 |
return "GIRAR"; |
|
230 |
} |
|
224 | 231 |
} |
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/cad/tools/CircleCadTool.java | ||
---|---|---|
40 | 40 |
*/ |
41 | 41 |
package com.iver.cit.gvsig.gui.cad.tools; |
42 | 42 |
|
43 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
43 | 44 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
44 | 45 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
45 | 46 |
import com.iver.cit.gvsig.fmap.edition.EditableFeatureSource; |
... | ... | |
99 | 100 |
p2 = new Point2D.Double(values[0], values[1]); |
100 | 101 |
} else if (status == 5) { |
101 | 102 |
p3 = new Point2D.Double(values[0], values[1]); |
102 |
center = TrigonometricalFunctions.getCircleCenter(p1, p2, p3); |
|
103 |
//center = TrigonometricalFunctions.getCenter(p1, p2, p3); |
|
104 |
//if (center!=null){ |
|
105 |
// double radio = center.distance(p1); |
|
103 | 106 |
|
104 |
double radio = center.distance(p1); |
|
105 |
|
|
106 | 107 |
try { |
107 |
editingSource.addGeometry(ShapeFactory.createCircle(center, |
|
108 |
radio)); |
|
108 |
IGeometry geom=ShapeFactory.createCircle(p1,p2,p3); |
|
109 |
if (geom!=null){ |
|
110 |
editingSource.addGeometry(geom); |
|
111 |
} |
|
109 | 112 |
} catch (DriverIOException e) { |
110 | 113 |
e.printStackTrace(); |
111 | 114 |
} catch (IOException e) { |
112 | 115 |
e.printStackTrace(); |
113 | 116 |
} |
114 |
|
|
117 |
// } |
|
115 | 118 |
ret = ret | circleStatus.transition("cancel"); |
116 | 119 |
} else if (status == 6) { |
117 | 120 |
try { |
... | ... | |
151 | 154 |
|
152 | 155 |
if (status == 1) { |
153 | 156 |
Point2D currentPoint = new Point2D.Double(x, y); |
154 |
double dist = currentPoint.distance(center); |
|
155 |
ShapeFactory.createCircle(center, dist).draw((Graphics2D) g, |
|
156 |
getAT(), |
|
157 |
CadTool.modifySymbol); |
|
157 |
ShapeFactory.createCircle(center,currentPoint).draw((Graphics2D) g, |
|
158 |
getAT(), |
|
159 |
CadTool.modifySymbol); |
|
158 | 160 |
} else if (status == 2) { |
159 | 161 |
} else if (status == 3) { |
160 | 162 |
drawLine((Graphics2D) g, p1, new Point2D.Double(x, y)); |
161 | 163 |
} else if (status == 4) { |
162 | 164 |
Point2D currentPoint = new Point2D.Double(x, y); |
163 |
|
|
164 |
if (p1.getX() == p2.getX()) { |
|
165 |
p2 = new Point2D.Double(p2.getX() + 0.0000001, p2.getY()); |
|
166 |
} else if (p1.getY() == p2.getY()) { |
|
167 |
p2 = new Point2D.Double(p2.getX(), p2.getY() + 0.0000001); |
|
168 |
} /*if (currentPoint.getX()==p1.getX()){ |
|
169 |
currentPoint=new Point2D.Double(currentPoint.getX()+0.0000001,currentPoint.getY()); |
|
170 |
}else if (currentPoint.getY()==p1.getY()){ |
|
171 |
currentPoint=new Point2D.Double(currentPoint.getX(),currentPoint.getY()+0.0000001); |
|
172 |
}if (currentPoint.getX()==p2.getX()){ |
|
173 |
currentPoint=new Point2D.Double(currentPoint.getX()+0.0000001,currentPoint.getY()); |
|
174 |
}else if (currentPoint.getY()==p2.getY()){ |
|
175 |
currentPoint=new Point2D.Double(currentPoint.getX(),currentPoint.getY()+0.0000001); |
|
176 |
}*/ |
|
177 |
Point2D currentCenter = TrigonometricalFunctions.getCircleCenter(p1, |
|
178 |
p2, currentPoint); |
|
179 |
double radio = currentCenter.distance(p1); |
|
180 |
ShapeFactory.createCircle(currentCenter, radio).draw((Graphics2D) g, |
|
165 |
//System.out.println("p2 = "+p2); |
|
166 |
//System.out.println("currentPoint = "+currentPoint); |
|
167 |
IGeometry geom=ShapeFactory.createCircle(p1,p2,currentPoint); |
|
168 |
if (geom!=null){ |
|
169 |
geom.draw((Graphics2D) g, |
|
181 | 170 |
getAT(), |
182 | 171 |
CadTool.modifySymbol); |
172 |
} |
|
183 | 173 |
} |
174 |
|
|
184 | 175 |
} |
185 | 176 |
|
186 | 177 |
/** |
... | ... | |
203 | 194 |
public Automaton getAutomaton() { |
204 | 195 |
return circleStatus; |
205 | 196 |
} |
197 |
|
|
198 |
/** |
|
199 |
* @see com.iver.cit.gvsig.gui.cad.CadTool#getName() |
|
200 |
*/ |
|
201 |
public String getName() { |
|
202 |
return "C?RCULO"; |
|
203 |
} |
|
206 | 204 |
} |
branches/gvSIG_CAD_Layout_version/applications/appgvSIG/src/com/iver/cit/gvsig/gui/cad/tools/RectangleCadTool.java | ||
---|---|---|
106 | 106 |
lastPoint = new Point2D.Double(values[0], values[1]); |
107 | 107 |
} |
108 | 108 |
|
109 |
/*GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, |
|
110 |
4); |
|
111 |
elShape.moveTo(firstPoint.getX(), firstPoint.getY()); |
|
112 |
elShape.lineTo(lastPoint.getX(), firstPoint.getY()); |
|
113 |
elShape.lineTo(lastPoint.getX(), lastPoint.getY()); |
|
114 |
elShape.lineTo(firstPoint.getX(), lastPoint.getY()); |
|
115 |
elShape.lineTo(firstPoint.getX(), firstPoint.getY()); |
|
116 |
editingSource.addGeometry(ShapeFactory.createPolyline2D( |
|
117 |
elShape)); |
|
118 |
*/ |
|
109 | 119 |
GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, |
110 | 120 |
2); |
111 | 121 |
elShape.moveTo(firstPoint.getX(), firstPoint.getY()); |
... | ... | |
238 | 248 |
firstPoint.getY() - (x - firstPoint.getX())); |
239 | 249 |
elShape.lineTo(firstPoint.getX(), firstPoint.getY()); |
240 | 250 |
ShapeFactory.createPolyline2D(elShape).draw((Graphics2D) g, |
241 |
getAT(),
|
|
242 |
CadTool.modifySymbol);
|
|
251 |
getAT(), |
|
252 |
CadTool.modifySymbol); |
|
243 | 253 |
} |
244 | 254 |
} |
245 | 255 |
|
Also available in: Unified diff