svn-document-layout / trunk / org.gvsig.app.document.layout.app / org.gvsig.app.document.layout.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / fframes / gui / dialogs / FFrameOverViewDialog.java @ 67
History | View | Annotate | Download (16.8 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.app.project.documents.layout.fframes.gui.dialogs; |
23 |
|
24 |
import java.awt.geom.Rectangle2D; |
25 |
import java.util.ArrayList; |
26 |
import java.util.List; |
27 |
|
28 |
import javax.swing.JList; |
29 |
|
30 |
import org.gvsig.andami.PluginServices; |
31 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
32 |
import org.gvsig.app.project.documents.layout.FLayoutUtilities; |
33 |
import org.gvsig.app.project.documents.layout.fframes.FFrameOverView; |
34 |
import org.gvsig.app.project.documents.layout.fframes.FFrameView; |
35 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
36 |
import org.gvsig.app.project.documents.layout.fframes.ListViewModel; |
37 |
import org.gvsig.app.project.documents.layout.fframes.ListWithoutOverViewModel; |
38 |
import org.gvsig.app.project.documents.layout.fframes.gui.JPRotation; |
39 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
40 |
|
41 |
/**
|
42 |
* Di?logo para a?adir una localizador al Layout.
|
43 |
*
|
44 |
* @author Vicente Caballero Navarro
|
45 |
*/
|
46 |
public class FFrameOverViewDialog extends AbstractFFrameDialog implements |
47 |
IFFrameDialog { |
48 |
|
49 |
private static final long serialVersionUID = 4912177399119383422L; |
50 |
private javax.swing.JPanel jContentPane = null; // @jve:decl-index=0:visual-constraint="37,10" |
51 |
private javax.swing.JLabel lVistas = null; |
52 |
private javax.swing.JScrollPane jScrollPane = null; |
53 |
private javax.swing.JList liVistas = null; // @jve:visual-info decl-index=0 |
54 |
// visual-constraint="98,-3"
|
55 |
private javax.swing.JButton bAceptar = null; |
56 |
private javax.swing.JButton bCancelar = null; |
57 |
private javax.swing.JLabel lCalidad = null; |
58 |
private javax.swing.JComboBox cbCalidad = null; |
59 |
private Rectangle2D rect = new Rectangle2D.Double(); |
60 |
private FFrameOverView fframeoverview = null; // new FFrameView(); |
61 |
private boolean isAcepted = false; |
62 |
private JPRotation rotation = null; |
63 |
private FFrameOverView newFFrameView;
|
64 |
private FFrameView fframeDependence;
|
65 |
private FFrameView fframeview;
|
66 |
|
67 |
/**
|
68 |
* This is the default constructor
|
69 |
*
|
70 |
* @param layoutPanel
|
71 |
* Referencia al Layout.
|
72 |
* @param fframe
|
73 |
* Referencia al fframe vista.
|
74 |
*/
|
75 |
public FFrameOverViewDialog(LayoutPanel layoutPanel, IFFrame frame) {
|
76 |
super(layoutPanel, frame);
|
77 |
fframeoverview = (FFrameOverView) frame; |
78 |
fframeDependence = (FFrameView) fframeoverview.getFFrameDependence()[0];
|
79 |
initialize(); |
80 |
} |
81 |
|
82 |
/**
|
83 |
* This method initializes this
|
84 |
*/
|
85 |
private void initialize() { |
86 |
this.setLayout(null); |
87 |
this.add(getJContentPane(), null); |
88 |
this.setSize(463, 222); |
89 |
|
90 |
getPRotation().setRotation(fframeoverview.getRotation()); |
91 |
} |
92 |
|
93 |
/**
|
94 |
* Inserta el rect?ngulo que ocupar? el fframe vista.
|
95 |
*
|
96 |
* @param r
|
97 |
* Rect?ngulo.
|
98 |
*/
|
99 |
public void setRectangle(Rectangle2D r) { |
100 |
rect.setRect(r); |
101 |
} |
102 |
|
103 |
/**
|
104 |
* This method initializes jContentPane
|
105 |
*
|
106 |
* @return javax.swing.JPanel
|
107 |
*/
|
108 |
private javax.swing.JPanel getJContentPane() {
|
109 |
if (jContentPane == null) { |
110 |
jContentPane = new javax.swing.JPanel();
|
111 |
jContentPane.setLayout(null);
|
112 |
jContentPane.add(getLVistas(), null);
|
113 |
jContentPane.add(getJScrollPane(), null);
|
114 |
jContentPane.add(getLCalidad(), null);
|
115 |
jContentPane.add(getCbCalidad(), null);
|
116 |
jContentPane.add(getbAceptar(), null);
|
117 |
jContentPane.add(getBCancelar(), null);
|
118 |
jContentPane.setSize(462, 184); |
119 |
jContentPane.setPreferredSize(new java.awt.Dimension(60, 60)); |
120 |
jContentPane.setLocation(0, 0); |
121 |
jContentPane.add(getPRotation(), null);
|
122 |
} |
123 |
|
124 |
return jContentPane;
|
125 |
} |
126 |
|
127 |
/**
|
128 |
* This method initializes lVistas
|
129 |
*
|
130 |
* @return javax.swing.JLabel
|
131 |
*/
|
132 |
private javax.swing.JLabel getLVistas() {
|
133 |
if (lVistas == null) { |
134 |
lVistas = new javax.swing.JLabel();
|
135 |
lVistas.setSize(85, 19); |
136 |
lVistas.setText(PluginServices.getText(this, "Vista")); |
137 |
lVistas.setLocation(10, 10); |
138 |
} |
139 |
|
140 |
return lVistas;
|
141 |
} |
142 |
|
143 |
/**
|
144 |
* This method initializes jScrollPane
|
145 |
*
|
146 |
* @return javax.swing.JScrollPane
|
147 |
*/
|
148 |
private javax.swing.JScrollPane getJScrollPane() {
|
149 |
if (jScrollPane == null) { |
150 |
jScrollPane = new javax.swing.JScrollPane();
|
151 |
jScrollPane.setViewportView(getLiVistas()); |
152 |
jScrollPane.setBounds(99, 8, 224, 64); |
153 |
jScrollPane.setPreferredSize(new java.awt.Dimension(250, 60)); |
154 |
} |
155 |
|
156 |
return jScrollPane;
|
157 |
} |
158 |
|
159 |
/**
|
160 |
* This method initializes liVistas
|
161 |
*
|
162 |
* @return javax.swing.JList
|
163 |
*/
|
164 |
private javax.swing.JList getLiVistas() {
|
165 |
if (liVistas == null) { |
166 |
ListViewModel listmodel = new ListWithoutOverViewModel();
|
167 |
|
168 |
listmodel.addViews(layoutPanel); |
169 |
|
170 |
// ================ Remove franmes with view = null
|
171 |
List<FFrameView> toremove = new ArrayList(); |
172 |
int sz = listmodel.getSize();
|
173 |
Object item = null; |
174 |
FFrameView item_fv = null;
|
175 |
for (int i=0; i<sz; i++) { |
176 |
item = listmodel.getElementAt(i); |
177 |
if (item instanceof FFrameView) { |
178 |
item_fv = (FFrameView) item; |
179 |
if (item_fv.getView() == null) { |
180 |
toremove.add(item_fv); |
181 |
} |
182 |
} |
183 |
} |
184 |
for (int i=0; i<toremove.size(); i++) { |
185 |
listmodel.removeFrameView(toremove.get(i)); |
186 |
} |
187 |
// ================
|
188 |
|
189 |
// /ArrayList list = listmodel.getViews();
|
190 |
liVistas = new javax.swing.JList();
|
191 |
liVistas.setModel(listmodel); |
192 |
|
193 |
for (int i = 0; i < liVistas.getModel().getSize(); i++) { |
194 |
if (fframeDependence != null) { |
195 |
fframeview = |
196 |
(FFrameView) liVistas.getModel().getElementAt(i); |
197 |
|
198 |
if (fframeview == fframeoverview.getFFrameDependence()[0]) { |
199 |
liVistas.setSelectedIndex(i); |
200 |
} |
201 |
|
202 |
/*
|
203 |
* m_projectView=(ProjectView)liVistas.getModel().getElementAt
|
204 |
* (i);
|
205 |
* if
|
206 |
* (m_projectView.getMapContext()==fframelegend.getFMap()){
|
207 |
* liVistas.setSelectedIndex(i);
|
208 |
* }
|
209 |
*/
|
210 |
} |
211 |
} |
212 |
|
213 |
liVistas |
214 |
.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
215 |
|
216 |
private int selectIndex = -1; |
217 |
|
218 |
public void valueChanged( |
219 |
javax.swing.event.ListSelectionEvent e) { |
220 |
IFFrame[] fframes =
|
221 |
layoutPanel.getLayoutContext().getFFrames(); |
222 |
int selectInt =
|
223 |
((JList) e.getSource()).getSelectedIndex();
|
224 |
if (selectInt != selectIndex) {
|
225 |
selectIndex = selectInt; |
226 |
if (selectIndex == -1) { |
227 |
return;
|
228 |
} |
229 |
fframeview = |
230 |
(FFrameView) liVistas.getModel().getElementAt( |
231 |
selectInt); |
232 |
|
233 |
for (int i = 0; i < fframes.length; i++) { |
234 |
IFFrame f = fframes[i]; |
235 |
|
236 |
if (f instanceof FFrameView) { |
237 |
if (((FFrameView) f).getView() == fframeview
|
238 |
.getView()) { |
239 |
fframeDependence = fframeview; |
240 |
// fframelegend
|
241 |
// .setFFrameDependence(fframeview);
|
242 |
} |
243 |
} |
244 |
} |
245 |
|
246 |
// fframelegend.setFFrameView(fframeview);
|
247 |
} |
248 |
} |
249 |
|
250 |
}); |
251 |
} |
252 |
|
253 |
return liVistas;
|
254 |
} |
255 |
|
256 |
// /**
|
257 |
// * This method initializes liVistas
|
258 |
// *
|
259 |
// * @return javax.swing.JList
|
260 |
// */
|
261 |
// private javax.swing.JList getLiVistas() {
|
262 |
// if (liVistas == null) {
|
263 |
// ListViewModel listmodel = new ListViewModel();
|
264 |
// listmodel.addViews();
|
265 |
// liVistas = new javax.swing.JList();
|
266 |
// liVistas.setModel(listmodel);
|
267 |
// for (int i = 0; i < liVistas.getModel().getSize(); i++) {
|
268 |
// if (fframeoverview.getMapContext() != null) {
|
269 |
//
|
270 |
// ProjectView pvaux= (ProjectView) liVistas.getModel()
|
271 |
// .getElementAt(i);
|
272 |
//
|
273 |
// if (pvaux.getMapContext().equals(fframeoverview.getMapContext())) {
|
274 |
// liVistas.setSelectedIndex(i);
|
275 |
// m_projectView= (ProjectView) liVistas.getModel()
|
276 |
// .getElementAt(i);
|
277 |
// }
|
278 |
// }
|
279 |
// }
|
280 |
//
|
281 |
// liVistas.addListSelectionListener(new
|
282 |
// javax.swing.event.ListSelectionListener() {
|
283 |
// private int selectIndex=-1;
|
284 |
// public void valueChanged(
|
285 |
// javax.swing.event.ListSelectionEvent e) {
|
286 |
// int selectInt = ((JList)e.getSource()).getSelectedIndex();
|
287 |
// if (selectInt!=selectIndex){
|
288 |
// selectIndex=selectInt;
|
289 |
// if (selectIndex==-1)
|
290 |
// return;
|
291 |
// m_projectView = (ProjectView) liVistas.getModel()
|
292 |
// .getElementAt(selectInt);
|
293 |
//
|
294 |
// // fframeview.setBoundBox(FLayoutUtilities.toSheetRect(
|
295 |
// // rect, m_layout.getAT()));
|
296 |
// // fframeview.setView(m_projectView);
|
297 |
// //
|
298 |
// // fframeview.setMapUnits(m_projectView.getMapContext()
|
299 |
// // .getViewPort()
|
300 |
// // .getMapUnits());
|
301 |
// }
|
302 |
// }
|
303 |
// });
|
304 |
// }
|
305 |
//
|
306 |
// return liVistas;
|
307 |
// }
|
308 |
|
309 |
/**
|
310 |
* This method initializes jButton
|
311 |
*
|
312 |
* @return javax.swing.JButton
|
313 |
*/
|
314 |
private javax.swing.JButton getbAceptar() {
|
315 |
if (bAceptar == null) { |
316 |
bAceptar = new javax.swing.JButton();
|
317 |
bAceptar.setSize(85, 26); |
318 |
bAceptar.setText(PluginServices.getText(this, "Aceptar")); |
319 |
bAceptar.setLocation(59, 136); |
320 |
bAceptar.addActionListener(new java.awt.event.ActionListener() {
|
321 |
|
322 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
323 |
try {
|
324 |
newFFrameView = (FFrameOverView) fframeoverview.clone(); |
325 |
newFFrameView.setBoundBox(FLayoutUtilities.toSheetRect( |
326 |
rect, layoutPanel.getLayoutControl().getAT())); |
327 |
newFFrameView.setRotation(getPRotation().getRotation()); |
328 |
if (fframeDependence != null) { |
329 |
// newFFrameView.setName(fframeDependence.getView().getName());
|
330 |
|
331 |
newFFrameView.setFFrameDependence(fframeDependence); |
332 |
newFFrameView.setView(fframeDependence.getView()); |
333 |
|
334 |
newFFrameView.setQuality(getCbCalidad() |
335 |
.getSelectedIndex()); |
336 |
newFFrameView.setBoundBox(FLayoutUtilities |
337 |
.toSheetRect(rect, layoutPanel |
338 |
.getLayoutControl().getAT())); |
339 |
|
340 |
/*
|
341 |
* for (int i=0;i<m_layout.getFFrames().size();i++){
|
342 |
* IFFrame
|
343 |
* fframe=(IFFrame)m_layout.getFFrames().get(i);
|
344 |
* if (fframe instanceof FFrameScaleBar){
|
345 |
* if
|
346 |
* (((FFrameScaleBar)fframe).getFFrameView()==fframeview
|
347 |
* ){
|
348 |
* if (getJComboBox().getSelectedIndex()!=0){
|
349 |
* ((FFrameScaleBar)fframe).setIsFixed(true);
|
350 |
* ((FFrameScaleBar)fframe).setScaleView(Long.parseLong
|
351 |
* (getJTextField().getText()));
|
352 |
* }else{
|
353 |
* ((FFrameScaleBar)fframe).setIsFixed(false);
|
354 |
* }
|
355 |
*
|
356 |
* }
|
357 |
* }
|
358 |
*
|
359 |
*
|
360 |
* }
|
361 |
*/
|
362 |
} |
363 |
} catch (CloneNotSupportedException e1) { |
364 |
LOG.error("It is not possible clonate the object", e);
|
365 |
} |
366 |
|
367 |
isAcepted = true;
|
368 |
|
369 |
// }else{
|
370 |
// isAcepted=false;
|
371 |
// }
|
372 |
PluginServices.getMDIManager().closeWindow( |
373 |
FFrameOverViewDialog.this); |
374 |
fframeoverview.refresh(); |
375 |
// m_layout.refresh();
|
376 |
} |
377 |
}); |
378 |
} |
379 |
|
380 |
return bAceptar;
|
381 |
} |
382 |
|
383 |
/**
|
384 |
* This method initializes bCancelar
|
385 |
*
|
386 |
* @return javax.swing.JButton
|
387 |
*/
|
388 |
private javax.swing.JButton getBCancelar() {
|
389 |
if (bCancelar == null) { |
390 |
bCancelar = new javax.swing.JButton();
|
391 |
bCancelar.setSize(85, 26); |
392 |
bCancelar.setText(PluginServices.getText(this, "Cancelar")); |
393 |
bCancelar.setLocation(199, 136); |
394 |
bCancelar.addActionListener(new java.awt.event.ActionListener() {
|
395 |
|
396 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
397 |
newFFrameView = null;
|
398 |
PluginServices.getMDIManager().closeWindow( |
399 |
FFrameOverViewDialog.this); |
400 |
} |
401 |
}); |
402 |
} |
403 |
|
404 |
return bCancelar;
|
405 |
} |
406 |
|
407 |
/**
|
408 |
* This method initializes lCalidad
|
409 |
*
|
410 |
* @return javax.swing.JLabel
|
411 |
*/
|
412 |
private javax.swing.JLabel getLCalidad() {
|
413 |
if (lCalidad == null) { |
414 |
lCalidad = new javax.swing.JLabel();
|
415 |
lCalidad.setSize(86, 16); |
416 |
lCalidad.setText(PluginServices.getText(this, "calidad")); |
417 |
lCalidad.setLocation(14, 112); |
418 |
} |
419 |
|
420 |
return lCalidad;
|
421 |
} |
422 |
|
423 |
/**
|
424 |
* This method initializes cbCalidad
|
425 |
*
|
426 |
* @return javax.swing.JComboBox
|
427 |
*/
|
428 |
private javax.swing.JComboBox getCbCalidad() {
|
429 |
if (cbCalidad == null) { |
430 |
// String[] s={"Presentaci?n","Borrador"};
|
431 |
cbCalidad = new javax.swing.JComboBox();
|
432 |
cbCalidad.setSize(220, 20); |
433 |
cbCalidad.addItem(PluginServices.getText(this, "presentacion")); |
434 |
cbCalidad.addItem(PluginServices.getText(this, "borrador")); |
435 |
cbCalidad.setSelectedIndex(fframeoverview.getQuality()); |
436 |
cbCalidad.setPreferredSize(new java.awt.Dimension(200, 20)); |
437 |
cbCalidad.setLocation(104, 112); |
438 |
} |
439 |
|
440 |
return cbCalidad;
|
441 |
} |
442 |
|
443 |
/*
|
444 |
* (non-Javadoc)
|
445 |
*
|
446 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
447 |
*/
|
448 |
public WindowInfo getWindowInfo() {
|
449 |
WindowInfo m_viewinfo = new WindowInfo(WindowInfo.MODALDIALOG);
|
450 |
|
451 |
// vi.setResizable(false);
|
452 |
m_viewinfo.setTitle(PluginServices.getText(this,
|
453 |
"propiedades_marco_localizador"));
|
454 |
|
455 |
return m_viewinfo;
|
456 |
} |
457 |
|
458 |
/**
|
459 |
* @see org.gvsig.app.project.documents.layout.fframes.gui.dialogs.IFFrameDialog#getIsAcepted()
|
460 |
*/
|
461 |
public boolean getIsAcepted() { |
462 |
return isAcepted;
|
463 |
} |
464 |
|
465 |
/**
|
466 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
|
467 |
*/
|
468 |
public void viewActivated() { |
469 |
} |
470 |
|
471 |
/**
|
472 |
* This method initializes rotation
|
473 |
*
|
474 |
* @return javax.swing.JPanel
|
475 |
*/
|
476 |
private JPRotation getPRotation() {
|
477 |
if (rotation == null) { |
478 |
rotation = new JPRotation();
|
479 |
rotation.setBounds(330, 30, 120, 130); |
480 |
} |
481 |
return rotation;
|
482 |
} |
483 |
|
484 |
public IFFrame getFFrame() {
|
485 |
return newFFrameView;
|
486 |
} |
487 |
|
488 |
public Object getWindowProfile() { |
489 |
return WindowInfo.DIALOG_PROFILE;
|
490 |
} |
491 |
|
492 |
} // @jve:decl-index=0:visual-constraint="10,10"
|