root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / dialogs / FFrameLegendDialog.java @ 3278
History | View | Annotate | Download (12.6 KB)
1 |
/*
|
---|---|
2 |
* Created on 02-jun-2004
|
3 |
*
|
4 |
*/
|
5 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
6 |
*
|
7 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
8 |
*
|
9 |
* This program is free software; you can redistribute it and/or
|
10 |
* modify it under the terms of the GNU General Public License
|
11 |
* as published by the Free Software Foundation; either version 2
|
12 |
* of the License, or (at your option) any later version.
|
13 |
*
|
14 |
* This program is distributed in the hope that it will be useful,
|
15 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
16 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
17 |
* GNU General Public License for more details.
|
18 |
*
|
19 |
* You should have received a copy of the GNU General Public License
|
20 |
* along with this program; if not, write to the Free Software
|
21 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
22 |
*
|
23 |
* For more information, contact:
|
24 |
*
|
25 |
* Generalitat Valenciana
|
26 |
* Conselleria d'Infraestructures i Transport
|
27 |
* Av. Blasco Ib??ez, 50
|
28 |
* 46010 VALENCIA
|
29 |
* SPAIN
|
30 |
*
|
31 |
* +34 963862235
|
32 |
* gvsig@gva.es
|
33 |
* www.gvsig.gva.es
|
34 |
*
|
35 |
* or
|
36 |
*
|
37 |
* IVER T.I. S.A
|
38 |
* Salamanca 50
|
39 |
* 46005 Valencia
|
40 |
* Spain
|
41 |
*
|
42 |
* +34 963163400
|
43 |
* dac@iver.es
|
44 |
*/
|
45 |
package com.iver.cit.gvsig.gui.layout.fframes.dialogs; |
46 |
|
47 |
import com.iver.andami.PluginServices; |
48 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
49 |
|
50 |
import com.iver.cit.gvsig.gui.Dialogs.FontChooser; |
51 |
import com.iver.cit.gvsig.gui.layout.FLayoutUtilities; |
52 |
import com.iver.cit.gvsig.gui.layout.Layout; |
53 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameLegend; |
54 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameView; |
55 |
import com.iver.cit.gvsig.gui.layout.fframes.IFFrame; |
56 |
import com.iver.cit.gvsig.gui.layout.fframes.ListViewModel; |
57 |
|
58 |
import java.awt.geom.Rectangle2D; |
59 |
|
60 |
import javax.swing.JList; |
61 |
import javax.swing.JPanel; |
62 |
|
63 |
|
64 |
/**
|
65 |
* Dialogo para a?adir la leyenda de alguna vista al Layout.
|
66 |
*
|
67 |
* @author Vicente Caballero Navarro
|
68 |
*/
|
69 |
public class FFrameLegendDialog extends JPanel implements IFFrameDialog { |
70 |
private javax.swing.JPanel jContentPane = null; |
71 |
private javax.swing.JLabel lMarcoVista = null; |
72 |
private javax.swing.JScrollPane jScrollPane = null; |
73 |
private javax.swing.JLabel lVisualizacion = null; |
74 |
private javax.swing.JComboBox cbVisualizacion = null; |
75 |
private javax.swing.JLabel lCalidad = null; |
76 |
private javax.swing.JComboBox cbCalidad = null; |
77 |
private javax.swing.JButton bAceptar = null; |
78 |
private javax.swing.JButton bCancelar = null; |
79 |
private javax.swing.JList liVistas = null; |
80 |
private Rectangle2D rect = new Rectangle2D.Double(); |
81 |
private Layout m_layout = null; // @jve:visual-info decl-index=0 visual-constraint="393,10" |
82 |
private FFrameLegend fframelegend = null; //new FFrameLegend(); |
83 |
private boolean isAcepted = false; |
84 |
private javax.swing.JButton bFuente = null; |
85 |
private FFrameView fframeview = null; |
86 |
private JPRotation pRotation = null; |
87 |
|
88 |
/**
|
89 |
* This is the default constructor
|
90 |
*
|
91 |
* @param layout Referencia al Layout.
|
92 |
* @param fframe Referencia al FFrameLegend.
|
93 |
*/
|
94 |
public FFrameLegendDialog(Layout layout, FFrameLegend fframe) {
|
95 |
super();
|
96 |
m_layout = layout; |
97 |
fframelegend = fframe; |
98 |
initialize(); |
99 |
} |
100 |
|
101 |
/**
|
102 |
* Inserta el rect?ngulo que ocupar? el fframe de leyenda.
|
103 |
*
|
104 |
* @param r extent.
|
105 |
*/
|
106 |
public void setRectangle(Rectangle2D r) { |
107 |
rect.setRect(r); |
108 |
} |
109 |
|
110 |
/**
|
111 |
* This method initializes this
|
112 |
*/
|
113 |
private void initialize() { |
114 |
this.setLayout(null); |
115 |
this.add(getJContentPane(), null); |
116 |
this.setSize(531, 175); |
117 |
getPRotation().setRotation(fframelegend.getRotation()); |
118 |
} |
119 |
|
120 |
/**
|
121 |
* This method initializes jContentPane
|
122 |
*
|
123 |
* @return javax.swing.JPanel
|
124 |
*/
|
125 |
private javax.swing.JPanel getJContentPane() {
|
126 |
if (jContentPane == null) { |
127 |
jContentPane = new javax.swing.JPanel();
|
128 |
jContentPane.setLayout(null);
|
129 |
jContentPane.add(getLMarcoVista(), null);
|
130 |
jContentPane.add(getJScrollPane(), null);
|
131 |
jContentPane.add(getLVisualizacion(), null);
|
132 |
jContentPane.add(getCbVisualizacion(), null);
|
133 |
jContentPane.add(getLCalidad(), null);
|
134 |
jContentPane.add(getCbCalidad(), null);
|
135 |
jContentPane.add(getBAceptar(), null);
|
136 |
jContentPane.add(getBCancelar(), null);
|
137 |
jContentPane.add(getBFuente(), null);
|
138 |
jContentPane.setBounds(3, 1, 524, 171); |
139 |
jContentPane.add(getPRotation(), null);
|
140 |
} |
141 |
|
142 |
return jContentPane;
|
143 |
} |
144 |
|
145 |
/**
|
146 |
* This method initializes lMarcoVista
|
147 |
*
|
148 |
* @return javax.swing.JLabel
|
149 |
*/
|
150 |
private javax.swing.JLabel getLMarcoVista() {
|
151 |
if (lMarcoVista == null) { |
152 |
lMarcoVista = new javax.swing.JLabel();
|
153 |
lMarcoVista.setSize(156, 63); |
154 |
lMarcoVista.setText(PluginServices.getText(this, "marco_vista")); |
155 |
lMarcoVista.setLocation(5, 10); |
156 |
} |
157 |
|
158 |
return lMarcoVista;
|
159 |
} |
160 |
|
161 |
/**
|
162 |
* This method initializes jScrollPane
|
163 |
*
|
164 |
* @return javax.swing.JScrollPane
|
165 |
*/
|
166 |
private javax.swing.JScrollPane getJScrollPane() {
|
167 |
if (jScrollPane == null) { |
168 |
jScrollPane = new javax.swing.JScrollPane();
|
169 |
jScrollPane.setViewportView(getLiVistas()); |
170 |
jScrollPane.setSize(217, 65); |
171 |
jScrollPane.setPreferredSize(new java.awt.Dimension(70, 60)); |
172 |
jScrollPane.setLocation(167, 10); |
173 |
} |
174 |
|
175 |
return jScrollPane;
|
176 |
} |
177 |
|
178 |
/**
|
179 |
* This method initializes lVisualizacion
|
180 |
*
|
181 |
* @return javax.swing.JLabel
|
182 |
*/
|
183 |
private javax.swing.JLabel getLVisualizacion() {
|
184 |
if (lVisualizacion == null) { |
185 |
lVisualizacion = new javax.swing.JLabel();
|
186 |
lVisualizacion.setSize(99, 16); |
187 |
lVisualizacion.setText(PluginServices.getText(this, "visualizacion")); |
188 |
lVisualizacion.setLocation(6, 83); |
189 |
} |
190 |
|
191 |
return lVisualizacion;
|
192 |
} |
193 |
|
194 |
/**
|
195 |
* This method initializes cbVisualizacion
|
196 |
*
|
197 |
* @return javax.swing.JComboBox
|
198 |
*/
|
199 |
private javax.swing.JComboBox getCbVisualizacion() {
|
200 |
if (cbVisualizacion == null) { |
201 |
cbVisualizacion = new javax.swing.JComboBox();
|
202 |
cbVisualizacion.addItem(PluginServices.getText(this, "cuando_activo")); |
203 |
cbVisualizacion.addItem(PluginServices.getText(this, "siempre")); |
204 |
cbVisualizacion.setSelectedIndex(fframelegend.getViewing()); |
205 |
cbVisualizacion.setSize(179, 20); |
206 |
cbVisualizacion.setPreferredSize(new java.awt.Dimension(200, 20)); |
207 |
cbVisualizacion.setLocation(111, 83); |
208 |
cbVisualizacion.setEnabled(false);
|
209 |
} |
210 |
|
211 |
return cbVisualizacion;
|
212 |
} |
213 |
|
214 |
/**
|
215 |
* This method initializes lCalidad
|
216 |
*
|
217 |
* @return javax.swing.JLabel
|
218 |
*/
|
219 |
private javax.swing.JLabel getLCalidad() {
|
220 |
if (lCalidad == null) { |
221 |
lCalidad = new javax.swing.JLabel();
|
222 |
lCalidad.setSize(99, 16); |
223 |
lCalidad.setText(PluginServices.getText(this, "calidad")); |
224 |
lCalidad.setLocation(6, 103); |
225 |
} |
226 |
|
227 |
return lCalidad;
|
228 |
} |
229 |
|
230 |
/**
|
231 |
* This method initializes cbCalidad
|
232 |
*
|
233 |
* @return javax.swing.JComboBox
|
234 |
*/
|
235 |
private javax.swing.JComboBox getCbCalidad() {
|
236 |
if (cbCalidad == null) { |
237 |
cbCalidad = new javax.swing.JComboBox();
|
238 |
cbCalidad.addItem(PluginServices.getText(this, "presentacion")); |
239 |
cbCalidad.addItem(PluginServices.getText(this, "borrador")); |
240 |
cbCalidad.setSelectedIndex(fframelegend.getQuality()); |
241 |
cbCalidad.setSize(179, 20); |
242 |
cbCalidad.setPreferredSize(new java.awt.Dimension(200, 20)); |
243 |
cbCalidad.setLocation(111, 103); |
244 |
} |
245 |
|
246 |
return cbCalidad;
|
247 |
} |
248 |
|
249 |
/**
|
250 |
* This method initializes bAceptar
|
251 |
*
|
252 |
* @return javax.swing.JButton
|
253 |
*/
|
254 |
private javax.swing.JButton getBAceptar() {
|
255 |
if (bAceptar == null) { |
256 |
bAceptar = new javax.swing.JButton();
|
257 |
bAceptar.setSize(79, 26); |
258 |
bAceptar.setText(PluginServices.getText(this, "Aceptar")); |
259 |
bAceptar.setLocation(77, 129); |
260 |
bAceptar.addActionListener(new java.awt.event.ActionListener() {
|
261 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
262 |
for (int i = 0; i < m_layout.getFFrames().size(); |
263 |
i++) { |
264 |
IFFrame f = (IFFrame) m_layout.getFFrames().get(i); |
265 |
|
266 |
if (f instanceof FFrameView && |
267 |
(fframeview != null)) {
|
268 |
//if (f.getName().compareTo(m_projectView.getName())==0){
|
269 |
//Esto cambia para que la escala se calcule en fframeview y no en fframescalebar.
|
270 |
/// fframelegend.setFMap(((FFrameView)f).getFMap());
|
271 |
fframelegend.setName("Leyenda de " +
|
272 |
((FFrameView) f).toString()); |
273 |
|
274 |
///fframescalebar.setScaleView(((FFrameView)f).getScale());
|
275 |
//}
|
276 |
} |
277 |
} |
278 |
|
279 |
/*if (m_projectView!=null){
|
280 |
fframelegend.setLayers(m_projectView.getMapContext().getLayers());
|
281 |
}
|
282 |
*/
|
283 |
fframelegend.setViewing(cbVisualizacion.getSelectedIndex()); |
284 |
fframelegend.setQuality(cbCalidad.getSelectedIndex()); |
285 |
fframelegend.setBoundBox(FLayoutUtilities.toSheetRect( |
286 |
rect, m_layout.getAT())); |
287 |
fframelegend.setRotation(getPRotation().getRotation()); |
288 |
PluginServices.getMDIManager().closeView(FFrameLegendDialog.this); |
289 |
m_layout.refresh(); |
290 |
isAcepted = true;
|
291 |
} |
292 |
}); |
293 |
} |
294 |
|
295 |
return bAceptar;
|
296 |
} |
297 |
|
298 |
/**
|
299 |
* This method initializes bCancelar
|
300 |
*
|
301 |
* @return javax.swing.JButton
|
302 |
*/
|
303 |
private javax.swing.JButton getBCancelar() {
|
304 |
if (bCancelar == null) { |
305 |
bCancelar = new javax.swing.JButton();
|
306 |
bCancelar.setSize(85, 26); |
307 |
bCancelar.setText(PluginServices.getText(this, "Cancelar")); |
308 |
bCancelar.setLocation(233, 129); |
309 |
bCancelar.addActionListener(new java.awt.event.ActionListener() {
|
310 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
311 |
PluginServices.getMDIManager().closeView(FFrameLegendDialog.this); |
312 |
} |
313 |
}); |
314 |
} |
315 |
|
316 |
return bCancelar;
|
317 |
} |
318 |
|
319 |
/**
|
320 |
* This method initializes liVistas
|
321 |
*
|
322 |
* @return javax.swing.JList
|
323 |
*/
|
324 |
private javax.swing.JList getLiVistas() {
|
325 |
if (liVistas == null) { |
326 |
ListViewModel listmodel = new ListViewModel();
|
327 |
|
328 |
//listmodel.addViews();
|
329 |
listmodel.addViews(m_layout); |
330 |
|
331 |
///ArrayList list = listmodel.getViews();
|
332 |
liVistas = new javax.swing.JList();
|
333 |
liVistas.setModel(listmodel); |
334 |
|
335 |
for (int i = 0; i < liVistas.getModel().getSize(); i++) { |
336 |
if (fframelegend.getFFrameDependence() != null) { |
337 |
fframeview = (FFrameView) liVistas.getModel().getElementAt(i); |
338 |
|
339 |
if (fframeview == fframelegend.getFFrameDependence()) {
|
340 |
liVistas.setSelectedIndex(i); |
341 |
} |
342 |
|
343 |
/*m_projectView=(ProjectView)liVistas.getModel().getElementAt(i);
|
344 |
if (m_projectView.getMapContext()==fframelegend.getFMap()){
|
345 |
liVistas.setSelectedIndex(i);
|
346 |
}
|
347 |
*/
|
348 |
} |
349 |
} |
350 |
|
351 |
liVistas.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
352 |
private int selectIndex=-1; |
353 |
public void valueChanged( |
354 |
javax.swing.event.ListSelectionEvent e) { |
355 |
/* int selectInt=(int)e.getFirstIndex();
|
356 |
m_projectView=(ProjectView)liVistas.getModel().getElementAt(selectInt);
|
357 |
*/
|
358 |
int selectInt = (int) ((JList)e.getSource()).getSelectedIndex(); |
359 |
if (selectInt!=selectIndex){
|
360 |
selectIndex=selectInt; |
361 |
fframeview = (FFrameView) liVistas.getModel() |
362 |
.getElementAt(selectInt); |
363 |
|
364 |
for (int i = 0; i < m_layout.getFFrames().size(); |
365 |
i++) { |
366 |
IFFrame f = (IFFrame) m_layout.getFFrames().get(i); |
367 |
|
368 |
if (f instanceof FFrameView) { |
369 |
if (((FFrameView) f).getView() == fframeview.getView()) {
|
370 |
fframelegend.setFFrameDependence(fframeview); |
371 |
} |
372 |
} |
373 |
} |
374 |
|
375 |
//fframelegend.setFFrameView(fframeview);
|
376 |
} |
377 |
} |
378 |
}); |
379 |
} |
380 |
|
381 |
return liVistas;
|
382 |
} |
383 |
|
384 |
/* (non-Javadoc)
|
385 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
386 |
*/
|
387 |
public ViewInfo getViewInfo() {
|
388 |
ViewInfo m_viewinfo = new ViewInfo(ViewInfo.MODALDIALOG);
|
389 |
m_viewinfo.setTitle(PluginServices.getText(this,
|
390 |
"propiedades_marco_leyenda"));
|
391 |
|
392 |
return m_viewinfo;
|
393 |
} |
394 |
|
395 |
/**
|
396 |
* @see com.iver.cit.gvsig.gui.layout.fframes.dialogs.IFFrameDialog#getIsAcepted()
|
397 |
*/
|
398 |
public boolean getIsAcepted() { |
399 |
return isAcepted;
|
400 |
} |
401 |
|
402 |
/**
|
403 |
* @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
|
404 |
*/
|
405 |
public void viewActivated() { |
406 |
} |
407 |
|
408 |
/**
|
409 |
* This method initializes bFuente
|
410 |
*
|
411 |
* @return javax.swing.JButton
|
412 |
*/
|
413 |
private javax.swing.JButton getBFuente() {
|
414 |
if (bFuente == null) { |
415 |
bFuente = new javax.swing.JButton();
|
416 |
bFuente.setSize(90, 23); |
417 |
bFuente.setText(PluginServices.getText(this, "fuente")); |
418 |
bFuente.setLocation(297, 89); |
419 |
bFuente.addActionListener(new java.awt.event.ActionListener() {
|
420 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
421 |
if (fframelegend.getFont() != null) { |
422 |
fframelegend.setFont(FontChooser.showDialog( |
423 |
PluginServices.getText(this,
|
424 |
"seleccion_fuente"),
|
425 |
fframelegend.getFont())); // fchoser=new FontChooser();
|
426 |
} else {
|
427 |
fframelegend.setFont(FontChooser.showDialog( |
428 |
PluginServices.getText(this,
|
429 |
"seleccion_fuente"), getFont()));
|
430 |
} |
431 |
} |
432 |
}); |
433 |
} |
434 |
|
435 |
return bFuente;
|
436 |
} |
437 |
|
438 |
/**
|
439 |
* This method initializes pRotation
|
440 |
*
|
441 |
* @return javax.swing.JPanel
|
442 |
*/
|
443 |
private JPRotation getPRotation() {
|
444 |
if (pRotation == null) { |
445 |
pRotation = new JPRotation();
|
446 |
pRotation.setBounds(400, 19, 120, 120); |
447 |
} |
448 |
return pRotation;
|
449 |
} |
450 |
} // @jve:decl-index=0:visual-constraint="10,10"
|