Hi to all,<br>I'd like to know if there's a way to preselect (in a "clean way") which of the FlyrVect layers of my Project's Vista can be set as snapping layer for another layer?<br><br>I tried to use the LayerCollectionListener interface to capture when a
layer is added and, when this occurs, and then add a LayerListener on
that layer to capture editionChange event.<br>The problem is that the snapping layer must be set when the layer enters editing mode and AFTER that its VectorialLayerEdited (which embeds snap settings) is created.<br>The EditionManager, which creates the VectorialLayerEdited, is another LayerListener at its own time but, unfortunately, it is added only when the edition starts so I'm not able to get<br>
the layer's VectorialLayerEdited because my LayerListener is always called before the EditionManager.<br><br>I managed to preselect a snapping layer in a "dirty" way (using polling on the EditionManager) but I don't like it:<br>
<br>public void editionChanged(LayerEvent e) {<br> System.out.println("------------------------------ EDIT STARTED");<br> // STOP EDITING: do nothing<br> if (!e.getSource().isEditing())<br>
return;<br>
source = e.getSource();<br> EditionManager edManager = CADExtension.getEditionManager();<br> VectorialLayerEdited lyrEd = (VectorialLayerEdited) edManager.getLayerEdited(source);<br> <br> <span style="background-color: rgb(255, 255, 102);"> // if the VectorialLayerEdited is not yet ready (editionChange of the EditionManager called)</span><br>
if (lyrEd == null) {<br> SwingUtilities.invokeLater(new Runnable() {<br> <br> public void run() {<br> EditionManager edManager = CADExtension.getEditionManager();<br>
VectorialLayerEdited lyrEd = null;<br> <span style="background-color: rgb(255, 255, 102);">// POLLING</span><br> while ((lyrEd = (VectorialLayerEdited) edManager.getLayerEdited(source)) == null) {<br>
try {<br> Thread.sleep(100);<br> System.out.println("Sleep...");<br> }<br> catch (InterruptedException e) {<br>
e.printStackTrace();<br> }<br> }<br> <span style="background-color: rgb(255, 255, 102);"> System.out.println("Found layer edited");</span><br>
ArrayList<FLyrVect> layersToSnap = lyrEd.getLayersToSnap();<br> .....<br> .....<br> }<br> }<br>}<br>Isn't it a limitation of gvSIG? Or is there a way to solve the problem in a better way?<br>
<br>Best regards,<br>Flavio<br>