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