svn-document-layout / trunk / org.gvsig.app.document.layout2.app / org.gvsig.app.document.layout2.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / fframes / gui / dialogs / FFrameViewDialog.java @ 341
History | View | Annotate | Download (27.9 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.GridBagConstraints; |
25 |
import java.awt.GridBagLayout; |
26 |
import java.awt.Insets; |
27 |
import java.awt.event.ActionEvent; |
28 |
import java.awt.event.ActionListener; |
29 |
import java.awt.geom.Rectangle2D; |
30 |
|
31 |
import javax.swing.BorderFactory; |
32 |
import javax.swing.ButtonGroup; |
33 |
import javax.swing.JButton; |
34 |
import javax.swing.JCheckBox; |
35 |
import javax.swing.JLabel; |
36 |
import javax.swing.JList; |
37 |
import javax.swing.JOptionPane; |
38 |
import javax.swing.JPanel; |
39 |
import javax.swing.JRadioButton; |
40 |
import javax.swing.JTextField; |
41 |
|
42 |
import org.gvsig.andami.PluginsLocator; |
43 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
44 |
import org.gvsig.andami.ui.mdiManager.SingletonWindow; |
45 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
46 |
import org.gvsig.app.ApplicationLocator; |
47 |
import org.gvsig.app.ApplicationManager; |
48 |
import org.gvsig.app.project.ProjectManager; |
49 |
import org.gvsig.app.project.documents.layout.FLayoutUtilities; |
50 |
import org.gvsig.app.project.documents.layout.LayoutManager; |
51 |
import org.gvsig.app.project.documents.layout.fframes.FFrameGrid; |
52 |
import org.gvsig.app.project.documents.layout.fframes.FFrameView; |
53 |
import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
54 |
import org.gvsig.app.project.documents.layout.fframes.IFFrameUseFMap.SCALE_TYPE; |
55 |
import org.gvsig.app.project.documents.layout.fframes.ListViewModel; |
56 |
import org.gvsig.app.project.documents.layout.fframes.gui.EnvelopePanel; |
57 |
import org.gvsig.app.project.documents.layout.fframes.gui.JPRotation; |
58 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
59 |
import org.gvsig.app.project.documents.layout.gui.dialogs.FConfigLayoutDialog; |
60 |
import org.gvsig.app.project.documents.view.DefaultViewDocument; |
61 |
import org.gvsig.app.project.documents.view.ViewDocument; |
62 |
import org.gvsig.app.project.documents.view.ViewManager; |
63 |
import org.gvsig.fmap.geom.primitive.Envelope; |
64 |
import org.gvsig.gui.beans.swing.GridBagLayoutPanel; |
65 |
import org.gvsig.i18n.Messages; |
66 |
import org.gvsig.tools.swing.api.usability.UsabilitySwingManager; |
67 |
|
68 |
/**
|
69 |
* Dialog to add a view to the Layout document, by means of a FFrameView
|
70 |
*
|
71 |
* @author Vicente Caballero Navarro
|
72 |
* @author Cesar Martinez Izquierdo
|
73 |
*/
|
74 |
public class FFrameViewDialog extends AbstractFFrameDialog implements |
75 |
IFFrameDialog, SingletonWindow { |
76 |
|
77 |
private static final long serialVersionUID = -7223804566537544559L; |
78 |
|
79 |
private final LayoutManager layoutManager; |
80 |
private javax.swing.JLabel lViews = null; |
81 |
private javax.swing.JScrollPane jScrollPane = null; |
82 |
private javax.swing.JList liViews = null; // @jve:visual-info decl-index=0 |
83 |
// visual-constraint="98,-3"
|
84 |
private javax.swing.JCheckBox chbSyncLayers = null; |
85 |
private javax.swing.JButton bAceptar = null; |
86 |
private javax.swing.JButton bCancelar = null; |
87 |
private javax.swing.JLabel lCalidad = null; |
88 |
private javax.swing.JComboBox cbCalidad = null; |
89 |
private ViewDocument m_projectView = null; |
90 |
private Rectangle2D rect = new Rectangle2D.Double(); |
91 |
private FFrameView fframeview = null; |
92 |
private boolean isAcepted = false; |
93 |
private JPRotation rotation = null; |
94 |
private FFrameView newFFrameView = null; |
95 |
private javax.swing.JButton bGrid = null; |
96 |
private javax.swing.JCheckBox chbShowGrid = null; |
97 |
private JPanel pnlFirstRow = null; |
98 |
private JCheckBox chbSyncExtent = null; |
99 |
|
100 |
private WindowInfo windowInfo = null; |
101 |
|
102 |
private GridBagLayoutPanel pnlSyncGroup = null; |
103 |
private GridBagLayoutPanel pnlScaleTypeGroup = null; |
104 |
private ButtonGroup grpScaleType = null; |
105 |
private JRadioButton btnNormalScale = null; |
106 |
private JRadioButton btnFixedScale = null; |
107 |
private JRadioButton btnFixedExtent = null; |
108 |
private JTextField fldScale = null; |
109 |
private EnvelopePanel pnlExtent = null; |
110 |
private JButton btConfigView = null; |
111 |
private JPanel pnlScale = null; |
112 |
private ViewDocument createdView = null; |
113 |
|
114 |
|
115 |
/**
|
116 |
* This is the default constructor
|
117 |
*
|
118 |
* @param layoutPanel
|
119 |
* Referencia al Layout.
|
120 |
* @param fframe
|
121 |
* Referencia al fframe vista.
|
122 |
*/
|
123 |
public FFrameViewDialog(LayoutPanel layoutPanel, IFFrame frame) {
|
124 |
super(layoutPanel, frame);
|
125 |
fframeview = (FFrameView) frame; |
126 |
try {
|
127 |
newFFrameView = (FFrameView) fframeview.clone(); |
128 |
} catch (CloneNotSupportedException e) { |
129 |
LOG.error("It is not possible to clone the object", e);
|
130 |
} |
131 |
initComponents(); |
132 |
layoutManager = (LayoutManager) ProjectManager.getInstance()
|
133 |
.getDocumentManager("project.document.layout");
|
134 |
} |
135 |
|
136 |
/**
|
137 |
* This method initializes this
|
138 |
*/
|
139 |
private void initComponents() { |
140 |
this.setLayout(new GridBagLayout()); |
141 |
GridBagConstraints c = new GridBagConstraints(); |
142 |
Insets insets = new Insets(5, 5, 5, 5); |
143 |
int row = 0; |
144 |
c.gridx = 0;
|
145 |
c.gridy = row++; |
146 |
c.insets = new Insets(0,0,0,0); |
147 |
c.anchor = GridBagConstraints.LINE_START;
|
148 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
149 |
add(getFirstRowPnl(), c); |
150 |
c.insets = insets; |
151 |
c.gridx = 0;
|
152 |
c.gridy = row++; |
153 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
154 |
c.fill = GridBagConstraints.HORIZONTAL;
|
155 |
|
156 |
GridBagLayoutPanel pnl = getPnlSyncGroup(); |
157 |
pnl.addComponent(getChbSyncLayers(), insets); |
158 |
pnl.addComponent(getChbSyncExtent(), insets); |
159 |
add(pnl, c); |
160 |
|
161 |
getGrpScaleType().add(getBtnNormalScale()); |
162 |
getGrpScaleType().add(getBtnFixedScale()); |
163 |
getGrpScaleType().add(getBtnFixedExtent()); |
164 |
|
165 |
pnl = getPnlScaleTypeGroup(); |
166 |
pnl.addComponent(getBtnNormalScale(), insets); |
167 |
pnl.addComponent(getPnlScale(), insets); // pnlScale() contains btnFixedScale
|
168 |
pnl.addComponent(getBtnFixedExtent(), new Insets(5, 5, 0, 5)); |
169 |
pnl.addComponent(getPnlExtent(), GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5)); |
170 |
if (fframeview.getScaleType()==SCALE_TYPE.FIXED_SCALE) {
|
171 |
getBtnFixedScale().setSelected(true);
|
172 |
setScaleType(SCALE_TYPE.FIXED_SCALE); |
173 |
getChbSyncExtent().setEnabled(false);
|
174 |
} |
175 |
else if (fframeview.getScaleType()==SCALE_TYPE.FIXED_EXTENT) { |
176 |
getBtnFixedExtent().setSelected(true);
|
177 |
setScaleType(SCALE_TYPE.FIXED_EXTENT); |
178 |
getChbSyncExtent().setEnabled(false);
|
179 |
} |
180 |
else {
|
181 |
getBtnNormalScale().setSelected(true);
|
182 |
setScaleType(SCALE_TYPE.NORMAL); |
183 |
} |
184 |
|
185 |
c.gridy = row++; |
186 |
add(pnl, c); |
187 |
|
188 |
c.fill = GridBagConstraints.NONE;
|
189 |
c.gridx = 0;
|
190 |
c.gridy = row++; |
191 |
c.gridwidth = 1;
|
192 |
add(getLCalidad(), c); |
193 |
c.gridx = 1;
|
194 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
195 |
add(getCbCalidad(), c); |
196 |
c.gridx = 0;
|
197 |
c.gridy = row++; |
198 |
c.gridwidth = 1;
|
199 |
add(getChbShowGrid(), c); |
200 |
c.gridx = 1;
|
201 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
202 |
add(getBGrid(), c); |
203 |
JPanel acceptCancelPnl = new JPanel(new GridBagLayout()); |
204 |
c.anchor = GridBagConstraints.LINE_START;
|
205 |
c.gridx = 0;
|
206 |
c.gridy = 0;
|
207 |
c.gridwidth = 1;
|
208 |
acceptCancelPnl.add(getbAceptar(), c); |
209 |
c.gridx = 1;
|
210 |
acceptCancelPnl.add(getBCancelar(), c); |
211 |
c.gridx = 0;
|
212 |
c.gridy = row++; |
213 |
c.anchor = GridBagConstraints.LINE_END;
|
214 |
c.gridwidth = GridBagConstraints.REMAINDER;
|
215 |
add(acceptCancelPnl, c); |
216 |
} |
217 |
|
218 |
public void setRectangle(Rectangle2D r) { |
219 |
rect.setRect(r); |
220 |
} |
221 |
|
222 |
private JPanel getFirstRowPnl() { |
223 |
if (pnlFirstRow==null) { |
224 |
pnlFirstRow = new JPanel(new GridBagLayout()); |
225 |
GridBagConstraints c = new GridBagConstraints(); |
226 |
Insets insets = new Insets(5, 5, 5, 5); |
227 |
Insets insetsTop = new Insets(12, 5, 5, 5); |
228 |
c.gridx = 0;
|
229 |
c.gridy = 0;
|
230 |
c.insets = insetsTop; |
231 |
c.anchor = GridBagConstraints.PAGE_START;
|
232 |
pnlFirstRow.add(getLViews(), c); |
233 |
c.gridx = 1;
|
234 |
pnlFirstRow.add(getScrolledViewList(), c); |
235 |
c.insets = insets; |
236 |
c.gridx = 2;
|
237 |
c.gridheight = 2;
|
238 |
pnlFirstRow.add(getPRotation(), c); |
239 |
c.anchor = GridBagConstraints.LINE_END;
|
240 |
c.gridy = 1;
|
241 |
c.gridx = 1;
|
242 |
c.gridheight = 1;
|
243 |
pnlFirstRow.add(getBtnConfigView(), c); |
244 |
} |
245 |
return pnlFirstRow;
|
246 |
} |
247 |
|
248 |
|
249 |
private JButton getBtnConfigView() { |
250 |
UsabilitySwingManager manager = org.gvsig.tools.swing.api.ToolsSwingLocator.getUsabilitySwingManager(); |
251 |
btConfigView = manager.createJButton(Messages.getText("Configure_view"));
|
252 |
btConfigView.addActionListener(new ActionListener() { |
253 |
public void actionPerformed(ActionEvent e) { |
254 |
ViewDocument view = getSelectedView(); |
255 |
if (view!=null) { |
256 |
IWindow propWin = view.getPropertiesWindow(); |
257 |
ApplicationManager manager = ApplicationLocator.getManager(); |
258 |
manager.getUIManager().addWindow(propWin); |
259 |
} |
260 |
} |
261 |
}); |
262 |
return btConfigView;
|
263 |
} |
264 |
|
265 |
/**
|
266 |
* This method initializes lVistas
|
267 |
*
|
268 |
* @return javax.swing.JLabel
|
269 |
*/
|
270 |
private javax.swing.JLabel getLViews() {
|
271 |
if (lViews == null) { |
272 |
lViews = new javax.swing.JLabel();
|
273 |
lViews.setText(Messages.getText("Vista"));
|
274 |
} |
275 |
|
276 |
return lViews;
|
277 |
} |
278 |
|
279 |
/**
|
280 |
* This method initializes jScrollPane
|
281 |
*
|
282 |
* @return javax.swing.JScrollPane
|
283 |
*/
|
284 |
private javax.swing.JScrollPane getScrolledViewList() {
|
285 |
if (jScrollPane == null) { |
286 |
jScrollPane = new javax.swing.JScrollPane();
|
287 |
jScrollPane.setViewportView(getViewList()); |
288 |
jScrollPane.setPreferredSize(new java.awt.Dimension(300, 100)); |
289 |
} |
290 |
return jScrollPane;
|
291 |
} |
292 |
|
293 |
/**
|
294 |
* This method initializes liVistas
|
295 |
*
|
296 |
* @return javax.swing.JList
|
297 |
*/
|
298 |
private javax.swing.JList getViewList() {
|
299 |
if (liViews == null) { |
300 |
ListViewModel listmodel = new ListViewModel();
|
301 |
listmodel.addCreateNewViewObj(); |
302 |
|
303 |
if (listmodel.addViews()) {
|
304 |
JOptionPane.showMessageDialog(
|
305 |
ApplicationLocator.getManager().getRootComponent(), |
306 |
Messages.getText("_Some_views_excluded_from_list_because_have_editing_layers"),
|
307 |
Messages.getText("propiedades_marco_vista"),
|
308 |
JOptionPane.WARNING_MESSAGE);
|
309 |
} |
310 |
|
311 |
liViews = new javax.swing.JList();
|
312 |
liViews.setModel(listmodel); |
313 |
// default value: create new view
|
314 |
liViews.setSelectedIndex(0);
|
315 |
viewSelected(); |
316 |
|
317 |
for (int i = 1; i < liViews.getModel().getSize(); i++) { |
318 |
if (fframeview.getMapContext() != null) { |
319 |
|
320 |
DefaultViewDocument pvaux = |
321 |
(DefaultViewDocument) liViews.getModel().getElementAt( |
322 |
i); |
323 |
|
324 |
if (pvaux.getMapContext()
|
325 |
.equals(fframeview.getMapContext())) { |
326 |
liViews.setSelectedIndex(i); |
327 |
m_projectView = |
328 |
(DefaultViewDocument) liViews.getModel() |
329 |
.getElementAt(i); |
330 |
} |
331 |
} |
332 |
} |
333 |
|
334 |
liViews |
335 |
.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
336 |
public void valueChanged( |
337 |
javax.swing.event.ListSelectionEvent e) { |
338 |
FFrameViewDialog.this.viewSelected(); |
339 |
} |
340 |
}); |
341 |
} |
342 |
|
343 |
return liViews;
|
344 |
} |
345 |
|
346 |
protected void viewSelected() { |
347 |
ViewDocument v = getSelectedView(); |
348 |
if (v!=m_projectView) {
|
349 |
m_projectView = v; |
350 |
if (m_projectView!=null && m_projectView.getMapContext()!=null) { |
351 |
newFFrameView.setViewMapContext(m_projectView.getMapContext()); |
352 |
} |
353 |
else {
|
354 |
newFFrameView.setViewMapContext(null);
|
355 |
} |
356 |
} |
357 |
} |
358 |
|
359 |
protected ViewDocument getSelectedView() {
|
360 |
Object selected = this.getViewList().getSelectedValue(); |
361 |
ViewDocument view = null;
|
362 |
if (selected instanceof ViewDocument) { |
363 |
view = (ViewDocument) selected; |
364 |
} |
365 |
else if (selected==ListViewModel.CREATE_NEW_VIEW_OBJECT) { |
366 |
if (this.createdView==null) { |
367 |
view = createView(); |
368 |
} |
369 |
else {
|
370 |
view = this.createdView;
|
371 |
} |
372 |
} |
373 |
return view;
|
374 |
} |
375 |
|
376 |
private ViewDocument createView() {
|
377 |
ProjectManager projectManager = ApplicationLocator.getProjectManager(); |
378 |
ViewManager viewManager = (ViewManager) projectManager.getDocumentManager(ViewManager.TYPENAME); |
379 |
createdView = (ViewDocument) viewManager.createDocument(); |
380 |
ProjectManager.getInstance().getCurrentProject().addDocument(createdView); |
381 |
return createdView;
|
382 |
} |
383 |
|
384 |
private void deleteView() { |
385 |
ProjectManager projectManager = ApplicationLocator.getProjectManager(); |
386 |
ProjectManager.getInstance().getCurrentProject().removeDocument(createdView); |
387 |
createdView = null;
|
388 |
} |
389 |
|
390 |
|
391 |
/**
|
392 |
* This method initializes chbEnlaceVivo
|
393 |
*
|
394 |
* @return javax.swing.JCheckBox
|
395 |
*/
|
396 |
private javax.swing.JCheckBox getChbSyncLayers() {
|
397 |
if (chbSyncLayers == null) { |
398 |
chbSyncLayers = new javax.swing.JCheckBox();
|
399 |
chbSyncLayers.setText(Messages.getText("Synchronize_layers"));
|
400 |
chbSyncLayers.setSelected(fframeview.getLayerSynced()); |
401 |
chbSyncLayers.addActionListener(new ActionListener() { |
402 |
|
403 |
public void actionPerformed(ActionEvent e) { |
404 |
if (chbSyncLayers.isSelected()) {
|
405 |
JOptionPane.showMessageDialog(FFrameViewDialog.this,
|
406 |
Messages.getText("Warning_Enabling_layer_synchronization_will_discard_any_change_not_present_in_associated_view"),
|
407 |
Messages.getText("Warning_Layer_sync"),
|
408 |
JOptionPane.WARNING_MESSAGE);
|
409 |
} |
410 |
} |
411 |
|
412 |
}); |
413 |
} |
414 |
|
415 |
return chbSyncLayers;
|
416 |
} |
417 |
|
418 |
private javax.swing.JCheckBox getChbSyncExtent() {
|
419 |
if (chbSyncExtent==null) { |
420 |
chbSyncExtent = new javax.swing.JCheckBox();
|
421 |
chbSyncExtent.setText(Messages.getText("Synchronize_extents"));
|
422 |
chbSyncExtent.setSelected(fframeview.getExtentSynced()); |
423 |
} |
424 |
return chbSyncExtent;
|
425 |
} |
426 |
|
427 |
protected void disableChbSyncExtent() { |
428 |
getChbSyncExtent().setEnabled(false);
|
429 |
getChbSyncExtent().setToolTipText(Messages.getText("Extent_cant_be_synchronized_when_using_fixed_scale_or_fixed_extent"));
|
430 |
} |
431 |
|
432 |
protected void enableChbSyncExtent() { |
433 |
getChbSyncExtent().setEnabled(true);
|
434 |
getChbSyncExtent().setToolTipText(null);
|
435 |
} |
436 |
|
437 |
/**
|
438 |
* This method initializes jButton
|
439 |
*
|
440 |
* @return javax.swing.JButton
|
441 |
*/
|
442 |
private javax.swing.JButton getbAceptar() {
|
443 |
if (bAceptar == null) { |
444 |
bAceptar = new javax.swing.JButton();
|
445 |
bAceptar.setText(Messages.getText("Aceptar"));
|
446 |
bAceptar.addActionListener(new java.awt.event.ActionListener() {
|
447 |
|
448 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
449 |
newFFrameView.setBoundBox(FLayoutUtilities.toSheetRect( |
450 |
rect, layoutPanel.getLayoutControl().getAT())); |
451 |
newFFrameView.setRotation(getPRotation().getRotation()); |
452 |
newFFrameView.setHasToc(true);
|
453 |
newFFrameView.setLayerSynced(getChbSyncLayers() |
454 |
.isSelected()); |
455 |
newFFrameView.setExtentSynced((getChbSyncExtent().isEnabled()&&getChbSyncExtent().isSelected())); |
456 |
try {
|
457 |
if (getBtnFixedScale().isSelected()) {
|
458 |
Double d = Double.parseDouble(getFldScale().getText()); |
459 |
newFFrameView.setScaleType(SCALE_TYPE.FIXED_SCALE, d); |
460 |
} |
461 |
else if (getBtnFixedExtent().isSelected()) { |
462 |
Envelope envelope = getPnlExtent().getEnvelope(); |
463 |
if (envelope!=null) { |
464 |
newFFrameView.setScaleType(SCALE_TYPE.FIXED_EXTENT, envelope); |
465 |
} |
466 |
else {
|
467 |
newFFrameView.setScaleType(SCALE_TYPE.NORMAL); |
468 |
} |
469 |
} |
470 |
else {
|
471 |
newFFrameView.setScaleType(SCALE_TYPE.NORMAL); |
472 |
} |
473 |
} |
474 |
catch (Exception ex) { |
475 |
newFFrameView.setScaleType(SCALE_TYPE.NORMAL); |
476 |
} |
477 |
if (createdView!=null && createdView!=getSelectedView()) { // a view was created but later de-selected |
478 |
deleteView(); |
479 |
} |
480 |
if (m_projectView != null) { |
481 |
newFFrameView.setView(m_projectView); |
482 |
newFFrameView.setQuality(getCbCalidad() |
483 |
.getSelectedIndex()); |
484 |
if (newFFrameView.getGrid()!=null) { |
485 |
((FFrameGrid)newFFrameView.getGrid()).setFFrameDependence(newFFrameView); |
486 |
} |
487 |
newFFrameView.showGrid(getChbShowGrid() |
488 |
.isSelected()); |
489 |
newFFrameView.setBoundBox(FLayoutUtilities |
490 |
.toSheetRect(rect, layoutPanel |
491 |
.getLayoutControl().getAT())); |
492 |
} |
493 |
isAcepted = true;
|
494 |
ApplicationLocator.getManager().getUIManager().closeWindow( |
495 |
FFrameViewDialog.this); |
496 |
notifyDialogClosed(); |
497 |
PluginsLocator.getMainFrame().refreshControls(); |
498 |
layoutPanel.getLayoutControl().setDefaultTool(); |
499 |
} |
500 |
}); |
501 |
} |
502 |
|
503 |
return bAceptar;
|
504 |
} |
505 |
|
506 |
/**
|
507 |
* This method initializes bCancelar
|
508 |
*
|
509 |
* @return javax.swing.JButton
|
510 |
*/
|
511 |
private javax.swing.JButton getBCancelar() {
|
512 |
if (bCancelar == null) { |
513 |
bCancelar = new javax.swing.JButton();
|
514 |
bCancelar.setText(Messages.getText("Cancelar"));
|
515 |
bCancelar.addActionListener(new java.awt.event.ActionListener() {
|
516 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
517 |
if (createdView!=null) { |
518 |
deleteView(); |
519 |
} |
520 |
newFFrameView = null;
|
521 |
ApplicationLocator.getManager().getUIManager().closeWindow( |
522 |
FFrameViewDialog.this); |
523 |
notifyDialogClosed(); |
524 |
} |
525 |
}); |
526 |
} |
527 |
|
528 |
return bCancelar;
|
529 |
} |
530 |
|
531 |
/**
|
532 |
* This method initializes lCalidad
|
533 |
*
|
534 |
* @return javax.swing.JLabel
|
535 |
*/
|
536 |
private javax.swing.JLabel getLCalidad() {
|
537 |
if (lCalidad == null) { |
538 |
lCalidad = new javax.swing.JLabel();
|
539 |
lCalidad.setText(Messages.getText("calidad"));
|
540 |
} |
541 |
|
542 |
return lCalidad;
|
543 |
} |
544 |
|
545 |
/**
|
546 |
* This method initializes cbCalidad
|
547 |
*
|
548 |
* @return javax.swing.JComboBox
|
549 |
*/
|
550 |
private javax.swing.JComboBox getCbCalidad() {
|
551 |
if (cbCalidad == null) { |
552 |
// String[] s={"Presentaci?n","Borrador"};
|
553 |
cbCalidad = new javax.swing.JComboBox();
|
554 |
cbCalidad.addItem(Messages.getText("presentacion"));
|
555 |
cbCalidad.addItem(Messages.getText("borrador"));
|
556 |
cbCalidad.setSelectedIndex(fframeview.getQuality()); |
557 |
} |
558 |
|
559 |
return cbCalidad;
|
560 |
} |
561 |
|
562 |
/*
|
563 |
* (non-Javadoc)
|
564 |
*
|
565 |
* @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
566 |
*/
|
567 |
public WindowInfo getWindowInfo() {
|
568 |
if (windowInfo==null) { |
569 |
windowInfo = new WindowInfo(WindowInfo.RESIZABLE);
|
570 |
windowInfo.setHeight(620);
|
571 |
windowInfo.setWidth(600);
|
572 |
windowInfo.setTitle(Messages.getText( |
573 |
"propiedades_marco_vista"));
|
574 |
} |
575 |
return windowInfo;
|
576 |
} |
577 |
|
578 |
/**
|
579 |
* @see org.gvsig.app.project.documents.layout.fframes.gui.dialogs.IFFrameDialog#getIsAcepted()
|
580 |
*/
|
581 |
public boolean getIsAcepted() { |
582 |
return isAcepted;
|
583 |
} |
584 |
|
585 |
/**
|
586 |
* This method initializes rotation
|
587 |
*
|
588 |
* @return javax.swing.JPanel
|
589 |
*/
|
590 |
private JPRotation getPRotation() {
|
591 |
if (rotation == null) { |
592 |
rotation = new JPRotation();
|
593 |
rotation.setRotation(fframeview.getRotation()); |
594 |
} |
595 |
return rotation;
|
596 |
} |
597 |
|
598 |
public IFFrame getFFrame() {
|
599 |
return newFFrameView;
|
600 |
} |
601 |
|
602 |
/**
|
603 |
* This method initializes bGrid
|
604 |
*
|
605 |
* @return javax.swing.JButton
|
606 |
*/
|
607 |
private JButton getBGrid() { |
608 |
if (bGrid == null) { |
609 |
bGrid = new JButton(); |
610 |
bGrid.setText(Messages.getText("configurar"));
|
611 |
bGrid.addActionListener(new java.awt.event.ActionListener() {
|
612 |
|
613 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
614 |
FFrameGrid fframeGrid = null;
|
615 |
|
616 |
if (newFFrameView.getGrid() != null) { |
617 |
fframeGrid = (FFrameGrid) newFFrameView.getGrid(); |
618 |
} else {
|
619 |
fframeGrid = (FFrameGrid) layoutManager.createFrame(FFrameGrid.PERSISTENCE_DEFINITION_NAME); |
620 |
fframeGrid.setFFrameDependence(fframeview); |
621 |
} |
622 |
|
623 |
FFrameGridDialog fframeGridDialog = |
624 |
(FFrameGridDialog)layoutManager.createFFrameDialog(fframeGrid, layoutPanel); |
625 |
fframeGridDialog.setFFrameView(newFFrameView); |
626 |
|
627 |
if (fframeGridDialog != null) { |
628 |
ApplicationLocator.getManager().getUIManager().addWindow(fframeGridDialog); |
629 |
} |
630 |
IFFrame newFrame = fframeGridDialog.getFFrame(); |
631 |
if (newFrame != null) { |
632 |
newFFrameView.setGrid(newFrame); |
633 |
} |
634 |
} |
635 |
}); |
636 |
} |
637 |
return bGrid;
|
638 |
} |
639 |
|
640 |
/**
|
641 |
* This method initializes chbShowGrid
|
642 |
*
|
643 |
* @return javax.swing.JCheckBox
|
644 |
*/
|
645 |
private JCheckBox getChbShowGrid() { |
646 |
if (chbShowGrid == null) { |
647 |
chbShowGrid = new JCheckBox(); |
648 |
chbShowGrid.setSelected(fframeview.isShowGrid()); |
649 |
chbShowGrid.setText(Messages.getText("Show_grid"));
|
650 |
chbShowGrid.addActionListener(new ActionListener() { |
651 |
|
652 |
public void actionPerformed(ActionEvent e) { |
653 |
if (e.getSource() instanceof JCheckBox) { |
654 |
JCheckBox cb = (JCheckBox) e.getSource(); |
655 |
if (cb.isSelected()) {
|
656 |
if (newFFrameView.getGrid()==null) { |
657 |
// ensure we have a non-null grid if the checkbox is selected
|
658 |
FFrameGrid fframeGrid = (FFrameGrid) layoutManager.createFrame(FFrameGrid.PERSISTENCE_DEFINITION_NAME); |
659 |
fframeGrid.setFFrameDependence(newFFrameView); |
660 |
newFFrameView.setGrid(fframeGrid); |
661 |
} |
662 |
} |
663 |
} |
664 |
} |
665 |
}); |
666 |
} |
667 |
return chbShowGrid;
|
668 |
} |
669 |
|
670 |
private GridBagLayoutPanel getPnlSyncGroup() {
|
671 |
if (pnlSyncGroup ==null) { |
672 |
pnlSyncGroup = new GridBagLayoutPanel();
|
673 |
pnlSyncGroup.setBorder(BorderFactory.createTitledBorder(Messages.getText("Synchronization_of_the_view_and_the_frame_view"))); |
674 |
} |
675 |
return pnlSyncGroup;
|
676 |
} |
677 |
|
678 |
private GridBagLayoutPanel getPnlScaleTypeGroup() {
|
679 |
if (pnlScaleTypeGroup ==null) { |
680 |
pnlScaleTypeGroup = new GridBagLayoutPanel();
|
681 |
pnlScaleTypeGroup.setBorder(BorderFactory.createTitledBorder(Messages.getText("Fixed_scale_and_extent"))); |
682 |
} |
683 |
return pnlScaleTypeGroup;
|
684 |
} |
685 |
|
686 |
private ButtonGroup getGrpScaleType() { |
687 |
if (grpScaleType==null) { |
688 |
grpScaleType = new ButtonGroup(); |
689 |
} |
690 |
return grpScaleType;
|
691 |
} |
692 |
|
693 |
private JRadioButton getBtnNormalScale() { |
694 |
if (btnNormalScale==null) { |
695 |
btnNormalScale = new JRadioButton(Messages.getText("Non_fixed")); |
696 |
btnNormalScale.addActionListener(new ActionListener() { |
697 |
public void actionPerformed(ActionEvent e) { |
698 |
FFrameViewDialog.this.setScaleType(SCALE_TYPE.NORMAL); |
699 |
FFrameViewDialog.this.enableChbSyncExtent(); |
700 |
} |
701 |
}); |
702 |
} |
703 |
return btnNormalScale;
|
704 |
} |
705 |
|
706 |
private JRadioButton getBtnFixedScale() { |
707 |
if (btnFixedScale==null) { |
708 |
btnFixedScale = new JRadioButton(Messages.getText("Fixed_scale")); |
709 |
btnFixedScale.addActionListener(new ActionListener() { |
710 |
public void actionPerformed(ActionEvent e) { |
711 |
FFrameViewDialog.this.setScaleType(SCALE_TYPE.FIXED_SCALE); |
712 |
FFrameViewDialog.this.disableChbSyncExtent(); |
713 |
} |
714 |
}); |
715 |
} |
716 |
return btnFixedScale;
|
717 |
} |
718 |
|
719 |
private JPanel getPnlScale() { |
720 |
if (pnlScale==null) { |
721 |
pnlScale = new JPanel(new GridBagLayout()); |
722 |
GridBagConstraints c = new GridBagConstraints(); |
723 |
c.insets = new Insets(0, 0, 0, 0); |
724 |
c.gridx = 0;
|
725 |
pnlScale.add(getBtnFixedScale()); |
726 |
c.anchor = GridBagConstraints.LINE_START;
|
727 |
c.gridx = 1;
|
728 |
c.insets = new Insets(0, 25, 0, 5); |
729 |
c.anchor = GridBagConstraints.LINE_END;
|
730 |
pnlScale.add(getLblScale(), c); |
731 |
c.gridx = 2;
|
732 |
c.insets = new Insets(0, 5, 0, 5);; |
733 |
c.anchor = GridBagConstraints.LINE_START;
|
734 |
pnlScale.add(getFldScale(), c); |
735 |
} |
736 |
return pnlScale;
|
737 |
} |
738 |
|
739 |
private JTextField getFldScale() { |
740 |
if (fldScale==null) { |
741 |
fldScale = new JTextField(8); |
742 |
if (fframeview!=null && |
743 |
fframeview.getMapContext()!=null &&
|
744 |
fframeview.getMapContext().getViewPort().getEnvelope()!=null) {
|
745 |
fldScale.setText(Long.toString(fframeview.getMapContext().getScaleView()));
|
746 |
} |
747 |
} |
748 |
return fldScale;
|
749 |
} |
750 |
|
751 |
private JLabel getLblScale() { |
752 |
return new JLabel(Messages.getText("1__")); |
753 |
} |
754 |
|
755 |
private JRadioButton getBtnFixedExtent() { |
756 |
if (btnFixedExtent==null) { |
757 |
btnFixedExtent = new JRadioButton(Messages.getText("Fixed_extent")); |
758 |
btnFixedExtent.addActionListener(new ActionListener() { |
759 |
public void actionPerformed(ActionEvent e) { |
760 |
FFrameViewDialog.this.setScaleType(SCALE_TYPE.FIXED_EXTENT); |
761 |
FFrameViewDialog.this.disableChbSyncExtent(); |
762 |
} |
763 |
}); |
764 |
} |
765 |
return btnFixedExtent;
|
766 |
} |
767 |
|
768 |
private EnvelopePanel getPnlExtent() {
|
769 |
if (pnlExtent==null) { |
770 |
pnlExtent = new EnvelopePanel();
|
771 |
if (fframeview!=null && |
772 |
fframeview.getMapContext()!=null &&
|
773 |
fframeview.getMapContext().getViewPort().getEnvelope()!=null) {
|
774 |
pnlExtent.setEnvelope(fframeview.getMapContext().getViewPort().getEnvelope()); |
775 |
} |
776 |
} |
777 |
return pnlExtent;
|
778 |
} |
779 |
|
780 |
public Object getWindowProfile() { |
781 |
return WindowInfo.DIALOG_PROFILE;
|
782 |
} |
783 |
|
784 |
public Object getWindowModel() { |
785 |
return fframeview;
|
786 |
} |
787 |
|
788 |
protected void setScaleType(SCALE_TYPE type) { |
789 |
if (type==SCALE_TYPE.NORMAL) {
|
790 |
getFldScale().setEditable(false);
|
791 |
getFldScale().setEnabled(false);
|
792 |
getPnlExtent().setEditable(false);
|
793 |
getPnlExtent().setEnabled(false);
|
794 |
} |
795 |
else if (type==SCALE_TYPE.FIXED_SCALE) { |
796 |
getFldScale().setEditable(true);
|
797 |
getFldScale().setEnabled(true);
|
798 |
getPnlExtent().setEditable(false);
|
799 |
getPnlExtent().setEnabled(false);
|
800 |
} |
801 |
else if (type==SCALE_TYPE.FIXED_EXTENT) { |
802 |
getFldScale().setEditable(false);
|
803 |
getFldScale().setEnabled(false);
|
804 |
getPnlExtent().setEditable(true);
|
805 |
getPnlExtent().setEnabled(true);
|
806 |
} |
807 |
|
808 |
} |
809 |
|
810 |
protected SCALE_TYPE getSelectedScaleType() {
|
811 |
if (getBtnFixedScale().isSelected()) {
|
812 |
return SCALE_TYPE.FIXED_SCALE;
|
813 |
} |
814 |
else if (getBtnFixedExtent().isSelected()) { |
815 |
return SCALE_TYPE.FIXED_EXTENT;
|
816 |
} |
817 |
return SCALE_TYPE.NORMAL;
|
818 |
} |
819 |
|
820 |
} // @jve:decl-index=0:visual-constraint="10,10"
|