Revision 4666
trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/fmap/layers/FLyrGeoRaster.java | ||
---|---|---|
170 | 170 |
public Point2D img2World(Point2D pixel){ |
171 | 171 |
Point2D p = new Point2D.Double(); |
172 | 172 |
double wcWidth = 0.0, wcHeight = 0.0; |
173 |
int pixelImgX = 0, pixelImgY = 0;
|
|
173 |
double mapImgX = 0, mapImgY = 0;
|
|
174 | 174 |
try{ |
175 | 175 |
wcWidth = getFullExtent().getWidth(); |
176 | 176 |
wcHeight = getFullExtent().getHeight(); |
177 |
pixelImgX = (int)((((pixel.getX() * wcWidth) / widthPxImg)) + this.getFullExtent().getMinX());
|
|
178 |
pixelImgY = (int)((((pixel.getY() * wcHeight) / heightPxImg)) + this.getFullExtent().getMinY());
|
|
177 |
mapImgX = ((((pixel.getX() * wcWidth) / widthPxImg)) + this.getFullExtent().getMinX());
|
|
178 |
mapImgY = ((((pixel.getY() * wcHeight) / heightPxImg)) + this.getFullExtent().getMinY());
|
|
179 | 179 |
}catch(DriverException ex){} |
180 |
p.setLocation(pixelImgX, pixelImgY);
|
|
180 |
p.setLocation(mapImgX, mapImgY);
|
|
181 | 181 |
return p; |
182 | 182 |
} |
183 | 183 |
|
... | ... | |
303 | 303 |
dialog.getConectorPanel().getAdjustGeorefPanel().getZoomRight().draw(); |
304 | 304 |
} |
305 | 305 |
//Actualizamos la vista |
306 |
getFLyrPoints().setDrawView(null); |
|
307 | 306 |
view.getMapControl().getMapContext().invalidate(); |
308 | 307 |
} |
309 | 308 |
} |
... | ... | |
331 | 330 |
* crear? una. |
332 | 331 |
* @return Capa de puntos |
333 | 332 |
*/ |
334 |
public FLyrPoints getFLyrPoints()throws ClassCastException{ |
|
335 |
|
|
336 |
View theView = (View) PluginServices.getMDIManager().getActiveView(); |
|
337 |
|
|
333 |
public FLyrPoints getFLyrPoints()throws ClassCastException{ |
|
338 | 334 |
//Si no existe una capa de puntos la creamos |
339 | 335 |
if(lyrPoints == null){ |
336 |
View theView = (View) PluginServices.getMDIManager().getActiveView(); |
|
340 | 337 |
lyrPoints = new FLyrPoints(this); |
341 | 338 |
lyrPoints.setName("Points"); |
342 | 339 |
lyrPoints.setVisible(true); |
343 |
theView.getMapControl().getMapContext().beginAtomicEvent(); |
|
340 |
/*theView.getMapControl().getMapContext().beginAtomicEvent();
|
|
344 | 341 |
FLayers virtualLayers = new FLayers(theView.getMapControl().getMapContext(), null); |
345 | 342 |
this.setVirtualLayers(virtualLayers); |
346 | 343 |
this.getVirtualLayers().addLayer(lyrPoints); |
347 |
theView.getMapControl().getMapContext().endAtomicEvent(); |
|
348 |
//theView.getMapControl().getMapContext().getLayers().addLayer(lyrPoints);
|
|
344 |
theView.getMapControl().getMapContext().endAtomicEvent();*/
|
|
345 |
theView.getMapControl().getMapContext().getLayers().addLayer(lyrPoints); |
|
349 | 346 |
} |
350 | 347 |
return lyrPoints; |
351 | 348 |
} |
trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/fmap/layers/FLyrPoints.java | ||
---|---|---|
91 | 91 |
private FLyrPointsState state = null; |
92 | 92 |
private GeoPointPersistence geoPointPersistence = new GeoPointPersistence(this); |
93 | 93 |
private FLyrGeoRaster lyrGeoRaster = null; |
94 |
private ViewPort viewPort = null; |
|
95 | 94 |
public static boolean isDrawing = false; |
96 | 95 |
//**********************End Vars********************************** |
97 | 96 |
|
... | ... | |
233 | 232 |
public void draw(BufferedImage image, Graphics2D g, ViewPort vp, |
234 | 233 |
Cancellable cancel,double scale) throws DriverException { |
235 | 234 |
|
236 |
View theView = (View)PluginServices.getMDIManager().getActiveView(); |
|
237 |
ViewPort vpView = theView.getMapControl().getViewPort(); |
|
238 |
|
|
239 | 235 |
Point2D pto = null; |
240 | 236 |
|
241 | 237 |
if(lyrGeoRaster != null){ |
... | ... | |
247 | 243 |
pto = ((GeoPoint)pointList.get(i)).pixelPoint; |
248 | 244 |
if(pto != null){ |
249 | 245 |
Point2D p = lyrGeoRaster.img2World(pto); |
250 |
if(this.viewPort != null) |
|
251 |
p = this.viewPort.fromMapPoint(p); |
|
252 |
else |
|
253 |
p = vpView.fromMapPoint(p); |
|
254 |
System.out.println("--->1"+p); |
|
246 |
p = vp.fromMapPoint(p); |
|
255 | 247 |
drawPixelCrux(g, p, i); |
256 | 248 |
} |
257 | 249 |
|
... | ... | |
259 | 251 |
pto = ((GeoPoint)pointList.get(i)).mapPoint; |
260 | 252 |
if(pto != null){ |
261 | 253 |
Point2D p = null; |
262 |
if(this.viewPort != null) |
|
263 |
p = this.viewPort.fromMapPoint(pto); |
|
264 |
else |
|
265 |
p = vpView.fromMapPoint(pto); |
|
266 |
System.out.println("--->2"+p); |
|
254 |
p = vp.fromMapPoint(pto); |
|
267 | 255 |
drawMapCrux(g, p, i); |
268 | 256 |
} |
269 | 257 |
} |
270 | 258 |
} |
271 | 259 |
} |
272 | 260 |
} |
273 |
this.viewPort = null; |
|
274 | 261 |
} |
275 | 262 |
|
276 | 263 |
/** |
... | ... | |
682 | 669 |
} |
683 | 670 |
//**********************End Methods********************************** |
684 | 671 |
|
685 |
//**********************Setters & Getters**************************** |
|
672 |
//**********************Setters & Getters****************************
|
|
686 | 673 |
/** |
687 |
* Asigna el viewPort de la vista sobre la que se dibuja. Si no hay ninguna |
|
688 |
* asignada se usar? el de la vista de gvSIG. Esta funci?n es util para cuando |
|
689 |
* las miniimagenes tienen que dibujar sobre su propio graphics que tiene un |
|
690 |
* viewPort distinto al de la vista. |
|
691 |
* @param vp ViewPort sobre el que se dibuja |
|
692 |
*/ |
|
693 |
public void setDrawView(ViewPort vp) { |
|
694 |
this.viewPort = vp; |
|
695 |
} |
|
696 |
|
|
697 |
/** |
|
698 | 674 |
* Asigna el viewPort de la mini imagen de la derecha en |
699 | 675 |
* el punto de la posici?n que se le pasa por par?metro |
700 | 676 |
* @param pos Posici?n del punto |
trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/fmap/tools/Behavior/DraggedBehavior.java | ||
---|---|---|
55 | 55 |
* @author Nacho Brodin (brodin_ign@gva.es) |
56 | 56 |
*/ |
57 | 57 |
public class DraggedBehavior extends Behavior { |
58 |
private Point2D m_FirstPoint; |
|
59 |
private Point2D m_PointAnt; |
|
60 | 58 |
private DraggedListener listener; |
61 | 59 |
|
62 | 60 |
/** |
trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/gui/Panels/SelectPointsPanel.java | ||
---|---|---|
14 | 14 |
|
15 | 15 |
import javax.swing.ImageIcon; |
16 | 16 |
import javax.swing.JButton; |
17 |
import javax.swing.JLabel; |
|
18 | 17 |
import javax.swing.JOptionPane; |
19 | 18 |
import javax.swing.JPanel; |
20 | 19 |
import javax.swing.JTextField; |
... | ... | |
27 | 26 |
|
28 | 27 |
public class SelectPointsPanel extends JPanel implements ActionListener, KeyListener, FocusListener{ |
29 | 28 |
|
30 |
private JPanel pGeneral = null; |
|
31 |
private JPanel pPointSelection = null; |
|
32 |
private JPanel pControlPoint = null; |
|
33 |
private JPanel pInfoPoint = null; |
|
34 |
private JPanel pX = null; |
|
35 |
private JPanel pY = null; |
|
36 |
private JPanel pLatitud = null; |
|
37 |
private JPanel pLongitud = null; |
|
38 |
private JTextField tX = null; |
|
39 |
private JLabel lX = null; |
|
40 |
private JLabel lY = null; |
|
41 |
private JTextField tY = null; |
|
42 |
private JLabel lLongitud = null; |
|
43 |
private JLabel lLatitud = null; |
|
44 |
private JTextField tLatitud = null; |
|
45 |
private JTextField tLongitud = null; |
|
46 |
|
|
47 |
private JPanel pControls = null; |
|
48 |
private JPanel pSelectFromView = null; |
|
49 |
private JButton bSelectFromView = null; |
|
50 |
private FLyrPoints lyrPoints = null; |
|
51 |
private boolean disableEvent = false; |
|
52 |
private JButton bClear = null; |
|
53 |
private JButton bDelPoint = null; |
|
54 |
private int lastIndexSelection = -1; |
|
55 |
|
|
56 |
private JPanel pManagerPoint = null; |
|
57 |
private JButton bExtended = null; |
|
58 |
private JPanel pExtend = null; |
|
59 |
|
|
60 |
private TableControlerPanel tableControlerPanel = null; |
|
61 |
private DataPointPanel dataPointPanel = null; |
|
62 |
private ErrorPointPanel errorPointPanel = null; |
|
63 |
|
|
64 |
private GeoreferencingDialog grd = null; |
|
65 |
private boolean update = false; |
|
66 |
|
|
29 |
//**********************Vars********************************** |
|
30 |
private JPanel pGeneral = null; |
|
31 |
private JPanel pPointSelection = null; |
|
32 |
private JPanel pControlPoint = null; |
|
33 |
private JButton bSelectFromView = null; |
|
34 |
private FLyrPoints lyrPoints = null; |
|
35 |
private boolean disableEvent = false; |
|
36 |
private int lastIndexSelection = -1; |
|
37 |
private JButton bExtended = null; |
|
38 |
private JPanel pExtend = null; |
|
39 |
private TableControlerPanel tableControlerPanel = null; |
|
40 |
private DataPointPanel dataPointPanel = null; |
|
41 |
private ErrorPointPanel errorPointPanel = null; |
|
42 |
private GeoreferencingDialog grd = null; |
|
43 |
private boolean update = false; |
|
67 | 44 |
/** |
68 | 45 |
* Valores ?ltimos que se han introducido en los JTextField para poder reponerlos. |
69 | 46 |
*/ |
70 | 47 |
public String lastTx = "", lastTy = "", lastLong = "", lastLat = ""; |
48 |
//**********************End Vars******************************** |
|
71 | 49 |
|
50 |
//**********************Methods********************************* |
|
51 |
/** |
|
52 |
* Contructor. Inicializa el panel. |
|
53 |
*/ |
|
72 | 54 |
public SelectPointsPanel() { |
73 | 55 |
super(); |
74 | 56 |
initialize(); |
... | ... | |
82 | 64 |
initialize(); |
83 | 65 |
this.grd = grd; |
84 | 66 |
} |
85 |
|
|
86 |
private void init(){} |
|
87 | 67 |
|
88 | 68 |
/** |
89 | 69 |
* This method initializes this |
... | ... | |
96 | 76 |
this.setLocation(new java.awt.Point(0,0)); |
97 | 77 |
this.add(getPGeneral(), null); |
98 | 78 |
} |
99 |
|
|
100 |
/** |
|
101 |
* This method initializes pGeneral |
|
102 |
* |
|
103 |
* @return javax.swing.JPanel |
|
104 |
*/ |
|
105 |
private JPanel getPGeneral() { |
|
106 |
if (pGeneral == null) { |
|
107 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
|
108 |
gridBagConstraints1.insets = new java.awt.Insets(0,0,0,0); |
|
109 |
gridBagConstraints1.gridy = 0; |
|
110 |
gridBagConstraints1.gridx = 0; |
|
111 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
|
112 |
gridBagConstraints.insets = new java.awt.Insets(5,0,5,0); |
|
113 |
gridBagConstraints.gridy = 1; |
|
114 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; |
|
115 |
gridBagConstraints.gridheight = 1; |
|
116 |
gridBagConstraints.gridx = 0; |
|
117 |
pGeneral = new JPanel(); |
|
118 |
pGeneral.setLayout(new GridBagLayout()); |
|
119 |
pGeneral.setPreferredSize(new java.awt.Dimension(390,163)); |
|
120 |
gridBagConstraints.gridwidth = 1; |
|
121 |
pGeneral.add(getPPointSelection(), gridBagConstraints); |
|
122 |
pGeneral.add(getPControlPoint(), gridBagConstraints1); |
|
123 |
} |
|
124 |
return pGeneral; |
|
125 |
} |
|
126 |
|
|
127 |
/** |
|
128 |
* This method initializes pFileSelection |
|
129 |
* |
|
130 |
* @return javax.swing.JPanel |
|
131 |
*/ |
|
132 |
private JPanel getPPointSelection() { |
|
133 |
if (pPointSelection == null) { |
|
134 |
//jLabel = new JLabel(); |
|
135 |
FlowLayout flowLayout1 = new FlowLayout(); |
|
136 |
FlowLayout flowLayout = new FlowLayout(); |
|
137 |
flowLayout.setVgap(-3); |
|
138 |
flowLayout.setAlignment(java.awt.FlowLayout.LEFT); |
|
139 |
pPointSelection = new JPanel(); |
|
140 |
pPointSelection.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), java.awt.Color.black)); |
|
141 |
pPointSelection.setName(""); |
|
142 |
pPointSelection.setLayout(flowLayout); |
|
143 |
pPointSelection.setPreferredSize(new java.awt.Dimension(375,27)); |
|
144 |
flowLayout.setHgap(0); |
|
145 |
if(this.tableControlerPanel == null){ |
|
146 |
tableControlerPanel = new TableControlerPanel(); |
|
147 |
tableControlerPanel.setLayout(flowLayout1); |
|
148 |
flowLayout1.setVgap(1); |
|
149 |
flowLayout1.setHgap(0); |
|
150 |
//jLabel.setVerticalAlignment(javax.swing.SwingConstants.CENTER); |
|
151 |
//tableControlerPanel.setLNumberOfPoints(jLabel); |
|
152 |
tableControlerPanel.getBFirst().addActionListener(this); |
|
153 |
tableControlerPanel.getBLast().addActionListener(this); |
|
154 |
tableControlerPanel.getBNext().addActionListener(this); |
|
155 |
tableControlerPanel.getBPrev().addActionListener(this); |
|
156 |
tableControlerPanel.getBNew().addActionListener(this); |
|
157 |
tableControlerPanel.getCPoint().addActionListener(this); |
|
158 |
tableControlerPanel.getBClear().addActionListener(this); |
|
159 |
tableControlerPanel.getBDelPoint().addActionListener(this); |
|
160 |
} |
|
161 |
//pPointSelection.add(getPTableControl(), null); |
|
162 |
pPointSelection.add(tableControlerPanel, null); |
|
163 |
pPointSelection.add(getBSelectFromView(), null); |
|
164 |
pPointSelection.add(getPExtend(), null); |
|
165 |
} |
|
166 |
return pPointSelection; |
|
167 |
} |
|
168 |
|
|
169 |
/** |
|
170 |
* This method initializes pControls |
|
171 |
* |
|
172 |
*/ |
|
173 |
private JPanel getPControlPoint() { |
|
174 |
if (pControlPoint == null) { |
|
175 |
GridBagConstraints gridBagConstraints11 = new GridBagConstraints(); |
|
176 |
GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); |
|
177 |
gridBagConstraints2.gridx = 0; |
|
178 |
gridBagConstraints2.insets = new java.awt.Insets(0,0,0,0); |
|
179 |
gridBagConstraints2.gridy = 0; |
|
180 |
pControlPoint = new JPanel(); |
|
181 |
pControlPoint.setLayout(new GridBagLayout()); |
|
182 |
pControlPoint.setPreferredSize(new java.awt.Dimension(380,125)); |
|
183 |
pControlPoint.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,0,0,0)); |
|
184 |
gridBagConstraints11.gridy = 0; |
|
185 |
gridBagConstraints11.gridx = 1; |
|
186 |
if(this.dataPointPanel == null){ |
|
187 |
dataPointPanel = new DataPointPanel(); |
|
188 |
dataPointPanel.getTX().addKeyListener(this); |
|
189 |
dataPointPanel.getTY().addKeyListener(this); |
|
190 |
dataPointPanel.getLatitud().addKeyListener(this); |
|
191 |
dataPointPanel.getLongitud().addKeyListener(this); |
|
192 |
dataPointPanel.getTX().addFocusListener(this); |
|
193 |
dataPointPanel.getTY().addFocusListener(this); |
|
194 |
dataPointPanel.getLatitud().addFocusListener(this); |
|
195 |
dataPointPanel.getLongitud().addFocusListener(this); |
|
196 |
} |
|
197 |
pControlPoint.add(dataPointPanel, gridBagConstraints2); |
|
198 | 79 |
|
199 |
getErrorPointPanel(); |
|
200 |
pControlPoint.add(errorPointPanel, gridBagConstraints11); |
|
201 |
} |
|
202 |
return pControlPoint; |
|
203 |
} |
|
204 |
|
|
205 | 80 |
/** |
206 | 81 |
* Actualiza el n?mero de puntos del combo a partir de los contenidos en |
207 | 82 |
* la capa de puntos. Esta funci?n es usada desde otros paneles que cambien |
... | ... | |
378 | 253 |
} |
379 | 254 |
|
380 | 255 |
/** |
381 |
* @return Returns the lyrPoints. |
|
382 |
*/ |
|
383 |
public FLyrPoints getLyrPoints() { |
|
384 |
if(lyrPoints == null){ |
|
385 |
try{ |
|
386 |
loadLyrPoint(); |
|
387 |
}catch(InstantiationException exc){ |
|
388 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
|
389 |
PluginServices.getText(this, "error_capa_puntos")); |
|
390 |
} |
|
391 |
} |
|
392 |
return lyrPoints; |
|
393 |
} |
|
394 |
|
|
395 |
/** |
|
396 |
* This method initializes jButton |
|
397 |
* |
|
398 |
* @return javax.swing.JButton |
|
399 |
*/ |
|
400 |
private JButton getBExtended() { |
|
401 |
if (bExtended == null) { |
|
402 |
bExtended = new JButton(); |
|
403 |
bExtended.setPreferredSize(new java.awt.Dimension(22,22)); |
|
404 |
bExtended.setIcon(new ImageIcon(getClass().getResource("/com/iver/cit/gvsig/gui/Panels/images/down.png"))); |
|
405 |
bExtended.addActionListener(this); |
|
406 |
} |
|
407 |
return bExtended; |
|
408 |
} |
|
409 |
/** |
|
410 |
* This method initializes jPanel |
|
411 |
* |
|
412 |
* @return javax.swing.JPanel |
|
413 |
*/ |
|
414 |
private JPanel getPExtend() { |
|
415 |
if (pExtend == null) { |
|
416 |
FlowLayout flowLayout21 = new FlowLayout(); |
|
417 |
pExtend = new JPanel(); |
|
418 |
pExtend.setLayout(flowLayout21); |
|
419 |
flowLayout21.setHgap(0); |
|
420 |
flowLayout21.setVgap(0); |
|
421 |
flowLayout21.setAlignment(java.awt.FlowLayout.RIGHT); |
|
422 |
pExtend.setPreferredSize(new java.awt.Dimension(35,22)); |
|
423 |
pExtend.add(getBExtended(), null); |
|
424 |
} |
|
425 |
return pExtend; |
|
426 |
} |
|
427 |
|
|
428 |
/** |
|
429 |
* @return Returns the dataPointPanel. |
|
430 |
*/ |
|
431 |
public DataPointPanel getDataPointPanel() { |
|
432 |
return dataPointPanel; |
|
433 |
} |
|
434 |
|
|
435 |
/** |
|
436 |
* @param dataPointPanel The dataPointPanel to set. |
|
437 |
*/ |
|
438 |
public void setDataPointPanel(DataPointPanel dataPointPanel) { |
|
439 |
this.dataPointPanel = dataPointPanel; |
|
440 |
} |
|
441 |
|
|
442 |
/** |
|
443 |
* @return Returns the tableControlerPanel. |
|
444 |
*/ |
|
445 |
public TableControlerPanel getTableControlerPanel() { |
|
446 |
return tableControlerPanel; |
|
447 |
} |
|
448 |
|
|
449 |
/** |
|
450 |
* @param tableControlerPanel The tableControlerPanel to set. |
|
451 |
*/ |
|
452 |
public void setTableControlerPanel(TableControlerPanel tableControlerPanel) { |
|
453 |
this.tableControlerPanel = tableControlerPanel; |
|
454 |
} |
|
455 |
|
|
456 |
/** |
|
457 | 256 |
* Control de eventos de TableControlerPanel |
458 | 257 |
*/ |
459 | 258 |
public void actionPerformed(ActionEvent e) { |
... | ... | |
691 | 490 |
if(update) |
692 | 491 |
this.updatePointsValue(pixel, map); |
693 | 492 |
|
493 |
this.abortSelectPoints(); |
|
494 |
|
|
694 | 495 |
}catch(NumberFormatException exc){ |
695 | 496 |
System.out.println("Formato numerico erroneo"); |
696 | 497 |
} |
... | ... | |
714 | 515 |
} |
715 | 516 |
|
716 | 517 |
/** |
518 |
* Cancela la selecci?n de puntos sobre la vista de forma gr?fica. Esta acci?n |
|
519 |
* conllevar? seleccionar la ?ltima herramienta del mapCtrl |
|
520 |
*/ |
|
521 |
private void abortSelectPoints(){ |
|
522 |
String tx = dataPointPanel.getTX().getText(); |
|
523 |
String ty = dataPointPanel.getTY().getText(); |
|
524 |
String lon = dataPointPanel.getLongitud().getText(); |
|
525 |
String lat = dataPointPanel.getLatitud().getText(); |
|
526 |
|
|
527 |
if(!tx.equals("") && !ty.equals("") && !lon.equals("") && !lat.equals("")){ |
|
528 |
//Si todos los puntos est?n rellenos deseleccionamos la herramienta de selecci?n de puntos |
|
529 |
GeorefPointSelectorListener.firstPoint = true; |
|
530 |
com.iver.cit.gvsig.gui.View theView = null; |
|
531 |
try{ |
|
532 |
theView = (com.iver.cit.gvsig.gui.View)PluginServices.getMDIManager().getActiveView(); |
|
533 |
theView.getMapControl().setTool(grd.getLyrPoints().getLastTool()); |
|
534 |
}catch(ClassCastException exc){ |
|
535 |
//No se selecciona la herramienta |
|
536 |
} |
|
537 |
} |
|
538 |
} |
|
539 |
|
|
540 |
/** |
|
717 | 541 |
* Los campos de texto de las coordenadas cuando pierden el foco actualizan el valor del pixel |
718 | 542 |
* en la cap, vista, mini imagen y tabla |
719 | 543 |
*/ |
720 | 544 |
public void focusLost(FocusEvent arg0) { |
721 |
Point2D pixel = new Point2D.Double(); |
|
722 |
Point2D map = new Point2D.Double(); |
|
723 |
pixel.setLocation(Double.valueOf(dataPointPanel.getTX().getText()).doubleValue(), |
|
724 |
Double.valueOf(dataPointPanel.getTY().getText()).doubleValue()); |
|
725 |
map.setLocation(Double.valueOf(dataPointPanel.getLongitud().getText()).doubleValue(), |
|
726 |
Double.valueOf(dataPointPanel.getLatitud().getText()).doubleValue()); |
|
727 |
//Si update es true significa q se ha pulsado Enter por lo q ya se est? actualizando |
|
728 |
//y no hace falta que se haga de nuevo pq podr?a salir un mensaje de error dos veces |
|
729 |
if(!update) |
|
730 |
this.updatePointsValue(pixel, map); |
|
545 |
String tx = dataPointPanel.getTX().getText(); |
|
546 |
String ty = dataPointPanel.getTY().getText(); |
|
547 |
String lon = dataPointPanel.getLongitud().getText(); |
|
548 |
String lat = dataPointPanel.getLatitud().getText(); |
|
549 |
|
|
550 |
if(!tx.equals("") && !ty.equals("") && !lon.equals("") && !lat.equals("")){ |
|
551 |
Point2D pixel = new Point2D.Double(); |
|
552 |
Point2D map = new Point2D.Double(); |
|
553 |
pixel.setLocation(Double.valueOf(tx).doubleValue(), |
|
554 |
Double.valueOf(ty).doubleValue()); |
|
555 |
map.setLocation(Double.valueOf(lon).doubleValue(), |
|
556 |
Double.valueOf(lat).doubleValue()); |
|
557 |
//Si update es true significa q se ha pulsado Enter por lo q ya se est? actualizando |
|
558 |
//y no hace falta que se haga de nuevo pq podr?a salir un mensaje de error dos veces |
|
559 |
if(!update) |
|
560 |
this.updatePointsValue(pixel, map); |
|
561 |
this.abortSelectPoints(); |
|
562 |
} |
|
731 | 563 |
} |
732 | 564 |
|
565 |
//**********************End Methods******************************* |
|
566 |
|
|
567 |
//**********************Setters & Getters************************* |
|
733 | 568 |
/** |
734 | 569 |
* @return Returns the errorPointPanel. |
735 | 570 |
*/ |
... | ... | |
738 | 573 |
errorPointPanel = new ErrorPointPanel(); |
739 | 574 |
return errorPointPanel; |
740 | 575 |
} |
576 |
/** |
|
577 |
* @return Returns the lyrPoints. |
|
578 |
*/ |
|
579 |
public FLyrPoints getLyrPoints() { |
|
580 |
if(lyrPoints == null){ |
|
581 |
try{ |
|
582 |
loadLyrPoint(); |
|
583 |
}catch(InstantiationException exc){ |
|
584 |
JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), |
|
585 |
PluginServices.getText(this, "error_capa_puntos")); |
|
586 |
} |
|
587 |
} |
|
588 |
return lyrPoints; |
|
589 |
} |
|
590 |
|
|
591 |
/** |
|
592 |
* This method initializes jButton |
|
593 |
* |
|
594 |
* @return javax.swing.JButton |
|
595 |
*/ |
|
596 |
private JButton getBExtended() { |
|
597 |
if (bExtended == null) { |
|
598 |
bExtended = new JButton(); |
|
599 |
bExtended.setPreferredSize(new java.awt.Dimension(22,22)); |
|
600 |
bExtended.setIcon(new ImageIcon(getClass().getResource("/com/iver/cit/gvsig/gui/Panels/images/down.png"))); |
|
601 |
bExtended.addActionListener(this); |
|
602 |
} |
|
603 |
return bExtended; |
|
604 |
} |
|
605 |
|
|
606 |
/** |
|
607 |
* This method initializes jPanel |
|
608 |
* |
|
609 |
* @return javax.swing.JPanel |
|
610 |
*/ |
|
611 |
private JPanel getPExtend() { |
|
612 |
if (pExtend == null) { |
|
613 |
FlowLayout flowLayout21 = new FlowLayout(); |
|
614 |
pExtend = new JPanel(); |
|
615 |
pExtend.setLayout(flowLayout21); |
|
616 |
flowLayout21.setHgap(0); |
|
617 |
flowLayout21.setVgap(0); |
|
618 |
flowLayout21.setAlignment(java.awt.FlowLayout.RIGHT); |
|
619 |
pExtend.setPreferredSize(new java.awt.Dimension(35,22)); |
|
620 |
pExtend.add(getBExtended(), null); |
|
621 |
} |
|
622 |
return pExtend; |
|
623 |
} |
|
624 |
|
|
625 |
/** |
|
626 |
* @return Returns the dataPointPanel. |
|
627 |
*/ |
|
628 |
public DataPointPanel getDataPointPanel() { |
|
629 |
return dataPointPanel; |
|
630 |
} |
|
631 |
|
|
632 |
/** |
|
633 |
* @param dataPointPanel The dataPointPanel to set. |
|
634 |
*/ |
|
635 |
public void setDataPointPanel(DataPointPanel dataPointPanel) { |
|
636 |
this.dataPointPanel = dataPointPanel; |
|
637 |
} |
|
638 |
|
|
639 |
/** |
|
640 |
* @return Returns the tableControlerPanel. |
|
641 |
*/ |
|
642 |
public TableControlerPanel getTableControlerPanel() { |
|
643 |
return tableControlerPanel; |
|
644 |
} |
|
645 |
|
|
646 |
/** |
|
647 |
* @param tableControlerPanel The tableControlerPanel to set. |
|
648 |
*/ |
|
649 |
public void setTableControlerPanel(TableControlerPanel tableControlerPanel) { |
|
650 |
this.tableControlerPanel = tableControlerPanel; |
|
651 |
} |
|
652 |
|
|
653 |
/** |
|
654 |
* This method initializes pGeneral |
|
655 |
* |
|
656 |
* @return javax.swing.JPanel |
|
657 |
*/ |
|
658 |
private JPanel getPGeneral() { |
|
659 |
if (pGeneral == null) { |
|
660 |
GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); |
|
661 |
gridBagConstraints1.insets = new java.awt.Insets(0,0,0,0); |
|
662 |
gridBagConstraints1.gridy = 0; |
|
663 |
gridBagConstraints1.gridx = 0; |
|
664 |
GridBagConstraints gridBagConstraints = new GridBagConstraints(); |
|
665 |
gridBagConstraints.insets = new java.awt.Insets(5,0,5,0); |
|
666 |
gridBagConstraints.gridy = 1; |
|
667 |
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTH; |
|
668 |
gridBagConstraints.gridheight = 1; |
|
669 |
gridBagConstraints.gridx = 0; |
|
670 |
pGeneral = new JPanel(); |
|
671 |
pGeneral.setLayout(new GridBagLayout()); |
|
672 |
pGeneral.setPreferredSize(new java.awt.Dimension(390,163)); |
|
673 |
gridBagConstraints.gridwidth = 1; |
|
674 |
pGeneral.add(getPPointSelection(), gridBagConstraints); |
|
675 |
pGeneral.add(getPControlPoint(), gridBagConstraints1); |
|
676 |
} |
|
677 |
return pGeneral; |
|
678 |
} |
|
679 |
|
|
680 |
/** |
|
681 |
* This method initializes pFileSelection |
|
682 |
* |
|
683 |
* @return javax.swing.JPanel |
|
684 |
*/ |
|
685 |
private JPanel getPPointSelection() { |
|
686 |
if (pPointSelection == null) { |
|
687 |
//jLabel = new JLabel(); |
|
688 |
FlowLayout flowLayout1 = new FlowLayout(); |
|
689 |
FlowLayout flowLayout = new FlowLayout(); |
|
690 |
flowLayout.setVgap(-3); |
|
691 |
flowLayout.setAlignment(java.awt.FlowLayout.LEFT); |
|
692 |
pPointSelection = new JPanel(); |
|
693 |
pPointSelection.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), java.awt.Color.black)); |
|
694 |
pPointSelection.setName(""); |
|
695 |
pPointSelection.setLayout(flowLayout); |
|
696 |
pPointSelection.setPreferredSize(new java.awt.Dimension(375,27)); |
|
697 |
flowLayout.setHgap(0); |
|
698 |
if(this.tableControlerPanel == null){ |
|
699 |
tableControlerPanel = new TableControlerPanel(); |
|
700 |
tableControlerPanel.setLayout(flowLayout1); |
|
701 |
flowLayout1.setVgap(1); |
|
702 |
flowLayout1.setHgap(0); |
|
703 |
//jLabel.setVerticalAlignment(javax.swing.SwingConstants.CENTER); |
|
704 |
//tableControlerPanel.setLNumberOfPoints(jLabel); |
|
705 |
tableControlerPanel.getBFirst().addActionListener(this); |
|
706 |
tableControlerPanel.getBLast().addActionListener(this); |
|
707 |
tableControlerPanel.getBNext().addActionListener(this); |
|
708 |
tableControlerPanel.getBPrev().addActionListener(this); |
|
709 |
tableControlerPanel.getBNew().addActionListener(this); |
|
710 |
tableControlerPanel.getCPoint().addActionListener(this); |
|
711 |
tableControlerPanel.getBClear().addActionListener(this); |
|
712 |
tableControlerPanel.getBDelPoint().addActionListener(this); |
|
713 |
} |
|
714 |
//pPointSelection.add(getPTableControl(), null); |
|
715 |
pPointSelection.add(tableControlerPanel, null); |
|
716 |
pPointSelection.add(getBSelectFromView(), null); |
|
717 |
pPointSelection.add(getPExtend(), null); |
|
718 |
} |
|
719 |
return pPointSelection; |
|
720 |
} |
|
721 |
|
|
722 |
/** |
|
723 |
* This method initializes pControls |
|
724 |
* |
|
725 |
*/ |
|
726 |
private JPanel getPControlPoint() { |
|
727 |
if (pControlPoint == null) { |
|
728 |
GridBagConstraints gridBagConstraints11 = new GridBagConstraints(); |
|
729 |
GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); |
|
730 |
gridBagConstraints2.gridx = 0; |
|
731 |
gridBagConstraints2.insets = new java.awt.Insets(0,0,0,0); |
|
732 |
gridBagConstraints2.gridy = 0; |
|
733 |
pControlPoint = new JPanel(); |
|
734 |
pControlPoint.setLayout(new GridBagLayout()); |
|
735 |
pControlPoint.setPreferredSize(new java.awt.Dimension(380,125)); |
|
736 |
pControlPoint.setBorder(javax.swing.BorderFactory.createEmptyBorder(0,0,0,0)); |
|
737 |
gridBagConstraints11.gridy = 0; |
|
738 |
gridBagConstraints11.gridx = 1; |
|
739 |
if(this.dataPointPanel == null){ |
|
740 |
dataPointPanel = new DataPointPanel(); |
|
741 |
dataPointPanel.getTX().addKeyListener(this); |
|
742 |
dataPointPanel.getTY().addKeyListener(this); |
|
743 |
dataPointPanel.getLatitud().addKeyListener(this); |
|
744 |
dataPointPanel.getLongitud().addKeyListener(this); |
|
745 |
dataPointPanel.getTX().addFocusListener(this); |
|
746 |
dataPointPanel.getTY().addFocusListener(this); |
|
747 |
dataPointPanel.getLatitud().addFocusListener(this); |
|
748 |
dataPointPanel.getLongitud().addFocusListener(this); |
|
749 |
} |
|
750 |
pControlPoint.add(dataPointPanel, gridBagConstraints2); |
|
751 |
|
|
752 |
getErrorPointPanel(); |
|
753 |
pControlPoint.add(errorPointPanel, gridBagConstraints11); |
|
754 |
} |
|
755 |
return pControlPoint; |
|
756 |
} |
|
757 |
//**********************End Setters & Getters********************* |
|
741 | 758 |
} |
trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/gui/Panels/AdjustGeorefPanel.java | ||
---|---|---|
11 | 11 |
|
12 | 12 |
public class AdjustGeorefPanel extends JPanel{ |
13 | 13 |
|
14 |
|
|
15 |
private JPanel pDetailImage = null; |
|
16 |
private ZoomControlPanel pixelZoom = null; |
|
17 |
private ZoomControlPanel mapZoom = null; |
|
18 |
private JPanel pOptions = null; |
|
19 |
private GeoreferencingDialog grd = null; |
|
20 |
private OptionsPanel optionsPanel = null; |
|
21 |
|
|
14 |
//**********************Vars********************************** |
|
15 |
private JPanel pDetailImage = null; |
|
16 |
private ZoomControlPanel pixelZoom = null; |
|
17 |
private ZoomControlPanel mapZoom = null; |
|
18 |
private JPanel pOptions = null; |
|
19 |
private GeoreferencingDialog grd = null; |
|
20 |
private OptionsPanel optionsPanel = null; |
|
21 |
//**********************End Vars****************************** |
|
22 |
|
|
23 |
//**********************Methods************************************** |
|
22 | 24 |
/** |
23 | 25 |
* This is the default constructor |
24 | 26 |
*/ |
... | ... | |
139 | 141 |
public OptionsPanel getOptionsPanel() { |
140 | 142 |
return optionsPanel; |
141 | 143 |
} |
142 |
|
|
143 | 144 |
|
145 |
//**********************End Methods********************************** |
|
146 |
|
|
144 | 147 |
} |
trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/gui/Panels/ZoomControlPanel.java | ||
---|---|---|
41 | 41 |
* |
42 | 42 |
*/ |
43 | 43 |
public class ZoomControlPanel extends JPanel implements ActionListener{ |
44 |
private JPanel pImage = null; |
|
45 |
private JPanel pControls = null; |
|
46 |
private JButton bZoomMas = null; |
|
47 |
private JButton bZoomMenos = null; |
|
48 |
|
|
49 |
private int sX = 140, sY = 140; |
|
50 |
private CanvasZone canvas = null; |
|
51 |
private ViewPort viewPort = null; |
|
44 |
|
|
45 |
//**********************Vars********************************** |
|
46 |
private JPanel pImage = null; |
|
47 |
private JPanel pControls = null; |
|
48 |
private JButton bZoomMas = null; |
|
49 |
private JButton bZoomMenos = null; |
|
50 |
private int sX = 140, sY = 140; |
|
51 |
private CanvasZone canvas = null; |
|
52 |
private ViewPort viewPort = null; |
|
53 |
public FLyrPoints lyrPoints = null; |
|
54 |
public FLyrGeoRaster lyrGeoRaster = null; |
|
55 |
public GeoreferencingDialog dialog = null; |
|
56 |
private boolean rightControl = false; |
|
57 |
//**********************End Vars****************************** |
|
52 | 58 |
|
53 |
public FLyrPoints lyrPoints = null; |
|
54 |
public FLyrGeoRaster lyrGeoRaster = null; |
|
55 |
public GeoreferencingDialog dialog = null; |
|
56 |
private boolean rightControl = false; |
|
57 |
|
|
58 |
|
|
59 |
|
|
59 |
//**********************Methods******************************* |
|
60 | 60 |
/** |
61 | 61 |
* This is the default constructor |
62 | 62 |
*/ |
... | ... | |
107 | 107 |
throw new InstantiationException("No se ha podido instanciar la capa de puntos o georreferenciada"); |
108 | 108 |
|
109 | 109 |
} |
110 |
|
|
111 |
/** |
|
112 |
*Llama a la funci?n de pintado del canvas con los par?metros que tenga en ese momento |
|
113 |
*/ |
|
114 |
public void draw(){ |
|
115 |
if(!getDialog().isEnlarge()) |
|
116 |
getCanvas().loadBuffer(); |
|
117 |
getCanvas().repaint(); |
|
118 |
} |
|
119 |
|
|
120 |
/** |
|
121 |
* Manejo de los controles zoom m?s y zoom menos |
|
122 |
*/ |
|
123 |
public void actionPerformed(ActionEvent e) { |
|
124 |
if(e.getSource() == bZoomMas){ |
|
125 |
canvas.calcZoom(0.6); |
|
126 |
canvas.repaint(); |
|
127 |
} |
|
128 |
|
|
129 |
if(e.getSource() == bZoomMenos){ |
|
130 |
canvas.calcZoom(1.8); |
|
131 |
canvas.repaint(); |
|
132 |
} |
|
133 |
|
|
134 |
} |
|
135 |
|
|
136 |
/** |
|
137 |
*Limpia el canvas |
|
138 |
*/ |
|
139 |
public void clear(){ |
|
140 |
canvas.setCleanCanvas(true); |
|
141 |
canvas.repaint(); |
|
142 |
} |
|
143 |
//**********************End Methods*************************** |
|
144 |
|
|
145 |
//**********************Setters & Getters********************* |
|
146 |
/** |
|
147 |
* @param viewPort The viewPort to set. |
|
148 |
*/ |
|
149 |
public void setViewPort(ViewPort viewPort) { |
|
150 |
this.viewPort = viewPort; |
|
151 |
getCanvas().setViewPort(this.viewPort); |
|
152 |
} |
|
110 | 153 |
|
111 | 154 |
/** |
112 | 155 |
* This method initializes jPanel |
... | ... | |
191 | 234 |
} |
192 | 235 |
return bZoomMenos; |
193 | 236 |
} |
194 |
|
|
195 |
/** |
|
196 |
* @param viewPort The viewPort to set. |
|
197 |
*/ |
|
198 |
public void setViewPort(ViewPort viewPort) { |
|
199 |
this.viewPort = viewPort; |
|
200 |
getCanvas().setViewPort(this.viewPort); |
|
201 |
} |
|
202 | 237 |
|
203 | 238 |
/** |
204 |
*Llama a la funci?n de pintado del canvas con los par?metros que tenga en ese momento |
|
205 |
*/ |
|
206 |
public void draw(){ |
|
207 |
if(!getDialog().isEnlarge()) |
|
208 |
getCanvas().loadBuffer(); |
|
209 |
getCanvas().repaint(); |
|
210 |
} |
|
211 |
|
|
212 |
/** |
|
213 |
* Asigna al canvas la propiedad de visibilidad a verdadero o falso. |
|
214 |
* @param visible true para mostrar el canvas y false para ocultarlo |
|
215 |
*/ |
|
216 |
public void setVisible(boolean visible){ |
|
217 |
canvas.setVisible(visible); |
|
218 |
if(!visible) |
|
219 |
canvas.setSize(0,0); |
|
220 |
else{ |
|
221 |
canvas.setSize(sX, sY); |
|
222 |
} |
|
223 |
canvas.repaint(); |
|
224 |
} |
|
225 |
|
|
226 |
/** |
|
227 |
* Asigna el punto sobre el que se centrar? el zoom de la minimagen |
|
228 |
* @param pto |
|
229 |
*/ |
|
230 |
public void setCenterPoint(Point2D pto){ |
|
231 |
getCanvas().setCenterPoint(pto); |
|
232 |
} |
|
233 |
|
|
234 |
/** |
|
235 |
* Recupera el n?mero de punto que se est? tratando |
|
236 |
* @param n |
|
237 |
*/ |
|
238 |
public int getNumberPoint(){ |
|
239 |
try{ |
|
240 |
if(getDialog().getConectorPanel().getDataPointsTabPanel().getTbPoints().getSelectedIndex() == 0) |
|
241 |
return Integer.valueOf(getDialog().getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getTableControlerPanel().getCPoint().getSelectedItem().toString()).intValue() - 1; |
|
242 |
else |
|
243 |
return Integer.valueOf(getDialog().getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().getTableControlerPanel().getCPoint().getSelectedItem().toString()).intValue() - 1; |
|
244 |
}catch(NullPointerException exc){ |
|
245 |
return -1; |
|
246 |
} |
|
247 |
} |
|
248 |
|
|
249 |
/** |
|
250 |
* Manejo de los controles zoom m?s y zoom menos |
|
251 |
*/ |
|
252 |
public void actionPerformed(ActionEvent e) { |
|
253 |
if(e.getSource() == bZoomMas){ |
|
254 |
canvas.calcZoom(0.6); |
|
255 |
canvas.repaint(); |
|
256 |
} |
|
257 |
|
|
258 |
if(e.getSource() == bZoomMenos){ |
|
259 |
canvas.calcZoom(1.8); |
|
260 |
canvas.repaint(); |
|
261 |
} |
|
262 |
|
|
263 |
} |
|
264 |
|
|
265 |
|
|
266 |
/** |
|
239 |
* Obtiene true si se trata de un control con los botones de zoom |
|
240 |
* a la derecha y false si los tiene a la izquierda. |
|
267 | 241 |
* @return Returns the rightControl. |
268 | 242 |
*/ |
269 | 243 |
public boolean isRightControl() { |
... | ... | |
271 | 245 |
} |
272 | 246 |
|
273 | 247 |
/** |
248 |
* Obtiene la capa de imagen georreferenciada. |
|
274 | 249 |
* @return Returns the lyrGeoRaster. |
275 | 250 |
*/ |
276 | 251 |
public FLyrGeoRaster getLyrGeoRaster() { |
277 | 252 |
return lyrGeoRaster; |
278 | 253 |
} |
279 | 254 |
|
280 |
|
|
281 | 255 |
/** |
256 |
* Obtiene la capa de puntos. |
|
282 | 257 |
* @return Returns the lyrPoints. |
283 | 258 |
*/ |
284 | 259 |
public FLyrPoints getLyrPoints() { |
... | ... | |
314 | 289 |
canvas.setNewViewPort(vp); |
315 | 290 |
} |
316 | 291 |
|
317 |
/** |
|
318 |
*Limpia el canvas |
|
319 |
*/ |
|
320 |
public void clear(){ |
|
321 |
canvas.setCleanCanvas(true); |
|
322 |
canvas.repaint(); |
|
323 |
} |
|
324 |
|
|
325 | 292 |
/** |
293 |
* Asigna al canvas la propiedad de visibilidad a verdadero o falso. |
|
294 |
* @param visible true para mostrar el canvas y false para ocultarlo |
|
295 |
*/ |
|
296 |
public void setVisible(boolean visible){ |
|
297 |
canvas.setVisible(visible); |
|
298 |
if(!visible) |
|
299 |
canvas.setSize(0,0); |
|
300 |
else{ |
|
301 |
canvas.setSize(sX, sY); |
|
302 |
} |
|
303 |
canvas.repaint(); |
|
304 |
} |
|
305 |
|
|
306 |
/** |
|
307 |
* Asigna el punto sobre el que se centrar? el zoom de la minimagen |
|
308 |
* @param pto |
|
309 |
*/ |
|
310 |
public void setCenterPoint(Point2D pto){ |
|
311 |
getCanvas().setCenterPoint(pto); |
|
312 |
} |
|
313 |
|
|
314 |
/** |
|
315 |
* Recupera el n?mero de punto que se est? tratando |
|
316 |
* @param n |
|
317 |
*/ |
|
318 |
public int getNumberPoint(){ |
|
319 |
try{ |
|
320 |
if(getDialog().getConectorPanel().getDataPointsTabPanel().getTbPoints().getSelectedIndex() == 0) |
|
321 |
return Integer.valueOf(getDialog().getConectorPanel().getDataPointsTabPanel().getSelectPointsPanel().getTableControlerPanel().getCPoint().getSelectedItem().toString()).intValue() - 1; |
|
322 |
else |
|
323 |
return Integer.valueOf(getDialog().getConectorPanel().getDataPointsTabPanel().getTablePointsPanel().getTableControlerPanel().getCPoint().getSelectedItem().toString()).intValue() - 1; |
|
324 |
}catch(NullPointerException exc){ |
|
325 |
return -1; |
|
326 |
} |
|
327 |
} |
|
328 |
//**********************End Setters & Getters***************** |
|
329 |
/** |
|
326 | 330 |
* Control que representa la zona de dibujado de la ventana. Este se encarga de |
327 | 331 |
* repintar el contenido sobre el Graphics2D a partir del viewPort que se le pase |
328 | 332 |
* @author Nacho Brodin (brodin_ign@gva.es) |
329 | 333 |
*/ |
330 |
public class CanvasZone extends Canvas implements MouseListener, MouseMotionListener{ |
|
331 |
private ZoomControlPanel zoomControl = null; |
|
332 |
private int ancho; |
|
333 |
private int alto; |
|
334 |
private FLayers flayers = null; |
|
335 |
private ViewPort viewPort = null; |
|
336 |
private ViewPort newViewPort = null; |
|
337 |
private Point2D centerPoint = null; |
|
338 |
private int initZoom = 20; |
|
339 |
private boolean dragged = false; |
|
340 |
private Image dobleBuffer = null; |
|
341 |
private BufferedImage imgTmp = null; |
|
342 |
private Graphics dbGraphics = null; |
|
343 |
private boolean cleanCanvas = false; |
|
344 |
|
|
334 |
public class CanvasZone extends JPanel implements MouseListener, MouseMotionListener{ |
|
335 |
|
|
336 |
//**********************Params******************************** |
|
337 |
/** |
|
338 |
* Zoom inicial de la miniimagen |
|
339 |
*/ |
|
340 |
private int initZoom = 20; |
|
341 |
//**********************End Params**************************** |
|
342 |
|
|
343 |
//**********************Vars********************************** |
|
344 |
private ZoomControlPanel zoomControl = null; |
|
345 |
private int ancho; |
|
346 |
private int alto; |
|
347 |
private FLayers flayers = null; |
|
348 |
private ViewPort newViewPort = null; |
|
349 |
private Point2D centerPoint = null; |
|
350 |
private boolean dragged = false; |
|
351 |
private Image dobleBuffer = null; |
|
352 |
private BufferedImage imgTmp = null; |
|
353 |
private Graphics dbGraphics = null; |
|
354 |
private boolean cleanCanvas = false; |
|
345 | 355 |
/** |
346 | 356 |
* Puntos inicial y final para el desplazamiento del punto de control |
347 | 357 |
*/ |
348 | 358 |
private Point2D ptoIni = null, ptoFin = null; |
349 | 359 |
private Point2D movDragged = null, initCrux = null; |
350 |
|
|
351 |
|
|
360 |
//**********************End Vars****************************** |
|
361 |
|
|
362 |
//**********************Methods******************************* |
|
363 |
/** |
|
364 |
* |
|
365 |
*/ |
|
352 | 366 |
public CanvasZone( int anc,int alt, ZoomControlPanel zc) { |
353 | 367 |
zoomControl = zc; |
354 | 368 |
ancho = anc; |
... | ... | |
361 | 375 |
dobleBuffer = new BufferedImage(this.ancho, this.alto, BufferedImage.TYPE_INT_ARGB); |
362 | 376 |
dbGraphics = dobleBuffer.getGraphics(); |
363 | 377 |
} |
364 |
|
|
378 |
|
|
365 | 379 |
/** |
366 |
* Asigna el viewPort |
|
367 |
* @param vp ViewPort |
|
368 |
*/ |
|
369 |
public void setViewPort(ViewPort vp){ |
|
370 |
this.viewPort = vp; |
|
371 |
this.initViewPort(vp, this.centerPoint, null); |
|
372 |
} |
|
373 |
|
|
374 |
/** |
|
375 |
* Asigna el viewPort recalculado |
|
376 |
* @param vp ViewPort |
|
377 |
*/ |
|
378 |
public void setNewViewPort(ViewPort vp){ |
|
379 |
this.newViewPort = vp; |
|
380 |
} |
|
381 |
|
|
382 |
/** |
|
383 | 380 |
* Calcula el zoom dependiendo del factor de escala pasado por |
384 | 381 |
* par?metro. |
385 | 382 |
*/ |
... | ... | |
443 | 440 |
*/ |
444 | 441 |
public void loadBuffer(){ |
445 | 442 |
Graphics2D gTmp = (Graphics2D)imgTmp.getGraphics(); |
443 |
|
|
446 | 444 |
if(!dragged){ |
447 | 445 |
dbGraphics.setColor( Color.WHITE ); |
448 | 446 |
dbGraphics.fillRect( 0,0,ancho,alto ); |
... | ... | |
477 | 475 |
//dibujamos |
478 | 476 |
|
479 | 477 |
if(zoomControl.getDialog().isEnlarge()){ |
480 |
zoomControl.getLyrPoints().setDrawView(newViewPort);
|
|
481 |
flayers.draw(null, (Graphics2D) dbGraphics, newViewPort,new Cancellable() { |
|
482 |
public boolean isCanceled() { |
|
483 |
return false; |
|
484 |
} |
|
485 |
},flayers.getFMap().getScaleView()); |
|
486 |
zoomControl.getLyrPoints().setDrawView(null);
|
|
478 |
if(zoomControl.getNumberPoint() != -1){
|
|
479 |
flayers.draw(null, (Graphics2D) dbGraphics, newViewPort,new Cancellable() {
|
|
480 |
public boolean isCanceled() {
|
|
481 |
return false;
|
|
482 |
}
|
|
483 |
},flayers.getFMap().getScaleView());
|
|
484 |
}
|
|
487 | 485 |
} |
488 | 486 |
|
489 |
zoomControl.getLyrPoints().setDrawView(newViewPort); |
|
490 | 487 |
flayers.draw(null, gTmp, newViewPort,new Cancellable() { |
491 | 488 |
public boolean isCanceled() { |
492 | 489 |
return false; |
493 | 490 |
} |
494 | 491 |
},flayers.getFMap().getScaleView()); |
495 |
zoomControl.getLyrPoints().setDrawView(null); |
|
496 | 492 |
|
497 | 493 |
} |
498 | 494 |
}catch (DriverException e) { |
... | ... | |
526 | 522 |
* @param g |
527 | 523 |
*/ |
528 | 524 |
public void paint( Graphics g ) { |
529 |
loadBuffer();
|
|
530 |
if(!cleanCanvas)
|
|
525 |
if(!cleanCanvas){
|
|
526 |
loadBuffer();
|
|
531 | 527 |
g.drawImage(dobleBuffer, 0, 0, null); |
532 |
else{ |
|
528 |
}else{
|
|
533 | 529 |
g.setColor( Color.WHITE ); |
534 | 530 |
g.fillRect( 0,0,ancho,alto ); |
535 | 531 |
cleanCanvas = false; |
536 | 532 |
} |
537 | 533 |
} |
538 |
|
|
534 |
|
|
539 | 535 |
/** |
540 |
* Asigna el punto donde se centrar? la vista de la minimagen |
|
541 |
* @param pto Punto central. |
|
542 |
*/ |
|
543 |
public void setCenterPoint(Point2D pto){ |
|
544 |
this.centerPoint = pto; |
|
545 |
} |
|
546 |
|
|
547 |
/** |
|
548 | 536 |
* Desplaza el extent al nuevo centro |
549 | 537 |
* @param pto |
550 | 538 |
*/ |
... | ... | |
602 | 590 |
}catch(ClassCastException exc){ |
603 | 591 |
return; |
604 | 592 |
} |
605 |
ViewPort viewPort = theView.getMapControl().getMapContext().getViewPort(); |
|
593 |
|
|
606 | 594 |
ptoFin = ev.getPoint(); |
607 | 595 |
this.dragged = false; |
608 | 596 |
|
... | ... | |
610 | 598 |
double destY = newViewPort.getExtent().getMinY() + (((this.getHeight() - ptoFin.getY()) * (centerPoint.getY() - newViewPort.getExtent().getMinY())) / (this.getHeight() - ptoIni.getY())); |
611 | 599 |
|
612 | 600 |
int nPoint = Integer.valueOf(zoomControl.getDialog().getSelectPointsPanel().getTableControlerPanel().getCPoint().getSelectedItem().toString()).intValue(); |
613 |
|
|
614 |
FLyrPoints lp = zoomControl.getLyrPoints();//(FLyrPoints)lyr; |
|
615 | 601 |
|
616 | 602 |
if(zoomControl.isRightControl()){ //Control de actualizaci?n de pixel de imagen |
617 | 603 |
Point2D pixelImg = zoomControl.getLyrGeoRaster().world2Img(destX, destY); |
... | ... | |
664 | 650 |
public void mouseMoved(MouseEvent arg0) { |
665 | 651 |
|
666 | 652 |
} |
653 |
//**********************End Methods*************************** |
|
667 | 654 |
|
655 |
//**********************Setters & Getters********************* |
|
668 | 656 |
/** |
669 | 657 |
* @param cleanCanvas The cleanCanvas to set. |
670 | 658 |
*/ |
... | ... | |
672 | 660 |
this.cleanCanvas = cleanCanvas; |
673 | 661 |
} |
674 | 662 |
|
663 |
/** |
|
664 |
* Asigna el punto donde se centrar? la vista de la minimagen |
|
665 |
* @param pto Punto central. |
|
666 |
*/ |
|
667 |
public void setCenterPoint(Point2D pto){ |
|
668 |
this.centerPoint = pto; |
|
669 |
} |
|
670 |
|
|
671 |
/** |
|
672 |
* Asigna el viewPort |
|
673 |
* @param vp ViewPort |
|
674 |
*/ |
|
675 |
public void setViewPort(ViewPort vp){ |
|
676 |
this.initViewPort(vp, this.centerPoint, null); |
|
677 |
} |
|
678 |
|
|
679 |
/** |
|
680 |
* Asigna el viewPort recalculado |
|
681 |
* @param vp ViewPort |
|
682 |
*/ |
|
683 |
public void setNewViewPort(ViewPort vp){ |
|
684 |
this.newViewPort = vp; |
|
685 |
} |
|
686 |
//**********************End Setters & Getters***************** |
|
687 |
|
|
675 | 688 |
} |
676 | 689 |
|
677 | 690 |
|
trunk/extensions/extGeoreferencing/src/com/iver/cit/gvsig/gui/toolListeners/GeorefPointSelectorListener.java | ||
---|---|---|
46 | 46 |
import javax.swing.JOptionPane; |
47 | 47 |
|
48 | 48 |
import com.iver.andami.PluginServices; |
49 |
import com.iver.cit.gvsig.fmap.DriverException; |
|
50 | 49 |
import com.iver.cit.gvsig.fmap.ViewPort; |
51 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
52 |
import com.iver.cit.gvsig.fmap.layers.FLyrGeoRaster; |
|
53 |
import com.iver.cit.gvsig.fmap.layers.FLyrPoints; |
|
54 | 50 |
import com.iver.cit.gvsig.fmap.tools.BehaviorException; |
55 | 51 |
import com.iver.cit.gvsig.fmap.tools.GeorefPointerListenerImpl; |
56 | 52 |
import com.iver.cit.gvsig.fmap.tools.Events.PointEvent; |
57 | 53 |
import com.iver.cit.gvsig.gui.View; |
58 | 54 |
import com.iver.cit.gvsig.gui.Dialogs.GeoreferencingDialog; |
59 |
import com.iver.cit.gvsig.gui.Panels.SelectFilePanel; |
|
60 |
import com.iver.cit.gvsig.gui.Panels.SelectPointsPanel; |
|
61 | 55 |
|
62 | 56 |
|
63 | 57 |
/** |
... | ... | |
69 | 63 |
*/ |
70 | 64 |
public class GeorefPointSelectorListener extends GeorefPointerListenerImpl { |
71 | 65 |
|
66 |
//**********************Vars********************************** |
|
72 | 67 |
private GeoreferencingDialog dialog = null; |
73 | 68 |
private View theView = null; |
74 | 69 |
|
... | ... | |
81 | 76 |
* Posici?n del punto a ser seleccionado. |
82 | 77 |
*/ |
83 | 78 |
public static int posPoint = -1; |
79 |
//**********************End Vars****************************** |
|
84 | 80 |
|
81 |
//**********************Methods******************************* |
|
85 | 82 |
/** |
86 | 83 |
* Constructor |
87 | 84 |
* |
... | ... | |
145 | 142 |
} |
146 | 143 |
//theView.getMapControl().drawMap(false); |
147 | 144 |
} |
145 |
|
|
146 |
//**********************End Methods******************************* |
|
148 | 147 |
} |
Also available in: Unified diff