Revision 4458 trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/MoveCADTool.java
MoveCADTool.java | ||
---|---|---|
45 | 45 |
import java.awt.event.InputEvent; |
46 | 46 |
import java.awt.geom.Point2D; |
47 | 47 |
import java.io.IOException; |
48 |
import java.util.ArrayList; |
|
48 | 49 |
|
49 | 50 |
import com.iver.andami.PluginServices; |
50 | 51 |
import com.iver.cit.gvsig.CADExtension; |
51 |
import com.iver.cit.gvsig.fmap.core.DefaultFeature;
|
|
52 |
import com.iver.cit.gvsig.fmap.core.IFeature;
|
|
52 | 53 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
53 | 54 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
55 |
import com.iver.cit.gvsig.fmap.edition.IRowEdited; |
|
54 | 56 |
import com.iver.cit.gvsig.fmap.edition.UtilFunctions; |
55 | 57 |
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter; |
56 | 58 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
... | ... | |
58 | 60 |
import com.iver.cit.gvsig.gui.cad.DefaultCADTool; |
59 | 61 |
import com.iver.cit.gvsig.gui.cad.tools.smc.MoveCADToolContext; |
60 | 62 |
import com.iver.cit.gvsig.gui.cad.tools.smc.MoveCADToolContext.MoveCADToolState; |
63 |
import com.iver.cit.gvsig.layers.VectorialLayerEdited; |
|
61 | 64 |
|
62 | 65 |
|
63 | 66 |
/** |
... | ... | |
130 | 133 |
MoveCADToolState actualState = (MoveCADToolState) _fsm.getPreviousState(); |
131 | 134 |
String status = actualState.getName(); |
132 | 135 |
VectorialEditableAdapter vea = getCadToolAdapter().getVectorialAdapter(); |
133 |
FBitSet selection = vea.getSelection(); |
|
136 |
VectorialLayerEdited vle = (VectorialLayerEdited) CADExtension |
|
137 |
.getEditionManager().getActiveLayerEdited(); |
|
138 |
ArrayList selectedRow = vle.getSelectedRow(); |
|
134 | 139 |
|
135 |
if (status.equals("Move.FirstPointToMove")) {
|
|
140 |
if (status.equals("Move.FirstPointToMove")) {
|
|
136 | 141 |
firstPoint = new Point2D.Double(x, y); |
137 | 142 |
} else if (status.equals("Move.SecondPointToMove")) { |
138 | 143 |
PluginServices.getMDIManager().setWaitCursor(); |
... | ... | |
140 | 145 |
vea.startComplexRow(); |
141 | 146 |
|
142 | 147 |
try { |
143 |
for (int i = selection.nextSetBit(0); i >= 0; |
|
144 |
i = selection.nextSetBit(i + 1)) { |
|
145 |
DefaultFeature fea = (DefaultFeature) vea.getRow(i) |
|
146 |
.getLinkedRow() |
|
147 |
.cloneRow(); |
|
148 |
// Movemos la geometr?a |
|
149 |
UtilFunctions.moveGeom(fea.getGeometry(), lastPoint.getX() - |
|
148 |
for (int i = 0; i < selectedRow.size(); i++) { |
|
149 |
IRowEdited edRow = (IRowEdited) selectedRow.get(i); |
|
150 |
IFeature feat = (IFeature) edRow.getLinkedRow().cloneRow(); |
|
151 |
IGeometry ig = feat.getGeometry(); |
|
152 |
if (ig == null) |
|
153 |
continue; |
|
154 |
// Movemos la geometr?a |
|
155 |
UtilFunctions.moveGeom(ig, lastPoint.getX() - |
|
150 | 156 |
firstPoint.getX(), lastPoint.getY() - firstPoint.getY()); |
151 | 157 |
|
152 |
vea.modifyRow(i,fea,getName());
|
|
153 |
}
|
|
154 |
|
|
158 |
vea.modifyRow(edRow.getIndex(),feat,getName());
|
|
159 |
}
|
|
160 |
selectedRow.clear(); |
|
155 | 161 |
vea.endComplexRow(); |
156 | 162 |
} catch (DriverIOException e) { |
157 |
// TODO Auto-generated catch block |
|
158 | 163 |
e.printStackTrace(); |
159 | 164 |
} catch (IOException e) { |
160 |
// TODO Auto-generated catch block |
|
161 | 165 |
e.printStackTrace(); |
162 | 166 |
} |
163 |
|
|
164 |
selection.clear(); |
|
165 | 167 |
PluginServices.getMDIManager().restoreCursor(); |
166 |
|
|
167 |
//ret = ret | copyStatus.transition("cancel"); |
|
168 | 168 |
} |
169 | 169 |
} |
170 | 170 |
|
... | ... | |
179 | 179 |
public void drawOperation(Graphics g, double x, double y) { |
180 | 180 |
MoveCADToolState actualState = ((MoveCADToolContext) _fsm).getState(); |
181 | 181 |
String status = actualState.getName(); |
182 |
VectorialEditableAdapter vea = getCadToolAdapter().getVectorialAdapter(); |
|
183 |
FBitSet selection = vea.getSelection(); |
|
184 |
|
|
185 |
try { |
|
186 |
drawHandlers(g, selection, |
|
187 |
getCadToolAdapter().getMapControl().getViewPort() |
|
188 |
.getAffineTransform()); |
|
189 |
} catch (DriverIOException e) { |
|
190 |
// TODO Auto-generated catch block |
|
191 |
e.printStackTrace(); |
|
192 |
} |
|
193 |
|
|
182 |
VectorialLayerEdited vle = (VectorialLayerEdited) CADExtension |
|
183 |
.getEditionManager().getActiveLayerEdited(); |
|
184 |
ArrayList selectedRow = vle.getSelectedRow(); |
|
185 |
drawHandlers(g, selectedRow, |
|
186 |
getCadToolAdapter().getMapControl().getViewPort() |
|
187 |
.getAffineTransform()); |
|
194 | 188 |
if (status.equals("Move.SecondPointToMove")) { |
195 |
///int dx = getCadToolAdapter().getMapControl().getViewPort().fromMapDistance(x - firstPoint.getX()); |
|
196 |
///int dy = -getCadToolAdapter().getMapControl().getViewPort().fromMapDistance(y - firstPoint.getY()); |
|
197 |
///Image img = getCadToolAdapter().getVectorialAdapter().getImage(); |
|
198 |
///g.drawImage(img, dx, dy, null); |
|
199 |
try { |
|
200 |
for (int i = selection.nextSetBit(0); i >= 0; |
|
201 |
i = selection.nextSetBit(i + 1)) { |
|
202 |
IGeometry geometry = vea.getShape(i).cloneGeometry(); |
|
203 |
// Movemos la geometr?a |
|
204 |
UtilFunctions.moveGeom(geometry, x - firstPoint.getX(), y - firstPoint.getY()); |
|
205 |
// geometry.move(x - firstPoint.getX(), y - firstPoint.getY()); |
|
206 |
geometry.draw((Graphics2D) g, |
|
207 |
getCadToolAdapter().getMapControl().getViewPort(), |
|
208 |
CADTool.drawingSymbol); |
|
209 |
} |
|
210 |
} catch (DriverIOException e) { |
|
211 |
e.printStackTrace(); |
|
212 |
} |
|
189 |
for (int i = 0; i < selectedRow.size(); i++) { |
|
190 |
IRowEdited edRow = (IRowEdited) selectedRow.get(i); |
|
191 |
IFeature feat = (IFeature) edRow.getLinkedRow(); |
|
192 |
IGeometry ig = feat.getGeometry().cloneGeometry(); |
|
193 |
if (ig == null) |
|
194 |
continue; |
|
195 |
// Movemos la geometr?a |
|
196 |
UtilFunctions.moveGeom(ig, x - firstPoint.getX(), y - firstPoint.getY()); |
|
197 |
ig.draw((Graphics2D) g, |
|
198 |
getCadToolAdapter().getMapControl().getViewPort(), |
|
199 |
CADTool.drawingSymbol); |
|
200 |
} |
|
213 | 201 |
} |
214 | 202 |
} |
215 | 203 |
|
Also available in: Unified diff