Revision 1525
branches/pilotoDWG/applications/appgvSIG/src/com/iver/cit/gvsig/gui/cad/CADToolAdapter.java | ||
---|---|---|
65 | 65 |
private int lastY; |
66 | 66 |
private FSymbol symbol = new FSymbol(FConstant.SYMBOL_TYPE_POINT, Color.RED); |
67 | 67 |
private JConsole console; |
68 |
private boolean grid = true;
|
|
69 |
private int gridSize = 30;
|
|
68 |
private boolean grid = false;
|
|
69 |
private int gridSize = 20;
|
|
70 | 70 |
private Point gridPoint; |
71 | 71 |
private CadMapControl cadMapControl; |
72 | 72 |
private boolean questionAsked = false; |
... | ... | |
96 | 96 |
} |
97 | 97 |
*/ |
98 | 98 |
drawGrid(g); |
99 |
if (gridPoint != null){ |
|
100 |
//g.drawLine(gridPoint.x, gridPoint.y, lastX, lastY); |
|
101 |
//g.drawRect(gridPoint.x-5, gridPoint.y-5, 5, 5); |
|
102 |
drawCursor(g); |
|
103 |
} |
|
99 |
drawCursor(g); |
|
104 | 100 |
Point2D p = getMapControl().getViewPort().toMapPoint((int) gridPoint.getX(), (int) gridPoint.getY()); |
105 | 101 |
((CadTool)cadToolStack.peek()).drawOperation(g, editableFeatureSource,selection,p.getX(), p.getY()); |
106 | 102 |
} |
... | ... | |
206 | 202 |
g.drawRect((int)(p.getX()-size2),(int)(p.getY()-size2),(int)(size2*2),(int)(size2*2)); |
207 | 203 |
} |
208 | 204 |
private void drawGrid(Graphics g){ |
205 |
if (!grid)return; |
|
209 | 206 |
for (int x=0;x<cadMapControl.getWidth();x+=gridSize){ |
210 | 207 |
for (int y=0;y<cadMapControl.getHeight();y+=gridSize){ |
211 | 208 |
g.drawOval(x,y,1,1); |
... | ... | |
222 | 219 |
if (minDistance < Double.MAX_VALUE){ |
223 | 220 |
gridPoint = point; |
224 | 221 |
}else{ |
225 |
gridPoint = null;
|
|
222 |
gridPoint = point;
|
|
226 | 223 |
} |
227 | 224 |
} |
228 | 225 |
|
branches/pilotoDWG/applications/appgvSIG/src/com/iver/cit/gvsig/gui/cad/automaton/Seleccion.java | ||
---|---|---|
35 | 35 |
|
36 | 36 |
case 1: |
37 | 37 |
|
38 |
if ("punto".equalsIgnoreCase(label)){
|
|
38 |
if ("no_sel".equalsIgnoreCase(label)){
|
|
39 | 39 |
previousStatus = status; |
40 | 40 |
status = 2; |
41 | 41 |
|
42 | 42 |
return com.iver.fsac.Automaton.TRANSITION_SUCCESS; |
43 | 43 |
} |
44 | 44 |
|
45 |
if ("sel".equalsIgnoreCase(label)){ |
|
46 |
previousStatus = status; |
|
47 |
status = 0; |
|
48 |
|
|
49 |
return com.iver.fsac.Automaton.TRANSITION_SUCCESS; |
|
50 |
} |
|
51 |
|
|
52 |
if ("handler".equalsIgnoreCase(label)){ |
|
53 |
previousStatus = status; |
|
54 |
status = 4; |
|
55 |
|
|
56 |
return com.iver.fsac.Automaton.TRANSITION_SUCCESS; |
|
57 |
} |
|
58 |
|
|
45 | 59 |
if ("cancel".equalsIgnoreCase(label)){ |
46 | 60 |
previousStatus = status; |
47 | 61 |
status = -1; |
... | ... | |
53 | 67 |
|
54 | 68 |
case 2: |
55 | 69 |
|
70 |
if ("punto".equalsIgnoreCase(label)){ |
|
71 |
previousStatus = status; |
|
72 |
status = 3; |
|
73 |
|
|
74 |
return com.iver.fsac.Automaton.TRANSITION_SUCCESS; |
|
75 |
} |
|
76 |
|
|
56 | 77 |
if ("cancel".equalsIgnoreCase(label)){ |
57 | 78 |
previousStatus = status; |
58 | 79 |
status = -1; |
... | ... | |
62 | 83 |
|
63 | 84 |
break; |
64 | 85 |
|
86 |
case 3: |
|
87 |
|
|
88 |
if ("sel".equalsIgnoreCase(label)){ |
|
89 |
previousStatus = status; |
|
90 |
status = 0; |
|
91 |
|
|
92 |
return com.iver.fsac.Automaton.TRANSITION_SUCCESS; |
|
93 |
} |
|
94 |
|
|
95 |
if ("no_sel".equalsIgnoreCase(label)){ |
|
96 |
previousStatus = status; |
|
97 |
status = 0; |
|
98 |
|
|
99 |
return com.iver.fsac.Automaton.TRANSITION_SUCCESS; |
|
100 |
} |
|
101 |
|
|
102 |
if ("cancel".equalsIgnoreCase(label)){ |
|
103 |
previousStatus = status; |
|
104 |
status = -1; |
|
105 |
|
|
106 |
return com.iver.fsac.Automaton.AUTOMATON_FINISHED; |
|
107 |
} |
|
108 |
|
|
109 |
break; |
|
110 |
|
|
111 |
case 4: |
|
112 |
|
|
113 |
if ("punto".equalsIgnoreCase(label)){ |
|
114 |
previousStatus = status; |
|
115 |
status = 5; |
|
116 |
|
|
117 |
return com.iver.fsac.Automaton.TRANSITION_SUCCESS; |
|
118 |
} |
|
119 |
|
|
120 |
if ("cancel".equalsIgnoreCase(label)){ |
|
121 |
previousStatus = status; |
|
122 |
status = -1; |
|
123 |
|
|
124 |
return com.iver.fsac.Automaton.AUTOMATON_FINISHED; |
|
125 |
} |
|
126 |
|
|
127 |
break; |
|
128 |
|
|
129 |
case 5: |
|
130 |
|
|
131 |
if ("done".equalsIgnoreCase(label)){ |
|
132 |
previousStatus = status; |
|
133 |
status = 0; |
|
134 |
|
|
135 |
return com.iver.fsac.Automaton.TRANSITION_SUCCESS; |
|
136 |
} |
|
137 |
|
|
138 |
if ("cancel".equalsIgnoreCase(label)){ |
|
139 |
previousStatus = status; |
|
140 |
status = -1; |
|
141 |
|
|
142 |
return com.iver.fsac.Automaton.AUTOMATON_FINISHED; |
|
143 |
} |
|
144 |
|
|
145 |
break; |
|
146 |
|
|
65 | 147 |
} |
66 | 148 |
|
67 | 149 |
return com.iver.fsac.Automaton.TRANSITION_FAILED; |
... | ... | |
82 | 164 |
} |
83 | 165 |
|
84 | 166 |
if (status == 0){ |
85 |
return "".indexOf(c) != -1; |
|
167 |
return "c".indexOf(c) != -1;
|
|
86 | 168 |
} |
87 | 169 |
|
88 | 170 |
if (status == 1){ |
... | ... | |
93 | 175 |
return "".indexOf(c) != -1; |
94 | 176 |
} |
95 | 177 |
|
178 |
if (status == 3){ |
|
179 |
return "".indexOf(c) != -1; |
|
180 |
} |
|
96 | 181 |
|
182 |
if (status == 4){ |
|
183 |
return "".indexOf(c) != -1; |
|
184 |
} |
|
185 |
|
|
186 |
if (status == 5){ |
|
187 |
return "".indexOf(c) != -1; |
|
188 |
} |
|
189 |
|
|
190 |
|
|
97 | 191 |
return false; |
98 | 192 |
} |
99 | 193 |
|
... | ... | |
108 | 202 |
} |
109 | 203 |
|
110 | 204 |
if (status == 1){ |
111 |
return new String[]{"punto", "cancel"};
|
|
205 |
return new String[]{"no_sel", "sel", "handler", "cancel"};
|
|
112 | 206 |
} |
113 | 207 |
|
114 | 208 |
if (status == 2){ |
115 |
return new String[]{"cancel"}; |
|
209 |
return new String[]{"punto", "cancel"};
|
|
116 | 210 |
} |
117 | 211 |
|
212 |
if (status == 3){ |
|
213 |
return new String[]{"sel", "no_sel", "cancel"}; |
|
214 |
} |
|
118 | 215 |
|
216 |
if (status == 4){ |
|
217 |
return new String[]{"punto", "cancel"}; |
|
218 |
} |
|
219 |
|
|
220 |
if (status == 5){ |
|
221 |
return new String[]{"done", "cancel"}; |
|
222 |
} |
|
223 |
|
|
224 |
|
|
119 | 225 |
throw new RuntimeException("Bug!"); |
120 | 226 |
} |
121 | 227 |
|
... | ... | |
130 | 236 |
} |
131 | 237 |
|
132 | 238 |
if (status == 1){ |
133 |
return new String[]{null, "Cancelar"}; |
|
239 |
return new String[]{null, null, null, "Cancelar"};
|
|
134 | 240 |
} |
135 | 241 |
|
136 | 242 |
if (status == 2){ |
137 |
return new String[]{"Cancelar"}; |
|
243 |
return new String[]{null, "Cancelar"};
|
|
138 | 244 |
} |
139 | 245 |
|
246 |
if (status == 3){ |
|
247 |
return new String[]{null, null, "Cancelar"}; |
|
248 |
} |
|
140 | 249 |
|
250 |
if (status == 4){ |
|
251 |
return new String[]{null, "Cancelar"}; |
|
252 |
} |
|
253 |
|
|
254 |
if (status == 5){ |
|
255 |
return new String[]{null, "Cancelar"}; |
|
256 |
} |
|
257 |
|
|
258 |
|
|
141 | 259 |
throw new RuntimeException("Bug!"); |
142 | 260 |
} |
143 | 261 |
} |
branches/pilotoDWG/applications/appgvSIG/src/com/iver/cit/gvsig/gui/cad/tools/SelectionCadTool.java | ||
---|---|---|
1 | 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 |
*/ |
|
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 | 41 |
package com.iver.cit.gvsig.gui.cad.tools; |
42 | 42 |
|
43 |
import java.awt.Graphics; |
|
44 |
import java.awt.Graphics2D; |
|
45 |
import java.awt.geom.Point2D; |
|
46 |
import java.awt.geom.Rectangle2D; |
|
47 |
import java.io.IOException; |
|
43 |
import com.iver.andami.PluginServices; |
|
48 | 44 |
|
49 |
import com.iver.andami.PluginServices; |
|
50 | 45 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
46 |
import com.iver.cit.gvsig.fmap.core.Handler; |
|
47 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
51 | 48 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
52 | 49 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
53 | 50 |
import com.iver.cit.gvsig.fmap.edition.EditableFeatureSource; |
... | ... | |
55 | 52 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
56 | 53 |
import com.iver.cit.gvsig.gui.cad.CadTool; |
57 | 54 |
import com.iver.cit.gvsig.gui.cad.automaton.Seleccion; |
55 |
|
|
58 | 56 |
import com.iver.fsac.Automaton; |
57 |
|
|
59 | 58 |
import com.vividsolutions.jts.geom.Envelope; |
60 | 59 |
|
60 |
import java.awt.Graphics; |
|
61 |
import java.awt.Graphics2D; |
|
62 |
import java.awt.geom.Point2D; |
|
63 |
import java.awt.geom.Rectangle2D; |
|
61 | 64 |
|
65 |
import java.io.IOException; |
|
66 |
import java.util.ArrayList; |
|
67 |
|
|
68 |
|
|
62 | 69 |
/** |
63 | 70 |
* DOCUMENT ME! |
64 | 71 |
* |
... | ... | |
66 | 73 |
*/ |
67 | 74 |
public class SelectionCadTool extends AbstractCadTool { |
68 | 75 |
private static Status[] STATUS = { |
69 |
new Status("Primer punto del rect?ngulo de selecci?n"), |
|
76 |
new Status(""), |
|
77 |
new Status(""), |
|
70 | 78 |
new Status("Siguiente punto del rect?ngulo de selecci?n"), |
79 |
new Status(""), |
|
80 |
new Status("Precise punto de estiramiento"), |
|
71 | 81 |
}; |
82 |
private final static int tolerance = 5; |
|
72 | 83 |
private Seleccion selectionStatus = new Seleccion(); |
73 | 84 |
private Point2D firstPoint; |
74 | 85 |
private Point2D lastPoint; |
75 |
|
|
76 |
private class PointSelector implements Runnable{ |
|
77 |
private Rectangle2D rect; |
|
78 |
private EditableFeatureSource editingSource; |
|
79 |
private FBitSet selectedGeometries; |
|
80 |
private int ret = 0; |
|
81 |
public PointSelector( final EditableFeatureSource editingSource, |
|
82 |
final FBitSet selectedGeometries, double x, double y){ |
|
83 |
double tam = getCadToolAdapter().getMapControl().getViewPort().toMapDistance(15); |
|
84 |
rect=new Rectangle2D.Double(firstPoint.getX()- tam , firstPoint.getY()- tam, tam, tam); |
|
85 |
this.editingSource = editingSource; |
|
86 |
this.selectedGeometries = selectedGeometries; |
|
87 |
} |
|
88 |
|
|
89 |
/** |
|
90 |
* @see java.lang.Runnable#run() |
|
91 |
*/ |
|
92 |
public void run() { |
|
93 |
int[] indexes = editingSource.getGeometriesIndexes(rect); |
|
94 |
boolean anySelected = false; |
|
95 |
|
|
96 |
for (int i=0;i<indexes.length; i++){ |
|
97 |
try { |
|
98 |
if (editingSource.getGeometry(indexes[i]).fastIntersects(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight())){ |
|
99 |
selectedGeometries.set(indexes[i],true); |
|
100 |
anySelected = true; |
|
101 |
break; |
|
102 |
} |
|
103 |
} catch (IOException e) { |
|
104 |
e.printStackTrace(); |
|
105 |
} catch (DriverIOException e) { |
|
106 |
e.printStackTrace(); |
|
107 |
} |
|
108 |
} |
|
109 |
|
|
110 |
if (anySelected){ |
|
111 |
ret = selectionStatus.transition("cancel"); |
|
112 |
} |
|
113 |
} |
|
114 |
public int getRet() { |
|
115 |
return ret; |
|
116 |
} |
|
117 |
} |
|
86 |
private ArrayList selectedHandler = new ArrayList(); |
|
87 |
private ArrayList selectedGeometry = new ArrayList(); |
|
88 |
private ArrayList selectedGeometryIndex = new ArrayList(); |
|
89 |
|
|
118 | 90 |
/** |
119 | 91 |
* @see com.iver.cit.gvsig.gui.cad.CadTool#transition(java.lang.String, |
120 | 92 |
* com.iver.cit.gvsig.fmap.edition.EditableFeatureSource, |
121 | 93 |
* com.iver.cit.gvsig.fmap.layers.FBitSet, double[]) |
122 | 94 |
*/ |
123 |
public int transition(String text, final EditableFeatureSource editingSource, |
|
95 |
public int transition(String text, |
|
96 |
final EditableFeatureSource editingSource, |
|
124 | 97 |
final FBitSet selectedGeometries, final double[] values) { |
125 | 98 |
int ret = selectionStatus.transition(text); |
126 | 99 |
|
... | ... | |
128 | 101 |
|
129 | 102 |
if (status == 0) { |
130 | 103 |
} else if (status == 1) { |
131 |
if (values.length != 0) { |
|
132 |
firstPoint = new Point2D.Double(values[0], values[1]); |
|
133 |
|
|
134 |
|
|
135 |
PointSelector ps = new PointSelector(editingSource, selectedGeometries, values[0], values[1]); |
|
136 |
|
|
137 |
ps.run(); |
|
138 |
ret = ret | ps.getRet(); |
|
139 |
} |
|
140 |
|
|
141 |
}else if(status == 2){ |
|
104 |
firstPoint = new Point2D.Double(values[0], values[1]); |
|
142 | 105 |
|
143 |
PluginServices.backgroundExecution(new Runnable() { |
|
144 |
public void run() { |
|
145 |
if (values.length != 0) { |
|
146 |
lastPoint = new Point2D.Double(values[0], values[1]); |
|
147 |
} |
|
148 |
selectedGeometries.clear(); |
|
149 |
try { |
|
150 |
double x; |
|
151 |
double y; |
|
152 |
double w; |
|
153 |
double h; |
|
154 |
if (firstPoint.getX()<lastPoint.getX()){ |
|
155 |
x=firstPoint.getX(); |
|
156 |
w=lastPoint.getX()-firstPoint.getX(); |
|
157 |
}else{ |
|
158 |
x=lastPoint.getX(); |
|
159 |
w=firstPoint.getX()-lastPoint.getX(); |
|
160 |
} |
|
161 |
if (firstPoint.getY()<lastPoint.getY()){ |
|
162 |
y=firstPoint.getY(); |
|
163 |
h=lastPoint.getY()-firstPoint.getY(); |
|
164 |
}else{ |
|
165 |
y=lastPoint.getY(); |
|
166 |
h=firstPoint.getY()-lastPoint.getY(); |
|
167 |
} |
|
168 |
|
|
169 |
Rectangle2D rect=new Rectangle2D.Double(x,y,w,h); |
|
106 |
double tolerance = getCadToolAdapter().getMapControl().getViewPort().toMapDistance(SelectionCadTool.tolerance); |
|
107 |
|
|
108 |
Rectangle2D r = new Rectangle2D.Double(firstPoint.getX() - |
|
109 |
tolerance, firstPoint.getY() - tolerance, tolerance * 2, |
|
110 |
tolerance * 2); |
|
170 | 111 |
|
171 |
/* for (int i=0;i<editingSource.getGeometryCount();i++){ |
|
172 |
|
|
173 |
if (rect.contains(editingSource.getGeometry(i).getBounds2D())){ |
|
174 |
selectedGeometries.set(i,true); |
|
112 |
if (selectedGeometries.cardinality() > 0) { |
|
113 |
try { |
|
114 |
selectedGeometry.clear(); |
|
115 |
selectedGeometryIndex.clear(); |
|
116 |
selectedHandler.clear(); |
|
117 |
for (int i = selectedGeometries.nextSetBit(0); i >= 0; |
|
118 |
i = selectedGeometries.nextSetBit(i + 1)) { |
|
119 |
Handler[] handlers = editingSource.getGeometry(i) |
|
120 |
.getHandlers(); |
|
121 |
|
|
122 |
IGeometry clonedGeometry = null; |
|
123 |
for (int j = 0; j < handlers.length; j++) { |
|
124 |
Point2D handlerPoint = handlers[j].getPoint(); |
|
125 |
|
|
126 |
if (r.contains(handlerPoint.getX(), |
|
127 |
handlerPoint.getY())) { |
|
128 |
if (clonedGeometry == null){ |
|
129 |
clonedGeometry = editingSource.getGeometry(i).cloneGeometry(); |
|
175 | 130 |
} |
131 |
selectedGeometry.add(clonedGeometry); |
|
132 |
selectedHandler.add(clonedGeometry.getHandlers()[j]); |
|
133 |
selectedGeometryIndex.add(new Integer(i)); |
|
176 | 134 |
} |
177 |
*/ |
|
178 |
|
|
179 |
int[] indexes = editingSource.getGeometriesIndexes(new Rectangle2D.Double(x,y, x+w, y+h)); |
|
180 |
|
|
181 |
for (int i=0;i<indexes.length; i++){ |
|
182 |
|
|
183 |
if (rect.contains(editingSource.getGeometry(indexes[i]).getBounds2D())){ |
|
184 |
selectedGeometries.set(indexes[i],true); |
|
185 |
} |
|
186 |
} |
|
187 |
|
|
188 |
} catch (DriverIOException e) { |
|
189 |
e.printStackTrace(); |
|
190 |
} catch (IOException e) { |
|
191 |
e.printStackTrace(); |
|
192 | 135 |
} |
193 | 136 |
} |
194 |
}); |
|
137 |
ret = ret | |
|
138 |
selectionStatus.transition("handler"); |
|
139 |
} catch (IOException e) { |
|
140 |
e.printStackTrace(); |
|
141 |
} catch (DriverIOException e) { |
|
142 |
e.printStackTrace(); |
|
143 |
} |
|
144 |
} else { |
|
145 |
PointSelector ps = new PointSelector(editingSource, |
|
146 |
selectedGeometries, values[0], values[1]); |
|
147 |
|
|
148 |
ps.run(); |
|
149 |
|
|
150 |
ret = ret | ps.getRet(); |
|
151 |
|
|
152 |
if (selectedGeometries.cardinality() > 0) { |
|
153 |
ret = ret | selectionStatus.transition("sel"); |
|
154 |
} else { |
|
155 |
ret = ret | selectionStatus.transition("no_sel"); |
|
156 |
} |
|
157 |
} |
|
158 |
|
|
159 |
return ret; |
|
160 |
} else if (status == 3) { |
|
161 |
// PluginServices.backgroundExecution(new Runnable() { |
|
162 |
// public void run() { |
|
163 |
if (values.length != 0) { |
|
164 |
lastPoint = new Point2D.Double(values[0], values[1]); |
|
165 |
} |
|
166 |
|
|
167 |
selectedGeometries.clear(); |
|
168 |
|
|
169 |
try { |
|
170 |
double x; |
|
171 |
double y; |
|
172 |
double w; |
|
173 |
double h; |
|
174 |
|
|
175 |
if (firstPoint.getX() < lastPoint.getX()) { |
|
176 |
x = firstPoint.getX(); |
|
177 |
w = lastPoint.getX() - firstPoint.getX(); |
|
178 |
} else { |
|
179 |
x = lastPoint.getX(); |
|
180 |
w = firstPoint.getX() - lastPoint.getX(); |
|
181 |
} |
|
182 |
|
|
183 |
if (firstPoint.getY() < lastPoint.getY()) { |
|
184 |
y = firstPoint.getY(); |
|
185 |
h = lastPoint.getY() - firstPoint.getY(); |
|
186 |
} else { |
|
187 |
y = lastPoint.getY(); |
|
188 |
h = firstPoint.getY() - lastPoint.getY(); |
|
189 |
} |
|
190 |
|
|
191 |
Rectangle2D rect = new Rectangle2D.Double(x, y, w, h); |
|
192 |
|
|
193 |
for (int i=0;i<editingSource.getGeometryCount();i++){ |
|
194 |
if (rect.contains(editingSource.getGeometry(i).getBounds2D())){ |
|
195 |
selectedGeometries.set(i,true); |
|
196 |
} |
|
197 |
} |
|
198 |
/* |
|
199 |
int[] indexes = editingSource.getGeometriesIndexes(new Rectangle2D.Double( |
|
200 |
x, y, x + w, y + h)); |
|
201 |
|
|
202 |
for (int i = 0; i < indexes.length; i++) { |
|
203 |
if (rect.contains(editingSource.getGeometry(indexes[i]) |
|
204 |
.getBounds2D())) { |
|
205 |
selectedGeometries.set(indexes[i], true); |
|
206 |
} |
|
207 |
}*/ |
|
208 |
} catch (DriverIOException e) { |
|
209 |
e.printStackTrace(); |
|
210 |
} catch (IOException e) { |
|
211 |
e.printStackTrace(); |
|
212 |
} |
|
213 |
|
|
214 |
// } |
|
215 |
// }); |
|
216 |
if (selectedGeometries.cardinality() > 0) { |
|
217 |
ret = ret | selectionStatus.transition("sel"); |
|
218 |
} else { |
|
219 |
ret = ret | selectionStatus.transition("no_sel"); |
|
220 |
} |
|
221 |
|
|
222 |
return ret; |
|
223 |
} else if (status == 5) { |
|
224 |
for (int i = 0; i < selectedGeometry.size(); i++) { |
|
225 |
Handler h = (Handler) selectedHandler.get(i); |
|
226 |
IGeometry geom = (IGeometry) selectedGeometry.get(i); |
|
227 |
int index = ((Integer) selectedGeometryIndex.get(i)).intValue(); |
|
228 |
|
|
229 |
h.set(values[0], values[1]); |
|
230 |
try { |
|
231 |
editingSource.modifyGeometry(index, geom); |
|
232 |
} catch (IOException e) { |
|
233 |
e.printStackTrace(); |
|
234 |
} catch (DriverIOException e) { |
|
235 |
e.printStackTrace(); |
|
236 |
} |
|
195 | 237 |
|
196 |
ret = ret | selectionStatus.transition("cancel");
|
|
197 |
}
|
|
238 |
}
|
|
239 |
ret = ret | selectionStatus.transition("done");
|
|
198 | 240 |
|
241 |
return ret; |
|
242 |
} |
|
243 |
|
|
199 | 244 |
return ret; |
200 | 245 |
} |
201 | 246 |
|
... | ... | |
208 | 253 |
FBitSet selectedGeometries, double x, double y) { |
209 | 254 |
int status = selectionStatus.getStatus(); |
210 | 255 |
|
211 |
if (status == 1){
|
|
256 |
if (status == 2) {
|
|
212 | 257 |
GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, |
213 | 258 |
4); |
214 | 259 |
elShape.moveTo(firstPoint.getX(), firstPoint.getY()); |
... | ... | |
216 | 261 |
elShape.lineTo(x, y); |
217 | 262 |
elShape.lineTo(firstPoint.getX(), y); |
218 | 263 |
elShape.lineTo(firstPoint.getX(), firstPoint.getY()); |
219 |
ShapeFactory.createPolyline2D(elShape).draw((Graphics2D) g, getCadToolAdapter().getMapControl().getViewPort(), CadTool.drawingSymbol); |
|
264 |
ShapeFactory.createPolyline2D(elShape).draw((Graphics2D) g, |
|
265 |
getCadToolAdapter().getMapControl().getViewPort(), |
|
266 |
CadTool.drawingSymbol); |
|
220 | 267 |
} |
221 | 268 |
} |
222 | 269 |
|
... | ... | |
240 | 287 |
public Automaton getAutomaton() { |
241 | 288 |
return selectionStatus; |
242 | 289 |
} |
243 |
} |
|
244 | 290 |
|
291 |
/** |
|
292 |
* DOCUMENT ME! |
|
293 |
* |
|
294 |
* @author Fernando Gonz?lez Cort?s |
|
295 |
*/ |
|
296 |
private class PointSelector implements Runnable { |
|
297 |
private Rectangle2D rect; |
|
298 |
private EditableFeatureSource editingSource; |
|
299 |
private FBitSet selectedGeometries; |
|
300 |
private int ret = 0; |
|
245 | 301 |
|
302 |
/** |
|
303 |
* Crea un nuevo PointSelector. |
|
304 |
* |
|
305 |
* @param editingSource DOCUMENT ME! |
|
306 |
* @param selectedGeometries DOCUMENT ME! |
|
307 |
* @param x DOCUMENT ME! |
|
308 |
* @param y DOCUMENT ME! |
|
309 |
*/ |
|
310 |
public PointSelector(final EditableFeatureSource editingSource, |
|
311 |
final FBitSet selectedGeometries, double x, double y) { |
|
312 |
double tam = getCadToolAdapter().getMapControl().getViewPort() |
|
313 |
.toMapDistance(15); |
|
314 |
rect = new Rectangle2D.Double(firstPoint.getX() - tam, |
|
315 |
firstPoint.getY() - tam, tam, tam); |
|
316 |
this.editingSource = editingSource; |
|
317 |
this.selectedGeometries = selectedGeometries; |
|
318 |
} |
|
246 | 319 |
|
320 |
/** |
|
321 |
* @see java.lang.Runnable#run() |
|
322 |
*/ |
|
323 |
public void run() { |
|
324 |
int[] indexes = editingSource.getGeometriesIndexes(rect); |
|
325 |
boolean anySelected = false; |
|
326 |
|
|
327 |
selectedGeometries.clear(); |
|
328 |
|
|
329 |
for (int i = 0; i < indexes.length; i++) { |
|
330 |
try { |
|
331 |
if (editingSource.getGeometry(indexes[i]).fastIntersects(rect.getX(), |
|
332 |
rect.getY(), rect.getWidth(), rect.getHeight())) { |
|
333 |
selectedGeometries.set(indexes[i], true); |
|
334 |
anySelected = true; |
|
335 |
|
|
336 |
break; |
|
337 |
} |
|
338 |
} catch (IOException e) { |
|
339 |
e.printStackTrace(); |
|
340 |
} catch (DriverIOException e) { |
|
341 |
e.printStackTrace(); |
|
342 |
} |
|
343 |
} |
|
344 |
|
|
345 |
if (anySelected) { |
|
346 |
ret = selectionStatus.transition("cancel"); |
|
347 |
} |
|
348 |
} |
|
349 |
|
|
350 |
/** |
|
351 |
* DOCUMENT ME! |
|
352 |
* |
|
353 |
* @return DOCUMENT ME! |
|
354 |
*/ |
|
355 |
public int getRet() { |
|
356 |
return ret; |
|
357 |
} |
|
358 |
} |
|
359 |
} |
branches/pilotoDWG/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/Handler.java | ||
---|---|---|
17 | 17 |
* |
18 | 18 |
* You should have received a copy of the GNU General Public License |
19 | 19 |
* along with this program; if not, write to the Free Software |
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
|
|
21 |
USA. |
|
20 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
|
21 |
USA.
|
|
22 | 22 |
* |
23 | 23 |
* For more information, contact: |
24 | 24 |
* |
... | ... | |
47 | 47 |
import java.awt.geom.Point2D; |
48 | 48 |
|
49 | 49 |
|
50 |
/** |
|
51 |
* DOCUMENT ME! |
|
52 |
* |
|
53 |
*/ |
|
50 | 54 |
public interface Handler { |
55 |
/** |
|
56 |
* Desplaza el handler aplicandole un vector de componentes 'x','y' |
|
57 |
* |
|
58 |
* @param x DOCUMENT ME! |
|
59 |
* @param y DOCUMENT ME! |
|
60 |
*/ |
|
51 | 61 |
public void move(double x, double y); |
62 |
|
|
63 |
/** |
|
64 |
* Mueve el vector a la posici?n 'x', 'y' |
|
65 |
* |
|
66 |
* @param x DOCUMENT ME! |
|
67 |
* @param y DOCUMENT ME! |
|
68 |
*/ |
|
69 |
public void set(double x, double y); |
|
70 |
|
|
71 |
/** |
|
72 |
* DOCUMENT ME! |
|
73 |
* |
|
74 |
* @return DOCUMENT ME! |
|
75 |
*/ |
|
52 | 76 |
public Point2D getPoint(); |
77 |
|
|
78 |
/** |
|
79 |
* DOCUMENT ME! |
|
80 |
* |
|
81 |
* @param b DOCUMENT ME! |
|
82 |
*/ |
|
53 | 83 |
public void select(boolean b); |
84 |
|
|
85 |
/** |
|
86 |
* DOCUMENT ME! |
|
87 |
* |
|
88 |
* @return DOCUMENT ME! |
|
89 |
*/ |
|
54 | 90 |
public boolean isSelected(); |
55 | 91 |
} |
branches/pilotoDWG/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/FPoint2D.java | ||
---|---|---|
227 | 227 |
* @return DOCUMENT ME! |
228 | 228 |
*/ |
229 | 229 |
public void move(double x, double y) { |
230 |
p.setLocation(p.getX()+x,p.getY()+y); |
|
230 |
p.setLocation(p.getX()+x,p.getY()+y);
|
|
231 | 231 |
} |
232 |
|
|
233 |
/** |
|
234 |
* @see com.iver.cit.gvsig.fmap.core.Handler#set(double, double) |
|
235 |
*/ |
|
236 |
public void set(double x, double y) { |
|
237 |
p.setLocation(x, y); |
|
238 |
} |
|
232 | 239 |
} |
233 | 240 |
} |
branches/pilotoDWG/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/FPolyline2D.java | ||
---|---|---|
268 | 268 |
gp.pointCoords[index*2]+=x; |
269 | 269 |
gp.pointCoords[index*2+1]+=y; |
270 | 270 |
} |
271 |
|
|
272 |
/** |
|
273 |
* @see com.iver.cit.gvsig.fmap.core.Handler#set(double, double) |
|
274 |
*/ |
|
275 |
public void set(double x, double y) { |
|
276 |
gp.pointCoords[index*2]=x; |
|
277 |
gp.pointCoords[index*2+1]=y; |
|
278 |
} |
|
271 | 279 |
} |
272 | 280 |
|
273 | 281 |
} |
branches/pilotoDWG/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/FCircle2D.java | ||
---|---|---|
116 | 116 |
gp.pointCoords[i*2+1]+=y; |
117 | 117 |
} |
118 | 118 |
} |
119 |
|
|
120 |
/** |
|
121 |
* @see com.iver.cit.gvsig.fmap.core.Handler#set(double, double) |
|
122 |
*/ |
|
123 |
public void set(double x, double y) { |
|
124 |
for (int i=0;i<gp.numCoords/2;i++){ |
|
125 |
gp.pointCoords[i*2]=x; |
|
126 |
gp.pointCoords[i*2+1]=y; |
|
127 |
} |
|
128 |
} |
|
119 | 129 |
} |
120 | 130 |
|
121 | 131 |
/** |
... | ... | |
147 | 157 |
public void move(double x, double y) { |
148 | 158 |
|
149 | 159 |
} |
160 |
|
|
161 |
/** |
|
162 |
* @see com.iver.cit.gvsig.fmap.core.Handler#set(double, double) |
|
163 |
*/ |
|
164 |
public void set(double x, double y) { |
|
165 |
} |
|
150 | 166 |
} |
151 | 167 |
} |
branches/pilotoDWG/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/FArc2D.java | ||
---|---|---|
163 | 163 |
public Point2D getPoint(){ |
164 | 164 |
return center; |
165 | 165 |
} |
166 |
|
|
167 |
/** |
|
168 |
* @see com.iver.cit.gvsig.fmap.core.Handler#set(double, double) |
|
169 |
*/ |
|
170 |
public void set(double x, double y) { |
|
171 |
} |
|
166 | 172 |
} |
167 | 173 |
|
168 | 174 |
/** |
... | ... | |
212 | 218 |
public Point2D getPoint(){ |
213 | 219 |
return init; |
214 | 220 |
} |
221 |
|
|
222 |
/** |
|
223 |
* @see com.iver.cit.gvsig.fmap.core.Handler#set(double, double) |
|
224 |
*/ |
|
225 |
public void set(double x, double y) { |
|
226 |
Point2D mediop=new Point2D.Double((init.getX()+end.getX())/2,(init.getY()+end.getY())/2); |
|
227 |
double dist=mediop.distance(center); |
|
228 |
init=new Point2D.Double(x,y); |
|
229 |
|
|
230 |
mediop=new Point2D.Double((init.getX()+end.getX())/2,(init.getY()+end.getY())/2); |
|
231 |
Point2D[] perp=TrigonometricalFunctions.getPerpendicular(init,end,mediop); |
|
232 |
if (TrigonometricalFunctions.getAngle(end,init)<=Math.PI){ |
|
233 |
dist=-dist; |
|
234 |
} |
|
235 |
center=TrigonometricalFunctions.getPoint(mediop,perp[1],dist); |
|
236 |
|
|
237 |
Arc2D arco = TrigonometricalFunctions.createArc(init,center, end); |
|
238 |
gp=new GeneralPathX(arco); |
|
239 |
} |
|
215 | 240 |
} |
216 | 241 |
/** |
217 | 242 |
* DOCUMENT ME! |
... | ... | |
260 | 285 |
public Point2D getPoint(){ |
261 | 286 |
return end; |
262 | 287 |
} |
288 |
|
|
289 |
/** |
|
290 |
* @see com.iver.cit.gvsig.fmap.core.Handler#set(double, double) |
|
291 |
*/ |
|
292 |
public void set(double x, double y) { |
|
293 |
Point2D mediop=new Point2D.Double((init.getX()+end.getX())/2,(init.getY()+end.getY())/2); |
|
294 |
double dist=mediop.distance(center); |
|
295 |
end=new Point2D.Double(x,y); |
|
296 |
|
|
297 |
mediop=new Point2D.Double((init.getX()+end.getX())/2,(init.getY()+end.getY())/2); |
|
298 |
Point2D[] perp=TrigonometricalFunctions.getPerpendicular(init,end,mediop); |
|
299 |
if (TrigonometricalFunctions.getAngle(end,init)<=Math.PI){ |
|
300 |
dist=-dist; |
|
301 |
} |
|
302 |
center=TrigonometricalFunctions.getPoint(mediop,perp[1],dist); |
|
303 |
|
|
304 |
Arc2D arco = TrigonometricalFunctions.createArc(init,center, end); |
|
305 |
gp=new GeneralPathX(arco); |
|
306 |
} |
|
263 | 307 |
} |
264 | 308 |
} |
Also available in: Unified diff