root / branches / pilotoDWG / applications / appgvSIG / src / com / iver / cit / gvsig / gui / cad / tools / ExploitCadTool.java @ 1634
History | View | Annotate | Download (4.02 KB)
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.gui.cad.tools; |
42 |
|
43 |
import com.iver.cit.gvsig.fmap.core.FGeometryCollection; |
44 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
45 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
46 |
import com.iver.cit.gvsig.fmap.edition.EditableFeatureSource; |
47 |
import com.iver.cit.gvsig.fmap.edition.cad.Status; |
48 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
49 |
import com.iver.cit.gvsig.gui.cad.automaton.Explotar; |
50 |
|
51 |
import com.iver.fsac.Automaton; |
52 |
|
53 |
import java.awt.Graphics; |
54 |
|
55 |
import java.io.IOException; |
56 |
|
57 |
|
58 |
/**
|
59 |
* Elimina la geometr?a compuesta y a?ade todas la geometr?as simples que la
|
60 |
* componen.
|
61 |
*
|
62 |
* @author Vicente Caballero Navarro
|
63 |
*/
|
64 |
public class ExploitCadTool extends AbstractCadTool { |
65 |
private static Status[] STATUS = { new Status("") }; |
66 |
private Explotar exploitStatus = new Explotar(); |
67 |
|
68 |
/**
|
69 |
* @see com.iver.cit.gvsig.gui.cad.CadTool#transition(java.lang.String,
|
70 |
* com.iver.cit.gvsig.fmap.edition.EditableFeatureSource,
|
71 |
* com.iver.cit.gvsig.fmap.layers.FBitSet, double[])
|
72 |
*/
|
73 |
public int transition(String text, EditableFeatureSource editingSource, |
74 |
FBitSet selectedGeometries, double[] ds) { |
75 |
int ret = exploitStatus.transition(text);
|
76 |
int status = exploitStatus.getStatus();
|
77 |
|
78 |
if (status == 0) { |
79 |
if (selectedGeometries.cardinality() == 0) { |
80 |
getCadToolAdapter().pushCadTool(new SelectionCadTool());
|
81 |
} |
82 |
|
83 |
for (int i = selectedGeometries.nextSetBit(0); i >= 0; |
84 |
i = selectedGeometries.nextSetBit(i + 1)) {
|
85 |
IGeometry geom = null;
|
86 |
|
87 |
try {
|
88 |
geom = editingSource.getGeometry(i); |
89 |
|
90 |
if (geom instanceof FGeometryCollection) { |
91 |
IGeometry[] geoms = ((FGeometryCollection) geom).getGeometries();
|
92 |
editingSource.removeGeometry(i); |
93 |
|
94 |
for (int j = 0; j < geoms.length; j++) { |
95 |
editingSource.addGeometry(geoms[j]); |
96 |
} |
97 |
} |
98 |
} catch (IOException e) { |
99 |
e.printStackTrace(); |
100 |
} catch (DriverIOException e) {
|
101 |
e.printStackTrace(); |
102 |
} |
103 |
} |
104 |
|
105 |
ret = ret | exploitStatus.transition("cancel");
|
106 |
selectedGeometries.clear(); |
107 |
} else if (status == 1) { |
108 |
} |
109 |
|
110 |
return ret;
|
111 |
} |
112 |
|
113 |
/**
|
114 |
* @see com.iver.cit.gvsig.gui.cad.CadTool#drawOperation(java.awt.Graphics,
|
115 |
* com.iver.cit.gvsig.fmap.edition.EditableFeatureSource,
|
116 |
* com.iver.cit.gvsig.fmap.layers.FBitSet, double, double)
|
117 |
*/
|
118 |
public void drawOperation(Graphics g, EditableFeatureSource efs, |
119 |
FBitSet selectedGeometries, double x, double y) { |
120 |
} |
121 |
|
122 |
/**
|
123 |
* @see com.iver.cit.gvsig.gui.cad.CadTool#getQuestion()
|
124 |
*/
|
125 |
public String getQuestion() { |
126 |
if (exploitStatus.getStatus() == -1) { |
127 |
return ""; |
128 |
} |
129 |
|
130 |
return STATUS[exploitStatus.getStatus()].getQuestion();
|
131 |
} |
132 |
|
133 |
/**
|
134 |
* @see com.iver.cit.gvsig.gui.cad.CadTool#initializeStatus()
|
135 |
*/
|
136 |
public void initializeStatus() { |
137 |
exploitStatus.initialize(); |
138 |
} |
139 |
|
140 |
/**
|
141 |
* @see com.iver.cit.gvsig.gui.cad.CadTool#getAutomaton()
|
142 |
*/
|
143 |
public Automaton getAutomaton() {
|
144 |
return exploitStatus;
|
145 |
} |
146 |
} |