Revision 23163 trunk/extensions/extTopology/src/com/iver/cit/gvsig/geoprocess/impl/referencing/gui/VectorErrorTable.java
VectorErrorTable.java | ||
---|---|---|
50 | 50 |
|
51 | 51 |
import java.awt.BorderLayout; |
52 | 52 |
import java.awt.Dimension; |
53 |
import java.awt.KeyEventDispatcher; |
|
53 | 54 |
import java.awt.Window; |
54 | 55 |
import java.awt.event.ActionEvent; |
55 | 56 |
import java.awt.event.ActionListener; |
57 |
import java.awt.event.KeyEvent; |
|
56 | 58 |
|
57 | 59 |
import javax.swing.BorderFactory; |
58 | 60 |
import javax.swing.JComponent; |
... | ... | |
61 | 63 |
import javax.swing.JPanel; |
62 | 64 |
import javax.swing.JScrollPane; |
63 | 65 |
import javax.swing.JTable; |
66 |
import javax.swing.KeyStroke; |
|
64 | 67 |
import javax.swing.ListSelectionModel; |
65 | 68 |
import javax.swing.border.EtchedBorder; |
66 | 69 |
import javax.swing.table.AbstractTableModel; |
... | ... | |
74 | 77 |
import org.gvsig.gui.beans.swing.JButton; |
75 | 78 |
import org.gvsig.referencing.DisactivableMappedPosition; |
76 | 79 |
import org.gvsig.referencing.MappedPositionContainer; |
80 |
import org.gvsig.referencing.ReferencingUtil; |
|
77 | 81 |
import org.gvsig.topology.ui.LayerJComboBox; |
78 | 82 |
import org.gvsig.topology.ui.LayerJComboBox.LayerFilter; |
79 | 83 |
import org.gvsig.topology.ui.util.BoxLayoutPanel; |
... | ... | |
96 | 100 |
import com.iver.cit.gvsig.fmap.drivers.VectorialDriver; |
97 | 101 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
98 | 102 |
import com.iver.cit.gvsig.fmap.layers.FLayerGenericVectorial; |
103 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
|
99 | 104 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
100 | 105 |
import com.iver.cit.gvsig.fmap.tools.BehaviorException; |
101 | 106 |
import com.iver.cit.gvsig.fmap.tools.Behavior.Behavior; |
102 | 107 |
import com.iver.cit.gvsig.fmap.tools.Behavior.MouseMovementBehavior; |
103 | 108 |
import com.iver.cit.gvsig.fmap.tools.Events.MoveEvent; |
109 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
|
104 | 110 |
import com.iver.cit.gvsig.project.documents.view.toolListeners.StatusBarListener; |
111 |
import com.iver.cit.gvsig.referencing.DisactivableMappedPositionContainerImpl; |
|
105 | 112 |
import com.iver.cit.gvsig.referencing.MappedPositionContainerLayerBased; |
106 | 113 |
import com.iver.cit.gvsig.referencing.TransformationsRegistry.TransformationRegistryEntry; |
107 | 114 |
|
... | ... | |
114 | 121 |
public class VectorErrorTable extends BoxLayoutPanel { |
115 | 122 |
|
116 | 123 |
private static final long serialVersionUID = -6506747314549738246L; |
124 |
|
|
125 |
|
|
126 |
private static boolean registeredKeyStrokes = false; |
|
117 | 127 |
|
118 | 128 |
/** |
119 | 129 |
* Current active view where user could digitize new vectorial errors. |
... | ... | |
125 | 135 |
*/ |
126 | 136 |
MappedPositionContainer verrorContainer; |
127 | 137 |
|
128 |
|
|
129 | 138 |
/** |
130 | 139 |
* Current transformation provider |
131 | 140 |
*/ |
132 | 141 |
TransformationRegistryEntry transformBuilderProvider; |
133 |
|
|
142 |
|
|
134 | 143 |
/** |
135 |
* Current transformation built from control points in vector error container
|
|
136 |
* with the current transformBuilderProvider |
|
144 |
* Current transformation built from control points in vector error |
|
145 |
* container with the current transformBuilderProvider
|
|
137 | 146 |
*/ |
138 | 147 |
MathTransform mathTransform; |
139 |
|
|
140 | 148 |
/** |
149 |
* Lyr we are spatially adjusting |
|
150 |
*/ |
|
151 |
FLyrVect adjustingLyr; |
|
152 |
|
|
153 |
/** |
|
141 | 154 |
* Table model to show control points and associated errors in a JTable |
155 |
* |
|
142 | 156 |
* @author Alvaro Zabala |
143 |
* |
|
157 |
*
|
|
144 | 158 |
*/ |
145 | 159 |
private final class VErrorTableModel extends AbstractTableModel { |
146 | 160 |
|
... | ... | |
156 | 170 |
public int getRowCount() { |
157 | 171 |
return verrorContainer.getCount(); |
158 | 172 |
} |
159 |
|
|
173 |
|
|
160 | 174 |
public Class getColumnClass(int c) { |
161 |
return getValueAt(0, c).getClass();
|
|
162 |
}
|
|
163 |
|
|
175 |
return getValueAt(0, c).getClass();
|
|
176 |
}
|
|
177 |
|
|
164 | 178 |
public boolean isCellEditable(int row, int col) { |
165 |
if (col == 6) {
|
|
166 |
return true;
|
|
167 |
} else {
|
|
168 |
return false;
|
|
169 |
}
|
|
170 |
}
|
|
179 |
if (col == 6) {
|
|
180 |
return true;
|
|
181 |
} else {
|
|
182 |
return false;
|
|
183 |
}
|
|
184 |
}
|
|
171 | 185 |
|
172 |
public void setValueAt(Object value, int row, int col) { |
|
173 |
if(col != 6) |
|
174 |
return; |
|
175 |
DisactivableMappedPosition mappedPosition = |
|
176 |
(DisactivableMappedPosition) verrorContainer.getMappedPosition(row); |
|
177 |
mappedPosition.setActive(((Boolean)value).booleanValue()); |
|
178 |
fireTableCellUpdated(row, col); |
|
179 |
|
|
180 |
updateVErrorTable(); |
|
181 |
updateRmsText(); |
|
182 |
} |
|
186 |
public void setValueAt(Object value, int row, int col) { |
|
187 |
if (col != 6) |
|
188 |
return; |
|
189 |
DisactivableMappedPosition mappedPosition = (DisactivableMappedPosition) verrorContainer |
|
190 |
.getMappedPosition(row); |
|
191 |
mappedPosition.setActive(((Boolean) value).booleanValue()); |
|
192 |
fireTableCellUpdated(row, col); |
|
183 | 193 |
|
194 |
updateVErrorTable(); |
|
195 |
updateRmsText(); |
|
196 |
} |
|
184 | 197 |
|
185 |
public Object getValueAt(int row, int col) {//FIXME USAR NUMBERFORMAT PARA LAS COORDENADAS |
|
198 |
public Object getValueAt(int row, int col) {// FIXME USAR NUMBERFORMAT |
|
199 |
// PARA LAS COORDENADAS |
|
186 | 200 |
Object solution = null; |
187 | 201 |
MappedPosition mappedPosition = verrorContainer |
188 | 202 |
.getMappedPosition(row); |
189 |
|
|
203 |
|
|
190 | 204 |
DirectPosition position = null; |
191 | 205 |
switch (col) { |
192 | 206 |
case 0:// Verror id |
... | ... | |
210 | 224 |
break; |
211 | 225 |
case 5:// RMS |
212 | 226 |
try { |
213 |
if(mathTransform == null){ |
|
214 |
//mathTransform at begininng will allways be null, because there arent |
|
215 |
//enought control points to build a transformation |
|
216 |
mathTransform = transformBuilderProvider.createTransformBuilder(verrorContainer.getAsList()).getMathTransform(); |
|
227 |
if (mathTransform == null) { |
|
228 |
// mathTransform at begininng will allways be null, |
|
229 |
// because there arent |
|
230 |
// enought control points to build a transformation |
|
231 |
mathTransform = transformBuilderProvider |
|
232 |
.createTransformBuilder( |
|
233 |
verrorContainer.getAsList()) |
|
234 |
.getMathTransform(); |
|
217 | 235 |
} |
218 | 236 |
solution = mappedPosition.getError(mathTransform, buffer) |
219 | 237 |
+ ""; |
220 | 238 |
} catch (TransformException e) { |
221 | 239 |
solution = ""; |
222 |
getRmsLabel().setText(PluginServices.getText(this, "Error_computing_RMS")); |
|
223 |
}catch(MismatchedSizeException e){ |
|
240 |
getRmsLabel() |
|
241 |
.setText( |
|
242 |
PluginServices.getText(this, |
|
243 |
"Error_computing_RMS")); |
|
244 |
} catch (MismatchedSizeException e) { |
|
224 | 245 |
solution = ""; |
225 |
getRmsLabel().setText(PluginServices.getText(this, "More_control_points_needed_for_the_current_transform")); |
|
226 |
}catch(MismatchedDimensionException e){ |
|
246 |
getRmsLabel() |
|
247 |
.setText( |
|
248 |
PluginServices |
|
249 |
.getText(this, |
|
250 |
"More_control_points_needed_for_the_current_transform")); |
|
251 |
} catch (MismatchedDimensionException e) { |
|
227 | 252 |
solution = ""; |
228 |
getRmsLabel().setText(PluginServices.getText(this, "Control_points_coordinates_dimension_are_insufficient_for_the_current_transform")); |
|
229 |
}catch(MismatchedReferenceSystemException e){ |
|
253 |
getRmsLabel() |
|
254 |
.setText( |
|
255 |
PluginServices |
|
256 |
.getText( |
|
257 |
this, |
|
258 |
"Control_points_coordinates_dimension_are_insufficient_for_the_current_transform")); |
|
259 |
} catch (MismatchedReferenceSystemException e) { |
|
230 | 260 |
solution = ""; |
231 |
getRmsLabel().setText(PluginServices.getText(this, "Control_points_have_inconsistent_reference_system")); |
|
261 |
getRmsLabel() |
|
262 |
.setText( |
|
263 |
PluginServices |
|
264 |
.getText(this, |
|
265 |
"Control_points_have_inconsistent_reference_system")); |
|
232 | 266 |
} catch (FactoryException e) { |
233 | 267 |
solution = ""; |
234 |
getRmsLabel().setText(PluginServices.getText(this, "Error_creating_mathTransform")); |
|
268 |
getRmsLabel().setText( |
|
269 |
PluginServices.getText(this, |
|
270 |
"Error_creating_mathTransform")); |
|
235 | 271 |
} |
236 |
// catch(RuntimeException e){//FIXME DIFERENCIAR MISMATCHED SIZE, MISMATCHED DIMENSION Y MISMATCHED REFERENCE SYSTEM |
|
237 |
// solution = ""; |
|
238 |
// e.printStackTrace(); |
|
239 |
// } |
|
272 |
// catch(RuntimeException e){//FIXME DIFERENCIAR MISMATCHED |
|
273 |
// SIZE, MISMATCHED DIMENSION Y MISMATCHED REFERENCE SYSTEM |
|
274 |
// solution = ""; |
|
275 |
// e.printStackTrace(); |
|
276 |
// } |
|
240 | 277 |
break; |
241 |
|
|
242 |
case 6://active or disactive |
|
243 |
if(mappedPosition instanceof DisactivableMappedPosition){ |
|
244 |
DisactivableMappedPosition pos = |
|
245 |
(DisactivableMappedPosition)mappedPosition; |
|
278 |
|
|
279 |
case 6:// active or disactive |
|
280 |
if (mappedPosition instanceof DisactivableMappedPosition) { |
|
281 |
DisactivableMappedPosition pos = (DisactivableMappedPosition) mappedPosition; |
|
246 | 282 |
solution = new Boolean(pos.isActive()); |
247 |
}else{
|
|
283 |
} else {
|
|
248 | 284 |
solution = new Boolean(true); |
249 | 285 |
} |
250 | 286 |
break; |
... | ... | |
264 | 300 |
private JButton addLinkBtn; |
265 | 301 |
|
266 | 302 |
private JButton loadLinksBtn; |
267 |
|
|
303 |
|
|
304 |
/** |
|
305 |
* Listener for mouse events in MapControl |
|
306 |
*/ |
|
307 |
private ExtendedVectorListener vl; |
|
308 |
/** |
|
309 |
* Behavior to digitize vector errors |
|
310 |
*/ |
|
311 |
private VectorBehavior vb; |
|
312 |
|
|
313 |
/** |
|
314 |
* Constructor. |
|
315 |
* @param currentView |
|
316 |
* @param adjustingLyr |
|
317 |
* @param transformBuilderProvider |
|
318 |
*/ |
|
268 | 319 |
public VectorErrorTable(MapControl currentView, |
269 |
MappedPositionContainer verrorContainer,
|
|
320 |
FLyrVect adjustingLyr,
|
|
270 | 321 |
TransformationRegistryEntry transformBuilderProvider) { |
271 | 322 |
this.currentView = currentView; |
272 |
this.verrorContainer = verrorContainer;
|
|
323 |
this.verrorContainer = new DisactivableMappedPositionContainerImpl();
|
|
273 | 324 |
this.transformBuilderProvider = transformBuilderProvider; |
325 |
this.adjustingLyr = adjustingLyr; |
|
274 | 326 |
try { |
275 |
this.mathTransform = transformBuilderProvider.createTransformBuilder(verrorContainer.getAsList()).getMathTransform(); |
|
276 |
}catch (Exception e) { |
|
327 |
this.mathTransform = transformBuilderProvider |
|
328 |
.createTransformBuilder(verrorContainer.getAsList()) |
|
329 |
.getMathTransform(); |
|
330 |
} catch (Exception e) { |
|
277 | 331 |
e.printStackTrace(); |
278 | 332 |
} |
279 | 333 |
initialize(); |
334 |
|
|
335 |
ReferencingUtil.getInstance().incrementAdjustSessions(); |
|
280 | 336 |
} |
281 | 337 |
|
282 | 338 |
public void updateVErrorTable() { |
... | ... | |
289 | 345 |
this.addRow(new JComponent[] { new JLabel(PluginServices.getText(this, |
290 | 346 |
"VERROR_TITLE")) }); |
291 | 347 |
|
292 |
|
|
293 | 348 |
JScrollPane scrollPane = new JScrollPane(); |
294 | 349 |
scrollPane.setViewportView(getVErrorTable()); |
295 |
scrollPane.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
|
|
296 |
// scrollPane.setPreferredSize(new Dimension(600, 160));
|
|
297 |
// scrollPane.setMinimumSize(new Dimension(600, 120));
|
|
298 |
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
|
299 |
scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
|
300 |
|
|
301 |
this.addRow(new JComponent[] { scrollPane },
|
|
302 |
600, 300);
|
|
350 |
scrollPane.setBorder(BorderFactory |
|
351 |
.createEtchedBorder(EtchedBorder.RAISED));
|
|
352 |
// scrollPane.setPreferredSize(new Dimension(600, 160));
|
|
353 |
// scrollPane.setMinimumSize(new Dimension(600, 120));
|
|
354 |
scrollPane |
|
355 |
.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
|
356 |
scrollPane
|
|
357 |
.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
|
303 | 358 |
|
304 |
|
|
359 |
this.addRow(new JComponent[] { scrollPane }, 600, 300); |
|
360 |
|
|
305 | 361 |
this.addRow(new JComponent[] { getAddVErrorButton(), |
306 |
getDeleteVErrorButton(), getLoadLinksButton()}, 600, DEFAULT_HEIGHT); |
|
362 |
getDeleteVErrorButton(), getLoadLinksButton() }, 600, |
|
363 |
DEFAULT_HEIGHT); |
|
307 | 364 |
|
308 | 365 |
this.addRow(new JComponent[] { getRmsLabel() }); |
366 |
|
|
367 |
initializeKeyEventsListening(); |
|
309 | 368 |
|
310 | 369 |
} |
370 |
|
|
371 |
private void initializeKeyEventsListening(){ |
|
372 |
if(! registeredKeyStrokes){ |
|
373 |
KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); |
|
374 |
|
|
375 |
PluginServices.registerKeyStroke(key, new KeyEventDispatcher(){ |
|
376 |
public boolean dispatchKeyEvent(KeyEvent e) { |
|
377 |
if (e.getID() != KeyEvent.KEY_RELEASED) |
|
378 |
return false; |
|
379 |
|
|
380 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
|
381 |
if (!(v instanceof View)) |
|
382 |
return false; |
|
311 | 383 |
|
384 |
View view = (View)v; |
|
385 |
MapControl mapControl = view.getMapControl(); |
|
386 |
if(mapControl.getCurrentTool().equals("digitizeVectorError")){ |
|
387 |
if (e.getKeyCode() == KeyEvent.VK_ESCAPE){ |
|
388 |
vl.showContainer(); |
|
389 |
return true; |
|
390 |
} |
|
391 |
} |
|
392 |
return false; |
|
393 |
}}); |
|
394 |
|
|
395 |
// KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); |
|
396 |
// kfm.addKeyEventPostProcessor(new KeyEventPostProcessor(){ |
|
397 |
// public boolean postProcessKeyEvent(KeyEvent arg0) { |
|
398 |
// return false; |
|
399 |
// }}); |
|
400 |
registeredKeyStrokes = true; |
|
401 |
} |
|
402 |
|
|
403 |
} |
|
404 |
|
|
312 | 405 |
private JTable getVErrorTable() { |
313 | 406 |
if (verrorTable == null) { |
314 | 407 |
verrorTable = new JTable(); |
... | ... | |
331 | 424 |
|
332 | 425 |
verrorTable.getColumnModel().getColumn(5).setHeaderValue( |
333 | 426 |
PluginServices.getText(this, "RMS")); |
334 |
|
|
427 |
|
|
335 | 428 |
verrorTable.getColumnModel().getColumn(6).setHeaderValue( |
336 | 429 |
PluginServices.getText(this, "Active")); |
337 |
|
|
430 |
|
|
338 | 431 |
verrorTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
339 | 432 |
} |
340 | 433 |
return verrorTable; |
... | ... | |
356 | 449 |
|
357 | 450 |
private JButton getAddVErrorButton() { |
358 | 451 |
if (addLinkBtn == null) { |
359 |
addLinkBtn = new JButton(PluginServices.getText(this, |
|
360 |
"Add_VError")); |
|
452 |
addLinkBtn = new JButton(PluginServices.getText(this, "Add_VError")); |
|
361 | 453 |
addLinkBtn.addActionListener(new ActionListener() { |
362 | 454 |
public void actionPerformed(ActionEvent arg0) { |
363 | 455 |
addLink(); |
... | ... | |
366 | 458 |
} |
367 | 459 |
return addLinkBtn; |
368 | 460 |
} |
369 |
|
|
370 |
private JButton getLoadLinksButton(){ |
|
371 |
if(loadLinksBtn == null){
|
|
461 |
|
|
462 |
private JButton getLoadLinksButton() {
|
|
463 |
if (loadLinksBtn == null) {
|
|
372 | 464 |
loadLinksBtn = new JButton(PluginServices.getText(this, |
373 |
"Load_links")); |
|
374 |
loadLinksBtn.addActionListener(new ActionListener(){ |
|
465 |
"Load_links"));
|
|
466 |
loadLinksBtn.addActionListener(new ActionListener() {
|
|
375 | 467 |
public void actionPerformed(ActionEvent arg0) { |
376 | 468 |
loadLinks(); |
377 |
}}); |
|
469 |
} |
|
470 |
}); |
|
378 | 471 |
} |
379 | 472 |
return loadLinksBtn; |
380 | 473 |
} |
... | ... | |
390 | 483 |
private void updateRmsText() { |
391 | 484 |
try { |
392 | 485 |
getRmsLabel().setText( |
393 |
PluginServices.getText(this, "RMS") + " : " |
|
394 |
+ transformBuilderProvider.createTransformBuilder(verrorContainer.getAsList()).getErrorStatistics().rms()); |
|
486 |
PluginServices.getText(this, "RMS") |
|
487 |
+ " : " |
|
488 |
+ transformBuilderProvider.createTransformBuilder( |
|
489 |
verrorContainer.getAsList()) |
|
490 |
.getErrorStatistics().rms()); |
|
395 | 491 |
} catch (FactoryException e) { |
396 | 492 |
getRmsLabel().setText( |
397 | 493 |
PluginServices.getText(this, "Error_al_calcular_RMS")); |
398 |
}catch(RuntimeException re){
|
|
494 |
} catch (RuntimeException re) {
|
|
399 | 495 |
getRmsLabel().setText(""); |
400 | 496 |
} |
497 |
|
|
498 |
// MismatchedSizeException, MismatchedDimensionException, |
|
499 |
// MismatchedReferenceSystemException |
|
500 |
} |
|
501 |
|
|
502 |
class ExtendedVectorListener extends VectorListenerImpl{ |
|
503 |
JComponent container; |
|
401 | 504 |
|
402 |
// MismatchedSizeException, MismatchedDimensionException, |
|
403 |
// MismatchedReferenceSystemException |
|
404 |
} |
|
505 |
public ExtendedVectorListener(MapControl mapCtrl, |
|
506 |
MappedPositionContainer linksList, |
|
507 |
JComponent container) { |
|
508 |
super(mapCtrl, linksList); |
|
509 |
this.container = container; |
|
510 |
} |
|
511 |
|
|
512 |
public void hideContainer(){ |
|
513 |
if (container != null) { |
|
514 |
GUIUtil.getInstance().getParentOfType(container, |
|
515 |
JDialog.class).setVisible(false); |
|
516 |
} |
|
517 |
} |
|
518 |
|
|
519 |
public void showContainer(){ |
|
520 |
if (container != null) { |
|
521 |
if (!GUIUtil.getInstance().getParentOfType(container, JDialog.class).isVisible()) { |
|
522 |
GUIUtil.getInstance().getParentOfType(container, JDialog.class).setVisible(true); |
|
523 |
}//if |
|
524 |
}// thisContainer |
|
525 |
} |
|
526 |
|
|
527 |
public void vector(MoveEvent event) throws BehaviorException { |
|
528 |
super.vector(event); |
|
529 |
if(isZooming) |
|
530 |
return; |
|
531 |
mapCtrl.setPrevTool(); |
|
405 | 532 |
|
533 |
if (!verrorContainer.existsLinksLyr()) { |
|
534 |
FLyrVect linkLyr = verrorContainer |
|
535 |
.getLinkLyr(currentView.getProjection()); |
|
536 |
MapContext mapContext = currentView.getMapContext(); |
|
537 |
|
|
538 |
//each time we create a new link layer, we are creating a new spatial adjusting session |
|
539 |
FLayers solution = new FLayers(); |
|
540 |
solution.setMapContext(mapContext); |
|
541 |
solution.setParentLayer(mapContext.getLayers()); |
|
542 |
solution.setName(PluginServices.getText(this, "SPATIAL_ADJUST_SESSION")+" "+ReferencingUtil.getInstance().getNumberOfSpatialAdjustSessions()); |
|
543 |
solution.addLayer(linkLyr); |
|
544 |
mapContext.beginAtomicEvent(); |
|
545 |
mapContext.getLayers().addLayer(solution); |
|
546 |
mapContext.endAtomicEvent(); |
|
547 |
} |
|
548 |
mapCtrl.commandRepaint(); |
|
549 |
|
|
550 |
updateVErrorTable(); |
|
551 |
updateRmsText(); |
|
552 |
|
|
553 |
showContainer(); |
|
554 |
} |
|
555 |
}//class ExtendedVectorListener |
|
556 |
|
|
406 | 557 |
private void addLink() { |
407 | 558 |
final MapControl mapCtrl = currentView; |
408 | 559 |
if (mapCtrl != null) { |
409 | 560 |
String sTool = "digitizeVectorError"; |
410 |
StatusBarListener sbl = new StatusBarListener(mapCtrl); |
|
411 |
|
|
412 |
final JComponent thisContainer = (JComponent) GUIUtil.getInstance() |
|
413 |
.getParentOfType(this, IWindow.class); |
|
414 |
|
|
415 |
VectorListenerImpl vl = new VectorListenerImpl(mapCtrl, |
|
416 |
verrorContainer) { |
|
417 |
public void vector(MoveEvent event) throws BehaviorException { |
|
418 |
super.vector(event); |
|
419 |
mapCtrl.setPrevTool(); |
|
420 |
|
|
421 |
if (!verrorContainer.existsLinksLyr()) { |
|
422 |
//TODO Use a FLayers as a container of all spatial adjust |
|
423 |
//auxiliar layers. |
|
424 |
|
|
425 |
FLyrVect linkLyr = verrorContainer |
|
426 |
.getLinkLyr(currentView.getProjection()); |
|
427 |
MapContext mapContext = currentView.getMapContext(); |
|
428 |
mapContext.beginAtomicEvent(); |
|
429 |
mapContext.getLayers().addLayer(linkLyr); |
|
430 |
mapContext.endAtomicEvent(); |
|
431 |
} |
|
432 |
mapCtrl.commandRepaint(); |
|
433 |
|
|
434 |
updateVErrorTable(); |
|
435 |
updateRmsText(); |
|
436 |
|
|
437 |
if (thisContainer != null) { |
|
438 |
if (!GUIUtil.getInstance().getParentOfType( |
|
439 |
thisContainer, JDialog.class) |
|
440 |
.isVisible()) { |
|
441 |
GUIUtil.getInstance().getParentOfType( |
|
442 |
thisContainer, JDialog.class) |
|
443 |
.setVisible(true); |
|
444 |
} |
|
445 |
|
|
446 |
}// thisContainer |
|
447 |
} |
|
448 |
}; |
|
449 |
|
|
450 |
mapCtrl.addMapTool(sTool, new Behavior[] { new VectorBehavior(vl), |
|
451 |
new MouseMovementBehavior(sbl) }); |
|
561 |
|
|
562 |
if(vb == null){ |
|
563 |
JComponent container = (JComponent) GUIUtil.getInstance() |
|
564 |
.getParentOfType(this, IWindow.class); |
|
565 |
|
|
566 |
vl = new ExtendedVectorListener(mapCtrl, |
|
567 |
verrorContainer, |
|
568 |
container); |
|
569 |
vb = new VectorBehavior(vl, this.adjustingLyr); |
|
570 |
|
|
571 |
StatusBarListener sbl = new StatusBarListener(mapCtrl); |
|
572 |
mapCtrl.addMapTool(sTool, |
|
573 |
new Behavior[] { vb, |
|
574 |
new MouseMovementBehavior(sbl) }); |
|
575 |
}//if vl == null |
|
576 |
|
|
452 | 577 |
mapCtrl.setTool(sTool); |
453 | 578 |
|
454 |
if (thisContainer != null) { |
|
455 |
GUIUtil.getInstance().getParentOfType(thisContainer, |
|
456 |
JDialog.class).setVisible(false); |
|
457 |
} |
|
579 |
vl.hideContainer(); |
|
458 | 580 |
}// if mapCtrl != null |
459 | 581 |
} |
460 | 582 |
|
583 |
|
|
461 | 584 |
private void deleteLink() { |
462 | 585 |
int toDelete = getVErrorTable().getSelectedRow(); |
463 | 586 |
this.verrorContainer.delete(toDelete); |
464 | 587 |
updateVErrorTable(); |
465 | 588 |
updateRmsText(); |
466 | 589 |
} |
467 |
|
|
468 |
|
|
590 |
|
|
469 | 591 |
/** |
470 | 592 |
* Creates de MappedPositionContainer from one of the TOC's layer |
471 | 593 |
*/ |
472 | 594 |
private void loadLinks() { |
473 |
LayerJComboBox lyrComboBox = |
|
474 |
new LayerJComboBox(currentView.getMapContext().getLayers(),
|
|
475 |
new LayerFilter(){
|
|
476 |
public boolean filter(FLayer layer) {
|
|
477 |
if(layer instanceof FLyrVect){
|
|
478 |
FLyrVect aux = (FLyrVect) layer;
|
|
479 |
try {
|
|
480 |
if(aux.getShapeType() == FShape.LINE)
|
|
481 |
return true;
|
|
482 |
} catch (ReadDriverException e) {
|
|
483 |
e.printStackTrace();
|
|
484 |
}
|
|
485 |
}
|
|
486 |
return false;
|
|
487 |
}});
|
|
488 |
|
|
489 |
class LayerComboPanel extends JPanel implements IWindow{ |
|
490 |
|
|
595 |
LayerJComboBox lyrComboBox = new LayerJComboBox(currentView
|
|
596 |
.getMapContext().getLayers(), new LayerFilter() {
|
|
597 |
public boolean filter(FLayer layer) {
|
|
598 |
if (layer instanceof FLyrVect) {
|
|
599 |
FLyrVect aux = (FLyrVect) layer;
|
|
600 |
try {
|
|
601 |
if (aux.getShapeType() == FShape.LINE)
|
|
602 |
return true;
|
|
603 |
} catch (ReadDriverException e) {
|
|
604 |
e.printStackTrace();
|
|
605 |
}
|
|
606 |
} |
|
607 |
return false;
|
|
608 |
}
|
|
609 |
}); |
|
610 |
|
|
611 |
class LayerComboPanel extends JPanel implements IWindow {
|
|
612 |
|
|
491 | 613 |
private boolean okPressed = false; |
492 |
|
|
614 |
|
|
493 | 615 |
public WindowInfo getWindowInfo() { |
494 |
WindowInfo solution = new WindowInfo(WindowInfo.MODALDIALOG| |
|
495 |
WindowInfo.PALETTE| |
|
496 |
WindowInfo.ICONIFIABLE| |
|
497 |
WindowInfo.RESIZABLE| |
|
498 |
WindowInfo.MAXIMIZABLE); |
|
499 |
solution.setTitle(PluginServices.getText(this, "Link_layer_Selection")); |
|
616 |
WindowInfo solution = new WindowInfo(WindowInfo.MODALDIALOG |
|
617 |
| WindowInfo.PALETTE | WindowInfo.ICONIFIABLE |
|
618 |
| WindowInfo.RESIZABLE | WindowInfo.MAXIMIZABLE); |
|
619 |
solution.setTitle(PluginServices.getText(this, |
|
620 |
"Link_layer_Selection")); |
|
500 | 621 |
solution.setWidth(300); |
501 | 622 |
solution.setHeight(50); |
502 | 623 |
return solution; |
503 | 624 |
} |
504 |
|
|
505 |
public void setOkPressed(boolean okPressed){ |
|
625 |
|
|
626 |
public void setOkPressed(boolean okPressed) {
|
|
506 | 627 |
this.okPressed = okPressed; |
507 | 628 |
} |
508 |
|
|
509 |
public boolean isOkPressed(){ |
|
629 |
|
|
630 |
public boolean isOkPressed() {
|
|
510 | 631 |
return this.okPressed; |
511 | 632 |
} |
512 |
}//class |
|
513 |
|
|
633 |
}// class
|
|
634 |
|
|
514 | 635 |
final LayerComboPanel panel = new LayerComboPanel(); |
515 | 636 |
panel.setLayout(new BorderLayout()); |
516 |
|
|
637 |
|
|
517 | 638 |
JPanel centerPanel = new JPanel(); |
518 | 639 |
centerPanel.setLayout(new BorderLayout()); |
519 | 640 |
JPanel caux = new JPanel(); |
520 |
caux.add(new JLabel(PluginServices.getText(this,"Select_link_layer")), BorderLayout.WEST); |
|
641 |
caux.add(new JLabel(PluginServices.getText(this, "Select_link_layer")), |
|
642 |
BorderLayout.WEST); |
|
521 | 643 |
caux.add(lyrComboBox, BorderLayout.EAST); |
522 | 644 |
centerPanel.add(caux, BorderLayout.EAST); |
523 | 645 |
panel.add(centerPanel, BorderLayout.CENTER); |
524 |
|
|
646 |
|
|
525 | 647 |
JPanel southPanel = new JPanel(); |
526 | 648 |
JButton okButton = new JButton(PluginServices.getText(this, "OK")); |
527 |
|
|
528 |
okButton.addActionListener(new ActionListener(){ |
|
649 |
|
|
650 |
okButton.addActionListener(new ActionListener() {
|
|
529 | 651 |
public void actionPerformed(ActionEvent arg0) { |
530 |
Window parentWindow = GUIUtil.getInstance().getParentWindow(panel); |
|
652 |
Window parentWindow = GUIUtil.getInstance().getParentWindow( |
|
653 |
panel); |
|
531 | 654 |
parentWindow.setVisible(false); |
532 | 655 |
parentWindow.dispose(); |
533 | 656 |
panel.setOkPressed(true); |
534 |
}}); |
|
535 |
|
|
657 |
} |
|
658 |
}); |
|
659 |
|
|
536 | 660 |
southPanel.setLayout(new BorderLayout()); |
537 | 661 |
JPanel aux = new JPanel(); |
538 | 662 |
aux.add(okButton, BorderLayout.EAST); |
539 | 663 |
southPanel.add(aux, BorderLayout.EAST); |
540 | 664 |
panel.add(southPanel, BorderLayout.SOUTH); |
541 |
|
|
665 |
|
|
542 | 666 |
panel.setSize(new Dimension(300, 50)); |
543 | 667 |
PluginServices.getMDIManager().addWindow(panel); |
544 |
|
|
545 |
//Now we check if user presssed ok |
|
546 |
if(panel.isOkPressed()){ |
|
547 |
FLyrVect selectedLyr = (FLyrVect) lyrComboBox.getSelectedLayer(); |
|
668 |
|
|
669 |
// Now we check if user presssed ok |
|
670 |
FLyrVect selectedLyr = null; |
|
671 |
if (panel.isOkPressed()) { |
|
672 |
selectedLyr = (FLyrVect) lyrComboBox.getSelectedLayer(); |
|
548 | 673 |
MappedPositionContainer auxContainer = null; |
549 |
if(selectedLyr instanceof FLayerGenericVectorial){
|
|
550 |
FLayerGenericVectorial genericLyr = (FLayerGenericVectorial)selectedLyr; |
|
674 |
if (selectedLyr instanceof FLayerGenericVectorial) {
|
|
675 |
FLayerGenericVectorial genericLyr = (FLayerGenericVectorial) selectedLyr;
|
|
551 | 676 |
VectorialDriver driver = genericLyr.getDriver(); |
552 |
if(driver instanceof VectorErrorMemoryDriver){
|
|
553 |
VectorErrorMemoryDriver errorDriver = (VectorErrorMemoryDriver)driver; |
|
677 |
if (driver instanceof VectorErrorMemoryDriver) {
|
|
678 |
VectorErrorMemoryDriver errorDriver = (VectorErrorMemoryDriver) driver;
|
|
554 | 679 |
auxContainer = errorDriver.getMappedPositionContainer(); |
555 | 680 |
} |
556 |
}else{
|
|
681 |
} else {
|
|
557 | 682 |
try { |
558 |
auxContainer = new MappedPositionContainerLayerBased(selectedLyr); |
|
683 |
auxContainer = new MappedPositionContainerLayerBased( |
|
684 |
selectedLyr); |
|
559 | 685 |
} catch (BaseException e) { |
560 | 686 |
e.printStackTrace(); |
561 |
GUIUtil.getInstance().messageBox(PluginServices.getText(this, "Error_cargando_links"), |
|
562 |
PluginServices.getText(this, "Error_cargando_links")); |
|
687 |
GUIUtil.getInstance().messageBox( |
|
688 |
PluginServices |
|
689 |
.getText(this, "Error_cargando_links"), |
|
690 |
PluginServices |
|
691 |
.getText(this, "Error_cargando_links")); |
|
563 | 692 |
return; |
564 | 693 |
} |
565 | 694 |
} |
566 | 695 |
boolean overwriteCurrentLinks = true; |
567 |
if(this.verrorContainer.getCount() > 0){ |
|
568 |
overwriteCurrentLinks = GUIUtil.getInstance(). |
|
569 |
optionMessage(PluginServices.getText(this, "overwrite_current_vector_error"), PluginServices.getText(this, "spatial_adjust_warning")); |
|
570 |
|
|
696 |
if (this.verrorContainer.getCount() > 0) { |
|
697 |
overwriteCurrentLinks = GUIUtil.getInstance().optionMessage( |
|
698 |
PluginServices.getText(this, |
|
699 |
"overwrite_current_vector_error"), |
|
700 |
PluginServices.getText(this, "spatial_adjust_warning")); |
|
701 |
|
|
571 | 702 |
} |
572 |
if(overwriteCurrentLinks){
|
|
703 |
if (overwriteCurrentLinks) {
|
|
573 | 704 |
this.verrorContainer = auxContainer; |
574 |
actualizar tambien la referencia en ReferencePanel y en el VectorialListener |
|
575 | 705 |
updateVErrorTable(); |
706 |
String folderName = PluginServices.getText(this, |
|
707 |
"SPATIAL_ADJUST_SESSION") |
|
708 |
+ " " |
|
709 |
+ ReferencingUtil.getInstance() |
|
710 |
.getNumberOfSpatialAdjustSessions(); |
|
711 |
FLayers rootLyrs = currentView.getMapContext().getLayers(); |
|
712 |
FLayers adjustSessionLyrs = (FLayers) rootLyrs.getLayer(folderName); |
|
713 |
if(adjustSessionLyrs == null){ |
|
714 |
adjustSessionLyrs = new FLayers(); |
|
715 |
adjustSessionLyrs.setMapContext(currentView.getMapContext()); |
|
716 |
adjustSessionLyrs.setParentLayer(rootLyrs); |
|
717 |
adjustSessionLyrs.setName(folderName); |
|
718 |
rootLyrs.addLayer(adjustSessionLyrs); |
|
719 |
}//if |
|
720 |
rootLyrs.removeLayer(selectedLyr); |
|
721 |
adjustSessionLyrs.addLayer(selectedLyr); |
|
722 |
|
|
723 |
|
|
576 | 724 |
} |
577 |
} |
|
578 |
|
|
579 |
|
|
580 |
|
|
581 |
} |
|
582 |
|
|
583 |
|
|
725 |
}//if ok pressed |
|
726 |
} |
|
584 | 727 |
|
585 | 728 |
public TransformationRegistryEntry getTransformBuilderProvider() { |
586 | 729 |
return transformBuilderProvider; |
587 | 730 |
} |
588 | 731 |
|
589 | 732 |
public void setTransformBuilderProvider( |
590 |
TransformationRegistryEntry transformBuilderProvider) throws FactoryException { |
|
733 |
TransformationRegistryEntry transformBuilderProvider) |
|
734 |
throws FactoryException { |
|
591 | 735 |
this.transformBuilderProvider = transformBuilderProvider; |
592 |
this.mathTransform = transformBuilderProvider.createTransformBuilder(verrorContainer.getAsList()).getMathTransform(); |
|
736 |
this.mathTransform = transformBuilderProvider.createTransformBuilder( |
|
737 |
verrorContainer.getAsList()).getMathTransform(); |
|
593 | 738 |
updateVErrorTable(); |
594 | 739 |
updateRmsText(); |
595 | 740 |
} |
... | ... | |
602 | 747 |
this.verrorContainer = verrorContainer; |
603 | 748 |
} |
604 | 749 |
|
750 |
public FLyrVect getAdjustingLyr() { |
|
751 |
return adjustingLyr; |
|
752 |
} |
|
753 |
|
|
754 |
public void setAdjustingLyr(FLyrVect adjustingLyr) { |
|
755 |
this.adjustingLyr = adjustingLyr; |
|
756 |
if(vb != null) |
|
757 |
vb.setSnappingLyr(adjustingLyr); |
|
758 |
} |
|
759 |
|
|
605 | 760 |
} |
Also available in: Unified diff