Revision 5985 trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/CADToolAdapter.java
CADToolAdapter.java | ||
---|---|---|
32 | 32 |
import com.iver.cit.gvsig.fmap.core.v02.FSymbol; |
33 | 33 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
34 | 34 |
import com.iver.cit.gvsig.fmap.edition.EditionEvent; |
35 |
import com.iver.cit.gvsig.fmap.edition.IRowEdited; |
|
35 | 36 |
import com.iver.cit.gvsig.fmap.edition.UtilFunctions; |
36 | 37 |
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter; |
37 | 38 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
... | ... | |
168 | 169 |
*/ |
169 | 170 |
private double adjustToHandler(Point2D point, |
170 | 171 |
Point2D mapHandlerAdjustedPoint) { |
171 |
|
|
172 |
|
|
172 | 173 |
if (!isRefentEnabled()) |
173 | 174 |
return Double.MAX_VALUE; |
174 | 175 |
|
... | ... | |
176 | 177 |
if (!(aux instanceof VectorialLayerEdited)) |
177 | 178 |
return Double.MAX_VALUE; |
178 | 179 |
VectorialLayerEdited vle = (VectorialLayerEdited) aux; |
179 |
|
|
180 |
|
|
180 | 181 |
ArrayList snappers = vle.getSnappers(); |
181 | 182 |
ArrayList layersToSnap = vle.getLayersToSnap(); |
182 | 183 |
|
... | ... | |
199 | 200 |
mapPoint.getY() - mapTolerance / 2, mapTolerance, mapTolerance); |
200 | 201 |
|
201 | 202 |
Envelope e = FConverter.convertRectangle2DtoEnvelope(r); |
202 |
|
|
203 |
|
|
203 | 204 |
usedSnap = null; |
204 | 205 |
Point2D lastPoint = null; |
205 | 206 |
if (previousPoint != null) |
... | ... | |
217 | 218 |
for (int i = 0; i < snappers.size(); i++) |
218 | 219 |
{ |
219 | 220 |
ISnapper theSnapper = (ISnapper) snappers.get(i); |
220 |
|
|
221 |
|
|
221 | 222 |
if (usedSnap != null) |
222 | 223 |
{ |
223 | 224 |
// Si ya tenemos un snap y es de alta prioridad, cogemos ese. (A no ser que en otra capa encontremos un snapper mejor) |
224 | 225 |
if (theSnapper.getPriority() < usedSnap.getPriority()) |
225 |
break;
|
|
226 |
break; |
|
226 | 227 |
} |
227 |
|
|
228 |
|
|
228 | 229 |
SnappingVisitor snapVisitor = new SnappingVisitor(theSnapper, point, mapTolerance, lastPoint); |
229 | 230 |
// System.out.println("Cache size = " + cache.size()); |
230 | 231 |
cache.query(e, snapVisitor); |
231 |
|
|
232 |
|
|
232 | 233 |
if (snapVisitor.getSnapPoint() != null) { |
233 | 234 |
if (minDist > snapVisitor.getMinDist()) |
234 | 235 |
{ |
... | ... | |
274 | 275 |
calculateSnapPoint(e.getPoint()); |
275 | 276 |
|
276 | 277 |
showCoords(e.getPoint()); |
277 |
|
|
278 |
|
|
278 | 279 |
getMapControl().repaint(); |
279 | 280 |
} |
280 | 281 |
|
... | ... | |
306 | 307 |
MainFrame mF = PluginServices.getMainFrame(); |
307 | 308 |
|
308 | 309 |
if (mF != null) |
309 |
{
|
|
310 |
{ |
|
310 | 311 |
mF.getStatusBar().setMessage("1", |
311 | 312 |
FConstant.NAMES[vp.getDistanceUnits()]); |
312 | 313 |
mF.getStatusBar().setMessage("6", "1:"+mapControl.getMapContext().getScaleView()); |
... | ... | |
366 | 367 |
if (usedSnap != null) |
367 | 368 |
{ |
368 | 369 |
usedSnap.draw(g, adjustedPoint); |
369 |
|
|
370 |
|
|
370 | 371 |
Graphics2D g2 = (Graphics2D) g; |
371 | 372 |
FontMetrics metrics = g2.getFontMetrics(); |
372 | 373 |
int w = metrics.stringWidth(usedSnap.getToolTipText()) + 5; |
373 | 374 |
int h = metrics.getMaxAscent() + 5; |
374 | 375 |
int x = (int)p.getX()+9; |
375 | 376 |
int y = (int)p.getY()- 7; |
376 |
|
|
377 |
|
|
377 | 378 |
g2.setColor(theTipColor ); |
378 | 379 |
g2.fillRect(x, y-h, w, h); |
379 | 380 |
g2.setColor(Color.BLACK); |
380 | 381 |
g2.drawRect(x, y-h, w, h); |
381 | 382 |
g2.drawString(usedSnap.getToolTipText(), x+3, y-3); |
382 |
|
|
383 | 383 |
|
384 |
|
|
384 | 385 |
// getMapControl().setToolTipText(usedSnap.getToolTipText()); |
385 | 386 |
} |
386 | 387 |
|
... | ... | |
680 | 681 |
public void setRefentEnabled(boolean activated) { |
681 | 682 |
bRefent = activated; |
682 | 683 |
} |
683 |
|
|
684 |
|
|
684 | 685 |
public boolean isRefentEnabled() |
685 | 686 |
{ |
686 | 687 |
return bRefent; |
... | ... | |
807 | 808 |
indexesToDel[j++] = i; |
808 | 809 |
// /vea.removeRow(i); |
809 | 810 |
} |
810 |
/* |
|
811 |
* VectorialLayerEdited vle = (VectorialLayerEdited) CADExtension
|
|
812 |
* .getEditionManager().getActiveLayerEdited(); ArrayList
|
|
813 |
* selectedRow = vle.getSelectedRow();
|
|
814 |
*
|
|
815 |
* int[] indexesToDel = new int[selectedRow.size()]; for (int i = 0;
|
|
816 |
* i < selectedRow.size(); i++) { IRowEdited edRow = (IRowEdited)
|
|
817 |
* selectedRow.get(i); indexesToDel[i] = edRow.getIndex(); }
|
|
818 |
*/
|
|
811 |
|
|
812 |
// ArrayList selectedRow = vle.getSelectedRow();
|
|
813 |
//
|
|
814 |
// int[] indexesToDel = new int[selectedRow.size()];
|
|
815 |
// for (int i = 0;i < selectedRow.size(); i++) {
|
|
816 |
// IRowEdited edRow = (IRowEdited) selectedRow.get(i);
|
|
817 |
// indexesToDel[i] = vea.getInversedIndex(edRow.getIndex());
|
|
818 |
// }
|
|
819 |
//
|
|
819 | 820 |
for (int i = indexesToDel.length - 1; i >= 0; i--) { |
820 | 821 |
vea.removeRow(indexesToDel[i], PluginServices.getText(this, |
821 | 822 |
"deleted_feature"),EditionEvent.GRAPHIC); |
... | ... | |
873 | 874 |
|
874 | 875 |
pushCadTool(selCad); |
875 | 876 |
// getVectorialAdapter().getSelection().clear(); |
876 |
|
|
877 |
|
|
877 | 878 |
refreshEditedLayer(); |
878 |
|
|
879 |
|
|
879 |
|
|
880 |
|
|
880 | 881 |
PluginServices.getMainFrame().setSelectedTool("_selection"); |
881 | 882 |
// askQuestion(); |
882 | 883 |
} else { |
... | ... | |
887 | 888 |
PluginServices.getMainFrame().enableControls(); |
888 | 889 |
|
889 | 890 |
} |
890 |
|
|
891 |
|
|
891 | 892 |
/** |
892 | 893 |
* Provoca un repintado "soft" de la capa activa en edici?n. |
893 |
* Las capas por debajo de ella no se dibujan de verdad, solo
|
|
894 |
* Las capas por debajo de ella no se dibujan de verdad, solo |
|
894 | 895 |
* se dibuja la que est? en edici?n y las que est?n por encima |
895 | 896 |
* de ella en el TOC. |
896 | 897 |
*/ |
... | ... | |
902 | 903 |
edLayer.getLayer().setDirty(true); |
903 | 904 |
getMapControl().rePaintDirtyLayers(); |
904 | 905 |
} |
905 |
|
|
906 |
|
|
906 | 907 |
} |
907 | 908 |
|
908 | 909 |
public CADGrid getGrid() { |
Also available in: Unified diff