Revision 37138 branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/gui/cad/tools/ComplexSelectionCADTool.java
ComplexSelectionCADTool.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
|
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
|
2 | 2 |
* |
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
5 | 6 |
* This program is free software; you can redistribute it and/or |
6 | 7 |
* modify it under the terms of the GNU General Public License |
7 | 8 |
* as published by the Free Software Foundation; either version 2 |
8 | 9 |
* of the License, or (at your option) any later version. |
9 |
* |
|
10 |
*
|
|
10 | 11 |
* This program is distributed in the hope that it will be useful, |
11 | 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | 14 |
* GNU General Public License for more details. |
14 |
* |
|
15 |
*
|
|
15 | 16 |
* You should have received a copy of the GNU General Public License |
16 | 17 |
* 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 |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
40 | 21 |
*/ |
41 | 22 |
package org.gvsig.editing.gui.cad.tools; |
42 | 23 |
|
... | ... | |
71 | 52 |
import org.gvsig.fmap.mapcontrol.MapControl; |
72 | 53 |
import org.gvsig.fmap.mapcontrol.MapControlDrawer; |
73 | 54 |
|
74 |
|
|
75 | 55 |
/** |
76 | 56 |
* DOCUMENT ME! |
77 |
* |
|
57 |
*
|
|
78 | 58 |
* @author Vicente Caballero Navarro |
79 | 59 |
*/ |
80 | 60 |
@SuppressWarnings({ "rawtypes", "unchecked" }) |
... | ... | |
107 | 87 |
/** |
108 | 88 |
* Equivale al transition del prototipo pero sin pasarle como par? metro el |
109 | 89 |
* editableFeatureSource que ya estar? creado. |
110 |
* |
|
90 |
*
|
|
111 | 91 |
* @param selection |
112 | 92 |
* Bitset con las geometr?as que est?n seleccionadas. |
113 | 93 |
* @param x |
... | ... | |
125 | 105 |
} |
126 | 106 |
return; |
127 | 107 |
} |
128 |
ComplexSelectionCADToolState actualState = (ComplexSelectionCADToolState) _fsm
|
|
129 |
.getPreviousState(); |
|
108 |
ComplexSelectionCADToolState actualState = |
|
109 |
(ComplexSelectionCADToolState) _fsm.getPreviousState();
|
|
130 | 110 |
String status = actualState.getName(); |
131 |
LOG.info("PREVIOUSSTATE =" + status);
|
|
111 |
LOG.info("PREVIOUSSTATE =" + status); |
|
132 | 112 |
LOG.info("STATUS ACTUAL = " + _fsm.getTransition()); |
133 | 113 |
if (status.equals("Selection.FirstPoint")) { |
134 | 114 |
firstPoint = new Point2D.Double(x, y); |
135 | 115 |
pointsPolygon.add(firstPoint); |
136 |
} else if (status.equals("Selection.SecondPoint")) { |
|
137 |
|
|
138 |
} else if (status.equals("Selection.WithSelectedFeatures")) { |
|
139 |
|
|
140 |
} else if (status.equals("Selection.WithHandlers")) { |
|
141 |
FeatureStore featureStore = null; |
|
142 |
try { |
|
143 |
VectorialLayerEdited vle = getVLE(); |
|
144 |
featureStore = vle.getFeatureStore(); |
|
145 |
addPointWithHandlers(x, y, featureStore, vle.getSelectedHandler()); |
|
146 |
} catch (ReadException e) { |
|
147 |
LOG.error("Error getting the feature store"); |
|
148 |
} |
|
149 |
} else if (status.equals("Selection.NextPointPolygon")) { |
|
150 |
pointsPolygon.add(new Point2D.Double(x, y)); |
|
151 |
} |
|
116 |
} else |
|
117 |
if (status.equals("Selection.SecondPoint")) { |
|
118 |
|
|
119 |
} else |
|
120 |
if (status.equals("Selection.WithSelectedFeatures")) { |
|
121 |
|
|
122 |
} else |
|
123 |
if (status.equals("Selection.WithHandlers")) { |
|
124 |
FeatureStore featureStore = null; |
|
125 |
try { |
|
126 |
VectorialLayerEdited vle = getVLE(); |
|
127 |
featureStore = vle.getFeatureStore(); |
|
128 |
addPointWithHandlers(x, y, featureStore, |
|
129 |
vle.getSelectedHandler()); |
|
130 |
} catch (ReadException e) { |
|
131 |
LOG.error("Error getting the feature store"); |
|
132 |
} |
|
133 |
} else |
|
134 |
if (status.equals("Selection.NextPointPolygon")) { |
|
135 |
pointsPolygon.add(new Point2D.Double(x, y)); |
|
136 |
} |
|
152 | 137 |
} |
153 | 138 |
|
154 |
|
|
155 |
|
|
156 | 139 |
/** |
157 | 140 |
* Receives second point |
158 |
* |
|
141 |
*
|
|
159 | 142 |
* @param x |
160 | 143 |
* @param y |
161 | 144 |
* @return numFeatures selected |
... | ... | |
163 | 146 |
public long selectWithSecondPointOutRectangle(double x, double y, |
164 | 147 |
InputEvent event) { |
165 | 148 |
Point2D lastPoint = new Point2D.Double(x, y); |
166 |
Surface surface = createSurface(); |
|
167 |
surface.addMoveToVertex(createPoint(firstPoint.getX(), firstPoint.getY())); |
|
149 |
Surface surface = createSurface(); |
|
150 |
surface.addMoveToVertex(createPoint(firstPoint.getX(), |
|
151 |
firstPoint.getY())); |
|
168 | 152 |
surface.addVertex(createPoint(lastPoint.getX(), firstPoint.getY())); |
169 | 153 |
surface.addVertex(createPoint(lastPoint.getX(), lastPoint.getY())); |
170 | 154 |
surface.addVertex(createPoint(firstPoint.getX(), lastPoint.getY())); |
171 |
surface.closePrimitive();
|
|
155 |
surface.closePrimitive(); |
|
172 | 156 |
return selectWithPolygon(surface); |
173 | 157 |
} |
174 | 158 |
|
175 | 159 |
/** |
176 | 160 |
* Receives second point |
177 |
* |
|
161 |
*
|
|
178 | 162 |
* @param x |
179 | 163 |
* @param y |
180 | 164 |
* @return numFeatures selected |
181 | 165 |
*/ |
182 | 166 |
public long selectWithCircle(double x, double y, InputEvent event) { |
183 |
Geometry circle = createCircle(firstPoint, |
|
184 |
new Point2D.Double(x, y)); |
|
167 |
Geometry circle = createCircle(firstPoint, new Point2D.Double(x, y)); |
|
185 | 168 |
return selectWithPolygon(circle); |
186 | 169 |
} |
187 | 170 |
|
... | ... | |
190 | 173 |
PluginServices.getMDIManager().setWaitCursor(); |
191 | 174 |
|
192 | 175 |
if (getType().equals(PluginServices.getText(this, "inside_circle")) |
193 |
|| getType().equals( |
|
194 |
PluginServices.getText(this, "inside_polygon"))) { |
|
176 |
|| getType().equals(PluginServices.getText(this, "inside_polygon"))) { |
|
195 | 177 |
vle.selectContainsSurface(polygon); |
196 |
} else if (getType().equals( |
|
197 |
PluginServices.getText(this, "cross_circle")) |
|
198 |
|| getType().equals( |
|
199 |
PluginServices.getText(this, "cross_polygon"))) { |
|
200 |
vle.selectIntersectsSurface(polygon); |
|
201 |
} else if (getType().equals(PluginServices.getText(this, "out_circle")) |
|
202 |
|| getType() |
|
203 |
.equals(PluginServices.getText(this, "out_polygon")) |
|
204 |
|| getType().equals( |
|
205 |
PluginServices.getText(this, "out_rectangle"))) { |
|
206 |
vle.selectOutPolygon(polygon); |
|
207 |
} |
|
178 |
} else |
|
179 |
if (getType().equals(PluginServices.getText(this, "cross_circle")) |
|
180 |
|| getType().equals( |
|
181 |
PluginServices.getText(this, "cross_polygon"))) { |
|
182 |
vle.selectIntersectsSurface(polygon); |
|
183 |
} else |
|
184 |
if (getType() |
|
185 |
.equals(PluginServices.getText(this, "out_circle")) |
|
186 |
|| getType().equals( |
|
187 |
PluginServices.getText(this, "out_polygon")) |
|
188 |
|| getType().equals( |
|
189 |
PluginServices.getText(this, "out_rectangle"))) { |
|
190 |
vle.selectOutPolygon(polygon); |
|
191 |
} |
|
208 | 192 |
long countSelection = 0; |
209 | 193 |
try { |
210 |
countSelection = ((FeatureSelection) vle.getFeatureStore() |
|
211 |
.getSelection()).getSize(); |
|
194 |
countSelection = |
|
195 |
((FeatureSelection) vle.getFeatureStore().getSelection()) |
|
196 |
.getSize(); |
|
212 | 197 |
} catch (ReadException e) { |
213 | 198 |
LOG.error("Error reading the store", e); |
214 | 199 |
} catch (DataException e) { |
... | ... | |
227 | 212 |
/** |
228 | 213 |
* M?todo para dibujar la lo necesario para el estado en el que nos |
229 | 214 |
* encontremos. |
230 |
* |
|
215 |
*
|
|
231 | 216 |
* @param g |
232 | 217 |
* Graphics sobre el que dibujar. |
233 | 218 |
* @param selectedGeometries |
... | ... | |
239 | 224 |
*/ |
240 | 225 |
public void drawOperation(MapControlDrawer renderer, double x, double y) { |
241 | 226 |
ComplexSelectionCADToolState actualState = _fsm.getState(); |
242 |
String status = actualState.getName();
|
|
227 |
String status = actualState.getName(); |
|
243 | 228 |
|
244 |
if (status.equals("Selection.SecondPoint") || status.equals("Selection.SecondPointOutRectangle")) { |
|
245 |
drawRectangle(renderer, x, y); |
|
246 |
} else if (status.equals("Selection.SecondPointCircle")) { |
|
247 |
drawSecondPointCircle(renderer, x, y); |
|
248 |
} else if (status.equals("Selection.NextPointPolygon")) { |
|
249 |
drawNextPointPolygon(renderer, x, y); |
|
250 |
} else if (status.equals("Selection.WithHandlers")) { |
|
251 |
VectorialLayerEdited vle = getVLE(); |
|
252 |
drawWithHandlers(renderer, x, y, vle.getSelectedHandler()); |
|
253 |
} |
|
229 |
if (status.equals("Selection.SecondPoint") |
|
230 |
|| status.equals("Selection.SecondPointOutRectangle")) { |
|
231 |
drawRectangle(renderer, x, y); |
|
232 |
} else |
|
233 |
if (status.equals("Selection.SecondPointCircle")) { |
|
234 |
drawSecondPointCircle(renderer, x, y); |
|
235 |
} else |
|
236 |
if (status.equals("Selection.NextPointPolygon")) { |
|
237 |
drawNextPointPolygon(renderer, x, y); |
|
238 |
} else |
|
239 |
if (status.equals("Selection.WithHandlers")) { |
|
240 |
VectorialLayerEdited vle = getVLE(); |
|
241 |
drawWithHandlers(renderer, x, y, |
|
242 |
vle.getSelectedHandler()); |
|
243 |
} |
|
254 | 244 |
} |
255 | 245 |
|
256 |
|
|
257 | 246 |
/** |
258 | 247 |
* Draw method for the nexp point of a polygon. |
248 |
* |
|
259 | 249 |
* @param mapControlDrawer |
260 |
* object used to draw. |
|
250 |
* object used to draw.
|
|
261 | 251 |
* @param x |
262 |
* selected x coordinate. |
|
252 |
* selected x coordinate.
|
|
263 | 253 |
* @param y |
264 |
* selected y coordinate. |
|
254 |
* selected y coordinate.
|
|
265 | 255 |
*/ |
266 |
private void drawNextPointPolygon(MapControlDrawer mapControlDrawer, double x, double y){ |
|
256 |
private void drawNextPointPolygon(MapControlDrawer mapControlDrawer, |
|
257 |
double x, double y) { |
|
267 | 258 |
// Dibuja el pol?gono de selecci?n |
268 |
Geometry curve = createOrientablePrimitive(new Point2D.Double(x, y), Geometry.TYPES.CURVE); |
|
269 |
mapControlDrawer.draw(curve, mapControlManager.getGeometrySelectionSymbol()); |
|
259 |
Geometry curve = |
|
260 |
createOrientablePrimitive(new Point2D.Double(x, y), |
|
261 |
Geometry.TYPES.CURVE); |
|
262 |
mapControlDrawer.draw(curve, |
|
263 |
mapControlManager.getGeometrySelectionSymbol()); |
|
270 | 264 |
} |
271 | 265 |
|
272 | 266 |
/** |
273 | 267 |
* Draw method for the second point of a "rectangle". |
268 |
* |
|
274 | 269 |
* @param mapControlDrawer |
275 |
* object used to draw. |
|
270 |
* object used to draw.
|
|
276 | 271 |
* @param x |
277 |
* selected x coordinate. |
|
272 |
* selected x coordinate.
|
|
278 | 273 |
* @param y |
279 |
* selected y coordinate. |
|
274 |
* selected y coordinate.
|
|
280 | 275 |
*/ |
281 |
private void drawRectangle(MapControlDrawer mapControlDrawer, double x, double y){ |
|
282 |
Curve curve = createEnvelopeLikeCurve(firstPoint, new Point2D.Double(x, y)); |
|
276 |
private void drawRectangle(MapControlDrawer mapControlDrawer, double x, |
|
277 |
double y) { |
|
278 |
Curve curve = |
|
279 |
createEnvelopeLikeCurve(firstPoint, new Point2D.Double(x, y)); |
|
283 | 280 |
mapControlDrawer.draw(curve); |
284 | 281 |
} |
285 | 282 |
|
286 | 283 |
/** |
287 | 284 |
* Draw method to draw a geometry with handlers |
285 |
* |
|
288 | 286 |
* @param mapControlDrawer |
289 |
* object used to draw. |
|
287 |
* object used to draw.
|
|
290 | 288 |
* @param x |
291 |
* selected x coordinate. |
|
289 |
* selected x coordinate.
|
|
292 | 290 |
* @param y |
293 |
* selected y coordinate. |
|
291 |
* selected y coordinate.
|
|
294 | 292 |
* @param selectedHandlers |
295 |
* the selected handlers |
|
293 |
* the selected handlers
|
|
296 | 294 |
*/ |
297 |
private void drawWithHandlers(MapControlDrawer mapControlDrawer, double x, double y, ArrayList selectedHandlers){ |
|
295 |
private void drawWithHandlers(MapControlDrawer mapControlDrawer, double x, |
|
296 |
double y, ArrayList selectedHandlers) { |
|
298 | 297 |
// Movemos los handlers que hemos seleccionado |
299 | 298 |
// previamente dentro del m?todo select() |
300 | 299 |
double xPrev = 0; |
... | ... | |
309 | 308 |
// redibujamos la nueva geometr?a. |
310 | 309 |
for (int i = 0; i < rowselectedHandlers.size(); i++) { |
311 | 310 |
Feature rowEd = (Feature) rowselectedHandlers.get(i); |
312 |
Geometry geom = (rowEd.getDefaultGeometry()) |
|
313 |
.cloneGeometry(); |
|
311 |
Geometry geom = (rowEd.getDefaultGeometry()).cloneGeometry(); |
|
314 | 312 |
mapControlDrawer.setColor(Color.gray); |
315 |
mapControlDrawer.draw(geom, mapControlManager.getAxisReferenceSymbol()); |
|
313 |
mapControlDrawer.draw(geom, |
|
314 |
mapControlManager.getAxisReferenceSymbol()); |
|
316 | 315 |
} |
317 | 316 |
for (int k = 0; k < selectedHandlers.size(); k++) { |
318 | 317 |
Handler h = (Handler) selectedHandlers.get(k); |
... | ... | |
320 | 319 |
} |
321 | 320 |
} |
322 | 321 |
|
323 |
|
|
324 | 322 |
/** |
325 | 323 |
* Draw method for the second point of the "circle" option |
324 |
* |
|
326 | 325 |
* @param mapControlDrawer |
327 |
* object used to draw. |
|
326 |
* object used to draw.
|
|
328 | 327 |
* @param x |
329 |
* selected x coordinate. |
|
328 |
* selected x coordinate.
|
|
330 | 329 |
* @param y |
331 |
* selected y coordinate. |
|
330 |
* selected y coordinate.
|
|
332 | 331 |
*/ |
333 |
private void drawSecondPointCircle(MapControlDrawer mapControlDrawer, double x, double y){
|
|
334 |
Geometry circle = createCircle(firstPoint,
|
|
335 |
new Point2D.Double(x, y));
|
|
332 |
private void drawSecondPointCircle(MapControlDrawer mapControlDrawer, |
|
333 |
double x, double y) {
|
|
334 |
Geometry circle = createCircle(firstPoint, new Point2D.Double(x, y));
|
|
336 | 335 |
GeneralPathX gpx = new GeneralPathX(); |
337 | 336 |
gpx.append(circle.getInternalShape().getPathIterator(null), true); |
338 | 337 |
Geometry circleSel = createCurve(gpx); |
339 | 338 |
// Draw the circle |
340 |
mapControlDrawer.draw(circleSel, mapControlManager.getGeometrySelectionSymbol()); |
|
339 |
mapControlDrawer.draw(circleSel, |
|
340 |
mapControlManager.getGeometrySelectionSymbol()); |
|
341 | 341 |
} |
342 | 342 |
|
343 | 343 |
/** |
344 | 344 |
* Add a diferent option. |
345 |
* |
|
345 |
*
|
|
346 | 346 |
* @param sel |
347 | 347 |
* DOCUMENT ME! |
348 | 348 |
* @param s |
349 | 349 |
* Diferent option. |
350 | 350 |
*/ |
351 | 351 |
public void addOption(String s) { |
352 |
ComplexSelectionCADToolState actualState = (ComplexSelectionCADToolState) _fsm
|
|
353 |
.getPreviousState(); |
|
352 |
ComplexSelectionCADToolState actualState = |
|
353 |
(ComplexSelectionCADToolState) _fsm.getPreviousState();
|
|
354 | 354 |
String status = actualState.getName(); |
355 |
LOG.info("PREVIOUSSTATE =" + status);
|
|
355 |
LOG.info("PREVIOUSSTATE =" + status); |
|
356 | 356 |
LOG.info("STATUS ACTUAL = " + _fsm.getTransition()); |
357 | 357 |
if (s.equals(PluginServices.getText(this, "cancel"))) { |
358 | 358 |
init(); |
... | ... | |
362 | 362 |
LOG.error("Error canceling the selection", e); |
363 | 363 |
} |
364 | 364 |
return; |
365 |
} else if (s.equals(PluginServices.getText(this, "select_all"))) { |
|
366 |
//The selct all is made in the context |
|
367 |
init(); |
|
368 |
return; |
|
369 |
} |
|
365 |
} else |
|
366 |
if (s.equals(PluginServices.getText(this, "select_all"))) { |
|
367 |
// The selct all is made in the context |
|
368 |
init(); |
|
369 |
return; |
|
370 |
} |
|
370 | 371 |
if (status.equals("Selection.FirstPoint")) { |
371 | 372 |
setType(s); |
372 | 373 |
return; |
373 |
} else if (status.equals("Selection.NextPointPolygon")) { |
|
374 |
if (s.equals(PluginServices.getText(this, "end_polygon")) |
|
375 |
|| s.equalsIgnoreCase(PluginServices.getText(this, "ComplexSelectionCADTool.end"))) { |
|
376 |
selectCurrentSurface(); |
|
377 |
return; |
|
374 |
} else |
|
375 |
if (status.equals("Selection.NextPointPolygon")) { |
|
376 |
if (s.equals(PluginServices.getText(this, "end_polygon")) |
|
377 |
|| s.equalsIgnoreCase(PluginServices.getText(this, |
|
378 |
"ComplexSelectionCADTool.end"))) { |
|
379 |
selectCurrentSurface(); |
|
380 |
return; |
|
381 |
} |
|
378 | 382 |
} |
379 |
} |
|
380 | 383 |
init(); |
381 | 384 |
} |
382 | 385 |
|
383 |
public long selectCurrentSurface(){ |
|
384 |
Geometry surface = createOrientablePrimitive(null, Geometry.TYPES.SURFACE); |
|
386 |
public long selectCurrentSurface() { |
|
387 |
Geometry surface = |
|
388 |
createOrientablePrimitive(null, Geometry.TYPES.SURFACE); |
|
385 | 389 |
GeneralPathX gpx = new GeneralPathX(); |
386 | 390 |
gpx.append(surface.getPathIterator(null), true); |
387 | 391 |
if (gpx.isCCW()) { |
388 | 392 |
gpx.flip(); |
389 | 393 |
surface = createSurface(gpx); |
390 |
}
|
|
391 |
pointsPolygon.clear();
|
|
394 |
} |
|
395 |
pointsPolygon.clear(); |
|
392 | 396 |
return selectWithPolygon(surface); |
393 | 397 |
} |
394 | 398 |
|
... | ... | |
398 | 402 |
vle.selectAll(); |
399 | 403 |
long countSelection = 0; |
400 | 404 |
try { |
401 |
countSelection = ((FeatureSelection) vle.getFeatureStore() |
|
402 |
.getSelection()).getSize(); |
|
405 |
countSelection = |
|
406 |
((FeatureSelection) vle.getFeatureStore().getSelection()) |
|
407 |
.getSize(); |
|
403 | 408 |
} catch (ReadException e) { |
404 | 409 |
LOG.error("Error reading the store", e); |
405 | 410 |
} catch (DataException e) { |
... | ... | |
415 | 420 |
return countSelection; |
416 | 421 |
} |
417 | 422 |
|
418 |
private OrientablePrimitive createOrientablePrimitive(Point2D p, int geometryType) { |
|
423 |
private OrientablePrimitive createOrientablePrimitive(Point2D p, |
|
424 |
int geometryType) { |
|
419 | 425 |
Point2D[] points = (Point2D[]) pointsPolygon.toArray(new Point2D[0]); |
420 |
OrientablePrimitive orientablePrimitive = createOrientablePrimitive(geometryType); |
|
426 |
OrientablePrimitive orientablePrimitive = |
|
427 |
createOrientablePrimitive(geometryType); |
|
421 | 428 |
|
422 | 429 |
for (int i = 0; i < points.length; i++) { |
423 | 430 |
if (i == 0) { |
424 |
orientablePrimitive.addMoveToVertex(createPoint(points[i].getX(), points[i].getY())); |
|
431 |
orientablePrimitive.addMoveToVertex(createPoint( |
|
432 |
points[i].getX(), points[i].getY())); |
|
425 | 433 |
} else { |
426 |
orientablePrimitive.addVertex(createPoint(points[i].getX(), points[i].getY())); |
|
434 |
orientablePrimitive.addVertex(createPoint(points[i].getX(), |
|
435 |
points[i].getY())); |
|
427 | 436 |
} |
428 | 437 |
} |
429 | 438 |
if (p != null) { |
430 |
orientablePrimitive.addVertex(createPoint(p.getX(), p.getY()));
|
|
439 |
orientablePrimitive.addVertex(createPoint(p.getX(), p.getY())); |
|
431 | 440 |
} |
432 |
orientablePrimitive.closePrimitive();
|
|
441 |
orientablePrimitive.closePrimitive(); |
|
433 | 442 |
return orientablePrimitive; |
434 | 443 |
} |
435 | 444 |
|
... | ... | |
462 | 471 |
} |
463 | 472 |
long countSelection = 0; |
464 | 473 |
try { |
465 |
countSelection = ((FeatureSelection) vle.getFeatureStore() |
|
466 |
.getSelection()).getSize(); |
|
474 |
countSelection = |
|
475 |
((FeatureSelection) vle.getFeatureStore().getSelection()) |
|
476 |
.getSize(); |
|
467 | 477 |
} catch (ReadException e) { |
468 | 478 |
LOG.error("Error reading the store", e); |
469 | 479 |
} catch (DataException e) { |
... | ... | |
486 | 496 |
|
487 | 497 |
public void setType(String type) { |
488 | 498 |
if (type.equalsIgnoreCase(PluginServices.getText(this, |
489 |
"ComplexSelectionCADTool.outrectangle"))) { |
|
499 |
"ComplexSelectionCADTool.outrectangle"))) {
|
|
490 | 500 |
this.type = PluginServices.getText(this, "out_rectangle"); |
491 |
} else if (type.equalsIgnoreCase(PluginServices.getText(this, |
|
492 |
"ComplexSelectionCADTool.intropolygon"))) { |
|
493 |
this.type = PluginServices.getText(this, "inside_polygon"); |
|
494 |
} else if (type.equalsIgnoreCase(PluginServices.getText(this, |
|
495 |
"ComplexSelectionCADTool.crosspolygon"))) { |
|
496 |
this.type = PluginServices.getText(this, "cross_polygon"); |
|
497 |
} else if (type.equalsIgnoreCase(PluginServices.getText(this, |
|
498 |
"ComplexSelectionCADTool.outpolygon"))) { |
|
499 |
this.type = PluginServices.getText(this, "out_polygon"); |
|
500 |
} else if (type.equalsIgnoreCase(PluginServices.getText(this, |
|
501 |
"ComplexSelectionCADTool.introcircle"))) { |
|
502 |
this.type = PluginServices.getText(this, "inside_circle"); |
|
503 |
} else if (type.equalsIgnoreCase(PluginServices.getText(this, |
|
504 |
"ComplexSelectionCADTool.crosscircle"))) { |
|
505 |
this.type = PluginServices.getText(this, "cross_circle"); |
|
506 |
} else if (type.equalsIgnoreCase(PluginServices.getText(this, |
|
507 |
"ComplexSelectionCADTool.outcircle"))) { |
|
508 |
this.type = PluginServices.getText(this, "out_circle"); |
|
509 |
} else if (type.equals(PluginServices.getText(this, "select_all"))) { |
|
510 |
selectAll(); |
|
511 |
init(); |
|
512 |
} else { |
|
513 |
this.type = type; |
|
514 |
} |
|
501 |
} else |
|
502 |
if (type.equalsIgnoreCase(PluginServices.getText(this, |
|
503 |
"ComplexSelectionCADTool.intropolygon"))) { |
|
504 |
this.type = PluginServices.getText(this, "inside_polygon"); |
|
505 |
} else |
|
506 |
if (type.equalsIgnoreCase(PluginServices.getText(this, |
|
507 |
"ComplexSelectionCADTool.crosspolygon"))) { |
|
508 |
this.type = PluginServices.getText(this, "cross_polygon"); |
|
509 |
} else |
|
510 |
if (type.equalsIgnoreCase(PluginServices.getText(this, |
|
511 |
"ComplexSelectionCADTool.outpolygon"))) { |
|
512 |
this.type = PluginServices.getText(this, "out_polygon"); |
|
513 |
} else |
|
514 |
if (type.equalsIgnoreCase(PluginServices.getText(this, |
|
515 |
"ComplexSelectionCADTool.introcircle"))) { |
|
516 |
this.type = |
|
517 |
PluginServices.getText(this, "inside_circle"); |
|
518 |
} else |
|
519 |
if (type.equalsIgnoreCase(PluginServices.getText( |
|
520 |
this, "ComplexSelectionCADTool.crosscircle"))) { |
|
521 |
this.type = |
|
522 |
PluginServices |
|
523 |
.getText(this, "cross_circle"); |
|
524 |
} else |
|
525 |
if (type.equalsIgnoreCase(PluginServices |
|
526 |
.getText(this, |
|
527 |
"ComplexSelectionCADTool.outcircle"))) { |
|
528 |
this.type = |
|
529 |
PluginServices.getText(this, |
|
530 |
"out_circle"); |
|
531 |
} else |
|
532 |
if (type.equals(PluginServices.getText( |
|
533 |
this, "select_all"))) { |
|
534 |
selectAll(); |
|
535 |
init(); |
|
536 |
} else { |
|
537 |
this.type = type; |
|
538 |
} |
|
515 | 539 |
pointsPolygon.clear(); |
516 | 540 |
} |
517 | 541 |
|
518 | 542 |
public void transition(double x, double y, InputEvent event) { |
519 |
LOG.info("TRANSITION FROM STATE " + _fsm.getState() |
|
520 |
+ " x= " + x + " y=" + y);
|
|
543 |
LOG.info("TRANSITION FROM STATE " + _fsm.getState() + " x= " + x
|
|
544 |
+ " y=" + y); |
|
521 | 545 |
try { |
522 | 546 |
_fsm.addPoint(x, y, event); |
523 | 547 |
} catch (Exception e) { |
... | ... | |
528 | 552 |
|
529 | 553 |
public String getStatus() { |
530 | 554 |
try { |
531 |
ComplexSelectionCADToolState actualState = (ComplexSelectionCADToolState) _fsm
|
|
532 |
.getPreviousState(); |
|
555 |
ComplexSelectionCADToolState actualState = |
|
556 |
(ComplexSelectionCADToolState) _fsm.getPreviousState();
|
|
533 | 557 |
String status = actualState.getName(); |
534 | 558 |
|
535 | 559 |
return status; |
Also available in: Unified diff