Revision 37138 branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/gui/cad/tools/RotateCADTool.java
RotateCADTool.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 |
|
43 |
import java.awt.Image; |
|
44 | 24 |
import java.awt.event.InputEvent; |
45 | 25 |
import java.awt.geom.AffineTransform; |
46 | 26 |
import java.awt.geom.Point2D; |
... | ... | |
56 | 36 |
import org.gvsig.editing.layers.VectorialLayerEdited; |
57 | 37 |
import org.gvsig.fmap.dal.exception.DataException; |
58 | 38 |
import org.gvsig.fmap.dal.exception.ReadException; |
59 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
60 | 39 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
61 | 40 |
import org.gvsig.fmap.dal.feature.Feature; |
62 | 41 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
63 | 42 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
64 | 43 |
import org.gvsig.fmap.geom.Geometry; |
65 | 44 |
import org.gvsig.fmap.geom.util.UtilFunctions; |
66 |
import org.gvsig.fmap.mapcontext.ViewPort; |
|
67 | 45 |
import org.gvsig.fmap.mapcontrol.MapControlDrawer; |
46 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
68 | 47 |
|
69 |
|
|
70 | 48 |
/** |
71 | 49 |
* DOCUMENT ME! |
72 |
* |
|
50 |
*
|
|
73 | 51 |
* @author Vicente Caballero Navarro |
74 | 52 |
*/ |
75 | 53 |
public class RotateCADTool extends DefaultCADTool { |
76 |
private RotateCADToolContext _fsm; |
|
77 |
private Point2D firstPoint; |
|
78 |
private Point2D lastPoint; |
|
79 | 54 |
|
80 |
/** |
|
81 |
* Crea un nuevo PolylineCADTool. |
|
82 |
*/ |
|
83 |
public RotateCADTool() { |
|
84 |
} |
|
55 |
private RotateCADToolContext _fsm; |
|
56 |
private Point2D firstPoint; |
|
57 |
private Point2D lastPoint; |
|
85 | 58 |
|
86 |
/** |
|
87 |
* M?todo de incio, para poner el c?digo de todo lo que se requiera de una |
|
88 |
* carga previa a la utilizaci?n de la herramienta. |
|
89 |
*/ |
|
90 |
public void init() { |
|
91 |
_fsm = new RotateCADToolContext(this); |
|
92 |
} |
|
59 |
/** |
|
60 |
* Crea un nuevo PolylineCADTool. |
|
61 |
*/ |
|
62 |
public RotateCADTool() { |
|
63 |
} |
|
93 | 64 |
|
94 |
/* |
|
95 |
* (non-Javadoc) |
|
96 |
* |
|
97 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, |
|
98 |
* double, double) |
|
99 |
*/ |
|
100 |
public void transition(double x, double y, InputEvent event) { |
|
101 |
_fsm.addPoint(x, y, event); |
|
102 |
} |
|
65 |
/** |
|
66 |
* M?todo de incio, para poner el c?digo de todo lo que se requiera de una |
|
67 |
* carga previa a la utilizaci?n de la herramienta. |
|
68 |
*/ |
|
69 |
public void init() { |
|
70 |
_fsm = new RotateCADToolContext(this); |
|
71 |
} |
|
103 | 72 |
|
104 |
/* |
|
105 |
* (non-Javadoc) |
|
106 |
* |
|
107 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, |
|
108 |
* double) |
|
109 |
*/ |
|
110 |
public void transition(double d) { |
|
111 |
_fsm.addValue(d); |
|
112 |
} |
|
73 |
/* |
|
74 |
* (non-Javadoc) |
|
75 |
* |
|
76 |
* @see |
|
77 |
* com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap |
|
78 |
* .layers.FBitSet, |
|
79 |
* double, double) |
|
80 |
*/ |
|
81 |
public void transition(double x, double y, InputEvent event) { |
|
82 |
_fsm.addPoint(x, y, event); |
|
83 |
} |
|
113 | 84 |
|
114 |
/*
|
|
115 |
* (non-Javadoc)
|
|
116 |
*
|
|
117 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet,
|
|
118 |
* java.lang.String)
|
|
119 |
*/
|
|
120 |
public void transition(String s) throws CommandException {
|
|
121 |
if (!super.changeCommand(s)) {
|
|
122 |
_fsm.addOption(s);
|
|
123 |
}
|
|
124 |
}
|
|
85 |
/*
|
|
86 |
* (non-Javadoc)
|
|
87 |
*
|
|
88 |
* @see
|
|
89 |
* com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap
|
|
90 |
* .layers.FBitSet,
|
|
91 |
* double)
|
|
92 |
*/
|
|
93 |
public void transition(double d) {
|
|
94 |
_fsm.addValue(d);
|
|
95 |
}
|
|
125 | 96 |
|
126 |
/** |
|
127 |
* DOCUMENT ME! |
|
128 |
*/ |
|
129 |
public void selection() { |
|
130 |
FeatureSet selection = null; |
|
131 |
try { |
|
132 |
selection = (FeatureSet) getVLE().getFeatureStore().getSelection(); |
|
97 |
/* |
|
98 |
* (non-Javadoc) |
|
99 |
* |
|
100 |
* @see |
|
101 |
* com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap |
|
102 |
* .layers.FBitSet, |
|
103 |
* java.lang.String) |
|
104 |
*/ |
|
105 |
public void transition(String s) throws CommandException { |
|
106 |
if (!super.changeCommand(s)) { |
|
107 |
_fsm.addOption(s); |
|
108 |
} |
|
109 |
} |
|
133 | 110 |
|
134 |
if (selection.getSize() == 0 |
|
135 |
&& !CADExtension |
|
136 |
.getCADTool() |
|
137 |
.getClass() |
|
138 |
.getName() |
|
139 |
.equals( |
|
140 |
"com.iver.cit.gvsig.gui.cad.tools.SelectionCADTool")) { |
|
141 |
CADExtension.setCADTool("_selection", false); |
|
142 |
((SelectionCADTool) CADExtension.getCADTool()) |
|
143 |
.setNextTool("_rotate"); |
|
144 |
} |
|
145 |
} catch (ReadException e) { |
|
146 |
// TODO Auto-generated catch block |
|
147 |
e.printStackTrace(); |
|
148 |
} catch (DataException e) { |
|
149 |
// TODO Auto-generated catch block |
|
150 |
e.printStackTrace(); |
|
151 |
} |
|
152 |
} |
|
111 |
/** |
|
112 |
* DOCUMENT ME! |
|
113 |
*/ |
|
114 |
public void selection() { |
|
115 |
FeatureSet selection = null; |
|
116 |
try { |
|
117 |
selection = (FeatureSet) getVLE().getFeatureStore().getSelection(); |
|
153 | 118 |
|
154 |
/** |
|
155 |
* Equivale al transition del prototipo pero sin pasarle como par?metro el |
|
156 |
* editableFeatureSource que ya estar? creado. |
|
157 |
* |
|
158 |
* @param x |
|
159 |
* par?metro x del punto que se pase en esta transici?n. |
|
160 |
* @param y |
|
161 |
* par?metro y del punto que se pase en esta transici?n. |
|
162 |
*/ |
|
163 |
public void addPoint(double x, double y, InputEvent event) { |
|
164 |
RotateCADToolState actualState = (RotateCADToolState) _fsm |
|
165 |
.getPreviousState(); |
|
166 |
String status = actualState.getName(); |
|
167 |
VectorialLayerEdited vle = getVLE(); |
|
168 |
FeatureStore featureStore = null; |
|
169 |
try { |
|
170 |
featureStore = vle.getFeatureStore(); |
|
171 |
} catch (ReadException e1) { |
|
172 |
// TODO Auto-generated catch block |
|
173 |
e1.printStackTrace(); |
|
174 |
} |
|
175 |
DisposableIterator iterator = null; |
|
176 |
try { |
|
177 |
FeatureSet selection = (FeatureSet) featureStore.getSelection();// getSelectedRows(); |
|
178 |
ArrayList selectedRowAux = new ArrayList(); |
|
119 |
if (selection.getSize() == 0 |
|
120 |
&& !CADExtension |
|
121 |
.getCADTool() |
|
122 |
.getClass() |
|
123 |
.getName() |
|
124 |
.equals("com.iver.cit.gvsig.gui.cad.tools.SelectionCADTool")) { |
|
125 |
CADExtension.setCADTool("_selection", false); |
|
126 |
((SelectionCADTool) CADExtension.getCADTool()) |
|
127 |
.setNextTool("_rotate"); |
|
128 |
} |
|
129 |
} catch (ReadException e) { |
|
130 |
// TODO Auto-generated catch block |
|
131 |
e.printStackTrace(); |
|
132 |
} catch (DataException e) { |
|
133 |
// TODO Auto-generated catch block |
|
134 |
e.printStackTrace(); |
|
135 |
} |
|
136 |
} |
|
179 | 137 |
|
180 |
if (status.equals("Rotate.PointMain")) { |
|
181 |
firstPoint = new Point2D.Double(x, y); |
|
182 |
} else if (status.equals("Rotate.AngleOrPoint")) { |
|
183 |
PluginServices.getMDIManager().setWaitCursor(); |
|
184 |
lastPoint = new Point2D.Double(x, y); |
|
138 |
/** |
|
139 |
* Equivale al transition del prototipo pero sin pasarle como par?metro el |
|
140 |
* editableFeatureSource que ya estar? creado. |
|
141 |
* |
|
142 |
* @param x |
|
143 |
* par?metro x del punto que se pase en esta transici?n. |
|
144 |
* @param y |
|
145 |
* par?metro y del punto que se pase en esta transici?n. |
|
146 |
*/ |
|
147 |
public void addPoint(double x, double y, InputEvent event) { |
|
148 |
RotateCADToolState actualState = |
|
149 |
(RotateCADToolState) _fsm.getPreviousState(); |
|
150 |
String status = actualState.getName(); |
|
151 |
VectorialLayerEdited vle = getVLE(); |
|
152 |
FeatureStore featureStore = null; |
|
153 |
try { |
|
154 |
featureStore = vle.getFeatureStore(); |
|
155 |
} catch (ReadException e1) { |
|
156 |
// TODO Auto-generated catch block |
|
157 |
e1.printStackTrace(); |
|
158 |
} |
|
159 |
DisposableIterator iterator = null; |
|
160 |
try { |
|
161 |
FeatureSet selection = (FeatureSet) featureStore.getSelection();// getSelectedRows(); |
|
162 |
ArrayList selectedRowAux = new ArrayList(); |
|
185 | 163 |
|
186 |
double w; |
|
187 |
double h; |
|
188 |
w = lastPoint.getX() - firstPoint.getX(); |
|
189 |
h = lastPoint.getY() - firstPoint.getY(); |
|
164 |
if (status.equals("Rotate.PointMain")) { |
|
165 |
firstPoint = new Point2D.Double(x, y); |
|
166 |
} else |
|
167 |
if (status.equals("Rotate.AngleOrPoint")) { |
|
168 |
PluginServices.getMDIManager().setWaitCursor(); |
|
169 |
lastPoint = new Point2D.Double(x, y); |
|
190 | 170 |
|
191 |
featureStore.beginEditingGroup(getName()); |
|
192 |
try { |
|
193 |
iterator = selection.iterator(); |
|
194 |
while (iterator.hasNext()) { |
|
195 |
Feature feature = (Feature) iterator.next(); |
|
171 |
double w; |
|
172 |
double h; |
|
173 |
w = lastPoint.getX() - firstPoint.getX(); |
|
174 |
h = lastPoint.getY() - firstPoint.getY(); |
|
196 | 175 |
|
197 |
// } |
|
198 |
// for (int i = 0; i < selectedRow.size(); i++) { |
|
199 |
// DefaultRowEdited row=(DefaultRowEdited) |
|
200 |
// selectedRow.get(i); |
|
201 |
// DefaultFeature fea = (DefaultFeature) |
|
202 |
// row.getLinkedRow().cloneRow(); |
|
203 |
// Rotamos la geometry |
|
204 |
Geometry geometry = (feature.getDefaultGeometry()) |
|
205 |
.cloneGeometry(); |
|
206 |
EditableFeature eFeature = feature.getEditable(); |
|
207 |
UtilFunctions.rotateGeom(geometry, -Math.atan2(w, h) |
|
208 |
+ (Math.PI / 2), firstPoint.getX(), firstPoint |
|
209 |
.getY()); |
|
210 |
eFeature.setGeometry(featureStore |
|
211 |
.getDefaultFeatureType() |
|
212 |
.getDefaultGeometryAttributeName(), geometry); |
|
213 |
featureStore.update(eFeature); |
|
214 |
// vea.modifyRow(row.getIndex(), fea, |
|
215 |
// getName(),EditionEvent.GRAPHIC); |
|
216 |
// selectedRowAux.add(new |
|
217 |
// DefaultRowEdited(fea,IRowEdited.STATUS_MODIFIED,row.getIndex())); |
|
218 |
} |
|
219 |
} finally { |
|
176 |
featureStore.beginEditingGroup(getName()); |
|
177 |
try { |
|
178 |
iterator = selection.iterator(); |
|
179 |
while (iterator.hasNext()) { |
|
180 |
Feature feature = (Feature) iterator.next(); |
|
220 | 181 |
|
221 |
featureStore.endEditingGroup(); |
|
222 |
} |
|
223 |
// vle.setSelectionCache(VectorialLayerEdited.NOTSAVEPREVIOUS, |
|
224 |
// selectedRowAux); |
|
225 |
// clearSelection(); |
|
226 |
// selectedRow.addAll(selectedRowAux); |
|
182 |
// } |
|
183 |
// for (int i = 0; i < selectedRow.size(); i++) { |
|
184 |
// DefaultRowEdited row=(DefaultRowEdited) |
|
185 |
// selectedRow.get(i); |
|
186 |
// DefaultFeature fea = (DefaultFeature) |
|
187 |
// row.getLinkedRow().cloneRow(); |
|
188 |
// Rotamos la geometry |
|
189 |
Geometry geometry = |
|
190 |
(feature.getDefaultGeometry()).cloneGeometry(); |
|
191 |
EditableFeature eFeature = feature.getEditable(); |
|
192 |
UtilFunctions.rotateGeom(geometry, |
|
193 |
-Math.atan2(w, h) + (Math.PI / 2), |
|
194 |
firstPoint.getX(), firstPoint.getY()); |
|
195 |
eFeature.setGeometry(featureStore |
|
196 |
.getDefaultFeatureType() |
|
197 |
.getDefaultGeometryAttributeName(), geometry); |
|
198 |
featureStore.update(eFeature); |
|
199 |
// vea.modifyRow(row.getIndex(), fea, |
|
200 |
// getName(),EditionEvent.GRAPHIC); |
|
201 |
// selectedRowAux.add(new |
|
202 |
// DefaultRowEdited(fea,IRowEdited.STATUS_MODIFIED,row.getIndex())); |
|
203 |
} |
|
204 |
} finally { |
|
227 | 205 |
|
228 |
PluginServices.getMDIManager().restoreCursor(); |
|
229 |
} |
|
230 |
} catch (DataException e) { |
|
231 |
NotificationManager.addError(e.getMessage(), e); |
|
232 |
} finally { |
|
233 |
if (iterator != null) { |
|
234 |
iterator.dispose(); |
|
235 |
} |
|
236 |
} |
|
237 |
} |
|
206 |
featureStore.endEditingGroup(); |
|
207 |
} |
|
208 |
// vle.setSelectionCache(VectorialLayerEdited.NOTSAVEPREVIOUS, |
|
209 |
// selectedRowAux); |
|
210 |
// clearSelection(); |
|
211 |
// selectedRow.addAll(selectedRowAux); |
|
238 | 212 |
|
239 |
/** |
|
240 |
* M?todo para dibujar la lo necesario para el estado en el que nos |
|
241 |
* encontremos. |
|
242 |
* |
|
243 |
* @param g |
|
244 |
* Graphics sobre el que dibujar. |
|
245 |
* @param x |
|
246 |
* par?metro x del punto que se pase para dibujar. |
|
247 |
* @param y |
|
248 |
* par?metro x del punto que se pase para dibujar. |
|
249 |
*/ |
|
250 |
public void drawOperation(MapControlDrawer renderer, double x, double y) { |
|
251 |
RotateCADToolState actualState = _fsm.getState(); |
|
252 |
String status = actualState.getName(); |
|
213 |
PluginServices.getMDIManager().restoreCursor(); |
|
214 |
} |
|
215 |
} catch (DataException e) { |
|
216 |
NotificationManager.addError(e.getMessage(), e); |
|
217 |
} finally { |
|
218 |
if (iterator != null) { |
|
219 |
iterator.dispose(); |
|
220 |
} |
|
221 |
} |
|
222 |
} |
|
253 | 223 |
|
254 |
if (status.equals("Rotate.AngleOrPoint")) { |
|
255 |
drawAndRotateSelectedGeometries(renderer, firstPoint, x, y); |
|
256 |
renderer.drawLine(firstPoint, new Point2D.Double(x, y), |
|
257 |
mapControlManager.getAxisReferenceSymbol()); |
|
258 |
} |
|
259 |
} |
|
224 |
/** |
|
225 |
* M?todo para dibujar la lo necesario para el estado en el que nos |
|
226 |
* encontremos. |
|
227 |
* |
|
228 |
* @param g |
|
229 |
* Graphics sobre el que dibujar. |
|
230 |
* @param x |
|
231 |
* par?metro x del punto que se pase para dibujar. |
|
232 |
* @param y |
|
233 |
* par?metro x del punto que se pase para dibujar. |
|
234 |
*/ |
|
235 |
public void drawOperation(MapControlDrawer renderer, double x, double y) { |
|
236 |
RotateCADToolState actualState = _fsm.getState(); |
|
237 |
String status = actualState.getName(); |
|
260 | 238 |
|
261 |
/** |
|
262 |
* Add a diferent option. |
|
263 |
* |
|
264 |
* @param s |
|
265 |
* Diferent option. |
|
266 |
*/ |
|
267 |
public void addOption(String s) { |
|
268 |
} |
|
239 |
if (status.equals("Rotate.AngleOrPoint")) { |
|
240 |
drawAndRotateSelectedGeometries(renderer, firstPoint, x, y); |
|
241 |
renderer.drawLine(firstPoint, new Point2D.Double(x, y), |
|
242 |
mapControlManager.getAxisReferenceSymbol()); |
|
243 |
} |
|
244 |
} |
|
269 | 245 |
|
270 |
/* |
|
271 |
* (non-Javadoc) |
|
272 |
* |
|
273 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#addvalue(double) |
|
274 |
*/ |
|
275 |
public void addValue(double d) { |
|
276 |
RotateCADToolState actualState = (RotateCADToolState) _fsm |
|
277 |
.getPreviousState(); |
|
278 |
String status = actualState.getName(); |
|
279 |
VectorialLayerEdited vle = getVLE(); |
|
280 |
FeatureStore featureStore = null; |
|
281 |
try { |
|
282 |
featureStore = vle.getFeatureStore(); |
|
283 |
} catch (ReadException e1) { |
|
284 |
// TODO Auto-generated catch block |
|
285 |
e1.printStackTrace(); |
|
286 |
} |
|
287 |
DisposableIterator iterator = null; |
|
288 |
try { |
|
289 |
FeatureSet selection = (FeatureSet) featureStore.getSelection();// getSelectedRows(); |
|
246 |
/** |
|
247 |
* Add a diferent option. |
|
248 |
* |
|
249 |
* @param s |
|
250 |
* Diferent option. |
|
251 |
*/ |
|
252 |
public void addOption(String s) { |
|
253 |
} |
|
290 | 254 |
|
291 |
if (status.equals("Rotate.AngleOrPoint")) { |
|
255 |
/* |
|
256 |
* (non-Javadoc) |
|
257 |
* |
|
258 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#addvalue(double) |
|
259 |
*/ |
|
260 |
public void addValue(double d) { |
|
261 |
RotateCADToolState actualState = |
|
262 |
(RotateCADToolState) _fsm.getPreviousState(); |
|
263 |
String status = actualState.getName(); |
|
264 |
VectorialLayerEdited vle = getVLE(); |
|
265 |
FeatureStore featureStore = null; |
|
266 |
try { |
|
267 |
featureStore = vle.getFeatureStore(); |
|
268 |
} catch (ReadException e1) { |
|
269 |
// TODO Auto-generated catch block |
|
270 |
e1.printStackTrace(); |
|
271 |
} |
|
272 |
DisposableIterator iterator = null; |
|
273 |
try { |
|
274 |
FeatureSet selection = (FeatureSet) featureStore.getSelection();// getSelectedRows(); |
|
292 | 275 |
|
293 |
featureStore.beginEditingGroup(getName()); |
|
294 |
try { |
|
295 |
// /ArrayList selectedRowAux=new ArrayList(); |
|
296 |
iterator = selection.iterator(); |
|
297 |
while (iterator.hasNext()) { |
|
298 |
Feature feature = (Feature) iterator.next(); |
|
276 |
if (status.equals("Rotate.AngleOrPoint")) { |
|
299 | 277 |
|
300 |
// } |
|
301 |
// for (int i = 0; i < selectedRow.size(); i++) { |
|
302 |
// DefaultRowEdited row=(DefaultRowEdited) |
|
303 |
// selectedRow.get(i); |
|
304 |
// DefaultFeature fea = (DefaultFeature) |
|
305 |
// row.getLinkedRow().cloneRow(); |
|
306 |
// Rotamos la geometry |
|
307 |
AffineTransform at = new AffineTransform(); |
|
308 |
at.rotate(Math.toRadians(d), firstPoint.getX(), |
|
309 |
firstPoint.getY()); |
|
310 |
Geometry geometry = (feature.getDefaultGeometry()) |
|
311 |
.cloneGeometry(); |
|
312 |
EditableFeature eFeature = feature.getEditable(); |
|
313 |
geometry.transform(at); |
|
314 |
eFeature.setGeometry(featureStore |
|
315 |
.getDefaultFeatureType() |
|
316 |
.getDefaultGeometryAttributeName(), geometry); |
|
317 |
featureStore.update(eFeature); |
|
318 |
// vea.modifyRow(row.getIndex(), |
|
319 |
// fea,getName(),EditionEvent.GRAPHIC); |
|
320 |
// /selectedRowAux.add(new |
|
321 |
// DefaultRowEdited(fea,IRowEdited.STATUS_MODIFIED,index)); |
|
322 |
} |
|
323 |
} finally { |
|
324 |
featureStore.endEditingGroup(); |
|
325 |
} |
|
326 |
clearSelection(); |
|
327 |
// /selectedRow=selectedRowAux; |
|
278 |
featureStore.beginEditingGroup(getName()); |
|
279 |
try { |
|
280 |
// /ArrayList selectedRowAux=new ArrayList(); |
|
281 |
iterator = selection.iterator(); |
|
282 |
while (iterator.hasNext()) { |
|
283 |
Feature feature = (Feature) iterator.next(); |
|
328 | 284 |
|
329 |
} |
|
330 |
} catch (DataException e) { |
|
331 |
NotificationManager.addError(e.getMessage(), e); |
|
332 |
} finally { |
|
333 |
if (iterator != null) { |
|
334 |
iterator.dispose(); |
|
335 |
} |
|
336 |
} |
|
337 |
} |
|
285 |
// } |
|
286 |
// for (int i = 0; i < selectedRow.size(); i++) { |
|
287 |
// DefaultRowEdited row=(DefaultRowEdited) |
|
288 |
// selectedRow.get(i); |
|
289 |
// DefaultFeature fea = (DefaultFeature) |
|
290 |
// row.getLinkedRow().cloneRow(); |
|
291 |
// Rotamos la geometry |
|
292 |
AffineTransform at = new AffineTransform(); |
|
293 |
at.rotate(Math.toRadians(d), firstPoint.getX(), |
|
294 |
firstPoint.getY()); |
|
295 |
Geometry geometry = |
|
296 |
(feature.getDefaultGeometry()).cloneGeometry(); |
|
297 |
EditableFeature eFeature = feature.getEditable(); |
|
298 |
geometry.transform(at); |
|
299 |
eFeature.setGeometry(featureStore |
|
300 |
.getDefaultFeatureType() |
|
301 |
.getDefaultGeometryAttributeName(), geometry); |
|
302 |
featureStore.update(eFeature); |
|
303 |
// vea.modifyRow(row.getIndex(), |
|
304 |
// fea,getName(),EditionEvent.GRAPHIC); |
|
305 |
// /selectedRowAux.add(new |
|
306 |
// DefaultRowEdited(fea,IRowEdited.STATUS_MODIFIED,index)); |
|
307 |
} |
|
308 |
} finally { |
|
309 |
featureStore.endEditingGroup(); |
|
310 |
} |
|
311 |
clearSelection(); |
|
312 |
// /selectedRow=selectedRowAux; |
|
338 | 313 |
|
339 |
public String getName() { |
|
340 |
return PluginServices.getText(this, "rotate_"); |
|
341 |
} |
|
314 |
} |
|
315 |
} catch (DataException e) { |
|
316 |
NotificationManager.addError(e.getMessage(), e); |
|
317 |
} finally { |
|
318 |
if (iterator != null) { |
|
319 |
iterator.dispose(); |
|
320 |
} |
|
321 |
} |
|
322 |
} |
|
342 | 323 |
|
343 |
public String toString() {
|
|
344 |
return "_rotate";
|
|
345 |
}
|
|
324 |
public String getName() {
|
|
325 |
return PluginServices.getText(this, "rotate_");
|
|
326 |
}
|
|
346 | 327 |
|
328 |
public String toString() { |
|
329 |
return "_rotate"; |
|
330 |
} |
|
331 |
|
|
347 | 332 |
} |
Also available in: Unified diff