root / branches / gvSIG_CAD_Layout_version / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / fframes / dialogs / FFrameLegendDialog.java @ 1822
History | View | Annotate | Download (12 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 |
import javax.swing.JPanel; |
60 |
|
61 |
|
62 |
/**
|
63 |
* Dialogo para a?adir la leyenda de alguna vista al Layout.
|
64 |
*
|
65 |
* @author Vicente Caballero Navarro
|
66 |
*/
|
67 |
public class FFrameLegendDialog extends JPanel implements IFFrameDialog { |
68 |
private javax.swing.JPanel jContentPane = null; |
69 |
private javax.swing.JLabel lMarcoVista = null; |
70 |
private javax.swing.JScrollPane jScrollPane = null; |
71 |
private javax.swing.JLabel lVisualizacion = null; |
72 |
private javax.swing.JComboBox cbVisualizacion = null; |
73 |
private javax.swing.JLabel lCalidad = null; |
74 |
private javax.swing.JComboBox cbCalidad = null; |
75 |
private javax.swing.JButton bAceptar = null; |
76 |
private javax.swing.JButton bCancelar = null; |
77 |
private javax.swing.JList liVistas = null; |
78 |
private Rectangle2D rect = new Rectangle2D.Double(); |
79 |
private Layout m_layout = null; // @jve:visual-info decl-index=0 visual-constraint="393,10" |
80 |
private FFrameLegend fframelegend = null; //new FFrameLegend(); |
81 |
private boolean isAcepted = false; |
82 |
private javax.swing.JButton bFuente = null; |
83 |
private FFrameView fframeview = null; |
84 |
|
85 |
/**
|
86 |
* This is the default constructor
|
87 |
*
|
88 |
* @param layout Referencia al Layout.
|
89 |
* @param fframe Referencia al FFrameLegend.
|
90 |
*/
|
91 |
public FFrameLegendDialog(Layout layout, FFrameLegend fframe) {
|
92 |
super();
|
93 |
m_layout = layout; |
94 |
fframelegend = fframe; |
95 |
initialize(); |
96 |
} |
97 |
|
98 |
/**
|
99 |
* Inserta el rect?ngulo que ocupar? el fframe de leyenda.
|
100 |
*
|
101 |
* @param r extent.
|
102 |
*/
|
103 |
public void setRectangle(Rectangle2D r) { |
104 |
rect.setRect(r); |
105 |
} |
106 |
|
107 |
/**
|
108 |
* This method initializes this
|
109 |
*/
|
110 |
private void initialize() { |
111 |
this.setLayout(null); |
112 |
this.add(getJContentPane(), null); |
113 |
this.setSize(406, 175); |
114 |
} |
115 |
|
116 |
/**
|
117 |
* This method initializes jContentPane
|
118 |
*
|
119 |
* @return javax.swing.JPanel
|
120 |
*/
|
121 |
private javax.swing.JPanel getJContentPane() {
|
122 |
if (jContentPane == null) { |
123 |
jContentPane = new javax.swing.JPanel();
|
124 |
jContentPane.setLayout(null);
|
125 |
jContentPane.add(getLMarcoVista(), null);
|
126 |
jContentPane.add(getJScrollPane(), null);
|
127 |
jContentPane.add(getLVisualizacion(), null);
|
128 |
jContentPane.add(getCbVisualizacion(), null);
|
129 |
jContentPane.add(getLCalidad(), null);
|
130 |
jContentPane.add(getCbCalidad(), null);
|
131 |
jContentPane.add(getBAceptar(), null);
|
132 |
jContentPane.add(getBCancelar(), null);
|
133 |
jContentPane.add(getBFuente(), null);
|
134 |
jContentPane.setBounds(3, 1, 402, 171); |
135 |
} |
136 |
|
137 |
return jContentPane;
|
138 |
} |
139 |
|
140 |
/**
|
141 |
* This method initializes lMarcoVista
|
142 |
*
|
143 |
* @return javax.swing.JLabel
|
144 |
*/
|
145 |
private javax.swing.JLabel getLMarcoVista() {
|
146 |
if (lMarcoVista == null) { |
147 |
lMarcoVista = new javax.swing.JLabel();
|
148 |
lMarcoVista.setSize(156, 63); |
149 |
lMarcoVista.setText(PluginServices.getText(this, "marco_vista")); |
150 |
lMarcoVista.setLocation(5, 10); |
151 |
} |
152 |
|
153 |
return lMarcoVista;
|
154 |
} |
155 |
|
156 |
/**
|
157 |
* This method initializes jScrollPane
|
158 |
*
|
159 |
* @return javax.swing.JScrollPane
|
160 |
*/
|
161 |
private javax.swing.JScrollPane getJScrollPane() {
|
162 |
if (jScrollPane == null) { |
163 |
jScrollPane = new javax.swing.JScrollPane();
|
164 |
jScrollPane.setViewportView(getLiVistas()); |
165 |
jScrollPane.setSize(217, 65); |
166 |
jScrollPane.setPreferredSize(new java.awt.Dimension(70, 60)); |
167 |
jScrollPane.setLocation(167, 10); |
168 |
} |
169 |
|
170 |
return jScrollPane;
|
171 |
} |
172 |
|
173 |
/**
|
174 |
* This method initializes lVisualizacion
|
175 |
*
|
176 |
* @return javax.swing.JLabel
|
177 |
*/
|
178 |
private javax.swing.JLabel getLVisualizacion() {
|
179 |
if (lVisualizacion == null) { |
180 |
lVisualizacion = new javax.swing.JLabel();
|
181 |
lVisualizacion.setSize(99, 16); |
182 |
lVisualizacion.setText(PluginServices.getText(this, "visualizacion")); |
183 |
lVisualizacion.setLocation(6, 83); |
184 |
} |
185 |
|
186 |
return lVisualizacion;
|
187 |
} |
188 |
|
189 |
/**
|
190 |
* This method initializes cbVisualizacion
|
191 |
*
|
192 |
* @return javax.swing.JComboBox
|
193 |
*/
|
194 |
private javax.swing.JComboBox getCbVisualizacion() {
|
195 |
if (cbVisualizacion == null) { |
196 |
cbVisualizacion = new javax.swing.JComboBox();
|
197 |
cbVisualizacion.addItem(PluginServices.getText(this, "cuando_activo")); |
198 |
cbVisualizacion.addItem(PluginServices.getText(this, "siempre")); |
199 |
cbVisualizacion.setSelectedIndex(fframelegend.getViewing()); |
200 |
cbVisualizacion.setSize(179, 20); |
201 |
cbVisualizacion.setPreferredSize(new java.awt.Dimension(200, 20)); |
202 |
cbVisualizacion.setLocation(111, 83); |
203 |
cbVisualizacion.setEnabled(false);
|
204 |
} |
205 |
|
206 |
return cbVisualizacion;
|
207 |
} |
208 |
|
209 |
/**
|
210 |
* This method initializes lCalidad
|
211 |
*
|
212 |
* @return javax.swing.JLabel
|
213 |
*/
|
214 |
private javax.swing.JLabel getLCalidad() {
|
215 |
if (lCalidad == null) { |
216 |
lCalidad = new javax.swing.JLabel();
|
217 |
lCalidad.setSize(99, 16); |
218 |
lCalidad.setText(PluginServices.getText(this, "calidad")); |
219 |
lCalidad.setLocation(6, 103); |
220 |
} |
221 |
|
222 |
return lCalidad;
|
223 |
} |
224 |
|
225 |
/**
|
226 |
* This method initializes cbCalidad
|
227 |
*
|
228 |
* @return javax.swing.JComboBox
|
229 |
*/
|
230 |
private javax.swing.JComboBox getCbCalidad() {
|
231 |
if (cbCalidad == null) { |
232 |
cbCalidad = new javax.swing.JComboBox();
|
233 |
cbCalidad.addItem(PluginServices.getText(this, "presentacion")); |
234 |
cbCalidad.addItem(PluginServices.getText(this, "borrador")); |
235 |
cbCalidad.setSelectedIndex(fframelegend.getQuality()); |
236 |
cbCalidad.setSize(179, 20); |
237 |
cbCalidad.setPreferredSize(new java.awt.Dimension(200, 20)); |
238 |
cbCalidad.setLocation(111, 103); |
239 |
} |
240 |
|
241 |
return cbCalidad;
|
242 |
} |
243 |
|
244 |
/**
|
245 |
* This method initializes bAceptar
|
246 |
*
|
247 |
* @return javax.swing.JButton
|
248 |
*/
|
249 |
private javax.swing.JButton getBAceptar() {
|
250 |
if (bAceptar == null) { |
251 |
bAceptar = new javax.swing.JButton();
|
252 |
bAceptar.setSize(79, 26); |
253 |
bAceptar.setText(PluginServices.getText(this, "Aceptar")); |
254 |
bAceptar.setLocation(77, 129); |
255 |
bAceptar.addActionListener(new java.awt.event.ActionListener() {
|
256 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
257 |
IFFrame[] frames=m_layout.getFFrames1();
|
258 |
for (int i = 0; i < frames.length; |
259 |
i++) { |
260 |
IFFrame f = frames[i];//(IFFrame) m_layout.getFFrames().get(i);
|
261 |
|
262 |
if (f instanceof FFrameView && |
263 |
(fframeview != null)) {
|
264 |
//if (f.getName().compareTo(m_projectView.getName())==0){
|
265 |
//Esto cambia para que la escala se calcule en fframeview y no en fframescalebar.
|
266 |
/// fframelegend.setFMap(((FFrameView)f).getFMap());
|
267 |
fframelegend.setName("Leyenda de " +
|
268 |
((FFrameView) f).toString()); |
269 |
|
270 |
///fframescalebar.setScaleView(((FFrameView)f).getScale());
|
271 |
//}
|
272 |
} |
273 |
} |
274 |
|
275 |
/*if (m_projectView!=null){
|
276 |
fframelegend.setLayers(m_projectView.getMapContext().getLayers());
|
277 |
}
|
278 |
*/
|
279 |
fframelegend.setViewing(cbVisualizacion.getSelectedIndex()); |
280 |
fframelegend.setQuality(cbCalidad.getSelectedIndex()); |
281 |
fframelegend.setBoundBox(FLayoutUtilities.toSheetRect( |
282 |
rect, m_layout.getAT())); |
283 |
PluginServices.getMDIManager().closeView(FFrameLegendDialog.this); |
284 |
m_layout.refresh(); |
285 |
isAcepted = true;
|
286 |
} |
287 |
}); |
288 |
} |
289 |
|
290 |
return bAceptar;
|
291 |
} |
292 |
|
293 |
/**
|
294 |
* This method initializes bCancelar
|
295 |
*
|
296 |
* @return javax.swing.JButton
|
297 |
*/
|
298 |
private javax.swing.JButton getBCancelar() {
|
299 |
if (bCancelar == null) { |
300 |
bCancelar = new javax.swing.JButton();
|
301 |
bCancelar.setSize(85, 26); |
302 |
bCancelar.setText(PluginServices.getText(this, "Cancelar")); |
303 |
bCancelar.setLocation(233, 129); |
304 |
bCancelar.addActionListener(new java.awt.event.ActionListener() {
|
305 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
306 |
PluginServices.getMDIManager().closeView(FFrameLegendDialog.this); |
307 |
} |
308 |
}); |
309 |
} |
310 |
|
311 |
return bCancelar;
|
312 |
} |
313 |
|
314 |
/**
|
315 |
* This method initializes liVistas
|
316 |
*
|
317 |
* @return javax.swing.JList
|
318 |
*/
|
319 |
private javax.swing.JList getLiVistas() {
|
320 |
if (liVistas == null) { |
321 |
ListViewModel listmodel = new ListViewModel();
|
322 |
|
323 |
//listmodel.addViews();
|
324 |
listmodel.addViewsforScale(m_layout); |
325 |
|
326 |
///ArrayList list = listmodel.getViews();
|
327 |
liVistas = new javax.swing.JList();
|
328 |
liVistas.setModel(listmodel); |
329 |
|
330 |
for (int i = 0; i < liVistas.getModel().getSize(); i++) { |
331 |
if (fframelegend.getFFrameView() != null) { |
332 |
fframeview = (FFrameView) liVistas.getModel().getElementAt(i); |
333 |
|
334 |
if (fframeview == fframelegend.getFFrameView()) {
|
335 |
liVistas.setSelectedIndex(i); |
336 |
} |
337 |
|
338 |
/*m_projectView=(ProjectView)liVistas.getModel().getElementAt(i);
|
339 |
if (m_projectView.getMapContext()==fframelegend.getFMap()){
|
340 |
liVistas.setSelectedIndex(i);
|
341 |
}
|
342 |
*/
|
343 |
} |
344 |
} |
345 |
|
346 |
liVistas.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
347 |
public void valueChanged( |
348 |
javax.swing.event.ListSelectionEvent e) { |
349 |
/* int selectInt=(int)e.getFirstIndex();
|
350 |
m_projectView=(ProjectView)liVistas.getModel().getElementAt(selectInt);
|
351 |
*/
|
352 |
int selectInt = (int) e.getFirstIndex(); |
353 |
fframeview = (FFrameView) liVistas.getModel() |
354 |
.getElementAt(selectInt); |
355 |
|
356 |
IFFrame[] frames=m_layout.getFFrames1();
|
357 |
for (int i = 0; i < frames.length; |
358 |
i++) { |
359 |
IFFrame f = frames[i];//(IFFrame) m_layout.getFFrames().get(i);
|
360 |
|
361 |
if (f instanceof FFrameView) { |
362 |
if (((FFrameView) f).getView() == fframeview.getView()) {
|
363 |
fframelegend.setFFrameView(fframeview); |
364 |
} |
365 |
} |
366 |
} |
367 |
|
368 |
//fframelegend.setFFrameView(fframeview);
|
369 |
} |
370 |
}); |
371 |
} |
372 |
|
373 |
return liVistas;
|
374 |
} |
375 |
|
376 |
/* (non-Javadoc)
|
377 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
378 |
*/
|
379 |
public ViewInfo getViewInfo() {
|
380 |
ViewInfo m_viewinfo = new ViewInfo(ViewInfo.MODALDIALOG);
|
381 |
m_viewinfo.setTitle(PluginServices.getText(this,
|
382 |
"propiedades_marco_leyenda"));
|
383 |
|
384 |
return m_viewinfo;
|
385 |
} |
386 |
|
387 |
/**
|
388 |
* @see com.iver.cit.gvsig.gui.layout.fframes.dialogs.IFFrameDialog#getIsAcepted()
|
389 |
*/
|
390 |
public boolean getIsAcepted() { |
391 |
return isAcepted;
|
392 |
} |
393 |
|
394 |
/**
|
395 |
* @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
|
396 |
*/
|
397 |
public void viewActivated() { |
398 |
} |
399 |
|
400 |
/**
|
401 |
* This method initializes bFuente
|
402 |
*
|
403 |
* @return javax.swing.JButton
|
404 |
*/
|
405 |
private javax.swing.JButton getBFuente() {
|
406 |
if (bFuente == null) { |
407 |
bFuente = new javax.swing.JButton();
|
408 |
bFuente.setSize(90, 23); |
409 |
bFuente.setText(PluginServices.getText(this, "fuente")); |
410 |
bFuente.setLocation(297, 89); |
411 |
bFuente.addActionListener(new java.awt.event.ActionListener() {
|
412 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
413 |
if (fframelegend.getFont() != null) { |
414 |
fframelegend.setFont(FontChooser.showDialog( |
415 |
PluginServices.getText(this,
|
416 |
"seleccion_fuente"),
|
417 |
fframelegend.getFont())); // fchoser=new FontChooser();
|
418 |
} else {
|
419 |
fframelegend.setFont(FontChooser.showDialog( |
420 |
PluginServices.getText(this,
|
421 |
"seleccion_fuente"), getFont()));
|
422 |
} |
423 |
} |
424 |
}); |
425 |
} |
426 |
|
427 |
return bFuente;
|
428 |
} |
429 |
} |