Revision 6469 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/layout/fframes/dialogs/FFrameLegendDialog.java
FFrameLegendDialog.java | ||
---|---|---|
45 | 45 |
package com.iver.cit.gvsig.gui.layout.fframes.dialogs; |
46 | 46 |
|
47 | 47 |
import com.iver.andami.PluginServices; |
48 |
import com.iver.andami.messages.NotificationManager; |
|
48 | 49 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
49 | 50 |
|
51 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
|
52 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
|
50 | 53 |
import com.iver.cit.gvsig.gui.dialogs.FontChooser; |
51 | 54 |
import com.iver.cit.gvsig.gui.layout.FLayoutUtilities; |
52 | 55 |
import com.iver.cit.gvsig.gui.layout.Layout; |
... | ... | |
54 | 57 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameView; |
55 | 58 |
import com.iver.cit.gvsig.gui.layout.fframes.IFFrame; |
56 | 59 |
import com.iver.cit.gvsig.gui.layout.fframes.ListViewModel; |
60 |
import com.iver.cit.gvsig.gui.project.MapProperties; |
|
57 | 61 |
|
62 |
import java.awt.Component; |
|
63 |
import java.awt.Dimension; |
|
64 |
import java.awt.event.ActionListener; |
|
58 | 65 |
import java.awt.geom.Rectangle2D; |
59 | 66 |
|
67 |
import javax.swing.JCheckBox; |
|
60 | 68 |
import javax.swing.JList; |
61 | 69 |
import javax.swing.JPanel; |
70 |
import javax.swing.JScrollPane; |
|
71 |
import java.awt.CardLayout; |
|
72 |
import java.util.ArrayList; |
|
73 |
import java.util.HashMap; |
|
62 | 74 |
|
75 |
import javax.swing.BoxLayout; |
|
76 |
import javax.swing.event.ChangeEvent; |
|
77 |
import javax.swing.event.ChangeListener; |
|
63 | 78 |
|
79 |
import org.apache.batik.dom.util.HashTable; |
|
80 |
import org.gvsig.gui.beans.AcceptCancelPanel; |
|
81 |
import org.gvsig.gui.beans.swing.JButton; |
|
82 |
|
|
83 |
|
|
64 | 84 |
/** |
65 | 85 |
* Dialogo para a?adir la leyenda de alguna vista al Layout. |
66 | 86 |
* |
... | ... | |
80 | 100 |
private Rectangle2D rect = new Rectangle2D.Double(); |
81 | 101 |
private Layout m_layout = null; // @jve:visual-info decl-index=0 visual-constraint="393,10" |
82 | 102 |
private FFrameLegend fframelegend = null; //new FFrameLegend(); |
103 |
private ArrayList nameLayers=new ArrayList(); |
|
104 |
private ArrayList areVisible=new ArrayList(); |
|
83 | 105 |
private boolean isAcepted = false; |
84 |
private javax.swing.JButton bFuente = null;
|
|
106 |
private JButton bFuente = null; |
|
85 | 107 |
private FFrameView fframeview = null; |
86 | 108 |
private JPRotation pRotation = null; |
87 | 109 |
//private JLabel lblNumColum = null; |
88 | 110 |
//private JTextField txtNumColum = null; |
89 | 111 |
//private ColumPanel pNumColum = null; |
112 |
private JScrollPane jScrollPane1 = null; |
|
113 |
private JPanel jPanel = null; |
|
114 |
private AcceptCancelPanel accept; |
|
90 | 115 |
|
91 | 116 |
/** |
92 | 117 |
* This is the default constructor |
... | ... | |
116 | 141 |
private void initialize() { |
117 | 142 |
this.setLayout(null); |
118 | 143 |
this.add(getJContentPane(), null); |
119 |
this.setSize(531, 190); |
|
144 |
this.setSize(616, 199); |
|
145 |
this.setSize(new java.awt.Dimension(616,189)); |
|
120 | 146 |
getPRotation().setRotation(fframelegend.getRotation()); |
121 | 147 |
} |
122 | 148 |
|
... | ... | |
129 | 155 |
if (jContentPane == null) { |
130 | 156 |
jContentPane = new javax.swing.JPanel(); |
131 | 157 |
jContentPane.setLayout(null); |
158 |
jContentPane.setBounds(new java.awt.Rectangle(3,1,609,183)); |
|
132 | 159 |
jContentPane.add(getLMarcoVista(), null); |
133 | 160 |
jContentPane.add(getJScrollPane(), null); |
134 | 161 |
jContentPane.add(getLVisualizacion(), null); |
135 | 162 |
jContentPane.add(getCbVisualizacion(), null); |
136 | 163 |
jContentPane.add(getLCalidad(), null); |
137 | 164 |
jContentPane.add(getCbCalidad(), null); |
138 |
jContentPane.add(getBAceptar(), null); |
|
139 |
jContentPane.add(getBCancelar(), null); |
|
165 |
//jContentPane.add(getBAceptar(), null); |
|
166 |
//jContentPane.add(getBCancelar(), null); |
|
167 |
jContentPane.add(getAcceptCancelPanel(),null); |
|
140 | 168 |
jContentPane.add(getBFuente(), null); |
141 |
jContentPane.setBounds(3, 1, 524, 188);
|
|
169 |
jContentPane.setBounds(3, 1, 609, 241);
|
|
142 | 170 |
jContentPane.add(getPRotation(), null); |
143 | 171 |
//jContentPane.add(lblNumColum, null); |
172 |
jContentPane.add(getJScrollPane1(), null); |
|
144 | 173 |
} |
145 | 174 |
|
146 | 175 |
return jContentPane; |
... | ... | |
154 | 183 |
private javax.swing.JLabel getLMarcoVista() { |
155 | 184 |
if (lMarcoVista == null) { |
156 | 185 |
lMarcoVista = new javax.swing.JLabel(); |
157 |
lMarcoVista.setSize(156, 63);
|
|
186 |
lMarcoVista.setSize(115, 63);
|
|
158 | 187 |
lMarcoVista.setText(PluginServices.getText(this, "marco_vista")); |
159 | 188 |
lMarcoVista.setLocation(5, 10); |
160 | 189 |
} |
... | ... | |
171 | 200 |
if (jScrollPane == null) { |
172 | 201 |
jScrollPane = new javax.swing.JScrollPane(); |
173 | 202 |
jScrollPane.setViewportView(getLiVistas()); |
174 |
jScrollPane.setSize(217, 65);
|
|
203 |
jScrollPane.setSize(179, 65);
|
|
175 | 204 |
jScrollPane.setPreferredSize(new java.awt.Dimension(70, 60)); |
176 |
jScrollPane.setLocation(167, 10);
|
|
205 |
jScrollPane.setLocation(129, 10);
|
|
177 | 206 |
} |
178 | 207 |
|
179 | 208 |
return jScrollPane; |
... | ... | |
187 | 216 |
private javax.swing.JLabel getLVisualizacion() { |
188 | 217 |
if (lVisualizacion == null) { |
189 | 218 |
lVisualizacion = new javax.swing.JLabel(); |
190 |
lVisualizacion.setSize(99, 16);
|
|
219 |
lVisualizacion.setSize(115, 16);
|
|
191 | 220 |
lVisualizacion.setText(PluginServices.getText(this, "visualizacion")); |
192 | 221 |
lVisualizacion.setLocation(6, 83); |
193 | 222 |
} |
... | ... | |
208 | 237 |
cbVisualizacion.setSelectedIndex(fframelegend.getViewing()); |
209 | 238 |
cbVisualizacion.setSize(179, 20); |
210 | 239 |
cbVisualizacion.setPreferredSize(new java.awt.Dimension(200, 20)); |
211 |
cbVisualizacion.setLocation(111, 83);
|
|
240 |
cbVisualizacion.setLocation(129, 83);
|
|
212 | 241 |
cbVisualizacion.setEnabled(false); |
213 | 242 |
} |
214 | 243 |
|
... | ... | |
223 | 252 |
private javax.swing.JLabel getLCalidad() { |
224 | 253 |
if (lCalidad == null) { |
225 | 254 |
lCalidad = new javax.swing.JLabel(); |
226 |
lCalidad.setSize(99, 16);
|
|
255 |
lCalidad.setSize(115, 16);
|
|
227 | 256 |
lCalidad.setText(PluginServices.getText(this, "calidad")); |
228 | 257 |
lCalidad.setLocation(6, 103); |
229 | 258 |
} |
... | ... | |
244 | 273 |
cbCalidad.setSelectedIndex(fframelegend.getQuality()); |
245 | 274 |
cbCalidad.setSize(179, 20); |
246 | 275 |
cbCalidad.setPreferredSize(new java.awt.Dimension(200, 20)); |
247 |
cbCalidad.setLocation(111, 103);
|
|
276 |
cbCalidad.setLocation(129, 103);
|
|
248 | 277 |
} |
249 | 278 |
|
250 | 279 |
return cbCalidad; |
251 | 280 |
} |
281 |
private AcceptCancelPanel getAcceptCancelPanel() { |
|
282 |
if (accept == null) { |
|
283 |
ActionListener okAction, cancelAction; |
|
284 |
okAction = new java.awt.event.ActionListener() { |
|
285 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
286 |
IFFrame[] fframes=m_layout.getFFrames(); |
|
287 |
for (int i = 0; i < fframes.length; |
|
288 |
i++) { |
|
289 |
IFFrame f = fframes[i]; |
|
252 | 290 |
|
253 |
/** |
|
254 |
* This method initializes bAceptar |
|
255 |
* |
|
256 |
* @return javax.swing.JButton |
|
257 |
*/ |
|
258 |
private javax.swing.JButton getBAceptar() { |
|
259 |
if (bAceptar == null) { |
|
260 |
bAceptar = new javax.swing.JButton(); |
|
261 |
bAceptar.setSize(79, 26); |
|
262 |
bAceptar.setText(PluginServices.getText(this, "Aceptar")); |
|
263 |
bAceptar.setLocation(77, 145); |
|
264 |
bAceptar.addActionListener(new java.awt.event.ActionListener() { |
|
265 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
266 |
IFFrame[] fframes=m_layout.getFFrames(); |
|
267 |
for (int i = 0; i < fframes.length; |
|
268 |
i++) { |
|
269 |
IFFrame f = fframes[i]; |
|
291 |
if (f instanceof FFrameView && |
|
292 |
(fframeview != null)) { |
|
293 |
fframelegend.setName("Leyenda de " + |
|
294 |
((FFrameView) f).toString()); |
|
270 | 295 |
|
271 |
if (f instanceof FFrameView && |
|
272 |
(fframeview != null)) { |
|
273 |
//if (f.getName().compareTo(m_projectView.getName())==0){ |
|
274 |
//Esto cambia para que la escala se calcule en fframeview y no en fframescalebar. |
|
275 |
/// fframelegend.setFMap(((FFrameView)f).getFMap()); |
|
276 |
fframelegend.setName("Leyenda de " + |
|
277 |
((FFrameView) f).toString()); |
|
278 | 296 |
|
279 |
///fframescalebar.setScaleView(((FFrameView)f).getScale()); |
|
280 |
//} |
|
281 |
} |
|
282 | 297 |
} |
283 |
|
|
284 |
/*if (m_projectView!=null){ |
|
285 |
fframelegend.setLayers(m_projectView.getMapContext().getLayers()); |
|
286 |
} |
|
287 |
*/ |
|
288 |
fframelegend.setViewing(cbVisualizacion.getSelectedIndex()); |
|
289 |
fframelegend.setQuality(cbCalidad.getSelectedIndex()); |
|
290 |
fframelegend.setBoundBox(FLayoutUtilities.toSheetRect( |
|
291 |
rect, m_layout.getAT())); |
|
292 |
fframelegend.setRotation(getPRotation().getRotation()); |
|
293 |
|
|
294 |
PluginServices.getMDIManager().closeView(FFrameLegendDialog.this); |
|
295 |
m_layout.refresh(); |
|
296 |
isAcepted = true; |
|
297 | 298 |
} |
298 |
}); |
|
299 |
} |
|
300 | 299 |
|
301 |
return bAceptar; |
|
302 |
} |
|
300 |
/*if (m_projectView!=null){ |
|
301 |
fframelegend.setLayers(m_projectView.getMapContext().getLayers()); |
|
302 |
} |
|
303 |
*/ |
|
304 |
fframelegend.setNameLayers(nameLayers); |
|
305 |
fframelegend.setAreVisible(areVisible); |
|
306 |
fframelegend.setViewing(cbVisualizacion.getSelectedIndex()); |
|
307 |
fframelegend.setQuality(cbCalidad.getSelectedIndex()); |
|
308 |
fframelegend.setBoundBox(FLayoutUtilities.toSheetRect( |
|
309 |
rect, m_layout.getAT())); |
|
310 |
fframelegend.setRotation(getPRotation().getRotation()); |
|
303 | 311 |
|
304 |
/** |
|
305 |
* This method initializes bCancelar |
|
306 |
* |
|
307 |
* @return javax.swing.JButton |
|
308 |
*/ |
|
309 |
private javax.swing.JButton getBCancelar() { |
|
310 |
if (bCancelar == null) { |
|
311 |
bCancelar = new javax.swing.JButton(); |
|
312 |
bCancelar.setSize(85, 26); |
|
313 |
bCancelar.setText(PluginServices.getText(this, "Cancelar")); |
|
314 |
bCancelar.setLocation(233, 145); |
|
315 |
bCancelar.addActionListener(new java.awt.event.ActionListener() { |
|
316 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
317 |
PluginServices.getMDIManager().closeView(FFrameLegendDialog.this); |
|
318 |
} |
|
319 |
}); |
|
312 |
PluginServices.getMDIManager().closeView(FFrameLegendDialog.this); |
|
313 |
m_layout.refresh(); |
|
314 |
isAcepted = true; |
|
315 |
} |
|
316 |
}; |
|
317 |
cancelAction = new java.awt.event.ActionListener() { |
|
318 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
|
319 |
PluginServices.getMDIManager().closeView(FFrameLegendDialog.this); |
|
320 |
} |
|
321 |
}; |
|
322 |
accept = new AcceptCancelPanel(okAction, cancelAction); |
|
323 |
accept.setPreferredSize(new java.awt.Dimension(300,34)); |
|
324 |
accept.setBounds(new java.awt.Rectangle(5,140,200,30)); |
|
325 |
//accept.setLocation(5, 200); |
|
320 | 326 |
} |
321 |
|
|
322 |
return bCancelar; |
|
327 |
return accept; |
|
323 | 328 |
} |
324 | 329 |
|
325 | 330 |
/** |
... | ... | |
344 | 349 |
|
345 | 350 |
if (fframeview == fframelegend.getFFrameDependence()) { |
346 | 351 |
liVistas.setSelectedIndex(i); |
352 |
nameLayers=fframelegend.getNameLayers(); |
|
353 |
areVisible=fframelegend.getAreVisible(); |
|
354 |
refreshLayers(); |
|
347 | 355 |
} |
348 | 356 |
|
349 | 357 |
/*m_projectView=(ProjectView)liVistas.getModel().getElementAt(i); |
... | ... | |
376 | 384 |
.getView()) { |
377 | 385 |
fframelegend |
378 | 386 |
.setFFrameDependence(fframeview); |
387 |
refreshLayers(); |
|
379 | 388 |
} |
380 | 389 |
} |
381 | 390 |
} |
... | ... | |
383 | 392 |
// fframelegend.setFFrameView(fframeview); |
384 | 393 |
} |
385 | 394 |
} |
395 |
|
|
386 | 396 |
}); |
387 | 397 |
} |
388 | 398 |
|
389 | 399 |
return liVistas; |
390 | 400 |
} |
401 |
private void refreshLayers() { |
|
402 |
getJPanel().removeAll(); |
|
391 | 403 |
|
404 |
if (fframeview==null) |
|
405 |
return; |
|
406 |
|
|
407 |
FLayers layers=fframeview.getFMap().getLayers(); |
|
408 |
boolean clear=false; |
|
409 |
if (layers.getLayersCount()!=nameLayers.size()) { |
|
410 |
clear=true; |
|
411 |
}else { |
|
412 |
int j=0; |
|
413 |
for (int i=layers.getLayersCount()-1;i>=0;i--) { |
|
414 |
String name=(String)nameLayers.get(j); |
|
415 |
if (!(nameLayers.size()>j && nameLayers.get(j).equals(name))) { |
|
416 |
clear=true; |
|
417 |
break; |
|
418 |
} |
|
419 |
j++; |
|
420 |
} |
|
421 |
} |
|
422 |
if (clear) { |
|
423 |
nameLayers.clear(); |
|
424 |
areVisible.clear(); |
|
425 |
} |
|
426 |
int j=0; |
|
427 |
for (int i=layers.getLayersCount()-1;i>=0;i--) { |
|
428 |
String name=layers.getLayer(i).getName(); |
|
429 |
if (nameLayers.size()>j && nameLayers.get(j).equals(name)) { |
|
430 |
boolean b=((Boolean)areVisible.get(j)).booleanValue(); |
|
431 |
addLayer(name,j,b); |
|
432 |
nameLayers.set(j,name); |
|
433 |
areVisible.set(j,new Boolean(b)); |
|
434 |
}else { |
|
435 |
addLayer(name,j,layers.getLayer(j).isVisible()); |
|
436 |
nameLayers.add(name); |
|
437 |
areVisible.add(new Boolean(layers.getLayer(i).isVisible())); |
|
438 |
|
|
439 |
} |
|
440 |
j++; |
|
441 |
|
|
442 |
} |
|
443 |
getJPanel().setSize(new Dimension(100,100)); |
|
444 |
} |
|
445 |
private void addLayer(String name,int i,boolean b) { |
|
446 |
JCheckBox chbox=new JCheckBox(name,b); |
|
447 |
// if (nameLayers.size()>i) { |
|
448 |
// nameLayers.set(i,name); |
|
449 |
// areVisible.set(i,new Boolean(b)); |
|
450 |
// }else { |
|
451 |
// nameLayers.add(name); |
|
452 |
// areVisible.add(new Boolean(b)); |
|
453 |
// } |
|
454 |
|
|
455 |
chbox.addChangeListener(new ChangeListener() { |
|
456 |
|
|
457 |
public void stateChanged(ChangeEvent arg0) { |
|
458 |
JCheckBox ckb=(JCheckBox)arg0.getSource(); |
|
459 |
Component[] components=getJPanel().getComponents(); |
|
460 |
int j=0; |
|
461 |
for (int i=components.length-1;i>=0;i--) { |
|
462 |
if (components[i].equals(ckb)) { |
|
463 |
areVisible.set(i,new Boolean(ckb.isSelected())); |
|
464 |
} |
|
465 |
j++; |
|
466 |
} |
|
467 |
//hashVisible.put(ckb.getLabel(),new Boolean(ckb.isSelected())); |
|
468 |
} |
|
469 |
|
|
470 |
}); |
|
471 |
getJPanel().add(name,chbox); |
|
472 |
} |
|
392 | 473 |
/* (non-Javadoc) |
393 | 474 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo() |
394 | 475 |
*/ |
... | ... | |
418 | 499 |
* |
419 | 500 |
* @return javax.swing.JButton |
420 | 501 |
*/ |
421 |
private javax.swing.JButton getBFuente() {
|
|
502 |
private JButton getBFuente() { |
|
422 | 503 |
if (bFuente == null) { |
423 |
bFuente = new javax.swing.JButton();
|
|
504 |
bFuente = new JButton(); |
|
424 | 505 |
bFuente.setSize(90, 23); |
425 | 506 |
bFuente.setText(PluginServices.getText(this, "fuente")); |
426 |
bFuente.setLocation(297, 89);
|
|
507 |
bFuente.setLocation(217, 146);
|
|
427 | 508 |
bFuente.addActionListener(new java.awt.event.ActionListener() { |
428 | 509 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
429 | 510 |
if (fframelegend.getFont() != null) { |
... | ... | |
451 | 532 |
private JPRotation getPRotation() { |
452 | 533 |
if (pRotation == null) { |
453 | 534 |
pRotation = new JPRotation(); |
454 |
pRotation.setBounds(400, 19, 120, 120);
|
|
535 |
pRotation.setBounds(470, 19, 120, 120);
|
|
455 | 536 |
} |
456 | 537 |
return pRotation; |
457 | 538 |
} |
458 | 539 |
|
540 |
/** |
|
541 |
* This method initializes jScrollPane1 |
|
542 |
* |
|
543 |
* @return javax.swing.JScrollPane |
|
544 |
*/ |
|
545 |
private JScrollPane getJScrollPane1() { |
|
546 |
if (jScrollPane1 == null) { |
|
547 |
jScrollPane1 = new JScrollPane(); |
|
548 |
jScrollPane1.setBounds(new java.awt.Rectangle(314,10,137,158)); |
|
549 |
jScrollPane1.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); |
|
550 |
jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
|
551 |
jScrollPane1.setViewportView(getJPanel()); |
|
552 |
} |
|
553 |
return jScrollPane1; |
|
554 |
} |
|
555 |
|
|
556 |
/** |
|
557 |
* This method initializes jPanel |
|
558 |
* |
|
559 |
* @return javax.swing.JPanel |
|
560 |
*/ |
|
561 |
private JPanel getJPanel() { |
|
562 |
if (jPanel == null) { |
|
563 |
jPanel = new JPanel(); |
|
564 |
jPanel.setLayout(new BoxLayout(getJPanel(), BoxLayout.Y_AXIS)); |
|
565 |
} |
|
566 |
return jPanel; |
|
567 |
} |
|
568 |
|
|
459 | 569 |
} // @jve:decl-index=0:visual-constraint="10,10" |
Also available in: Unified diff